@keymanapp/kmc-ldml 17.0.120-alpha → 17.0.122-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.
Files changed (51) hide show
  1. package/build/src/compiler/compiler.d.ts +12 -2
  2. package/build/src/compiler/compiler.d.ts.map +1 -1
  3. package/build/src/compiler/compiler.js +39 -11
  4. package/build/src/compiler/compiler.js.map +1 -1
  5. package/build/src/compiler/disp.d.ts +2 -2
  6. package/build/src/compiler/disp.d.ts.map +1 -1
  7. package/build/src/compiler/disp.js.map +1 -1
  8. package/build/src/compiler/empty-compiler.d.ts +31 -0
  9. package/build/src/compiler/empty-compiler.d.ts.map +1 -0
  10. package/build/src/compiler/empty-compiler.js +56 -0
  11. package/build/src/compiler/empty-compiler.js.map +1 -0
  12. package/build/src/compiler/keys.d.ts +4 -4
  13. package/build/src/compiler/keys.d.ts.map +1 -1
  14. package/build/src/compiler/keys.js.map +1 -1
  15. package/build/src/compiler/layr.d.ts +2 -2
  16. package/build/src/compiler/layr.d.ts.map +1 -1
  17. package/build/src/compiler/layr.js.map +1 -1
  18. package/build/src/compiler/loca.d.ts +2 -2
  19. package/build/src/compiler/loca.d.ts.map +1 -1
  20. package/build/src/compiler/loca.js.map +1 -1
  21. package/build/src/compiler/messages.d.ts +40 -0
  22. package/build/src/compiler/messages.d.ts.map +1 -1
  23. package/build/src/compiler/messages.js +23 -0
  24. package/build/src/compiler/messages.js.map +1 -1
  25. package/build/src/compiler/meta.d.ts +2 -2
  26. package/build/src/compiler/meta.d.ts.map +1 -1
  27. package/build/src/compiler/meta.js.map +1 -1
  28. package/build/src/compiler/name.d.ts +2 -2
  29. package/build/src/compiler/name.d.ts.map +1 -1
  30. package/build/src/compiler/name.js.map +1 -1
  31. package/build/src/compiler/section-compiler.d.ts +11 -1
  32. package/build/src/compiler/section-compiler.d.ts.map +1 -1
  33. package/build/src/compiler/section-compiler.js +21 -0
  34. package/build/src/compiler/section-compiler.js.map +1 -1
  35. package/build/src/compiler/tran.d.ts +15 -22
  36. package/build/src/compiler/tran.d.ts.map +1 -1
  37. package/build/src/compiler/tran.js +111 -45
  38. package/build/src/compiler/tran.js.map +1 -1
  39. package/build/src/compiler/vars.d.ts +20 -0
  40. package/build/src/compiler/vars.d.ts.map +1 -0
  41. package/build/src/compiler/vars.js +178 -0
  42. package/build/src/compiler/vars.js.map +1 -0
  43. package/build/src/util/util.d.ts +10 -0
  44. package/build/src/util/util.d.ts.map +1 -1
  45. package/build/src/util/util.js +35 -0
  46. package/build/src/util/util.js.map +1 -1
  47. package/package.json +5 -4
  48. package/build/src/compiler/ordr.d.ts +0 -12
  49. package/build/src/compiler/ordr.d.ts.map +0 -1
  50. package/build/src/compiler/ordr.js +0 -35
  51. package/build/src/compiler/ordr.js.map +0 -1
@@ -1,12 +1,22 @@
1
1
  import { LDMLKeyboard, KMXPlus, CompilerCallbacks } from "@keymanapp/common-types";
2
2
  import { SectionIdent } from '@keymanapp/ldml-keyboard-constants';
3
3
  export declare class SectionCompiler {
4
+ /**
5
+ * Opportunity for async initialization.
6
+ * @returns true when OK. On false, causes a message to happen.
7
+ */
8
+ init(): Promise<boolean>;
4
9
  protected readonly keyboard: LDMLKeyboard.LKKeyboard;
5
10
  protected readonly callbacks: CompilerCallbacks;
6
11
  constructor(source: LDMLKeyboard.LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
7
12
  get id(): SectionIdent;
8
13
  get required(): boolean;
9
- compile(sections: KMXPlus.GlobalSections): KMXPlus.Section;
14
+ compile(sections: KMXPlus.DependencySections): KMXPlus.Section;
10
15
  validate(): boolean;
16
+ /**
17
+ * Get the dependencies for this compiler.
18
+ * @returns set of dependent sections
19
+ */
20
+ get dependencies(): Set<SectionIdent>;
11
21
  }
12
22
  //# sourceMappingURL=section-compiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"section-compiler.d.ts","sourceRoot":"","sources":["../../../src/compiler/section-compiler.ts"],"names":[],"mappings":"AAA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C,YAAY,CAAC,CAO3C;CACF"}
@@ -1,5 +1,14 @@
1
+ import { constants } from '@keymanapp/ldml-keyboard-constants';
1
2
  /* istanbul ignore next */
2
3
  export class SectionCompiler {
4
+ /**
5
+ * Opportunity for async initialization.
6
+ * @returns true when OK. On false, causes a message to happen.
7
+ */
8
+ async init() {
9
+ // nothing to do here
10
+ return true;
11
+ }
3
12
  keyboard;
4
13
  callbacks;
5
14
  constructor(source, callbacks) {
@@ -18,5 +27,17 @@ export class SectionCompiler {
18
27
  validate() {
19
28
  return true;
20
29
  }
30
+ /**
31
+ * Get the dependencies for this compiler.
32
+ * @returns set of dependent sections
33
+ */
34
+ get dependencies() {
35
+ const defaults = new Set([
36
+ constants.section.strs,
37
+ constants.section.list,
38
+ constants.section.elem
39
+ ]);
40
+ return defaults;
41
+ }
21
42
  }
22
43
  //# sourceMappingURL=section-compiler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"section-compiler.js","sourceRoot":"","sources":["../../../src/compiler/section-compiler.ts"],"names":[],"mappings":"AAGA,0BAA0B;AAC1B,MAAM,OAAO,eAAe;IACP,QAAQ,CAA0B;IAClC,SAAS,CAAoB;IAEhD,YAAY,MAA8C,EAAE,SAA4B;QACtF,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAW,EAAE;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,OAAO,CAAC,QAAgC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
1
+ {"version":3,"file":"section-compiler.js","sourceRoot":"","sources":["../../../src/compiler/section-compiler.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE7E,0BAA0B;AAC1B,MAAM,OAAO,eAAe;IAC1B;;;OAGG;IACI,KAAK,CAAC,IAAI;QACf,qBAAqB;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAEkB,QAAQ,CAA0B;IAClC,SAAS,CAAoB;IAEhD,YAAY,MAA8C,EAAE,SAA4B;QACtF,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAW,EAAE;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,OAAO,CAAC,QAAoC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,IAAW,YAAY;QACrB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAiB;YACvC,SAAS,CAAC,OAAO,CAAC,IAAI;YACtB,SAAS,CAAC,OAAO,CAAC,IAAI;YACtB,SAAS,CAAC,OAAO,CAAC,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -1,41 +1,34 @@
1
+ import { SectionIdent } from "@keymanapp/ldml-keyboard-constants";
1
2
  import { KMXPlus, LDMLKeyboard, CompilerCallbacks } from '@keymanapp/common-types';
2
3
  import { SectionCompiler } from "./section-compiler.js";
3
- import Finl = KMXPlus.Finl;
4
- import FinlItem = KMXPlus.FinlItem;
5
4
  import Bksp = KMXPlus.Bksp;
6
- import BkspItem = KMXPlus.BkspItem;
7
- import GlobalSections = KMXPlus.GlobalSections;
5
+ import DependencySections = KMXPlus.DependencySections;
8
6
  import Tran = KMXPlus.Tran;
9
- import TranItem = KMXPlus.TranItem;
10
7
  import LDMLKeyboardXMLSourceFile = LDMLKeyboard.LDMLKeyboardXMLSourceFile;
11
- type TransformCompilerType = 'simple' | 'final' | 'backspace';
12
- declare class TransformCompiler<T extends TransformCompilerType, TranBase extends Tran, TranItemBase extends TranItem> extends SectionCompiler {
8
+ type TransformCompilerType = 'simple' | 'backspace';
9
+ declare class TransformCompiler<T extends TransformCompilerType, TranBase extends Tran> extends SectionCompiler {
13
10
  protected type: T;
14
11
  constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
15
12
  validate(): boolean;
16
- protected newTranItem(): TranItemBase;
17
13
  protected newTran(): TranBase;
18
- private compileTransform;
19
14
  private compileTransforms;
20
- compile(sections: GlobalSections): TranBase;
15
+ private compileTransformGroup;
16
+ private compileTransformTranGroup;
17
+ private compileTransform;
18
+ private compileReorderTranGroup;
19
+ private compileReorder;
20
+ compile(sections: DependencySections): TranBase;
21
+ get dependencies(): Set<SectionIdent>;
21
22
  }
22
- export declare class TranCompiler extends TransformCompiler<'simple', Tran, TranItem> {
23
+ export declare class TranCompiler extends TransformCompiler<'simple', Tran> {
23
24
  constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
24
- protected newTranItem(): TranItem;
25
25
  protected newTran(): Tran;
26
- get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
27
- }
28
- export declare class FinlCompiler extends TransformCompiler<'final', Finl, FinlItem> {
29
- constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
30
- protected newTranItem(): FinlItem;
31
- protected newTran(): Finl;
32
- get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
26
+ get id(): SectionIdent;
33
27
  }
34
- export declare class BkspCompiler extends TransformCompiler<'backspace', Bksp, BkspItem> {
28
+ export declare class BkspCompiler extends TransformCompiler<'backspace', Bksp> {
35
29
  constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
36
- protected newTranItem(): BkspItem;
37
30
  protected newTran(): Bksp;
38
- get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
31
+ get id(): SectionIdent;
39
32
  }
40
33
  export {};
41
34
  //# sourceMappingURL=t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S,CAAC,IAAI,EAAE,CAAC,CAAC;gBAEN,MAAM,EAAE,yBAAyB,EAAE,SAAS,EAAE,iBAAiB;IAIpE,QAAQ,IAAI,OAAO;IAwC1B,SAAS,CAAC,OAAO,IAAI,QAAQ;IAK7B,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,yBAAyB;IASjC,OAAO,CAAC,gBAAgB;IA4BxB,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,cAAc;IAOf,OAAO,CAAC,QAAQ,EAAE,kBAAkB,GAAG,QAAQ;IAStD,IAAW,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,CAS3C;CACF;AAED,qBAAa,YAAa,SAAQ,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAgB;gBACpE,MAAM,EAAE,yBAAyB,EAAE,SAAS,EAAE,iBAAiB;IAI3E,SAAS,CAAC,OAAO,IAAI,IAAI;IAGzB,IAAW,EAAE,iBAEZ;CACF;AAED,qBAAa,YAAa,SAAQ,iBAAiB,CAAC,WAAW,EAAE,IAAI,CAAgB;gBACvE,MAAM,EAAE,yBAAyB,EAAE,SAAS,EAAE,iBAAiB;IAI3E,SAAS,CAAC,OAAO,IAAI,IAAI;IAGzB,IAAW,EAAE,iBAEZ;CACF"}
@@ -1,54 +1,142 @@
1
1
  import { constants } from "@keymanapp/ldml-keyboard-constants";
2
- import { KMXPlus } from '@keymanapp/common-types';
2
+ import { KMXPlus, VariableParser } from '@keymanapp/common-types';
3
3
  import { SectionCompiler } from "./section-compiler.js";
4
- var Finl = KMXPlus.Finl;
5
- var FinlItem = KMXPlus.FinlItem;
6
4
  var Bksp = KMXPlus.Bksp;
7
- var BkspItem = KMXPlus.BkspItem;
8
5
  var Tran = KMXPlus.Tran;
9
- var TranItem = KMXPlus.TranItem;
10
- var TranItemFlags = KMXPlus.TranItemFlags;
6
+ var TranReorder = KMXPlus.TranReorder;
7
+ var TranTransform = KMXPlus.TranTransform;
8
+ import { verifyValidAndUnique } from "../util/util.js";
9
+ import { CompilerMessages } from "./messages.js";
11
10
  class TransformCompiler extends SectionCompiler {
12
11
  type;
13
12
  constructor(source, callbacks) {
14
13
  super(source, callbacks);
15
14
  }
16
15
  validate() {
16
+ const reportMessage = this.callbacks.reportMessage.bind(this.callbacks);
17
17
  let valid = true;
18
- // TODO-LDML: linting here should check for identical before+from, but this involves a double-parse which is ugly
19
- // TODO-LDML: unicodesets means that either we fully parse them and verify conflicting rules or the linting is imperfect
18
+ const transforms = this?.keyboard?.transforms;
19
+ if (transforms) {
20
+ const types = transforms.map(({ type }) => type);
21
+ if (!verifyValidAndUnique(types, types => reportMessage(CompilerMessages.Error_DuplicateTransformsType({ types })), new Set(['simple', 'backspace']), types => reportMessage(CompilerMessages.Error_InvalidTransformsType({ types })))) {
22
+ valid = false;
23
+ }
24
+ // check for mixed groups
25
+ let mixed = false;
26
+ let empty = false;
27
+ transforms.forEach(({ transformGroup }) => transformGroup.forEach((transformGroup) => {
28
+ if (transformGroup.reorder?.length && transformGroup.transform?.length) {
29
+ mixed = true;
30
+ }
31
+ if (!transformGroup.reorder?.length && !transformGroup.transform?.length) {
32
+ empty = true;
33
+ }
34
+ }));
35
+ if (mixed) {
36
+ valid = false;
37
+ reportMessage(CompilerMessages.Error_MixedTransformGroup()); // report this once
38
+ }
39
+ if (empty) {
40
+ valid = false;
41
+ reportMessage(CompilerMessages.Error_EmptyTransformGroup()); // report this once
42
+ }
43
+ // TODO-LDML: linting here should check for identical from, but this involves a double-parse which is ugly
44
+ // TODO-LDML: unicodesets means that either we fully parse them and verify conflicting rules or the linting is imperfect
45
+ }
20
46
  return valid;
21
47
  }
22
- newTranItem() {
23
- return null;
24
- }
25
48
  newTran() {
49
+ // needs to be overridden in the subclass
26
50
  return null;
27
51
  }
28
- compileTransform(sections, transform) {
29
- let result = this.newTranItem();
30
- result.from = sections.elem.allocElementString(sections.strs, transform.from);
31
- result.to = sections.strs.allocAndUnescapeString(transform.to);
32
- result.before = sections.elem.allocElementString(sections.strs, transform.before);
33
- result.flags = transform.error == 'fail' ? TranItemFlags.error : TranItemFlags.none;
34
- return result;
35
- }
36
52
  compileTransforms(sections, transforms) {
37
53
  let result = this.newTran();
38
- if (transforms?.transform) {
39
- for (let transform of transforms.transform) {
40
- result.items.push(this.compileTransform(sections, transform));
54
+ if (transforms?.transformGroup) {
55
+ for (let transformGroup of transforms.transformGroup) {
56
+ result.groups.push(this.compileTransformGroup(sections, transformGroup));
41
57
  }
42
58
  }
43
59
  return result;
44
60
  }
61
+ compileTransformGroup(sections, transformGroup) {
62
+ if (transformGroup.reorder.length && transformGroup.transform.length) {
63
+ // should have been caught by validate
64
+ throw Error(`Internal error: transformGroup has both reorder and transform elements.`);
65
+ }
66
+ else if (transformGroup.reorder.length) {
67
+ return this.compileReorderTranGroup(sections, transformGroup.reorder);
68
+ }
69
+ else if (transformGroup.transform.length) {
70
+ return this.compileTransformTranGroup(sections, transformGroup.transform);
71
+ }
72
+ else {
73
+ throw Error(`Internal error: transformGroup has neither reorder nor transform elements.`);
74
+ }
75
+ }
76
+ compileTransformTranGroup(sections, transforms) {
77
+ const result = {
78
+ type: constants.tran_group_type_transform,
79
+ transforms: transforms.map(transform => this.compileTransform(sections, transform)),
80
+ reorders: [],
81
+ };
82
+ return result;
83
+ }
84
+ compileTransform(sections, transform) {
85
+ let result = new TranTransform();
86
+ let cookedFrom = transform.from;
87
+ let cookedTo = transform.to;
88
+ cookedFrom = sections.vars.substituteStrings(cookedFrom, sections);
89
+ // TODO: handle 'map' case
90
+ const mapFrom = VariableParser.CAPTURE_SET_REFERENCE.exec(cookedFrom);
91
+ const mapTo = VariableParser.MAPPED_SET_REFERENCE.exec(cookedTo || '');
92
+ if (mapFrom && mapTo) { // TODO-LDML: error cases
93
+ result.mapFrom = sections.strs.allocString(mapFrom[1]); // var name
94
+ result.mapTo = sections.strs.allocString(mapTo[1]); // var name
95
+ }
96
+ else {
97
+ result.mapFrom = sections.strs.allocString(''); // TODO-LDML
98
+ result.mapTo = sections.strs.allocString(''); // TODO-LDML
99
+ }
100
+ cookedFrom = sections.vars.substituteSetRegex(cookedFrom, sections);
101
+ if (cookedTo) {
102
+ cookedTo = sections.vars.substituteStrings(cookedTo, sections);
103
+ }
104
+ result.from = sections.strs.allocAndUnescapeString(cookedFrom); // TODO-LDML: not unescaped here, done previously
105
+ result.to = sections.strs.allocAndUnescapeString(cookedTo); // TODO-LDML: not unescaped here, done previously
106
+ return result;
107
+ }
108
+ compileReorderTranGroup(sections, reorders) {
109
+ const result = {
110
+ type: constants.tran_group_type_reorder,
111
+ transforms: [],
112
+ reorders: reorders.map(reorder => this.compileReorder(sections, reorder)),
113
+ };
114
+ return result;
115
+ }
116
+ compileReorder(sections, reorder) {
117
+ let result = new TranReorder();
118
+ result.elements = sections.elem.allocElementString(sections.strs, reorder.from, reorder.order, reorder.tertiary, reorder.tertiaryBase, reorder.preBase);
119
+ result.before = sections.elem.allocElementString(sections.strs, reorder.before);
120
+ return result;
121
+ }
45
122
  compile(sections) {
46
123
  for (let t of this.keyboard.transforms) {
47
124
  if (t.type == this.type) {
125
+ // compile only the transforms of the correct type
48
126
  return this.compileTransforms(sections, t);
49
127
  }
50
128
  }
51
- return this.newTran();
129
+ return this.newTran(); // empty: nothing of this type found.
130
+ }
131
+ get dependencies() {
132
+ const defaults = new Set([
133
+ constants.section.strs,
134
+ constants.section.list,
135
+ constants.section.elem,
136
+ constants.section.vars,
137
+ ]);
138
+ defaults.delete(this.id);
139
+ return defaults;
52
140
  }
53
141
  }
54
142
  export class TranCompiler extends TransformCompiler {
@@ -56,9 +144,6 @@ export class TranCompiler extends TransformCompiler {
56
144
  super(source, callbacks);
57
145
  this.type = 'simple';
58
146
  }
59
- newTranItem() {
60
- return new TranItem();
61
- }
62
147
  newTran() {
63
148
  return new Tran();
64
149
  }
@@ -67,30 +152,11 @@ export class TranCompiler extends TransformCompiler {
67
152
  }
68
153
  }
69
154
  ;
70
- export class FinlCompiler extends TransformCompiler {
71
- constructor(source, callbacks) {
72
- super(source, callbacks);
73
- this.type = 'final';
74
- }
75
- newTranItem() {
76
- return new FinlItem();
77
- }
78
- newTran() {
79
- return new Finl();
80
- }
81
- get id() {
82
- return constants.section.finl;
83
- }
84
- }
85
- ;
86
155
  export class BkspCompiler extends TransformCompiler {
87
156
  constructor(source, callbacks) {
88
157
  super(source, callbacks);
89
158
  this.type = 'backspace';
90
159
  }
91
- newTranItem() {
92
- return new BkspItem();
93
- }
94
160
  newTran() {
95
161
  return new Bksp();
96
162
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tran.js","sourceRoot":"","sources":["../../../src/compiler/tran.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAmC,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,IAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC3B,IAAO,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AACnC,IAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC3B,IAAO,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AAEnC,IAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC3B,IAAO,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AACnC,IAAO,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAO7C,MAAM,iBAAyG,SAAQ,eAAe;IAE1H,IAAI,CAAI;IAElB,YAAY,MAAiC,EAAE,SAA4B;QACzE,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC3B,CAAC;IAEM,QAAQ;QACb,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,iHAAiH;QACjH,wHAAwH;QACxH,OAAO,KAAK,CAAC;IACf,CAAC;IAES,WAAW;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IA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,CAAC,CAAC;QACH,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,iBAAgD;IAChF,YAAY,MAAiC,EAAE,SAA4B;QACzE,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;IACvB,CAAC;IACS,OAAO;QACf,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,IAAW,EAAE;QACX,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;CACF;AAAA,CAAC;AAEF,MAAM,OAAO,YAAa,SAAQ,iBAAmD;IACnF,YAAY,MAAiC,EAAE,SAA4B;QACzE,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;IACS,OAAO;QACf,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,IAAW,EAAE;QACX,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;CACF;AAAA,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { SectionIdent } from "@keymanapp/ldml-keyboard-constants";
2
+ import { KMXPlus, LDMLKeyboard, CompilerCallbacks } from '@keymanapp/common-types';
3
+ import { UnicodeSetParser } from '@keymanapp/common-types';
4
+ import { SectionCompiler } from "./section-compiler.js";
5
+ import Vars = KMXPlus.Vars;
6
+ import DependencySections = KMXPlus.DependencySections;
7
+ import LDMLKeyboardXMLSourceFile = LDMLKeyboard.LDMLKeyboardXMLSourceFile;
8
+ export declare class VarsCompiler extends SectionCompiler {
9
+ get id(): SectionIdent;
10
+ get dependencies(): Set<SectionIdent>;
11
+ usetparser: UnicodeSetParser;
12
+ init(): Promise<boolean>;
13
+ constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
14
+ validate(): boolean;
15
+ compile(sections: DependencySections): Vars;
16
+ addString(result: Vars, e: LDMLKeyboard.LKString, sections: DependencySections): void;
17
+ addSet(result: Vars, e: LDMLKeyboard.LKSet, sections: DependencySections): void;
18
+ addUnicodeSet(result: Vars, e: LDMLKeyboard.LKUnicodeSet, sections: DependencySections): void;
19
+ }
20
+ //# sourceMappingURL=vars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vars.d.ts","sourceRoot":"","sources":["../../../src/compiler/vars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAkB,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAI3B,OAAO,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;AACvD,OAAO,yBAAyB,GAAG,YAAY,CAAC,yBAAyB,CAAC;AAE1E,qBAAa,YAAa,SAAQ,eAAe;IAC/C,IAAW,EAAE,iBAEZ;IAED,IAAW,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,CAO3C;IAED,UAAU,EAAG,gBAAgB,CAAQ;IAExB,IAAI,IAAK,OAAO,CAAC,OAAO,CAAC;gBAS1B,MAAM,EAAE,yBAAyB,EAAE,SAAS,EAAE,iBAAiB;IAIpE,QAAQ,IAAI,OAAO;IA0GnB,OAAO,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAwBlD,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAOrF,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAU/E,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI;CAS9F"}
@@ -0,0 +1,178 @@
1
+ import { constants } from "@keymanapp/ldml-keyboard-constants";
2
+ import { KMXPlus } from '@keymanapp/common-types';
3
+ import { VariableParser } from '@keymanapp/common-types';
4
+ import { KmnCompiler } from '@keymanapp/kmc-kmn';
5
+ import { SectionCompiler } from "./section-compiler.js";
6
+ var Vars = KMXPlus.Vars;
7
+ var StringVarItem = KMXPlus.StringVarItem;
8
+ var SetVarItem = KMXPlus.SetVarItem;
9
+ var UnicodeSetItem = KMXPlus.UnicodeSetItem;
10
+ import { CompilerMessages } from "./messages.js";
11
+ export class VarsCompiler extends SectionCompiler {
12
+ get id() {
13
+ return constants.section.vars;
14
+ }
15
+ get dependencies() {
16
+ const defaults = new Set([
17
+ constants.section.strs,
18
+ constants.section.elem
19
+ ]);
20
+ defaults.delete(this.id);
21
+ return defaults;
22
+ }
23
+ usetparser = null;
24
+ async init() {
25
+ const compiler = new KmnCompiler();
26
+ const ok = await compiler.init(this.callbacks);
27
+ if (ok) {
28
+ this.usetparser = compiler;
29
+ }
30
+ return ok;
31
+ }
32
+ constructor(source, callbacks) {
33
+ super(source, callbacks);
34
+ }
35
+ validate() {
36
+ let valid = true;
37
+ // TODO-LDML scan for markers?
38
+ // Check for duplicate ids
39
+ const allIds = new Set();
40
+ const dups = new Set();
41
+ const variables = this.keyboard?.variables;
42
+ if (!variables)
43
+ return valid;
44
+ const allStrings = new Set();
45
+ const allSets = new Set();
46
+ const allUnicodeSets = new Set();
47
+ /**
48
+ * add an ID to check for duplicates
49
+ * @param id id
50
+ */
51
+ function addId(id) {
52
+ if (allIds.has(id)) {
53
+ dups.add(id);
54
+ }
55
+ else {
56
+ allIds.add(id);
57
+ }
58
+ }
59
+ // Strings
60
+ for (const { id, value } of variables?.string) {
61
+ addId(id);
62
+ allStrings.add(id);
63
+ const stringrefs = VariableParser.allStringReferences(value);
64
+ for (const id2 of stringrefs) {
65
+ if (!allStrings.has(id2)) {
66
+ valid = false;
67
+ this.callbacks.reportMessage(CompilerMessages.Error_MissingStringVariable({ id: id2 }));
68
+ }
69
+ }
70
+ }
71
+ // Sets
72
+ for (const { id, value } of variables.set) {
73
+ addId(id);
74
+ allSets.add(id);
75
+ // check for illegal references, here.
76
+ const stringrefs = VariableParser.allStringReferences(value);
77
+ for (const id2 of stringrefs) {
78
+ if (!allStrings.has(id2)) {
79
+ valid = false;
80
+ this.callbacks.reportMessage(CompilerMessages.Error_MissingStringVariable({ id: id2 }));
81
+ }
82
+ }
83
+ // Now split into spaces.
84
+ const items = VariableParser.setSplitter(value);
85
+ for (const item of items) {
86
+ const setrefs = VariableParser.allSetReferences(item);
87
+ if (setrefs.length > 1) {
88
+ // this is the form $[seta]$[setb]
89
+ valid = false;
90
+ this.callbacks.reportMessage(CompilerMessages.Error_NeedSpacesBetweenSetVariables({ item }));
91
+ }
92
+ else {
93
+ for (const id2 of setrefs) {
94
+ if (!allSets.has(id2)) {
95
+ valid = false;
96
+ this.callbacks.reportMessage(CompilerMessages.Error_MissingSetVariable({ id: id2 }));
97
+ }
98
+ }
99
+ }
100
+ // TODO-LDML: Are there other illegal cases here? what about "x$[set]"?
101
+ }
102
+ }
103
+ // UnicodeSets
104
+ for (const { id, value } of variables.unicodeSet) {
105
+ addId(id);
106
+ allUnicodeSets.add(id);
107
+ const stringrefs = VariableParser.allStringReferences(value);
108
+ for (const id2 of stringrefs) {
109
+ if (!allStrings.has(id2)) {
110
+ valid = false;
111
+ this.callbacks.reportMessage(CompilerMessages.Error_MissingStringVariable({ id: id2 }));
112
+ }
113
+ }
114
+ const setrefs = VariableParser.allSetReferences(value);
115
+ for (const id2 of setrefs) {
116
+ if (!allUnicodeSets.has(id2)) {
117
+ valid = false;
118
+ if (allSets.has(id2)) {
119
+ // $[set] in a UnicodeSet must be another UnicodeSet.
120
+ this.callbacks.reportMessage(CompilerMessages.Error_CantReferenceSetFromUnicodeSet({ id: id2 }));
121
+ }
122
+ else {
123
+ this.callbacks.reportMessage(CompilerMessages.Error_MissingUnicodeSetVariable({ id: id2 }));
124
+ }
125
+ }
126
+ }
127
+ }
128
+ // one report if any dups
129
+ if (dups.size > 0) {
130
+ this.callbacks.reportMessage(CompilerMessages.Error_DuplicateVariable({
131
+ ids: Array.from(dups.values()).sort().join(', ')
132
+ }));
133
+ valid = false;
134
+ }
135
+ return valid;
136
+ }
137
+ compile(sections) {
138
+ const result = new Vars();
139
+ const variables = this.keyboard?.variables;
140
+ if (!variables)
141
+ return result; // Empty vars, to simplify other sections
142
+ // we already know the variables do not conflict with each other
143
+ // need to add these one by one, because they depend on each other.
144
+ // we don't add these in completely 'natural' order because xml2js has already lost that.
145
+ // instead we go: strings, sets, then unicodeSets.
146
+ // first, strings.
147
+ variables?.string?.forEach((e) => this.addString(result, e, sections));
148
+ variables?.set?.forEach((e) => this.addSet(result, e, sections));
149
+ variables?.unicodeSet?.forEach((e) => this.addUnicodeSet(result, e, sections));
150
+ return result.valid() ? result : null;
151
+ }
152
+ // routines for initializing Vars remain here, in the compiler.
153
+ addString(result, e, sections) {
154
+ const { id } = e;
155
+ let { value } = e;
156
+ // fix any variables
157
+ value = result.substituteStrings(value, sections);
158
+ result.strings.push(new StringVarItem(id, value, sections));
159
+ }
160
+ addSet(result, e, sections) {
161
+ const { id } = e;
162
+ let { value } = e;
163
+ // first substitute strings
164
+ value = result.substituteStrings(value, sections);
165
+ // OK to do this as a substitute, because we've already validated the set above.
166
+ value = result.substituteSets(value, sections);
167
+ const items = VariableParser.setSplitter(value);
168
+ result.sets.push(new SetVarItem(id, items, sections));
169
+ }
170
+ addUnicodeSet(result, e, sections) {
171
+ const { id } = e;
172
+ let { value } = e;
173
+ value = result.substituteStrings(value, sections);
174
+ value = result.substituteUnicodeSets(value, sections);
175
+ result.unicodeSets.push(new UnicodeSetItem(id, value, sections, this.usetparser));
176
+ }
177
+ }
178
+ //# sourceMappingURL=vars.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vars.js","sourceRoot":"","sources":["../../../src/compiler/vars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAmC,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAoB,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAO,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,IAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC3B,IAAO,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAC7C,IAAO,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;AACvC,IAAO,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,MAAM,OAAO,YAAa,SAAQ,eAAe;IAC/C,IAAW,EAAE;QACX,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,IAAW,YAAY;QACrB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAiB;YACvC,SAAS,CAAC,OAAO,CAAC,IAAI;YACtB,SAAS,CAAC,OAAO,CAAC,IAAI;SACvB,CAAC,CAAC;QACH,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,UAAU,GAAsB,IAAI,CAAC;IAE9B,KAAK,CAAC,IAAI;QACf,MAAM,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;QACnC,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAA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pF,CAAC;CAGF"}
@@ -18,6 +18,16 @@ export declare function calculateUniqueKeys(keys?: LDMLKeyboard.LKKey[]): LDMLKe
18
18
  * @returns set of key IDs
19
19
  */
20
20
  export declare function allUsedKeyIdsInLayers(layersList: LDMLKeyboard.LKLayers[] | null): Set<string>;
21
+ /**
22
+ * Helper function for validating child elements. Written for the convenience of message passing functions.
23
+ *
24
+ * @param values array of values to check
25
+ * @param onDuplicate callback with array of duplicate values, deduped
26
+ * @param allowed optional set of valid values
27
+ * @param onInvalid callback with array of invalid values, deduped
28
+ * @returns true if all OK
29
+ */
30
+ export declare function verifyValidAndUnique(values: string[], onDuplicate: (duplicates: string[]) => void, allowed?: Set<string>, onInvalid?: (invalids: string[]) => void): boolean;
21
31
  /**
22
32
  * Determine modifier from layer info
23
33
  * @param layer layer obj
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,WAEjG;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,KAAK,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE,CAiBrF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAgB9F;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,GAAI,MAAM,CAYjF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAI,O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