@keymanapp/kmc-kmn 17.0.85-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +37 -0
- package/build/src/compiler/compiler.d.ts +15 -0
- package/build/src/compiler/compiler.d.ts.map +1 -0
- package/build/src/compiler/compiler.js +73 -0
- package/build/src/compiler/compiler.js.map +1 -0
- package/build/src/import/kmcmplib/wasm-host.d.ts +3 -0
- package/build/src/import/kmcmplib/wasm-host.d.ts.map +1 -0
- package/build/src/import/kmcmplib/wasm-host.js +1898 -0
- package/build/src/import/kmcmplib/wasm-host.js.map +1 -0
- package/build/src/import/kmcmplib/wasm-host.wasm +0 -0
- package/build/src/main.d.ts +2 -0
- package/build/src/main.d.ts.map +1 -0
- package/build/src/main.js +2 -0
- package/build/src/main.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build.sh +74 -0
- package/package.json +56 -0
- package/src/compiler/compiler.ts +93 -0
- package/src/main.ts +2 -0
- package/test/README.md +7 -0
- package/test/fixtures/000.kmn +11 -0
- package/test/fixtures/000.kmx +0 -0
- package/test/test-compiler.ts +47 -0
- package/test/tsconfig.json +24 -0
- package/tsconfig.json +22 -0
package/Makefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Keyman Developer - kmc kmn Compiler Makefile
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
!include ..\Defines.mak
|
|
6
|
+
|
|
7
|
+
build: .virtual
|
|
8
|
+
$(GIT_BASH_FOR_KEYMAN) build.sh build
|
|
9
|
+
|
|
10
|
+
configure: .virtual
|
|
11
|
+
$(GIT_BASH_FOR_KEYMAN) build.sh configure
|
|
12
|
+
|
|
13
|
+
clean: .virtual
|
|
14
|
+
$(GIT_BASH_FOR_KEYMAN) build.sh clean
|
|
15
|
+
|
|
16
|
+
test: .virtual
|
|
17
|
+
$(GIT_BASH_FOR_KEYMAN) build.sh test
|
|
18
|
+
|
|
19
|
+
# build.sh bundle must be run from shell as it requires a temp folder to be
|
|
20
|
+
# passed in. See inst/download.in.mak for instantiation.
|
|
21
|
+
|
|
22
|
+
publish: .virtual
|
|
23
|
+
$(GIT_BASH_FOR_KEYMAN) build.sh publish
|
|
24
|
+
|
|
25
|
+
signcode:
|
|
26
|
+
@rem nothing to do
|
|
27
|
+
|
|
28
|
+
wrap-symbols:
|
|
29
|
+
@rem nothing to do
|
|
30
|
+
|
|
31
|
+
test-manifest:
|
|
32
|
+
@rem nothing to do
|
|
33
|
+
|
|
34
|
+
install:
|
|
35
|
+
@rem nothing to do
|
|
36
|
+
|
|
37
|
+
!include ..\Target.mak
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface CompilerOptions {
|
|
2
|
+
shouldAddCompilerVersion?: boolean;
|
|
3
|
+
saveDebug?: boolean;
|
|
4
|
+
compilerWarningsAsErrors?: boolean;
|
|
5
|
+
warnDeprecatedCode?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class Compiler {
|
|
8
|
+
wasmModule: any;
|
|
9
|
+
compileKeyboardFile: any;
|
|
10
|
+
setCompilerOptions: any;
|
|
11
|
+
init(): Promise<boolean>;
|
|
12
|
+
run(infile: string, outfile: string, options?: CompilerOptions): boolean;
|
|
13
|
+
private runCompiler;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/compiler/compiler.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,eAAe;IAC9B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACpC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B;AASD,qBAAa,QAAQ;IACnB,UAAU,EAAE,GAAG,CAAC;IAChB,mBAAmB,EAAE,GAAG,CAAC;IACzB,kBAAkB,EAAE,GAAG,CAAC;IAEX,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAU9B,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO;IAoB/E,OAAO,CAAC,WAAW;CAiBpB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
TODO: implement additional interfaces:
|
|
3
|
+
|
|
4
|
+
extern "C" bool kmcmp_CompileKeyboardFileToBuffer(
|
|
5
|
+
char* pszInfile,
|
|
6
|
+
void* pfkBuffer,
|
|
7
|
+
bool ACompilerWarningsAsErrors,
|
|
8
|
+
bool AWarnDeprecatedCode,
|
|
9
|
+
kmcmp_CompilerMessageProc pMsgproc,
|
|
10
|
+
void* AmsgprocContext,
|
|
11
|
+
int Target
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
typedef bool (*kmcmp_ValidateJsonMessageProc)(int64_t offset, const char* szText, void* context);
|
|
15
|
+
|
|
16
|
+
extern "C" bool kmcmp_ValidateJsonFile(
|
|
17
|
+
std::fstream& f,
|
|
18
|
+
std::fstream& fd,
|
|
19
|
+
kmcmp_ValidateJsonMessageProc MessageProc,
|
|
20
|
+
void* context
|
|
21
|
+
);
|
|
22
|
+
*/
|
|
23
|
+
// TODO: rename wasm-host?
|
|
24
|
+
import loadWasmHost from '../import/kmcmplib/wasm-host.js';
|
|
25
|
+
;
|
|
26
|
+
const baseOptions = {
|
|
27
|
+
shouldAddCompilerVersion: true,
|
|
28
|
+
saveDebug: true,
|
|
29
|
+
compilerWarningsAsErrors: false,
|
|
30
|
+
warnDeprecatedCode: true
|
|
31
|
+
};
|
|
32
|
+
export class Compiler {
|
|
33
|
+
wasmModule;
|
|
34
|
+
compileKeyboardFile;
|
|
35
|
+
setCompilerOptions;
|
|
36
|
+
async init() {
|
|
37
|
+
if (!this.wasmModule) {
|
|
38
|
+
this.wasmModule = await loadWasmHost();
|
|
39
|
+
this.compileKeyboardFile = this.wasmModule.cwrap('kmcmp_Wasm_CompileKeyboardFile', 'number', ['string', 'string',
|
|
40
|
+
'number', 'number', 'number', 'string']);
|
|
41
|
+
this.setCompilerOptions = this.wasmModule.cwrap('kmcmp_Wasm_SetCompilerOptions', 'number', ['number']);
|
|
42
|
+
}
|
|
43
|
+
return this.compileKeyboardFile !== undefined && this.setCompilerOptions !== undefined;
|
|
44
|
+
}
|
|
45
|
+
run(infile, outfile, options) {
|
|
46
|
+
if (!this.wasmModule) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
options = { ...baseOptions, ...options };
|
|
50
|
+
globalThis.msgproc = function (line, code, msg) {
|
|
51
|
+
// TODO: link into the kmc error reporting infrastructure
|
|
52
|
+
console.log(`[${line}] ${code}: ${msg}`);
|
|
53
|
+
};
|
|
54
|
+
// TODO: use callbacks for file access -- so kmc-kmn is entirely fs agnostic
|
|
55
|
+
let result = this.runCompiler(infile, outfile, options) == 1;
|
|
56
|
+
globalThis.msgproc = null;
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
runCompiler(infile, outfile, options) {
|
|
60
|
+
try {
|
|
61
|
+
if (!this.setCompilerOptions(options.shouldAddCompilerVersion)) {
|
|
62
|
+
console.error('Unable to set compiler options');
|
|
63
|
+
}
|
|
64
|
+
return this.compileKeyboardFile(infile, outfile, options.saveDebug ? 1 : 0, options.compilerWarningsAsErrors ? 1 : 0, options.warnDeprecatedCode ? 1 : 0, 'msgproc');
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
// TODO: use sentry
|
|
68
|
+
console.error(e);
|
|
69
|
+
}
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/compiler/compiler.ts"],"names":[],"mappings":"AAA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