@keymanapp/kmc-model-info 18.0.41-alpha → 18.0.45-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/index.d.ts +2 -2
- package/build/src/index.js +3 -6
- package/build/src/index.js.map +1 -1
- package/build/src/min-keyman-version.d.ts +1 -1
- package/build/src/min-keyman-version.js +2 -5
- package/build/src/min-keyman-version.js.map +1 -1
- package/build/src/model-info-compiler-messages.d.ts +43 -43
- package/build/src/model-info-compiler-messages.js +31 -34
- package/build/src/model-info-compiler-messages.js.map +1 -1
- package/build/src/model-info-compiler.d.ts +112 -112
- package/build/src/model-info-compiler.js +232 -235
- package/build/src/model-info-compiler.js.map +1 -1
- package/build/src/model-info-file.d.ts +27 -27
- package/build/src/model-info-file.js +2 -5
- package/build/src/model-info-file.js.map +1 -1
- package/package.json +4 -4
package/build/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ModelInfoSources, ModelInfoCompilerOptions, ModelInfoCompilerArtifacts, ModelInfoCompilerResult, ModelInfoCompiler } from './model-info-compiler.js';
|
|
2
|
-
export { ModelInfoCompilerMessages } from './model-info-compiler-messages.js';
|
|
1
|
+
export { ModelInfoSources, ModelInfoCompilerOptions, ModelInfoCompilerArtifacts, ModelInfoCompilerResult, ModelInfoCompiler } from './model-info-compiler.js';
|
|
2
|
+
export { ModelInfoCompilerMessages } from './model-info-compiler-messages.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { ModelInfoCompilerMessages } from './model-info-compiler-messages.js';
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
6
|
-
//# debugId=e8aadc91-fccc-5f75-a188-425f385ac749
|
|
1
|
+
export { ModelInfoSources, ModelInfoCompiler } from './model-info-compiler.js';
|
|
2
|
+
export { ModelInfoCompilerMessages } from './model-info-compiler-messages.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAiF,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC9J,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const minKeymanVersion = "12.0";
|
|
1
|
+
export declare const minKeymanVersion = "12.0";
|
|
2
2
|
//# sourceMappingURL=min-keyman-version.d.ts.map
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const minKeymanVersion = '12.0';
|
|
4
|
-
//# sourceMappingURL=min-keyman-version.js.map
|
|
5
|
-
//# debugId=3eeebeae-6b50-50bd-86e1-c2d19a89d42c
|
|
1
|
+
export const minKeymanVersion = '12.0';
|
|
2
|
+
//# sourceMappingURL=min-keyman-version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"min-keyman-version.js","sources":["../../src/min-keyman-version.ts"],"
|
|
1
|
+
{"version":3,"file":"min-keyman-version.js","sourceRoot":"","sources":["../../src/min-keyman-version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC"}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export declare class ModelInfoCompilerMessages {
|
|
5
|
-
static FATAL_UnexpectedException: number;
|
|
6
|
-
static Fatal_UnexpectedException: (o: {
|
|
7
|
-
e: any;
|
|
8
|
-
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
9
|
-
static ERROR_FileDoesNotExist: number;
|
|
10
|
-
static Error_FileDoesNotExist: (o: {
|
|
11
|
-
filename: string;
|
|
12
|
-
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
13
|
-
static ERROR_FileIsNotValid: number;
|
|
14
|
-
static Error_FileIsNotValid: (o: {
|
|
15
|
-
filename: string;
|
|
16
|
-
e: any;
|
|
17
|
-
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
18
|
-
static WARN_MetadataFieldInconsistent: number;
|
|
19
|
-
static Warn_MetadataFieldInconsistent: (o: {
|
|
20
|
-
field: string;
|
|
21
|
-
value: any;
|
|
22
|
-
expected: any;
|
|
23
|
-
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
24
|
-
static ERROR_InvalidAuthorEmail: number;
|
|
25
|
-
static Error_InvalidAuthorEmail: (o: {
|
|
26
|
-
email: string;
|
|
27
|
-
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
28
|
-
static ERROR_LicenseFileIsMissing: number;
|
|
29
|
-
static Error_LicenseFileIsMissing: (o: {
|
|
30
|
-
filename: string;
|
|
31
|
-
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
32
|
-
static ERROR_LicenseFileIsDamaged: number;
|
|
33
|
-
static Error_LicenseFileIsDamaged: (o: {
|
|
34
|
-
filename: string;
|
|
35
|
-
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
36
|
-
static ERROR_LicenseIsNotValid: number;
|
|
37
|
-
static Error_LicenseIsNotValid: (o: {
|
|
38
|
-
filename: string;
|
|
39
|
-
message: string;
|
|
40
|
-
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
41
|
-
static ERROR_NoLicenseFound: number;
|
|
42
|
-
static Error_NoLicenseFound: () => import("@keymanapp/common-types").CompilerEvent;
|
|
43
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export declare class ModelInfoCompilerMessages {
|
|
5
|
+
static FATAL_UnexpectedException: number;
|
|
6
|
+
static Fatal_UnexpectedException: (o: {
|
|
7
|
+
e: any;
|
|
8
|
+
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
9
|
+
static ERROR_FileDoesNotExist: number;
|
|
10
|
+
static Error_FileDoesNotExist: (o: {
|
|
11
|
+
filename: string;
|
|
12
|
+
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
13
|
+
static ERROR_FileIsNotValid: number;
|
|
14
|
+
static Error_FileIsNotValid: (o: {
|
|
15
|
+
filename: string;
|
|
16
|
+
e: any;
|
|
17
|
+
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
18
|
+
static WARN_MetadataFieldInconsistent: number;
|
|
19
|
+
static Warn_MetadataFieldInconsistent: (o: {
|
|
20
|
+
field: string;
|
|
21
|
+
value: any;
|
|
22
|
+
expected: any;
|
|
23
|
+
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
24
|
+
static ERROR_InvalidAuthorEmail: number;
|
|
25
|
+
static Error_InvalidAuthorEmail: (o: {
|
|
26
|
+
email: string;
|
|
27
|
+
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
28
|
+
static ERROR_LicenseFileIsMissing: number;
|
|
29
|
+
static Error_LicenseFileIsMissing: (o: {
|
|
30
|
+
filename: string;
|
|
31
|
+
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
32
|
+
static ERROR_LicenseFileIsDamaged: number;
|
|
33
|
+
static Error_LicenseFileIsDamaged: (o: {
|
|
34
|
+
filename: string;
|
|
35
|
+
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
36
|
+
static ERROR_LicenseIsNotValid: number;
|
|
37
|
+
static Error_LicenseIsNotValid: (o: {
|
|
38
|
+
filename: string;
|
|
39
|
+
message: string;
|
|
40
|
+
}) => import("@keymanapp/common-types").CompilerEvent;
|
|
41
|
+
static ERROR_NoLicenseFound: number;
|
|
42
|
+
static Error_NoLicenseFound: () => import("@keymanapp/common-types").CompilerEvent;
|
|
43
|
+
}
|
|
44
44
|
//# sourceMappingURL=model-info-compiler-messages.d.ts.map
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
static
|
|
15
|
-
static
|
|
16
|
-
static
|
|
17
|
-
static
|
|
18
|
-
static
|
|
19
|
-
static
|
|
20
|
-
static
|
|
21
|
-
static
|
|
22
|
-
static
|
|
23
|
-
static
|
|
24
|
-
static
|
|
25
|
-
static
|
|
26
|
-
static
|
|
27
|
-
static
|
|
28
|
-
static
|
|
29
|
-
static
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=model-info-compiler-messages.js.map
|
|
34
|
-
//# debugId=002e68f2-db80-5297-a18a-e54b82c99814
|
|
1
|
+
import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m, CompilerMessageDef as def, CompilerMessageSpecWithException } from "@keymanapp/common-types";
|
|
2
|
+
const Namespace = CompilerErrorNamespace.ModelInfoCompiler;
|
|
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
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export class ModelInfoCompilerMessages {
|
|
12
|
+
static FATAL_UnexpectedException = SevFatal | 0x0001;
|
|
13
|
+
static Fatal_UnexpectedException = (o) => CompilerMessageSpecWithException(this.FATAL_UnexpectedException, null, o.e ?? 'unknown error');
|
|
14
|
+
static ERROR_FileDoesNotExist = SevError | 0x0002;
|
|
15
|
+
static Error_FileDoesNotExist = (o) => m(this.ERROR_FileDoesNotExist, `File ${def(o.filename)} does not exist.`);
|
|
16
|
+
static ERROR_FileIsNotValid = SevError | 0x0003;
|
|
17
|
+
static Error_FileIsNotValid = (o) => m(this.ERROR_FileIsNotValid, `File ${def(o.filename)} could not be parsed: ${(o.e ?? 'unknown error').toString()}.`);
|
|
18
|
+
static WARN_MetadataFieldInconsistent = SevWarn | 0x0004;
|
|
19
|
+
static Warn_MetadataFieldInconsistent = (o) => m(this.WARN_MetadataFieldInconsistent, `Warning: field ${def(o.field)} value "${def(o.value)}" does not match "${def(o.expected)}" found in source file metadata.`);
|
|
20
|
+
static ERROR_InvalidAuthorEmail = SevError | 0x0005;
|
|
21
|
+
static Error_InvalidAuthorEmail = (o) => m(this.ERROR_InvalidAuthorEmail, `Invalid author email: ${def(o.email)}`);
|
|
22
|
+
static ERROR_LicenseFileIsMissing = SevError | 0x0006;
|
|
23
|
+
static Error_LicenseFileIsMissing = (o) => m(this.ERROR_LicenseFileIsMissing, `License file ${def(o.filename)} does not exist.`);
|
|
24
|
+
static ERROR_LicenseFileIsDamaged = SevError | 0x0007;
|
|
25
|
+
static Error_LicenseFileIsDamaged = (o) => m(this.ERROR_LicenseFileIsDamaged, `License file ${def(o.filename)} could not be loaded or decoded.`);
|
|
26
|
+
static ERROR_LicenseIsNotValid = SevError | 0x0008;
|
|
27
|
+
static Error_LicenseIsNotValid = (o) => m(this.ERROR_LicenseIsNotValid, `An error was encountered parsing license file ${def(o.filename)}: ${def(o.message)}.`);
|
|
28
|
+
static ERROR_NoLicenseFound = SevError | 0x0009;
|
|
29
|
+
static Error_NoLicenseFound = () => m(this.ERROR_NoLicenseFound, `No license for the model was found. MIT license is required for publication to Keyman lexical-models repository.`);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=model-info-compiler-messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-info-compiler-messages.js","sources":["../../src/model-info-compiler-messages.ts"],"
|
|
1
|
+
{"version":3,"file":"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,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1F,MAAM,CAAC,oBAAoB,GAAG,QAAQ,GAAG,MAAM,CAAC;IAChD,MAAM,CAAC,oBAAoB,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,EAC7D,kHAAkH,CAAC,CAAC"}
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds a source .model_info file with metadata extracted from .kps file and
|
|
3
|
-
* compiled files to produce a comprehensive .model_info file.
|
|
4
|
-
*/
|
|
5
|
-
import { CompilerCallbacks, CompilerOptions, KeymanCompiler, KeymanCompilerArtifact, KeymanCompilerArtifacts, KeymanCompilerResult, KmpJsonFile } from "@keymanapp/common-types";
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
* Description of sources and metadata required to build a .model_info file
|
|
9
|
-
*/
|
|
10
|
-
export declare class ModelInfoSources {
|
|
11
|
-
/** The identifier for the model */
|
|
12
|
-
model_id: string;
|
|
13
|
-
/** The data from the .kps file, transformed to kmp.json */
|
|
14
|
-
kmpJsonData: KmpJsonFile.KmpJsonFile;
|
|
15
|
-
/** The path in the keymanapp/lexical-models repo where this model may be found */
|
|
16
|
-
sourcePath: string;
|
|
17
|
-
/** The compiled model filename and relative path (.js) */
|
|
18
|
-
modelFileName: string;
|
|
19
|
-
/** The compiled package filename and relative path (.kmp) */
|
|
20
|
-
kmpFileName: string;
|
|
21
|
-
/** The source package filename and relative path (.kps) */
|
|
22
|
-
kpsFilename: string;
|
|
23
|
-
/** Last modification date for files in the project folder 'YYYY-MM-DDThh:mm:ssZ' */
|
|
24
|
-
lastCommitDate?: string;
|
|
25
|
-
/** Return an error if project does not meet requirements of lexical-models repository */
|
|
26
|
-
forPublishing: boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @public
|
|
30
|
-
* Options for the .model_info compiler
|
|
31
|
-
*/
|
|
32
|
-
export interface ModelInfoCompilerOptions extends CompilerOptions {
|
|
33
|
-
/**
|
|
34
|
-
* Description of sources and metadata required to build a .model_info file
|
|
35
|
-
*/
|
|
36
|
-
sources: ModelInfoSources;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* @public
|
|
40
|
-
* Internal in-memory build artifacts from a successful compilation
|
|
41
|
-
*/
|
|
42
|
-
export interface ModelInfoCompilerArtifacts extends KeymanCompilerArtifacts {
|
|
43
|
-
/**
|
|
44
|
-
* Binary model info filedata and filename - used by keyman.com
|
|
45
|
-
*/
|
|
46
|
-
model_info: KeymanCompilerArtifact;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @public
|
|
50
|
-
* Build artifacts from the .model_info compiler
|
|
51
|
-
*/
|
|
52
|
-
export interface ModelInfoCompilerResult extends KeymanCompilerResult {
|
|
53
|
-
/**
|
|
54
|
-
* Internal in-memory build artifacts from a successful compilation. Caller
|
|
55
|
-
* can write these to disk with {@link ModelInfoCompiler.write}
|
|
56
|
-
*/
|
|
57
|
-
artifacts: ModelInfoCompilerArtifacts;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @public
|
|
61
|
-
* Compiles source data from a lexical model project to a .model_info. The
|
|
62
|
-
* compiler does not read or write from filesystem or network directly, but
|
|
63
|
-
* relies on callbacks for all external IO.
|
|
64
|
-
*/
|
|
65
|
-
export declare class ModelInfoCompiler implements KeymanCompiler {
|
|
66
|
-
private callbacks;
|
|
67
|
-
private options;
|
|
68
|
-
constructor();
|
|
69
|
-
/**
|
|
70
|
-
* Initialize the compiler.
|
|
71
|
-
* Copies options.
|
|
72
|
-
* @param callbacks - Callbacks for external interfaces, including message
|
|
73
|
-
* reporting and file io
|
|
74
|
-
* @param options - Compiler options
|
|
75
|
-
* @returns false if initialization fails
|
|
76
|
-
*/
|
|
77
|
-
init(callbacks: CompilerCallbacks, options: ModelInfoCompilerOptions): Promise<boolean>;
|
|
78
|
-
/**
|
|
79
|
-
* Builds .model_info file with metadata from the model and package source
|
|
80
|
-
* file. Returns an object containing binary artifacts on success. The files
|
|
81
|
-
* are passed in by name, and the compiler will use callbacks as passed to the
|
|
82
|
-
* {@link ModelInfoCompiler.init} function to read any input files by disk.
|
|
83
|
-
*
|
|
84
|
-
* This function is intended for use within the lexical-models repository.
|
|
85
|
-
* While many of the parameters could be deduced from each other, they are
|
|
86
|
-
* specified here to reduce the number of places the filenames are
|
|
87
|
-
* constructed.
|
|
88
|
-
*
|
|
89
|
-
* @param infile - Path to source file. Path will be parsed to find relative
|
|
90
|
-
* references in the .kpj file, such as .model.ts or
|
|
91
|
-
* .model.kps file
|
|
92
|
-
* @param outfile - Path to output file. The file will not be written to, but
|
|
93
|
-
* will be included in the result for use by
|
|
94
|
-
* {@link ModelInfoCompiler.write}.
|
|
95
|
-
* @returns Binary artifacts on success, null on failure.
|
|
96
|
-
*
|
|
97
|
-
* @param sources - Details on files from which to extract additional metadata
|
|
98
|
-
*/
|
|
99
|
-
run(inputFilename: string, outputFilename?: string): Promise<ModelInfoCompilerResult>;
|
|
100
|
-
/**
|
|
101
|
-
* Write artifacts from a successful compile to disk, via callbacks methods.
|
|
102
|
-
* The artifacts written may include:
|
|
103
|
-
*
|
|
104
|
-
* - .model_info file - metadata file used by keyman.com
|
|
105
|
-
*
|
|
106
|
-
* @param artifacts - object containing artifact binary data to write out
|
|
107
|
-
* @returns true on success
|
|
108
|
-
*/
|
|
109
|
-
write(artifacts: ModelInfoCompilerArtifacts): Promise<boolean>;
|
|
110
|
-
private isLicenseMIT;
|
|
111
|
-
private loadJsFile;
|
|
112
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Builds a source .model_info file with metadata extracted from .kps file and
|
|
3
|
+
* compiled files to produce a comprehensive .model_info file.
|
|
4
|
+
*/
|
|
5
|
+
import { CompilerCallbacks, CompilerOptions, KeymanCompiler, KeymanCompilerArtifact, KeymanCompilerArtifacts, KeymanCompilerResult, KmpJsonFile } from "@keymanapp/common-types";
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
* Description of sources and metadata required to build a .model_info file
|
|
9
|
+
*/
|
|
10
|
+
export declare class ModelInfoSources {
|
|
11
|
+
/** The identifier for the model */
|
|
12
|
+
model_id: string;
|
|
13
|
+
/** The data from the .kps file, transformed to kmp.json */
|
|
14
|
+
kmpJsonData: KmpJsonFile.KmpJsonFile;
|
|
15
|
+
/** The path in the keymanapp/lexical-models repo where this model may be found */
|
|
16
|
+
sourcePath: string;
|
|
17
|
+
/** The compiled model filename and relative path (.js) */
|
|
18
|
+
modelFileName: string;
|
|
19
|
+
/** The compiled package filename and relative path (.kmp) */
|
|
20
|
+
kmpFileName: string;
|
|
21
|
+
/** The source package filename and relative path (.kps) */
|
|
22
|
+
kpsFilename: string;
|
|
23
|
+
/** Last modification date for files in the project folder 'YYYY-MM-DDThh:mm:ssZ' */
|
|
24
|
+
lastCommitDate?: string;
|
|
25
|
+
/** Return an error if project does not meet requirements of lexical-models repository */
|
|
26
|
+
forPublishing: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
* Options for the .model_info compiler
|
|
31
|
+
*/
|
|
32
|
+
export interface ModelInfoCompilerOptions extends CompilerOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Description of sources and metadata required to build a .model_info file
|
|
35
|
+
*/
|
|
36
|
+
sources: ModelInfoSources;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
* Internal in-memory build artifacts from a successful compilation
|
|
41
|
+
*/
|
|
42
|
+
export interface ModelInfoCompilerArtifacts extends KeymanCompilerArtifacts {
|
|
43
|
+
/**
|
|
44
|
+
* Binary model info filedata and filename - used by keyman.com
|
|
45
|
+
*/
|
|
46
|
+
model_info: KeymanCompilerArtifact;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @public
|
|
50
|
+
* Build artifacts from the .model_info compiler
|
|
51
|
+
*/
|
|
52
|
+
export interface ModelInfoCompilerResult extends KeymanCompilerResult {
|
|
53
|
+
/**
|
|
54
|
+
* Internal in-memory build artifacts from a successful compilation. Caller
|
|
55
|
+
* can write these to disk with {@link ModelInfoCompiler.write}
|
|
56
|
+
*/
|
|
57
|
+
artifacts: ModelInfoCompilerArtifacts;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @public
|
|
61
|
+
* Compiles source data from a lexical model project to a .model_info. The
|
|
62
|
+
* compiler does not read or write from filesystem or network directly, but
|
|
63
|
+
* relies on callbacks for all external IO.
|
|
64
|
+
*/
|
|
65
|
+
export declare class ModelInfoCompiler implements KeymanCompiler {
|
|
66
|
+
private callbacks;
|
|
67
|
+
private options;
|
|
68
|
+
constructor();
|
|
69
|
+
/**
|
|
70
|
+
* Initialize the compiler.
|
|
71
|
+
* Copies options.
|
|
72
|
+
* @param callbacks - Callbacks for external interfaces, including message
|
|
73
|
+
* reporting and file io
|
|
74
|
+
* @param options - Compiler options
|
|
75
|
+
* @returns false if initialization fails
|
|
76
|
+
*/
|
|
77
|
+
init(callbacks: CompilerCallbacks, options: ModelInfoCompilerOptions): Promise<boolean>;
|
|
78
|
+
/**
|
|
79
|
+
* Builds .model_info file with metadata from the model and package source
|
|
80
|
+
* file. Returns an object containing binary artifacts on success. The files
|
|
81
|
+
* are passed in by name, and the compiler will use callbacks as passed to the
|
|
82
|
+
* {@link ModelInfoCompiler.init} function to read any input files by disk.
|
|
83
|
+
*
|
|
84
|
+
* This function is intended for use within the lexical-models repository.
|
|
85
|
+
* While many of the parameters could be deduced from each other, they are
|
|
86
|
+
* specified here to reduce the number of places the filenames are
|
|
87
|
+
* constructed.
|
|
88
|
+
*
|
|
89
|
+
* @param infile - Path to source file. Path will be parsed to find relative
|
|
90
|
+
* references in the .kpj file, such as .model.ts or
|
|
91
|
+
* .model.kps file
|
|
92
|
+
* @param outfile - Path to output file. The file will not be written to, but
|
|
93
|
+
* will be included in the result for use by
|
|
94
|
+
* {@link ModelInfoCompiler.write}.
|
|
95
|
+
* @returns Binary artifacts on success, null on failure.
|
|
96
|
+
*
|
|
97
|
+
* @param sources - Details on files from which to extract additional metadata
|
|
98
|
+
*/
|
|
99
|
+
run(inputFilename: string, outputFilename?: string): Promise<ModelInfoCompilerResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Write artifacts from a successful compile to disk, via callbacks methods.
|
|
102
|
+
* The artifacts written may include:
|
|
103
|
+
*
|
|
104
|
+
* - .model_info file - metadata file used by keyman.com
|
|
105
|
+
*
|
|
106
|
+
* @param artifacts - object containing artifact binary data to write out
|
|
107
|
+
* @returns true on success
|
|
108
|
+
*/
|
|
109
|
+
write(artifacts: ModelInfoCompilerArtifacts): Promise<boolean>;
|
|
110
|
+
private isLicenseMIT;
|
|
111
|
+
private loadJsFile;
|
|
112
|
+
}
|
|
113
113
|
//# sourceMappingURL=model-info-compiler.d.ts.map
|
|
@@ -1,235 +1,232 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds a source .model_info file with metadata extracted from .kps file and
|
|
3
|
-
* compiled files to produce a comprehensive .model_info file.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** The
|
|
17
|
-
|
|
18
|
-
/** The
|
|
19
|
-
|
|
20
|
-
/** The
|
|
21
|
-
|
|
22
|
-
/** The compiled
|
|
23
|
-
|
|
24
|
-
/** The
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
;
|
|
34
|
-
;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @param
|
|
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
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* @
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* "
|
|
89
|
-
* "
|
|
90
|
-
* "
|
|
91
|
-
* "
|
|
92
|
-
* "
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
// https://
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
model_info.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
//
|
|
152
|
-
model_info.
|
|
153
|
-
|
|
154
|
-
model_info.
|
|
155
|
-
model_info.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
model_info.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
model_info.
|
|
168
|
-
model_info.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* -
|
|
191
|
-
*
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
//# sourceMappingURL=model-info-compiler.js.map
|
|
235
|
-
//# debugId=4d908771-d902-523f-90aa-7d5f79acdb2c
|
|
1
|
+
/**
|
|
2
|
+
* Builds a source .model_info file with metadata extracted from .kps file and
|
|
3
|
+
* compiled files to produce a comprehensive .model_info file.
|
|
4
|
+
*/
|
|
5
|
+
import { minKeymanVersion } from "./min-keyman-version.js";
|
|
6
|
+
import { ModelInfoCompilerMessages } from "./model-info-compiler-messages.js";
|
|
7
|
+
import { KeymanUrls, validateMITLicense } from "@keymanapp/developer-utils";
|
|
8
|
+
/* c8 ignore start */
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
* Description of sources and metadata required to build a .model_info file
|
|
12
|
+
*/
|
|
13
|
+
export class ModelInfoSources {
|
|
14
|
+
/** The identifier for the model */
|
|
15
|
+
model_id;
|
|
16
|
+
/** The data from the .kps file, transformed to kmp.json */
|
|
17
|
+
kmpJsonData;
|
|
18
|
+
/** The path in the keymanapp/lexical-models repo where this model may be found */
|
|
19
|
+
sourcePath;
|
|
20
|
+
/** The compiled model filename and relative path (.js) */
|
|
21
|
+
modelFileName;
|
|
22
|
+
/** The compiled package filename and relative path (.kmp) */
|
|
23
|
+
kmpFileName;
|
|
24
|
+
/** The source package filename and relative path (.kps) */
|
|
25
|
+
kpsFilename;
|
|
26
|
+
/** Last modification date for files in the project folder 'YYYY-MM-DDThh:mm:ssZ' */
|
|
27
|
+
lastCommitDate;
|
|
28
|
+
/** Return an error if project does not meet requirements of lexical-models repository */
|
|
29
|
+
forPublishing;
|
|
30
|
+
}
|
|
31
|
+
;
|
|
32
|
+
;
|
|
33
|
+
;
|
|
34
|
+
;
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
* Compiles source data from a lexical model project to a .model_info. The
|
|
38
|
+
* compiler does not read or write from filesystem or network directly, but
|
|
39
|
+
* relies on callbacks for all external IO.
|
|
40
|
+
*/
|
|
41
|
+
export class ModelInfoCompiler {
|
|
42
|
+
callbacks;
|
|
43
|
+
options;
|
|
44
|
+
constructor() {
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Initialize the compiler.
|
|
48
|
+
* Copies options.
|
|
49
|
+
* @param callbacks - Callbacks for external interfaces, including message
|
|
50
|
+
* reporting and file io
|
|
51
|
+
* @param options - Compiler options
|
|
52
|
+
* @returns false if initialization fails
|
|
53
|
+
*/
|
|
54
|
+
async init(callbacks, options) {
|
|
55
|
+
this.callbacks = callbacks;
|
|
56
|
+
this.options = { ...options };
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Builds .model_info file with metadata from the model and package source
|
|
61
|
+
* file. Returns an object containing binary artifacts on success. The files
|
|
62
|
+
* are passed in by name, and the compiler will use callbacks as passed to the
|
|
63
|
+
* {@link ModelInfoCompiler.init} function to read any input files by disk.
|
|
64
|
+
*
|
|
65
|
+
* This function is intended for use within the lexical-models repository.
|
|
66
|
+
* While many of the parameters could be deduced from each other, they are
|
|
67
|
+
* specified here to reduce the number of places the filenames are
|
|
68
|
+
* constructed.
|
|
69
|
+
*
|
|
70
|
+
* @param infile - Path to source file. Path will be parsed to find relative
|
|
71
|
+
* references in the .kpj file, such as .model.ts or
|
|
72
|
+
* .model.kps file
|
|
73
|
+
* @param outfile - Path to output file. The file will not be written to, but
|
|
74
|
+
* will be included in the result for use by
|
|
75
|
+
* {@link ModelInfoCompiler.write}.
|
|
76
|
+
* @returns Binary artifacts on success, null on failure.
|
|
77
|
+
*
|
|
78
|
+
* @param sources - Details on files from which to extract additional metadata
|
|
79
|
+
*/
|
|
80
|
+
async run(inputFilename, outputFilename) {
|
|
81
|
+
const sources = this.options.sources;
|
|
82
|
+
/*
|
|
83
|
+
* Model info looks like this:
|
|
84
|
+
*
|
|
85
|
+
* {
|
|
86
|
+
* "name": "Example Template Model"
|
|
87
|
+
* "license": "mit",
|
|
88
|
+
* "version": "1.0.0",
|
|
89
|
+
* "languages": ["en"],
|
|
90
|
+
* "authorName": "Example Author",
|
|
91
|
+
* "authorEmail": "nobody@example.com",
|
|
92
|
+
* "description": "Example wordlist model"
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* For full documentation, see:
|
|
96
|
+
* https://help.keyman.com/developer/cloud/model_info/1.0/
|
|
97
|
+
*/
|
|
98
|
+
let jsFile = null;
|
|
99
|
+
if (sources.modelFileName) {
|
|
100
|
+
jsFile = this.loadJsFile(sources.modelFileName);
|
|
101
|
+
if (!jsFile) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
let model_info = {
|
|
106
|
+
languages: [],
|
|
107
|
+
};
|
|
108
|
+
//
|
|
109
|
+
// Build .model_info file -- some fields have "special" behaviours -- see below
|
|
110
|
+
// https://api.keyman.com/schemas/model_info.source.json and
|
|
111
|
+
// https://api.keyman.com/schemas/model_info.distribution.json
|
|
112
|
+
// https://help.keyman.com/developer/cloud/model_info/1.0
|
|
113
|
+
//
|
|
114
|
+
model_info.id = sources.model_id;
|
|
115
|
+
model_info.name = sources.kmpJsonData.info.name.description;
|
|
116
|
+
// License
|
|
117
|
+
if (!sources.kmpJsonData.options?.licenseFile) {
|
|
118
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_NoLicenseFound());
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
if (!this.isLicenseMIT(this.callbacks.resolveFilename(sources.kpsFilename, sources.kmpJsonData.options.licenseFile))) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
model_info.license = 'mit';
|
|
125
|
+
const author = sources.kmpJsonData.info.author;
|
|
126
|
+
model_info.authorName = author?.description ?? '';
|
|
127
|
+
if (author?.url) {
|
|
128
|
+
// we strip the mailto: from the .kps file for the .model_info
|
|
129
|
+
const match = author.url.match(/^(mailto\:)?(.+)$/);
|
|
130
|
+
/* c8 ignore next 3 */
|
|
131
|
+
if (match === null) {
|
|
132
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_InvalidAuthorEmail({ email: author.url }));
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
model_info.authorEmail = match[2];
|
|
136
|
+
}
|
|
137
|
+
// description
|
|
138
|
+
if (sources.kmpJsonData.info.description?.description) {
|
|
139
|
+
model_info.description = sources.kmpJsonData.info.description.description.trim();
|
|
140
|
+
}
|
|
141
|
+
// isRTL -- this is a little bit of a heuristic from a compiled .js
|
|
142
|
+
// which may need modification if compilers change
|
|
143
|
+
if (jsFile?.match(/("?)isRTL("?):\s*true/)) {
|
|
144
|
+
model_info.isRTL = true;
|
|
145
|
+
}
|
|
146
|
+
// extract the language identifiers from the language metadata
|
|
147
|
+
// arrays for each of the lexical models in the kmp.json file,
|
|
148
|
+
// and merge into a single array of identifiers in the
|
|
149
|
+
// .model_info file.
|
|
150
|
+
model_info.languages = sources.kmpJsonData.lexicalModels.reduce((a, e) => [].concat(a, e.languages.map((f) => f.id)), []);
|
|
151
|
+
// If a last commit date is not given, then just use the current time
|
|
152
|
+
model_info.lastModifiedDate = sources.lastCommitDate ?? (new Date).toISOString();
|
|
153
|
+
model_info.packageFilename = this.callbacks.path.basename(sources.kmpFileName);
|
|
154
|
+
model_info.packageFileSize = this.callbacks.fileSize(sources.kmpFileName);
|
|
155
|
+
if (model_info.packageFileSize === undefined) {
|
|
156
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_FileDoesNotExist({ filename: sources.kmpFileName }));
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
model_info.jsFilename = this.callbacks.path.basename(sources.modelFileName);
|
|
160
|
+
model_info.jsFileSize = this.callbacks.fileSize(sources.modelFileName);
|
|
161
|
+
if (model_info.jsFileSize === undefined) {
|
|
162
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_FileDoesNotExist({ filename: sources.modelFileName }));
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
model_info.packageIncludes = sources.kmpJsonData.files.filter((e) => !!e.name.match(/.[ot]tf$/i)).length ? ['fonts'] : [];
|
|
166
|
+
model_info.version = sources.kmpJsonData.info.version.description;
|
|
167
|
+
model_info.minKeymanVersion = minKeymanVersion;
|
|
168
|
+
model_info.helpLink = KeymanUrls.HELP_MODEL(model_info.id);
|
|
169
|
+
if (sources.sourcePath) {
|
|
170
|
+
model_info.sourcePath = sources.sourcePath;
|
|
171
|
+
}
|
|
172
|
+
const jsonOutput = JSON.stringify(model_info, null, 2);
|
|
173
|
+
const data = new TextEncoder().encode(jsonOutput);
|
|
174
|
+
const result = {
|
|
175
|
+
artifacts: {
|
|
176
|
+
model_info: {
|
|
177
|
+
data,
|
|
178
|
+
filename: outputFilename ?? inputFilename.replace(/\.kpj$/, '.model_info')
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Write artifacts from a successful compile to disk, via callbacks methods.
|
|
186
|
+
* The artifacts written may include:
|
|
187
|
+
*
|
|
188
|
+
* - .model_info file - metadata file used by keyman.com
|
|
189
|
+
*
|
|
190
|
+
* @param artifacts - object containing artifact binary data to write out
|
|
191
|
+
* @returns true on success
|
|
192
|
+
*/
|
|
193
|
+
async write(artifacts) {
|
|
194
|
+
this.callbacks.fs.writeFileSync(artifacts.model_info.filename, artifacts.model_info.data);
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
isLicenseMIT(filename) {
|
|
198
|
+
const data = this.callbacks.loadFile(filename);
|
|
199
|
+
if (!data) {
|
|
200
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_LicenseFileIsMissing({ filename }));
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
let license = null;
|
|
204
|
+
try {
|
|
205
|
+
license = new TextDecoder().decode(data);
|
|
206
|
+
}
|
|
207
|
+
catch (e) {
|
|
208
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_LicenseFileIsDamaged({ filename }));
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
if (!license) {
|
|
212
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_LicenseFileIsDamaged({ filename }));
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
const message = validateMITLicense(license);
|
|
216
|
+
if (message != null) {
|
|
217
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_LicenseIsNotValid({ filename, message }));
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
loadJsFile(filename) {
|
|
223
|
+
const data = this.callbacks.loadFile(filename);
|
|
224
|
+
if (!data) {
|
|
225
|
+
this.callbacks.reportMessage(ModelInfoCompilerMessages.Error_FileDoesNotExist({ filename }));
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(data);
|
|
229
|
+
return text;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=model-info-compiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-info-compiler.js","sources":["../../src/model-info-compiler.ts"],"
|
|
1
|
+
{"version":3,"file":"model-info-compiler.js","sourceRoot":"","sources":["../../src/model-info-compiler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAE5E,qBAAqB;AACrB;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B,mCAAmC;IACnC,QAAQ,CAAS;IAEjB,2DAA2D;IAC3D,WAAW,CAA0B;IAErC,kFAAkF;IAClF,UAAU,CAAS;IAEnB,0DAA0D;IAC1D,aAAa,CAAS;IAEtB,6DAA6D;IAC7D,WAAW,CAAS;IAEpB,2DAA2D;IAC3D,WAAW,CAAS;IAEpB,oFAA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C,QAAQ,CAAC,CAAC;QAC/C,IAAG,CAAC,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,CAAC;YAC3F,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export interface ModelInfoFile {
|
|
2
|
-
id?: string;
|
|
3
|
-
name?: string;
|
|
4
|
-
authorName?: string;
|
|
5
|
-
authorEmail?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
license?: "mit";
|
|
8
|
-
languages: Array<string>;
|
|
9
|
-
lastModifiedDate?: string;
|
|
10
|
-
packageFilename?: string;
|
|
11
|
-
packageFileSize?: number;
|
|
12
|
-
jsFilename?: string;
|
|
13
|
-
jsFileSize?: number;
|
|
14
|
-
isRTL?: boolean;
|
|
15
|
-
packageIncludes?: string[];
|
|
16
|
-
version?: string;
|
|
17
|
-
minKeymanVersion?: string;
|
|
18
|
-
helpLink?: string;
|
|
19
|
-
sourcePath?: string;
|
|
20
|
-
related?: {
|
|
21
|
-
[id: string]: ModelInfoFileRelated;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export interface ModelInfoFileRelated {
|
|
25
|
-
deprecates?: string;
|
|
26
|
-
deprecatedBy?: string;
|
|
27
|
-
}
|
|
1
|
+
export interface ModelInfoFile {
|
|
2
|
+
id?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
authorName?: string;
|
|
5
|
+
authorEmail?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
license?: "mit";
|
|
8
|
+
languages: Array<string>;
|
|
9
|
+
lastModifiedDate?: string;
|
|
10
|
+
packageFilename?: string;
|
|
11
|
+
packageFileSize?: number;
|
|
12
|
+
jsFilename?: string;
|
|
13
|
+
jsFileSize?: number;
|
|
14
|
+
isRTL?: boolean;
|
|
15
|
+
packageIncludes?: string[];
|
|
16
|
+
version?: string;
|
|
17
|
+
minKeymanVersion?: string;
|
|
18
|
+
helpLink?: string;
|
|
19
|
+
sourcePath?: string;
|
|
20
|
+
related?: {
|
|
21
|
+
[id: string]: ModelInfoFileRelated;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface ModelInfoFileRelated {
|
|
25
|
+
deprecates?: string;
|
|
26
|
+
deprecatedBy?: string;
|
|
27
|
+
}
|
|
28
28
|
//# sourceMappingURL=model-info-file.d.ts.map
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {};
|
|
4
|
-
//# sourceMappingURL=model-info-file.js.map
|
|
5
|
-
//# debugId=17f5bb68-283d-5dc9-ab7b-bae0b88a8ab5
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=model-info-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-info-file.js","sources":["../../src/model-info-file.ts"],"
|
|
1
|
+
{"version":3,"file":"model-info-file.js","sourceRoot":"","sources":["../../src/model-info-file.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"url": "https://github.com/keymanapp/keyman/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@keymanapp/common-types": "18.0.
|
|
34
|
-
"@keymanapp/models-types": "18.0.
|
|
35
|
-
"@keymanapp/developer-utils": "18.0.
|
|
33
|
+
"@keymanapp/common-types": "18.0.45-alpha",
|
|
34
|
+
"@keymanapp/models-types": "18.0.45-alpha",
|
|
35
|
+
"@keymanapp/developer-utils": "18.0.45-alpha"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/mocha": "^5.2.7",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"type": "git",
|
|
54
54
|
"url": "git+https://github.com/keymanapp/keyman.git"
|
|
55
55
|
},
|
|
56
|
-
"version": "18.0.
|
|
56
|
+
"version": "18.0.45-alpha"
|
|
57
57
|
}
|