UNPKG

18.8 kBTypeScriptView Raw
1export const __esModule: boolean;
2declare var index$4: Readonly<{
3 __proto__: any;
4 swu2mark: (swuMark: string) => string;
5 mark2swu: (fswMark: string) => string;
6 swu2num: (swuNum: string) => number;
7 num2swu: (num: number) => string;
8 swu2coord: (swuCoord: string) => number[];
9 coord2swu: (coord: number[]) => string;
10 fsw2coord: (fswCoord: string) => number[];
11 coord2fsw: (coord: number[]) => string;
12 swu2code: (swuSym: string) => number;
13 code2swu: (code: number) => string;
14 swu2id: (swuSym: string) => number;
15 id2swu: (id: number) => string;
16 key2id: (key: string) => number;
17 id2key: (id: number) => string;
18 swu2key: (swuSym: string) => string;
19 key2swu: (key: string) => string;
20 swu2fsw: (swuText: string) => string;
21 fsw2swu: (fswText: string) => string;
22 symidArr: string[];
23 symidMax: (symidMin: string) => string;
24 symidMin: (symidMax: string) => string;
25 symid2key: (symid: string) => string;
26 key2symid: (key: string) => string;
27}>;
28/** The fsw module contains functions for handling Formal SignWriting in ASCII (FSW) characters.
29 * [FSW characters definition](https://tools.ietf.org/id/draft-slevinski-formal-signwriting-09.html#name-formal-signwriting-in-ascii)
30 * @module fsw
31 */
32declare var index$3: Readonly<{
33 __proto__: any;
34 re: {
35 symbol: string;
36 coord: string;
37 sort: string;
38 box: string;
39 };
40 parse: {
41 /**
42 * Function to parse an fsw symbol with optional coordinate and style string
43 * @function fsw.parse.symbol
44 * @param {string} fswSym - an fsw symbol
45 * @returns {SymbolObject} elements of fsw symbol
46 * @example
47 * fsw.parse.symbol('S10000500x500-C')
48 *
49 * return {
50 * 'symbol': 'S10000',
51 * 'coord': [500, 500],
52 * 'style': '-C'
53 * }
54 */
55 symbol: (fswSym: string) => SymbolObject;
56 /**
57 * Function to parse an fsw sign with style string
58 * @function fsw.parse.sign
59 * @param {string} fswSign - an fsw sign
60 * @returns { SignObject } elements of fsw sign
61 * @example
62 * fsw.parse.sign('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C')
63 *
64 * return {
65 * sequence: ['S10011', 'S10019', 'S2e704', 'S2e748'],
66 * box: 'M',
67 * max: [525, 535],
68 * spatials: [
69 * {
70 * symbol: 'S2e748',
71 * coord: [483, 510]
72 * },
73 * {
74 * symbol: 'S10011',
75 * coord: [501, 466]
76 * },
77 * {
78 * symbol: 'S2e704',
79 * coord: [510, 500]
80 * },
81 * {
82 * symbol: 'S10019',
83 * coord: [476, 475]
84 * }
85 * ],
86 * style: '-C'
87 * }
88 */
89 sign: (fswSign: string) => SignObject;
90 /**
91 * Function to parse an fsw text
92 * @function fsw.parse.text
93 * @param {string} fswText - an fsw text
94 * @returns {string[]} fsw signs and punctuations
95 * @example
96 * fsw.parse.text('AS14c20S27106M518x529S14c20481x471S27106503x489 AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468 S38800464x496')
97 *
98 * return [
99 * 'AS14c20S27106M518x529S14c20481x471S27106503x489',
100 * 'AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468',
101 * 'S38800464x496'
102 * ]
103 */
104 text: (fswText: string) => string[];
105 };
106 compose: {
107 /**
108 * Function to compose an fsw symbol with optional coordinate and style string
109 * @function fsw.compose.symbol
110 * @param {SymbolObject} fswSymObject - an fsw symbol object
111 * @returns {string} an fsw symbol string
112 * @example
113 * fsw.compose.symbol({
114 * 'symbol': 'S10000',
115 * 'coord': [480, 480],
116 * 'style': '-C'
117 * })
118 *
119 * return 'S10000480x480-C'
120 */
121 symbol: (fswSymObject: SymbolObject) => string;
122 /**
123 * Function to compose an fsw sign with style string
124 * @function fsw.compose.sign
125 * @param {SignObject} fswSignObject - an fsw symbol object
126 * @returns {string} an fsw sign string
127 * @example
128 * fsw.compose.sign({
129 * sequence: ['S10011', 'S10019', 'S2e704', 'S2e748'],
130 * box: 'M',
131 * max: [525, 535],
132 * spatials: [
133 * {
134 * symbol: 'S2e748',
135 * coord: [483, 510]
136 * },
137 * {
138 * symbol: 'S10011',
139 * coord: [501, 466]
140 * },
141 * {
142 * symbol: 'S2e704',
143 * coord: [510, 500]
144 * },
145 * {
146 * symbol: 'S10019',
147 * coord: [476, 475]
148 * }
149 * ],
150 * style: '-C'
151 * })
152 *
153 * return 'AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C'
154 */
155 sign: (fswSignObject: SignObject) => string;
156 };
157 info: (fsw: string) => SegmentInfo;
158 columnDefaults: {
159 height: number;
160 width: number;
161 offset: number;
162 pad: number;
163 margin: number;
164 dynamic: boolean;
165 background: any;
166 punctuation: {
167 spacing: boolean;
168 pad: number;
169 pull: boolean;
170 };
171 style: {
172 detail: string[];
173 zoom: number;
174 };
175 };
176 columnDefaultsMerge: (options: ColumnOptions) => ColumnOptions;
177 columns: (fswText: string, options: ColumnOptions) => {
178 options: ColumnOptions;
179 widths: number[];
180 columns: ColumnData;
181 };
182 kind: number[];
183 category: number[];
184 group: number[];
185 ranges: any;
186 isType: (key: string, type: string) => boolean;
187 colors: string[];
188 colorize: (key: string) => string;
189}>;
190/** The fswquery module contains functions for handling the FSW query language.
191 * [Query Language definition](https://tools.ietf.org/id/draft-slevinski-formal-signwriting-09.html#name-query-language)
192 * @module fswquery
193 */
194declare var index$2: Readonly<{
195 __proto__: any;
196 re: any;
197 parse: (fswQueryString: string) => QueryObject;
198 compose: (fswQueryObject: QueryObject) => string;
199 fsw2query: (fswSign: string, flags: string) => string;
200 range: (min: (number | string), max: (number | string), hex: boolean | null) => string;
201 regex: (query: string) => string[];
202 results: (query: string, text: string) => string[];
203 lines: (query: string, text: string) => string[];
204}>;
205/** The style module contains regular expressions and functions for parsing and composing style strings.
206 * [Style string definition](https://tools.ietf.org/id/draft-slevinski-formal-signwriting-09.html#name-styling-string)
207 * @module style
208 */
209declare var index$5: Readonly<{
210 __proto__: any;
211 re: any;
212 parse: (styleString: string) => StyleObject;
213 compose: (styleObject: StyleObject) => string;
214 merge: (style1: StyleObject, style2: StyleObject) => StyleObject;
215 rgb2hex: (rgb: string, tolerance?: number) => string;
216 rgba2hex: (color: string, background: string) => string;
217}>;
218/** The swu module contains functions for handling SignWriting in Unicode (SWU) characters.
219 * [SWU characters definition](https://tools.ietf.org/id/draft-slevinski-formal-signwriting-09.html#name-signwriting-in-unicode-swu)
220 * @module swu
221 */
222declare var index$1: Readonly<{
223 __proto__: any;
224 re: {
225 symbol: string;
226 coord: string;
227 sort: string;
228 box: string;
229 };
230 parse: {
231 /**
232 * Function to parse an swu symbol with optional coordinate and style string
233 * @function swu.parse.symbol
234 * @param {string} swuSym - an swu symbol
235 * @returns {SymbolObject} elements of swu symbol
236 * @example
237 * swu.parse.symbol('񀀁𝤆𝤆-C')
238 *
239 * return {
240 * 'symbol': '񀀁',
241 * 'coord': [500, 500],
242 * 'style': '-C'
243 * }
244 */
245 symbol: (swuSym: string) => SymbolObject;
246 /**
247 * Function to parse an swu sign with style string
248 * @function swu.parse.sign
249 * @param {string} swuSign - an swu sign
250 * @returns {SignObject} elements of swu sign
251 * @example
252 * swu.parse.sign('𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C')
253 *
254 * return {
255 * sequence: ['񀀒','񀀚','񋚥','񋛩'],
256 * box: '𝠃',
257 * max: [525, 535],
258 * spatials: [
259 * {
260 * symbol: '񋛩',
261 * coord: [483, 510]
262 * },
263 * {
264 * symbol: '񀀒',
265 * coord: [501, 466]
266 * },
267 * {
268 * symbol: '񋚥',
269 * coord: [510, 500]
270 * },
271 * {
272 * symbol: '񀀚',
273 * coord: [476, 475]
274 * }
275 * ],
276 * style: '-C'
277 * }
278 */
279 sign: (swuSign: string) => SignObject;
280 /**
281 * Function to parse an swu text
282 * @function swu.parse.text
283 * @param {string} swuText - an swu text
284 * @returns {string[]} swu signs and punctuations
285 * @example
286 * swu.parse.text('𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻 𝠀񃊢񃊫񋛕񆇡𝠃𝤘𝤧񃊫𝣻𝤕񃊢𝣴𝣼񆇡𝤎𝤂񋛕𝤆𝣦 񏌁𝣢𝤂')
287 *
288 * return [
289 * '𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻',
290 * '𝠀񃊢񃊫񋛕񆇡𝠃𝤘𝤧񃊫𝣻𝤕񃊢𝣴𝣼񆇡𝤎𝤂񋛕𝤆𝣦',
291 * '񏌁𝣢𝤂'
292 * ]
293 */
294 text: (swuText: string) => string[];
295 };
296 encode: (swu: string) => string;
297 decode: (encoded: string) => string;
298 pair: (swuChar: string) => string[];
299 compose: {
300 /**
301 * Function to compose an swu symbol with optional coordinate and style string
302 * @function swu.compose.symbol
303 * @param {SymbolObject} swuSymObject - an swu symbol object
304 * @returns {string} an swu symbol string
305 * @example
306 * swu.compose.symbol({
307 * 'symbol': '񀀁',
308 * 'coord': [500, 500],
309 * 'style': '-C'
310 * })
311 *
312 * return '񀀁𝤆𝤆-C'
313 */
314 symbol: (swuSymObject: SymbolObject) => string;
315 /**
316 * Function to compose an swu sign with style string
317 * @function swu.compose.sign
318 * @param {SignObject} swuSignObject - an swu sign object
319 * @returns {string} an swu sign string
320 * @example
321 * swu.compose.sign({
322 * sequence: ['񀀒','񀀚','񋚥','񋛩'],
323 * box: '𝠃',
324 * max: [525, 535],
325 * spatials: [
326 * {
327 * symbol: '񋛩',
328 * coord: [483, 510]
329 * },
330 * {
331 * symbol: '񀀒',
332 * coord: [501, 466]
333 * },
334 * {
335 * symbol: '񋚥',
336 * coord: [510, 500]
337 * },
338 * {
339 * symbol: '񀀚',
340 * coord: [476, 475]
341 * }
342 * ],
343 * style: '-C'
344 * })
345 *
346 * return '𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C'
347 */
348 sign: (swuSignObject: SignObject) => string;
349 };
350 info: (swu: string) => SegmentInfo;
351 columnDefaults: {
352 height: number;
353 width: number;
354 offset: number;
355 pad: number;
356 margin: number;
357 dynamic: boolean;
358 background: any;
359 punctuation: {
360 spacing: boolean;
361 pad: number;
362 pull: boolean;
363 };
364 style: {
365 detail: string[];
366 zoom: number;
367 };
368 };
369 columnDefaultsMerge: (options: ColumnOptions) => ColumnOptions;
370 columns: (swuText: string, options: ColumnOptions) => {
371 options: ColumnOptions;
372 widths: number[];
373 columns: ColumnData;
374 };
375 kind: any[];
376 category: any[];
377 group: any[];
378 ranges: any;
379 isType: (swuSym: string, type: string) => boolean;
380 colors: any[];
381 colorize: (swuSym: string) => string;
382}>;
383/** The swuquery module contains functions for handling the SWU query language.
384 * [Query Language definition](https://tools.ietf.org/id/draft-slevinski-formal-signwriting-09.html#name-query-language)
385 * @module swuquery
386 */
387declare var index: Readonly<{
388 __proto__: any;
389 re: any;
390 parse: (swuQueryString: string) => QueryObject;
391 compose: (swuQueryObject: QueryObject) => string;
392 swu2query: (swuSign: string, flags: string) => string;
393 range: (min: string, max: string) => string;
394 symbolRanges: (symbolFR: string) => string;
395 regex: (query: string) => string[];
396 results: (query: string, text: string) => string[];
397 lines: (query: string, text: string) => string[];
398}>;
399export { index$4 as convert, index$3 as fsw, index$2 as fswquery, index$5 as style, index$1 as swu, index as swuquery };
400/**
401 * Object of query elements with regular expression identification.
402 */
403type QueryObject = {
404 /**
405 * - required true for query object
406 */
407 query: boolean;
408 /**
409 * - an object for prefix elements
410 */
411 prefix?: {
412 required: boolean;
413 parts?: (string | string[] | (string | string[])[])[];
414 };
415 /**
416 * - array of objects for symbols, ranges, and list of symbols or ranges, with optional coordinates
417 */
418 signbox?: (QuerySignboxSymbol | QuerySignboxRange | QuerySignboxOr)[];
419 /**
420 * - amount that x or y coordinates can vary and find a match, defaults to 20
421 */
422 variance?: number;
423 /**
424 * - boolean value for including style string in matches
425 */
426 style?: boolean;
427};
428type QuerySignboxSymbol = {
429 /**
430 * - a symbol
431 */
432 symbol: string;
433 /**
434 * - an optional coordinate
435 */
436 coord?: number[];
437};
438type QuerySignboxRange = {
439 /**
440 * - an array of two symbols
441 */
442 range: string[];
443 /**
444 * - an optional coordinate
445 */
446 coord?: number[];
447};
448type QuerySignboxOr = {
449 /**
450 * - an array of symbol strings and range arrays
451 */
452 or: (string | string[])[];
453 /**
454 * - an optional coordinate
455 */
456 coord?: number[];
457};
458type ColumnOptions = {
459 /**
460 * - the height of the columns
461 */
462 height?: number;
463 /**
464 * - the widths of the columns
465 */
466 width?: number;
467 /**
468 * - the lane offset for left and right lanes
469 */
470 offset?: number;
471 /**
472 * - amount of padding before and after signs as well as at top, left, and right of columns
473 */
474 pad?: number;
475 /**
476 * - amount of space at bottom of column that is not available
477 */
478 margin?: number;
479 /**
480 * - enables variable width columns
481 */
482 dynamic?: boolean;
483 /**
484 * - background color for columns
485 */
486 background?: string;
487 /**
488 * - an object of style options
489 */
490 style?: StyleObject;
491 /**
492 * - an object of punctuation options
493 */
494 punctuation?: {
495 spacing?: boolean;
496 pad?: number;
497 pull?: boolean;
498 };
499};
500type ColumnData = ColumnSegment[];
501type ColumnSegment = {
502 /**
503 * - the x position in the column
504 */
505 x: number;
506 /**
507 * - the y position in the column
508 */
509 y: number;
510 /**
511 * - the min x value within the segment
512 */
513 minX: number;
514 /**
515 * - the min y value within the segment
516 */
517 minY: number;
518 /**
519 * - the width of the text segment
520 */
521 width: number;
522 /**
523 * - the height of the text segment
524 */
525 height: number;
526 /**
527 * - Left as -1, Middle as 0, Right as 1
528 */
529 lane: number;
530 /**
531 * - the padding of the text segment affects colored background
532 */
533 padding: number;
534 /**
535 * - "sign" or "symbol"
536 */
537 segment: string;
538 /**
539 * - the text of the sign or symbol with optional style string
540 */
541 text: string;
542 /**
543 * - the zoom size of the segment
544 */
545 zoom: number;
546};
547type SegmentInfo = {
548 /**
549 * - the min x value within the segment
550 */
551 minX: number;
552 /**
553 * - the min y value within the segment
554 */
555 minY: number;
556 /**
557 * - the width of the text segment
558 */
559 width: number;
560 /**
561 * - the height of the text segment
562 */
563 height: number;
564 /**
565 * - Left as -1, Middle as 0, Right as 1
566 */
567 lane: number;
568 /**
569 * - the padding of the text segment affects colored background
570 */
571 padding: number;
572 /**
573 * - "sign" or "symbol"
574 */
575 segment: string;
576 /**
577 * - the zoom size of the segment
578 */
579 zoom: number;
580};
581/**
582 * The elements of a style string
583 */
584type StyleObject = {
585 /**
586 * - boolean to use standardized colors for symbol groups
587 */
588 colorize?: boolean;
589 /**
590 * - integer value for padding around symbol or sign
591 */
592 padding?: number;
593 /**
594 * - css name or hex color for background
595 */
596 background?: string;
597 /**
598 * - array for css name or hex color for line and optional fill
599 */
600 detail?: string[];
601 /**
602 * - decimal value for zoom level
603 */
604 zoom?: number;
605 /**
606 * - custom colors for individual symbols
607 */
608 detailsym?: {
609 index: number;
610 detail: string[];
611 };
612 /**
613 * - list of class names separated with spaces used for SVG
614 */
615 classes?: string;
616 /**
617 * - id name used for SVG
618 */
619 id?: string;
620};
621/**
622 * The elements of a symbol string
623 */
624type SymbolObject = {
625 /**
626 * - symbol identifier
627 */
628 symbol?: string;
629 /**
630 * - x,y coordinate
631 */
632 coord?: number[];
633 /**
634 * - style string
635 */
636 style?: string;
637};
638/**
639 * The elements of a sign string
640 */
641type SignObject = {
642 /**
643 * - array of symbols
644 */
645 sequence?: string[];
646 /**
647 * - signbox marker or lane
648 */
649 box?: string;
650 /**
651 * - preprocessed x,y coordinate
652 */
653 max?: number[];
654 /**
655 * - array of symbols with coordinates
656 */
657 spatials?: {
658 symbol: string;
659 coord: number[];
660 }[];
661 /**
662 * - style string
663 */
664 style?: string;
665};