UNPKG

@sutton-signwriting/core

Version:

a javascript package for node and browsers that supports general processing of the Sutton SignWriting script

565 lines (564 loc) β€’ 13.1 kB
export const __esModule: boolean; /** * Array of plane 4 code points for categories of symbols: hand, movement, dynamics, head, trunk & limb, location, and punctuation. * @alias swu.category * @type {array} */ export const category: any[]; /** * Function that returns the standardized color for a symbol. * @function swu.colorize * @param {string} swuSym - an SWU symbol character * @returns {string} name of standardized color for symbol * @example * swu.colorize('ρ€€') * * return '#0000CC' */ export function colorize(swuSym: string): string; /** * Array of colors associated with the seven symbol categories. * @alias swu.colors * @type {array} */ export const colors: any[]; export namespace columnDefaults { const height: number; const width: number; const offset: number; const pad: number; const margin: number; const dynamic: boolean; const background: any; namespace punctuation { export const spacing: boolean; const pad_1: number; export { pad_1 as pad }; export const pull: boolean; } namespace style { const detail: string[]; const zoom: number; } } /** * Function to an object of column options with default values * * @function swu.columnDefaultsMerge * @param {ColumnOptions} options - object of column options * @returns {ColumnOptions} object of column options merged with column defaults * @example * swu.columnDefaultsMerge({height: 500,width:150}) * * return { * "height": 500, * "width": 150, * "offset": 50, * "pad": 20, * "margin": 5, * "dynamic": false, * "punctuation": { * "spacing": true, * "pad": 30, * "pull": true * }, * "style": { * "detail": [ * "black", * "white" * ], * "zoom": 1 * } * } */ export function columnDefaultsMerge(options: ColumnOptions): ColumnOptions; /** * Function to transform an SWU text to an array of columns * * @function swu.columns * @param {string} swuText - SWU text of signs and punctuation * @param {ColumnOptions} options - object of column options * @returns {{options:ColumnOptions,widths:number[],columns:ColumnData}} object of column options, widths array, and column data * @example * swu.columns('𝠀ρ²‘ρˆ©§π ƒπ€˜π€£ρ²‘𝣳𝣩ρˆ©§π€‰π£» 𝠀ρƒŠ’ρƒŠ«ρ‹›•ρ†‡‘π ƒπ€˜π€§ρƒŠ«π£»π€•ρƒŠ’𝣴𝣼ρ†‡‘π€Žπ€‚ρ‹›•𝀆𝣦 ρŒπ£’𝀂', {height: 500,width:150}) * * return { * "options": { * "height": 500, * "width": 150, * "offset": 50, * "pad": 20, * "margin": 5, * "dynamic": false, * "punctuation": { * "spacing": true, * "pad": 30, * "pull": true * }, * "style": { * "detail": [ * "black", * "white" * ], * "zoom": 1 * } * }, * "widths": [ * 150 * ], * "columns": [ * [ * { * "x": 56, * "y": 20, * "minX": 481, * "minY": 471, * "width": 37, * "height": 58, * "lane": 0, * "padding": 0, * "segment": "sign", * "text": "𝠀ρ²‘ρˆ©§π ƒπ€˜π€£ρ²‘𝣳𝣩ρˆ©§π€‰π£»", * "zoom": 1 * }, * { * "x": 57, * "y": 118, * "minX": 482, * "minY": 468, * "width": 36, * "height": 65, * "lane": 0, * "padding": 0, * "segment": "sign", * "text": "𝠀ρƒŠ’ρƒŠ«ρ‹›•ρ†‡‘π ƒπ€˜π€§ρƒŠ«π£»π€•ρƒŠ’𝣴𝣼ρ†‡‘π€Žπ€‚ρ‹›•𝀆𝣦", * "zoom": 1 * }, * { * "x": 39, * "y": 203, * "minX": 464, * "minY": 496, * "width": 72, * "height": 8, * "lane": 0, * "padding": 0, * "segment": "symbol", * "text": "ρŒπ£’𝀂", * "zoom": 1 * } * ] * ] * } */ export function columns(swuText: string, options: ColumnOptions): { options: ColumnOptions; widths: number[]; columns: ColumnData; }; export namespace compose { function symbol(swuSymObject: SymbolObject): string; function sign(swuSignObject: SignObject): string; } /** * Function to decode UTF-16 escape format to SWU characters. * @function swu.decode * @param {string} encoded - UTF-16 escape format * @returns {string} SWU characters * @example * swu.decode('\\uD8C0\\uDC01\\uD836\\uDD06\\uD836\\uDD06') * * return 'ρ€€π€†π€†' */ export function decode(encoded: string): string; /** * Function to encode SWU characters using the UTF-16 escape format. * @function swu.encode * @param {string} swu - SWU characters * @returns {string} UTF-16 escape format * @example * swu.encode('ρ€€π€†π€†') * * return '\\uD8C0\\uDC01\\uD836\\uDD06\\uD836\\uDD06' */ export function encode(swu: string): string; /** * Array of plane 4 code points for the 30 symbol groups. * @alias swu.group * @type {array} */ export const group: any[]; /** * Function to gather sizing information about an swu sign or symbol * @function swu.info * @param {string} swu - an swu sign or symbol * @returns {SegmentInfo} information about the swu string * @example * swu.info('𝠀ρ²‘ρˆ©§π ‚π€˜π€£ρ²‘𝣳𝣩ρˆ©§π€‰π£»-P10Z2') * * return { * minX: 481, * minY: 471, * width: 37, * height: 58, * lane: -1, * padding: 10, * segment: 'sign', * zoom: 2 * } */ export function info(swu: string): SegmentInfo; /** * Function to test if symbol is of a certain type. * @function swu.isType * @param {string} swuSym - an SWU symbol character * @param {string} type - the name of a symbol range * @returns {boolean} is symbol of specified type * @example * swu.isType('ρ€€', 'hand') * * return true */ export function isType(swuSym: string, type: string): boolean; /** * Array of plane 4 code points for kinds of symbols: writing, location, and punctuation. * @alias swu.kind * @type {array} */ export const kind: any[]; /** * Function to decompose an SWU character into UTF-16 surrogate pairs. * @function swu.pair * @param {string} swuChar - an SWU character * @returns {string[]} an array of UTF-16 surrogate pairs * @example * swu.pair('ρ€€') * * return ['D8C0', 'DC01'] */ export function pair(swuChar: string): string[]; export namespace parse { export function symbol_1(swuSym: string): SymbolObject; export { symbol_1 as symbol }; export function sign_1(swuSign: string): SignObject; export { sign_1 as sign }; export function text(swuText: string): string[]; } /** * Object of symbol ranges with starting and ending code points on plane 4. * * { all, writing, hand, movement, dynamic, head, hcenter, vcenter, trunk, limb, location, punctuation } * @alias swu.ranges * @type {object} */ export const ranges: object; declare namespace re$1 { const _null: string; export { _null as null }; const symbol_2: string; export { symbol_2 as symbol }; export const coord: string; export const sort: string; export const box: string; } export { re$1 as re }; /** * Object of query elements with regular expression identification. */ type QueryObject = { /** * - required true for query object */ query: boolean; /** * - an object for prefix elements */ prefix?: { required: boolean; parts?: (string | string[] | (string | string[])[])[]; }; /** * - array of objects for symbols, ranges, and list of symbols or ranges, with optional coordinates */ signbox?: (QuerySignboxSymbol | QuerySignboxRange | QuerySignboxOr)[]; /** * - amount that x or y coordinates can vary and find a match, defaults to 20 */ variance?: number; /** * - boolean value for including style string in matches */ style?: boolean; }; type QuerySignboxSymbol = { /** * - a symbol */ symbol: string; /** * - an optional coordinate */ coord?: number[]; }; type QuerySignboxRange = { /** * - an array of two symbols */ range: string[]; /** * - an optional coordinate */ coord?: number[]; }; type QuerySignboxOr = { /** * - an array of symbol strings and range arrays */ or: (string | string[])[]; /** * - an optional coordinate */ coord?: number[]; }; type ColumnOptions = { /** * - the height of the columns */ height?: number; /** * - the widths of the columns */ width?: number; /** * - the lane offset for left and right lanes */ offset?: number; /** * - amount of padding before and after signs as well as at top, left, and right of columns */ pad?: number; /** * - amount of space at bottom of column that is not available */ margin?: number; /** * - enables variable width columns */ dynamic?: boolean; /** * - background color for columns */ background?: string; /** * - an object of style options */ style?: StyleObject; /** * - an object of punctuation options */ punctuation?: { spacing?: boolean; pad?: number; pull?: boolean; }; }; type ColumnData = ColumnSegment[]; type ColumnSegment = { /** * - the x position in the column */ x: number; /** * - the y position in the column */ y: number; /** * - the min x value within the segment */ minX: number; /** * - the min y value within the segment */ minY: number; /** * - the width of the text segment */ width: number; /** * - the height of the text segment */ height: number; /** * - Left as -1, Middle as 0, Right as 1 */ lane: number; /** * - the padding of the text segment affects colored background */ padding: number; /** * - "sign" or "symbol" */ segment: string; /** * - the text of the sign or symbol with optional style string */ text: string; /** * - the zoom size of the segment */ zoom: number; }; type SegmentInfo = { /** * - the min x value within the segment */ minX: number; /** * - the min y value within the segment */ minY: number; /** * - the width of the text segment */ width: number; /** * - the height of the text segment */ height: number; /** * - Left as -1, Middle as 0, Right as 1 */ lane: number; /** * - the padding of the text segment affects colored background */ padding: number; /** * - "sign" or "symbol" */ segment: string; /** * - the zoom size of the segment */ zoom: number; }; /** * The elements of a style string */ type StyleObject = { /** * - boolean to use standardized colors for symbol groups */ colorize?: boolean; /** * - integer value for padding around symbol or sign */ padding?: number; /** * - css name or hex color for background */ background?: string; /** * - array for css name or hex color for line and optional fill */ detail?: string[]; /** * - decimal value for zoom level */ zoom?: number; /** * - custom colors for individual symbols */ detailsym?: { index: number; detail: string[]; }; /** * - list of class names separated with spaces used for SVG */ classes?: string; /** * - id name used for SVG */ id?: string; }; /** * The elements of a symbol string */ type SymbolObject = { /** * - symbol identifier */ symbol?: string; /** * - x,y coordinate */ coord?: number[]; /** * - style string */ style?: string; }; /** * The elements of a sign string */ type SignObject = { /** * - array of symbols */ sequence?: string[]; /** * - signbox marker or lane */ box?: string; /** * - preprocessed x,y coordinate */ max?: number[]; /** * - array of symbols with coordinates */ spatials?: { symbol: string; coord: number[]; }[]; /** * - style string */ style?: string; }; type TokenizerObject = { /** * - Index to string mapping */ i2s: any; /** * - String to index mapping */ s2i: any; /** * - Total number of tokens */ length: number; /** * - Returns array of all tokens */ vocab: Function; /** * - Encodes a string of SignWriting to token indices */ encode: Function; /** * - Decodes token indices to a string of SignWriting */ decode: Function; /** * - Encodes an array of token strings to token indices */ encodeTokens: Function; /** * - Decodes an array of token indices to token strings */ decodeTokens: Function; };