@markw65/monkeyc-optimizer 1.1.87 → 1.1.89

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 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.89
6
+
7
+ - Fix error determining whether or not to generate a SHA256 signature, so that things start working with sdk-8.2.2 again
8
+
9
+ ### 1.1.88
10
+
11
+ - Fix output of cft-font-info
12
+ - 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.
13
+ - Update to [@markw65/prettier-plugin-monkeyc@1.0.61](https://github.com/markw65/prettier-plugin-monkeyc/blob/main/CHANGELOG.md#1061)
14
+
15
+ - Allow semi-colons after expression-statements, and uncontrolled block-statements to match Garmin's parser.
16
+
17
+ - 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))
18
+ - Fix various issues with tests so that they pass with 7.4.3, and on windows
19
+ - 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.
20
+
5
21
  ### 1.1.87
6
22
 
7
23
  - 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.
@@ -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: () => import_chunk_N2N7HF67.checkCompilerVersion,
22
- clearDiagnostics: () => import_chunk_N2N7HF67.clearDiagnostics,
23
- collectNamespaces: () => import_chunk_N2N7HF67.collectNamespaces,
24
- createDocumentationMap: () => import_chunk_N2N7HF67.createDocumentationMap,
25
- declKey: () => import_chunk_N2N7HF67.declKey,
26
- diagnostic: () => import_chunk_N2N7HF67.diagnostic,
27
- diagnosticHelper: () => import_chunk_N2N7HF67.diagnosticHelper,
28
- findNamesInScope: () => import_chunk_N2N7HF67.findNamesInScope,
29
- findUsingForNode: () => import_chunk_N2N7HF67.findUsingForNode,
30
- formatAst: () => import_chunk_N2N7HF67.formatAst,
31
- formatAstLongLines: () => import_chunk_N2N7HF67.formatAstLongLines,
32
- formatScopedName: () => import_chunk_N2N7HF67.formatScopedName,
33
- getApiFunctionInfo: () => import_chunk_N2N7HF67.getApiFunctionInfo,
34
- getApiMapping: () => import_chunk_N2N7HF67.getApiMapping,
35
- getSuperClasses: () => import_chunk_N2N7HF67.getSuperClasses,
36
- handleImportUsing: () => import_chunk_N2N7HF67.handleImportUsing,
21
+ checkCompilerVersion: () => import_chunk_7CG7CM26.checkCompilerVersion,
22
+ clearDiagnostics: () => import_chunk_7CG7CM26.clearDiagnostics,
23
+ collectNamespaces: () => import_chunk_7CG7CM26.collectNamespaces,
24
+ createDocumentationMap: () => import_chunk_7CG7CM26.createDocumentationMap,
25
+ declKey: () => import_chunk_7CG7CM26.declKey,
26
+ diagnostic: () => import_chunk_7CG7CM26.diagnostic,
27
+ diagnosticHelper: () => import_chunk_7CG7CM26.diagnosticHelper,
28
+ findNamesInScope: () => import_chunk_7CG7CM26.findNamesInScope,
29
+ findUsingForNode: () => import_chunk_7CG7CM26.findUsingForNode,
30
+ formatAst: () => import_chunk_7CG7CM26.formatAst,
31
+ formatAstLongLines: () => import_chunk_7CG7CM26.formatAstLongLines,
32
+ formatScopedName: () => import_chunk_7CG7CM26.formatScopedName,
33
+ getApiFunctionInfo: () => import_chunk_7CG7CM26.getApiFunctionInfo,
34
+ getApiMapping: () => import_chunk_7CG7CM26.getApiMapping,
35
+ getSuperClasses: () => import_chunk_7CG7CM26.getSuperClasses,
36
+ handleImportUsing: () => import_chunk_7CG7CM26.handleImportUsing,
37
37
  hasProperty: () => import_chunk_JDC43A3I.hasProperty,
38
- isClassVariable: () => import_chunk_N2N7HF67.isClassVariable,
39
- isLocal: () => import_chunk_N2N7HF67.isLocal,
40
- isLookupCandidate: () => import_chunk_N2N7HF67.isLookupCandidate,
41
- isStateNode: () => import_chunk_N2N7HF67.isStateNode,
42
- lookupByFullName: () => import_chunk_N2N7HF67.lookupByFullName,
43
- lookupNext: () => import_chunk_N2N7HF67.lookupNext,
44
- lookupResultContains: () => import_chunk_N2N7HF67.lookupResultContains,
45
- lookupWithType: () => import_chunk_N2N7HF67.lookupWithType,
46
- makeToyboxLink: () => import_chunk_N2N7HF67.makeToyboxLink,
47
- mapVarDeclsByType: () => import_chunk_N2N7HF67.mapVarDeclsByType,
48
- markInvokeClassMethod: () => import_chunk_N2N7HF67.markInvokeClassMethod,
49
- parseSdkVersion: () => import_chunk_N2N7HF67.parseSdkVersion,
50
- popRootNode: () => import_chunk_N2N7HF67.popRootNode,
51
- pushRootNode: () => import_chunk_N2N7HF67.pushRootNode,
52
- resolveDiagnostics: () => import_chunk_N2N7HF67.resolveDiagnostics,
53
- resolveDiagnosticsMap: () => import_chunk_N2N7HF67.resolveDiagnosticsMap,
54
- sameLookupResult: () => import_chunk_N2N7HF67.sameLookupResult,
38
+ isClassVariable: () => import_chunk_7CG7CM26.isClassVariable,
39
+ isLocal: () => import_chunk_7CG7CM26.isLocal,
40
+ isLookupCandidate: () => import_chunk_7CG7CM26.isLookupCandidate,
41
+ isStateNode: () => import_chunk_7CG7CM26.isStateNode,
42
+ lookupByFullName: () => import_chunk_7CG7CM26.lookupByFullName,
43
+ lookupNext: () => import_chunk_7CG7CM26.lookupNext,
44
+ lookupResultContains: () => import_chunk_7CG7CM26.lookupResultContains,
45
+ lookupWithType: () => import_chunk_7CG7CM26.lookupWithType,
46
+ makeToyboxLink: () => import_chunk_7CG7CM26.makeToyboxLink,
47
+ mapVarDeclsByType: () => import_chunk_7CG7CM26.mapVarDeclsByType,
48
+ markInvokeClassMethod: () => import_chunk_7CG7CM26.markInvokeClassMethod,
49
+ parseSdkVersion: () => import_chunk_7CG7CM26.parseSdkVersion,
50
+ popRootNode: () => import_chunk_7CG7CM26.popRootNode,
51
+ pushRootNode: () => import_chunk_7CG7CM26.pushRootNode,
52
+ resolveDiagnostics: () => import_chunk_7CG7CM26.resolveDiagnostics,
53
+ resolveDiagnosticsMap: () => import_chunk_7CG7CM26.resolveDiagnosticsMap,
54
+ sameLookupResult: () => import_chunk_7CG7CM26.sameLookupResult,
55
55
  traverseAst: () => import_chunk_JDC43A3I.traverseAst,
56
- variableDeclarationName: () => import_chunk_N2N7HF67.variableDeclarationName,
57
- visitReferences: () => import_chunk_N2N7HF67.visitReferences,
58
- visit_resources: () => import_chunk_N2N7HF67.visit_resources,
59
- visitorNode: () => import_chunk_N2N7HF67.visitorNode
56
+ variableDeclarationName: () => import_chunk_7CG7CM26.variableDeclarationName,
57
+ visitReferences: () => import_chunk_7CG7CM26.visitReferences,
58
+ visit_resources: () => import_chunk_7CG7CM26.visit_resources,
59
+ visitorNode: () => import_chunk_7CG7CM26.visitorNode
60
60
  });
61
61
  module.exports = __toCommonJS(api_exports);
62
- var import_chunk_N2N7HF67 = require("./chunk-N2N7HF67.cjs");
62
+ var import_chunk_7CG7CM26 = require("./chunk-7CG7CM26.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, import_chunk_N2N7HF67.init_api)();
66
+ (0, import_chunk_7CG7CM26.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 chunk_N2N7HF67_exports = {};
30
- __export(chunk_N2N7HF67_exports, {
29
+ var chunk_7CG7CM26_exports = {};
30
+ __export(chunk_7CG7CM26_exports, {
31
31
  EnumTagsConst: () => EnumTagsConst,
32
32
  LastTypeTag: () => LastTypeTag,
33
33
  ObjectLikeTagsConst: () => ObjectLikeTagsConst,
@@ -140,7 +140,7 @@ __export(chunk_N2N7HF67_exports, {
140
140
  visitorNode: () => visitorNode,
141
141
  xml_util_exports: () => xml_util_exports
142
142
  });
143
- module.exports = __toCommonJS(chunk_N2N7HF67_exports);
143
+ module.exports = __toCommonJS(chunk_7CG7CM26_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 - 8;
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
- const sectionLength = signature.length + modulus.byteLength + 4;
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
- let offset = 8;
26112
- signature.forEach((b, i) => {
26113
- buffer.setUint8(offset + 512, modulus.getUint8(i));
26114
- buffer.setUint8(offset++, b);
26115
- });
26116
- buffer.setInt32(offset + 512, publicExponent);
26117
- const max = Object.values(context.sections).reduce(
26118
- (max2, cur) => cur.offset + cur.length > max2 ? cur.offset + cur.length : max2,
26119
- 0
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("SHA1");
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("SHA1");
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
- let i;
26572
- const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
26573
- const len = split.length;
26574
- for (i = 0; i < len; i++) {
26575
- if (!split[i]) {
26576
- continue;
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
- namespaces = split[i].replace(/\*/g, ".*?");
26579
- if (namespaces[0] === "-") {
26580
- createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
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
- createDebug.names.push(new RegExp("^" + namespaces + "$"));
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.map(toNamespace),
26589
- ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
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
- if (name[name.length - 1] === "*") {
26596
- return true;
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 (i = 0, len = createDebug.names.length; i < len; i++) {
26606
- if (createDebug.names[i].test(name)) {
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(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
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.format(...args) + "\n");
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 && 1734629819655 < opt_time) {
30755
+ if (source_time < opt_time && 1754525704940 < 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.87",
30793
+ optimizerVersion: "1.1.89",
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]) => {
@@ -31334,11 +31375,15 @@ function optimizePackage(filepath, devKey, output, config) {
31334
31375
  );
31335
31376
  };
31336
31377
  unzip.readEntry();
31378
+ let hasSig2 = false;
31337
31379
  unzip.on("entry", function(entry) {
31338
31380
  if (/\/$/.test(entry.fileName)) {
31339
31381
  unzip.readEntry();
31340
31382
  } else {
31341
31383
  if (entry.fileName.startsWith("manifest.sig")) {
31384
+ if (entry.fileName === "manifest.sig2") {
31385
+ hasSig2 = true;
31386
+ }
31342
31387
  unzip.readEntry();
31343
31388
  return;
31344
31389
  }
@@ -31422,8 +31467,8 @@ function optimizePackage(filepath, devKey, output, config) {
31422
31467
  );
31423
31468
  }
31424
31469
  const newName = rename(filename);
31425
- const sig2 = sigs.get(newName);
31426
- if (!sig2) {
31470
+ const sig = sigs.get(newName);
31471
+ if (!sig) {
31427
31472
  throw new Error(
31428
31473
  `${newName}, listed in the manifest for product ${id}, was not found`
31429
31474
  );
@@ -31434,20 +31479,27 @@ function optimizePackage(filepath, devKey, output, config) {
31434
31479
  );
31435
31480
  }
31436
31481
  attr.filename.value.value = newName;
31437
- attr.sig.value.value = sig2.toString("hex").toUpperCase();
31438
- delete attr.sig2;
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
+ }
31439
31488
  });
31440
31489
  const contents = Buffer.from(xml_util_exports.writeXml(xml));
31441
31490
  zipfile.addBuffer(contents, "manifest.xml");
31442
- const sig = signView(
31443
- key,
31444
- new DataView(
31445
- contents.buffer,
31446
- contents.byteOffset,
31447
- contents.byteLength
31448
- )
31491
+ const contentView = new DataView(
31492
+ contents.buffer,
31493
+ contents.byteOffset,
31494
+ contents.byteLength
31449
31495
  );
31450
- zipfile.addBuffer(sig, "manifest.sig");
31496
+ zipfile.addBuffer(signView(key, contentView), "manifest.sig");
31497
+ if (hasSig2) {
31498
+ zipfile.addBuffer(
31499
+ signView(key, contentView, "SHA256"),
31500
+ "manifest.sig2"
31501
+ );
31502
+ }
31451
31503
  zipfile.end();
31452
31504
  });
31453
31505
  } catch (e) {
@@ -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: () => import_chunk_N2N7HF67.StateNodeAttributes,
22
- buildConfigDescription: () => import_chunk_N2N7HF67.buildConfigDescription,
23
- buildOptimizedProject: () => import_chunk_N2N7HF67.buildOptimizedProject,
21
+ StateNodeAttributes: () => import_chunk_7CG7CM26.StateNodeAttributes,
22
+ buildConfigDescription: () => import_chunk_7CG7CM26.buildConfigDescription,
23
+ buildOptimizedProject: () => import_chunk_7CG7CM26.buildOptimizedProject,
24
24
  copyRecursiveAsNeeded: () => import_chunk_X7QCZR3F.copyRecursiveAsNeeded,
25
- defaultConfig: () => import_chunk_N2N7HF67.defaultConfig,
26
- display: () => import_chunk_N2N7HF67.display,
27
- generateOneConfig: () => import_chunk_N2N7HF67.generateOneConfig,
28
- generateOptimizedProject: () => import_chunk_N2N7HF67.generateOptimizedProject,
29
- getConfig: () => import_chunk_N2N7HF67.getConfig,
30
- getFnMapAnalysis: () => import_chunk_N2N7HF67.getFnMapAnalysis,
31
- getProjectAnalysis: () => import_chunk_N2N7HF67.getProjectAnalysis,
32
- get_jungle: () => import_chunk_N2N7HF67.get_jungle,
33
- isErrorWithLocation: () => import_chunk_N2N7HF67.isErrorWithLocation,
34
- launchSimulator: () => import_chunk_N2N7HF67.launchSimulator,
35
- manifestProducts: () => import_chunk_N2N7HF67.manifestProducts,
36
- mctree: () => import_chunk_N2N7HF67.mctree,
37
- simulateProgram: () => import_chunk_N2N7HF67.simulateProgram
25
+ defaultConfig: () => import_chunk_7CG7CM26.defaultConfig,
26
+ display: () => import_chunk_7CG7CM26.display,
27
+ generateOneConfig: () => import_chunk_7CG7CM26.generateOneConfig,
28
+ generateOptimizedProject: () => import_chunk_7CG7CM26.generateOptimizedProject,
29
+ getConfig: () => import_chunk_7CG7CM26.getConfig,
30
+ getFnMapAnalysis: () => import_chunk_7CG7CM26.getFnMapAnalysis,
31
+ getProjectAnalysis: () => import_chunk_7CG7CM26.getProjectAnalysis,
32
+ get_jungle: () => import_chunk_7CG7CM26.get_jungle,
33
+ isErrorWithLocation: () => import_chunk_7CG7CM26.isErrorWithLocation,
34
+ launchSimulator: () => import_chunk_7CG7CM26.launchSimulator,
35
+ manifestProducts: () => import_chunk_7CG7CM26.manifestProducts,
36
+ mctree: () => import_chunk_7CG7CM26.mctree,
37
+ simulateProgram: () => import_chunk_7CG7CM26.simulateProgram
38
38
  });
39
39
  module.exports = __toCommonJS(optimizer_exports);
40
- var import_chunk_N2N7HF67 = require("./chunk-N2N7HF67.cjs");
40
+ var import_chunk_7CG7CM26 = require("./chunk-7CG7CM26.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, import_chunk_N2N7HF67.init_optimizer)();
44
+ (0, import_chunk_7CG7CM26.init_optimizer)();
45
45
  // Annotate the CommonJS export names for ESM import in node:
46
46
  0 && (module.exports = {
47
47
  StateNodeAttributes,
@@ -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: () => import_chunk_N2N7HF67.SectionKinds,
22
- appSupport: () => import_chunk_N2N7HF67.appSupport,
23
- connectiq: () => import_chunk_N2N7HF67.connectiq,
24
- getDeviceInfo: () => import_chunk_N2N7HF67.getDeviceInfo,
25
- getFunctionDocumentation: () => import_chunk_N2N7HF67.getFunctionDocumentation,
26
- getLanguages: () => import_chunk_N2N7HF67.getLanguages,
27
- getSdkPath: () => import_chunk_N2N7HF67.getSdkPath,
28
- isWin: () => import_chunk_N2N7HF67.isWin,
29
- optimizeProgram: () => import_chunk_N2N7HF67.optimizeProgram,
30
- readPrg: () => import_chunk_N2N7HF67.readPrg,
31
- readPrgWithOffsets: () => import_chunk_N2N7HF67.readPrgWithOffsets,
32
- xmlUtil: () => import_chunk_N2N7HF67.xml_util_exports
21
+ SectionKinds: () => import_chunk_7CG7CM26.SectionKinds,
22
+ appSupport: () => import_chunk_7CG7CM26.appSupport,
23
+ connectiq: () => import_chunk_7CG7CM26.connectiq,
24
+ getDeviceInfo: () => import_chunk_7CG7CM26.getDeviceInfo,
25
+ getFunctionDocumentation: () => import_chunk_7CG7CM26.getFunctionDocumentation,
26
+ getLanguages: () => import_chunk_7CG7CM26.getLanguages,
27
+ getSdkPath: () => import_chunk_7CG7CM26.getSdkPath,
28
+ isWin: () => import_chunk_7CG7CM26.isWin,
29
+ optimizeProgram: () => import_chunk_7CG7CM26.optimizeProgram,
30
+ readPrg: () => import_chunk_7CG7CM26.readPrg,
31
+ readPrgWithOffsets: () => import_chunk_7CG7CM26.readPrgWithOffsets,
32
+ xmlUtil: () => import_chunk_7CG7CM26.xml_util_exports
33
33
  });
34
34
  module.exports = __toCommonJS(sdk_util_exports);
35
- var import_chunk_N2N7HF67 = require("./chunk-N2N7HF67.cjs");
35
+ var import_chunk_7CG7CM26 = require("./chunk-7CG7CM26.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, import_chunk_N2N7HF67.init_sdk_util)();
39
+ (0, import_chunk_7CG7CM26.init_sdk_util)();
40
40
  // Annotate the CommonJS export names for ESM import in node:
41
41
  0 && (module.exports = {
42
42
  SectionKinds,
@@ -0,0 +1,34 @@
1
+ import { JungleQualifier, JungleResourceMap, Target } from "./jungles";
2
+ import { BuildConfig, ExcludeAnnotationsMap, FilesToOptimizeMap, ProgramStateAnalysis } from "./optimizer-types";
3
+ import { xmlUtil } from "./sdk-util";
4
+ import { TypeMap } from "./type-flow/interp";
5
+ export type PreAnalysis = {
6
+ fnMap: FilesToOptimizeMap;
7
+ paths: string[];
8
+ };
9
+ export type Analysis = {
10
+ fnMap: FilesToOptimizeMap;
11
+ paths: string[];
12
+ state: ProgramStateAnalysis;
13
+ typeMap?: TypeMap | null | undefined;
14
+ };
15
+ export declare function relative_path_no_dotdot(relative: string): string;
16
+ type GlobCache = Map<string, Promise<string[]>>;
17
+ export declare function fileInfoFromConfig(workspace: string, buildDir: string, output: string, buildConfig: JungleQualifier, extraExcludes: ExcludeAnnotationsMap, barrel: string, cache?: GlobCache): Promise<PreAnalysis>;
18
+ /**
19
+ * A barrel can specify a list of possible annotations, and the
20
+ * jungle that requests the barrel can specify the annotations it wants.
21
+ *
22
+ * We should exclude all the possible annotations that weren't explicitly
23
+ * requested.
24
+ */
25
+ export declare function excludesFromAnnotations(baseAnnotations: string[] | undefined, barrelAnnotations: string[] | undefined): {
26
+ [k: string]: boolean;
27
+ };
28
+ export declare function getProjectAnalysisHelper(targets: Target[], analysis: PreAnalysis | null, manifestXML: xmlUtil.Document, options: BuildConfig): Promise<Analysis | PreAnalysis>;
29
+ export declare function getFnMapAnalysis(fnMap: FilesToOptimizeMap, resourcesMap: Record<string, JungleResourceMap>, manifestXML: xmlUtil.Document, options: BuildConfig): Promise<{
30
+ fnMap: FilesToOptimizeMap;
31
+ state: ProgramStateAnalysis;
32
+ typeMap: TypeMap | null;
33
+ }>;
34
+ export {};
@@ -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;
@@ -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 import_chunk_N2N7HF67 = require("./chunk-N2N7HF67.cjs");
24
+ var import_chunk_7CG7CM26 = require("./chunk-7CG7CM26.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, import_chunk_N2N7HF67.init_worker_task)();
31
+ (0, import_chunk_7CG7CM26.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, import_chunk_N2N7HF67.performTask)(task));
34
+ return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_7CG7CM26.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.87",
4
+ "version": "1.1.89",
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.60"
59
+ "@markw65/prettier-plugin-monkeyc": "^1.0.61"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@markw65/peggy-optimizer": "^1.0.1",