@markw65/monkeyc-optimizer 1.1.86 → 1.1.88
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 +16 -0
- package/bin/cft-font-info.js +10 -3
- package/build/api.cjs +39 -39
- package/build/{chunk-BPCBFFSW.cjs → chunk-ROZUBUPR.cjs} +140 -65
- package/build/optimizer.cjs +18 -18
- package/build/sdk-util.cjs +14 -14
- package/build/src/readprg/signer.d.ts +2 -2
- package/build/src/sdk-util.d.ts +10 -0
- package/build/worker-thread.cjs +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the "monkeyc-optimizer" package will be documented in this file.
|
|
4
4
|
|
|
5
|
+
### 1.1.88
|
|
6
|
+
|
|
7
|
+
- Fix output of cft-font-info
|
|
8
|
+
- When I refactored the code to avoid holding everything in memory at once, I inadvertently changed the format. This restores the original format, and adds a flag to enable the incorrect format, just in case someone's relying on it.
|
|
9
|
+
- Update to [@markw65/prettier-plugin-monkeyc@1.0.61](https://github.com/markw65/prettier-plugin-monkeyc/blob/main/CHANGELOG.md#1061)
|
|
10
|
+
|
|
11
|
+
- Allow semi-colons after expression-statements, and uncontrolled block-statements to match Garmin's parser.
|
|
12
|
+
|
|
13
|
+
- Fix a crash when no valid products are found in the manifest (Fixes [prettier-extension-monkeyc#19](https://github.com/markw65/prettier-extension-monkeyc/issues/19))
|
|
14
|
+
- Fix various issues with tests so that they pass with 7.4.3, and on windows
|
|
15
|
+
- Sdk 7.4.3 started signing `.iq` files with SHA256 in addition to SHA1. For now, the store still accepts files that are only signed with SHA1, but this adds the SHA256 for future proofing.
|
|
16
|
+
|
|
17
|
+
### 1.1.87
|
|
18
|
+
|
|
19
|
+
- Update post build optimizer to work with sdk-7.4.3. The manifest file was changed a little with this release, so I had to update the optimizer to match.
|
|
20
|
+
|
|
5
21
|
### 1.1.86
|
|
6
22
|
|
|
7
23
|
- Leaving stashed type lists on ArrayExpression and ObjectExpression could confuse the prettier printer, and result in errors when outputing the optimized files. Remove all of them after optimization is done.
|
package/bin/cft-font-info.js
CHANGED
|
@@ -9,6 +9,7 @@ const fonts = new Set();
|
|
|
9
9
|
const otherArgs = [];
|
|
10
10
|
let charsWanted;
|
|
11
11
|
let charInfoAsArray;
|
|
12
|
+
let flatFonts;
|
|
12
13
|
|
|
13
14
|
function error(e) {
|
|
14
15
|
throw new Error(e);
|
|
@@ -38,6 +39,9 @@ const prev = process.argv.slice(2).reduce((key, value) => {
|
|
|
38
39
|
case "char-info-as-array":
|
|
39
40
|
charInfoAsArray = !value || /^(true|1)$/i.test(value);
|
|
40
41
|
break;
|
|
42
|
+
case "flat-fonts":
|
|
43
|
+
flatFonts = !value || /^(true|1)$/i.test(value);
|
|
44
|
+
break;
|
|
41
45
|
default:
|
|
42
46
|
error(`Unknown argument: --${key}`);
|
|
43
47
|
}
|
|
@@ -76,7 +80,8 @@ Promise.all(
|
|
|
76
80
|
);
|
|
77
81
|
})
|
|
78
82
|
).then((results) => {
|
|
79
|
-
console.log("{
|
|
83
|
+
console.log(`{${flatFonts ? "" : `\n"fonts":{`}`);
|
|
84
|
+
let started = false;
|
|
80
85
|
let last = -1;
|
|
81
86
|
let active = [];
|
|
82
87
|
const fontArray = Array.from(fonts).sort();
|
|
@@ -85,14 +90,15 @@ Promise.all(
|
|
|
85
90
|
fontArray[i] &&
|
|
86
91
|
cft
|
|
87
92
|
.getCFTFontInfo(fontArray[i], { chars: charsWanted, charInfoAsArray })
|
|
88
|
-
.then(({ name, ...rest }) => `"${name}":${JSON.stringify(rest)}
|
|
93
|
+
.then(({ name, ...rest }) => `"${name}":${JSON.stringify(rest)}`)
|
|
89
94
|
.catch(() => null)
|
|
90
95
|
.then((line) => {
|
|
91
96
|
active[i] = line;
|
|
92
97
|
while (active[last + 1] !== undefined) {
|
|
93
98
|
const a = active[++last];
|
|
94
99
|
if (a != null) {
|
|
95
|
-
console.log(a);
|
|
100
|
+
console.log(started ? "," : "", a);
|
|
101
|
+
started = true;
|
|
96
102
|
}
|
|
97
103
|
delete active[last];
|
|
98
104
|
}
|
|
@@ -101,6 +107,7 @@ Promise.all(
|
|
|
101
107
|
.then(() => active.forEach((line) => line && console.log(line)))
|
|
102
108
|
.then(() =>
|
|
103
109
|
console.log(
|
|
110
|
+
flatFonts ? "," : "},\n",
|
|
104
111
|
`"devices":${JSON.stringify(
|
|
105
112
|
Object.fromEntries(
|
|
106
113
|
results
|
package/build/api.cjs
CHANGED
|
@@ -18,52 +18,52 @@ 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
|
-
clearDiagnostics: () =>
|
|
23
|
-
collectNamespaces: () =>
|
|
24
|
-
createDocumentationMap: () =>
|
|
25
|
-
declKey: () =>
|
|
26
|
-
diagnostic: () =>
|
|
27
|
-
diagnosticHelper: () =>
|
|
28
|
-
findNamesInScope: () =>
|
|
29
|
-
findUsingForNode: () =>
|
|
30
|
-
formatAst: () =>
|
|
31
|
-
formatAstLongLines: () =>
|
|
32
|
-
formatScopedName: () =>
|
|
33
|
-
getApiFunctionInfo: () =>
|
|
34
|
-
getApiMapping: () =>
|
|
35
|
-
getSuperClasses: () =>
|
|
36
|
-
handleImportUsing: () =>
|
|
21
|
+
checkCompilerVersion: () => import_chunk_ROZUBUPR.checkCompilerVersion,
|
|
22
|
+
clearDiagnostics: () => import_chunk_ROZUBUPR.clearDiagnostics,
|
|
23
|
+
collectNamespaces: () => import_chunk_ROZUBUPR.collectNamespaces,
|
|
24
|
+
createDocumentationMap: () => import_chunk_ROZUBUPR.createDocumentationMap,
|
|
25
|
+
declKey: () => import_chunk_ROZUBUPR.declKey,
|
|
26
|
+
diagnostic: () => import_chunk_ROZUBUPR.diagnostic,
|
|
27
|
+
diagnosticHelper: () => import_chunk_ROZUBUPR.diagnosticHelper,
|
|
28
|
+
findNamesInScope: () => import_chunk_ROZUBUPR.findNamesInScope,
|
|
29
|
+
findUsingForNode: () => import_chunk_ROZUBUPR.findUsingForNode,
|
|
30
|
+
formatAst: () => import_chunk_ROZUBUPR.formatAst,
|
|
31
|
+
formatAstLongLines: () => import_chunk_ROZUBUPR.formatAstLongLines,
|
|
32
|
+
formatScopedName: () => import_chunk_ROZUBUPR.formatScopedName,
|
|
33
|
+
getApiFunctionInfo: () => import_chunk_ROZUBUPR.getApiFunctionInfo,
|
|
34
|
+
getApiMapping: () => import_chunk_ROZUBUPR.getApiMapping,
|
|
35
|
+
getSuperClasses: () => import_chunk_ROZUBUPR.getSuperClasses,
|
|
36
|
+
handleImportUsing: () => import_chunk_ROZUBUPR.handleImportUsing,
|
|
37
37
|
hasProperty: () => import_chunk_JDC43A3I.hasProperty,
|
|
38
|
-
isClassVariable: () =>
|
|
39
|
-
isLocal: () =>
|
|
40
|
-
isLookupCandidate: () =>
|
|
41
|
-
isStateNode: () =>
|
|
42
|
-
lookupByFullName: () =>
|
|
43
|
-
lookupNext: () =>
|
|
44
|
-
lookupResultContains: () =>
|
|
45
|
-
lookupWithType: () =>
|
|
46
|
-
makeToyboxLink: () =>
|
|
47
|
-
mapVarDeclsByType: () =>
|
|
48
|
-
markInvokeClassMethod: () =>
|
|
49
|
-
parseSdkVersion: () =>
|
|
50
|
-
popRootNode: () =>
|
|
51
|
-
pushRootNode: () =>
|
|
52
|
-
resolveDiagnostics: () =>
|
|
53
|
-
resolveDiagnosticsMap: () =>
|
|
54
|
-
sameLookupResult: () =>
|
|
38
|
+
isClassVariable: () => import_chunk_ROZUBUPR.isClassVariable,
|
|
39
|
+
isLocal: () => import_chunk_ROZUBUPR.isLocal,
|
|
40
|
+
isLookupCandidate: () => import_chunk_ROZUBUPR.isLookupCandidate,
|
|
41
|
+
isStateNode: () => import_chunk_ROZUBUPR.isStateNode,
|
|
42
|
+
lookupByFullName: () => import_chunk_ROZUBUPR.lookupByFullName,
|
|
43
|
+
lookupNext: () => import_chunk_ROZUBUPR.lookupNext,
|
|
44
|
+
lookupResultContains: () => import_chunk_ROZUBUPR.lookupResultContains,
|
|
45
|
+
lookupWithType: () => import_chunk_ROZUBUPR.lookupWithType,
|
|
46
|
+
makeToyboxLink: () => import_chunk_ROZUBUPR.makeToyboxLink,
|
|
47
|
+
mapVarDeclsByType: () => import_chunk_ROZUBUPR.mapVarDeclsByType,
|
|
48
|
+
markInvokeClassMethod: () => import_chunk_ROZUBUPR.markInvokeClassMethod,
|
|
49
|
+
parseSdkVersion: () => import_chunk_ROZUBUPR.parseSdkVersion,
|
|
50
|
+
popRootNode: () => import_chunk_ROZUBUPR.popRootNode,
|
|
51
|
+
pushRootNode: () => import_chunk_ROZUBUPR.pushRootNode,
|
|
52
|
+
resolveDiagnostics: () => import_chunk_ROZUBUPR.resolveDiagnostics,
|
|
53
|
+
resolveDiagnosticsMap: () => import_chunk_ROZUBUPR.resolveDiagnosticsMap,
|
|
54
|
+
sameLookupResult: () => import_chunk_ROZUBUPR.sameLookupResult,
|
|
55
55
|
traverseAst: () => import_chunk_JDC43A3I.traverseAst,
|
|
56
|
-
variableDeclarationName: () =>
|
|
57
|
-
visitReferences: () =>
|
|
58
|
-
visit_resources: () =>
|
|
59
|
-
visitorNode: () =>
|
|
56
|
+
variableDeclarationName: () => import_chunk_ROZUBUPR.variableDeclarationName,
|
|
57
|
+
visitReferences: () => import_chunk_ROZUBUPR.visitReferences,
|
|
58
|
+
visit_resources: () => import_chunk_ROZUBUPR.visit_resources,
|
|
59
|
+
visitorNode: () => import_chunk_ROZUBUPR.visitorNode
|
|
60
60
|
});
|
|
61
61
|
module.exports = __toCommonJS(api_exports);
|
|
62
|
-
var
|
|
62
|
+
var import_chunk_ROZUBUPR = require("./chunk-ROZUBUPR.cjs");
|
|
63
63
|
var import_chunk_X7QCZR3F = require("./chunk-X7QCZR3F.cjs");
|
|
64
64
|
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
|
|
65
65
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
66
|
-
(0,
|
|
66
|
+
(0, import_chunk_ROZUBUPR.init_api)();
|
|
67
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
68
|
0 && (module.exports = {
|
|
69
69
|
checkCompilerVersion,
|
|
@@ -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_ROZUBUPR_exports = {};
|
|
30
|
+
__export(chunk_ROZUBUPR_exports, {
|
|
31
31
|
EnumTagsConst: () => EnumTagsConst,
|
|
32
32
|
LastTypeTag: () => LastTypeTag,
|
|
33
33
|
ObjectLikeTagsConst: () => ObjectLikeTagsConst,
|
|
@@ -140,7 +140,7 @@ __export(chunk_BPCBFFSW_exports, {
|
|
|
140
140
|
visitorNode: () => visitorNode,
|
|
141
141
|
xml_util_exports: () => xml_util_exports
|
|
142
142
|
});
|
|
143
|
-
module.exports = __toCommonJS(
|
|
143
|
+
module.exports = __toCommonJS(chunk_ROZUBUPR_exports);
|
|
144
144
|
var import_chunk_X7QCZR3F = require("./chunk-X7QCZR3F.cjs");
|
|
145
145
|
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
|
|
146
146
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
@@ -26075,6 +26075,10 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
26075
26075
|
function getPrgSignature(context) {
|
|
26076
26076
|
if (!context.key)
|
|
26077
26077
|
return;
|
|
26078
|
+
const withSha256 = context.sections[
|
|
26079
|
+
-507453934
|
|
26080
|
+
/* SIGNATURE */
|
|
26081
|
+
]?.length === 1036 + 512;
|
|
26078
26082
|
delete context.sections[
|
|
26079
26083
|
-507453934
|
|
26080
26084
|
/* SIGNATURE */
|
|
@@ -26086,6 +26090,9 @@ function getPrgSignature(context) {
|
|
|
26086
26090
|
const signature = signatureFromContext(context);
|
|
26087
26091
|
if (!signature)
|
|
26088
26092
|
return;
|
|
26093
|
+
const signature2 = withSha256 ? signatureFromContext(context, "SHA256") : null;
|
|
26094
|
+
if (withSha256 && !signature2)
|
|
26095
|
+
return;
|
|
26089
26096
|
const keyInfo = context.key.export({ format: "jwk" });
|
|
26090
26097
|
(0, import_node_assert16.default)(keyInfo.n && keyInfo.e);
|
|
26091
26098
|
const modulusBuf = Buffer.from(keyInfo.n, "base64");
|
|
@@ -26100,23 +26107,31 @@ function getPrgSignature(context) {
|
|
|
26100
26107
|
modulusBuf.byteLength - delta
|
|
26101
26108
|
);
|
|
26102
26109
|
(0, import_node_assert16.default)(modulus.byteLength === 512 && signature.length === 512);
|
|
26103
|
-
|
|
26110
|
+
(0, import_node_assert16.default)(!signature2 || signature2.length === 512);
|
|
26111
|
+
const sectionLength = signature.length + modulus.byteLength + 4 + (signature2?.length ?? 0);
|
|
26104
26112
|
const buffer = new DataView(new ArrayBuffer(sectionLength + 8));
|
|
26113
|
+
const asUint = new Uint8Array(
|
|
26114
|
+
buffer.buffer,
|
|
26115
|
+
buffer.byteOffset,
|
|
26116
|
+
buffer.byteLength
|
|
26117
|
+
);
|
|
26105
26118
|
buffer.setInt32(
|
|
26106
26119
|
0,
|
|
26107
26120
|
-507453934
|
|
26108
26121
|
/* SIGNATURE */
|
|
26109
26122
|
);
|
|
26110
26123
|
buffer.setInt32(4, sectionLength);
|
|
26111
|
-
|
|
26112
|
-
|
|
26113
|
-
buffer.
|
|
26114
|
-
|
|
26115
|
-
|
|
26116
|
-
buffer.setInt32(
|
|
26117
|
-
|
|
26118
|
-
(
|
|
26119
|
-
|
|
26124
|
+
asUint.set(signature, 8);
|
|
26125
|
+
asUint.set(
|
|
26126
|
+
new Uint8Array(modulus.buffer, modulus.byteOffset, modulus.byteLength),
|
|
26127
|
+
520
|
|
26128
|
+
);
|
|
26129
|
+
buffer.setInt32(1032, publicExponent);
|
|
26130
|
+
if (signature2) {
|
|
26131
|
+
asUint.set(signature2, 1036);
|
|
26132
|
+
}
|
|
26133
|
+
const max = Math.max(
|
|
26134
|
+
...Object.values(context.sections).map((cur) => cur.offset + cur.length)
|
|
26120
26135
|
);
|
|
26121
26136
|
context.sections[
|
|
26122
26137
|
-507453934
|
|
@@ -26126,7 +26141,7 @@ function getPrgSignature(context) {
|
|
|
26126
26141
|
length: sectionLength,
|
|
26127
26142
|
view: new DataView(buffer.buffer, 8, sectionLength)
|
|
26128
26143
|
};
|
|
26129
|
-
return signature;
|
|
26144
|
+
return signature2 ? Buffer.concat([signature, signature2]) : signature;
|
|
26130
26145
|
}
|
|
26131
26146
|
function getDevKey(file) {
|
|
26132
26147
|
return fs3.readFile(file).then(
|
|
@@ -26137,10 +26152,10 @@ function getDevKey(file) {
|
|
|
26137
26152
|
})
|
|
26138
26153
|
);
|
|
26139
26154
|
}
|
|
26140
|
-
function signatureFromContext(context) {
|
|
26155
|
+
function signatureFromContext(context, method = "SHA1") {
|
|
26141
26156
|
if (!context.key)
|
|
26142
26157
|
return null;
|
|
26143
|
-
const signer = crypto.createSign(
|
|
26158
|
+
const signer = crypto.createSign(method);
|
|
26144
26159
|
Object.entries(context.sections).filter(
|
|
26145
26160
|
([section]) => Number(section) !== -507453934 && Number(section) !== 20833
|
|
26146
26161
|
/* STORE_SIG */
|
|
@@ -26156,8 +26171,8 @@ function signatureFromContext(context) {
|
|
|
26156
26171
|
signer.end();
|
|
26157
26172
|
return signer.sign(context.key);
|
|
26158
26173
|
}
|
|
26159
|
-
function signView(key, view) {
|
|
26160
|
-
const signer = crypto.createSign(
|
|
26174
|
+
function signView(key, view, method = "SHA1") {
|
|
26175
|
+
const signer = crypto.createSign(method);
|
|
26161
26176
|
signer.update(view);
|
|
26162
26177
|
signer.end();
|
|
26163
26178
|
return signer.sign(key);
|
|
@@ -26568,50 +26583,64 @@ var require_common = (0, import_chunk_ABYVSU2C.__commonJS)({
|
|
|
26568
26583
|
createDebug.namespaces = namespaces;
|
|
26569
26584
|
createDebug.names = [];
|
|
26570
26585
|
createDebug.skips = [];
|
|
26571
|
-
|
|
26572
|
-
|
|
26573
|
-
|
|
26574
|
-
|
|
26575
|
-
|
|
26576
|
-
|
|
26586
|
+
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(" ", ",").split(",").filter(Boolean);
|
|
26587
|
+
for (const ns of split) {
|
|
26588
|
+
if (ns[0] === "-") {
|
|
26589
|
+
createDebug.skips.push(ns.slice(1));
|
|
26590
|
+
} else {
|
|
26591
|
+
createDebug.names.push(ns);
|
|
26577
26592
|
}
|
|
26578
|
-
|
|
26579
|
-
|
|
26580
|
-
|
|
26593
|
+
}
|
|
26594
|
+
}
|
|
26595
|
+
function matchesTemplate(search, template) {
|
|
26596
|
+
let searchIndex = 0;
|
|
26597
|
+
let templateIndex = 0;
|
|
26598
|
+
let starIndex = -1;
|
|
26599
|
+
let matchIndex = 0;
|
|
26600
|
+
while (searchIndex < search.length) {
|
|
26601
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
26602
|
+
if (template[templateIndex] === "*") {
|
|
26603
|
+
starIndex = templateIndex;
|
|
26604
|
+
matchIndex = searchIndex;
|
|
26605
|
+
templateIndex++;
|
|
26606
|
+
} else {
|
|
26607
|
+
searchIndex++;
|
|
26608
|
+
templateIndex++;
|
|
26609
|
+
}
|
|
26610
|
+
} else if (starIndex !== -1) {
|
|
26611
|
+
templateIndex = starIndex + 1;
|
|
26612
|
+
matchIndex++;
|
|
26613
|
+
searchIndex = matchIndex;
|
|
26581
26614
|
} else {
|
|
26582
|
-
|
|
26615
|
+
return false;
|
|
26583
26616
|
}
|
|
26584
26617
|
}
|
|
26618
|
+
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
26619
|
+
templateIndex++;
|
|
26620
|
+
}
|
|
26621
|
+
return templateIndex === template.length;
|
|
26585
26622
|
}
|
|
26586
26623
|
function disable() {
|
|
26587
26624
|
const namespaces = [
|
|
26588
|
-
...createDebug.names
|
|
26589
|
-
...createDebug.skips.map(
|
|
26625
|
+
...createDebug.names,
|
|
26626
|
+
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
26590
26627
|
].join(",");
|
|
26591
26628
|
createDebug.enable("");
|
|
26592
26629
|
return namespaces;
|
|
26593
26630
|
}
|
|
26594
26631
|
function enabled(name) {
|
|
26595
|
-
|
|
26596
|
-
|
|
26597
|
-
}
|
|
26598
|
-
let i;
|
|
26599
|
-
let len;
|
|
26600
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
26601
|
-
if (createDebug.skips[i].test(name)) {
|
|
26632
|
+
for (const skip of createDebug.skips) {
|
|
26633
|
+
if (matchesTemplate(name, skip)) {
|
|
26602
26634
|
return false;
|
|
26603
26635
|
}
|
|
26604
26636
|
}
|
|
26605
|
-
for (
|
|
26606
|
-
if (
|
|
26637
|
+
for (const ns of createDebug.names) {
|
|
26638
|
+
if (matchesTemplate(name, ns)) {
|
|
26607
26639
|
return true;
|
|
26608
26640
|
}
|
|
26609
26641
|
}
|
|
26610
26642
|
return false;
|
|
26611
26643
|
}
|
|
26612
|
-
function toNamespace(regexp) {
|
|
26613
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
26614
|
-
}
|
|
26615
26644
|
function coerce(val) {
|
|
26616
26645
|
if (val instanceof Error) {
|
|
26617
26646
|
return val.stack || val.message;
|
|
@@ -26728,10 +26757,11 @@ var require_browser = (0, import_chunk_ABYVSU2C.__commonJS)({
|
|
|
26728
26757
|
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
26729
26758
|
return false;
|
|
26730
26759
|
}
|
|
26760
|
+
let m;
|
|
26731
26761
|
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
26732
26762
|
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
26733
26763
|
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
26734
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(
|
|
26764
|
+
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
26735
26765
|
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
26736
26766
|
}
|
|
26737
26767
|
function formatArgs(args) {
|
|
@@ -27046,7 +27076,7 @@ var require_node = (0, import_chunk_ABYVSU2C.__commonJS)({
|
|
|
27046
27076
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
27047
27077
|
}
|
|
27048
27078
|
function log2(...args) {
|
|
27049
|
-
return process.stderr.write(util.
|
|
27079
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
|
|
27050
27080
|
}
|
|
27051
27081
|
function save(namespaces) {
|
|
27052
27082
|
if (namespaces) {
|
|
@@ -29955,6 +29985,11 @@ async function launchSimulator(force = true) {
|
|
|
29955
29985
|
"Contents/MacOS/simulator"
|
|
29956
29986
|
)
|
|
29957
29987
|
]);
|
|
29988
|
+
if (process.platform === "win32") {
|
|
29989
|
+
child.stdin?.end();
|
|
29990
|
+
child.stdout?.destroy();
|
|
29991
|
+
child.stderr?.destroy();
|
|
29992
|
+
}
|
|
29958
29993
|
child.unref();
|
|
29959
29994
|
for (let i = 0; ; i++) {
|
|
29960
29995
|
if (await checkIfSimulatorRunning())
|
|
@@ -30717,7 +30752,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
30717
30752
|
const opt_time = await (0, import_chunk_X7QCZR3F.first_modified)(
|
|
30718
30753
|
Object.values(fnMap).map((v) => v.output)
|
|
30719
30754
|
);
|
|
30720
|
-
if (source_time < opt_time &&
|
|
30755
|
+
if (source_time < opt_time && 1738628242341 < opt_time) {
|
|
30721
30756
|
return {
|
|
30722
30757
|
hasTests,
|
|
30723
30758
|
diagnostics: prevDiagnostics,
|
|
@@ -30755,7 +30790,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
30755
30790
|
hasTests: hasTests2,
|
|
30756
30791
|
diagnostics,
|
|
30757
30792
|
sdkVersion,
|
|
30758
|
-
optimizerVersion: "1.1.
|
|
30793
|
+
optimizerVersion: "1.1.88",
|
|
30759
30794
|
...Object.fromEntries(
|
|
30760
30795
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
30761
30796
|
)
|
|
@@ -30830,6 +30865,12 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
30830
30865
|
cur.paths.push(...result.paths);
|
|
30831
30866
|
return cur;
|
|
30832
30867
|
}, null)
|
|
30868
|
+
).then(
|
|
30869
|
+
(result) => result ?? Promise.reject(
|
|
30870
|
+
new Error(
|
|
30871
|
+
`No valid devices found in manifest. Found ${manifestProducts(manifestXML).map((p) => `'${p}'`).join(", ") || "no products"}`
|
|
30872
|
+
)
|
|
30873
|
+
)
|
|
30833
30874
|
);
|
|
30834
30875
|
if (analysis) {
|
|
30835
30876
|
Object.entries(fnMap).forEach(([k, v]) => {
|
|
@@ -31262,8 +31303,17 @@ function optimizePackage(filepath, devKey, output, config) {
|
|
|
31262
31303
|
const outName = path5.basename(output, ".iq") + ".prg";
|
|
31263
31304
|
const rename = (name) => path5.basename(name) === inName ? path5.join(path5.dirname(name), outName) : name;
|
|
31264
31305
|
const poolStarted = startPool();
|
|
31265
|
-
return
|
|
31266
|
-
(
|
|
31306
|
+
return Promise.all([
|
|
31307
|
+
getDevKey(devKey),
|
|
31308
|
+
getDeviceInfo().then(
|
|
31309
|
+
(deviceInfo) => Object.fromEntries(
|
|
31310
|
+
Object.entries(deviceInfo).flatMap(
|
|
31311
|
+
([id, info]) => info.partNumbers.map((part) => [part.number, id])
|
|
31312
|
+
)
|
|
31313
|
+
)
|
|
31314
|
+
)
|
|
31315
|
+
]).then(
|
|
31316
|
+
([key, deviceInfo]) => new Promise((resolve5, reject) => {
|
|
31267
31317
|
let manifest = null;
|
|
31268
31318
|
const sigs = /* @__PURE__ */ new Map();
|
|
31269
31319
|
const zipfile = new yazl.ZipFile();
|
|
@@ -31325,11 +31375,15 @@ function optimizePackage(filepath, devKey, output, config) {
|
|
|
31325
31375
|
);
|
|
31326
31376
|
};
|
|
31327
31377
|
unzip.readEntry();
|
|
31378
|
+
let hasSig2 = false;
|
|
31328
31379
|
unzip.on("entry", function(entry) {
|
|
31329
31380
|
if (/\/$/.test(entry.fileName)) {
|
|
31330
31381
|
unzip.readEntry();
|
|
31331
31382
|
} else {
|
|
31332
|
-
if (entry.fileName
|
|
31383
|
+
if (entry.fileName.startsWith("manifest.sig")) {
|
|
31384
|
+
if (entry.fileName === "manifest.sig2") {
|
|
31385
|
+
hasSig2 = true;
|
|
31386
|
+
}
|
|
31333
31387
|
unzip.readEntry();
|
|
31334
31388
|
return;
|
|
31335
31389
|
}
|
|
@@ -31382,7 +31436,7 @@ function optimizePackage(filepath, devKey, output, config) {
|
|
|
31382
31436
|
});
|
|
31383
31437
|
}
|
|
31384
31438
|
});
|
|
31385
|
-
unzip.on("end", () => {
|
|
31439
|
+
unzip.on("end", async () => {
|
|
31386
31440
|
try {
|
|
31387
31441
|
if (!manifest) {
|
|
31388
31442
|
throw new Error("No manifest file found");
|
|
@@ -31392,12 +31446,18 @@ function optimizePackage(filepath, devKey, output, config) {
|
|
|
31392
31446
|
if (body instanceof Error) {
|
|
31393
31447
|
throw body;
|
|
31394
31448
|
}
|
|
31395
|
-
Promise.all(promises).then(() => {
|
|
31449
|
+
await Promise.all(promises).then(() => {
|
|
31396
31450
|
body.children("iq:application").children("iq:products").children("iq:product").attrs().forEach((attr) => {
|
|
31397
|
-
const
|
|
31451
|
+
const part = attr.partNumber?.value.value;
|
|
31452
|
+
if (!part) {
|
|
31453
|
+
throw new Error(
|
|
31454
|
+
`Missing partNumber for product in manifest`
|
|
31455
|
+
);
|
|
31456
|
+
}
|
|
31457
|
+
const id = deviceInfo[part];
|
|
31398
31458
|
if (!id) {
|
|
31399
31459
|
throw new Error(
|
|
31400
|
-
`
|
|
31460
|
+
`No id found for partNumber '${part}' in manifest`
|
|
31401
31461
|
);
|
|
31402
31462
|
}
|
|
31403
31463
|
const filename = attr.filename?.value.value;
|
|
@@ -31407,8 +31467,8 @@ function optimizePackage(filepath, devKey, output, config) {
|
|
|
31407
31467
|
);
|
|
31408
31468
|
}
|
|
31409
31469
|
const newName = rename(filename);
|
|
31410
|
-
const
|
|
31411
|
-
if (!
|
|
31470
|
+
const sig = sigs.get(newName);
|
|
31471
|
+
if (!sig) {
|
|
31412
31472
|
throw new Error(
|
|
31413
31473
|
`${newName}, listed in the manifest for product ${id}, was not found`
|
|
31414
31474
|
);
|
|
@@ -31419,19 +31479,27 @@ function optimizePackage(filepath, devKey, output, config) {
|
|
|
31419
31479
|
);
|
|
31420
31480
|
}
|
|
31421
31481
|
attr.filename.value.value = newName;
|
|
31422
|
-
attr.sig.value.value =
|
|
31482
|
+
attr.sig.value.value = sig.subarray(0, 512).toString("hex").toUpperCase();
|
|
31483
|
+
if (attr.sig2 && sig.length === 1024) {
|
|
31484
|
+
attr.sig2.value.value = sig.subarray(512).toString("hex").toUpperCase();
|
|
31485
|
+
} else {
|
|
31486
|
+
delete attr.sig2;
|
|
31487
|
+
}
|
|
31423
31488
|
});
|
|
31424
31489
|
const contents = Buffer.from(xml_util_exports.writeXml(xml));
|
|
31425
31490
|
zipfile.addBuffer(contents, "manifest.xml");
|
|
31426
|
-
const
|
|
31427
|
-
|
|
31428
|
-
|
|
31429
|
-
|
|
31430
|
-
contents.byteOffset,
|
|
31431
|
-
contents.byteLength
|
|
31432
|
-
)
|
|
31491
|
+
const contentView = new DataView(
|
|
31492
|
+
contents.buffer,
|
|
31493
|
+
contents.byteOffset,
|
|
31494
|
+
contents.byteLength
|
|
31433
31495
|
);
|
|
31434
|
-
zipfile.addBuffer(
|
|
31496
|
+
zipfile.addBuffer(signView(key, contentView), "manifest.sig");
|
|
31497
|
+
if (hasSig2) {
|
|
31498
|
+
zipfile.addBuffer(
|
|
31499
|
+
signView(key, contentView, "SHA256"),
|
|
31500
|
+
"manifest.sig2"
|
|
31501
|
+
);
|
|
31502
|
+
}
|
|
31435
31503
|
zipfile.end();
|
|
31436
31504
|
});
|
|
31437
31505
|
} catch (e) {
|
|
@@ -31512,7 +31580,14 @@ async function getDeviceInfo() {
|
|
|
31512
31580
|
const ciqVersions = partNumbers.map((part) => part.connectIQVersion);
|
|
31513
31581
|
return [
|
|
31514
31582
|
deviceId,
|
|
31515
|
-
{
|
|
31583
|
+
{
|
|
31584
|
+
appTypes,
|
|
31585
|
+
deviceFamily,
|
|
31586
|
+
displayName,
|
|
31587
|
+
languages,
|
|
31588
|
+
ciqVersions,
|
|
31589
|
+
partNumbers
|
|
31590
|
+
}
|
|
31516
31591
|
];
|
|
31517
31592
|
});
|
|
31518
31593
|
})
|
package/build/optimizer.cjs
CHANGED
|
@@ -18,30 +18,30 @@ 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
|
-
buildConfigDescription: () =>
|
|
23
|
-
buildOptimizedProject: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_ROZUBUPR.StateNodeAttributes,
|
|
22
|
+
buildConfigDescription: () => import_chunk_ROZUBUPR.buildConfigDescription,
|
|
23
|
+
buildOptimizedProject: () => import_chunk_ROZUBUPR.buildOptimizedProject,
|
|
24
24
|
copyRecursiveAsNeeded: () => import_chunk_X7QCZR3F.copyRecursiveAsNeeded,
|
|
25
|
-
defaultConfig: () =>
|
|
26
|
-
display: () =>
|
|
27
|
-
generateOneConfig: () =>
|
|
28
|
-
generateOptimizedProject: () =>
|
|
29
|
-
getConfig: () =>
|
|
30
|
-
getFnMapAnalysis: () =>
|
|
31
|
-
getProjectAnalysis: () =>
|
|
32
|
-
get_jungle: () =>
|
|
33
|
-
isErrorWithLocation: () =>
|
|
34
|
-
launchSimulator: () =>
|
|
35
|
-
manifestProducts: () =>
|
|
36
|
-
mctree: () =>
|
|
37
|
-
simulateProgram: () =>
|
|
25
|
+
defaultConfig: () => import_chunk_ROZUBUPR.defaultConfig,
|
|
26
|
+
display: () => import_chunk_ROZUBUPR.display,
|
|
27
|
+
generateOneConfig: () => import_chunk_ROZUBUPR.generateOneConfig,
|
|
28
|
+
generateOptimizedProject: () => import_chunk_ROZUBUPR.generateOptimizedProject,
|
|
29
|
+
getConfig: () => import_chunk_ROZUBUPR.getConfig,
|
|
30
|
+
getFnMapAnalysis: () => import_chunk_ROZUBUPR.getFnMapAnalysis,
|
|
31
|
+
getProjectAnalysis: () => import_chunk_ROZUBUPR.getProjectAnalysis,
|
|
32
|
+
get_jungle: () => import_chunk_ROZUBUPR.get_jungle,
|
|
33
|
+
isErrorWithLocation: () => import_chunk_ROZUBUPR.isErrorWithLocation,
|
|
34
|
+
launchSimulator: () => import_chunk_ROZUBUPR.launchSimulator,
|
|
35
|
+
manifestProducts: () => import_chunk_ROZUBUPR.manifestProducts,
|
|
36
|
+
mctree: () => import_chunk_ROZUBUPR.mctree,
|
|
37
|
+
simulateProgram: () => import_chunk_ROZUBUPR.simulateProgram
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(optimizer_exports);
|
|
40
|
-
var
|
|
40
|
+
var import_chunk_ROZUBUPR = require("./chunk-ROZUBUPR.cjs");
|
|
41
41
|
var import_chunk_X7QCZR3F = require("./chunk-X7QCZR3F.cjs");
|
|
42
42
|
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
|
|
43
43
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
44
|
-
(0,
|
|
44
|
+
(0, import_chunk_ROZUBUPR.init_optimizer)();
|
|
45
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
46
|
0 && (module.exports = {
|
|
47
47
|
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_ROZUBUPR.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_ROZUBUPR.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_ROZUBUPR.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_ROZUBUPR.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_ROZUBUPR.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_ROZUBUPR.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_ROZUBUPR.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_ROZUBUPR.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_ROZUBUPR.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_ROZUBUPR.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_ROZUBUPR.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_ROZUBUPR.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_ROZUBUPR = require("./chunk-ROZUBUPR.cjs");
|
|
36
36
|
var import_chunk_X7QCZR3F = require("./chunk-X7QCZR3F.cjs");
|
|
37
37
|
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
|
|
38
38
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
39
|
-
(0,
|
|
39
|
+
(0, import_chunk_ROZUBUPR.init_sdk_util)();
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
SectionKinds,
|
|
@@ -4,5 +4,5 @@ import * as crypto from "node:crypto";
|
|
|
4
4
|
import { Context } from "./bytecode";
|
|
5
5
|
export declare function getPrgSignature(context: Context): Buffer | undefined;
|
|
6
6
|
export declare function getDevKey(file: string): Promise<crypto.KeyObject>;
|
|
7
|
-
export declare function signatureFromContext(context: Context): Buffer | null;
|
|
8
|
-
export declare function signView(key: crypto.KeyObject, view: DataView): Buffer;
|
|
7
|
+
export declare function signatureFromContext(context: Context, method?: string): Buffer | null;
|
|
8
|
+
export declare function signView(key: crypto.KeyObject, view: DataView, method?: string): Buffer;
|
package/build/src/sdk-util.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ export declare const isWin: boolean;
|
|
|
5
5
|
export declare const appSupport: string;
|
|
6
6
|
export declare const connectiq: string;
|
|
7
7
|
export declare function getSdkPath(): Promise<string>;
|
|
8
|
+
export type PartNumber = {
|
|
9
|
+
connectIQVersion: string;
|
|
10
|
+
firmwareVersion: string;
|
|
11
|
+
languages: Array<{
|
|
12
|
+
code: string;
|
|
13
|
+
fontSet: string;
|
|
14
|
+
}>;
|
|
15
|
+
number: string;
|
|
16
|
+
};
|
|
8
17
|
export type DeviceInfo = {
|
|
9
18
|
[key: string]: {
|
|
10
19
|
appTypes: {
|
|
@@ -15,6 +24,7 @@ export type DeviceInfo = {
|
|
|
15
24
|
displayName: string;
|
|
16
25
|
languages: Record<string, true>;
|
|
17
26
|
ciqVersions: Array<string>;
|
|
27
|
+
partNumbers: PartNumber[];
|
|
18
28
|
};
|
|
19
29
|
};
|
|
20
30
|
export declare function getDeviceInfo(): Promise<DeviceInfo>;
|
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_ROZUBUPR = require("./chunk-ROZUBUPR.cjs");
|
|
25
25
|
var import_chunk_X7QCZR3F = require("./chunk-X7QCZR3F.cjs");
|
|
26
26
|
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.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_ROZUBUPR.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_ROZUBUPR.performTask)(task));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markw65/monkeyc-optimizer",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.88",
|
|
5
5
|
"description": "Source to source optimizer for Garmin Monkey C code",
|
|
6
6
|
"main": "build/optimizer.cjs",
|
|
7
7
|
"types": "build/src/optimizer.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"author": "markw65",
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@markw65/prettier-plugin-monkeyc": "^1.0.
|
|
59
|
+
"@markw65/prettier-plugin-monkeyc": "^1.0.61"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@markw65/peggy-optimizer": "^1.0.1",
|