@markw65/monkeyc-optimizer 1.1.46 → 1.1.48
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/CHANGELOG.md +9 -0
- package/bin/cft-font-info.js +77 -25
- package/build/api.cjs +34 -34
- package/build/cftinfo.cjs +181 -5
- package/build/{chunk-LZIGQANB.cjs → chunk-NB4IMZ6R.cjs} +5 -5
- package/build/optimizer.cjs +16 -16
- package/build/sdk-util.cjs +14 -14
- package/build/src/cftinfo.d.ts +27 -3
- package/build/worker-thread.cjs +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the "monkeyc-optimizer" package will be documented in this file.
|
|
4
4
|
|
|
5
|
+
### 1.1.48
|
|
6
|
+
|
|
7
|
+
- Adds a `--char-info-as-array` option to `cft-font-info`. When this option is set, charInfo is an array of arrays, rather than an array of objects, and there is a (single) `charInfoNames` array, giving the names of the elements of the charInfo sub-arrays. This is to save space - the charInfo array only contains the data, rather than (potentially) thousands of copies of the field names.
|
|
8
|
+
|
|
9
|
+
### 1.1.47
|
|
10
|
+
|
|
11
|
+
- Adds glyphAscent and glyphDescent to the font info produced by `cft-font-info`
|
|
12
|
+
- Adds a `--chars` option to `cft-font-info` to select the chars you want included. This can save time, and greatly reduce the amount of output produced.
|
|
13
|
+
|
|
5
14
|
### 1.1.46
|
|
6
15
|
|
|
7
16
|
- No change in functionality, but make @markw65/peggy-optimizer a devDependency so it doesn't get shipped with the package, and update to [@markw65/prettier-plugin-monkeyc@1.0.55](https://github.com/markw65/prettier-plugin-monkeyc/blob/main/CHANGELOG.md#1055) for the same reason.
|
package/bin/cft-font-info.js
CHANGED
|
@@ -2,12 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
const cft = require("../build/cftinfo.cjs");
|
|
4
4
|
const sdkUtil = require("../build/sdk-util.cjs");
|
|
5
|
-
const { globa } = require("../build/util.cjs");
|
|
5
|
+
const { globa, promiseAll } = require("../build/util.cjs");
|
|
6
6
|
const path = require("node:path");
|
|
7
7
|
|
|
8
8
|
const fonts = new Set();
|
|
9
|
+
const otherArgs = [];
|
|
10
|
+
let charsWanted;
|
|
11
|
+
let charInfoAsArray;
|
|
12
|
+
|
|
13
|
+
function error(e) {
|
|
14
|
+
throw new Error(e);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const prev = process.argv.slice(2).reduce((key, value) => {
|
|
18
|
+
const plain = !key && !value.startsWith("--");
|
|
19
|
+
if (plain) {
|
|
20
|
+
otherArgs.push(value);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const match = /^--((?:\w|-)+)(?:=(.*))?$/.exec(value);
|
|
24
|
+
if (!key) {
|
|
25
|
+
if (!match) {
|
|
26
|
+
error(`Expected an argument but got: ${value}`);
|
|
27
|
+
}
|
|
28
|
+
key = match[1];
|
|
29
|
+
value = match[2];
|
|
30
|
+
} else if (match) {
|
|
31
|
+
error(`Missing arg for '${key}'`);
|
|
32
|
+
}
|
|
33
|
+
switch (key) {
|
|
34
|
+
case "chars":
|
|
35
|
+
if (value == null) return key;
|
|
36
|
+
charsWanted = (charsWanted ?? "") + value;
|
|
37
|
+
break;
|
|
38
|
+
case "char-info-as-array":
|
|
39
|
+
charInfoAsArray = !value || /^(true|1)$/i.test(value);
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
error(`Unknown argument: --${key}`);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}, null);
|
|
46
|
+
if (prev) error(`Missing arg for '${prev}'`);
|
|
47
|
+
|
|
9
48
|
Promise.all(
|
|
10
|
-
|
|
49
|
+
otherArgs.map((filename) => {
|
|
11
50
|
if (/\.cft$/i.test(filename)) {
|
|
12
51
|
return globa(path.resolve(sdkUtil.connectiq, "Fonts", filename)).then(
|
|
13
52
|
(filenames) => {
|
|
@@ -36,28 +75,41 @@ Promise.all(
|
|
|
36
75
|
)
|
|
37
76
|
);
|
|
38
77
|
})
|
|
39
|
-
)
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
78
|
+
).then((results) => {
|
|
79
|
+
console.log("{");
|
|
80
|
+
let last = -1;
|
|
81
|
+
let active = [];
|
|
82
|
+
const fontArray = Array.from(fonts).sort();
|
|
83
|
+
return promiseAll(
|
|
84
|
+
(i) =>
|
|
85
|
+
fontArray[i] &&
|
|
86
|
+
cft
|
|
87
|
+
.getCFTFontInfo(fontArray[i], { chars: charsWanted, charInfoAsArray })
|
|
88
|
+
.then(({ name, ...rest }) => `"${name}":${JSON.stringify(rest)},`)
|
|
89
|
+
.catch(() => null)
|
|
90
|
+
.then((line) => {
|
|
91
|
+
active[i] = line;
|
|
92
|
+
while (active[last + 1] !== undefined) {
|
|
93
|
+
const a = active[++last];
|
|
94
|
+
if (a != null) {
|
|
95
|
+
console.log(a);
|
|
96
|
+
}
|
|
97
|
+
delete active[last];
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
)
|
|
101
|
+
.then(() => active.forEach((line) => line && console.log(line)))
|
|
102
|
+
.then(() =>
|
|
103
|
+
console.log(
|
|
104
|
+
`"devices":${JSON.stringify(
|
|
105
|
+
Object.fromEntries(
|
|
106
|
+
results
|
|
107
|
+
.flat()
|
|
108
|
+
.filter((result) => result != null)
|
|
109
|
+
.map(({ device, ...rest }) => [device, rest])
|
|
110
|
+
)
|
|
111
|
+
)}`
|
|
44
112
|
)
|
|
45
113
|
)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
fonts
|
|
49
|
-
.filter((font) => font != null)
|
|
50
|
-
.map(({ name, ...rest }) => [name, rest])
|
|
51
|
-
)
|
|
52
|
-
)
|
|
53
|
-
.then((fonts) => ({
|
|
54
|
-
fonts,
|
|
55
|
-
devices: Object.fromEntries(
|
|
56
|
-
results
|
|
57
|
-
.flat()
|
|
58
|
-
.filter((result) => result != null)
|
|
59
|
-
.map(({ device, ...rest }) => [device, rest])
|
|
60
|
-
),
|
|
61
|
-
}))
|
|
62
|
-
)
|
|
63
|
-
.then((results) => console.log(JSON.stringify(results)));
|
|
114
|
+
.then(() => console.log("}"));
|
|
115
|
+
});
|
package/build/api.cjs
CHANGED
|
@@ -18,47 +18,47 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var api_exports = {};
|
|
20
20
|
__export(api_exports, {
|
|
21
|
-
checkCompilerVersion: () =>
|
|
22
|
-
collectNamespaces: () =>
|
|
23
|
-
createDocumentationMap: () =>
|
|
24
|
-
diagnostic: () =>
|
|
25
|
-
diagnosticHelper: () =>
|
|
26
|
-
findNamesInScope: () =>
|
|
27
|
-
findUsingForNode: () =>
|
|
28
|
-
formatAst: () =>
|
|
29
|
-
formatAstLongLines: () =>
|
|
30
|
-
formatScopedName: () =>
|
|
31
|
-
getApiFunctionInfo: () =>
|
|
32
|
-
getApiMapping: () =>
|
|
33
|
-
getSuperClasses: () =>
|
|
21
|
+
checkCompilerVersion: () => import_chunk_NB4IMZ6R.checkCompilerVersion,
|
|
22
|
+
collectNamespaces: () => import_chunk_NB4IMZ6R.collectNamespaces,
|
|
23
|
+
createDocumentationMap: () => import_chunk_NB4IMZ6R.createDocumentationMap,
|
|
24
|
+
diagnostic: () => import_chunk_NB4IMZ6R.diagnostic,
|
|
25
|
+
diagnosticHelper: () => import_chunk_NB4IMZ6R.diagnosticHelper,
|
|
26
|
+
findNamesInScope: () => import_chunk_NB4IMZ6R.findNamesInScope,
|
|
27
|
+
findUsingForNode: () => import_chunk_NB4IMZ6R.findUsingForNode,
|
|
28
|
+
formatAst: () => import_chunk_NB4IMZ6R.formatAst,
|
|
29
|
+
formatAstLongLines: () => import_chunk_NB4IMZ6R.formatAstLongLines,
|
|
30
|
+
formatScopedName: () => import_chunk_NB4IMZ6R.formatScopedName,
|
|
31
|
+
getApiFunctionInfo: () => import_chunk_NB4IMZ6R.getApiFunctionInfo,
|
|
32
|
+
getApiMapping: () => import_chunk_NB4IMZ6R.getApiMapping,
|
|
33
|
+
getSuperClasses: () => import_chunk_NB4IMZ6R.getSuperClasses,
|
|
34
34
|
hasProperty: () => import_chunk_MBTLUWXR.hasProperty,
|
|
35
|
-
isClassVariable: () =>
|
|
36
|
-
isLocal: () =>
|
|
37
|
-
isLookupCandidate: () =>
|
|
38
|
-
isStateNode: () =>
|
|
39
|
-
lookupByFullName: () =>
|
|
40
|
-
lookupNext: () =>
|
|
41
|
-
lookupResultContains: () =>
|
|
42
|
-
lookupWithType: () =>
|
|
43
|
-
makeToyboxLink: () =>
|
|
44
|
-
mapVarDeclsByType: () =>
|
|
45
|
-
markInvokeClassMethod: () =>
|
|
46
|
-
parseSdkVersion: () =>
|
|
47
|
-
resolveDiagnostics: () =>
|
|
48
|
-
resolveDiagnosticsMap: () =>
|
|
49
|
-
sameLookupResult: () =>
|
|
35
|
+
isClassVariable: () => import_chunk_NB4IMZ6R.isClassVariable,
|
|
36
|
+
isLocal: () => import_chunk_NB4IMZ6R.isLocal,
|
|
37
|
+
isLookupCandidate: () => import_chunk_NB4IMZ6R.isLookupCandidate,
|
|
38
|
+
isStateNode: () => import_chunk_NB4IMZ6R.isStateNode,
|
|
39
|
+
lookupByFullName: () => import_chunk_NB4IMZ6R.lookupByFullName,
|
|
40
|
+
lookupNext: () => import_chunk_NB4IMZ6R.lookupNext,
|
|
41
|
+
lookupResultContains: () => import_chunk_NB4IMZ6R.lookupResultContains,
|
|
42
|
+
lookupWithType: () => import_chunk_NB4IMZ6R.lookupWithType,
|
|
43
|
+
makeToyboxLink: () => import_chunk_NB4IMZ6R.makeToyboxLink,
|
|
44
|
+
mapVarDeclsByType: () => import_chunk_NB4IMZ6R.mapVarDeclsByType,
|
|
45
|
+
markInvokeClassMethod: () => import_chunk_NB4IMZ6R.markInvokeClassMethod,
|
|
46
|
+
parseSdkVersion: () => import_chunk_NB4IMZ6R.parseSdkVersion,
|
|
47
|
+
resolveDiagnostics: () => import_chunk_NB4IMZ6R.resolveDiagnostics,
|
|
48
|
+
resolveDiagnosticsMap: () => import_chunk_NB4IMZ6R.resolveDiagnosticsMap,
|
|
49
|
+
sameLookupResult: () => import_chunk_NB4IMZ6R.sameLookupResult,
|
|
50
50
|
traverseAst: () => import_chunk_MBTLUWXR.traverseAst,
|
|
51
|
-
variableDeclarationName: () =>
|
|
52
|
-
visitReferences: () =>
|
|
53
|
-
visit_resources: () =>
|
|
54
|
-
visitorNode: () =>
|
|
51
|
+
variableDeclarationName: () => import_chunk_NB4IMZ6R.variableDeclarationName,
|
|
52
|
+
visitReferences: () => import_chunk_NB4IMZ6R.visitReferences,
|
|
53
|
+
visit_resources: () => import_chunk_NB4IMZ6R.visit_resources,
|
|
54
|
+
visitorNode: () => import_chunk_NB4IMZ6R.visitorNode
|
|
55
55
|
});
|
|
56
56
|
module.exports = __toCommonJS(api_exports);
|
|
57
|
-
var
|
|
57
|
+
var import_chunk_NB4IMZ6R = require("./chunk-NB4IMZ6R.cjs");
|
|
58
58
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
59
59
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
60
60
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
61
|
-
(0,
|
|
61
|
+
(0, import_chunk_NB4IMZ6R.init_api)();
|
|
62
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
63
|
0 && (module.exports = {
|
|
64
64
|
checkCompilerVersion,
|
package/build/cftinfo.cjs
CHANGED
|
@@ -38,26 +38,64 @@ var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
|
38
38
|
var import_node_assert = __toESM(require("node:assert"));
|
|
39
39
|
var fs = __toESM(require("node:fs/promises"));
|
|
40
40
|
var path = __toESM(require("node:path"));
|
|
41
|
+
var zlib = __toESM(require("node:zlib"));
|
|
41
42
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
42
|
-
function getCFTFontInfoFromBuffer(name, data) {
|
|
43
|
+
async function getCFTFontInfoFromBuffer(name, data, options) {
|
|
43
44
|
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
45
|
+
const glyphFlags = view.getUint8(3);
|
|
44
46
|
const cmapOffset = view.getUint32(8);
|
|
45
47
|
const glyphInfoOffset = view.getUint32(12);
|
|
48
|
+
const glyphDataOffset = view.getUint32(16);
|
|
46
49
|
const height = view.getUint16(22);
|
|
47
50
|
const ascent = view.getUint16(24);
|
|
48
51
|
const internalLeading = view.getUint16(26);
|
|
52
|
+
const { chars, charInfoAsArray } = typeof options === "string" ? { chars: options } : options ?? {};
|
|
53
|
+
const charFilter = chars != null ? new Set(chars.split("").map((ch) => ch.charCodeAt(0))) : null;
|
|
49
54
|
const cmapNGroups = view.getUint32(cmapOffset + 12);
|
|
50
55
|
const charInfo = [];
|
|
56
|
+
const maybeCompressed = view.getUint16(0) === 40;
|
|
57
|
+
const align = maybeCompressed ? view.getUint8(36) : 1;
|
|
58
|
+
const glyphData = await getGlyphData(view, glyphDataOffset, maybeCompressed);
|
|
51
59
|
for (let i = 0, offset = cmapOffset + 16; i < cmapNGroups; i++) {
|
|
52
60
|
const startChar = view.getUint32(offset + 0);
|
|
53
61
|
const endChar = view.getUint32(offset + 4);
|
|
54
62
|
const startGlyph = view.getUint32(offset + 8);
|
|
55
63
|
offset += 12;
|
|
56
64
|
for (let code = startChar, g = startGlyph; code <= endChar; code++, g++) {
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
if (charFilter && !charFilter.has(code)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const word = view.getUint32(glyphInfoOffset + g * 4);
|
|
69
|
+
const glyphOffset = (word >> 16 & 65535) + ((word & 65280) << 8);
|
|
70
|
+
const width = word & 255;
|
|
71
|
+
const [glyphAscent, glyphDescent] = getGlyphAscentDescent(
|
|
72
|
+
glyphData,
|
|
73
|
+
glyphOffset,
|
|
74
|
+
width,
|
|
75
|
+
height,
|
|
76
|
+
ascent,
|
|
77
|
+
align,
|
|
78
|
+
glyphFlags
|
|
79
|
+
);
|
|
80
|
+
charInfo.push({
|
|
81
|
+
code,
|
|
82
|
+
char: String.fromCharCode(code),
|
|
83
|
+
width,
|
|
84
|
+
glyphAscent,
|
|
85
|
+
glyphDescent
|
|
86
|
+
});
|
|
59
87
|
}
|
|
60
88
|
}
|
|
89
|
+
if (charInfoAsArray && charInfo.length) {
|
|
90
|
+
return {
|
|
91
|
+
name,
|
|
92
|
+
height,
|
|
93
|
+
ascent,
|
|
94
|
+
internalLeading,
|
|
95
|
+
charInfo: charInfo.map((info) => Object.values(info)),
|
|
96
|
+
charInfoNames: Object.keys(charInfo[0])
|
|
97
|
+
};
|
|
98
|
+
}
|
|
61
99
|
return {
|
|
62
100
|
name,
|
|
63
101
|
height,
|
|
@@ -66,10 +104,10 @@ function getCFTFontInfoFromBuffer(name, data) {
|
|
|
66
104
|
charInfo
|
|
67
105
|
};
|
|
68
106
|
}
|
|
69
|
-
function getCFTFontInfo(filename) {
|
|
107
|
+
function getCFTFontInfo(filename, chars) {
|
|
70
108
|
return fs.readFile(filename).then((data) => {
|
|
71
109
|
const name = path.basename(filename, ".cft");
|
|
72
|
-
return getCFTFontInfoFromBuffer(name, data);
|
|
110
|
+
return getCFTFontInfoFromBuffer(name, data, chars);
|
|
73
111
|
});
|
|
74
112
|
}
|
|
75
113
|
function getDeviceFontInfo(dirname) {
|
|
@@ -104,6 +142,144 @@ function getDeviceFontInfo(dirname) {
|
|
|
104
142
|
return { device: path.basename(dirname), fontSets, langMap };
|
|
105
143
|
});
|
|
106
144
|
}
|
|
145
|
+
async function getGlyphData(view, offset, maybeCompressed) {
|
|
146
|
+
if (maybeCompressed) {
|
|
147
|
+
const firstWord = view.getUint32(offset);
|
|
148
|
+
if (firstWord === 3439329293) {
|
|
149
|
+
offset += 4;
|
|
150
|
+
} else if (firstWord === 3489660941) {
|
|
151
|
+
offset += 4;
|
|
152
|
+
maybeCompressed = false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (maybeCompressed) {
|
|
156
|
+
const result = [];
|
|
157
|
+
const _length = view.getUint32(offset);
|
|
158
|
+
offset += 4;
|
|
159
|
+
const inflate = zlib.createInflate();
|
|
160
|
+
inflate.on("data", (chunk) => result.push(chunk));
|
|
161
|
+
const promise = new Promise((resolve2, reject) => {
|
|
162
|
+
inflate.on("end", () => resolve2(Buffer.concat(result)));
|
|
163
|
+
inflate.on("error", (e) => reject(e));
|
|
164
|
+
});
|
|
165
|
+
inflate.write(
|
|
166
|
+
Buffer.from(
|
|
167
|
+
view.buffer,
|
|
168
|
+
view.byteOffset + offset,
|
|
169
|
+
view.byteLength - offset
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
inflate.end();
|
|
173
|
+
const buffer = await promise;
|
|
174
|
+
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
175
|
+
}
|
|
176
|
+
return new DataView(
|
|
177
|
+
view.buffer,
|
|
178
|
+
view.byteOffset + offset,
|
|
179
|
+
view.byteLength - offset
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
function getGlyphAscentDescent(glyphData, glyphOffset, width, height, ascent, align, flags) {
|
|
183
|
+
const rle = (flags & 2) !== 0;
|
|
184
|
+
if (rle) {
|
|
185
|
+
glyphOffset &= 8388607;
|
|
186
|
+
}
|
|
187
|
+
const pixelsPerByte = flags & 4 ? 4 : 8;
|
|
188
|
+
const bytesToCount = Math.ceil(width / pixelsPerByte);
|
|
189
|
+
const byteWidth = Math.ceil(bytesToCount / align) * align;
|
|
190
|
+
const size = byteWidth * height;
|
|
191
|
+
const glyph = rle ? rleDecode(glyphData, glyphOffset, size) : new DataView(glyphData.buffer, glyphData.byteOffset + glyphOffset, size);
|
|
192
|
+
const glyphAscent = (() => {
|
|
193
|
+
let row = 0;
|
|
194
|
+
do {
|
|
195
|
+
const offset = row * byteWidth;
|
|
196
|
+
for (let i = 0; i < bytesToCount; i++) {
|
|
197
|
+
if (glyph.getUint8(offset + i))
|
|
198
|
+
return ascent - row;
|
|
199
|
+
}
|
|
200
|
+
} while (++row < ascent);
|
|
201
|
+
return 0;
|
|
202
|
+
})();
|
|
203
|
+
const glyphDescent = (() => {
|
|
204
|
+
let row = height;
|
|
205
|
+
while (row-- > ascent) {
|
|
206
|
+
const offset = row * byteWidth;
|
|
207
|
+
for (let i = 0; i < bytesToCount; i++) {
|
|
208
|
+
if (glyph.getUint8(offset + i))
|
|
209
|
+
return row - ascent;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return 0;
|
|
213
|
+
})();
|
|
214
|
+
return [glyphAscent, glyphDescent];
|
|
215
|
+
}
|
|
216
|
+
function rleDecode(encoded, offset, size) {
|
|
217
|
+
let bitsLeft = 0;
|
|
218
|
+
let val = 0;
|
|
219
|
+
const getBits = (n) => {
|
|
220
|
+
if (bitsLeft >= n) {
|
|
221
|
+
const result = val & (1 << n) - 1;
|
|
222
|
+
bitsLeft -= n;
|
|
223
|
+
val >>>= n;
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
if (bitsLeft === 0) {
|
|
227
|
+
val = encoded.getUint8(offset);
|
|
228
|
+
offset += 1;
|
|
229
|
+
bitsLeft = 8;
|
|
230
|
+
return getBits(n);
|
|
231
|
+
}
|
|
232
|
+
const bl = bitsLeft;
|
|
233
|
+
return getBits(bl) + (getBits(n - bl) << bl);
|
|
234
|
+
};
|
|
235
|
+
let runBits = 1;
|
|
236
|
+
while (getBits(1) === 0) {
|
|
237
|
+
runBits++;
|
|
238
|
+
}
|
|
239
|
+
const chunkSize = getBits(5) + 1;
|
|
240
|
+
const escape = getBits(chunkSize);
|
|
241
|
+
const output = new DataView(new ArrayBuffer(size + 3 & ~3));
|
|
242
|
+
let outOffset = 0;
|
|
243
|
+
let outBitOff = 0;
|
|
244
|
+
let outVal = 0;
|
|
245
|
+
const putBits = (value) => {
|
|
246
|
+
outVal |= value << outBitOff;
|
|
247
|
+
outBitOff += chunkSize;
|
|
248
|
+
if (outBitOff >= 32) {
|
|
249
|
+
output.setUint32(outOffset, outVal, true);
|
|
250
|
+
outOffset += 4;
|
|
251
|
+
outBitOff -= 32;
|
|
252
|
+
outVal = 0;
|
|
253
|
+
if (outBitOff !== 0) {
|
|
254
|
+
outVal = value >>> chunkSize - outBitOff;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
let prev = -1;
|
|
259
|
+
const getChunk = () => {
|
|
260
|
+
const val2 = getBits(chunkSize);
|
|
261
|
+
if (val2 !== escape) {
|
|
262
|
+
prev = val2;
|
|
263
|
+
return [val2, 1];
|
|
264
|
+
}
|
|
265
|
+
const run = getBits(runBits);
|
|
266
|
+
if (run === 0) {
|
|
267
|
+
prev = val2;
|
|
268
|
+
return [val2, 1];
|
|
269
|
+
}
|
|
270
|
+
return [prev, run + 1];
|
|
271
|
+
};
|
|
272
|
+
while (outOffset + (outBitOff >>> 3) < size) {
|
|
273
|
+
let [val2, run] = getChunk();
|
|
274
|
+
while (run--) {
|
|
275
|
+
putBits(val2);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (outOffset < size) {
|
|
279
|
+
output.setUint32(outOffset, outVal, true);
|
|
280
|
+
}
|
|
281
|
+
return output;
|
|
282
|
+
}
|
|
107
283
|
// Annotate the CommonJS export names for ESM import in node:
|
|
108
284
|
0 && (module.exports = {
|
|
109
285
|
getCFTFontInfo,
|
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_NB4IMZ6R_exports = {};
|
|
30
|
+
__export(chunk_NB4IMZ6R_exports, {
|
|
31
31
|
EnumTagsConst: () => EnumTagsConst,
|
|
32
32
|
LastTypeTag: () => LastTypeTag,
|
|
33
33
|
ObjectLikeTagsConst: () => ObjectLikeTagsConst,
|
|
@@ -133,7 +133,7 @@ __export(chunk_LZIGQANB_exports, {
|
|
|
133
133
|
visitorNode: () => visitorNode,
|
|
134
134
|
xml_util_exports: () => xml_util_exports
|
|
135
135
|
});
|
|
136
|
-
module.exports = __toCommonJS(
|
|
136
|
+
module.exports = __toCommonJS(chunk_NB4IMZ6R_exports);
|
|
137
137
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
138
138
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
139
139
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
@@ -28344,7 +28344,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28344
28344
|
const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
|
|
28345
28345
|
Object.values(fnMap).map((v) => v.output)
|
|
28346
28346
|
);
|
|
28347
|
-
if (source_time < opt_time &&
|
|
28347
|
+
if (source_time < opt_time && 1708360159116 < opt_time) {
|
|
28348
28348
|
return {
|
|
28349
28349
|
hasTests,
|
|
28350
28350
|
diagnostics: prevDiagnostics,
|
|
@@ -28383,7 +28383,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28383
28383
|
hasTests: hasTests2,
|
|
28384
28384
|
diagnostics,
|
|
28385
28385
|
sdkVersion,
|
|
28386
|
-
optimizerVersion: "1.1.
|
|
28386
|
+
optimizerVersion: "1.1.48",
|
|
28387
28387
|
...Object.fromEntries(
|
|
28388
28388
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
28389
28389
|
)
|
package/build/optimizer.cjs
CHANGED
|
@@ -18,28 +18,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var optimizer_exports = {};
|
|
20
20
|
__export(optimizer_exports, {
|
|
21
|
-
StateNodeAttributes: () =>
|
|
22
|
-
buildOptimizedProject: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_NB4IMZ6R.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_NB4IMZ6R.buildOptimizedProject,
|
|
23
23
|
copyRecursiveAsNeeded: () => import_chunk_SG7ODKRM.copyRecursiveAsNeeded,
|
|
24
|
-
defaultConfig: () =>
|
|
25
|
-
display: () =>
|
|
26
|
-
generateOneConfig: () =>
|
|
27
|
-
generateOptimizedProject: () =>
|
|
28
|
-
getConfig: () =>
|
|
29
|
-
getProjectAnalysis: () =>
|
|
30
|
-
get_jungle: () =>
|
|
31
|
-
isErrorWithLocation: () =>
|
|
32
|
-
launchSimulator: () =>
|
|
33
|
-
manifestProducts: () =>
|
|
34
|
-
mctree: () =>
|
|
35
|
-
simulateProgram: () =>
|
|
24
|
+
defaultConfig: () => import_chunk_NB4IMZ6R.defaultConfig,
|
|
25
|
+
display: () => import_chunk_NB4IMZ6R.display,
|
|
26
|
+
generateOneConfig: () => import_chunk_NB4IMZ6R.generateOneConfig,
|
|
27
|
+
generateOptimizedProject: () => import_chunk_NB4IMZ6R.generateOptimizedProject,
|
|
28
|
+
getConfig: () => import_chunk_NB4IMZ6R.getConfig,
|
|
29
|
+
getProjectAnalysis: () => import_chunk_NB4IMZ6R.getProjectAnalysis,
|
|
30
|
+
get_jungle: () => import_chunk_NB4IMZ6R.get_jungle,
|
|
31
|
+
isErrorWithLocation: () => import_chunk_NB4IMZ6R.isErrorWithLocation,
|
|
32
|
+
launchSimulator: () => import_chunk_NB4IMZ6R.launchSimulator,
|
|
33
|
+
manifestProducts: () => import_chunk_NB4IMZ6R.manifestProducts,
|
|
34
|
+
mctree: () => import_chunk_NB4IMZ6R.mctree,
|
|
35
|
+
simulateProgram: () => import_chunk_NB4IMZ6R.simulateProgram
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(optimizer_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_chunk_NB4IMZ6R = require("./chunk-NB4IMZ6R.cjs");
|
|
39
39
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
40
40
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
41
41
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
42
|
-
(0,
|
|
42
|
+
(0, import_chunk_NB4IMZ6R.init_optimizer)();
|
|
43
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
44
|
0 && (module.exports = {
|
|
45
45
|
StateNodeAttributes,
|
package/build/sdk-util.cjs
CHANGED
|
@@ -18,25 +18,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var sdk_util_exports = {};
|
|
20
20
|
__export(sdk_util_exports, {
|
|
21
|
-
SectionKinds: () =>
|
|
22
|
-
appSupport: () =>
|
|
23
|
-
connectiq: () =>
|
|
24
|
-
getDeviceInfo: () =>
|
|
25
|
-
getFunctionDocumentation: () =>
|
|
26
|
-
getLanguages: () =>
|
|
27
|
-
getSdkPath: () =>
|
|
28
|
-
isWin: () =>
|
|
29
|
-
optimizeProgram: () =>
|
|
30
|
-
readPrg: () =>
|
|
31
|
-
readPrgWithOffsets: () =>
|
|
32
|
-
xmlUtil: () =>
|
|
21
|
+
SectionKinds: () => import_chunk_NB4IMZ6R.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_NB4IMZ6R.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_NB4IMZ6R.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_NB4IMZ6R.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_NB4IMZ6R.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_NB4IMZ6R.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_NB4IMZ6R.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_NB4IMZ6R.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_NB4IMZ6R.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_NB4IMZ6R.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_NB4IMZ6R.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_NB4IMZ6R.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_NB4IMZ6R = require("./chunk-NB4IMZ6R.cjs");
|
|
36
36
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
37
37
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
38
38
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
39
|
-
(0,
|
|
39
|
+
(0, import_chunk_NB4IMZ6R.init_sdk_util)();
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
SectionKinds,
|
package/build/src/cftinfo.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
export
|
|
2
|
+
export type FontInfoOptions = {
|
|
3
|
+
chars?: string;
|
|
4
|
+
charInfoAsArray?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function getCFTFontInfoFromBuffer(name: string, data: Buffer, options?: FontInfoOptions | string): Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
height: number;
|
|
9
|
+
ascent: number;
|
|
10
|
+
internalLeading: number;
|
|
11
|
+
charInfo: (string | number)[][];
|
|
12
|
+
charInfoNames: string[];
|
|
13
|
+
} | {
|
|
3
14
|
name: string;
|
|
4
15
|
height: number;
|
|
5
16
|
ascent: number;
|
|
@@ -8,9 +19,19 @@ export declare function getCFTFontInfoFromBuffer(name: string, data: Buffer): {
|
|
|
8
19
|
code: number;
|
|
9
20
|
char: string;
|
|
10
21
|
width: number;
|
|
22
|
+
glyphAscent: number;
|
|
23
|
+
glyphDescent: number;
|
|
11
24
|
}[];
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
charInfoNames?: undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export declare function getCFTFontInfo(filename: string, chars?: string): Promise<{
|
|
28
|
+
name: string;
|
|
29
|
+
height: number;
|
|
30
|
+
ascent: number;
|
|
31
|
+
internalLeading: number;
|
|
32
|
+
charInfo: (string | number)[][];
|
|
33
|
+
charInfoNames: string[];
|
|
34
|
+
} | {
|
|
14
35
|
name: string;
|
|
15
36
|
height: number;
|
|
16
37
|
ascent: number;
|
|
@@ -19,7 +40,10 @@ export declare function getCFTFontInfo(filename: string): Promise<{
|
|
|
19
40
|
code: number;
|
|
20
41
|
char: string;
|
|
21
42
|
width: number;
|
|
43
|
+
glyphAscent: number;
|
|
44
|
+
glyphDescent: number;
|
|
22
45
|
}[];
|
|
46
|
+
charInfoNames?: undefined;
|
|
23
47
|
}>;
|
|
24
48
|
export declare function getDeviceFontInfo(dirname: string): Promise<{
|
|
25
49
|
device: string;
|
package/build/worker-thread.cjs
CHANGED
|
@@ -21,17 +21,17 @@ __export(worker_thread_exports, {
|
|
|
21
21
|
default: () => worker_thread_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(worker_thread_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_chunk_NB4IMZ6R = require("./chunk-NB4IMZ6R.cjs");
|
|
25
25
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
26
26
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
27
27
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
28
28
|
var import_node_worker_threads = require("node:worker_threads");
|
|
29
29
|
var require_worker_thread = (0, import_chunk_ABYVSU2C.__commonJS)({
|
|
30
30
|
"src/worker-thread.ts"() {
|
|
31
|
-
(0,
|
|
31
|
+
(0, import_chunk_NB4IMZ6R.init_worker_task)();
|
|
32
32
|
if (import_node_worker_threads.parentPort) {
|
|
33
33
|
import_node_worker_threads.parentPort.on("message", async (task) => {
|
|
34
|
-
return import_node_worker_threads.parentPort.postMessage(await (0,
|
|
34
|
+
return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_NB4IMZ6R.performTask)(task));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}
|
package/package.json
CHANGED