cubing 0.61.3 → 0.62.1

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.
Files changed (89) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/chunks/{chunk-5WXNSJ2M.js → chunk-7HTSOKX4.js} +2 -2
  3. package/dist/bin/order.js +3 -3
  4. package/dist/bin/order.js.map +2 -2
  5. package/dist/bin/puzzle-geometry-bin.js +3 -3
  6. package/dist/bin/puzzle-geometry-bin.js.map +2 -2
  7. package/dist/bin/scramble.js +3 -3
  8. package/dist/bin/scramble.js.map +2 -2
  9. package/dist/lib/cubing/{PuzzleLoader-CkghxdIL.d.ts → PuzzleLoader-B2JfN7uX.d.ts} +7 -7
  10. package/dist/lib/cubing/alg/index.d.ts +2 -2
  11. package/dist/lib/cubing/alg/index.js +1 -1
  12. package/dist/lib/cubing/bluetooth/index.d.ts +23 -4
  13. package/dist/lib/cubing/bluetooth/index.js +13 -10
  14. package/dist/lib/cubing/bluetooth/index.js.map +2 -2
  15. package/dist/lib/cubing/chunks/{big-puzzle-orientation-3GQ3L26S.js → big-puzzle-orientation-ZVZQJEF5.js} +2 -2
  16. package/dist/lib/cubing/chunks/{chunk-T3SF7NHB.js → chunk-2AUSVPAU.js} +3 -3
  17. package/dist/lib/cubing/chunks/{chunk-T3SF7NHB.js.map → chunk-2AUSVPAU.js.map} +2 -2
  18. package/dist/lib/cubing/chunks/{chunk-ZGT5MZSV.js → chunk-5F7JRCTP.js} +5 -5
  19. package/dist/lib/cubing/chunks/{chunk-MZKROP74.js → chunk-FLK6AZKB.js} +4 -4
  20. package/dist/lib/cubing/chunks/{chunk-MZKROP74.js.map → chunk-FLK6AZKB.js.map} +1 -1
  21. package/dist/lib/cubing/chunks/{chunk-QSGI7DXX.js → chunk-FUHYAW74.js} +4 -4
  22. package/dist/lib/cubing/chunks/{chunk-QSGI7DXX.js.map → chunk-FUHYAW74.js.map} +1 -1
  23. package/dist/lib/cubing/chunks/{chunk-XITTJ75E.js → chunk-LIVDX4MD.js} +79 -35
  24. package/dist/lib/cubing/chunks/chunk-LIVDX4MD.js.map +7 -0
  25. package/dist/lib/cubing/chunks/{chunk-3PS5LIPR.js → chunk-LWCBAAHO.js} +15 -9
  26. package/dist/lib/cubing/chunks/{chunk-3PS5LIPR.js.map → chunk-LWCBAAHO.js.map} +2 -2
  27. package/dist/lib/cubing/chunks/{chunk-WI337PMF.js → chunk-NGW52SHR.js} +3 -3
  28. package/dist/lib/cubing/chunks/{chunk-7D7ZUWUK.js → chunk-O6HEZXGY.js} +1 -1
  29. package/dist/lib/cubing/chunks/chunk-O6HEZXGY.js.map +7 -0
  30. package/dist/lib/cubing/chunks/{chunk-WAYEJXCG.js → chunk-RINY3U6G.js} +2 -2
  31. package/dist/lib/cubing/chunks/{chunk-AVOUJS6N.js → chunk-ROB5TROI.js} +2 -2
  32. package/dist/lib/cubing/chunks/{chunk-ZKJKRQKY.js → chunk-XO3JAA3V.js} +1 -2
  33. package/dist/lib/cubing/chunks/chunk-XO3JAA3V.js.map +7 -0
  34. package/dist/lib/cubing/chunks/{chunk-LCJT5ROJ.js → chunk-ZU7PSGX4.js} +3 -3
  35. package/dist/lib/cubing/chunks/chunk-ZU7PSGX4.js.map +7 -0
  36. package/dist/lib/cubing/chunks/{inside-FGQBCNHY.js → inside-TJAQBDDY.js} +16 -16
  37. package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-E5KVBK2Y.js → search-dynamic-sgs-side-events-GB4WAJ7I.js} +6 -6
  38. package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-IFHNOIEL.js → search-dynamic-sgs-unofficial-2CECFBP3.js} +6 -6
  39. package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-OBPW4YC2.js → search-dynamic-solve-4x4x4-NRWKTCNT.js} +8 -8
  40. package/dist/lib/cubing/chunks/{search-dynamic-solve-fto-HZREG6ZH.js → search-dynamic-solve-fto-UZMNOI6U.js} +2 -2
  41. package/dist/lib/cubing/chunks/{search-dynamic-solve-kilominx-GCNVEBDJ.js → search-dynamic-solve-kilominx-CD57C3C4.js} +2 -2
  42. package/dist/lib/cubing/chunks/search-worker-entry.js +5 -7
  43. package/dist/lib/cubing/chunks/search-worker-entry.js.map +2 -2
  44. package/dist/lib/cubing/chunks/{twips-OVT324QJ.js → twips-YHXBF55O.js} +2 -2
  45. package/dist/lib/cubing/chunks/{twisty-dynamic-3d-O6UL3R7C.js → twisty-dynamic-3d-IKE4BUQG.js} +9 -9
  46. package/dist/lib/cubing/chunks/twisty-dynamic-3d-IKE4BUQG.js.map +7 -0
  47. package/dist/lib/cubing/events-BDkOaqlG.d.ts +35 -0
  48. package/dist/lib/cubing/{index-B_8W-2zR.d.ts → index-DWA95mSl.d.ts} +1 -1
  49. package/dist/lib/cubing/kpuzzle/index.d.ts +1 -1
  50. package/dist/lib/cubing/kpuzzle/index.js +2 -2
  51. package/dist/lib/cubing/notation/index.d.ts +1 -1
  52. package/dist/lib/cubing/notation/index.js +4 -4
  53. package/dist/lib/cubing/protocol/index.d.ts +1 -1
  54. package/dist/lib/cubing/protocol/index.js +4 -4
  55. package/dist/lib/cubing/puzzle-geometry/index.d.ts +2 -2
  56. package/dist/lib/cubing/puzzle-geometry/index.js +1 -1
  57. package/dist/lib/cubing/puzzle-geometry/index.js.map +1 -1
  58. package/dist/lib/cubing/puzzles/index.d.ts +1 -1
  59. package/dist/lib/cubing/puzzles/index.js +4 -4
  60. package/dist/lib/cubing/scramble/index.d.ts +2 -2
  61. package/dist/lib/cubing/scramble/index.js +7 -7
  62. package/dist/lib/cubing/search/index.d.ts +3 -3
  63. package/dist/lib/cubing/search/index.js +7 -7
  64. package/dist/lib/cubing/stream/index.d.ts +4 -16
  65. package/dist/lib/cubing/stream/index.js +1 -1
  66. package/dist/lib/cubing/stream/index.js.map +2 -2
  67. package/dist/lib/cubing/twisty/index.d.ts +2 -2
  68. package/dist/lib/cubing/twisty/index.js +70 -62
  69. package/dist/lib/cubing/twisty/index.js.map +2 -2
  70. package/package.json +3 -3
  71. package/dist/lib/cubing/bluetooth-puzzle-c-_IBAdu.d.ts +0 -43
  72. package/dist/lib/cubing/chunks/chunk-7D7ZUWUK.js.map +0 -7
  73. package/dist/lib/cubing/chunks/chunk-LCJT5ROJ.js.map +0 -7
  74. package/dist/lib/cubing/chunks/chunk-XITTJ75E.js.map +0 -7
  75. package/dist/lib/cubing/chunks/chunk-ZKJKRQKY.js.map +0 -7
  76. package/dist/lib/cubing/chunks/twisty-dynamic-3d-O6UL3R7C.js.map +0 -7
  77. /package/dist/bin/chunks/{chunk-5WXNSJ2M.js.map → chunk-7HTSOKX4.js.map} +0 -0
  78. /package/dist/lib/cubing/chunks/{big-puzzle-orientation-3GQ3L26S.js.map → big-puzzle-orientation-ZVZQJEF5.js.map} +0 -0
  79. /package/dist/lib/cubing/chunks/{chunk-ZGT5MZSV.js.map → chunk-5F7JRCTP.js.map} +0 -0
  80. /package/dist/lib/cubing/chunks/{chunk-WI337PMF.js.map → chunk-NGW52SHR.js.map} +0 -0
  81. /package/dist/lib/cubing/chunks/{chunk-WAYEJXCG.js.map → chunk-RINY3U6G.js.map} +0 -0
  82. /package/dist/lib/cubing/chunks/{chunk-AVOUJS6N.js.map → chunk-ROB5TROI.js.map} +0 -0
  83. /package/dist/lib/cubing/chunks/{inside-FGQBCNHY.js.map → inside-TJAQBDDY.js.map} +0 -0
  84. /package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-E5KVBK2Y.js.map → search-dynamic-sgs-side-events-GB4WAJ7I.js.map} +0 -0
  85. /package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-IFHNOIEL.js.map → search-dynamic-sgs-unofficial-2CECFBP3.js.map} +0 -0
  86. /package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-OBPW4YC2.js.map → search-dynamic-solve-4x4x4-NRWKTCNT.js.map} +0 -0
  87. /package/dist/lib/cubing/chunks/{search-dynamic-solve-fto-HZREG6ZH.js.map → search-dynamic-solve-fto-UZMNOI6U.js.map} +0 -0
  88. /package/dist/lib/cubing/chunks/{search-dynamic-solve-kilominx-GCNVEBDJ.js.map → search-dynamic-solve-kilominx-CD57C3C4.js.map} +0 -0
  89. /package/dist/lib/cubing/chunks/{twips-OVT324QJ.js.map → twips-YHXBF55O.js.map} +0 -0
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-7GUL3OBQ.js";
4
4
  import {
5
5
  node_adapter_default
6
- } from "./chunk-ZKJKRQKY.js";
6
+ } from "./chunk-XO3JAA3V.js";
7
7
  import {
8
8
  Alg
9
- } from "./chunk-7D7ZUWUK.js";
9
+ } from "./chunk-O6HEZXGY.js";
10
10
 
11
11
  // src/cubing/vendor/apache/comlink-everywhere/outside/index.ts
12
12
  import { wrap } from "comlink";
@@ -16,7 +16,6 @@ async function nodeWorker(source, options) {
16
16
  "node:worker_threads"
17
17
  );
18
18
  const worker = new NodeWorker(source, options);
19
- worker.unref();
20
19
  return node_adapter_default(worker);
21
20
  }
22
21
  async function constructWorker(source, options) {
@@ -93,7 +92,7 @@ async function instantiateModuleWorkerAttempt(workerEntryFileURL, crossOriginTra
93
92
  };
94
93
  const onFirstMessage = (messageData) => {
95
94
  if (messageData === "comlink-exposed") {
96
- resolve(wrapWithTerminate(worker));
95
+ resolve(wrapWithTerminateAndRefs(worker));
97
96
  } else {
98
97
  reject(
99
98
  new Error(`wrong module instantiation message ${messageData}`)
@@ -124,7 +123,7 @@ async function instantiateModuleWorkerDirectlyForBrowser() {
124
123
  };
125
124
  const onFirstMessage = (messageData) => {
126
125
  if (messageData === "comlink-exposed") {
127
- resolve(wrapWithTerminate(worker));
126
+ resolve(wrapWithTerminateAndRefs(worker));
128
127
  } else {
129
128
  reject(
130
129
  new Error(`wrong module instantiation message ${messageData}`)
@@ -142,10 +141,15 @@ async function instantiateModuleWorkerDirectlyForBrowser() {
142
141
  }
143
142
  });
144
143
  }
145
- function wrapWithTerminate(worker) {
144
+ function wrapWithTerminateAndRefs(worker) {
146
145
  const insideAPI = wrap(worker);
147
146
  const terminate = worker.terminate.bind(worker);
148
- return { insideAPI, outsideAPI: { terminate } };
147
+ const nodeWorker2 = worker.nodeWorker;
148
+ const ref = nodeWorker2?.ref?.bind(nodeWorker2) ?? (() => {
149
+ });
150
+ const unref = nodeWorker2?.unref?.bind(nodeWorker2) ?? (() => {
151
+ });
152
+ return { insideAPI, outsideAPI: { terminate, ref, unref } };
149
153
  }
150
154
  var allInsideOutsideAPIPromises = [];
151
155
  async function instantiateWorker() {
@@ -158,11 +162,6 @@ async function instantiateWorker() {
158
162
  );
159
163
  return insideOutsideAPIPromise;
160
164
  }
161
- async function mapToAllWorkers(f) {
162
- await Promise.all(
163
- allInsideOutsideAPIPromises.map((worker) => worker.then(f))
164
- );
165
- }
166
165
  async function instantiateWorkerImplementation() {
167
166
  if (globalThis.location?.protocol === "file:") {
168
167
  console.warn(
@@ -234,9 +233,40 @@ var cachedWorkerInstance;
234
233
  function getCachedWorkerInstance() {
235
234
  return cachedWorkerInstance ??= instantiateWorker();
236
235
  }
236
+ var leases = /* @__PURE__ */ new WeakMap();
237
+ async function leaseRef(api, promiseFn) {
238
+ if (!leases.has(api)) {
239
+ leases.set(api, /* @__PURE__ */ new Set());
240
+ }
241
+ const promise = promiseFn(api);
242
+ const leasesForWorker = leases.get(api);
243
+ leasesForWorker.add(promise);
244
+ api.outsideAPI?.ref?.();
245
+ try {
246
+ return await promise;
247
+ } finally {
248
+ leasesForWorker.delete(promise);
249
+ if (leasesForWorker.size === 0) {
250
+ api.outsideAPI?.unref();
251
+ }
252
+ }
253
+ }
254
+ async function leaseCachedWorkerInstanceRef(promiseFn) {
255
+ return leaseRef(await getCachedWorkerInstance(), promiseFn);
256
+ }
257
+ async function mapToAllWorkers(f) {
258
+ await Promise.all(
259
+ allInsideOutsideAPIPromises.map(async (worker) => {
260
+ await leaseRef(await worker, async (worker2) => f(worker2));
261
+ })
262
+ );
263
+ }
237
264
  async function randomScrambleForEvent(eventID) {
238
265
  const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble ? await instantiateWorker() : await getCachedWorkerInstance();
239
- const scrambleString = await worker.insideAPI.randomScrambleStringForEvent(eventID);
266
+ const scrambleString = await leaseRef(
267
+ worker,
268
+ (worker2) => worker2.insideAPI.randomScrambleStringForEvent(eventID)
269
+ );
240
270
  return Alg.fromString(scrambleString);
241
271
  }
242
272
  async function deriveScrambleForEvent(derivationSeedHex, derivationSaltHierarchy, eventID) {
@@ -244,41 +274,49 @@ async function deriveScrambleForEvent(derivationSeedHex, derivationSaltHierarchy
244
274
  throw new Error("Derived scrambles are not allowed.");
245
275
  }
246
276
  const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble ? await instantiateWorker() : await getCachedWorkerInstance();
247
- const scrambleString = await worker.insideAPI.deriveScrambleStringForEvent(
248
- derivationSeedHex,
249
- derivationSaltHierarchy,
250
- eventID
277
+ const scrambleString = await leaseRef(
278
+ worker,
279
+ (worker2) => worker2.insideAPI.deriveScrambleStringForEvent(
280
+ derivationSeedHex,
281
+ derivationSaltHierarchy,
282
+ eventID
283
+ )
251
284
  );
252
285
  return Alg.fromString(scrambleString);
253
286
  }
254
287
  async function experimentalSolve3x3x3IgnoringCenters(pattern) {
255
- const cwi = await getCachedWorkerInstance();
256
288
  return Alg.fromString(
257
- await cwi.insideAPI.solve333ToString(pattern.patternData)
289
+ await leaseCachedWorkerInstanceRef(
290
+ (cwi) => cwi.insideAPI.solve333ToString(pattern.patternData)
291
+ )
258
292
  );
259
293
  }
260
294
  async function experimentalSolve2x2x2(pattern) {
261
- const cwi = await getCachedWorkerInstance();
262
295
  return Alg.fromString(
263
- await cwi.insideAPI.solve222ToString(pattern.patternData)
296
+ await leaseCachedWorkerInstanceRef(
297
+ (cwi) => cwi.insideAPI.solve222ToString(pattern.patternData)
298
+ )
264
299
  );
265
300
  }
266
301
  async function solveSkewb(pattern) {
267
- const cwi = await getCachedWorkerInstance();
268
302
  return Alg.fromString(
269
- await cwi.insideAPI.solveSkewbToString(pattern.patternData)
303
+ await leaseCachedWorkerInstanceRef(
304
+ (cwi) => cwi.insideAPI.solveSkewbToString(pattern.patternData)
305
+ )
270
306
  );
271
307
  }
272
308
  async function solvePyraminx(pattern) {
273
- const cwi = await getCachedWorkerInstance();
274
309
  return Alg.fromString(
275
- await cwi.insideAPI.solvePyraminxToString(pattern.patternData)
310
+ await leaseCachedWorkerInstanceRef(
311
+ (cwi) => cwi.insideAPI.solvePyraminxToString(pattern.patternData)
312
+ )
276
313
  );
277
314
  }
278
315
  async function solveMegaminx(pattern) {
279
- const cwi = await getCachedWorkerInstance();
280
316
  return Alg.fromString(
281
- await cwi.insideAPI.solveMegaminxToString(pattern.patternData)
317
+ await leaseCachedWorkerInstanceRef(
318
+ (cwi) => cwi.insideAPI.solveMegaminxToString(pattern.patternData)
319
+ )
282
320
  );
283
321
  }
284
322
  async function solveTwips(kpuzzle, pattern, options) {
@@ -292,15 +330,19 @@ async function solveTwips(kpuzzle, pattern, options) {
292
330
  const dedicatedWorker = await instantiateWorker();
293
331
  try {
294
332
  return Alg.fromString(
295
- await dedicatedWorker.insideAPI.solveTwipsToString(
296
- def,
297
- pattern.patternData,
298
- apiOptions
333
+ // TODO: unnecessary because we terminate the worker?
334
+ await leaseRef(
335
+ dedicatedWorker,
336
+ (worker) => worker.insideAPI.solveTwipsToString(
337
+ def,
338
+ pattern.patternData,
339
+ apiOptions
340
+ )
299
341
  )
300
342
  );
301
343
  } finally {
302
344
  console.log("Search ended, terminating dedicated `twips` worker.");
303
- await dedicatedWorker.outsideAPI.terminate();
345
+ dedicatedWorker.outsideAPI.terminate();
304
346
  }
305
347
  }
306
348
  var searchOutsideDebugGlobals = {
@@ -315,11 +357,13 @@ function setSearchDebug(options) {
315
357
  const { logPerf, scramblePrefetchLevel } = options;
316
358
  if (typeof logPerf !== "undefined") {
317
359
  searchOutsideDebugGlobals.logPerf = logPerf;
318
- mapToAllWorkers((worker) => worker.insideAPI.setDebugMeasurePerf(logPerf));
360
+ void mapToAllWorkers(
361
+ (worker) => worker.insideAPI.setDebugMeasurePerf(logPerf)
362
+ );
319
363
  }
320
364
  if (typeof scramblePrefetchLevel !== "undefined") {
321
365
  searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;
322
- mapToAllWorkers(
366
+ void mapToAllWorkers(
323
367
  (worker) => worker.insideAPI.setScramblePrefetchLevel(
324
368
  scramblePrefetchLevel
325
369
  )
@@ -348,4 +392,4 @@ export {
348
392
  solveTwips,
349
393
  setSearchDebug
350
394
  };
351
- //# sourceMappingURL=chunk-XITTJ75E.js.map
395
+ //# sourceMappingURL=chunk-LIVDX4MD.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/cubing/vendor/apache/comlink-everywhere/outside/index.ts", "../../../../src/cubing/search/worker-workarounds/index.ts", "../../../../src/cubing/search/instantiator.ts", "../../../../src/cubing/search/outside.ts"],
4
+ "sourcesContent": ["import nodeEndpoint from \"../node-adapter\";\n\nexport { wrap } from \"comlink\";\n\nconst useNodeWorkarounds =\n typeof globalThis.Worker === \"undefined\" &&\n typeof (globalThis as any).WorkerNavigator === \"undefined\";\n\nasync function nodeWorker(\n source: string | URL,\n options?: { eval?: boolean },\n): Promise<Worker> {\n const { Worker: NodeWorker } = globalThis.process.getBuiltinModule(\n \"node:worker_threads\",\n );\n const worker = new NodeWorker(source, options);\n // worker.unref();\n return nodeEndpoint(worker);\n}\n\nexport async function constructWorker(\n source: string | URL,\n options?: { type?: WorkerType },\n): Promise<Worker> {\n let worker: Worker;\n if (useNodeWorkarounds) {\n return nodeWorker(source);\n } else {\n worker = new globalThis.Worker(source, {\n type: options ? options.type : undefined, // TODO: Is it safe to use `options?.type`?\n });\n }\n return worker;\n}\n", "import { exposeAPI } from \"./worker-guard\";\n\nexport function searchWorkerURLImportMetaResolve(): string {\n // Note:\n // - We have to hardcode the expected path of the entry file in the ESM build, due to lack of `esbuild` support: https://github.com/evanw/esbuild/issues/2866\n // - This URL is based on the assumption that the code from this file ends up in a shared chunk in the `esm` build. This is not guaranteed by `esbuild`, but it consistently happens for our codebase.\n // - We inline the value (instead of using a constant), to maximize compatibility for hardcoded syntax detection in bundlers.\n return import.meta.resolve(\"./search-worker-entry.js\");\n}\n\nexport function searchWorkerURLNewURLImportMetaURL(): URL {\n // Note:\n // - We have to hardcode the expected path of the entry file in the ESM build, due to lack of `esbuild` support: https://github.com/evanw/esbuild/issues/795\n // - This URL is based on the assumption that the code from this file ends up in a shared chunk in the `esm` build. This is not guaranteed by `esbuild`, but it consistently happens for our codebase.\n // - We inline the value (instead of using a constant), to maximize compatibility for hardcoded syntax detection in bundlers.\n return new URL(\"./search-worker-entry.js\", import.meta.url);\n}\n\n// Workaround for `esbuild`: https://github.com/evanw/esbuild/issues/312#issuecomment-1092195778\nexport async function searchWorkerURLEsbuildWorkaround(): Promise<string> {\n exposeAPI.expose = false;\n return (await import(\"./search-worker-entry.js\")).WORKER_ENTRY_FILE_URL;\n}\n\nexport function instantiateSearchWorkerURLNewURLImportMetaURL(): Worker {\n return new Worker(new URL(\"./search-worker-entry.js\", import.meta.url), {\n type: \"module\",\n });\n}\n", "import type { NodeWorker } from \"../vendor/apache/comlink-everywhere/node-adapter\";\nimport {\n constructWorker,\n wrap,\n} from \"../vendor/apache/comlink-everywhere/outside\";\nimport type { WorkerInsideAPI } from \"./inside/api\";\nimport { searchOutsideDebugGlobals } from \"./outside\";\nimport {\n instantiateSearchWorkerURLNewURLImportMetaURL,\n searchWorkerURLEsbuildWorkaround,\n searchWorkerURLImportMetaResolve,\n searchWorkerURLNewURLImportMetaURL,\n} from \"./worker-workarounds\";\n\nexport interface WorkerOutsideAPI {\n terminate: () => void; // `node` can return a `Promise` with an exit code, but we match the web worker API.\n ref: () => void;\n unref: () => void;\n}\n\nexport interface InsideOutsideAPI {\n insideAPI: WorkerInsideAPI;\n outsideAPI: WorkerOutsideAPI;\n}\n\nfunction probablyCrossOrigin(workerEntryFileURL: URL): boolean {\n try {\n const scriptOrigin = globalThis.location?.origin;\n const workerOrigin = workerEntryFileURL.origin;\n return !!scriptOrigin && !!workerOrigin && scriptOrigin !== workerOrigin;\n } catch {\n return false;\n }\n}\n\nasync function instantiateModuleWorker(\n workerEntryFileURL: string | URL,\n): Promise<InsideOutsideAPI> {\n // We need the `import.meta.url` base for `bun`.\n const url = new URL(workerEntryFileURL, import.meta.url);\n const tryTrampolineFirst = probablyCrossOrigin(url);\n try {\n return instantiateModuleWorkerAttempt(url, tryTrampolineFirst);\n } catch {\n return instantiateModuleWorkerAttempt(url, !tryTrampolineFirst);\n }\n}\n\ninterface BunWorker extends Worker {\n unref?: () => void;\n}\n\nasync function instantiateModuleWorkerAttempt(\n workerEntryFileURL: URL,\n crossOriginTrampoline: boolean,\n): Promise<InsideOutsideAPI> {\n // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO\n return new Promise<InsideOutsideAPI>(async (resolve, reject) => {\n try {\n if (!workerEntryFileURL) {\n reject(new Error(\"Could not get worker entry file URL.\"));\n }\n let url: URL = workerEntryFileURL;\n if (crossOriginTrampoline) {\n // Standard browser-like environment.\n const importSrc = `import ${JSON.stringify(\n workerEntryFileURL.toString(),\n )};`;\n const blob = new Blob([importSrc], {\n type: \"text/javascript\",\n });\n url = new URL(URL.createObjectURL(blob));\n }\n\n const worker = (await constructWorker(url, {\n type: \"module\",\n })) as Worker & {\n nodeWorker?: NodeWorker;\n } & BunWorker;\n\n worker.unref?.(); // Unref in `bun`.\n\n const onError = (e: ErrorEvent) => {\n reject(e);\n };\n\n // TODO: Remove this once we can remove the workarounds for lack of `import.meta.resolve(\u2026)` support.\n const onFirstMessage = (messageData: string) => {\n if (messageData === \"comlink-exposed\") {\n // We need to clear the timeout so that we don't prevent `node` from exiting in the meantime.\n resolve(wrapWithTerminateAndRefs(worker));\n } else {\n reject(\n new Error(`wrong module instantiation message ${messageData}`),\n );\n }\n };\n\n if (worker.nodeWorker) {\n // We have to use `once` so the `unref()` from `comlink-everywhere` allows the process to quit as expected.\n worker.nodeWorker.once(\"message\", onFirstMessage);\n } else {\n worker.addEventListener(\"error\", onError, {\n once: true,\n });\n worker.addEventListener(\"message\", (e) => onFirstMessage(e.data), {\n once: true,\n });\n }\n } catch (e) {\n reject(e);\n }\n });\n}\n\n// Maybe some day if we work really hard, this code path can work:\n// - in `node` (https://github.com/nodejs/node/issues/43583#issuecomment-1540025755)\n// - for CDNs (https://github.com/tc39/proposal-module-expressions or https://github.com/whatwg/html/issues/6911)\nexport async function instantiateModuleWorkerDirectlyForBrowser(): Promise<InsideOutsideAPI> {\n // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO\n return new Promise<InsideOutsideAPI>(async (resolve, reject) => {\n try {\n const worker = instantiateSearchWorkerURLNewURLImportMetaURL();\n\n const onError = (e: ErrorEvent) => {\n reject(e);\n };\n\n // TODO: Remove this once we can remove the workarounds for lack of `import.meta.resolve(\u2026)` support.\n const onFirstMessage = (messageData: string) => {\n if (messageData === \"comlink-exposed\") {\n // We need to clear the timeout so that we don't prevent `node` from exiting in the meantime.\n resolve(wrapWithTerminateAndRefs(worker));\n } else {\n reject(\n new Error(`wrong module instantiation message ${messageData}`),\n );\n }\n };\n\n worker.addEventListener(\"error\", onError, {\n once: true,\n });\n worker.addEventListener(\"message\", (e) => onFirstMessage(e.data), {\n once: true,\n });\n } catch (e) {\n reject(e);\n }\n });\n}\n\nfunction wrapWithTerminateAndRefs(worker: Worker): InsideOutsideAPI {\n const insideAPI = wrap<WorkerInsideAPI>(worker);\n const terminate = worker.terminate.bind(worker);\n const nodeWorker = (worker as Worker & { nodeWorker?: NodeWorker })\n .nodeWorker;\n const ref = nodeWorker?.ref?.bind(nodeWorker) ?? (() => {});\n const unref = nodeWorker?.unref?.bind(nodeWorker) ?? (() => {});\n return { insideAPI, outsideAPI: { terminate, ref, unref } };\n}\n\nexport const allInsideOutsideAPIPromises: Promise<InsideOutsideAPI>[] = [];\n\nexport async function instantiateWorker(): Promise<InsideOutsideAPI> {\n const insideOutsideAPIPromise = instantiateWorkerImplementation();\n allInsideOutsideAPIPromises.push(insideOutsideAPIPromise);\n const { insideAPI } = await insideOutsideAPIPromise;\n insideAPI.setDebugMeasurePerf(searchOutsideDebugGlobals.logPerf);\n insideAPI.setScramblePrefetchLevel(\n searchOutsideDebugGlobals.scramblePrefetchLevel,\n );\n return insideOutsideAPIPromise;\n}\n\ntype FallbackStrategyInfo = [\n fn: () => Promise<InsideOutsideAPI>,\n description: string,\n warnOnSuccess: null | string,\n];\n\nasync function instantiateWorkerImplementation(): Promise<InsideOutsideAPI> {\n if (globalThis.location?.protocol === \"file:\") {\n console.warn(\n \"This current web page is loaded from the local filesystem (a URL that starts with `file://`). In this situation, `cubing.js` may be unable to generate scrambles or perform searches in some browsers. See: https://js.cubing.net/cubing/scramble/#file-server-required\",\n );\n }\n\n function failed(methodDescription?: string) {\n return `Module worker instantiation${\n methodDescription ? ` ${methodDescription}` : \"\"\n } failed`;\n }\n\n const importMetaResolveStrategy: FallbackStrategyInfo = [\n async () => instantiateModuleWorker(searchWorkerURLImportMetaResolve()),\n \"using `import.meta.resolve(\u2026)\",\n null,\n ];\n const esbuildWorkaroundStrategy: FallbackStrategyInfo = [\n async () =>\n instantiateModuleWorker(await searchWorkerURLEsbuildWorkaround()),\n \"using the `esbuild` workaround\",\n // TODO: we will hopefully discontinue the `esbuild` workaround at some\n // point, but `esbuild` has been stuck for 3 years on this issue. Because\n // `esbuild` and Vite (which uses `esbuild`) are now dominating the\n // ecosystem, this just causes a warning for a lot of devs/users that they\n // can't do anything about. As frustrating as the situation is, the\n // workaround is semantically fine (even if it's convoluted) and is\n // preserved by `esbuild`-based flows in practice. So we suppress the\n // warning in the medium-term but maintain long-term hope that we can\n // remove it (and the other fallbacks as well).\n null,\n ];\n const newURLStrategy: FallbackStrategyInfo = [\n async () => instantiateModuleWorker(searchWorkerURLNewURLImportMetaURL()),\n \"using `new URL(\u2026, import.meta.url)`\",\n \"will\",\n ];\n const inlineNewURLStrategy: FallbackStrategyInfo = [\n instantiateModuleWorkerDirectlyForBrowser,\n \"using inline `new URL(\u2026, import.meta.url)`\",\n \"may\",\n ];\n\n const fallbackOrder: FallbackStrategyInfo[] =\n searchOutsideDebugGlobals.prioritizeEsbuildWorkaroundForWorkerInstantiation\n ? [\n esbuildWorkaroundStrategy,\n importMetaResolveStrategy,\n newURLStrategy,\n inlineNewURLStrategy,\n ]\n : [\n importMetaResolveStrategy,\n esbuildWorkaroundStrategy,\n newURLStrategy,\n inlineNewURLStrategy,\n ];\n\n for (const [fn, description, warnOnSuccess] of fallbackOrder) {\n try {\n const worker = await fn();\n if (warnOnSuccess) {\n if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {\n console.warn(\n `Module worker instantiation required ${description}. \\`cubing.js\\` ${warnOnSuccess} not support this fallback in the future.`,\n );\n }\n }\n return worker;\n } catch {\n // if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {\n // console.warn(`${failed(description)}, falling back.`);\n // }\n }\n }\n\n throw new Error(`${failed()}. There are no more fallbacks available.`);\n}\n", "import { Alg } from \"../alg\";\nimport type { KPuzzle } from \"../kpuzzle\";\n// import { preInitialize222 } from \"../implementations/2x2x2\";\nimport type { KPattern } from \"../kpuzzle/KPattern\";\nimport type { PrefetchLevel } from \"./inside/api\";\nimport type { TwipsOptions } from \"./inside/solve/twips\";\nimport {\n allInsideOutsideAPIPromises,\n type InsideOutsideAPI,\n instantiateWorker,\n} from \"./instantiator\";\n\nlet cachedWorkerInstance: Promise<InsideOutsideAPI> | undefined;\nfunction getCachedWorkerInstance(): Promise<InsideOutsideAPI> {\n return (cachedWorkerInstance ??= instantiateWorker());\n}\n\n/**\n * `node` has the unfortunate semantics that:\n *\n * - Every message refs a worker.\n * - The process hangs if any reffed worker still exists.\n *\n * And we need workers with pending scrambles to be reffed to avoid\n * https://github.com/cubing/cubing.js/issues/358\n *\n * So we have to carefully track everything that can result in message\n * exchanges, and unref once the line has gone quiet (until reffed again).\n *\n * We don't technically need to ref here (just unref), but we do it because:\n *\n * - it's not hard to do,\n * - it makes the implementation more clear,\n * - it can guard against subtle race conditions to do it here synchronously.\n *\n */\n// TODO: this should be pushed to the comlink layer.\nconst leases: WeakMap<InsideOutsideAPI, Set<Promise<any>>> = new WeakMap();\nasync function leaseRef<T>(\n api: InsideOutsideAPI,\n promiseFn: (api: InsideOutsideAPI) => Promise<T>,\n) {\n if (!leases.has(api)) {\n leases.set(api, new Set());\n }\n const promise = promiseFn(api);\n const leasesForWorker = leases.get(api)!;\n leasesForWorker.add(promise);\n api.outsideAPI?.ref?.();\n try {\n // Note: the `await` is critical here.\n return await promise;\n } finally {\n leasesForWorker.delete(promise);\n if (leasesForWorker.size === 0) {\n api.outsideAPI?.unref();\n }\n }\n}\n\nasync function leaseCachedWorkerInstanceRef<T>(\n promiseFn: (cwi: InsideOutsideAPI) => Promise<T>,\n): Promise<T> {\n // TODO: typing\n return leaseRef((await getCachedWorkerInstance()) as any, promiseFn);\n}\n\nexport async function mapToAllWorkers(\n f: (worker: InsideOutsideAPI) => void,\n): Promise<void> {\n await Promise.all(\n allInsideOutsideAPIPromises.map(async (worker) => {\n await leaseRef(await worker, async (worker) => f(worker));\n }),\n );\n}\n\n// Pre-initialize the scrambler for the given event. (Otherwise, an event is\n// initialized the first time you ask for a scramble for that event.)\n//\n// Some typical numbers for a fast computer:\n// - 3x3x3 initialization: 200ms\n// - Each 3x3x3 scramble: 50ms\n// - 4x4x4 initialization: 2500ms\n// - Each 4x4x4 scramble: 300ms to 800ms\n//\n// It is safe to immediately call for a scramble\n// any time after starting pre-initialization, or to call for them without\n// pre-initializing. Pre-initializing essentially gives the scramble worker a\n// head start in case a scramble doesn't get requested immediately.\n//\n// Note that events cannot be pre-initialized in parallel. Attempting to\n// pre-initialize multiple events will initialize them consecutively. Scrambles\n// for a given event cannot be computed while another event is being initialized.\nexport function _preInitializationHintForEvent(\n eventID: string,\n // callback?: () => void\n): void {\n switch (eventID) {\n case \"333oh\":\n _preInitializationHintForEvent(\"333\");\n return;\n }\n void (async () => {\n await (await getCachedWorkerInstance()).insideAPI.initialize(eventID);\n })();\n}\n\nexport async function randomScrambleForEvent(eventID: string): Promise<Alg> {\n const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble\n ? await instantiateWorker()\n : await getCachedWorkerInstance();\n const scrambleString = await leaseRef(worker, (worker) =>\n worker.insideAPI.randomScrambleStringForEvent(eventID),\n );\n return Alg.fromString(scrambleString);\n}\n\nexport async function deriveScrambleForEvent(\n derivationSeedHex: string,\n derivationSaltHierarchy: string[],\n eventID: string,\n): Promise<Alg> {\n if (!searchOutsideDebugGlobals.allowDerivedScrambles) {\n throw new Error(\"Derived scrambles are not allowed.\");\n }\n const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble\n ? await instantiateWorker()\n : await getCachedWorkerInstance();\n const scrambleString = await leaseRef(worker, (worker) =>\n worker.insideAPI.deriveScrambleStringForEvent(\n derivationSeedHex,\n derivationSaltHierarchy,\n eventID,\n ),\n );\n return Alg.fromString(scrambleString);\n}\n\nexport async function experimentalSolve3x3x3IgnoringCenters(\n pattern: KPattern,\n): Promise<Alg> {\n return Alg.fromString(\n await leaseCachedWorkerInstanceRef((cwi) =>\n cwi.insideAPI.solve333ToString(pattern.patternData),\n ),\n );\n}\n\nexport async function experimentalSolve2x2x2(pattern: KPattern): Promise<Alg> {\n return Alg.fromString(\n await leaseCachedWorkerInstanceRef((cwi) =>\n cwi.insideAPI.solve222ToString(pattern.patternData),\n ),\n );\n}\n\nexport async function solveSkewb(pattern: KPattern): Promise<Alg> {\n return Alg.fromString(\n await leaseCachedWorkerInstanceRef((cwi) =>\n cwi.insideAPI.solveSkewbToString(pattern.patternData),\n ),\n );\n}\n\nexport async function solvePyraminx(pattern: KPattern): Promise<Alg> {\n return Alg.fromString(\n await leaseCachedWorkerInstanceRef((cwi) =>\n cwi.insideAPI.solvePyraminxToString(pattern.patternData),\n ),\n );\n}\n\nexport async function solveMegaminx(pattern: KPattern): Promise<Alg> {\n return Alg.fromString(\n await leaseCachedWorkerInstanceRef((cwi) =>\n cwi.insideAPI.solveMegaminxToString(pattern.patternData),\n ),\n );\n}\n\nexport interface SolveTwipsOptions {\n generatorMoves?: string[];\n targetPattern?: KPattern;\n minDepth?: number;\n maxDepth?: number;\n}\n\nexport async function solveTwips(\n kpuzzle: KPuzzle,\n pattern: KPattern,\n options?: SolveTwipsOptions,\n): Promise<Alg> {\n const { targetPattern, ...otherOptions } = options ?? {};\n const apiOptions: TwipsOptions = otherOptions;\n if (targetPattern) {\n apiOptions.targetPattern = targetPattern.patternData;\n }\n const { ...def } = kpuzzle.definition;\n delete def.experimentalIsPatternSolved;\n // delete def.derivedMoves;\n const dedicatedWorker = await instantiateWorker();\n try {\n return Alg.fromString(\n // TODO: unnecessary because we terminate the worker?\n await leaseRef(dedicatedWorker, (worker) =>\n worker.insideAPI.solveTwipsToString(\n def,\n pattern.patternData,\n apiOptions,\n ),\n ),\n );\n } finally {\n console.log(\"Search ended, terminating dedicated `twips` worker.\");\n // TODO: support re-using the same worker for multiple searches..\n dedicatedWorker.outsideAPI.terminate();\n }\n}\n\ninterface SearchOutsideDebugGlobals {\n logPerf: boolean;\n scramblePrefetchLevel: `${PrefetchLevel}`;\n forceNewWorkerForEveryScramble: boolean;\n showWorkerInstantiationWarnings: boolean;\n // This can prevent a request to `search-worker-entry.js` when it doesn't exist, if the library semantics have been mangled by `esbuild`.\n prioritizeEsbuildWorkaroundForWorkerInstantiation: boolean;\n allowDerivedScrambles: boolean;\n}\n\nexport const searchOutsideDebugGlobals: SearchOutsideDebugGlobals = {\n logPerf: true,\n scramblePrefetchLevel: \"auto\",\n forceNewWorkerForEveryScramble: false,\n showWorkerInstantiationWarnings: true,\n prioritizeEsbuildWorkaroundForWorkerInstantiation: false,\n allowDerivedScrambles: false,\n};\n\nexport function setSearchDebug(\n options: Partial<SearchOutsideDebugGlobals>,\n): void {\n const { logPerf, scramblePrefetchLevel } = options;\n if (typeof logPerf !== \"undefined\") {\n searchOutsideDebugGlobals.logPerf = logPerf;\n void mapToAllWorkers((worker) =>\n worker.insideAPI.setDebugMeasurePerf(logPerf),\n );\n }\n if (typeof scramblePrefetchLevel !== \"undefined\") {\n searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;\n void mapToAllWorkers((worker) =>\n worker.insideAPI.setScramblePrefetchLevel(\n scramblePrefetchLevel as PrefetchLevel,\n ),\n );\n }\n for (const booleanField of [\n \"forceNewWorkerForEveryScramble\",\n \"showWorkerInstantiationWarnings\",\n \"prioritizeEsbuildWorkaroundForWorkerInstantiation\",\n \"allowDerivedScrambles\",\n ] as const) {\n if (booleanField in options) {\n searchOutsideDebugGlobals[booleanField] =\n options[booleanField] ?? searchOutsideDebugGlobals[booleanField];\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAEA,SAAS,YAAY;AAErB,IAAM,qBACJ,OAAO,WAAW,WAAW,eAC7B,OAAQ,WAAmB,oBAAoB;AAEjD,eAAe,WACb,QACA,SACiB;AACjB,QAAM,EAAE,QAAQ,WAAW,IAAI,WAAW,QAAQ;AAAA,IAChD;AAAA,EACF;AACA,QAAM,SAAS,IAAI,WAAW,QAAQ,OAAO;AAE7C,SAAO,qBAAa,MAAM;AAC5B;AAEA,eAAsB,gBACpB,QACA,SACiB;AACjB,MAAI;AACJ,MAAI,oBAAoB;AACtB,WAAO,WAAW,MAAM;AAAA,EAC1B,OAAO;AACL,aAAS,IAAI,WAAW,OAAO,QAAQ;AAAA,MACrC,MAAM,UAAU,QAAQ,OAAO;AAAA;AAAA,IACjC,CAAC;AAAA,EACH;AACA,SAAO;AACT;;;AC/BO,SAAS,mCAA2C;AAKzD,SAAO,YAAY,QAAQ,0BAA0B;AACvD;AAEO,SAAS,qCAA0C;AAKxD,SAAO,IAAI,IAAI,4BAA4B,YAAY,GAAG;AAC5D;AAGA,eAAsB,mCAAoD;AACxE,YAAU,SAAS;AACnB,UAAQ,MA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YAW74.js";
4
4
 
5
5
  // src/cubing/twisty/debug.ts
6
6
  var twistyDebugGlobals = {
@@ -527,7 +527,7 @@ var StatsPanel = class {
527
527
  // src/cubing/twisty/heavy-code-imports/3d.ts
528
528
  var cachedConstructorProxy = null;
529
529
  async function bulk3DCode() {
530
- return cachedConstructorProxy ??= import("./twisty-dynamic-3d-O6UL3R7C.js");
530
+ return cachedConstructorProxy ??= import("./twisty-dynamic-3d-IKE4BUQG.js");
531
531
  }
532
532
 
533
533
  // src/cubing/twisty/views/canvas.ts
@@ -935,11 +935,11 @@ var Twisty3DVantage = class extends ManagedCustomElement {
935
935
  async connectedCallback() {
936
936
  this.addCSS(twisty3DVantageCSS);
937
937
  this.addElement((await this.canvasInfo()).canvas);
938
- this.#onResize();
938
+ void this.#onResize();
939
939
  const observer = new ResizeObserver(this.#onResize.bind(this));
940
940
  observer.observe(this.contentWrapper);
941
- this.orbitControls();
942
- this.#setupBasicPresses();
941
+ void this.orbitControls();
942
+ void this.#setupBasicPresses();
943
943
  this.scheduleRender();
944
944
  }
945
945
  async #setupBasicPresses() {
@@ -998,7 +998,7 @@ var Twisty3DVantage = class extends ManagedCustomElement {
998
998
  camera.aspect = w / h;
999
999
  camera.setViewOffset(w, h - excess, off, yoff, w, h);
1000
1000
  camera.updateProjectionMatrix();
1001
- this.clearCanvas();
1001
+ void this.clearCanvas();
1002
1002
  if (this.rendererIsShared) {
1003
1003
  const canvasInfo = await this.canvasInfo();
1004
1004
  canvasInfo.canvas.width = w * pixelRatio();
@@ -1093,7 +1093,7 @@ var Twisty3DVantage = class extends ManagedCustomElement {
1093
1093
  this.model.twistySceneModel.orbitCoordinates,
1094
1094
  async (orbitCoordinates) => {
1095
1095
  const camera = await this.camera();
1096
- setCameraFromOrbitCoordinates(
1096
+ void setCameraFromOrbitCoordinates(
1097
1097
  camera,
1098
1098
  orbitCoordinates,
1099
1099
  this.options?.backView
@@ -1133,7 +1133,13 @@ var Twisty3DVantage = class extends ManagedCustomElement {
1133
1133
  this.canvasInfo()
1134
1134
  ]);
1135
1135
  if (this.rendererIsShared) {
1136
- renderPooled(this.#width, this.#height, canvas.canvas, scene, camera);
1136
+ await renderPooled(
1137
+ this.#width,
1138
+ this.#height,
1139
+ canvas.canvas,
1140
+ scene,
1141
+ camera
1142
+ );
1137
1143
  } else {
1138
1144
  (await this.renderer()).render(scene, camera);
1139
1145
  }
@@ -1171,4 +1177,4 @@ export {
1171
1177
  Twisty3DVantage,
1172
1178
  bulk3DCode
1173
1179
  };
1174
- //# sourceMappingURL=chunk-3PS5LIPR.js.map
1180
+ //# sourceMappingURL=chunk-LWCBAAHO.js.map