@keymanapp/kmc-model 17.0.235-alpha → 17.0.237-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/lexical-model-compiler.d.ts +19 -5
- package/build/src/lexical-model-compiler.d.ts.map +1 -1
- package/build/src/lexical-model-compiler.js +66 -6
- package/build/src/lexical-model-compiler.js.map +1 -1
- package/build/src/main.d.ts +3 -18
- package/build/src/main.d.ts.map +1 -1
- package/build/src/main.js +3 -59
- package/build/src/main.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1bc80df3-48dc-5244-9634-1f202c49337f")}catch(e){}}();
|
|
2
2
|
import { LexicalModelSource } from "./lexical-model.js";
|
|
3
|
-
import { CompilerCallbacks } from "@keymanapp/common-types";
|
|
4
|
-
export
|
|
5
|
-
|
|
3
|
+
import { CompilerCallbacks, CompilerOptions, KeymanCompiler, KeymanCompilerArtifact, KeymanCompilerArtifacts, KeymanCompilerResult } from "@keymanapp/common-types";
|
|
4
|
+
export interface LexicalModelCompilerArtifacts extends KeymanCompilerArtifacts {
|
|
5
|
+
js: KeymanCompilerArtifact;
|
|
6
|
+
}
|
|
7
|
+
export interface LexicalModelCompilerResult extends KeymanCompilerResult {
|
|
8
|
+
artifacts: LexicalModelCompilerArtifacts;
|
|
9
|
+
}
|
|
10
|
+
export declare class LexicalModelCompiler implements KeymanCompiler {
|
|
11
|
+
init(callbacks: CompilerCallbacks, _options: CompilerOptions): Promise<boolean>;
|
|
12
|
+
run(inputFilename: string, outputFilename?: string): Promise<LexicalModelCompilerResult>;
|
|
13
|
+
write(artifacts: LexicalModelCompilerArtifacts): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Loads a lexical model's source module from the given filename.
|
|
16
|
+
*
|
|
17
|
+
* @param filename path to the model source file.
|
|
18
|
+
*/
|
|
19
|
+
loadFromFilename(filename: string): LexicalModelSource;
|
|
6
20
|
/**
|
|
7
21
|
* Returns the generated code for the model that will ultimately be loaded by
|
|
8
22
|
* the LMLayer worker. This code contains all model parameters, and specifies
|
|
@@ -15,5 +29,5 @@ export default class LexicalModelCompiler {
|
|
|
15
29
|
generateLexicalModelCode(model_id: string, modelSource: LexicalModelSource, sourcePath: string): string;
|
|
16
30
|
transpileSources(sources: Array<string>): Array<string>;
|
|
17
31
|
}
|
|
18
|
-
//# debugId=
|
|
32
|
+
//# debugId=1bc80df3-48dc-5244-9634-1f202c49337f
|
|
19
33
|
//# sourceMappingURL=lexical-model-compiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"debug_id":"
|
|
1
|
+
{"debug_id":"1bc80df3-48dc-5244-9634-1f202c49337f","file":"lexical-model-compiler.d.ts","mappings":";AASA,OAAO,EAAE,kBAAkB,EAA0C,MAAM,oBAAoB,CAAC;AAGhG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAWpK,MAAM,WAAW,6BAA8B,SAAQ,uBAAuB;IAC5E,EAAE,EAAE,sBAAsB,CAAC;CAC5B;AAED,MAAM,WAAW,0BAA2B,SAAQ,oBAAoB;IACtE,SAAS,EAAE,6BAA6B,CAAC;CAC1C;AAED,qBAAa,oBAAqB,YAAW,cAAc;IAEnD,IAAI,CAAC,SAAS,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/E,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAwBxF,KAAK,CAAC,SAAS,EAAE,6BAA6B,GAAG,OAAO,CAAC,OAAO,CAAC;IAKvE;;;;OAIG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB;IA8B7D;;;;;;;;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","names":[],"sourceRoot":"","sources":["../../src/lexical-model-compiler.ts"],"version":3}
|
|
@@ -1,17 +1,77 @@
|
|
|
1
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a26d57c2-60f8-5a6d-8fe4-fa183fc38841")}catch(e){}}();
|
|
2
2
|
/*
|
|
3
3
|
lexical-model-compiler.ts: base file for lexical model compiler.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import ts from "typescript";
|
|
6
6
|
import { createTrieDataStructure } from "./build-trie.js";
|
|
7
7
|
import { ModelDefinitions } from "./model-definitions.js";
|
|
8
8
|
import { decorateWithJoin } from "./join-word-breaker-decorator.js";
|
|
9
9
|
import { decorateWithScriptOverrides } from "./script-overrides-decorator.js";
|
|
10
|
-
import { ModelCompilerError, ModelCompilerMessages } from "./model-compiler-errors.js";
|
|
10
|
+
import { ModelCompilerError, ModelCompilerMessageContext, ModelCompilerMessages } from "./model-compiler-errors.js";
|
|
11
11
|
import { callbacks, setCompilerCallbacks } from "./compiler-callbacks.js";
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
;
|
|
13
|
+
;
|
|
14
|
+
;
|
|
15
|
+
export class LexicalModelCompiler {
|
|
16
|
+
async init(callbacks, _options) {
|
|
14
17
|
setCompilerCallbacks(callbacks);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
async run(inputFilename, outputFilename) {
|
|
21
|
+
try {
|
|
22
|
+
let modelSource = this.loadFromFilename(inputFilename);
|
|
23
|
+
let containingDirectory = callbacks.path.dirname(inputFilename);
|
|
24
|
+
let code = this.generateLexicalModelCode('<unknown>', modelSource, containingDirectory);
|
|
25
|
+
const result = {
|
|
26
|
+
artifacts: {
|
|
27
|
+
js: {
|
|
28
|
+
data: new TextEncoder().encode(code),
|
|
29
|
+
filename: outputFilename ?? inputFilename.replace(/\.model\.ts$/, '.model.js')
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
callbacks.reportMessage(e instanceof ModelCompilerError
|
|
37
|
+
? e.event
|
|
38
|
+
: ModelCompilerMessages.Fatal_UnexpectedException({ e: e }));
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async write(artifacts) {
|
|
43
|
+
callbacks.fs.writeFileSync(artifacts.js.filename, artifacts.js.data);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Loads a lexical model's source module from the given filename.
|
|
48
|
+
*
|
|
49
|
+
* @param filename path to the model source file.
|
|
50
|
+
*/
|
|
51
|
+
loadFromFilename(filename) {
|
|
52
|
+
let sourceCode = new TextDecoder().decode(callbacks.loadFile(filename));
|
|
53
|
+
// Compile the module to JavaScript code.
|
|
54
|
+
// NOTE: transpile module does a very simple TS to JS compilation.
|
|
55
|
+
// It DOES NOT check for types!
|
|
56
|
+
let compilationOutput = ts.transpile(sourceCode, {
|
|
57
|
+
// Our runtime only supports ES3 with Node/CommonJS modules on Android 5.0.
|
|
58
|
+
// When we drop Android 5.0 support, we can update this to a `ScriptTarget`
|
|
59
|
+
// matrix against target version of Keyman, here and in
|
|
60
|
+
// lexical-model-compiler.ts.
|
|
61
|
+
target: ts.ScriptTarget.ES3,
|
|
62
|
+
module: ts.ModuleKind.CommonJS,
|
|
63
|
+
});
|
|
64
|
+
// Turn the module into a function in which we can inject a global.
|
|
65
|
+
let moduleCode = '(function(exports){' + compilationOutput + '})';
|
|
66
|
+
// Run the module; its exports will be assigned to `moduleExports`.
|
|
67
|
+
let moduleExports = {};
|
|
68
|
+
let module = eval(moduleCode);
|
|
69
|
+
module(moduleExports);
|
|
70
|
+
if (!moduleExports['__esModule'] || !moduleExports['default']) {
|
|
71
|
+
ModelCompilerMessageContext.filename = filename;
|
|
72
|
+
throw new ModelCompilerError(ModelCompilerMessages.Error_NoDefaultExport());
|
|
73
|
+
}
|
|
74
|
+
return moduleExports['default'];
|
|
15
75
|
}
|
|
16
76
|
/**
|
|
17
77
|
* Returns the generated code for the model that will ultimately be loaded by
|
|
@@ -149,5 +209,5 @@ function normalizeWordBreakerSpec(wordBreakerSpec) {
|
|
|
149
209
|
function isSimpleWordBreaker(spec) {
|
|
150
210
|
return typeof spec === "function" || spec === "default" || spec === "ascii";
|
|
151
211
|
}
|
|
152
|
-
//# debugId=
|
|
212
|
+
//# debugId=a26d57c2-60f8-5a6d-8fe4-fa183fc38841
|
|
153
213
|
//# sourceMappingURL=lexical-model-compiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"debug_id":"
|
|
1
|
+
{"debug_id":"a26d57c2-60f8-5a6d-8fe4-fa183fc38841","file":"lexical-model-compiler.js","mappings":";AAAA;;EAEE;AAEF,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE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,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","names":[],"sourceRoot":"","sources":["../../src/lexical-model-compiler.ts"],"version":3}
|
package/build/src/main.d.ts
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { default as LexicalModelCompiler } from './lexical-model-compiler.js';
|
|
5
|
-
/**
|
|
6
|
-
* Compiles a model.ts file, using paths relative to its location.
|
|
7
|
-
*
|
|
8
|
-
* @param filename path to model.ts source.
|
|
9
|
-
* @return model source code, or null on error
|
|
10
|
-
*/
|
|
11
|
-
export declare function compileModel(filename: string, callbacks: CompilerCallbacks): string;
|
|
12
|
-
/**
|
|
13
|
-
* Loads a lexical model's source module from the given filename.
|
|
14
|
-
*
|
|
15
|
-
* @param filename path to the model source file.
|
|
16
|
-
*/
|
|
17
|
-
export declare function loadFromFilename(filename: string, callbacks: CompilerCallbacks): LexicalModelSource;
|
|
18
|
-
//# debugId=914ad039-c717-5956-b13a-c57d240219d0
|
|
1
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="adea63ba-5b29-50fc-a3e5-04032e9ec24a")}catch(e){}}();
|
|
2
|
+
export { LexicalModelCompiler } from './lexical-model-compiler.js';
|
|
3
|
+
//# debugId=adea63ba-5b29-50fc-a3e5-04032e9ec24a
|
|
19
4
|
//# sourceMappingURL=main.d.ts.map
|
package/build/src/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"debug_id":"
|
|
1
|
+
{"debug_id":"adea63ba-5b29-50fc-a3e5-04032e9ec24a","file":"main.d.ts","mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC","names":[],"sourceRoot":"","sources":["../../src/main.ts"],"version":3}
|
package/build/src/main.js
CHANGED
|
@@ -1,60 +1,4 @@
|
|
|
1
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import LexicalModelCompiler from './lexical-model-compiler.js';
|
|
5
|
-
import { ModelCompilerError, ModelCompilerMessageContext, ModelCompilerMessages } from './model-compiler-errors.js';
|
|
6
|
-
export { default as LexicalModelCompiler } from './lexical-model-compiler.js';
|
|
7
|
-
/**
|
|
8
|
-
* Compiles a model.ts file, using paths relative to its location.
|
|
9
|
-
*
|
|
10
|
-
* @param filename path to model.ts source.
|
|
11
|
-
* @return model source code, or null on error
|
|
12
|
-
*/
|
|
13
|
-
export function compileModel(filename, callbacks) {
|
|
14
|
-
setCompilerCallbacks(callbacks);
|
|
15
|
-
try {
|
|
16
|
-
let modelSource = loadFromFilename(filename, callbacks);
|
|
17
|
-
let containingDirectory = callbacks.path.dirname(filename);
|
|
18
|
-
return (new LexicalModelCompiler(callbacks))
|
|
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;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Loads a lexical model's source module from the given filename.
|
|
30
|
-
*
|
|
31
|
-
* @param filename path to the model source file.
|
|
32
|
-
*/
|
|
33
|
-
export function loadFromFilename(filename, callbacks) {
|
|
34
|
-
setCompilerCallbacks(callbacks);
|
|
35
|
-
let sourceCode = new TextDecoder().decode(callbacks.loadFile(filename));
|
|
36
|
-
// Compile the module to JavaScript code.
|
|
37
|
-
// NOTE: transpile module does a very simple TS to JS compilation.
|
|
38
|
-
// It DOES NOT check for types!
|
|
39
|
-
let compilationOutput = ts.transpile(sourceCode, {
|
|
40
|
-
// Our runtime only supports ES3 with Node/CommonJS modules on Android 5.0.
|
|
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
|
|
43
|
-
// lexical-model-compiler.ts.
|
|
44
|
-
target: ts.ScriptTarget.ES3,
|
|
45
|
-
module: ts.ModuleKind.CommonJS,
|
|
46
|
-
});
|
|
47
|
-
// Turn the module into a function in which we can inject a global.
|
|
48
|
-
let moduleCode = '(function(exports){' + compilationOutput + '})';
|
|
49
|
-
// Run the module; its exports will be assigned to `moduleExports`.
|
|
50
|
-
let moduleExports = {};
|
|
51
|
-
let module = eval(moduleCode);
|
|
52
|
-
module(moduleExports);
|
|
53
|
-
if (!moduleExports['__esModule'] || !moduleExports['default']) {
|
|
54
|
-
ModelCompilerMessageContext.filename = filename;
|
|
55
|
-
throw new ModelCompilerError(ModelCompilerMessages.Error_NoDefaultExport());
|
|
56
|
-
}
|
|
57
|
-
return moduleExports['default'];
|
|
58
|
-
}
|
|
59
|
-
//# debugId=f09f4d7a-0757-5697-8d03-cea9f4438922
|
|
1
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6c5a0612-dc21-5041-a778-84e934f144df")}catch(e){}}();
|
|
2
|
+
export { LexicalModelCompiler } from './lexical-model-compiler.js';
|
|
3
|
+
//# debugId=6c5a0612-dc21-5041-a778-84e934f144df
|
|
60
4
|
//# sourceMappingURL=main.js.map
|
package/build/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"debug_id":"
|
|
1
|
+
{"debug_id":"6c5a0612-dc21-5041-a778-84e934f144df","file":"main.js","mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC","names":[],"sourceRoot":"","sources":["../../src/main.ts"],"version":3}
|
package/package.json
CHANGED
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"url": "https://github.com/keymanapp/keyman/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@keymanapp/common-types": "17.0.
|
|
34
|
-
"@keymanapp/keyman-version": "17.0.
|
|
35
|
-
"@keymanapp/models-types": "17.0.
|
|
33
|
+
"@keymanapp/common-types": "17.0.237-alpha",
|
|
34
|
+
"@keymanapp/keyman-version": "17.0.237-alpha",
|
|
35
|
+
"@keymanapp/models-types": "17.0.237-alpha",
|
|
36
36
|
"typescript": "^4.9.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@keymanapp/developer-test-helpers": "17.0.
|
|
39
|
+
"@keymanapp/developer-test-helpers": "17.0.237-alpha",
|
|
40
40
|
"@types/chai": "^4.1.7",
|
|
41
41
|
"@types/mocha": "^5.2.7",
|
|
42
42
|
"@types/node": "^20.4.1",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"type": "git",
|
|
70
70
|
"url": "git+https://github.com/keymanapp/keyman.git"
|
|
71
71
|
},
|
|
72
|
-
"version": "17.0.
|
|
72
|
+
"version": "17.0.237-alpha"
|
|
73
73
|
}
|