@keymanapp/kmc-model 17.0.91-alpha → 17.0.92-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/build-trie.d.ts.map +1 -1
- package/build/src/build-trie.js +10 -6
- package/build/src/build-trie.js.map +1 -1
- package/build/src/compiler-callbacks.d.ts +4 -0
- package/build/src/compiler-callbacks.d.ts.map +1 -0
- package/build/src/compiler-callbacks.js +5 -0
- package/build/src/compiler-callbacks.js.map +1 -0
- package/build/src/lexical-model-compiler.d.ts +0 -3
- package/build/src/lexical-model-compiler.d.ts.map +1 -1
- package/build/src/lexical-model-compiler.js +4 -9
- package/build/src/lexical-model-compiler.js.map +1 -1
- package/build/src/main.d.ts +4 -3
- package/build/src/main.d.ts.map +1 -1
- package/build/src/main.js +23 -10
- package/build/src/main.js.map +1 -1
- package/build/src/model-compiler-errors.d.ts +44 -72
- package/build/src/model-compiler-errors.d.ts.map +1 -1
- package/build/src/model-compiler-errors.js +47 -149
- package/build/src/model-compiler-errors.js.map +1 -1
- package/build/src/script-overrides-decorator.d.ts.map +1 -1
- package/build/src/script-overrides-decorator.js +2 -1
- package/build/src/script-overrides-decorator.js.map +1 -1
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-trie.d.ts","sourceRoot":"","sources":["../../src/build-trie.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-trie.d.ts","sourceRoot":"","sources":["../../src/build-trie.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG;IAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,CAAC;AAEpD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAU7G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAGpF;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAGpF"}
|
package/build/src/build-trie.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "fs";
|
|
2
|
-
import {
|
|
2
|
+
import { ModelCompilerError, ModelCompilerMessages } from "./model-compiler-errors.js";
|
|
3
|
+
import { callbacks } from "./compiler-callbacks.js";
|
|
3
4
|
// Supports LF or CRLF line terminators.
|
|
4
5
|
const NEWLINE_SEPARATOR = /\u000d?\u000a/;
|
|
5
6
|
/**
|
|
@@ -12,7 +13,7 @@ const NEWLINE_SEPARATOR = /\u000d?\u000a/;
|
|
|
12
13
|
*/
|
|
13
14
|
export function createTrieDataStructure(filenames, searchTermToKey) {
|
|
14
15
|
if (typeof searchTermToKey !== "function") {
|
|
15
|
-
throw new
|
|
16
|
+
throw new ModelCompilerError(ModelCompilerMessages.Error_SearchTermToKeyMustBeExplicitlySpecified());
|
|
16
17
|
}
|
|
17
18
|
// Make one big word list out of all of the filenames provided.
|
|
18
19
|
let wordlist = {};
|
|
@@ -32,6 +33,7 @@ export function createTrieDataStructure(filenames, searchTermToKey) {
|
|
|
32
33
|
* @param filename filename of the word list
|
|
33
34
|
*/
|
|
34
35
|
export function parseWordListFromFilename(wordlist, filename) {
|
|
36
|
+
ModelCompilerMessages.filename = filename;
|
|
35
37
|
_parseWordList(wordlist, new WordListFromFilename(filename));
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
@@ -42,6 +44,7 @@ export function parseWordListFromFilename(wordlist, filename) {
|
|
|
42
44
|
* @param filename filename of the word list
|
|
43
45
|
*/
|
|
44
46
|
export function parseWordListFromContents(wordlist, contents) {
|
|
47
|
+
ModelCompilerMessages.filename = undefined;
|
|
45
48
|
_parseWordList(wordlist, new WordListFromMemory(contents));
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
@@ -74,6 +77,7 @@ function _parseWordList(wordlist, source) {
|
|
|
74
77
|
const TAB = "\t";
|
|
75
78
|
let wordsSeenInThisFile = new Set();
|
|
76
79
|
for (let [lineno, line] of source.lines()) {
|
|
80
|
+
ModelCompilerMessages.line = lineno;
|
|
77
81
|
// Remove the byte-order mark (BOM) from the beginning of the string.
|
|
78
82
|
// Because `contents` can be the concatenation of several files, we have to remove
|
|
79
83
|
// the BOM from every possible start of file -- i.e., beginning of every line.
|
|
@@ -88,7 +92,7 @@ function _parseWordList(wordlist, source) {
|
|
|
88
92
|
wordform = wordform.normalize('NFC');
|
|
89
93
|
if (original !== wordform) {
|
|
90
94
|
// Mixed normalization forms are yucky! Warn about it.
|
|
91
|
-
|
|
95
|
+
callbacks.reportMessage(ModelCompilerMessages.Warn_MixedNormalizationForms({ wordform: wordform }));
|
|
92
96
|
}
|
|
93
97
|
wordform = wordform.trim();
|
|
94
98
|
countText = (countText || '').trim().replace(/,/g, '');
|
|
@@ -102,7 +106,7 @@ function _parseWordList(wordlist, source) {
|
|
|
102
106
|
if (wordsSeenInThisFile.has(wordform)) {
|
|
103
107
|
// The same word seen across multiple files is fine,
|
|
104
108
|
// but a word seen multiple times in one file is a problem!
|
|
105
|
-
|
|
109
|
+
callbacks.reportMessage(ModelCompilerMessages.Warn_DuplicateWordInSameFile({ wordform: wordform }));
|
|
106
110
|
}
|
|
107
111
|
wordsSeenInThisFile.add(wordform);
|
|
108
112
|
wordlist[wordform] = (isNaN(wordlist[wordform]) ? 0 : wordlist[wordform] || 0) + count;
|
|
@@ -322,7 +326,7 @@ var Trie;
|
|
|
322
326
|
.reduce((acc, count) => acc + count, 0);
|
|
323
327
|
}
|
|
324
328
|
if (isNaN(val)) {
|
|
325
|
-
|
|
329
|
+
throw new Error("Unexpected NaN has appeared!");
|
|
326
330
|
}
|
|
327
331
|
return val;
|
|
328
332
|
}
|
|
@@ -352,7 +356,7 @@ function detectEncoding(filename) {
|
|
|
352
356
|
else if (buffer[0] == 0xFE && buffer[1] == 0xFF) {
|
|
353
357
|
// Big Endian, is NOT supported because Node does not support it (???)
|
|
354
358
|
// See: https://stackoverflow.com/a/14551669/6626414
|
|
355
|
-
throw new
|
|
359
|
+
throw new ModelCompilerError(ModelCompilerMessages.Error_UTF16BEUnsupported());
|
|
356
360
|
}
|
|
357
361
|
else {
|
|
358
362
|
// Assume its in UTF-8, with or without a BOM.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-trie.js","sourceRoot":"","sources":["../../src/build-trie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"build-trie.js","sourceRoot":"","sources":["../../src/build-trie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,wCAAwC;AACxC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAW1C;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAmB,EAAE,eAAwC;IACnG,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE;QACzC,MAAM,IAAI,kBAAkB,CAAC,qBAAqB,CAAC,8CAA8C,EAAE,CAAC,CAAC;KACtG;IACD,+DAA+D;IAC/D,IAAI,QAAQ,GAAa,EAAE,CAAC;IAC5B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE7E,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,eAAuC,CAAC,CAAC;IAC7E,OAA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C;KACf;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-callbacks.d.ts","sourceRoot":"","sources":["../../src/compiler-callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,eAAO,IAAI,SAAS,EAAE,iBAAiB,CAAC;AAExC,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,iBAAiB,QAExD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-callbacks.js","sourceRoot":"","sources":["../../src/compiler-callbacks.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,IAAI,SAA4B,CAAC;AAExC,MAAM,UAAU,oBAAoB,CAAC,CAAoB;IACvD,SAAS,GAAG,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -12,8 +12,5 @@ export default class LexicalModelCompiler {
|
|
|
12
12
|
*/
|
|
13
13
|
generateLexicalModelCode(model_id: string, modelSource: LexicalModelSource, sourcePath: string): string;
|
|
14
14
|
transpileSources(sources: Array<string>): Array<string>;
|
|
15
|
-
logError(s: string): void;
|
|
16
|
-
}
|
|
17
|
-
export declare class ModelSourceError extends Error {
|
|
18
15
|
}
|
|
19
16
|
//# sourceMappingURL=lexical-model-compiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexical-model-compiler.d.ts","sourceRoot":"","sources":["../../src/lexical-model-compiler.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAA0C,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"lexical-model-compiler.d.ts","sourceRoot":"","sources":["../../src/lexical-model-compiler.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAA0C,MAAM,oBAAoB,CAAC;AAGhG,MAAM,CAAC,OAAO,OAAO,oBAAoB;IAEvC;;;;;;;;OAQG;IACH,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM;IAiE9F,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;CAUxD"}
|
|
@@ -9,6 +9,7 @@ import { createTrieDataStructure } from "./build-trie.js";
|
|
|
9
9
|
import { ModelDefinitions } from "./model-definitions.js";
|
|
10
10
|
import { decorateWithJoin } from "./join-word-breaker-decorator.js";
|
|
11
11
|
import { decorateWithScriptOverrides } from "./script-overrides-decorator.js";
|
|
12
|
+
import { ModelCompilerError, ModelCompilerMessages } from "./model-compiler-errors.js";
|
|
12
13
|
export default class LexicalModelCompiler {
|
|
13
14
|
/**
|
|
14
15
|
* Returns the generated code for the model that will ultimately be loaded by
|
|
@@ -36,7 +37,7 @@ export default class LexicalModelCompiler {
|
|
|
36
37
|
func += `LMLayerWorker.loadModel(new ${modelSource.rootClass}());\n`;
|
|
37
38
|
break;
|
|
38
39
|
case "fst-foma-1.0":
|
|
39
|
-
throw new
|
|
40
|
+
throw new ModelCompilerError(ModelCompilerMessages.Error_UnimplementedModelFormat({ format: modelSource.format }));
|
|
40
41
|
case "trie-1.0":
|
|
41
42
|
// Convert all relative path names to paths relative to the enclosing
|
|
42
43
|
// directory. This way, we'll read the files relative to the model.ts
|
|
@@ -64,7 +65,7 @@ export default class LexicalModelCompiler {
|
|
|
64
65
|
func += `}));\n`;
|
|
65
66
|
break;
|
|
66
67
|
default:
|
|
67
|
-
throw new
|
|
68
|
+
throw new ModelCompilerError(ModelCompilerMessages.Error_UnknownModelFormat({ format: modelSource.format }));
|
|
68
69
|
}
|
|
69
70
|
func += fileSuffix;
|
|
70
71
|
return func;
|
|
@@ -78,14 +79,8 @@ export default class LexicalModelCompiler {
|
|
|
78
79
|
}).outputText);
|
|
79
80
|
}
|
|
80
81
|
;
|
|
81
|
-
logError(s) {
|
|
82
|
-
console.error(require('chalk').red(s));
|
|
83
|
-
}
|
|
84
|
-
;
|
|
85
82
|
}
|
|
86
83
|
;
|
|
87
|
-
export class ModelSourceError extends Error {
|
|
88
|
-
}
|
|
89
84
|
/**
|
|
90
85
|
* Returns a JavaScript expression (as a string) that can serve as a word
|
|
91
86
|
* breaking function.
|
|
@@ -146,7 +141,7 @@ function normalizeWordBreakerSpec(wordBreakerSpec) {
|
|
|
146
141
|
return wordBreakerSpec;
|
|
147
142
|
}
|
|
148
143
|
else {
|
|
149
|
-
throw new
|
|
144
|
+
throw new ModelCompilerError(ModelCompilerMessages.Error_UnknownWordBreaker({ spec: wordBreakerSpec.toString() }));
|
|
150
145
|
}
|
|
151
146
|
}
|
|
152
147
|
function isSimpleWordBreaker(spec) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexical-model-compiler.js","sourceRoot":"","sources":["../../src/lexical-model-compiler.ts"],"names":[],"mappings":"AAAA;;EAEE;AAEF,2CAA2C;AAE3C,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAC,2BAA2B,EAAC,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"lexical-model-compiler.js","sourceRoot":"","sources":["../../src/lexical-model-compiler.ts"],"names":[],"mappings":"AAAA;;EAEE;AAEF,2CAA2C;AAE3C,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,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I,CAAC,QAAQ,EAAE;YACpB,uEAAuE;YACvE,kBAAkB;aACjB,OAAO,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;KAChD;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,wBAAwB,CAAC,eAAkD;IAClF,IAAI,eAAe,IAAI,SAAS,EAAE;QAChC,qDAAqD;QACrD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;KAC3B;SAAM,IAAI,mBAAmB,CAAC,eAAe,CAAC,EAAE;QAC/C,0EAA0E;QAC1E,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;KACjC;SAAM,IAAI,eAAe,CAAC,GAAG,EAAE;QAC9B,OAAO,eAAe,CAAC;KACxB;SAAM;QACL,MAAM,IAAI,kBAAkB,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,EAAC,IAAI,EAAE,eAAe,CAAC,QAAQ,EAAE,EAAC,CAAC,CAAC,CAAC;KAClH;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,IAA6C;IACxE,OAAO,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,OAAO,CAAC;AAC9E,CAAC"}
|
package/build/src/main.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { CompilerCallbacks } from '@keymanapp/common-types';
|
|
1
2
|
import { LexicalModelSource } from './lexical-model.js';
|
|
2
3
|
/**
|
|
3
4
|
* Compiles a model.ts file, using paths relative to its location.
|
|
4
5
|
*
|
|
5
6
|
* @param filename path to model.ts source.
|
|
6
|
-
* @return model source code
|
|
7
|
+
* @return model source code, or null on error
|
|
7
8
|
*/
|
|
8
|
-
export declare function compileModel(filename: string): string;
|
|
9
|
+
export declare function compileModel(filename: string, callbacks: CompilerCallbacks): string;
|
|
9
10
|
/**
|
|
10
11
|
* Loads a lexical model's source module from the given filename.
|
|
11
12
|
*
|
|
12
13
|
* @param filename path to the model source file.
|
|
13
14
|
*/
|
|
14
|
-
export declare function loadFromFilename(filename: string): LexicalModelSource;
|
|
15
|
+
export declare function loadFromFilename(filename: string, callbacks: CompilerCallbacks): LexicalModelSource;
|
|
15
16
|
//# sourceMappingURL=main.d.ts.map
|
package/build/src/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAO5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAiBnF;AAWD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,kBAAkB,CA6BnG"}
|
package/build/src/main.js
CHANGED
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
+
import { setCompilerCallbacks } from './compiler-callbacks.js';
|
|
4
5
|
import LexicalModelCompiler from './lexical-model-compiler.js';
|
|
6
|
+
import { ModelCompilerError, ModelCompilerMessages } from './model-compiler-errors.js';
|
|
5
7
|
/**
|
|
6
8
|
* Compiles a model.ts file, using paths relative to its location.
|
|
7
9
|
*
|
|
8
10
|
* @param filename path to model.ts source.
|
|
9
|
-
* @return model source code
|
|
11
|
+
* @return model source code, or null on error
|
|
10
12
|
*/
|
|
11
|
-
export function compileModel(filename) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.
|
|
13
|
+
export function compileModel(filename, callbacks) {
|
|
14
|
+
setCompilerCallbacks(callbacks);
|
|
15
|
+
try {
|
|
16
|
+
let modelSource = loadFromFilename(filename, callbacks);
|
|
17
|
+
let containingDirectory = path.dirname(filename);
|
|
18
|
+
return (new LexicalModelCompiler)
|
|
19
|
+
.generateLexicalModelCode('<unknown>', modelSource, containingDirectory);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
callbacks.reportMessage(e instanceof ModelCompilerError
|
|
23
|
+
? e.event
|
|
24
|
+
: ModelCompilerMessages.Fatal_UnexpectedException({ e: e }));
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
16
27
|
}
|
|
17
28
|
/**
|
|
18
29
|
* Loads a lexical model's source module from the given filename.
|
|
19
30
|
*
|
|
20
31
|
* @param filename path to the model source file.
|
|
21
32
|
*/
|
|
22
|
-
export function loadFromFilename(filename) {
|
|
33
|
+
export function loadFromFilename(filename, callbacks) {
|
|
34
|
+
setCompilerCallbacks(callbacks);
|
|
23
35
|
let sourceCode = fs.readFileSync(filename, 'utf8');
|
|
24
36
|
// Compile the module to JavaScript code.
|
|
25
37
|
// NOTE: transpile module does a very simple TS to JS compilation.
|
|
26
38
|
// It DOES NOT check for types!
|
|
27
39
|
let compilationOutput = ts.transpile(sourceCode, {
|
|
28
40
|
// Our runtime only supports ES3 with Node/CommonJS modules on Android 5.0.
|
|
29
|
-
// When we drop Android 5.0 support, we can update this to a `ScriptTarget`
|
|
30
|
-
// matrix against target version of Keyman, here and in
|
|
41
|
+
// When we drop Android 5.0 support, we can update this to a `ScriptTarget`
|
|
42
|
+
// matrix against target version of Keyman, here and in
|
|
31
43
|
// lexical-model-compiler.ts.
|
|
32
44
|
target: ts.ScriptTarget.ES3,
|
|
33
45
|
module: ts.ModuleKind.CommonJS,
|
|
@@ -39,7 +51,8 @@ export function loadFromFilename(filename) {
|
|
|
39
51
|
let module = eval(moduleCode);
|
|
40
52
|
module(moduleExports);
|
|
41
53
|
if (!moduleExports['__esModule'] || !moduleExports['default']) {
|
|
42
|
-
|
|
54
|
+
ModelCompilerMessages.filename = filename;
|
|
55
|
+
throw new ModelCompilerError(ModelCompilerMessages.Error_NoDefaultExport());
|
|
43
56
|
}
|
|
44
57
|
return moduleExports['default'];
|
|
45
58
|
}
|
package/build/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,oBAAoB,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEvF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,SAA4B;IACzE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAEhC,IAAI;QACF,IAAI,WAAW,GAAG,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACxD,IAAI,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEjD,OAAO,CAAC,IAAI,oBAAoB,CAAC;aAC9B,wBAAwB,CAAC,WAAW,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC;KAC5E;IAAC,OAAM,CAAC,EAAE;QACT,SAAS,CAAC,aAAa,CACrB,CAAC,YAAY,kBAAkB;YAC/B,CAAC,CAAC,CAAC,CAAC,KAAK;YACT,CAAC,CAAC,qBAAqB,CAAC,yBAAyB,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CACzD,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAWD;;;;GAIG;AACH,MAAM,UA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-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* @param code Error code
|
|
40
|
-
* @param message A helpful message!
|
|
41
|
-
* @param source [optional] the filename/line number in the source that induced this error
|
|
42
|
-
*
|
|
43
|
-
* @see https://github.com/keymanapp/keyman/blob/99db3c0d2448f448242e6397f9d72e9a7ccee4b9/windows/src/developer/TIKE/project/Keyman.Developer.System.Project.ProjectLog.pas#L60-L77
|
|
44
|
-
*/
|
|
45
|
-
export declare function log(code: KeymanCompilerError, message: string, source?: FilenameAndLineNo): void;
|
|
46
|
-
/**
|
|
47
|
-
* Override where log messages go.
|
|
48
|
-
*
|
|
49
|
-
* @param fn The desired log message handler.
|
|
50
|
-
*/
|
|
51
|
-
export declare function redirectLogMessagesTo(fn: (log: LogMessage) => void): void;
|
|
52
|
-
/**
|
|
53
|
-
* Reset the log message handler to the default.
|
|
54
|
-
*/
|
|
55
|
-
export declare function resetLogMessageHandler(): void;
|
|
56
|
-
/**
|
|
57
|
-
* Prints log messages to stdout. The default log action.
|
|
58
|
-
*/
|
|
59
|
-
export declare function printLogs(log: LogMessage): void;
|
|
60
|
-
/**
|
|
61
|
-
* Duct tapes together a filename and a line number of a log.
|
|
62
|
-
*/
|
|
63
|
-
interface FilenameAndLineNo {
|
|
64
|
-
readonly filename: string;
|
|
65
|
-
readonly lineno: number;
|
|
1
|
+
import { CompilerEvent } from "@keymanapp/common-types";
|
|
2
|
+
export declare class ModelCompilerMessages {
|
|
3
|
+
static line: number;
|
|
4
|
+
static filename: string;
|
|
5
|
+
static Fatal_UnexpectedException: (o: {
|
|
6
|
+
e: any;
|
|
7
|
+
}) => CompilerEvent;
|
|
8
|
+
static FATAL_UnexpectedException: number;
|
|
9
|
+
static Warn_MixedNormalizationForms: (o: {
|
|
10
|
+
wordform: string;
|
|
11
|
+
}) => CompilerEvent;
|
|
12
|
+
static WARN_MixedNormalizationForms: number;
|
|
13
|
+
static Warn_DuplicateWordInSameFile: (o: {
|
|
14
|
+
wordform: string;
|
|
15
|
+
}) => CompilerEvent;
|
|
16
|
+
static WARN_DuplicateWordInSameFile: number;
|
|
17
|
+
static Error_UnimplementedModelFormat: (o: {
|
|
18
|
+
format: string;
|
|
19
|
+
}) => CompilerEvent;
|
|
20
|
+
static ERROR_UnimplementedModelFormat: number;
|
|
21
|
+
static Error_UnknownModelFormat: (o: {
|
|
22
|
+
format: string;
|
|
23
|
+
}) => CompilerEvent;
|
|
24
|
+
static ERROR_UnknownModelFormat: number;
|
|
25
|
+
static Error_NoDefaultExport: () => CompilerEvent;
|
|
26
|
+
static ERROR_NoDefaultExport: number;
|
|
27
|
+
static Error_SearchTermToKeyMustBeExplicitlySpecified: () => CompilerEvent;
|
|
28
|
+
static ERROR_SearchTermToKeyMustBeExplicitlySpecified: number;
|
|
29
|
+
static Error_UTF16BEUnsupported: () => CompilerEvent;
|
|
30
|
+
static ERROR_UTF16BEUnsupported: number;
|
|
31
|
+
static Error_UnknownWordBreaker: (o: {
|
|
32
|
+
spec: string;
|
|
33
|
+
}) => CompilerEvent;
|
|
34
|
+
static ERROR_UnknownWordBreaker: number;
|
|
35
|
+
static Error_UnsupportedScriptOverride: (o: {
|
|
36
|
+
option: string;
|
|
37
|
+
}) => CompilerEvent;
|
|
38
|
+
static ERROR_UnsupportedScriptOverride: number;
|
|
66
39
|
}
|
|
67
40
|
/**
|
|
68
|
-
* A
|
|
41
|
+
* A ModelCompilerError should be thrown when an unrecoverable error occurs that
|
|
42
|
+
* would block further compilation. It will be caught in the top-most compiler
|
|
43
|
+
* API endpoint and converted into a callback message.
|
|
69
44
|
*/
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
readonly message: string;
|
|
74
|
-
format(): string;
|
|
45
|
+
export declare class ModelCompilerError extends Error {
|
|
46
|
+
event: CompilerEvent;
|
|
47
|
+
constructor(event: CompilerEvent);
|
|
75
48
|
}
|
|
76
|
-
export {};
|
|
77
49
|
//# sourceMappingURL=model-compiler-errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-compiler-errors.d.ts","sourceRoot":"","sources":["../../src/model-compiler-errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-compiler-errors.d.ts","sourceRoot":"","sources":["../../src/model-compiler-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAgBvG,qBAAa,qBAAqB;IAEhC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;IAExB,MAAM,CAAC,yBAAyB,MAAM;QAAC,CAAC,EAAE,GAAG,CAAA;KAAC,mBACgG;IAC9I,MAAM,CAAC,yBAAyB,SAAqB;IAErD,MAAM,CAAC,4BAA4B,MAAM;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,mBACkB;IAC7E,MAAM,CAAC,4BAA4B,SAAoB;IAEvD,MAAM,CAAC,4BAA4B,MAAM;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,mBACY;IACvE,MAAM,CAAC,4BAA4B,SAAqB;IAExD,MAAM,CAAC,8BAA8B,MAAM;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,mBACd;IAC7C,MAAM,CAAC,8BAA8B,SAAqB;IAE1D,MAAM,CAAC,wBAAwB,MAAM;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,mBACR;IAC7C,MAAM,CAAC,wBAAwB,SAAqB;IAEpD,MAAM,CAAC,qBAAqB,sBACwE;IACpG,MAAM,CAAC,qBAAqB,SAAqB;IAEjD,MAAM,CAAC,8CAA8C,sBACH;IAClD,MAAM,CAAC,8CAA8C,SAAqB;IAE1E,MAAM,CAAC,wBAAwB,sBAAqE;IACpG,MAAM,CAAC,wBAAwB,SAAqB;IAEpD,MAAM,CAAC,wBAAwB,MAAM;QAAC,IAAI,EAAC,MAAM,CAAA;KAAC,mBACb;IACrC,MAAM,CAAC,wBAAwB,SAAqB;IAEpD,MAAM,CAAC,+BAA+B,MAAM;QAAC,MAAM,EAAC,MAAM,CAAA;KAAC,mBACb;IAC9C,MAAM,CAAC,+BAA+B,SAAqB;CAC5D;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IACxB,KAAK,EAAE,aAAa;gBAApB,KAAK,EAAE,aAAa;CAGxC"}
|
|
@@ -1,156 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
LogLevel[LogLevel["CERR_WARNING"] = 8192] = "CERR_WARNING";
|
|
16
|
-
LogLevel[LogLevel["CERR_HINT"] = 4096] = "CERR_HINT";
|
|
17
|
-
})(LogLevel || (LogLevel = {}));
|
|
18
|
-
;
|
|
19
|
-
/**
|
|
20
|
-
* Error codes. Use these when logging messages.
|
|
21
|
-
*
|
|
22
|
-
* Extends https://github.com/keymanapp/keyman/blob/99db3c0d2448f448242e6397f9d72e9a7ccee4b9/windows/src/global/inc/Comperr.h
|
|
23
|
-
*/
|
|
24
|
-
export var KeymanCompilerError;
|
|
25
|
-
(function (KeymanCompilerError) {
|
|
26
|
-
KeymanCompilerError[KeymanCompilerError["CERR_LEXICAL_MODEL_MIN"] = 2048] = "CERR_LEXICAL_MODEL_MIN";
|
|
27
|
-
KeymanCompilerError[KeymanCompilerError["CERR_LEXICAL_MODEL_MAX"] = 2303] = "CERR_LEXICAL_MODEL_MAX";
|
|
28
|
-
KeymanCompilerError[KeymanCompilerError["CERR_FATAL_LM"] = 34816] = "CERR_FATAL_LM";
|
|
29
|
-
/* Place all fatal LM compiler errors here! */
|
|
30
|
-
KeymanCompilerError[KeymanCompilerError["CERR_ERROR_LM"] = 18432] = "CERR_ERROR_LM";
|
|
31
|
-
/* Place all recoverable LM compiler errors here! */
|
|
32
|
-
KeymanCompilerError[KeymanCompilerError["CERR_WARN_LM"] = 10240] = "CERR_WARN_LM";
|
|
33
|
-
/* Place all LM compiler warnings here! */
|
|
34
|
-
KeymanCompilerError[KeymanCompilerError["CWARN_MixedNormalizationForms"] = 10241] = "CWARN_MixedNormalizationForms";
|
|
35
|
-
KeymanCompilerError[KeymanCompilerError["CWARN_DuplicateWordInSameFile"] = 10242] = "CWARN_DuplicateWordInSameFile";
|
|
36
|
-
KeymanCompilerError[KeymanCompilerError["CERR_HINT_LM"] = 6144] = "CERR_HINT_LM";
|
|
37
|
-
/* Place all LM compiler hints here! */
|
|
38
|
-
/* Errors that are not specific to the lexical model compiler, from comperr.h: */
|
|
39
|
-
KeymanCompilerError[KeymanCompilerError["CWARN_TooManyErrorsOrWarnings"] = 8359] = "CWARN_TooManyErrorsOrWarnings";
|
|
40
|
-
})(KeymanCompilerError || (KeymanCompilerError = {}));
|
|
41
|
-
/**
|
|
42
|
-
* Human-readable titles for the various log levels.
|
|
43
|
-
*
|
|
44
|
-
* Taken from https://github.com/keymanapp/keyman/blob/d83cfffe511ce65b781f919e89e3693146844849/windows/src/developer/TIKE/project/Keyman.Developer.System.Project.ProjectLog.pas#L39-L46
|
|
45
|
-
*/
|
|
46
|
-
const LOG_LEVEL_TITLE = {
|
|
47
|
-
[LogLevel.CERR_HINT]: 'Hint',
|
|
48
|
-
[LogLevel.CERR_WARNING]: 'Warning',
|
|
49
|
-
[LogLevel.CERR_ERROR]: 'Error',
|
|
50
|
-
[LogLevel.CERR_FATAL]: 'Fatal Error',
|
|
1
|
+
import { CompilerErrorNamespace, CompilerErrorSeverity } from "@keymanapp/common-types";
|
|
2
|
+
const Namespace = CompilerErrorNamespace.ModelCompiler;
|
|
3
|
+
// const SevInfo = CompilerErrorSeverity.Info | Namespace;
|
|
4
|
+
// const SevHint = CompilerErrorSeverity.Hint | Namespace;
|
|
5
|
+
const SevWarn = CompilerErrorSeverity.Warn | Namespace;
|
|
6
|
+
const SevError = CompilerErrorSeverity.Error | Namespace;
|
|
7
|
+
const SevFatal = CompilerErrorSeverity.Fatal | Namespace;
|
|
8
|
+
const m = (code, message) => {
|
|
9
|
+
return {
|
|
10
|
+
line: ModelCompilerMessages.line,
|
|
11
|
+
filename: ModelCompilerMessages.filename,
|
|
12
|
+
code,
|
|
13
|
+
message
|
|
14
|
+
};
|
|
51
15
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return;
|
|
77
|
-
let logMessage = source
|
|
78
|
-
? new LogMessageFromSource(code, message, source)
|
|
79
|
-
: new OrdinaryLogMessage(code, message);
|
|
80
|
-
_logHandler(logMessage);
|
|
81
|
-
_messagesSeen++;
|
|
82
|
-
if (_messagesSeen > MAX_MESSAGES) {
|
|
83
|
-
_logHandler(new OrdinaryLogMessage(KeymanCompilerError.CWARN_TooManyErrorsOrWarnings, `More than ${MAX_MESSAGES} warnings or errors received; suppressing further messages`));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Override where log messages go.
|
|
88
|
-
*
|
|
89
|
-
* @param fn The desired log message handler.
|
|
90
|
-
*/
|
|
91
|
-
export function redirectLogMessagesTo(fn) {
|
|
92
|
-
_logHandler = fn;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Reset the log message handler to the default.
|
|
96
|
-
*/
|
|
97
|
-
export function resetLogMessageHandler() {
|
|
98
|
-
_logHandler = printLogs;
|
|
99
|
-
_messagesSeen = 0;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Prints log messages to stdout. The default log action.
|
|
103
|
-
*/
|
|
104
|
-
export function printLogs(log) {
|
|
105
|
-
console.log(log.format());
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Concrete implementation of the log message.
|
|
109
|
-
*/
|
|
110
|
-
class OrdinaryLogMessage {
|
|
111
|
-
code;
|
|
112
|
-
message;
|
|
113
|
-
constructor(code, message) {
|
|
114
|
-
this.code = code;
|
|
115
|
-
this.message = message;
|
|
116
|
-
}
|
|
117
|
-
get level() {
|
|
118
|
-
return this.code & 0xF000;
|
|
119
|
-
}
|
|
120
|
-
determineLogLevelTitle() {
|
|
121
|
-
return LOG_LEVEL_TITLE[this.level] || '';
|
|
122
|
-
}
|
|
123
|
-
format() {
|
|
124
|
-
let prefix = this.determineLogLevelTitle();
|
|
125
|
-
if (prefix)
|
|
126
|
-
prefix = `${prefix}: `;
|
|
127
|
-
return `${prefix}${h(this.code)} ${this.message}`;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* A log message with a filename and line number.
|
|
132
|
-
*/
|
|
133
|
-
class LogMessageFromSource extends OrdinaryLogMessage {
|
|
134
|
-
filename;
|
|
135
|
-
lineno;
|
|
136
|
-
constructor(code, message, source) {
|
|
137
|
-
super(code, message);
|
|
138
|
-
this.filename = source.filename;
|
|
139
|
-
this.lineno = source.lineno;
|
|
140
|
-
}
|
|
141
|
-
format() {
|
|
142
|
-
let originalMessage = super.format();
|
|
143
|
-
return `${this.filename} (${this.lineno}): ${originalMessage}`;
|
|
144
|
-
}
|
|
16
|
+
export class ModelCompilerMessages {
|
|
17
|
+
// Context added to all messages
|
|
18
|
+
static line;
|
|
19
|
+
static filename;
|
|
20
|
+
static Fatal_UnexpectedException = (o) => m(this.FATAL_UnexpectedException, `Unexpected exception: ${(o.e ?? 'unknown error').toString()}\n\nCall stack:\n${(o.e instanceof Error ? o.e.stack : (new Error()).stack)}`);
|
|
21
|
+
static FATAL_UnexpectedException = SevFatal | 0x0001;
|
|
22
|
+
static Warn_MixedNormalizationForms = (o) => m(this.WARN_MixedNormalizationForms, `“${o.wordform}” is not in Unicode NFC. Automatically converting to NFC.`);
|
|
23
|
+
static WARN_MixedNormalizationForms = SevWarn | 0x0002;
|
|
24
|
+
static Warn_DuplicateWordInSameFile = (o) => m(this.WARN_DuplicateWordInSameFile, `duplicate word “${o.wordform}” found in same file; summing counts`);
|
|
25
|
+
static WARN_DuplicateWordInSameFile = SevFatal | 0x0003;
|
|
26
|
+
static Error_UnimplementedModelFormat = (o) => m(this.ERROR_UnimplementedModelFormat, `Unimplemented model format: ${o.format}`);
|
|
27
|
+
static ERROR_UnimplementedModelFormat = SevError | 0x0004;
|
|
28
|
+
static Error_UnknownModelFormat = (o) => m(this.ERROR_UnknownModelFormat, `Unimplemented model format: ${o.format}`);
|
|
29
|
+
static ERROR_UnknownModelFormat = SevError | 0x0005;
|
|
30
|
+
static Error_NoDefaultExport = () => m(this.ERROR_NoDefaultExport, `Model source does have a default export. Did you remember to write \`export default source;\`?`);
|
|
31
|
+
static ERROR_NoDefaultExport = SevError | 0x0006;
|
|
32
|
+
static Error_SearchTermToKeyMustBeExplicitlySpecified = () => m(this.ERROR_SearchTermToKeyMustBeExplicitlySpecified, "searchTermToKey must be explicitly specified");
|
|
33
|
+
static ERROR_SearchTermToKeyMustBeExplicitlySpecified = SevError | 0x0007;
|
|
34
|
+
static Error_UTF16BEUnsupported = () => m(this.ERROR_UTF16BEUnsupported, 'UTF-16BE is unsupported');
|
|
35
|
+
static ERROR_UTF16BEUnsupported = SevError | 0x0008;
|
|
36
|
+
static Error_UnknownWordBreaker = (o) => m(this.ERROR_UnknownWordBreaker, `Unknown word breaker: ${o.spec}`);
|
|
37
|
+
static ERROR_UnknownWordBreaker = SevError | 0x0009;
|
|
38
|
+
static Error_UnsupportedScriptOverride = (o) => m(this.ERROR_UnsupportedScriptOverride, `Unsupported script override: ${o.option}`);
|
|
39
|
+
static ERROR_UnsupportedScriptOverride = SevError | 0x000A;
|
|
145
40
|
}
|
|
41
|
+
;
|
|
146
42
|
/**
|
|
147
|
-
*
|
|
43
|
+
* A ModelCompilerError should be thrown when an unrecoverable error occurs that
|
|
44
|
+
* would block further compilation. It will be caught in the top-most compiler
|
|
45
|
+
* API endpoint and converted into a callback message.
|
|
148
46
|
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
47
|
+
export class ModelCompilerError extends Error {
|
|
48
|
+
event;
|
|
49
|
+
constructor(event) {
|
|
50
|
+
super(event.message);
|
|
51
|
+
this.event = event;
|
|
153
52
|
}
|
|
154
|
-
return formatted;
|
|
155
53
|
}
|
|
156
54
|
//# sourceMappingURL=model-compiler-errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-compiler-errors.js","sourceRoot":"","sources":["../../src/model-compiler-errors.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"model-compiler-errors.js","sourceRoot":"","sources":["../../src/model-compiler-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAiB,MAAM,yBAAyB,CAAC;AAEvG,MAAM,SAAS,GAAG,sBAAsB,CAAC,aAAa,CAAC;AACvD,0DAA0D;AAC1D,0DAA0D;AAC1D,MAAM,OAAO,GAAG,qBAAqB,CAAC,IAAI,GAAG,SAAS,CAAC;AACvD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,GAAG,SAAS,CAAC;AACzD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,GAAG,SAAS,CAAC;AAEzD,MAAM,CAAC,GAAG,CAAC,IAAY,EAAE,OAAe,EAAkB,EAAE;IAAG,OAAO;QACpE,IAAI,EAAE,qBAAqB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,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QADJ,UAAK,GAAL,KAAK,CAAe;IAEvC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-overrides-decorator.d.ts","sourceRoot":"","sources":["../../src/script-overrides-decorator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"script-overrides-decorator.d.ts","sourceRoot":"","sources":["../../src/script-overrides-decorator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,sBAAsB,YAgB/D,MAAM,KAAG,IAAI,EAAE,CAwDxD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ModelCompilerError, ModelCompilerMessages } from "./model-compiler-errors.js";
|
|
1
2
|
export function decorateWithScriptOverrides(breaker, option) {
|
|
2
3
|
if (option !== 'break-words-at-spaces') {
|
|
3
|
-
throw new
|
|
4
|
+
throw new ModelCompilerError(ModelCompilerMessages.Error_UnsupportedScriptOverride({ option }));
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
6
7
|
* Matches if when a span contains a Southeast-Asian letter or mark anywhere.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-overrides-decorator.js","sourceRoot":"","sources":["../../src/script-overrides-decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"script-overrides-decorator.js","sourceRoot":"","sources":["../../src/script-overrides-decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEvF,MAAM,UAAU,2BAA2B,CAAC,OAA6B,EAAE,MAA8B;IACvG,IAAI,MAAM,KAAK,uBAAuB,EAAE;QACtC,MAAM,IAAI,kBAAkB,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SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SACjH;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;YACrC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;SAChC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,SAAS,QAAQ,CAAI,KAAU;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -31,8 +31,9 @@
|
|
|
31
31
|
"url": "https://github.com/keymanapp/keyman/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@keymanapp/keyman-version": "17.0.
|
|
35
|
-
"@keymanapp/models-types": "17.0.
|
|
34
|
+
"@keymanapp/keyman-version": "17.0.92-alpha",
|
|
35
|
+
"@keymanapp/models-types": "17.0.92-alpha",
|
|
36
|
+
"@keymanapp/common-types": "17.0.92-alpha",
|
|
36
37
|
"typescript": "^4.9.5",
|
|
37
38
|
"xml2js": "^0.4.19"
|
|
38
39
|
},
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"type": "git",
|
|
71
72
|
"url": "git+https://github.com/keymanapp/keyman.git"
|
|
72
73
|
},
|
|
73
|
-
"version": "17.0.
|
|
74
|
+
"version": "17.0.92-alpha"
|
|
74
75
|
}
|