@keymanapp/kmc 17.0.83-alpha → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"buildKmnKeyboard.d.ts","sourceRoot":"","sources":["../../../src/activities/buildKmnKeyboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAgDrG"}
1
+ {"version":3,"file":"buildKmnKeyboard.d.ts","sourceRoot":"","sources":["../../../src/activities/buildKmnKeyboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAI3D,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAmBrG"}
@@ -1,45 +1,35 @@
1
- import { spawnSync } from 'child_process';
2
1
  import * as path from 'path';
3
- import { getDeveloperBinPath } from '../util/getDeveloperBinPath.js';
2
+ import { Compiler } from '@keymanapp/kmc-kmn';
3
+ import { platform } from 'os';
4
4
  export async function buildKmnKeyboard(infile, options) {
5
- // We'll call out to kmcomp.exe to build a .kmn keyboard into a .kmx Note:
6
- // kmcomp.exe will also build a .js if it is required, and may not actually
7
- // generate a .kmx if the output target defined in the .kmn is mobile/web
8
- // only. kmcomp.exe will also build the .kvk file.
9
- const binRoot = getDeveloperBinPath();
10
- if (binRoot == null) {
11
- console.error('Could not locate Keyman Developer bin path');
5
+ let compiler = new Compiler();
6
+ if (!await compiler.init()) {
12
7
  return false;
13
8
  }
14
- let args = ['-nologo'];
15
- if (options.debug) {
16
- args.push('-d');
17
- }
18
- args.push(path.win32.normalize(infile));
19
- // .* target file name option allows us to specify .kmx output file and the
20
- // .js output file will also be generated as required, in the same way as when
21
- // we build a project. Note: this is a stop gap as we work to deprecate
22
- // kmcomp.exe and replace it with kmcmp (cross-platform .kmx compiler in C++)
23
- // + kmc-kmw (KMX->KMW transpiler in TypeScript) + kmc-kvk (KVK compiler in
24
- // TypeScript).
25
- let outfile = (options.outFile ?? infile).replace(/\\/g, '/');
26
- // For now, we normalize to posix, and then renormalize to win32 for launching
27
- // kmcomp, until we have a cross-platform alternative to use
28
- outfile = path.win32.normalize(options.outFile).replace(/\.km.$/i, '.*');
29
- args.push(outfile);
30
- const kmcomp = path.join(binRoot, 'kmcomp.exe');
31
- // We won't attempt to make this call cross-platform, yet.
32
- let child = spawnSync(kmcomp, args, {
33
- encoding: 'utf8'
9
+ // We need to resolve paths to absolute paths before calling kmc-kmn
10
+ let outfile = (options.outFile ?? infile).replace(/\.km.$/i, '.kmx');
11
+ infile = getPosixAbsolutePath(infile);
12
+ outfile = getPosixAbsolutePath(outfile);
13
+ // TODO: Currently this only builds .kmn->.kmx, and targeting .js is as-yet unsupported
14
+ // TODO: Support additional options compilerWarningsAsErrors, warnDeprecatedCode
15
+ return compiler.run(infile, outfile, {
16
+ saveDebug: options.debug,
17
+ shouldAddCompilerVersion: options.compilerVersion,
34
18
  });
35
- if (child.error) {
36
- console.error(child.error);
37
- return false;
19
+ }
20
+ function getPosixAbsolutePath(filename) {
21
+ if (platform() == 'win32') {
22
+ // On Win32, we need to use backslashes for path.resolve to work
23
+ filename = filename.replace(/\//g, '\\');
38
24
  }
39
- console.log(child.stdout);
40
- if (child.stderr) {
41
- console.error(child.stderr);
25
+ // Resolve to a fully qualified absolute path
26
+ filename = path.resolve(filename);
27
+ if (platform() == 'win32') {
28
+ // Ensure that we convert the result back to posix-style paths which is what
29
+ // kmc-kmn expects. On posix platforms, we assume paths have forward slashes
30
+ // already
31
+ filename = filename.replace(/\\/g, '/');
42
32
  }
43
- return child.status === 0;
33
+ return filename;
44
34
  }
45
35
  //# sourceMappingURL=buildKmnKeyboard.js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,OAAO,EAAE;QACnC,SAAS,EAAE,OAAO,CAAC,KAAK;QACxB,wBAAwB,EAAE,OAAO,CAAC,eAAe;KAClD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,IAAG,QAAQ,EAAE,IAAI,OAAO,EAAE;QACxB,gEAAgE;QAChE,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KAC1C;IAED,6CAA6C;IAC7C,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAElC,IAAG,QAAQ,EAAE,IAAI,OAAO,EAAE;QACxB,4EAA4E;QAC5E,4EAA4E;QAC5E,UAAU;QACV,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KACzC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -69,5 +69,5 @@
69
69
  "type": "git",
70
70
  "url": "git+https://github.com/keymanapp/keyman.git"
71
71
  },
72
- "version": "17.0.83-alpha"
72
+ "version": "17.0.85-alpha"
73
73
  }