@keymanapp/common-types 17.0.85-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/consts/virtual-key-constants.d.ts +131 -0
- package/build/src/consts/virtual-key-constants.d.ts.map +1 -0
- package/build/src/consts/virtual-key-constants.js +245 -0
- package/build/src/consts/virtual-key-constants.js.map +1 -0
- package/build/src/import/techpreview/cldr_info.json +5 -0
- package/build/src/import/techpreview/keys-Latn-implied.xml +80 -0
- package/build/src/import/techpreview/keys-Zyyy-currency.xml +22 -0
- package/build/src/import/techpreview/keys-Zyyy-punctuation.xml +46 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts +7 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.d.ts.map +1 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js +74 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-reader.js.map +1 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts +24 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.d.ts.map +1 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js +75 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file-writer.js.map +1 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts +76 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.d.ts.map +1 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.js +26 -0
- package/build/src/keyman-touch-layout/keyman-touch-layout-file.js.map +1 -0
- package/build/src/keyman-touch-layout.clean.spec.json +170 -0
- package/build/src/kmx/element-string.d.ts +19 -0
- package/build/src/kmx/element-string.d.ts.map +1 -0
- package/build/src/kmx/element-string.js +72 -0
- package/build/src/kmx/element-string.js.map +1 -0
- package/build/src/kmx/kmx-builder.d.ts +77 -0
- package/build/src/kmx/kmx-builder.d.ts.map +1 -0
- package/build/src/kmx/kmx-builder.js +193 -0
- package/build/src/kmx/kmx-builder.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-disp.d.ts +18 -0
- package/build/src/kmx/kmx-plus-builder/build-disp.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-disp.js +25 -0
- package/build/src/kmx/kmx-plus-builder/build-disp.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-elem.d.ts +26 -0
- package/build/src/kmx/kmx-plus-builder/build-elem.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-elem.js +78 -0
- package/build/src/kmx/kmx-plus-builder/build-elem.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-keys.d.ts +60 -0
- package/build/src/kmx/kmx-plus-builder/build-keys.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-keys.js +107 -0
- package/build/src/kmx/kmx-plus-builder/build-keys.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-layr.d.ts +54 -0
- package/build/src/kmx/kmx-plus-builder/build-layr.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-layr.js +99 -0
- package/build/src/kmx/kmx-plus-builder/build-layr.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-list.d.ts +34 -0
- package/build/src/kmx/kmx-plus-builder/build-list.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-list.js +62 -0
- package/build/src/kmx/kmx-plus-builder/build-list.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-loca.d.ts +12 -0
- package/build/src/kmx/kmx-plus-builder/build-loca.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-loca.js +20 -0
- package/build/src/kmx/kmx-plus-builder/build-loca.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-meta.d.ts +17 -0
- package/build/src/kmx/kmx-plus-builder/build-meta.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-meta.js +21 -0
- package/build/src/kmx/kmx-plus-builder/build-meta.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-name.d.ts +12 -0
- package/build/src/kmx/kmx-plus-builder/build-name.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-name.js +23 -0
- package/build/src/kmx/kmx-plus-builder/build-name.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-ordr.d.ts +18 -0
- package/build/src/kmx/kmx-plus-builder/build-ordr.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-ordr.js +27 -0
- package/build/src/kmx/kmx-plus-builder/build-ordr.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-sect.d.ts +16 -0
- package/build/src/kmx/kmx-plus-builder/build-sect.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-sect.js +14 -0
- package/build/src/kmx/kmx-plus-builder/build-sect.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-strs.d.ts +18 -0
- package/build/src/kmx/kmx-plus-builder/build-strs.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-strs.js +34 -0
- package/build/src/kmx/kmx-plus-builder/build-strs.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-tran.d.ts +20 -0
- package/build/src/kmx/kmx-plus-builder/build-tran.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-tran.js +30 -0
- package/build/src/kmx/kmx-plus-builder/build-tran.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-vkey.d.ts +16 -0
- package/build/src/kmx/kmx-plus-builder/build-vkey.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/build-vkey.js +23 -0
- package/build/src/kmx/kmx-plus-builder/build-vkey.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/builder-section.d.ts +6 -0
- package/build/src/kmx/kmx-plus-builder/builder-section.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/builder-section.js +3 -0
- package/build/src/kmx/kmx-plus-builder/builder-section.js.map +1 -0
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts +47 -0
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js +143 -0
- package/build/src/kmx/kmx-plus-builder/kmx-plus-builder.js.map +1 -0
- package/build/src/kmx/kmx-plus.d.ts +259 -0
- package/build/src/kmx/kmx-plus.d.ts.map +1 -0
- package/build/src/kmx/kmx-plus.js +594 -0
- package/build/src/kmx/kmx-plus.js.map +1 -0
- package/build/src/kmx/kmx.d.ts +166 -0
- package/build/src/kmx/kmx.d.ts.map +1 -0
- package/build/src/kmx/kmx.js +271 -0
- package/build/src/kmx/kmx.js.map +1 -0
- package/build/src/kmx/string-list.d.ts +29 -0
- package/build/src/kmx/string-list.d.ts.map +1 -0
- package/build/src/kmx/string-list.js +75 -0
- package/build/src/kmx/string-list.js.map +1 -0
- package/build/src/kpj/keyman-developer-project.d.ts +58 -0
- package/build/src/kpj/keyman-developer-project.d.ts.map +1 -0
- package/build/src/kpj/keyman-developer-project.js +141 -0
- package/build/src/kpj/keyman-developer-project.js.map +1 -0
- package/build/src/kpj/kpj-file-reader.d.ts +17 -0
- package/build/src/kpj/kpj-file-reader.d.ts.map +1 -0
- package/build/src/kpj/kpj-file-reader.js +92 -0
- package/build/src/kpj/kpj-file-reader.js.map +1 -0
- package/build/src/kpj/kpj-file.d.ts +39 -0
- package/build/src/kpj/kpj-file.d.ts.map +1 -0
- package/build/src/kpj/kpj-file.js +11 -0
- package/build/src/kpj/kpj-file.js.map +1 -0
- package/build/src/kpj.schema.json +127 -0
- package/build/src/kvk/kvk-file-reader.d.ts +5 -0
- package/build/src/kvk/kvk-file-reader.d.ts.map +1 -0
- package/build/src/kvk/kvk-file-reader.js +35 -0
- package/build/src/kvk/kvk-file-reader.js.map +1 -0
- package/build/src/kvk/kvk-file-writer.d.ts +20 -0
- package/build/src/kvk/kvk-file-writer.d.ts.map +1 -0
- package/build/src/kvk/kvk-file-writer.js +67 -0
- package/build/src/kvk/kvk-file-writer.js.map +1 -0
- package/build/src/kvk/kvk-file.d.ts +64 -0
- package/build/src/kvk/kvk-file.d.ts.map +1 -0
- package/build/src/kvk/kvk-file.js +63 -0
- package/build/src/kvk/kvk-file.js.map +1 -0
- package/build/src/kvk/kvks-file-reader.d.ts +30 -0
- package/build/src/kvk/kvks-file-reader.d.ts.map +1 -0
- package/build/src/kvk/kvks-file-reader.js +154 -0
- package/build/src/kvk/kvks-file-reader.js.map +1 -0
- package/build/src/kvk/kvks-file-writer.d.ts +6 -0
- package/build/src/kvk/kvks-file-writer.d.ts.map +1 -0
- package/build/src/kvk/kvks-file-writer.js +99 -0
- package/build/src/kvk/kvks-file-writer.js.map +1 -0
- package/build/src/kvk/kvks-file.d.ts +44 -0
- package/build/src/kvk/kvks-file.d.ts.map +1 -0
- package/build/src/kvk/kvks-file.js +10 -0
- package/build/src/kvk/kvks-file.js.map +1 -0
- package/build/src/kvk/visual-keyboard.d.ts +35 -0
- package/build/src/kvk/visual-keyboard.d.ts.map +1 -0
- package/build/src/kvk/visual-keyboard.js +61 -0
- package/build/src/kvk/visual-keyboard.js.map +1 -0
- package/build/src/kvks.schema.json +182 -0
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts +56 -0
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.d.ts.map +1 -0
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js +20 -0
- package/build/src/ldml-keyboard/ldml-keyboard-testdata-xml.js.map +1 -0
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts +91 -0
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.d.ts.map +1 -0
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js +370 -0
- package/build/src/ldml-keyboard/ldml-keyboard-xml-reader.js.map +1 -0
- package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts +143 -0
- package/build/src/ldml-keyboard/ldml-keyboard-xml.d.ts.map +1 -0
- package/build/src/ldml-keyboard/ldml-keyboard-xml.js +34 -0
- package/build/src/ldml-keyboard/ldml-keyboard-xml.js.map +1 -0
- package/build/src/ldml-keyboard.schema.json +634 -0
- package/build/src/ldml-keyboardtest.schema.json +221 -0
- package/build/src/main.d.ts +21 -0
- package/build/src/main.d.ts.map +1 -0
- package/build/src/main.js +20 -0
- package/build/src/main.js.map +1 -0
- package/build/src/util/common-events.d.ts +49 -0
- package/build/src/util/common-events.d.ts.map +1 -0
- package/build/src/util/common-events.js +29 -0
- package/build/src/util/common-events.js.map +1 -0
- package/build/src/util/compiler-interfaces.d.ts +51 -0
- package/build/src/util/compiler-interfaces.d.ts.map +1 -0
- package/build/src/util/compiler-interfaces.js +33 -0
- package/build/src/util/compiler-interfaces.js.map +1 -0
- package/build/src/util/util.d.ts +17 -0
- package/build/src/util/util.d.ts.map +1 -0
- package/build/src/util/util.js +67 -0
- package/build/src/util/util.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build.sh +86 -0
- package/package.json +58 -0
- package/src/consts/virtual-key-constants.ts +257 -0
- package/src/keyman-touch-layout/keyman-touch-layout-file-reader.ts +81 -0
- package/src/keyman-touch-layout/keyman-touch-layout-file-writer.ts +84 -0
- package/src/keyman-touch-layout/keyman-touch-layout-file.ts +87 -0
- package/src/kmx/element-string.ts +79 -0
- package/src/kmx/kmx-builder.ts +287 -0
- package/src/kmx/kmx-plus-builder/build-disp.ts +46 -0
- package/src/kmx/kmx-plus-builder/build-elem.ts +103 -0
- package/src/kmx/kmx-plus-builder/build-keys.ts +175 -0
- package/src/kmx/kmx-plus-builder/build-layr.ts +154 -0
- package/src/kmx/kmx-plus-builder/build-list.ts +95 -0
- package/src/kmx/kmx-plus-builder/build-loca.ts +34 -0
- package/src/kmx/kmx-plus-builder/build-meta.ts +37 -0
- package/src/kmx/kmx-plus-builder/build-name.ts +37 -0
- package/src/kmx/kmx-plus-builder/build-ordr.ts +45 -0
- package/src/kmx/kmx-plus-builder/build-sect.ts +31 -0
- package/src/kmx/kmx-plus-builder/build-strs.ts +58 -0
- package/src/kmx/kmx-plus-builder/build-tran.ts +50 -0
- package/src/kmx/kmx-plus-builder/build-vkey.ts +43 -0
- package/src/kmx/kmx-plus-builder/builder-section.ts +6 -0
- package/src/kmx/kmx-plus-builder/kmx-plus-builder.ts +190 -0
- package/src/kmx/kmx-plus.ts +692 -0
- package/src/kmx/kmx.ts +360 -0
- package/src/kmx/string-list.ts +74 -0
- package/src/kpj/keyman-developer-project.ts +155 -0
- package/src/kpj/kpj-file-reader.ts +103 -0
- package/src/kpj/kpj-file.ts +52 -0
- package/src/kvk/kvk-file-reader.ts +34 -0
- package/src/kvk/kvk-file-writer.ts +72 -0
- package/src/kvk/kvk-file.ts +122 -0
- package/src/kvk/kvks-file-reader.ts +164 -0
- package/src/kvk/kvks-file-writer.ts +113 -0
- package/src/kvk/kvks-file.ts +53 -0
- package/src/kvk/visual-keyboard.ts +80 -0
- package/src/ldml-keyboard/ldml-keyboard-testdata-xml.ts +74 -0
- package/src/ldml-keyboard/ldml-keyboard-xml-reader.ts +387 -0
- package/src/ldml-keyboard/ldml-keyboard-xml.ts +177 -0
- package/src/main.ts +27 -0
- package/src/restructure.d.ts +2 -0
- package/src/util/common-events.ts +50 -0
- package/src/util/compiler-interfaces.ts +54 -0
- package/src/util/util.ts +68 -0
- package/test/fixtures/import-minimal.xml +8 -0
- package/test/fixtures/import-minimal1.xml +11 -0
- package/test/fixtures/import-minimal2.xml +11 -0
- package/test/fixtures/import-symbols.xml +13 -0
- package/test/fixtures/invalid-conforms-to.xml +19 -0
- package/test/fixtures/invalid-import-base.xml +16 -0
- package/test/fixtures/invalid-import-path.xml +16 -0
- package/test/fixtures/invalid-import-readfail.xml +16 -0
- package/test/fixtures/invalid-import-wrongroot.xml +16 -0
- package/test/fixtures/invalid-structure-per-dtd.xml +8 -0
- package/test/fixtures/keyman-touch-layout/khmer_angkor.keyman-touch-layout +1950 -0
- package/test/fixtures/keyman-touch-layout/legacy.keyman-touch-layout +36 -0
- package/test/fixtures/kpj/khmer_angkor.kpj +187 -0
- package/test/fixtures/kvk/khmer_angkor.kvk +0 -0
- package/test/fixtures/kvk/khmer_angkor.kvks +206 -0
- package/test/fixtures/test-fr.xml +22 -0
- package/test/helpers/index.ts +39 -0
- package/test/helpers/reader-callback-test.ts +199 -0
- package/test/keyman-touch-layout/test-keyman-touch-layout-file-reader.ts +71 -0
- package/test/keyman-touch-layout/test-keyman-touch-layout-round-trip.ts +35 -0
- package/test/kpj/test-kpj-file-reader.ts +123 -0
- package/test/kvk/test-kvk-file.ts +15 -0
- package/test/kvk/test-kvk-round-trip.ts +87 -0
- package/test/kvk/test-kvk-utils.ts +24 -0
- package/test/kvk/test-kvks-file.ts +45 -0
- package/test/ldml-keyboard/test-ldml-keyboard-testdata-reader.ts +51 -0
- package/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts +131 -0
- package/test/tsconfig.json +21 -0
- package/test/util/test-unescape.ts +38 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m } from './compiler-interfaces.js';
|
|
2
|
+
import { constants } from '@keymanapp/ldml-keyboard-constants';
|
|
3
|
+
|
|
4
|
+
const CommonTypesErrMask = CompilerErrorNamespace.CommonTypes;
|
|
5
|
+
// const SevInfo = CompilerErrorSeverity.Info | CommonTypesErrMask;
|
|
6
|
+
// const SevHint = CompilerErrorSeverity.Hint | CommonTypesErrMask;
|
|
7
|
+
// const SevWarn = CompilerErrorSeverity.Warn | CommonTypesErrMask;
|
|
8
|
+
const SevError = CompilerErrorSeverity.Error | CommonTypesErrMask;
|
|
9
|
+
// const SevFatal = CompilerErrorSeverity.Fatal | CommonTypesErrMask;
|
|
10
|
+
|
|
11
|
+
export class CommonTypesMessages {
|
|
12
|
+
// structured Ajv validation error
|
|
13
|
+
static Error_SchemaValidationError = (o:{instancePath:string, keyword:string, message: string, params: string}) => m(this.ERROR_SchemaValidationError,
|
|
14
|
+
`Error validating LDML XML file: ${o.instancePath}: ${o.keyword}: ${o.message} ${o.params}`);
|
|
15
|
+
static ERROR_SchemaValidationError = SevError | 0x0001;
|
|
16
|
+
|
|
17
|
+
static Error_ImportInvalidBase = (o: { base: string, path: string, subtag: string }) =>
|
|
18
|
+
m(this.ERROR_ImportInvalidBase,
|
|
19
|
+
`Import element with base ${o.base} is unsupported. Only ${constants.cldr_import_base} is supported.`);
|
|
20
|
+
static ERROR_ImportInvalidBase = SevError | 0x0002;
|
|
21
|
+
|
|
22
|
+
static Error_ImportInvalidPath = (o: { base: string, path: string, subtag: string }) =>
|
|
23
|
+
m(this.ERROR_ImportInvalidPath,
|
|
24
|
+
`Import element with invalid path ${o.path}: expected the form '${constants.cldr_version_latest}./*.xml`);
|
|
25
|
+
static ERROR_ImportInvalidPath = SevError | 0x0003;
|
|
26
|
+
|
|
27
|
+
static Error_ImportReadFail = (o: { base: string, path: string, subtag: string }) =>
|
|
28
|
+
m(this.ERROR_ImportReadFail,
|
|
29
|
+
`Import could not read data with path ${o.path}: expected the form '${constants.cldr_version_latest}./*.xml'`);
|
|
30
|
+
static ERROR_ImportReadFail = SevError | 0x0004;
|
|
31
|
+
|
|
32
|
+
static Error_ImportWrongRoot = (o: { base: string, path: string, subtag: string }) =>
|
|
33
|
+
m(this.ERROR_ImportWrongRoot,
|
|
34
|
+
`Invalid import file ${o.path}: expected ${o.subtag} as root element.`);
|
|
35
|
+
static ERROR_ImportWrongRoot = SevError | 0x0005;
|
|
36
|
+
|
|
37
|
+
static Error_ImportMergeFail = (o: { base: string, path: string, subtag: string, subsubtag: string }) =>
|
|
38
|
+
m(this.ERROR_ImportMergeFail,
|
|
39
|
+
`Problem importing ${o.path}: not sure how to handle non-array ${o.subtag}.${o.subsubtag}`);
|
|
40
|
+
static ERROR_ImportMergeFail = SevError | 0x0006;
|
|
41
|
+
|
|
42
|
+
static Error_TestDataUnexpectedArray = (o: {subtag: string}) =>
|
|
43
|
+
m(this.ERROR_TestDataUnexpectedArray,
|
|
44
|
+
`Problem reading test data: expected single ${o.subtag} element, found multiple`);
|
|
45
|
+
static ERROR_TestDataUnexpectedArray = SevError | 0x0007;
|
|
46
|
+
static Error_TestDataUnexpectedAction = (o: {subtag: string}) =>
|
|
47
|
+
m(this.ERROR_TestDataUnexpectedAction,
|
|
48
|
+
`Problem reading test data: unexpected action element ${o.subtag}`);
|
|
49
|
+
static ERROR_TestDataUnexpectedAction = SevError | 0x0008;
|
|
50
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract interface for compiler error and warning messages
|
|
3
|
+
*/
|
|
4
|
+
export interface CompilerEvent {
|
|
5
|
+
code: number;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export enum CompilerErrorSeverity {
|
|
10
|
+
Info = 0x000000, // Informational, not necessarily a problem
|
|
11
|
+
Hint = 0x100000, // Something the user might want to be aware of
|
|
12
|
+
Warn = 0x200000, // Warning: Not great, but we can keep going.
|
|
13
|
+
Error = 0x300000, // Severe error where we can't continue
|
|
14
|
+
Fatal = 0x400000, // OOM or should-not-happen internal problem
|
|
15
|
+
|
|
16
|
+
Severity_Mask = 0xF00000, // includes reserved bits
|
|
17
|
+
Error_Mask = 0x0FFFFF,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export enum CompilerErrorNamespace {
|
|
21
|
+
/**
|
|
22
|
+
* kmc-keyboard errors between 0x0000…0x0FFF
|
|
23
|
+
*/
|
|
24
|
+
KeyboardCompiler = 0x0000,
|
|
25
|
+
/**
|
|
26
|
+
* common/web/types errors between 0x1000…0x1FFF
|
|
27
|
+
*/
|
|
28
|
+
CommonTypes = 0x1000,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Abstract interface for callbacks, to abstract out file i/o
|
|
33
|
+
*/
|
|
34
|
+
export interface CompilerCallbacks {
|
|
35
|
+
/**
|
|
36
|
+
* Attempt to load a file. Return falsy if not found.
|
|
37
|
+
* @param baseFilename
|
|
38
|
+
* @param filename
|
|
39
|
+
*/
|
|
40
|
+
loadFile(baseFilename: string, filename: string | URL): Buffer;
|
|
41
|
+
loadLdmlKeyboardSchema(): Buffer;
|
|
42
|
+
loadLdmlKeyboardTestSchema(): Buffer;
|
|
43
|
+
reportMessage(event: CompilerEvent): void;
|
|
44
|
+
loadKvksJsonSchema(): Buffer;
|
|
45
|
+
loadKpjJsonSchema(): Buffer;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Convenience function for constructing CompilerEvents
|
|
50
|
+
* @param code
|
|
51
|
+
* @param message
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
export const CompilerMessageSpec = (code: number, message: string) : CompilerEvent => { return { code, message } };
|
package/src/util/util.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xml2js will not place single-entry objects into arrays. Easiest way to fix
|
|
3
|
+
* this is to box them ourselves as needed. Ensures that o.x is an array.
|
|
4
|
+
*
|
|
5
|
+
* @param o Object with property to box
|
|
6
|
+
* @param x Name of element to box
|
|
7
|
+
*/
|
|
8
|
+
export function boxXmlArray(o: any, x: string): void {
|
|
9
|
+
if(typeof o == 'object' && !Array.isArray(o[x])) {
|
|
10
|
+
if(o[x] === null || o[x] === undefined) {
|
|
11
|
+
o[x] = [];
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
o[x] = [o[x]];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// TODO-LDML: #7569 the below regex works, but captures more than it should
|
|
20
|
+
// (it would include \u{fffffffffffffffff } which
|
|
21
|
+
// is overlong and has a space at the end.) The second regex does not work yet.
|
|
22
|
+
const MATCH_HEX_ESCAPE = /\\u{([0-9a-fA-F ]{1,})}/g;
|
|
23
|
+
// const MATCH_HEX_ESCAPE = /\\u{((?:(?:[0-9a-fA-F]{1,5})|(?:10[0-9a-fA-F]{4})(?: (?!}))?)+)}/g;
|
|
24
|
+
|
|
25
|
+
export class UnescapeError extends Error {
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Unescapes a string according to UTS#18§1.1, see <https://www.unicode.org/reports/tr18/#Hex_notation>
|
|
30
|
+
* @param s escaped string
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export function unescapeString(s: string): string {
|
|
34
|
+
if(!s) {
|
|
35
|
+
return s;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
/**
|
|
39
|
+
* Unescape one codepoint
|
|
40
|
+
* @param hex one codepoint in hex, such as '0127'
|
|
41
|
+
* @returns the unescaped codepoint
|
|
42
|
+
*/
|
|
43
|
+
function unescapeOne(hex: string) : string {
|
|
44
|
+
const codepoint = Number.parseInt(hex, 16);
|
|
45
|
+
return String.fromCodePoint(codepoint);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* process one regex match
|
|
49
|
+
* @param str ignored
|
|
50
|
+
* @param matched the entire match such as '0127' or '22 22'
|
|
51
|
+
* @returns the unescaped match
|
|
52
|
+
*/
|
|
53
|
+
function processMatch(str: string, matched: string) : string {
|
|
54
|
+
const codepoints = matched.split(' ');
|
|
55
|
+
const unescaped = codepoints.map(unescapeOne);
|
|
56
|
+
return unescaped.join('');
|
|
57
|
+
}
|
|
58
|
+
s = s.replaceAll(MATCH_HEX_ESCAPE, processMatch);
|
|
59
|
+
} catch(e) {
|
|
60
|
+
if (e instanceof RangeError) {
|
|
61
|
+
throw new UnescapeError(`Out of range while unescaping '${s}': ${e.message}`, { cause: e });
|
|
62
|
+
} else {
|
|
63
|
+
throw e;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return s;
|
|
68
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
|
|
3
|
+
<keyboard locale="und" conformsTo="techpreview">
|
|
4
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
5
|
+
<names>
|
|
6
|
+
<name value="Test Minimal Keyboard" />
|
|
7
|
+
</names>
|
|
8
|
+
</keyboard>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
|
|
3
|
+
<keyboard locale="und" conformsTo="techpreview">
|
|
4
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
5
|
+
<names>
|
|
6
|
+
<name value="Test Minimal Keyboard" />
|
|
7
|
+
</names>
|
|
8
|
+
<keys>
|
|
9
|
+
|
|
10
|
+
</keys>
|
|
11
|
+
</keyboard>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
|
|
3
|
+
<keyboard locale="und" conformsTo="techpreview">
|
|
4
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
5
|
+
<names>
|
|
6
|
+
<name value="Test Minimal Keyboard" />
|
|
7
|
+
</names>
|
|
8
|
+
<keys>
|
|
9
|
+
<key id="a" to="å"/> <!-- override -->
|
|
10
|
+
</keys>
|
|
11
|
+
</keyboard>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
|
|
3
|
+
<keyboard locale="und" conformsTo="techpreview">
|
|
4
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
5
|
+
<names>
|
|
6
|
+
<name value="Test Minimal Keyboard" />
|
|
7
|
+
</names>
|
|
8
|
+
<keys>
|
|
9
|
+
<import base="cldr" path="techpreview/keys-Zyyy-punctuation.xml"/>
|
|
10
|
+
<key id="zz" to="zz"/>
|
|
11
|
+
<key id="hash" to="##"/> <!-- override -->
|
|
12
|
+
</keys>
|
|
13
|
+
</keyboard>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd"
|
|
5
|
+
Disabling doctype for this invalid file, not used by compiler, and avoids complaints in IDEs etc.
|
|
6
|
+
-->
|
|
7
|
+
<keyboard locale="mt" conformsTo="nothing-anyone-ever-heard-of"> <!-- invalid -->
|
|
8
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
9
|
+
|
|
10
|
+
<names>
|
|
11
|
+
<name value="TestKbd" />
|
|
12
|
+
</names>
|
|
13
|
+
|
|
14
|
+
<keys>
|
|
15
|
+
<key id="hmaqtugha" to="ħ" />
|
|
16
|
+
<key id="that" to="ថា" />
|
|
17
|
+
</keys>
|
|
18
|
+
|
|
19
|
+
</keyboard>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
|
|
3
|
+
<keyboard locale="mt" conformsTo="techpreview">
|
|
4
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
5
|
+
|
|
6
|
+
<names>
|
|
7
|
+
<name value="TestKbd" />
|
|
8
|
+
</names>
|
|
9
|
+
|
|
10
|
+
<keys>
|
|
11
|
+
<import base="SOME_INVALID_BASE" path="abcd/keys-Zyyy-punctuation.xml"/> <!-- invalid -->
|
|
12
|
+
<key id="hmaqtugha" to="ħ" />
|
|
13
|
+
<key id="that" to="ថា" />
|
|
14
|
+
</keys>
|
|
15
|
+
|
|
16
|
+
</keyboard>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
|
|
3
|
+
<keyboard locale="mt" conformsTo="techpreview">
|
|
4
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
5
|
+
|
|
6
|
+
<names>
|
|
7
|
+
<name value="TestKbd" />
|
|
8
|
+
</names>
|
|
9
|
+
|
|
10
|
+
<keys>
|
|
11
|
+
<import base="cldr" path="techpreview/too/many/slashes/leading/to/nothing-Zxxx-does-not-exist.xml"/> <!-- invalid -->
|
|
12
|
+
<key id="hmaqtugha" to="ħ" />
|
|
13
|
+
<key id="that" to="ថា" />
|
|
14
|
+
</keys>
|
|
15
|
+
|
|
16
|
+
</keyboard>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
|
|
3
|
+
<keyboard locale="mt" conformsTo="techpreview">
|
|
4
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
5
|
+
|
|
6
|
+
<names>
|
|
7
|
+
<name value="TestKbd" />
|
|
8
|
+
</names>
|
|
9
|
+
|
|
10
|
+
<keys>
|
|
11
|
+
<import base="cldr" path="techpreview/none-Zxxx-does-not-exist.xml"/> <!-- invalid -->
|
|
12
|
+
<key id="hmaqtugha" to="ħ" />
|
|
13
|
+
<key id="that" to="ថា" />
|
|
14
|
+
</keys>
|
|
15
|
+
|
|
16
|
+
</keyboard>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
|
|
3
|
+
<keyboard locale="mt" conformsTo="techpreview">
|
|
4
|
+
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
|
|
5
|
+
|
|
6
|
+
<names>
|
|
7
|
+
<import base="cldr" path="techpreview/keys-Zyyy-punctuation.xml"/> <!-- wrong root! -->
|
|
8
|
+
<name value="TestKbd" />
|
|
9
|
+
</names>
|
|
10
|
+
|
|
11
|
+
<keys>
|
|
12
|
+
<key id="hmaqtugha" to="ħ" />
|
|
13
|
+
<key id="that" to="ថា" />
|
|
14
|
+
</keys>
|
|
15
|
+
|
|
16
|
+
</keyboard>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd"
|
|
5
|
+
Disabling doctype for this invalid file, not used by compiler, and avoids complaints in IDEs etc.
|
|
6
|
+
-->
|
|
7
|
+
<keyboard locale="mt" conformsTo="techpreview">
|
|
8
|
+
</keyboard>
|