cubing 0.63.5 → 0.63.6

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.
@@ -4,10 +4,10 @@
4
4
  var packageVersion = (
5
5
  // biome-ignore lint/suspicious/noTsIgnore: This comment is stil present in the compiled file, where an error is *not* expected.
6
6
  /** @ts-ignore Populated by `esbuild` at compile time. */
7
- "0.63.5"
7
+ "0.63.6"
8
8
  );
9
9
 
10
10
  export {
11
11
  packageVersion
12
12
  };
13
- //# sourceMappingURL=chunk-22VWCGBC.js.map
13
+ //# sourceMappingURL=chunk-RHJ7ANWU.js.map
package/dist/bin/order.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S node --
2
2
  import {
3
3
  packageVersion
4
- } from "./chunks/chunk-22VWCGBC.js";
4
+ } from "./chunks/chunk-RHJ7ANWU.js";
5
5
 
6
6
  // src/bin/order.ts
7
7
  import { basename } from "node:path";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S node --
2
2
  import {
3
3
  packageVersion
4
- } from "./chunks/chunk-22VWCGBC.js";
4
+ } from "./chunks/chunk-RHJ7ANWU.js";
5
5
 
6
6
  // src/bin/puzzle-geometry-bin.ts
7
7
  import { basename } from "node:path";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S node --
2
2
  import {
3
3
  packageVersion
4
- } from "./chunks/chunk-22VWCGBC.js";
4
+ } from "./chunks/chunk-RHJ7ANWU.js";
5
5
 
6
6
  // src/bin/scramble.ts
7
7
  import { basename } from "node:path";
package/dist/bin/svg.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S node --
2
2
  import {
3
3
  packageVersion
4
- } from "./chunks/chunk-22VWCGBC.js";
4
+ } from "./chunks/chunk-RHJ7ANWU.js";
5
5
 
6
6
  // src/bin/svg.ts
7
7
  import { basename } from "node:path";
@@ -218,7 +218,7 @@ var searchOutsideDebugGlobals = {
218
218
  scramblePrefetchLevel: "auto",
219
219
  forceNewWorkerForEveryScramble: false,
220
220
  forceTwipsForScrambles: false,
221
- showWorkerInstantiationWarnings: true,
221
+ showWorkerInstantiationWarnings: false,
222
222
  prioritizeEsbuildWorkaroundForWorkerInstantiation: false,
223
223
  allowLegacyPatternsForWorkerInstantiation: true,
224
224
  allowDerivedScrambles: false
@@ -265,4 +265,4 @@ export {
265
265
  solveTwips,
266
266
  setSearchDebug
267
267
  };
268
- //# sourceMappingURL=chunk-WMKAKGVZ.js.map
268
+ //# sourceMappingURL=chunk-5KMTA6PX.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cubing/search/worker-workarounds/index.ts", "../../../../src/cubing/search/instantiator.ts", "../../../../src/cubing/search/outside.ts"],
4
- "sourcesContent": ["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 { Worker as NodeWorker } from \"node:worker_threads\";\nimport { PortableWorker, wrap } from \"@cubing/comlink-everywhere\";\nimport type { WorkerAPI } from \"./inside/api\";\nimport { searchOutsideDebugGlobals } from \"./outside\";\nimport {\n searchWorkerURLEsbuildWorkaround,\n searchWorkerURLImportMetaResolve,\n searchWorkerURLNewURLImportMetaURL,\n} from \"./worker-workarounds\";\n\nfunction wrapAPI(worker: Worker | NodeWorker): WorkerAPI {\n return wrap<WorkerAPI>(worker);\n}\n\nasync function instantiateModuleWorker(\n workerEntryFileURL: string | URL,\n): Promise<WorkerAPI> {\n // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO\n return new Promise<WorkerAPI>(async (resolve, reject) => {\n try {\n const worker = new PortableWorker(workerEntryFileURL);\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(wrapAPI(worker));\n } else {\n reject(\n new Error(`wrong module instantiation message ${messageData}`),\n );\n }\n };\n\n const onError = (e: ErrorEvent) => {\n reject(e);\n };\n\n if (\"once\" in worker /* hack to detect `node` */) {\n // We have to use `once` so the `unref()` from `comlink-everywhere` allows the process to quit as expected.\n worker.once(\"message\", onFirstMessage);\n } else {\n worker.addEventListener(\"error\", onError, {\n once: true,\n });\n worker.addEventListener(\n \"message\",\n (e: MessageEvent) => onFirstMessage(e.data),\n {\n once: true,\n },\n );\n }\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport const allWorkerAPIPromises: Promise<WorkerAPI>[] = [];\n\nexport async function instantiateWorkerAPI(): Promise<WorkerAPI> {\n const workerAPIPromise = instantiateWorkerImplementation();\n allWorkerAPIPromises.push(workerAPIPromise);\n const insideAPI = await workerAPIPromise;\n insideAPI.setDebugMeasurePerf(searchOutsideDebugGlobals.logPerf);\n insideAPI.setDebugForceTwipsForScrambles(\n searchOutsideDebugGlobals.forceTwipsForScrambles,\n );\n insideAPI.setScramblePrefetchLevel(\n searchOutsideDebugGlobals.scramblePrefetchLevel,\n );\n return workerAPIPromise;\n}\n\ntype FallbackStrategyInfo = [\n fn: () => Promise<WorkerAPI>,\n description: string,\n warnOnSuccess: null | string,\n];\n\nfunction fallbackOrder(): FallbackStrategyInfo[] {\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\n if (!searchOutsideDebugGlobals.allowLegacyPatternsForWorkerInstantiation) {\n return [importMetaResolveStrategy];\n }\n if (\n searchOutsideDebugGlobals.prioritizeEsbuildWorkaroundForWorkerInstantiation\n ) {\n return [\n esbuildWorkaroundStrategy,\n importMetaResolveStrategy,\n newURLStrategy,\n ];\n }\n return [importMetaResolveStrategy, esbuildWorkaroundStrategy, newURLStrategy];\n}\n\nasync function instantiateWorkerImplementation(): Promise<WorkerAPI> {\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 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 (e) {\n if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {\n console.warn(`${failed(description)}, falling back.`, e);\n }\n }\n }\n\n throw new Error(\n `Module worker instantiation failed. There are no more fallbacks available.`,\n );\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, WorkerAPI } from \"./inside/api\";\nimport type { TwipsOptions } from \"./inside/solve/twips\";\nimport { allWorkerAPIPromises, instantiateWorkerAPI } from \"./instantiator\";\n\nlet cachedWorkerInstance: Promise<WorkerAPI> | undefined;\nfunction getCachedWorkerInstance(): Promise<WorkerAPI> {\n return (cachedWorkerInstance ??= instantiateWorkerAPI());\n}\n\nexport async function mapToAllWorkers(\n f: (worker: WorkerAPI) => void,\n): Promise<void> {\n await Promise.all(\n allWorkerAPIPromises.map(async (worker) => {\n f(await 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()).initialize(eventID);\n })();\n}\n\nexport async function randomScrambleForEvent(eventID: string): Promise<Alg> {\n const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble\n ? await instantiateWorkerAPI()\n : await getCachedWorkerInstance();\n const scrambleString = await worker.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 instantiateWorkerAPI()\n : await getCachedWorkerInstance();\n const scrambleString = await worker.deriveScrambleStringForEvent(\n derivationSeedHex,\n derivationSaltHierarchy,\n eventID,\n );\n return Alg.fromString(scrambleString);\n}\n\nexport async function experimentalSolve3x3x3IgnoringCenters(\n pattern: KPattern,\n): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solve333ToString(pattern.patternData));\n}\n\nexport async function experimentalSolve2x2x2(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solve222ToString(pattern.patternData));\n}\n\nexport async function solveSkewb(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solveSkewbToString(pattern.patternData));\n}\n\nexport async function solvePyraminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solvePyraminxToString(pattern.patternData));\n}\n\nexport async function solveMegaminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solveMegaminxToString(pattern.patternData));\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 instantiateWorkerAPI();\n try {\n return Alg.fromString(\n // TODO: unnecessary because we terminate the worker?\n await dedicatedWorker.solveTwipsToString(\n def,\n pattern.patternData,\n apiOptions,\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.terminate?.(); // TODO\n }\n}\n\ninterface SearchOutsideDebugGlobals {\n logPerf: boolean;\n scramblePrefetchLevel: `${PrefetchLevel}`;\n forceNewWorkerForEveryScramble: boolean;\n showWorkerInstantiationWarnings: boolean;\n forceTwipsForScrambles: boolean;\n // Allow fallbacks from `import.meta.resolve(\u2026)`.\n allowLegacyPatternsForWorkerInstantiation: 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 forceTwipsForScrambles: false,\n showWorkerInstantiationWarnings: true,\n prioritizeEsbuildWorkaroundForWorkerInstantiation: false,\n allowLegacyPatternsForWorkerInstantiation: true,\n allowDerivedScrambles: false,\n};\n\nexport function setSearchDebug(\n options: Partial<SearchOutsideDebugGlobals>,\n): void {\n const { logPerf, forceTwipsForScrambles, scramblePrefetchLevel } = options;\n if (typeof logPerf !== \"undefined\") {\n searchOutsideDebugGlobals.logPerf = logPerf;\n void mapToAllWorkers((worker) => worker.setDebugMeasurePerf(logPerf));\n }\n if (typeof forceTwipsForScrambles !== \"undefined\") {\n searchOutsideDebugGlobals.forceTwipsForScrambles = forceTwipsForScrambles;\n void mapToAllWorkers((worker) =>\n worker.setDebugMeasurePerf(forceTwipsForScrambles),\n );\n }\n if (typeof scramblePrefetchLevel !== \"undefined\") {\n searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;\n void mapToAllWorkers((worker) =>\n worker.setScramblePrefetchLevel(scramblePrefetchLevel as PrefetchLevel),\n );\n }\n for (const booleanField of [\n \"forceNewWorkerForEveryScramble\",\n \"showWorkerInstantiationWarnings\",\n \"prioritizeEsbuildWorkaroundForWorkerInstantiation\",\n \"allowLegacyPatternsForWorkerInstantiation\",\n \"allowDerivedScrambles\",\n ] as const) {\n if (booleanField in options) {\n searchOutsideDebugGlobals[booleanField] =\n options[booleanField] ?? searchOutsideDebugGlobals[booleanField];\n }\n }\n}\n"],
4
+ "sourcesContent": ["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 { Worker as NodeWorker } from \"node:worker_threads\";\nimport { PortableWorker, wrap } from \"@cubing/comlink-everywhere\";\nimport type { WorkerAPI } from \"./inside/api\";\nimport { searchOutsideDebugGlobals } from \"./outside\";\nimport {\n searchWorkerURLEsbuildWorkaround,\n searchWorkerURLImportMetaResolve,\n searchWorkerURLNewURLImportMetaURL,\n} from \"./worker-workarounds\";\n\nfunction wrapAPI(worker: Worker | NodeWorker): WorkerAPI {\n return wrap<WorkerAPI>(worker);\n}\n\nasync function instantiateModuleWorker(\n workerEntryFileURL: string | URL,\n): Promise<WorkerAPI> {\n // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO\n return new Promise<WorkerAPI>(async (resolve, reject) => {\n try {\n const worker = new PortableWorker(workerEntryFileURL);\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(wrapAPI(worker));\n } else {\n reject(\n new Error(`wrong module instantiation message ${messageData}`),\n );\n }\n };\n\n const onError = (e: ErrorEvent) => {\n reject(e);\n };\n\n if (\"once\" in worker /* hack to detect `node` */) {\n // We have to use `once` so the `unref()` from `comlink-everywhere` allows the process to quit as expected.\n worker.once(\"message\", onFirstMessage);\n } else {\n worker.addEventListener(\"error\", onError, {\n once: true,\n });\n worker.addEventListener(\n \"message\",\n (e: MessageEvent) => onFirstMessage(e.data),\n {\n once: true,\n },\n );\n }\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport const allWorkerAPIPromises: Promise<WorkerAPI>[] = [];\n\nexport async function instantiateWorkerAPI(): Promise<WorkerAPI> {\n const workerAPIPromise = instantiateWorkerImplementation();\n allWorkerAPIPromises.push(workerAPIPromise);\n const insideAPI = await workerAPIPromise;\n insideAPI.setDebugMeasurePerf(searchOutsideDebugGlobals.logPerf);\n insideAPI.setDebugForceTwipsForScrambles(\n searchOutsideDebugGlobals.forceTwipsForScrambles,\n );\n insideAPI.setScramblePrefetchLevel(\n searchOutsideDebugGlobals.scramblePrefetchLevel,\n );\n return workerAPIPromise;\n}\n\ntype FallbackStrategyInfo = [\n fn: () => Promise<WorkerAPI>,\n description: string,\n warnOnSuccess: null | string,\n];\n\nfunction fallbackOrder(): FallbackStrategyInfo[] {\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\n if (!searchOutsideDebugGlobals.allowLegacyPatternsForWorkerInstantiation) {\n return [importMetaResolveStrategy];\n }\n if (\n searchOutsideDebugGlobals.prioritizeEsbuildWorkaroundForWorkerInstantiation\n ) {\n return [\n esbuildWorkaroundStrategy,\n importMetaResolveStrategy,\n newURLStrategy,\n ];\n }\n return [importMetaResolveStrategy, esbuildWorkaroundStrategy, newURLStrategy];\n}\n\nasync function instantiateWorkerImplementation(): Promise<WorkerAPI> {\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 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 (e) {\n if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {\n console.warn(`${failed(description)}, falling back.`, e);\n }\n }\n }\n\n throw new Error(\n `Module worker instantiation failed. There are no more fallbacks available.`,\n );\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, WorkerAPI } from \"./inside/api\";\nimport type { TwipsOptions } from \"./inside/solve/twips\";\nimport { allWorkerAPIPromises, instantiateWorkerAPI } from \"./instantiator\";\n\nlet cachedWorkerInstance: Promise<WorkerAPI> | undefined;\nfunction getCachedWorkerInstance(): Promise<WorkerAPI> {\n return (cachedWorkerInstance ??= instantiateWorkerAPI());\n}\n\nexport async function mapToAllWorkers(\n f: (worker: WorkerAPI) => void,\n): Promise<void> {\n await Promise.all(\n allWorkerAPIPromises.map(async (worker) => {\n f(await 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()).initialize(eventID);\n })();\n}\n\nexport async function randomScrambleForEvent(eventID: string): Promise<Alg> {\n const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble\n ? await instantiateWorkerAPI()\n : await getCachedWorkerInstance();\n const scrambleString = await worker.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 instantiateWorkerAPI()\n : await getCachedWorkerInstance();\n const scrambleString = await worker.deriveScrambleStringForEvent(\n derivationSeedHex,\n derivationSaltHierarchy,\n eventID,\n );\n return Alg.fromString(scrambleString);\n}\n\nexport async function experimentalSolve3x3x3IgnoringCenters(\n pattern: KPattern,\n): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solve333ToString(pattern.patternData));\n}\n\nexport async function experimentalSolve2x2x2(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solve222ToString(pattern.patternData));\n}\n\nexport async function solveSkewb(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solveSkewbToString(pattern.patternData));\n}\n\nexport async function solvePyraminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solvePyraminxToString(pattern.patternData));\n}\n\nexport async function solveMegaminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(await cwi.solveMegaminxToString(pattern.patternData));\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 instantiateWorkerAPI();\n try {\n return Alg.fromString(\n // TODO: unnecessary because we terminate the worker?\n await dedicatedWorker.solveTwipsToString(\n def,\n pattern.patternData,\n apiOptions,\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.terminate?.(); // TODO\n }\n}\n\ninterface SearchOutsideDebugGlobals {\n logPerf: boolean;\n scramblePrefetchLevel: `${PrefetchLevel}`;\n forceNewWorkerForEveryScramble: boolean;\n showWorkerInstantiationWarnings: boolean;\n forceTwipsForScrambles: boolean;\n // Allow fallbacks from `import.meta.resolve(\u2026)`.\n allowLegacyPatternsForWorkerInstantiation: 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 forceTwipsForScrambles: false,\n showWorkerInstantiationWarnings: false,\n prioritizeEsbuildWorkaroundForWorkerInstantiation: false,\n allowLegacyPatternsForWorkerInstantiation: true,\n allowDerivedScrambles: false,\n};\n\nexport function setSearchDebug(\n options: Partial<SearchOutsideDebugGlobals>,\n): void {\n const { logPerf, forceTwipsForScrambles, scramblePrefetchLevel } = options;\n if (typeof logPerf !== \"undefined\") {\n searchOutsideDebugGlobals.logPerf = logPerf;\n void mapToAllWorkers((worker) => worker.setDebugMeasurePerf(logPerf));\n }\n if (typeof forceTwipsForScrambles !== \"undefined\") {\n searchOutsideDebugGlobals.forceTwipsForScrambles = forceTwipsForScrambles;\n void mapToAllWorkers((worker) =>\n worker.setDebugMeasurePerf(forceTwipsForScrambles),\n );\n }\n if (typeof scramblePrefetchLevel !== \"undefined\") {\n searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;\n void mapToAllWorkers((worker) =>\n worker.setScramblePrefetchLevel(scramblePrefetchLevel as PrefetchLevel),\n );\n }\n for (const booleanField of [\n \"forceNewWorkerForEveryScramble\",\n \"showWorkerInstantiationWarnings\",\n \"prioritizeEsbuildWorkaroundForWorkerInstantiation\",\n \"allowLegacyPatternsForWorkerInstantiation\",\n \"allowDerivedScrambles\",\n ] as const) {\n if (booleanField in options) {\n searchOutsideDebugGlobals[booleanField] =\n options[booleanField] ?? searchOutsideDebugGlobals[booleanField];\n }\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;AAEO,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,MAAM,OAAO,0BAA0B,GAAG;AACpD;;;ACZA,SAAS,QAAQ,QAAwC;AACvD,SAAO,KAAgB,MAAM;AAC/B;AAEA,eAAe,wBACb,oBACoB;AAEpB,SAAO,IAAI,QAAmB,OAAO,SAAS,WAAW;AACvD,QAAI;AACF,YAAM,SAAS,IAAI,eAAe,kBAAkB;AAGpD,YAAM,iBAAiB,CAAC,gBAAwB;AAC9C,YAAI,gBAAgB,mBAAmB;AAErC,kBAAQ,QAAQ,MAAM,CAAC;AAAA,QACzB,OAAO;AACL;AAAA,YACE,IAAI,MAAM,sCAAsC,WAAW,EAAE;AAAA,UAC/D;AAAA,QACF;AAAA,MACF;AAEA,YAAM,UAAU,CAAC,MAAkB;AACjC,eAAO,CAAC;AAAA,MACV;AAEA,UAAI,UAAU,QAAoC;AAEhD,eAAO,KAAK,WAAW,cAAc;AAAA,MACvC,OAAO;AACL,eAAO,iBAAiB,SAAS,SAAS;AAAA,UACxC,MAAM;AAAA,QACR,CAAC;AACD,eAAO;AAAA,UACL;AAAA,UACA,CAAC,MAAoB,eAAe,EAAE,IAAI;AAAA,UAC1C;AAAA,YACE,MAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,GAAG;AACV,aAAO,CAAC;AAAA,IACV;AAAA,EACF,CAAC;AACH;AAEO,IAAM,uBAA6C,CAAC;AAE3D,eAAsB,uBAA2C;AAC/D,QAAM,mBAAmB,gCAAgC;AACzD,uBA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AAI,OAAO,0BAA0B,aAAa;AAChD,8BAA0B,wBAAwB;AAClD,SAAK;AAAA,MAAgB,CAAC,WACpB,OAAO,yBAAyB,qBAAsC;AAAA,IACxE;AAAA,EACF;AACA,aAAW,gBAAgB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAY;AACV,QAAI,gBAAgB,SAAS;AAC3B,gCAA0B,YAAY,IACpC,QAAQ,YAAY,KAAK,0BAA0B,YAAY;AAAA,IACnE;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -213,7 +213,7 @@ async function solve222(pattern) {
213
213
 
214
214
  // src/cubing/search/inside/solve/puzzles/dynamic/4x4x4/index.ts
215
215
  var dynamic4x4x4Solver = new LazyPromise(
216
- () => import("./search-dynamic-solve-4x4x4-KIH4YATU.js")
216
+ () => import("./search-dynamic-solve-4x4x4-BGV4AJVT.js")
217
217
  );
218
218
 
219
219
  // src/cubing/search/inside/solve/puzzles/4x4x4.ts
@@ -589,4 +589,4 @@ var insideAPI = {
589
589
 
590
590
  // src/cubing/search/inside/index.ts
591
591
  expose(insideAPI);
592
- //# sourceMappingURL=inside-LSPIPZY2.js.map
592
+ //# sourceMappingURL=inside-JAJOK2MI.js.map
@@ -1,5 +1,5 @@
1
1
  import "./chunk-NAPITA3L.js";
2
- import "./chunk-WMKAKGVZ.js";
2
+ import "./chunk-5KMTA6PX.js";
3
3
  import {
4
4
  random333Scramble
5
5
  } from "./chunk-H5KMIDAF.js";
@@ -2920,4 +2920,4 @@ export {
2920
2920
  initialize,
2921
2921
  random444Scramble
2922
2922
  };
2923
- //# sourceMappingURL=search-dynamic-solve-4x4x4-KIH4YATU.js.map
2923
+ //# sourceMappingURL=search-dynamic-solve-4x4x4-BGV4AJVT.js.map
@@ -4,7 +4,7 @@ import {
4
4
 
5
5
  // src/cubing/search/worker-workarounds/search-worker-entry.js
6
6
  if (exposeAPI.expose) {
7
- void import("./inside-LSPIPZY2.js").then(() => {
7
+ void import("./inside-JAJOK2MI.js").then(() => {
8
8
  if (globalThis.postMessage) {
9
9
  globalThis.postMessage("comlink-exposed");
10
10
  } else {
@@ -2,7 +2,7 @@ import "../chunks/chunk-NAPITA3L.js";
2
2
  import {
3
3
  deriveScrambleForEvent,
4
4
  randomScrambleForEvent
5
- } from "../chunks/chunk-WMKAKGVZ.js";
5
+ } from "../chunks/chunk-5KMTA6PX.js";
6
6
  import "../chunks/chunk-H5KMIDAF.js";
7
7
  import "../chunks/chunk-7GUL3OBQ.js";
8
8
  import "../chunks/chunk-FUAADKXE.js";
@@ -6,7 +6,7 @@ import {
6
6
  solvePyraminx,
7
7
  solveSkewb,
8
8
  solveTwips
9
- } from "../chunks/chunk-WMKAKGVZ.js";
9
+ } from "../chunks/chunk-5KMTA6PX.js";
10
10
  import {
11
11
  random333Pattern
12
12
  } from "../chunks/chunk-H5KMIDAF.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cubing",
3
- "version": "0.63.5",
3
+ "version": "0.63.6",
4
4
  "description": "A collection of JavaScript cubing libraries.",
5
5
  "author": "The js.cubing.net team",
6
6
  "license": "MPL-2.0 OR GPL-3.0-or-later",