@markw65/monkeyc-optimizer 1.0.36 → 1.0.37

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/README.md CHANGED
@@ -417,6 +417,6 @@ Bug Fixes
417
417
 
418
418
  ### 1.0.36
419
419
 
420
- - Update to [@markw65/prettier-plugin-monkeyc@1.0.34](https://github.com/markw65/prettier-plugin-monkeyc#1034).
420
+ - Update to [@markw65/prettier-plugin-monkeyc@1.0.35](https://github.com/markw65/prettier-plugin-monkeyc#1035).
421
421
  - Fixes [prettier-plugin-monkeyc#1](https://github.com/markw65/prettier-plugin-monkeyc/issues/1)
422
422
  - Fixes [monkeyc-optimizer#1](https://github.com/markw65/monkeyc-optimizer/issues/1)
@@ -10956,6 +10956,8 @@ async function get_jungle(jungles, options) {
10956
10956
  return result;
10957
10957
  }
10958
10958
 
10959
+ ;// CONCATENATED MODULE: external "net"
10960
+ const external_net_namespaceObject = require("net");
10959
10961
  ;// CONCATENATED MODULE: external "child_process"
10960
10962
  const external_child_process_namespaceObject = require("child_process");
10961
10963
  ;// CONCATENATED MODULE: ./src/launch.ts
@@ -10963,10 +10965,27 @@ const external_child_process_namespaceObject = require("child_process");
10963
10965
 
10964
10966
 
10965
10967
 
10968
+
10966
10969
  function launchSimulator() {
10967
- return (0,external_sdk_util_cjs_namespaceObject.getSdkPath)().then((sdk) => {
10968
- const child = (0,external_child_process_namespaceObject.execFile)(external_path_.resolve(sdk, "bin", external_sdk_util_cjs_namespaceObject.isWin ? "simulator" : "connectiq"));
10969
- child.unref();
10970
+ return checkIfSimulatorRunning().then((running) => running
10971
+ ? Promise.resolve()
10972
+ : (0,external_sdk_util_cjs_namespaceObject.getSdkPath)().then((sdk) => {
10973
+ const child = (0,external_child_process_namespaceObject.execFile)(external_path_.resolve(sdk, "bin", external_sdk_util_cjs_namespaceObject.isWin ? "simulator" : "connectiq"));
10974
+ child.unref();
10975
+ }));
10976
+ }
10977
+ function checkIfSimulatorRunning() {
10978
+ return Promise.all([1234, 1235, 1236, 1237, 1238].map(checkIfSimulatorRunningOn)).then((results) => results.some((v) => v));
10979
+ }
10980
+ function checkIfSimulatorRunningOn(port) {
10981
+ return new Promise((resolve) => {
10982
+ let listening = false;
10983
+ const socket = new external_net_namespaceObject.Socket();
10984
+ socket.on("data", (data) => (listening = data.toString().includes("A garmin device")));
10985
+ socket.on("error", () => resolve(false));
10986
+ socket.on("end", () => resolve(listening));
10987
+ socket.connect(port, "localhost");
10988
+ socket.end();
10970
10989
  });
10971
10990
  }
10972
10991
  function simulateProgram(prg, device, test = false, logger) {
@@ -15438,6 +15457,7 @@ const configOptionsToCheck = [
15438
15457
  "ignoredSourcePaths",
15439
15458
  "checkInvalidSymbols",
15440
15459
  "sizeBasedPRE",
15460
+ "extensionVersion",
15441
15461
  ];
15442
15462
  /**
15443
15463
  * @param {BuildConfig} config
@@ -15489,7 +15509,7 @@ async function generateOneConfig(buildConfig, dependencyFiles, config) {
15489
15509
  // the oldest optimized file, we don't need to regenerate
15490
15510
  const source_time = await (0,external_util_cjs_namespaceObject.last_modified)(Object.keys(fnMap).concat(dependencyFiles));
15491
15511
  const opt_time = await (0,external_util_cjs_namespaceObject.first_modified)(Object.values(fnMap).map((v) => v.output));
15492
- if (source_time < opt_time && 1662763619992 < opt_time) {
15512
+ if (source_time < opt_time && 1666558228929 < opt_time) {
15493
15513
  return { hasTests, diagnostics: prevDiagnostics };
15494
15514
  }
15495
15515
  }
@@ -15514,6 +15534,7 @@ async function generateOneConfig(buildConfig, dependencyFiles, config) {
15514
15534
  return promises_namespaceObject.writeFile(external_path_.join(output, "build-info.json"), JSON.stringify({
15515
15535
  hasTests,
15516
15536
  diagnostics,
15537
+ optimizerVersion: "1.0.37",
15517
15538
  ...Object.fromEntries(configOptionsToCheck.map((option) => [option, config[option]])),
15518
15539
  }))
15519
15540
  .then(() => ({ hasTests, diagnostics }));
@@ -1,3 +1,5 @@
1
1
  import { LineHandler } from "./util";
2
2
  export declare function launchSimulator(): Promise<void>;
3
+ export declare function checkIfSimulatorRunning(): Promise<boolean>;
4
+ export declare function checkIfSimulatorRunningOn(port: number): Promise<boolean>;
3
5
  export declare function simulateProgram(prg: string, device: string, test?: boolean, logger?: LineHandler | LineHandler[]): Promise<void>;
@@ -26,6 +26,7 @@ export declare type BuildConfig = {
26
26
  checkInvalidSymbols?: DiagnosticType | "OFF";
27
27
  sizeBasedPRE?: boolean | string;
28
28
  prettier?: Record<string, unknown>;
29
+ extensionVersion?: string;
29
30
  _cache?: {
30
31
  barrels?: Record<string, ResolvedJungle>;
31
32
  barrelMap?: Record<string, Record<string, ResolvedJungle>>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "module",
4
- "version": "1.0.36",
4
+ "version": "1.0.37",
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",