@keymanapp/common-types 17.0.85-alpha → 17.0.87-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/package.json +5 -2
- package/build/tsconfig.tsbuildinfo +0 -1
- package/build.sh +0 -86
- package/src/consts/virtual-key-constants.ts +0 -257
- package/src/keyman-touch-layout/keyman-touch-layout-file-reader.ts +0 -81
- package/src/keyman-touch-layout/keyman-touch-layout-file-writer.ts +0 -84
- package/src/keyman-touch-layout/keyman-touch-layout-file.ts +0 -87
- package/src/kmx/element-string.ts +0 -79
- package/src/kmx/kmx-builder.ts +0 -287
- package/src/kmx/kmx-plus-builder/build-disp.ts +0 -46
- package/src/kmx/kmx-plus-builder/build-elem.ts +0 -103
- package/src/kmx/kmx-plus-builder/build-keys.ts +0 -175
- package/src/kmx/kmx-plus-builder/build-layr.ts +0 -154
- package/src/kmx/kmx-plus-builder/build-list.ts +0 -95
- package/src/kmx/kmx-plus-builder/build-loca.ts +0 -34
- package/src/kmx/kmx-plus-builder/build-meta.ts +0 -37
- package/src/kmx/kmx-plus-builder/build-name.ts +0 -37
- package/src/kmx/kmx-plus-builder/build-ordr.ts +0 -45
- package/src/kmx/kmx-plus-builder/build-sect.ts +0 -31
- package/src/kmx/kmx-plus-builder/build-strs.ts +0 -58
- package/src/kmx/kmx-plus-builder/build-tran.ts +0 -50
- package/src/kmx/kmx-plus-builder/build-vkey.ts +0 -43
- package/src/kmx/kmx-plus-builder/builder-section.ts +0 -6
- package/src/kmx/kmx-plus-builder/kmx-plus-builder.ts +0 -190
- package/src/kmx/kmx-plus.ts +0 -692
- package/src/kmx/kmx.ts +0 -360
- package/src/kmx/string-list.ts +0 -74
- package/src/kpj/keyman-developer-project.ts +0 -155
- package/src/kpj/kpj-file-reader.ts +0 -103
- package/src/kpj/kpj-file.ts +0 -52
- package/src/kvk/kvk-file-reader.ts +0 -34
- package/src/kvk/kvk-file-writer.ts +0 -72
- package/src/kvk/kvk-file.ts +0 -122
- package/src/kvk/kvks-file-reader.ts +0 -164
- package/src/kvk/kvks-file-writer.ts +0 -113
- package/src/kvk/kvks-file.ts +0 -53
- package/src/kvk/visual-keyboard.ts +0 -80
- package/src/ldml-keyboard/ldml-keyboard-testdata-xml.ts +0 -74
- package/src/ldml-keyboard/ldml-keyboard-xml-reader.ts +0 -387
- package/src/ldml-keyboard/ldml-keyboard-xml.ts +0 -177
- package/src/main.ts +0 -27
- package/src/restructure.d.ts +0 -2
- package/src/util/common-events.ts +0 -50
- package/src/util/compiler-interfaces.ts +0 -54
- package/src/util/util.ts +0 -68
- package/test/fixtures/import-minimal.xml +0 -8
- package/test/fixtures/import-minimal1.xml +0 -11
- package/test/fixtures/import-minimal2.xml +0 -11
- package/test/fixtures/import-symbols.xml +0 -13
- package/test/fixtures/invalid-conforms-to.xml +0 -19
- package/test/fixtures/invalid-import-base.xml +0 -16
- package/test/fixtures/invalid-import-path.xml +0 -16
- package/test/fixtures/invalid-import-readfail.xml +0 -16
- package/test/fixtures/invalid-import-wrongroot.xml +0 -16
- package/test/fixtures/invalid-structure-per-dtd.xml +0 -8
- package/test/fixtures/keyman-touch-layout/khmer_angkor.keyman-touch-layout +0 -1950
- package/test/fixtures/keyman-touch-layout/legacy.keyman-touch-layout +0 -36
- package/test/fixtures/kpj/khmer_angkor.kpj +0 -187
- package/test/fixtures/kvk/khmer_angkor.kvk +0 -0
- package/test/fixtures/kvk/khmer_angkor.kvks +0 -206
- package/test/fixtures/test-fr.xml +0 -22
- package/test/helpers/index.ts +0 -39
- package/test/helpers/reader-callback-test.ts +0 -199
- package/test/keyman-touch-layout/test-keyman-touch-layout-file-reader.ts +0 -71
- package/test/keyman-touch-layout/test-keyman-touch-layout-round-trip.ts +0 -35
- package/test/kpj/test-kpj-file-reader.ts +0 -123
- package/test/kvk/test-kvk-file.ts +0 -15
- package/test/kvk/test-kvk-round-trip.ts +0 -87
- package/test/kvk/test-kvk-utils.ts +0 -24
- package/test/kvk/test-kvks-file.ts +0 -45
- package/test/ldml-keyboard/test-ldml-keyboard-testdata-reader.ts +0 -51
- package/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts +0 -131
- package/test/tsconfig.json +0 -21
- package/test/util/test-unescape.ts +0 -38
- package/tsconfig.json +0 -17
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { constants } from "@keymanapp/ldml-keyboard-constants";
|
|
3
|
-
import { Bksp, Finl, Tran } from "../kmx-plus.js";
|
|
4
|
-
import { build_elem_index, BUILDER_ELEM } from "./build-elem.js";
|
|
5
|
-
import { build_strs_index, BUILDER_STRS } from "./build-strs.js";
|
|
6
|
-
import { BUILDER_SECTION } from "./builder-section.js";
|
|
7
|
-
|
|
8
|
-
/* ------------------------------------------------------------------
|
|
9
|
-
* tran section
|
|
10
|
-
------------------------------------------------------------------ */
|
|
11
|
-
|
|
12
|
-
interface BUILDER_TRAN_ITEM {
|
|
13
|
-
from: number; //elem.string
|
|
14
|
-
to: number; //str
|
|
15
|
-
before: number; //elem.string
|
|
16
|
-
flags: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export interface BUILDER_TRAN extends BUILDER_SECTION {
|
|
20
|
-
count: number;
|
|
21
|
-
items: BUILDER_TRAN_ITEM[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Builder for the 'tran', 'finl', and 'bksp' sections, all of which use the BUILDER_TRAN layout
|
|
26
|
-
*/
|
|
27
|
-
export function build_tran(source_tran: Tran|Finl|Bksp, sect_strs: BUILDER_STRS, sect_elem: BUILDER_ELEM): BUILDER_TRAN {
|
|
28
|
-
if(!source_tran?.items.length) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let tran: BUILDER_TRAN = {
|
|
33
|
-
ident: constants.hex_section_id(source_tran.id),
|
|
34
|
-
size: constants.length_tran + constants.length_tran_item * source_tran.items.length,
|
|
35
|
-
_offset: 0,
|
|
36
|
-
count: source_tran.items.length,
|
|
37
|
-
items: []
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
for(let item of source_tran.items) {
|
|
41
|
-
tran.items.push({
|
|
42
|
-
from: build_elem_index(sect_elem, item.from),
|
|
43
|
-
to: build_strs_index(sect_strs, item.to),
|
|
44
|
-
before: build_elem_index(sect_elem, item.before),
|
|
45
|
-
flags: item.flags
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return tran;
|
|
50
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { constants } from '@keymanapp/ldml-keyboard-constants';
|
|
2
|
-
import { KMXPlusData } from "../kmx-plus.js";
|
|
3
|
-
import { BUILDER_SECTION } from './builder-section.js';
|
|
4
|
-
|
|
5
|
-
/* ------------------------------------------------------------------
|
|
6
|
-
* vkey section
|
|
7
|
-
------------------------------------------------------------------ */
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Builder for the 'vkey' section
|
|
11
|
-
*/
|
|
12
|
-
interface BUILDER_VKEY_ITEM {
|
|
13
|
-
vkey: number;
|
|
14
|
-
target: number;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export interface BUILDER_VKEY extends BUILDER_SECTION {
|
|
18
|
-
count: number;
|
|
19
|
-
items: BUILDER_VKEY_ITEM[];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function build_vkey(kmxplus: KMXPlusData): BUILDER_VKEY {
|
|
23
|
-
if(!kmxplus.vkey.vkeys.length) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let vkey: BUILDER_VKEY = {
|
|
28
|
-
ident: constants.hex_section_id(constants.section.vkey),
|
|
29
|
-
size: constants.length_vkey + constants.length_vkey_item * kmxplus.vkey.vkeys.length,
|
|
30
|
-
_offset: 0,
|
|
31
|
-
count: kmxplus.vkey.vkeys.length,
|
|
32
|
-
items: []
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
for(let item of kmxplus.vkey.vkeys) {
|
|
36
|
-
vkey.items.push({
|
|
37
|
-
vkey: item.vkey,
|
|
38
|
-
target: item.target
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return vkey;
|
|
43
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import * as r from 'restructure';
|
|
2
|
-
import { KMXPlusFile } from "../kmx-plus.js";
|
|
3
|
-
import { constants, SectionIdent } from '@keymanapp/ldml-keyboard-constants';
|
|
4
|
-
import { BUILDER_SECTION } from './builder-section.js';
|
|
5
|
-
import { BUILDER_SECT, build_sect } from './build-sect.js';
|
|
6
|
-
import { BUILDER_DISP, build_disp } from './build-disp.js';
|
|
7
|
-
import { BUILDER_ELEM, build_elem } from './build-elem.js';
|
|
8
|
-
import { BUILDER_KEYS, build_keys } from './build-keys.js';
|
|
9
|
-
import { BUILDER_LAYR, build_layr } from './build-layr.js';
|
|
10
|
-
import { BUILDER_LIST, build_list } from './build-list.js';
|
|
11
|
-
import { BUILDER_LOCA, build_loca } from './build-loca.js';
|
|
12
|
-
import { BUILDER_META, build_meta } from './build-meta.js';
|
|
13
|
-
import { BUILDER_NAME, build_name } from './build-name.js';
|
|
14
|
-
import { BUILDER_ORDR, build_ordr } from './build-ordr.js';
|
|
15
|
-
import { BUILDER_STRS, build_strs } from './build-strs.js';
|
|
16
|
-
import { BUILDER_TRAN, build_tran } from './build-tran.js';
|
|
17
|
-
import { BUILDER_VKEY, build_vkey } from './build-vkey.js';
|
|
18
|
-
|
|
19
|
-
type BUILDER_BKSP = BUILDER_TRAN;
|
|
20
|
-
type BUILDER_FINL = BUILDER_TRAN;
|
|
21
|
-
|
|
22
|
-
type SectionBuilders = {
|
|
23
|
-
// [id in SectionIdent]: BUILDER_SECTION;
|
|
24
|
-
sect?: BUILDER_SECT;
|
|
25
|
-
bksp?: BUILDER_BKSP;
|
|
26
|
-
disp?: BUILDER_DISP;
|
|
27
|
-
elem?: BUILDER_ELEM;
|
|
28
|
-
finl?: BUILDER_FINL;
|
|
29
|
-
keys?: BUILDER_KEYS;
|
|
30
|
-
layr?: BUILDER_LAYR;
|
|
31
|
-
list?: BUILDER_LIST;
|
|
32
|
-
loca?: BUILDER_LOCA;
|
|
33
|
-
meta?: BUILDER_META;
|
|
34
|
-
name?: BUILDER_NAME;
|
|
35
|
-
ordr?: BUILDER_ORDR;
|
|
36
|
-
strs?: BUILDER_STRS;
|
|
37
|
-
tran?: BUILDER_TRAN;
|
|
38
|
-
vkey?: BUILDER_VKEY;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default class KMXPlusBuilder {
|
|
42
|
-
private file: KMXPlusFile;
|
|
43
|
-
//private writeDebug: boolean;
|
|
44
|
-
|
|
45
|
-
sect : SectionBuilders = {
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
constructor(file: KMXPlusFile, _writeDebug: boolean) {
|
|
50
|
-
this.file = file;
|
|
51
|
-
//this.writeDebug = _writeDebug;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public compile(): Uint8Array {
|
|
55
|
-
const fileSize = this.build();
|
|
56
|
-
let file: Uint8Array = new Uint8Array(fileSize);
|
|
57
|
-
|
|
58
|
-
this.emitSection(file, this.file.COMP_PLUS_SECT, this.sect.sect);
|
|
59
|
-
// Keep the rest of these in order.
|
|
60
|
-
this.emitSection(file, this.file.COMP_PLUS_BKSP, this.sect.bksp);
|
|
61
|
-
this.emitSection(file, this.file.COMP_PLUS_DISP, this.sect.disp);
|
|
62
|
-
this.emitSection(file, this.file.COMP_PLUS_ELEM, this.sect.elem);
|
|
63
|
-
this.emitElements(file);
|
|
64
|
-
this.emitSection(file, this.file.COMP_PLUS_FINL, this.sect.finl);
|
|
65
|
-
this.emitSection(file, this.file.COMP_PLUS_KEYS, this.sect.keys);
|
|
66
|
-
this.emitSection(file, this.file.COMP_PLUS_LAYR, this.sect.layr);
|
|
67
|
-
this.emitSection(file, this.file.COMP_PLUS_LIST, this.sect.list);
|
|
68
|
-
this.emitSection(file, this.file.COMP_PLUS_LOCA, this.sect.loca);
|
|
69
|
-
this.emitSection(file, this.file.COMP_PLUS_META, this.sect.meta);
|
|
70
|
-
this.emitSection(file, this.file.COMP_PLUS_NAME, this.sect.name);
|
|
71
|
-
this.emitSection(file, this.file.COMP_PLUS_ORDR, this.sect.ordr);
|
|
72
|
-
this.emitSection(file, this.file.COMP_PLUS_STRS, this.sect.strs);
|
|
73
|
-
this.emitStrings(file);
|
|
74
|
-
this.emitSection(file, this.file.COMP_PLUS_TRAN, this.sect.tran);
|
|
75
|
-
this.emitSection(file, this.file.COMP_PLUS_VKEY, this.sect.vkey);
|
|
76
|
-
|
|
77
|
-
return file;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private build() {
|
|
81
|
-
// Required sections: sect, strs, loca, meta
|
|
82
|
-
|
|
83
|
-
// We must prepare the strs, list, and elem sections early so that other sections can
|
|
84
|
-
// reference them. However, they will be emitted in alpha order.
|
|
85
|
-
this.sect.strs = build_strs(this.file.kmxplus.strs);
|
|
86
|
-
this.sect.list = build_list(this.file.kmxplus.list, this.sect.strs);
|
|
87
|
-
this.sect.elem = build_elem(this.file.kmxplus.elem, this.sect.strs);
|
|
88
|
-
|
|
89
|
-
const build_bksp = build_tran;
|
|
90
|
-
const build_finl = build_tran;
|
|
91
|
-
|
|
92
|
-
this.sect.bksp = build_bksp(this.file.kmxplus.bksp, this.sect.strs, this.sect.elem);
|
|
93
|
-
this.sect.disp = build_disp(this.file.kmxplus, this.sect.strs);
|
|
94
|
-
this.sect.finl = build_finl(this.file.kmxplus.finl, this.sect.strs, this.sect.elem);
|
|
95
|
-
this.sect.keys = build_keys(this.file.kmxplus, this.sect.strs, this.sect.list);
|
|
96
|
-
this.sect.layr = build_layr(this.file.kmxplus, this.sect.strs, this.sect.list);
|
|
97
|
-
this.sect.loca = build_loca(this.file.kmxplus, this.sect.strs);
|
|
98
|
-
this.sect.meta = build_meta(this.file.kmxplus, this.sect.strs);
|
|
99
|
-
this.sect.name = build_name(this.file.kmxplus, this.sect.strs);
|
|
100
|
-
this.sect.ordr = build_ordr(this.file.kmxplus, this.sect.strs, this.sect.elem);
|
|
101
|
-
this.sect.tran = build_tran(this.file.kmxplus.tran, this.sect.strs, this.sect.elem);
|
|
102
|
-
this.sect.vkey = build_vkey(this.file.kmxplus);
|
|
103
|
-
|
|
104
|
-
// Finalize the sect (index) section
|
|
105
|
-
|
|
106
|
-
this.sect.sect = build_sect();
|
|
107
|
-
this.finalize_sect(); // must be done last
|
|
108
|
-
return this.sect.sect.total;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private finalize_sect() {
|
|
112
|
-
// 'sect' section
|
|
113
|
-
|
|
114
|
-
this.sect.sect.count = 0;
|
|
115
|
-
|
|
116
|
-
Object.keys(constants.section).forEach((sectstr : string) => {
|
|
117
|
-
const sect : SectionIdent = constants.section[<SectionIdent>sectstr];
|
|
118
|
-
if(this.sect[sect] && sect !== 'sect') {
|
|
119
|
-
this.sect.sect.count++;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
this.sect.sect.size = constants.length_sect + constants.length_sect_item * this.sect.sect.count;
|
|
124
|
-
|
|
125
|
-
let offset = this.sect.sect.size;
|
|
126
|
-
// Note: in order! Everyone's here except 'sect' which is at offset 0
|
|
127
|
-
offset = this.finalize_sect_item(this.sect.bksp, offset);
|
|
128
|
-
offset = this.finalize_sect_item(this.sect.disp, offset);
|
|
129
|
-
offset = this.finalize_sect_item(this.sect.elem, offset);
|
|
130
|
-
offset = this.finalize_sect_item(this.sect.finl, offset);
|
|
131
|
-
offset = this.finalize_sect_item(this.sect.keys, offset);
|
|
132
|
-
offset = this.finalize_sect_item(this.sect.layr, offset);
|
|
133
|
-
offset = this.finalize_sect_item(this.sect.list, offset);
|
|
134
|
-
offset = this.finalize_sect_item(this.sect.loca, offset);
|
|
135
|
-
offset = this.finalize_sect_item(this.sect.meta, offset);
|
|
136
|
-
offset = this.finalize_sect_item(this.sect.name, offset);
|
|
137
|
-
offset = this.finalize_sect_item(this.sect.ordr, offset);
|
|
138
|
-
offset = this.finalize_sect_item(this.sect.strs, offset);
|
|
139
|
-
offset = this.finalize_sect_item(this.sect.tran, offset);
|
|
140
|
-
offset = this.finalize_sect_item(this.sect.vkey, offset);
|
|
141
|
-
|
|
142
|
-
this.sect.sect.total = offset;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private finalize_sect_item(sect: BUILDER_SECTION, offset: number): number {
|
|
146
|
-
if(!sect) {
|
|
147
|
-
// Don't include null sections
|
|
148
|
-
return offset;
|
|
149
|
-
}
|
|
150
|
-
sect._offset = offset;
|
|
151
|
-
this.sect.sect.items.push({sect: sect.ident, offset: offset});
|
|
152
|
-
return offset + sect.size;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private emitSection(file: Uint8Array, comp: any, sect: BUILDER_SECTION) {
|
|
156
|
-
if(sect) {
|
|
157
|
-
const buf = comp.toBuffer(sect);
|
|
158
|
-
if (buf.length > sect.size) {
|
|
159
|
-
// buf.length may be < sect.size if there is a variable part (i.e. elem)
|
|
160
|
-
throw new RangeError(`Internal Error: Section ${constants.str_section_id(sect.ident)} claimed size ${sect.size} but produced buffer of size ${buf.length}.`);
|
|
161
|
-
}
|
|
162
|
-
file.set(buf, sect._offset);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
private emitStrings(file: Uint8Array) {
|
|
167
|
-
for(let item of this.sect.strs.items) {
|
|
168
|
-
if(item._value === '') {
|
|
169
|
-
// We have a special case for the zero-length string
|
|
170
|
-
let sbuf = r.uint16le;
|
|
171
|
-
file.set(sbuf.toBuffer(0), item.offset + this.sect.strs._offset);
|
|
172
|
-
} else {
|
|
173
|
-
let sbuf = new r.String(null, 'utf16le');
|
|
174
|
-
file.set(sbuf.toBuffer(item._value), item.offset + this.sect.strs._offset);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private emitElements(file: Uint8Array) {
|
|
180
|
-
if(this.sect.elem) {
|
|
181
|
-
for(let str of this.sect.elem.strings) {
|
|
182
|
-
if(str.items.length > 0) {
|
|
183
|
-
let COMP_PLUS_ELEM_ELEMENTS = new r.Array(this.file.COMP_PLUS_ELEM_ELEMENT, str.items.length);
|
|
184
|
-
file.set(COMP_PLUS_ELEM_ELEMENTS.toBuffer(str.items), str.offset + this.sect.elem._offset);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
}
|