@keymanapp/kmc-model-info 17.0.154-alpha → 17.0.156-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/messages.d.ts +28 -0
- package/build/src/messages.d.ts.map +1 -0
- package/build/src/messages.js +22 -0
- package/build/src/messages.js.map +1 -0
- package/build/src/min-keyman-version.d.ts +4 -2
- package/build/src/min-keyman-version.d.ts.map +1 -1
- package/build/src/min-keyman-version.js +4 -2
- package/build/src/min-keyman-version.js.map +1 -1
- package/build/src/model-info-compiler.d.ts +30 -29
- package/build/src/model-info-compiler.d.ts.map +1 -1
- package/build/src/model-info-compiler.js +133 -103
- package/build/src/model-info-compiler.js.map +1 -1
- package/build/src/model-info-file.d.ts +36 -32
- package/build/src/model-info-file.d.ts.map +1 -1
- package/build/src/model-info-file.js +4 -2
- package/build/src/model-info-file.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,28 @@
|
|
|
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]="076f4fcf-172c-57c9-be2e-ed668e0214bb")}catch(e){}}();
|
|
2
|
+
export declare class ModelInfoCompilerMessages {
|
|
3
|
+
static Fatal_UnexpectedException: (o: {
|
|
4
|
+
e: any;
|
|
5
|
+
}) => import("node_modules/@keymanapp/common-types/src/main.js").CompilerEvent;
|
|
6
|
+
static FATAL_UnexpectedException: number;
|
|
7
|
+
static Error_FileDoesNotExist: (o: {
|
|
8
|
+
filename: string;
|
|
9
|
+
}) => import("node_modules/@keymanapp/common-types/src/main.js").CompilerEvent;
|
|
10
|
+
static ERROR_FileDoesNotExist: number;
|
|
11
|
+
static Error_FileIsNotValid: (o: {
|
|
12
|
+
filename: string;
|
|
13
|
+
e: any;
|
|
14
|
+
}) => import("node_modules/@keymanapp/common-types/src/main.js").CompilerEvent;
|
|
15
|
+
static ERROR_FileIsNotValid: number;
|
|
16
|
+
static Warn_MetadataFieldInconsistent: (o: {
|
|
17
|
+
field: string;
|
|
18
|
+
value: any;
|
|
19
|
+
expected: any;
|
|
20
|
+
}) => import("node_modules/@keymanapp/common-types/src/main.js").CompilerEvent;
|
|
21
|
+
static WARN_MetadataFieldInconsistent: number;
|
|
22
|
+
static Error_InvalidAuthorEmail: (o: {
|
|
23
|
+
email: string;
|
|
24
|
+
}) => import("node_modules/@keymanapp/common-types/src/main.js").CompilerEvent;
|
|
25
|
+
static ERROR_InvalidAuthorEmail: number;
|
|
26
|
+
}
|
|
27
|
+
//# debugId=076f4fcf-172c-57c9-be2e-ed668e0214bb
|
|
28
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"debug_id":"076f4fcf-172c-57c9-be2e-ed668e0214bb","file":"messages.d.ts","mappings":";AASA,qBAAa,yBAAyB;IACpC,MAAM,CAAC,yBAAyB,MAAM;QAAC,CAAC,EAAE,GAAG,CAAA;KAAC,8EACgG;IAC9I,MAAM,CAAC,yBAAyB,SAAqB;IAErD,MAAM,CAAC,sBAAsB,MAAM;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,8EAA0E;IAC/H,MAAM,CAAC,sBAAsB,SAAqB;IAElD,MAAM,CAAC,oBAAoB,MAAM;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,GAAG,CAAA;KAAC,8EAC0B;IACrF,MAAM,CAAC,oBAAoB,SAAqB;IAEhD,MAAM,CAAC,8BAA8B,MAAM;QAAC,KAAK,EAAC,MAAM,CAAC;QAAC,KAAK,EAAC,GAAG,CAAC;QAAC,QAAQ,EAAC,GAAG,CAAA;KAAC,8EAC8B;IAChH,MAAM,CAAC,8BAA8B,SAAoB;IAEzD,MAAM,CAAC,wBAAwB,MAAM;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,8EACb;IACtC,MAAM,CAAC,wBAAwB,SAAqB;CAErD","names":[],"sourceRoot":"","sources":["../../src/messages.ts"],"version":3}
|
|
@@ -0,0 +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]="ee84771d-6eec-5b25-a408-899c3a64547a")}catch(e){}}();
|
|
2
|
+
import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m } from "@keymanapp/common-types";
|
|
3
|
+
const Namespace = CompilerErrorNamespace.ModelInfoCompiler;
|
|
4
|
+
// const SevInfo = CompilerErrorSeverity.Info | Namespace;
|
|
5
|
+
// const SevHint = CompilerErrorSeverity.Hint | Namespace;
|
|
6
|
+
const SevWarn = CompilerErrorSeverity.Warn | Namespace;
|
|
7
|
+
const SevError = CompilerErrorSeverity.Error | Namespace;
|
|
8
|
+
const SevFatal = CompilerErrorSeverity.Fatal | Namespace;
|
|
9
|
+
export class ModelInfoCompilerMessages {
|
|
10
|
+
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)}`);
|
|
11
|
+
static FATAL_UnexpectedException = SevFatal | 0x0001;
|
|
12
|
+
static Error_FileDoesNotExist = (o) => m(this.ERROR_FileDoesNotExist, `File ${o.filename} does not exist.`);
|
|
13
|
+
static ERROR_FileDoesNotExist = SevError | 0x0002;
|
|
14
|
+
static Error_FileIsNotValid = (o) => m(this.ERROR_FileIsNotValid, `File ${o.filename} could not be parsed: ${(o.e ?? 'unknown error').toString()}.`);
|
|
15
|
+
static ERROR_FileIsNotValid = SevError | 0x0003;
|
|
16
|
+
static Warn_MetadataFieldInconsistent = (o) => m(this.WARN_MetadataFieldInconsistent, `Warning: field ${o.field} value "${o.value}" does not match "${o.expected}" found in source file metadata.`);
|
|
17
|
+
static WARN_MetadataFieldInconsistent = SevWarn | 0x0004;
|
|
18
|
+
static Error_InvalidAuthorEmail = (o) => m(this.ERROR_InvalidAuthorEmail, `Invalid author email: ${o.email}`);
|
|
19
|
+
static ERROR_InvalidAuthorEmail = SevError | 0x0005;
|
|
20
|
+
}
|
|
21
|
+
//# debugId=ee84771d-6eec-5b25-a408-899c3a64547a
|
|
22
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"debug_id":"ee84771d-6eec-5b25-a408-899c3a64547a","file":"messages.js","mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,mBAAmB,IAAI,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAElH,MAAM,SAAS,GAAG,sBAAsB,CAAC,iBAAiB,CAAC;AAC3D,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,OAAO,yBAAyB;IACpC,MAAM,CAAC,yBAAyB,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,EACjF,yBAAyB,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC9I,MAAM,CAAC,yBAAyB,GAAG,QAAQ,GAAG,MAAM,CAAC;IAErD,MAAM,CAAC,sBAAsB,GAAG,CAAC,CAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,QAAQ,kBAAkB,CAAC,CAAC;IAC/H,MAAM,CAAC,sBAAsB,GAAG,QAAQ,GAAG,MAAM,CAAC;IAElD,MAAM,CAAC,oBAAoB,GAAG,CAAC,CAA4B,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,EACzF,QAAQ,CAAC,CAAC,QAAQ,yBAAyB,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACrF,MAAM,CAAC,oBAAoB,GAAG,QAAQ,GAAG,MAAM,CAAC;IAEhD,MAAM,CAAC,8BAA8B,GAAG,CAAC,CAAyC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,8BAA8B,EAC1H,kBAAkB,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,KAAK,qBAAqB,CAAC,CAAC,QAAQ,kCAAkC,CAAC,CAAC;IAChH,MAAM,CAAC,8BAA8B,GAAG,OAAO,GAAG,MAAM,CAAC;IAEzD,MAAM,CAAC,wBAAwB,GAAG,CAAC,CAAgB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,wBAAwB,EACrF,yBAAyB,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACtC,MAAM,CAAC,wBAAwB,GAAG,QAAQ,GAAG,MAAM,CAAC","names":[],"sourceRoot":"","sources":["../../src/messages.ts"],"version":3}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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]="91f7d314-b12b-539a-9118-8b4409d2b415")}catch(e){}}();
|
|
2
|
+
export declare const minKeymanVersion = "12.0";
|
|
3
|
+
//# debugId=91f7d314-b12b-539a-9118-8b4409d2b415
|
|
4
|
+
//# sourceMappingURL=min-keyman-version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"91f7d314-b12b-539a-9118-8b4409d2b415","file":"min-keyman-version.d.ts","mappings":";AAAA,eAAO,MAAM,gBAAgB,SAAS,CAAC","names":[],"sourceRoot":"","sources":["../../src/min-keyman-version.ts"],"version":3}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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]="4e395607-c79d-5c87-a45e-53071ac96436")}catch(e){}}();
|
|
2
|
+
export const minKeymanVersion = '12.0';
|
|
3
|
+
//# debugId=4e395607-c79d-5c87-a45e-53071ac96436
|
|
4
|
+
//# sourceMappingURL=min-keyman-version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"4e395607-c79d-5c87-a45e-53071ac96436","file":"min-keyman-version.js","mappings":";AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC","names":[],"sourceRoot":"","sources":["../../src/min-keyman-version.ts"],"version":3}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param options Details on files from which to extract additional metadata
|
|
27
|
-
*/
|
|
28
|
-
export declare function writeMergedModelMetadataFile(sourceModelInfoFileName: string,
|
|
29
|
-
//#
|
|
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]="a8d87ef4-8219-5c7a-b6cd-94783c1ed307")}catch(e){}}();
|
|
2
|
+
/**
|
|
3
|
+
* Merges a source .model_info file with metadata extracted from .kps file and
|
|
4
|
+
* compiled files to produce a comprehensive .model_info file.
|
|
5
|
+
*/
|
|
6
|
+
import { CompilerCallbacks, KmpJsonFile } from "@keymanapp/common-types";
|
|
7
|
+
export declare class ModelInfoOptions {
|
|
8
|
+
/** The identifier for the model */
|
|
9
|
+
model_id: string;
|
|
10
|
+
/** The data from the .kps file, transformed to kmp.json */
|
|
11
|
+
kmpJsonData: KmpJsonFile.KmpJsonFile;
|
|
12
|
+
/** The path in the keymanapp/lexical-models repo where this model may be found (optional) */
|
|
13
|
+
sourcePath?: string;
|
|
14
|
+
/** The compiled model filename and relative path (.js) */
|
|
15
|
+
modelFileName: string;
|
|
16
|
+
/** The compiled package filename and relative path (.kmp) */
|
|
17
|
+
kmpFileName: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Merges source .model_info file with metadata from the model and package source file.
|
|
21
|
+
* This function is intended for use within the lexical-models repository. While many of the
|
|
22
|
+
* parameters could be deduced from each other, they are specified here to reduce the
|
|
23
|
+
* number of places the filenames are constructed.
|
|
24
|
+
*
|
|
25
|
+
* @param sourceModelInfoFileName Path for the source .model_info file
|
|
26
|
+
* @param options Details on files from which to extract additional metadata
|
|
27
|
+
*/
|
|
28
|
+
export declare function writeMergedModelMetadataFile(sourceModelInfoFileName: string, callbacks: CompilerCallbacks, options: ModelInfoOptions): Uint8Array;
|
|
29
|
+
//# debugId=a8d87ef4-8219-5c7a-b6cd-94783c1ed307
|
|
30
|
+
//# sourceMappingURL=model-info-compiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"a8d87ef4-8219-5c7a-b6cd-94783c1ed307","file":"model-info-compiler.d.ts","mappings":";AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAIzE,qBAAa,gBAAgB;IAC3B,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IAEjB,2DAA2D;IAC3D,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC;IAErC,6FAA6F;IAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAC;IAEtB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;CACrB;AAGD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CACxC,uBAAuB,EAAE,MAAM,EAC/B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,gBAAgB,GACxB,UAAU,CAwHd","names":[],"sourceRoot":"","sources":["../../src/model-info-compiler.ts"],"version":3}
|
|
@@ -1,103 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @param
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* "
|
|
38
|
-
* "
|
|
39
|
-
* "
|
|
40
|
-
* "
|
|
41
|
-
* "
|
|
42
|
-
* "
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
setModelMetadata(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
setModelMetadata('
|
|
87
|
-
setModelMetadata('
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
setModelMetadata('
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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]="5fc69a5b-f603-58cb-8020-d4824657a011")}catch(e){}}();
|
|
2
|
+
/**
|
|
3
|
+
* Merges a source .model_info file with metadata extracted from .kps file and
|
|
4
|
+
* compiled files to produce a comprehensive .model_info file.
|
|
5
|
+
*/
|
|
6
|
+
import { minKeymanVersion } from "./min-keyman-version.js";
|
|
7
|
+
import { ModelInfoCompilerMessages } from "./messages.js";
|
|
8
|
+
/* c8 ignore start */
|
|
9
|
+
export class ModelInfoOptions {
|
|
10
|
+
/** The identifier for the model */
|
|
11
|
+
model_id;
|
|
12
|
+
/** The data from the .kps file, transformed to kmp.json */
|
|
13
|
+
kmpJsonData;
|
|
14
|
+
/** The path in the keymanapp/lexical-models repo where this model may be found (optional) */
|
|
15
|
+
sourcePath;
|
|
16
|
+
/** The compiled model filename and relative path (.js) */
|
|
17
|
+
modelFileName;
|
|
18
|
+
/** The compiled package filename and relative path (.kmp) */
|
|
19
|
+
kmpFileName;
|
|
20
|
+
}
|
|
21
|
+
;
|
|
22
|
+
/* c8 ignore stop */
|
|
23
|
+
/**
|
|
24
|
+
* Merges source .model_info file with metadata from the model and package source file.
|
|
25
|
+
* This function is intended for use within the lexical-models repository. While many of the
|
|
26
|
+
* parameters could be deduced from each other, they are specified here to reduce the
|
|
27
|
+
* number of places the filenames are constructed.
|
|
28
|
+
*
|
|
29
|
+
* @param sourceModelInfoFileName Path for the source .model_info file
|
|
30
|
+
* @param options Details on files from which to extract additional metadata
|
|
31
|
+
*/
|
|
32
|
+
export function writeMergedModelMetadataFile(sourceModelInfoFileName, callbacks, options) {
|
|
33
|
+
/*
|
|
34
|
+
* Model info looks like this:
|
|
35
|
+
*
|
|
36
|
+
* {
|
|
37
|
+
* "name": "Example Template Model"
|
|
38
|
+
* "license": "mit",
|
|
39
|
+
* "version": "1.0.0",
|
|
40
|
+
* "languages": ["en"],
|
|
41
|
+
* "authorName": "Example Author",
|
|
42
|
+
* "authorEmail": "nobody@example.com",
|
|
43
|
+
* "description": "Example wordlist model"
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* For full documentation, see:
|
|
47
|
+
* https://help.keyman.com/developer/cloud/model_info/1.0/
|
|
48
|
+
*/
|
|
49
|
+
const dataInput = callbacks.loadFile(sourceModelInfoFileName);
|
|
50
|
+
if (!dataInput) {
|
|
51
|
+
callbacks.reportMessage(ModelInfoCompilerMessages.Error_FileDoesNotExist({ filename: sourceModelInfoFileName }));
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
let model_info = null;
|
|
55
|
+
try {
|
|
56
|
+
const jsonInput = new TextDecoder('utf-8', { fatal: true }).decode(dataInput);
|
|
57
|
+
model_info = JSON.parse(jsonInput);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
callbacks.reportMessage(ModelInfoCompilerMessages.Error_FileIsNotValid({ filename: sourceModelInfoFileName, e }));
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
//
|
|
64
|
+
// Build merged .model_info file
|
|
65
|
+
// https://api.keyman.com/schemas/model_info.source.json and
|
|
66
|
+
// https://api.keyman.com/schemas/model_info.distribution.json
|
|
67
|
+
// https://help.keyman.com/developer/cloud/model_info/1.0
|
|
68
|
+
//
|
|
69
|
+
function setModelMetadata(field, expected, warn = true) {
|
|
70
|
+
/* c8 ignore next 4 */
|
|
71
|
+
if (model_info[field] && model_info[field] !== expected) {
|
|
72
|
+
if (warn ?? true) {
|
|
73
|
+
callbacks.reportMessage(ModelInfoCompilerMessages.Warn_MetadataFieldInconsistent({
|
|
74
|
+
field, value: model_info[field], expected
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// TypeScript gets upset with this assignment, because it cannot deduce
|
|
79
|
+
// the exact type of model_info[field] -- there are many possibilities!
|
|
80
|
+
// So we assert that it's unknown so that TypeScript can chill.
|
|
81
|
+
model_info[field] = model_info[field] || expected;
|
|
82
|
+
}
|
|
83
|
+
//
|
|
84
|
+
// Merge model info file -- some fields have "special" behaviours -- see below
|
|
85
|
+
//
|
|
86
|
+
setModelMetadata('id', options.model_id);
|
|
87
|
+
setModelMetadata('name', options.kmpJsonData.info.name.description);
|
|
88
|
+
let author = options.kmpJsonData.info.author;
|
|
89
|
+
setModelMetadata('authorName', author?.description);
|
|
90
|
+
if (author?.url) {
|
|
91
|
+
// we strip the mailto: from the .kps file for the .model_info
|
|
92
|
+
let match = author.url.match(/^(mailto\:)?(.+)$/);
|
|
93
|
+
/* c8 ignore next 3 */
|
|
94
|
+
if (match === null) {
|
|
95
|
+
callbacks.reportMessage(ModelInfoCompilerMessages.Error_InvalidAuthorEmail({ email: author.url }));
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
let email = match[2];
|
|
99
|
+
setModelMetadata('authorEmail', email, false);
|
|
100
|
+
}
|
|
101
|
+
// extract the language identifiers from the language metadata
|
|
102
|
+
// arrays for each of the lexical models in the kmp.json file,
|
|
103
|
+
// and merge into a single array of identifiers in the
|
|
104
|
+
// .model_info file.
|
|
105
|
+
model_info.languages = model_info.languages || options.kmpJsonData.lexicalModels.reduce((a, e) => [].concat(a, e.languages.map((f) => f.id)), []);
|
|
106
|
+
setModelMetadata('lastModifiedDate', (new Date).toISOString());
|
|
107
|
+
setModelMetadata('packageFilename', callbacks.path.basename(options.kmpFileName));
|
|
108
|
+
// Always overwrite with actual file size
|
|
109
|
+
model_info.packageFileSize = callbacks.fileSize(options.kmpFileName);
|
|
110
|
+
if (model_info.packageFileSize === undefined) {
|
|
111
|
+
callbacks.reportMessage(ModelInfoCompilerMessages.Error_FileDoesNotExist({ filename: options.kmpFileName }));
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
setModelMetadata('jsFilename', callbacks.path.basename(options.modelFileName));
|
|
115
|
+
// Always overwrite with actual file size
|
|
116
|
+
model_info.jsFileSize = callbacks.fileSize(options.modelFileName);
|
|
117
|
+
if (model_info.jsFileSize === undefined) {
|
|
118
|
+
callbacks.reportMessage(ModelInfoCompilerMessages.Error_FileDoesNotExist({ filename: options.modelFileName }));
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
// Always overwrite source data
|
|
122
|
+
model_info.packageIncludes = options.kmpJsonData.files.filter((e) => !!e.name.match(/.[ot]tf$/i)).length ? ['fonts'] : [];
|
|
123
|
+
setModelMetadata('version', options.kmpJsonData.info.version.description);
|
|
124
|
+
// The minimum Keyman version detected in the package file may be manually set higher by the developer
|
|
125
|
+
setModelMetadata('minKeymanVersion', minKeymanVersion, false);
|
|
126
|
+
if (options.sourcePath) {
|
|
127
|
+
setModelMetadata('sourcePath', options.sourcePath);
|
|
128
|
+
}
|
|
129
|
+
const jsonOutput = JSON.stringify(model_info, null, 2);
|
|
130
|
+
return new TextEncoder().encode(jsonOutput);
|
|
131
|
+
}
|
|
132
|
+
//# debugId=5fc69a5b-f603-58cb-8020-d4824657a011
|
|
133
|
+
//# sourceMappingURL=model-info-compiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"5fc69a5b-f603-58cb-8020-d4824657a011","file":"model-info-compiler.js","mappings":";AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,qBAAqB;AACrB,MAAM,OAAO,gBAAgB;IAC3B,mCAAmC;IACnC,QAAQ,CAAS;IAEjB,2DAA2D;IAC3D,WAAW,CAA0B;IAErC,6FAA6F;IAC7F,UAAU,CAAU;IAEpB,0DAA0D;IAC1D,aAAa,CAAS;IAEtB,6DAA6D;IAC7D,WAAW,CAAS;CACrB;AAAA,CAAC;AACF,oBAAoB;AAEpB;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B,CACxC,uBAA+B,EAC/B,SAA4B,EAC5B,OAAyB;IAG3B;;;;;;;;;;;;;;;QAeI;IACJ,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;IAC9D,IAAG,CAAC,SAAS,EAAE;QACb,SAAS,CAAC,aAAa,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,EAAC,QAAQ,EAAE,uBAAuB,EAAC,CAAC,CAAC,CAAC;QAC/G,OAAO,IAAI,CAAC;KACb;IAED,IAAI,UAAU,GAAkB,IAAI,CAAC;IACrC,IAAI;QACF,MAAM,SAAS,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAC,KAAK,E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-compiler.ts"],"version":3}
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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]="70c98f01-41e6-51eb-b628-26d829923d6a")}catch(e){}}();
|
|
2
|
+
export interface ModelInfoFile {
|
|
3
|
+
id?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
authorName?: string;
|
|
6
|
+
authorEmail?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
license: "mit";
|
|
9
|
+
languages: Array<string>;
|
|
10
|
+
lastModifiedDate?: string;
|
|
11
|
+
links: ModelInfoFileLink[];
|
|
12
|
+
packageFilename?: string;
|
|
13
|
+
packageFileSize?: number;
|
|
14
|
+
jsFilename?: string;
|
|
15
|
+
jsFileSize?: number;
|
|
16
|
+
isRTL?: boolean;
|
|
17
|
+
packageIncludes?: string[];
|
|
18
|
+
version?: string;
|
|
19
|
+
minKeymanVersion?: string;
|
|
20
|
+
helpLink?: string;
|
|
21
|
+
sourcePath?: string;
|
|
22
|
+
related?: {
|
|
23
|
+
[id: string]: ModelInfoFileRelated;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface ModelInfoFileLink {
|
|
27
|
+
name: string;
|
|
28
|
+
url: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ModelInfoFileRelated {
|
|
31
|
+
deprecates?: string;
|
|
32
|
+
deprecatedBy?: string;
|
|
33
|
+
note?: string;
|
|
34
|
+
}
|
|
35
|
+
//# debugId=70c98f01-41e6-51eb-b628-26d829923d6a
|
|
36
|
+
//# sourceMappingURL=model-info-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"70c98f01-41e6-51eb-b628-26d829923d6a","file":"model-info-file.d.ts","mappings":";AAAA,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE;QAAC,CAAC,EAAE,EAAC,MAAM,GAAE,oBAAoB,CAAA;KAAC,CAAC;CAC9C;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf","names":[],"sourceRoot":"","sources":["../../src/model-info-file.ts"],"version":3}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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]="dba5a239-2e02-5adc-b46b-4f2141609c45")}catch(e){}}();
|
|
2
|
+
export {};
|
|
3
|
+
//# debugId=dba5a239-2e02-5adc-b46b-4f2141609c45
|
|
4
|
+
//# sourceMappingURL=model-info-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"dba5a239-2e02-5adc-b46b-4f2141609c45","file":"model-info-file.js","mappings":";","names":[],"sourceRoot":"","sources":["../../src/model-info-file.ts"],"version":3}
|
package/package.json
CHANGED
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"url": "https://github.com/keymanapp/keyman/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@keymanapp/common-types": "17.0.
|
|
35
|
-
"@keymanapp/models-types": "17.0.
|
|
34
|
+
"@keymanapp/common-types": "17.0.156-alpha",
|
|
35
|
+
"@keymanapp/models-types": "17.0.156-alpha"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/chai": "^4.1.7",
|
|
39
39
|
"@types/mocha": "^5.2.7",
|
|
40
|
-
"@types/node": "^
|
|
40
|
+
"@types/node": "^20.4.1",
|
|
41
41
|
"@types/xml2js": "^0.4.5",
|
|
42
42
|
"c8": "^7.12.0",
|
|
43
43
|
"chai": "^4.3.4",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"type": "git",
|
|
57
57
|
"url": "git+https://github.com/keymanapp/keyman.git"
|
|
58
58
|
},
|
|
59
|
-
"version": "17.0.
|
|
59
|
+
"version": "17.0.156-alpha"
|
|
60
60
|
}
|