repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
starsoft35/quark
src/component/index.ts
export * from './StyledComponents'; export { default as SectionStateComponent } from './SectionState'; export { default as MobileWrapper } from './MobileWrapper'; export { default as ListWrapper } from './ListWrapper';
starsoft35/quark
src/store/app/action.ts
<gh_stars>0 import { SectionStateEnum } from '@vdfor/util'; import { Dispatch } from 'redux'; import { IAppRouteState } from './type'; import { SET_APP_ROUTE_STATE, SET_APP_UI_STATUS, ID } from './constant'; import { GetStateFunc } from '..'; // 设置全局页面状态 const setAppUIStatus = ({ status, routeId }: { status: SectionSt...
starsoft35/quark
src/util/vconsole.ts
<reponame>starsoft35/quark export default () => { if (process.env.NODE_ENV === 'development') { import('vconsole').then(m => { const VConsole = m.default; const vconsole = new VConsole(); console.info(`vconsole init, version is ${vconsole.version}`); }); } };
starsoft35/quark
src/asset/image/index.ts
<filename>src/asset/image/index.ts // 如需将 svg 图标作为 React 组件导入,该svg文件的名称应以 -icon.svg 结尾 export { default as tabbarHomeImg } from './tabbar-home.png'; export { default as tabbarHomeSelectedImg } from './tabbar-home-selected.png'; export { default as tabbarAboutImg } from './tabbar-about.png'; export { default as tabbarAb...
starsoft35/quark
src/store/app/constant.ts
<gh_stars>0 export const SET_APP_ROUTE_STATE = 'SET_APP_ROUTE_STATE'; export const SET_APP_UI_STATUS = 'SET_APP_UI_STATUS'; export const APP_REDUCER_NAME = 'APP_REDUCER'; export const ID = 'APP';
starsoft35/quark
src/store/list-demo/action.ts
import { Dispatch } from 'redux'; import { LoadActionEnum } from '@vdfor/util'; import { loadListApi } from './api'; import { ID, LOAD_LIST_REQUEST_TASK_KEY } from './constant'; import { appAction, getQuxListAction, GetStateFunc, APP_CONSTANT } from '..'; const getLoadListAction = (status = '') => getQuxListAction({...
starsoft35/quark
config/routes.ts
import { IRoute } from 'umi'; const routes: IRoute[] = [ { path: '/', exact: true, redirect: '/welcome', }, { path: '/welcome', component: '@/page/Welcome', title: '欢迎', meta: { id: 'welcome', }, }, { path: '/home', component: '@/page/Home', title: '主页', ...
starsoft35/quark
src/constant/httpCode.ts
// 自定义httpCode export const cancelHttpCode = 1001; // 请求取消
starsoft35/quark
src/constant/env.ts
<reponame>starsoft35/quark export const API_BASE_URL = process.env.REACT_APP_API_BASE_URL;
starsoft35/quark
src/page/ListDemo/index.tsx
<filename>src/page/ListDemo/index.tsx import React, { useEffect, useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { createSelector } from 'reselect'; import { Tabs, ListView, PullToRefresh } from 'antd-mobile'; import { LoadActionEnum } from '@vdfor/util'; import { Spin } from '@v...
starsoft35/quark
src/index.tsx
<filename>src/index.tsx import React, { PropsWithChildren } from 'react'; import { Provider } from 'react-redux'; import { ConfigProvider } from '@vdfor/react-component'; import { store } from '@/store'; import { vconsoleInit } from '@/util'; vconsoleInit(); export default ({ children }: PropsWithChildren<any...
starsoft35/quark
src/util/request/errorHandler.ts
import { notification } from 'antd'; import { Toast } from 'antd-mobile'; import { isMobileDevice } from '..'; /** * 错误处理 * 若需要判断是否为请求超时,参考 https://github.com/umijs/umi-request/issues/14 * @params error ResponseError * @params showErrorNotification boolean 是否弹出错误通知 */ const errorHandler = ({ error, showErrorN...
starsoft35/quark
src/store/rootReducer.ts
import { combineReducers, Reducer } from 'redux'; import { appReducer, APP_CONSTANT } from './app'; import { LIST_DEMO_CONSTANT, listDemoReducer } from './list-demo'; import { IRootReducer } from './type'; export default combineReducers({ [APP_CONSTANT.ID]: appReducer, [LIST_DEMO_CONSTANT.ID]: listDemoReducer, }) ...
starsoft35/quark
typings.d.ts
declare module '*.css'; declare module '*.less'; declare module '*.png'; declare module '*-icon.svg'; declare module 'vconsole'; declare module 'postcss-px-to-viewport'; declare module 'less-var-parse';
starsoft35/quark
src/store/app/reducer.ts
import { AnyAction, combineReducers, Reducer } from 'redux'; import { produce } from 'immer'; import { SectionStateEnum } from '@vdfor/util'; import { IAppRouteState, IAppState } from './type'; import { SET_APP_ROUTE_STATE, SET_APP_UI_STATUS } from './constant'; const routeStateReducer = ( state: IAppRouteState = { ...
starsoft35/quark
src/util/request/request-tasks.ts
export const setRequestTaskToGlobalData = (key: string, val: any) => { if (!window) { return; } const tasks = (window as any).requestTasks; if (!tasks) { (window as any).requestTasks = { [key]: val, }; return; } (window as any).requestTasks[key] = val; }; export const getRequestTaskFr...
starsoft35/quark
src/store/list-demo/constant.ts
<reponame>starsoft35/quark<filename>src/store/list-demo/constant.ts export const ID = 'LIST_DEMO'; export const LOAD_LIST_REQUEST_TASK_KEY = 'LIST_DEMO_LOAD_LIST_REQUEST_TASK';
starsoft35/quark
src/component/SectionState.tsx
<reponame>starsoft35/quark import React, { CSSProperties, memo } from 'react'; import styled from 'styled-components/macro'; import { errorStateImg, emptyStateImg } from '@/asset'; import { pxTransform } from '@/util'; import { StyledCenter } from './StyledComponents'; interface ISectionStateProps { style?: C...
starsoft35/quark
src/store/base/list/index.ts
<reponame>starsoft35/quark export * from './action'; export { default as getQuxListReducer } from './reducer'; export { IQuxListState, IListBasicState } from './type';
starsoft35/quark
src/util/request/request.ts
import { request, RequestConfig } from 'umi'; import AbortController from 'abort-controller'; import { cancelHttpCode } from '@/constant'; import { setRequestTaskToGlobalData, removeRequestTaskFromGlobalData, handleRequestError, } from '..'; interface IRequestParams extends RequestConfig { skipErrorHandler?: b...
starsoft35/quark
src/store/base/list/constant.ts
<filename>src/store/base/list/constant.ts export const RESET_LIST_REQUEST = '_QUX_LIST_RESET_LIST_REQUEST'; export const RESET_LIST_SUCCESS = '_QUX_LIST_RESET_LIST_SUCCESS'; export const RESET_LIST_FAIL = '_QUX_LIST_RESET_LIST_FAIL'; export const REFRESH_LIST_REQUEST = '_QUX_LIST_REFRESH_LIST_REQUEST'; export const REF...
starsoft35/quark
src/util/request/index.ts
export * from './request-tasks'; export { default as request } from './request'; export { default as handleRequestError } from './errorHandler';
js-n/clock-util
index.test.ts
<reponame>js-n/clock-util import 'mocha' import { expect } from 'chai' import { systemClock, constantClock, Clock } from 'clock' import { ClockUtil } from './.' import { stub, SinonStub } from 'sinon' describe('ClockUtils', () => { const epochClock = constantClock() let testClock: (time: number) => Clock befo...
js-n/clock-util
index.ts
<filename>index.ts import {Clock, systemClock} from 'clock' /** * Returns a Date object from the current clock time */ export function getDate(clock: Clock): Date { return new Date(clock.now()) } /** * Returns the number of seconds since the Unix epoch */ export function getSSE(clock: Clock): number { return ...
ChargeIn/SPDF
src/app/libs/fontkit/tables/JSTF.ts
<reponame>ChargeIn/SPDF import r from 'restructure'; import { ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device, } from './opentype'; import { GPOSLookup } from './GPOS'; const JstfGSUBModList = new r.Array(r.uint16, r.uint16); const JstfPriority = new r.Struct({ shrinkageEnableGSUB: new r...
ChargeIn/SPDF
src/app/libs/pdf/font/embedded.ts
/* * Original PDFKit - embedded.js * Translated to ts by <NAME> */ import { PDFFont } from '../font'; import { PDFDocument } from '../document'; import { BBOX, Font, GlyphPosition } from 'fontkit'; import { DescFontRefData, FontGlyphPosition } from '../types'; const toHex = function (num: number) { return `0000${...
ChargeIn/SPDF
src/app/libs/pdf/font/afm.ts
/* * Original PDFKit - afm.js * Translated to ts by <NAME> */ import { fs } from '../../fs'; const WIN_ANSI_MAP = { 402: 131, 8211: 150, 8212: 151, 8216: 145, 8217: 146, 8218: 130, 8220: 147, 8221: 148, 8222: 132, 8224: 134, 8225: 135, 8226: 149, 8230: 133, 8364: 128, 8240: 137, 8249...
ChargeIn/SPDF
src/app/libs/pdf/data.ts
<gh_stars>0 /* * Original PDFKit - data.js * Translated to ts by <NAME> */ export class Data { private readonly _data: any[]; private _pos: number; private _length: number; constructor(data = []) { this._data = data; this._pos = 0; this._length = this._data.length; } readByte() { return...
ChargeIn/SPDF
src/app/libs/fontkit/tables/gvar.ts
<filename>src/app/libs/fontkit/tables/gvar.ts import r from 'restructure'; const shortFrac = new r.Fixed(16, 'BE', 14); class Offset { static decode(stream, parent) { // In short format, offsets are multiplied by 2. // This doesn't seem to be documented by Apple, but it // is implemented this way in Fre...
ChargeIn/SPDF
src/app/libs/fontkit/tables/COLR.ts
<reponame>ChargeIn/SPDF import r from 'restructure'; const LayerRecord = new r.Struct({ gid: r.uint16, // Glyph ID of layer glyph (must be in z-order from bottom to top). paletteIndex: r.uint16, // Index value to use in the appropriate palette. This value must }); // be less than numPaletteEntries in the CPAL tabl...
ChargeIn/SPDF
src/app/libs/pdf/images.ts
/* * Original PDFKit - images.js * Translated to ts by <NAME> */ import { JPEG } from './image/lib/jpeg'; import { PNG } from './image/lib/png-js/png'; import { PNGImage } from './image/lib/png'; import { fs } from '../fs'; export class PDFImage { static open(src, label) { let data; if (Buffer.isBuffer(sr...
ChargeIn/SPDF
src/app/libs/fontkit/glyph/TTFGlyph.ts
<gh_stars>0 import Glyph from './Glyph'; import Path from './Path'; import BBox from './BBox'; import r from 'restructure'; // The header for both simple and composite glyphs const GlyfHeader = new r.Struct({ numberOfContours: r.int16, // if negative, this is a composite glyph xMin: r.int16, yMin: r.int16, xMa...
ChargeIn/SPDF
src/app/libs/pdf/object.ts
/* * PDFObject - converts JavaScript types into their corresponding PDF types. * By <NAME> * Translated to ts by <NAME> */ import { PDFAbstractReference } from './reference'; import { PDFTree } from './trees'; const pad = (str: number, length: number) => (Array(length + 1).join('0') + str).slice(-length); const...
ChargeIn/SPDF
src/app/libs/pdf/types.ts
/* * Copyright (c) by <NAME> */ import { ReadableOptions } from 'stream'; import { PDFReference } from './reference'; import { PDFNameTree, PDFNumberTree } from './trees'; import { PDFStructureElement } from './structure_element'; import { GlyphPosition } from 'fontkit'; export interface PDFOptions extends ReadableO...
ChargeIn/SPDF
src/app/libs/pdf/mixins/attachments.ts
/* * Original PDFKit - attachments.js * Translated to ts by <NAME> */ // Moved the content directly to the PDFDocument class since mixins are badly supported in ts. // TODO: Rework content to mixins /** check two embedded file metadata objects for equality */ export function isEqual(a, b) { return ( a.Subtyp...
ChargeIn/SPDF
src/app/libs/pdf/structure_element.ts
/* * Original PDFKit - structure_element.js * By <NAME> * Translated to ts by <NAME> */ import { PDFDocument } from './document'; import { PDFReference } from './reference'; import { PDFStructureContent } from './structure_content'; export class PDFStructureElement { private _document: PDFDocument; private _a...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/OTProcessor.ts
<reponame>ChargeIn/SPDF import GlyphIterator from './GlyphIterator'; import * as Script from '../layout/Script'; const DEFAULT_SCRIPTS = ['DFLT', 'dflt', 'latn']; export default class OTProcessor { constructor(font, table) { this.font = font; this.table = table; this.script = null; this.scriptTag =...
ChargeIn/SPDF
src/app/libs/fontkit/aat/AATFeatureMap.ts
// see https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html // and /System/Library/Frameworks/CoreText.framework/Versions/A/Headers/SFNTLayoutTypes.h on a Mac const featuresMap = { allTypographicFeatures: { code: 0, exclusive: false, allTypeFeatures: 0, }, ligatures: { c...
ChargeIn/SPDF
src/app/libs/fontkit/tables/WOFFDirectory.ts
<filename>src/app/libs/fontkit/tables/WOFFDirectory.ts import r from 'restructure'; export const WOFFDirectoryEntry = new r.Struct({ tag: new r.String(4), offset: new r.Pointer(r.uint32, 'void', { type: 'global' }), compLength: r.uint32, length: r.uint32, origChecksum: r.uint32, }); export const WOFFDirecto...
ChargeIn/SPDF
src/app/libs/fontkit/DFont.ts
<reponame>ChargeIn/SPDF import r from 'restructure'; import TTFFont from './TTFFont'; const DFontName = new r.String(r.uint8); const DFontData = new r.Struct({ len: r.uint32, buf: new r.Buffer('len'), }); const Ref = new r.Struct({ id: r.uint16, nameOffset: r.int16, attr: r.uint8, dataOffset: r.uint24, ...
ChargeIn/SPDF
src/app/libs/fontkit/tables/bsln.ts
import r from 'restructure'; import { LookupTable } from './aat'; const BslnSubtable = new r.VersionedStruct('format', { 0: { // Distance-based, no mapping deltas: new r.Array(r.int16, 32), }, 1: { // Distance-based, with mapping deltas: new r.Array(r.int16, 32), mappingData: new LookupTable...
ChargeIn/SPDF
src/app/libs/fontkit/tables/sbix.ts
<filename>src/app/libs/fontkit/tables/sbix.ts import r from 'restructure'; const ImageTable = new r.Struct({ ppem: r.uint16, resolution: r.uint16, imageOffsets: new r.Array( new r.Pointer(r.uint32, 'void'), (t) => t.parent.parent.maxp.numGlyphs + 1 ), }); // This is the Apple sbix table, used by the "...
ChargeIn/SPDF
src/app/libs/pdf/security.ts
/* PDFSecurity - represents PDF security settings By <NAME> <<EMAIL>> Translated to ts by <NAME> */ import { PDFDocument } from './document'; import { PDFReference } from './reference'; import * as CryptoJS from 'crypto-js'; import { PDFInfo, PDFOptions, PDFPermissions, UtilEncDict } from './types'; import { ...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/shapers/DefaultShaper.ts
<gh_stars>0 import unicode from 'unicode-properties'; const VARIATION_FEATURES = ['rvrn']; const COMMON_FEATURES = ['ccmp', 'locl', 'rlig', 'mark', 'mkmk']; const FRACTIONAL_FEATURES = ['frac', 'numr', 'dnom']; const HORIZONTAL_FEATURES = ['calt', 'clig', 'liga', 'rclt', 'curs', 'kern']; const VERTICAL_FEATURES = ['ve...
ChargeIn/SPDF
src/app/libs/fontkit/glyph/BBox.ts
<filename>src/app/libs/fontkit/glyph/BBox.ts<gh_stars>0 /** * Represents a glyph bounding box */ export default class BBox { minX: number; maxX: number; minY: number; maxY: number; constructor( minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity ) { /** * The min...
ChargeIn/SPDF
src/app/libs/fontkit/tables/cmap.ts
import r from 'restructure'; const SubHeader = new r.Struct({ firstCode: r.uint16, entryCount: r.uint16, idDelta: r.int16, idRangeOffset: r.uint16, }); const CmapGroup = new r.Struct({ startCharCode: r.uint32, endCharCode: r.uint32, glyphID: r.uint32, }); const UnicodeValueRange = new r.Struct({ star...
ChargeIn/SPDF
src/app/libs/fontkit/tables/just.ts
<filename>src/app/libs/fontkit/tables/just.ts import r from 'restructure'; import { LookupTable, StateTable1 } from './aat'; const ClassTable = new r.Struct({ length: r.uint16, coverage: r.uint16, subFeatureFlags: r.uint32, stateTable: new StateTable1(), }); const WidthDeltaRecord = new r.Struct({ justClass...
ChargeIn/SPDF
src/app/libs/fontkit/tables/loca.ts
<reponame>ChargeIn/SPDF import r from 'restructure'; const loca = new r.VersionedStruct('head.indexToLocFormat', { 0: { offsets: new r.Array(r.uint16), }, 1: { offsets: new r.Array(r.uint32), }, }); loca.process = function () { if (this.version === 0) { for (let i = 0; i < this.offsets.length; i...
ChargeIn/SPDF
src/app/libs/fontkit/tables/name.ts
import r from 'restructure'; import { getEncoding, LANGUAGES } from '../encodings'; const NameRecord = new r.Struct({ platformID: r.uint16, encodingID: r.uint16, languageID: r.uint16, nameID: r.uint16, length: r.uint16, string: new r.Pointer( r.uint16, new r.String('length', (t) => getEncodin...
ChargeIn/SPDF
src/app/libs/fontkit/CmapProcessor.ts
import { binarySearch, range } from './utils'; import { getEncoding } from './encodings'; import { cache } from './decorators'; // iconv-lite is an optional dependency. try { const iconv = require('iconv-lite'); } catch (err) {} export default class CmapProcessor { constructor(cmapTable) { // Attempt to find ...
ChargeIn/SPDF
src/app/libs/fontkit/tables/CPAL.ts
<filename>src/app/libs/fontkit/tables/CPAL.ts import r from 'restructure'; const ColorRecord = new r.Struct({ blue: r.uint8, green: r.uint8, red: r.uint8, alpha: r.uint8, }); export default new r.VersionedStruct(r.uint16, { header: { numPaletteEntries: r.uint16, numPalettes: r.uint16, numColorRe...
ChargeIn/SPDF
src/app/libs/fontkit/aat/AATStateMachine.ts
/* * Copyright (c) <NAME> */ import AATLookupTable from './AATLookupTable'; const START_OF_TEXT_STATE = 0; const START_OF_LINE_STATE = 1; const END_OF_TEXT_CLASS = 0; const OUT_OF_BOUNDS_CLASS = 1; const DELETED_GLYPH_CLASS = 2; const END_OF_LINE_CLASS = 3; const DONT_ADVANCE = 0x4000; export default class AATSt...
ChargeIn/SPDF
src/app/libs/fontkit/glyph/Glyph.ts
import { cache } from '../decorators'; import Path from './Path'; import unicode from 'unicode-properties'; import StandardNames from './StandardNames'; import TTFFont from '../TTFFont'; /** * Glyph objects represent a glyph in the font. They have various properties for accessing metrics and * the actual vector path...
ChargeIn/SPDF
src/app/libs/fontkit/tables/vmtx.ts
<reponame>ChargeIn/SPDF import r from 'restructure'; const VmtxEntry = new r.Struct({ advance: r.uint16, // The advance height of the glyph bearing: r.int16, // The top sidebearing of the glyph }); // Vertical Metrics Table export default new r.Struct({ metrics: new r.LazyArray(VmtxEntry, (t) => t.parent.vhea.n...
ChargeIn/SPDF
src/app/libs/fontkit/WOFF2Font.ts
<reponame>ChargeIn/SPDF import r from 'restructure'; import brotli from 'brotli/decompress'; import TTFFont from './TTFFont'; import TTFGlyph, { Point } from './glyph/TTFGlyph'; import WOFF2Glyph from './glyph/WOFF2Glyph'; import WOFF2Directory from './tables/WOFF2Directory'; /** * Subclass of TTFFont that represents...
ChargeIn/SPDF
src/app/libs/pdf/mixins/vector.ts
/* * Original PDFKit - vector.js * Translated to ts by <NAME> */ // Moved the content directly to the PDFDocument class since mixins are badly supported in ts. // TODO: Rework content to mixins export const _CAP_STYLES: { [key: string]: number } = { BUTT: 0, ROUND: 1, SQUARE: 2, }; export const _JOIN_STYLES...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/shapers/HangulShaper.ts
<filename>src/app/libs/fontkit/opentype/shapers/HangulShaper.ts<gh_stars>0 import DefaultShaper from './DefaultShaper'; import GlyphInfo from '../GlyphInfo'; /** * This is a shaper for the Hangul script, used by the Korean language. * It does the following: * - decompose if unsupported by the font: * <LV> ...
ChargeIn/SPDF
src/app/libs/fontkit/tables/GDEF.ts
import r from 'restructure'; import { ClassDef, Coverage, Device } from './opentype'; import { ItemVariationStore } from './variations'; const AttachPoint = new r.Array(r.uint16, r.uint16); const AttachList = new r.Struct({ coverage: new r.Pointer(r.uint16, Coverage), glyphCount: r.uint16, attachPoints: new r.Ar...
ChargeIn/SPDF
src/app/libs/pdf/pattern.ts
<filename>src/app/libs/pdf/pattern.ts /* * PDF tiling pattern support. Uncolored only. * Original: PDFKit -- pattern.js * Translated to ts by <NAME> */ import { PDFDocument } from './document'; import { PDFReference } from './reference'; const underlyingColorSpaces = ['DeviceCMYK', 'DeviceRGB']; export class PDFT...
ChargeIn/SPDF
src/app/libs/fontkit/aat/AATLookupTable.ts
import { cache } from '../decorators'; import { range } from '../utils'; export default class AATLookupTable { constructor(table) { this.table = table; } lookup(glyph) { switch (this.table.version) { case 0: // simple array format return this.table.values.getItem(glyph); case 2: // ...
ChargeIn/SPDF
src/app/libs/pdf/image/lib/jpeg.ts
<filename>src/app/libs/pdf/image/lib/jpeg.ts /* * Original PDFKit jpeg.js * Translated to ts by <NAME> */ import { PDFReference } from '../../reference'; import { PDFDocument } from '../../document'; const MARKERS = [ 0xffc0, 0xffc1, 0xffc2, 0xffc3, 0xffc5, 0xffc6, 0xffc7, 0xffc8, 0xffc9, 0xffca, 0xffcb, 0xffc...
ChargeIn/SPDF
src/app/libs/fontkit/cff/CFFFont.ts
import CFFTop from './CFFTop'; import standardStrings from './CFFStandardStrings'; class CFFFont { private version: number; constructor(stream) { this.stream = stream; this.decode(); } static decode(stream) { return new CFFFont(stream); } decode() { const start = this.stream.pos; cons...
ChargeIn/SPDF
src/app/libs/fontkit/tables/hmtx.ts
<gh_stars>0 import r from 'restructure'; const HmtxEntry = new r.Struct({ advance: r.uint16, bearing: r.int16, }); export default new r.Struct({ metrics: new r.LazyArray(HmtxEntry, (t) => t.parent.hhea.numberOfMetrics), bearings: new r.LazyArray( r.int16, (t) => t.parent.maxp.numGlyphs - t.parent.hhea...
ChargeIn/SPDF
src/app/libs/pdf/reference.ts
<reponame>ChargeIn/SPDF /* PDFReference - represents a reference to another object in the PDF object heirarchy By <NAME> Translated to ts by <NAME> */ import { PDFDocument } from './document'; import * as zlib from 'zlib'; import { PDFObject } from './object'; export class PDFAbstractReference { toString(): string {...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/shapers/gen-indic.ts
<filename>src/app/libs/fontkit/opentype/shapers/gen-indic.ts import codepoints from 'codepoints'; import UnicodeTrieBuilder from 'unicode-trie/builder'; import compile from 'dfa/compile'; import { CATEGORIES, CONSONANT_FLAGS, POSITIONS } from './indic-data'; import { fs } from '../../../fs'; const CATEGORY_MAP = { A...
ChargeIn/SPDF
src/app/libs/fontkit/tables/hdmx.ts
import r from 'restructure'; const DeviceRecord = new r.Struct({ pixelSize: r.uint8, maximumWidth: r.uint8, widths: new r.Array(r.uint8, (t) => t.parent.parent.maxp.numGlyphs), }); // The Horizontal Device Metrics table stores integer advance widths scaled to particular pixel sizes export default new r.Struct({...
ChargeIn/SPDF
src/app/libs/fontkit/tables/VDMX.ts
<reponame>ChargeIn/SPDF<gh_stars>0 import r from 'restructure'; // VDMX tables contain ascender/descender overrides for certain (usually small) // sizes. This is needed in order to match font metrics on Windows. const Ratio = new r.Struct({ bCharSet: r.uint8, // Character set xRatio: r.uint8, // Value to use for ...
ChargeIn/SPDF
src/app/libs/fs.ts
/* * Copyright (c) <NAME> */ import * as nodeFs from 'fs'; export const fs: typeof nodeFs = window.require('fs');
ChargeIn/SPDF
src/app/libs/fontkit/opentype/ShapingPlan.ts
<reponame>ChargeIn/SPDF /** * ShapingPlans are used by the OpenType shapers to store which * features should by applied, and in what order to apply them. * The features are applied in groups called stages. A feature * can be applied globally to all glyphs, or locally to only * specific glyphs. * * @private */ e...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/GPOSProcessor.ts
<filename>src/app/libs/fontkit/opentype/GPOSProcessor.ts import OTProcessor from './OTProcessor'; export default class GPOSProcessor extends OTProcessor { applyPositionValue(sequenceIndex, value) { const position = this.positions[this.glyphIterator.peekIndex(sequenceIndex)]; if (value.xAdvance != null)...
ChargeIn/SPDF
src/app/libs/fontkit/tables/aat.ts
import r from 'restructure'; class UnboundedArrayAccessor { constructor(type, stream, parent) { this.type = type; this.stream = stream; this.parent = parent; this.base = this.stream.pos; this._items = []; } getItem(index) { if (this._items[index] == null) { const pos = this.stream....
ChargeIn/SPDF
src/app/libs/fontkit/layout/GlyphPosition.ts
/** * Represents positioning information for a glyph in a GlyphRun. */ export default class GlyphPosition { private xAdvance: number; private yAdvance: number; private xOffset: number; private yOffset: number; constructor(xAdvance = 0, yAdvance = 0, xOffset = 0, yOffset = 0) { /** * The amount to ...
ChargeIn/SPDF
src/app/libs/fontkit/TrueTypeCollection.ts
import r from 'restructure'; import TTFFont from './TTFFont'; const TTCHeader = new r.VersionedStruct(r.uint32, { 0x00010000: { numFonts: r.uint32, offsets: new r.Array(r.uint32, 'numFonts'), }, 0x00020000: { numFonts: r.uint32, offsets: new r.Array(r.uint32, 'numFonts'), dsigTag: r.uint32, ...
ChargeIn/SPDF
src/app/libs/pdf/page.ts
/* PDFPage - represents a single page in the PDF document By <NAME> Translate to ts by <NAME> */ import { PDFMargins, PDFOptions } from './types'; import { PDFDocument } from './document'; import { PDFReference } from './reference'; const DEFAULT_MARGINS = { top: 72, left: 72, bottom: 72, right: 72, }; const ...
ChargeIn/SPDF
src/app/libs/pdf/outline.ts
<gh_stars>0 /* * Original PDFKit - outline.js * Translated to ts by <NAME> */ import { PDFDocument } from './document'; import { PDFReference } from './reference'; export class PDFOutline { dictionary: PDFReference; children: PDFOutline[]; private readonly _document: PDFDocument; private _options: { expande...
ChargeIn/SPDF
src/app/libs/fontkit/TTFFont.ts
<gh_stars>0 import r from 'restructure'; import { cache } from './decorators'; import fontkit from './base'; import Directory from './tables/directory'; import tables from './tables'; import CmapProcessor from './CmapProcessor'; import LayoutEngine from './layout/LayoutEngine'; import TTFGlyph from './glyph/TTFGlyph'; ...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/shapers/gen-use.ts
import codepoints from 'codepoints'; import UnicodeTrieBuilder from 'unicode-trie/builder'; import compile from 'dfa/compile'; import { fs } from '../../../fs'; const CATEGORIES = { B: [ { UISC: 'Number' }, { UISC: 'Avagraha', UGC: 'Lo' }, { UISC: 'Bindu', UGC: 'Lo' }, { UISC: 'Consonant' }, { UI...
ChargeIn/SPDF
src/app/libs/pdf/mixins/markings.ts
<gh_stars>0 /* * Original PDFKit - markings.js * Translated to ts by <NAME> */ // Moved the content directly to the PDFDocument class since mixins are badly supported in ts. // TODO: Rework content to mixins
ChargeIn/SPDF
src/app/libs/fontkit/opentype/GlyphInfo.ts
<reponame>ChargeIn/SPDF<filename>src/app/libs/fontkit/opentype/GlyphInfo.ts import unicode from 'unicode-properties'; import OTProcessor from './OTProcessor'; export default class GlyphInfo { constructor(font, id, codePoints = [], features?) { this._font = font; this.codePoints = codePoints; this.id = id...
ChargeIn/SPDF
src/app/libs/pdf/image/lib/png-js/zlib.ts
<reponame>ChargeIn/SPDF<filename>src/app/libs/pdf/image/lib/png-js/zlib.ts /* * Extracted from pdf.js * https://github.com/andreasgal/pdf.js * * Copyright (c) 2011 Mozilla Foundation * Translated to ts by <NAME> * * Contributors: <NAME> <<EMAIL>> * <NAME> <<EMAIL>> * <NAME> <<EMAIL>...
ChargeIn/SPDF
src/app/libs/fontkit/tables/GPOS.ts
<reponame>ChargeIn/SPDF import r from 'restructure'; import { ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device, Context, ChainingContext, } from './opentype'; import { FeatureVariations } from './variations'; const ValueFormat = new r.Bitfield(r.uint16, [ 'xPlacement', 'yPlacement', ...
ChargeIn/SPDF
src/app/libs/pdf/slaprep/index.ts
/* * Original PDFKit * Translated to ts by <NAME> */ import { isBidirectionalL, isBidirectionalRAL, isCommonlyMappedToNothing, isNonASCIISpaceCharacter, isProhibitedCharacter, isUnassignedCodePoint, } from './lib/code-points'; // 2.1. Mapping /** * non-ASCII space characters [StringPrep, C.1.2] that ...
ChargeIn/SPDF
src/app/libs/fontkit/layout/UnicodeLayoutEngine.ts
import unicode from 'unicode-properties'; import TTFFont from '../TTFFont'; import Glyph from '../glyph/Glyph'; /** * This class is used when GPOS does not define 'mark' or 'mkmk' features * for positioning marks relative to base glyphs. It uses the unicode * combining class property to position marks. * * Based ...
ChargeIn/SPDF
src/app/libs/fontkit/layout/LayoutEngine.ts
import KernProcessor from './KernProcessor'; import UnicodeLayoutEngine from './UnicodeLayoutEngine'; import GlyphRun from './GlyphRun'; import GlyphPosition from './GlyphPosition'; import * as Script from './Script'; import AATLayoutEngine from '../aat/AATLayoutEngine'; import OTLayoutEngine from '../opentype/OTLayout...
ChargeIn/SPDF
src/app/libs/fontkit/tables/feat.ts
import r from 'restructure'; const Setting = new r.Struct({ setting: r.uint16, nameIndex: r.int16, name: (t) => t.parent.parent.parent.name.records.fontFeatures[t.nameIndex], }); const FeatureName = new r.Struct({ feature: r.uint16, nSettings: r.uint16, settingTable: new r.Pointer(r.uint32, new r.Array(Se...
ChargeIn/SPDF
src/app/libs/pdf/document.ts
/* PDFDocument - represents an entire PDF document By <NAME> Translated to ts by <NAME> */ import * as stream from 'stream'; import * as CryptoJS from 'crypto-js'; import { PDFReference } from './reference'; import { PDFNameTree, PDFNumberTree } from './trees'; import { PDFSecurity } from './security'; import { AcroF...
ChargeIn/SPDF
src/app/libs/fontkit/glyph/CFFGlyph.ts
import Glyph from './Glyph'; import Path from './Path'; /** * Represents an OpenType PostScript glyph, in the Compact Font Format. */ export default class CFFGlyph extends Glyph { _getName() { if (this._font.CFF2) { return super._getName(); } return this._font['CFF '].getGlyphName(this.id); } ...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/OTLayoutEngine.ts
import ShapingPlan from './ShapingPlan'; import * as Shapers from './shapers'; import GlyphInfo from './GlyphInfo'; import GSUBProcessor from './GSUBProcessor'; import GPOSProcessor from './GPOSProcessor'; export default class OTLayoutEngine { private readonly GSUBProcessor: GSUBProcessor; private readonly GPOSPro...
ChargeIn/SPDF
src/app/libs/pdf/virtual_fs.ts
<gh_stars>0 /* * Original PDFKit - virtual_fs.js * Translated to ts by <NAME> */ export class VirtualFileSystem { private _fileData: { [key: string]: Buffer | string }; constructor() { this._fileData = {}; } readFileSync( fileName, options: { encoding?: BufferEncoding } | BufferEncoding = {} ...
ChargeIn/SPDF
src/app/libs/fontkit/glyph/SBIXGlyph.ts
<gh_stars>0 import TTFGlyph from './TTFGlyph'; import r from 'restructure'; const SBIXImage = new r.Struct({ originX: r.uint16, originY: r.uint16, type: new r.String(4), data: new r.Buffer((t) => t.parent.buflen - t._currentOffset), }); /** * Represents a color (e.g. emoji) glyph in Apple's SBIX format. */ ...
ChargeIn/SPDF
src/app/libs/fontkit/cff/CFFPrivateDict.ts
import CFFDict from './CFFDict'; import CFFIndex from './CFFIndex'; import CFFPointer from './CFFPointer'; class CFFBlendOp { static decode(stream, parent, operands) { const numBlends = operands.pop(); // TODO: actually blend. For now just consume the deltas // since we don't use any of the values anywa...
ChargeIn/SPDF
src/app/libs/fontkit/utils.ts
export function binarySearch(arr, cmp) { let min = 0; let max = arr.length - 1; while (min <= max) { const mid = (min + max) >> 1; const res = cmp(arr[mid]); if (res < 0) { max = mid - 1; } else if (res > 0) { min = mid + 1; } else { return mid; } } return -1; } ex...
ChargeIn/SPDF
src/app/libs/pdf/image/lib/png.ts
<reponame>ChargeIn/SPDF /* * Original PDFKit png.ts * Translated to ts by <NAME> */ import { PDFDocument } from '../../document'; import { PNG } from './png-js/png'; import { PDFReference } from '../../reference'; import * as zlib from 'zlib'; export class PNGImage { private _label: string; private _image: PNG;...
ChargeIn/SPDF
src/app/libs/pdf/mixins/acroform.ts
/* * Original PDFKit - acroform.js * Translated to ts by <NAME> */ // Moved the content directly to the PDFDocument class since mixins are badly supported in ts. // TODO: Rework content to mixins export const FIELD_FLAGS: { [key: string]: number } = { readOnly: 1, required: 2, noExport: 4, multiline: 0x100...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/shapers/generate-data.ts
// // This script generates a UnicodeTrie containing shaping data derived // from Unicode properties (currently just for the Arabic shaper). // import codepoints from 'codepoints'; import UnicodeTrieBuilder from 'unicode-trie/builder'; import { fs } from '../../../fs'; const ShapingClasses = { Non_Joining: 0, Left...
ChargeIn/SPDF
src/app/libs/fontkit/cff/CFFIndex.ts
import r from 'restructure'; export default class CFFIndex { constructor(type?) { this.type = type; } getCFFVersion(ctx) { while (ctx && !ctx.hdrSize) { ctx = ctx.parent; } return ctx ? ctx.version : -1; } decode(stream, parent) { const version = this.getCFFVersion(parent); c...
ChargeIn/SPDF
src/app/libs/fontkit/WOFFFont.ts
<filename>src/app/libs/fontkit/WOFFFont.ts import TTFFont from './TTFFont'; import WOFFDirectory from './tables/WOFFDirectory'; import inflate from 'tiny-inflate'; import r from 'restructure'; export default class WOFFFont extends TTFFont { directory: any; static probe(buffer) { return buffer.toString('ascii',...
ChargeIn/SPDF
src/app/libs/fontkit/tables/BASE.ts
import r from 'restructure'; import { ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device, } from './opentype'; import { ItemVariationStore } from './variations'; const BaseCoord = new r.VersionedStruct(r.uint16, { 1: { // Design units only coordinate: r.int16, // X or Y value, in des...
ChargeIn/SPDF
src/app/libs/fontkit/tables/kern.ts
<reponame>ChargeIn/SPDF import r from 'restructure'; const KernPair = new r.Struct({ left: r.uint16, right: r.uint16, value: r.int16, }); const ClassTable = new r.Struct({ firstGlyph: r.uint16, nGlyphs: r.uint16, offsets: new r.Array(r.uint16, 'nGlyphs'), max: (t) => t.offsets.length && Math.max.apply(M...
ChargeIn/SPDF
src/app/libs/fontkit/opentype/shapers/indic-data.ts
// Cateories used in the OpenType spec: // https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx export const CATEGORIES = { X: 1 << 0, C: 1 << 1, V: 1 << 2, N: 1 << 3, H: 1 << 4, ZWNJ: 1 << 5, ZWJ: 1 << 6, M: 1 << 7, SM: 1 << 8, VD: 1 << 9, A: 1 << 10, Placeholder: 1 << 11, Dotte...