cubing 0.59.0 → 0.59.2
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/dist/bin/scramble.js +4 -2
- package/dist/bin/scramble.js.map +2 -2
- package/dist/lib/cubing/chunks/{chunk-I4OWC23M.js → chunk-2HSEQ2FC.js} +2 -4
- package/dist/lib/cubing/chunks/{chunk-I4OWC23M.js.map → chunk-2HSEQ2FC.js.map} +2 -2
- package/dist/lib/cubing/chunks/{chunk-RDSQRW3G.js → chunk-NX2Q6B7Y.js} +11 -8
- package/dist/lib/cubing/chunks/chunk-NX2Q6B7Y.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-6WYRN27C.js → chunk-REBGU5ET.js} +3 -5
- package/dist/lib/cubing/chunks/{chunk-6WYRN27C.js.map → chunk-REBGU5ET.js.map} +2 -2
- package/dist/lib/cubing/chunks/{inside-4ARWPJBB.js → inside-NS3PIQ5Z.js} +4 -4
- package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-AS5AIKBC.js → search-dynamic-solve-4x4x4-GNM5XEZR.js} +3 -3
- package/dist/lib/cubing/chunks/search-worker-entry.js +3 -3
- package/dist/lib/cubing/{index-DsFKu-dM.d.ts → index-B28YEQVF.d.ts} +0 -1
- package/dist/lib/cubing/scramble/index.d.ts +1 -1
- package/dist/lib/cubing/scramble/index.js +2 -2
- package/dist/lib/cubing/search/index.d.ts +1 -1
- package/dist/lib/cubing/search/index.js +2 -2
- package/package.json +1 -1
- package/dist/lib/cubing/chunks/chunk-RDSQRW3G.js.map +0 -7
- /package/dist/lib/cubing/chunks/{inside-4ARWPJBB.js.map → inside-NS3PIQ5Z.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-AS5AIKBC.js.map → search-dynamic-solve-4x4x4-GNM5XEZR.js.map} +0 -0
package/dist/bin/scramble.js
CHANGED
|
@@ -153,8 +153,10 @@ ${scrambleText(scramble)}
|
|
|
153
153
|
}
|
|
154
154
|
jsonListPrinter?.finish();
|
|
155
155
|
}
|
|
156
|
-
(await import("node:process")).exit(0);
|
|
157
156
|
}
|
|
158
157
|
});
|
|
159
|
-
|
|
158
|
+
function nodeForgetTopLevelAwaitWorkaround(_promise) {
|
|
159
|
+
return Promise.resolve();
|
|
160
|
+
}
|
|
161
|
+
await nodeForgetTopLevelAwaitWorkaround(run(binary(app), process.argv));
|
|
160
162
|
//# sourceMappingURL=scramble.js.map
|
package/dist/bin/scramble.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/bin/scramble.ts"],
|
|
4
|
-
"sourcesContent": ["// To run this file directly:\n// bun run src/bin/scramble.ts -- 333\n\n// TODO: completions for `bash`, `zsh`, and `fish`: https://github.com/loilo/completarr\n\n// Important! We import this instead of inlining, because `esbuild` preserves import order semantics but hoists imports above any code inlined here.\n\nimport type { Alg } from \"cubing/alg\";\nimport { eventInfo } from \"cubing/puzzles\";\nimport { randomScrambleForEvent } from \"cubing/scramble\";\nimport { setSearchDebug } from \"cubing/search\";\nimport \"./guards/cmd-ts-too-guard\";\n\nconst {\n binary,\n number: cmdNumber,\n string: cmdString,\n command,\n flag,\n oneOf,\n option,\n optional,\n positional,\n run,\n} = await import(\"cmd-ts-too\");\n\n// TODO: file an issue about printing these values.\nconst outputFormats = [\"text\", \"link\", \"json-text\"] as const;\nconst notationTypes = [\"auto\", \"LGN\"] as const;\n\nconst app = command({\n name: \"scramble\",\n args: {\n amount: option({\n description: \"Amount of scrambles\",\n type: cmdNumber,\n long: \"amount\",\n short: \"n\",\n defaultValue: () => 1,\n defaultValueIsSerializable: true,\n }),\n format: option({\n description: `Output format. One of: ${outputFormats.join(\", \")}`,\n type: optional(oneOf(outputFormats)),\n long: \"format\",\n short: \"f\",\n }),\n notation: option({\n description: `Notation type. One of: ${notationTypes.join(\", \")}`,\n type: optional(oneOf([\"auto\", \"LGN\"])),\n long: \"notation\",\n }),\n text: flag({\n description: \"Convenient shorthand for `--format text`.\",\n long: \"t\", // TODO: https://github.com/lgarron/cmd-ts-too/issues/6\n short: \"t\",\n }),\n eventID: positional({\n type: cmdString,\n displayName: \"WCA or unofficial event ID\",\n }),\n },\n handler: async ({ amount, format: argsFormat, notation, text, eventID }) => {\n const format =\n argsFormat ?? (text || !process.stdout.isTTY ? \"text\" : \"auto\");\n\n setSearchDebug({ logPerf: false, showWorkerInstantiationWarnings: false });\n\n function scrambleText(scramble: Alg): string {\n return scramble.toString({\n // TODO: any\n notation: notation as (typeof notationTypes)[number], // TODO: handle type conversion at arg parse time.\n });\n }\n\n function scrambleLink(scramble: Alg): string {\n const url = new URL(\"https://alpha.twizzle.net/edit/\");\n const puzzleID = eventInfo(eventID)?.puzzleID;\n puzzleID && url.searchParams.set(\"puzzle\", puzzleID);\n url.searchParams.set(\"alg\", scrambleText(scramble));\n return url.toString();\n }\n\n class JSONListPrinter<T> {\n #finished = false;\n #firstValuePrintedAlready = false;\n constructor() {\n process.stdout.write(\"[\\n \");\n }\n\n push(value: T) {\n if (this.#firstValuePrintedAlready) {\n process.stdout.write(\",\\n \");\n }\n this.#firstValuePrintedAlready = true;\n process.stdout.write(JSON.stringify(value));\n }\n\n finish() {\n if (this.#finished) {\n throw new Error(\"Tried to finish JSON list printing multiple times.\");\n }\n this.#finished = true;\n console.log(\"\\n]\");\n }\n }\n\n if (format !== \"json-text\" && amount === 1) {\n const scramble = await randomScrambleForEvent(eventID);\n\n switch (format) {\n case \"text\": {\n console.log(scrambleText(scramble));\n break;\n }\n case \"link\": {\n console.log(scrambleLink(scramble));\n break;\n }\n // @ts-expect-error This is a code guard for future refactoring.\n case \"json-text\": {\n throw new Error(\n \"Encountered `json` format in code that is not expected to handle it.\",\n );\n }\n case \"auto\": {\n console.log(`${scrambleText(scramble)}\n\n\uD83D\uDD17 ${scrambleLink(scramble)}`);\n break;\n }\n default: {\n throw new Error(\"Unknown format!\");\n }\n }\n } else {\n const jsonListPrinter: JSONListPrinter<string> | undefined =\n format === \"json-text\" ? new JSONListPrinter() : undefined;\n for (let i = 0; i < amount; i++) {\n const scramble = await randomScrambleForEvent(eventID);\n switch (format) {\n case \"text\": {\n console.log(`// Scramble #${i + 1}`);\n console.log(`${scrambleText(scramble)}\\n`);\n break;\n }\n case \"link\": {\n console.log(`// Scramble #${i + 1}`);\n console.log(`${scrambleLink(scramble)}\\n`);\n break;\n }\n case \"json-text\": {\n jsonListPrinter?.push(scramble.toString());\n break;\n }\n case \"auto\": {\n console.log(`// Scramble #${i + 1}\n${scrambleText(scramble)}\n\n\uD83D\uDD17 ${scrambleLink(scramble)}\n`);\n break;\n }\n default: {\n throw new Error(\"Unknown format!\");\n }\n }\n }\n jsonListPrinter?.finish();\n }\n\n
|
|
5
|
-
"mappings": ";;;;AAQA,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAG/B,IAAM;AAAA,EACJ;AAAA,EACA,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAI,MAAM,OAAO,YAAY;AAG7B,IAAM,gBAAgB,CAAC,QAAQ,QAAQ,WAAW;AAClD,IAAM,gBAAgB,CAAC,QAAQ,KAAK;AAEpC,IAAM,MAAM,QAAQ;AAAA,EAClB,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,QAAQ,OAAO;AAAA,MACb,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO;AAAA,MACP,cAAc,MAAM;AAAA,MACpB,4BAA4B;AAAA,IAC9B,CAAC;AAAA,IACD,QAAQ,OAAO;AAAA,MACb,aAAa,0BAA0B,cAAc,KAAK,IAAI,CAAC;AAAA,MAC/D,MAAM,SAAS,MAAM,aAAa,CAAC;AAAA,MACnC,MAAM;AAAA,MACN,OAAO;AAAA,IACT,CAAC;AAAA,IACD,UAAU,OA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AAA,EAC3C,aAAa,QAAQ,CAAC;AAAA;AAAA,YAEnB,aAAa,QAAQ,CAAC;AAAA,CAC1B;AACW;AAAA,UACF;AAAA,UACA,SAAS;AACP,kBAAM,IAAI,MAAM,iBAAiB;AAAA,UACnC;AAAA,QACF;AAAA,MACF;AACA,uBAAiB,OAAO;AAAA,IAC1B;
|
|
4
|
+
"sourcesContent": ["// To run this file directly:\n// bun run src/bin/scramble.ts -- 333\n\n// TODO: completions for `bash`, `zsh`, and `fish`: https://github.com/loilo/completarr\n\n// Important! We import this instead of inlining, because `esbuild` preserves import order semantics but hoists imports above any code inlined here.\n\nimport type { Alg } from \"cubing/alg\";\nimport { eventInfo } from \"cubing/puzzles\";\nimport { randomScrambleForEvent } from \"cubing/scramble\";\nimport { setSearchDebug } from \"cubing/search\";\nimport \"./guards/cmd-ts-too-guard\";\n\nconst {\n binary,\n number: cmdNumber,\n string: cmdString,\n command,\n flag,\n oneOf,\n option,\n optional,\n positional,\n run,\n} = await import(\"cmd-ts-too\");\n\n// TODO: file an issue about printing these values.\nconst outputFormats = [\"text\", \"link\", \"json-text\"] as const;\nconst notationTypes = [\"auto\", \"LGN\"] as const;\n\nconst app = command({\n name: \"scramble\",\n args: {\n amount: option({\n description: \"Amount of scrambles\",\n type: cmdNumber,\n long: \"amount\",\n short: \"n\",\n defaultValue: () => 1,\n defaultValueIsSerializable: true,\n }),\n format: option({\n description: `Output format. One of: ${outputFormats.join(\", \")}`,\n type: optional(oneOf(outputFormats)),\n long: \"format\",\n short: \"f\",\n }),\n notation: option({\n description: `Notation type. One of: ${notationTypes.join(\", \")}`,\n type: optional(oneOf([\"auto\", \"LGN\"])),\n long: \"notation\",\n }),\n text: flag({\n description: \"Convenient shorthand for `--format text`.\",\n long: \"t\", // TODO: https://github.com/lgarron/cmd-ts-too/issues/6\n short: \"t\",\n }),\n eventID: positional({\n type: cmdString,\n displayName: \"WCA or unofficial event ID\",\n }),\n },\n handler: async ({ amount, format: argsFormat, notation, text, eventID }) => {\n const format =\n argsFormat ?? (text || !process.stdout.isTTY ? \"text\" : \"auto\");\n\n setSearchDebug({ logPerf: false, showWorkerInstantiationWarnings: false });\n\n function scrambleText(scramble: Alg): string {\n return scramble.toString({\n // TODO: any\n notation: notation as (typeof notationTypes)[number], // TODO: handle type conversion at arg parse time.\n });\n }\n\n function scrambleLink(scramble: Alg): string {\n const url = new URL(\"https://alpha.twizzle.net/edit/\");\n const puzzleID = eventInfo(eventID)?.puzzleID;\n puzzleID && url.searchParams.set(\"puzzle\", puzzleID);\n url.searchParams.set(\"alg\", scrambleText(scramble));\n return url.toString();\n }\n\n class JSONListPrinter<T> {\n #finished = false;\n #firstValuePrintedAlready = false;\n constructor() {\n process.stdout.write(\"[\\n \");\n }\n\n push(value: T) {\n if (this.#firstValuePrintedAlready) {\n process.stdout.write(\",\\n \");\n }\n this.#firstValuePrintedAlready = true;\n process.stdout.write(JSON.stringify(value));\n }\n\n finish() {\n if (this.#finished) {\n throw new Error(\"Tried to finish JSON list printing multiple times.\");\n }\n this.#finished = true;\n console.log(\"\\n]\");\n }\n }\n\n if (format !== \"json-text\" && amount === 1) {\n const scramble = await randomScrambleForEvent(eventID);\n\n switch (format) {\n case \"text\": {\n console.log(scrambleText(scramble));\n break;\n }\n case \"link\": {\n console.log(scrambleLink(scramble));\n break;\n }\n // @ts-expect-error This is a code guard for future refactoring.\n case \"json-text\": {\n throw new Error(\n \"Encountered `json` format in code that is not expected to handle it.\",\n );\n }\n case \"auto\": {\n console.log(`${scrambleText(scramble)}\n\n\uD83D\uDD17 ${scrambleLink(scramble)}`);\n break;\n }\n default: {\n throw new Error(\"Unknown format!\");\n }\n }\n } else {\n const jsonListPrinter: JSONListPrinter<string> | undefined =\n format === \"json-text\" ? new JSONListPrinter() : undefined;\n for (let i = 0; i < amount; i++) {\n const scramble = await randomScrambleForEvent(eventID);\n switch (format) {\n case \"text\": {\n console.log(`// Scramble #${i + 1}`);\n console.log(`${scrambleText(scramble)}\\n`);\n break;\n }\n case \"link\": {\n console.log(`// Scramble #${i + 1}`);\n console.log(`${scrambleLink(scramble)}\\n`);\n break;\n }\n case \"json-text\": {\n jsonListPrinter?.push(scramble.toString());\n break;\n }\n case \"auto\": {\n console.log(`// Scramble #${i + 1}\n${scrambleText(scramble)}\n\n\uD83D\uDD17 ${scrambleLink(scramble)}\n`);\n break;\n }\n default: {\n throw new Error(\"Unknown format!\");\n }\n }\n }\n jsonListPrinter?.finish();\n }\n },\n});\n\n// Possibly: https://github.com/nodejs/node/issues/55468 Technically we could\n// just remove `await` from the called function, but this is semantically\n// unsound. This function encapsulates the unsoundness.\nfunction nodeForgetTopLevelAwaitWorkaround(\n _promise: Promise<any>,\n): Promise<void> {\n return Promise.resolve();\n}\n\nawait nodeForgetTopLevelAwaitWorkaround(run(binary(app), process.argv));\n"],
|
|
5
|
+
"mappings": ";;;;AAQA,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAG/B,IAAM;AAAA,EACJ;AAAA,EACA,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAI,MAAM,OAAO,YAAY;AAG7B,IAAM,gBAAgB,CAAC,QAAQ,QAAQ,WAAW;AAClD,IAAM,gBAAgB,CAAC,QAAQ,KAAK;AAEpC,IAAM,MAAM,QAAQ;AAAA,EAClB,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,QAAQ,OAAO;AAAA,MACb,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO;AAAA,MACP,cAAc,MAAM;AAAA,MACpB,4BAA4B;AAAA,IAC9B,CAAC;AAAA,IACD,QAAQ,OAAO;AAAA,MACb,aAAa,0BAA0B,cAAc,KAAK,IAAI,CAAC;AAAA,MAC/D,MAAM,SAAS,MAAM,aAAa,CAAC;AAAA,MACnC,MAAM;AAAA,MACN,OAAO;AAAA,IACT,CAAC;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AAgB,IAAI,CAAC;AAAA,EAC3C,aAAa,QAAQ,CAAC;AAAA;AAAA,YAEnB,aAAa,QAAQ,CAAC;AAAA,CAC1B;AACW;AAAA,UACF;AAAA,UACA,SAAS;AACP,kBAAM,IAAI,MAAM,iBAAiB;AAAA,UACnC;AAAA,QACF;AAAA,MACF;AACA,uBAAiB,OAAO;AAAA,IAC1B;AAAA,EACF;AACF,CAAC;AAKD,SAAS,kCACP,UACe;AACf,SAAO,QAAQ,QAAQ;AACzB;AAEA,MAAM,kCAAkC,IAAI,OAAO,GAAG,GAAG,QAAQ,IAAI,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-7GUL3OBQ.js";
|
|
4
4
|
import {
|
|
5
5
|
node_adapter_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NX2Q6B7Y.js";
|
|
7
7
|
import {
|
|
8
8
|
Alg
|
|
9
9
|
} from "./chunk-7D7ZUWUK.js";
|
|
@@ -306,7 +306,6 @@ async function solveTwsearch(kpuzzle, pattern, options) {
|
|
|
306
306
|
var searchOutsideDebugGlobals = {
|
|
307
307
|
logPerf: true,
|
|
308
308
|
scramblePrefetchLevel: "auto",
|
|
309
|
-
disableStringWorker: false,
|
|
310
309
|
forceNewWorkerForEveryScramble: false,
|
|
311
310
|
showWorkerInstantiationWarnings: true,
|
|
312
311
|
prioritizeEsbuildWorkaroundForWorkerInstantiation: false,
|
|
@@ -327,7 +326,6 @@ function setSearchDebug(options) {
|
|
|
327
326
|
);
|
|
328
327
|
}
|
|
329
328
|
for (const booleanField of [
|
|
330
|
-
"disableStringWorker",
|
|
331
329
|
"forceNewWorkerForEveryScramble",
|
|
332
330
|
"showWorkerInstantiationWarnings",
|
|
333
331
|
"prioritizeEsbuildWorkaroundForWorkerInstantiation",
|
|
@@ -350,4 +348,4 @@ export {
|
|
|
350
348
|
solveTwsearch,
|
|
351
349
|
setSearchDebug
|
|
352
350
|
};
|
|
353
|
-
//# sourceMappingURL=chunk-
|
|
351
|
+
//# sourceMappingURL=chunk-2HSEQ2FC.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 {\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}\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?: import(\"worker_threads\").Worker;\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(wrapWithTerminate(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(wrapWithTerminate(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 wrapWithTerminate(worker: Worker): InsideOutsideAPI {\n const insideAPI = wrap<WorkerInsideAPI>(worker);\n const terminate = worker.terminate.bind(worker);\n return { insideAPI, outsideAPI: { terminate } };\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\nexport async function mapToAllWorkers(\n f: (worker: InsideOutsideAPI) => void,\n): Promise<void> {\n await Promise.all(\n allInsideOutsideAPIPromises.map((worker) => worker.then(f)),\n );\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 { TwsearchOptions } from \"./inside/solve/twsearch\";\nimport {\n type InsideOutsideAPI,\n instantiateWorker,\n mapToAllWorkers,\n} from \"./instantiator\";\n\nlet cachedWorkerInstance: Promise<InsideOutsideAPI> | undefined;\nfunction getCachedWorkerInstance(): Promise<InsideOutsideAPI> {\n return (cachedWorkerInstance ??= instantiateWorker());\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 (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 =\n await worker.insideAPI.randomScrambleStringForEvent(eventID);\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 worker.insideAPI.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(\n await cwi.insideAPI.solve333ToString(pattern.patternData),\n );\n}\n\nexport async function experimentalSolve2x2x2(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(\n await cwi.insideAPI.solve222ToString(pattern.patternData),\n );\n}\n\nexport async function solveSkewb(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(\n await cwi.insideAPI.solveSkewbToString(pattern.patternData),\n );\n}\n\nexport async function solvePyraminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(\n await cwi.insideAPI.solvePyraminxToString(pattern.patternData),\n );\n}\n\nexport async function solveMegaminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(\n await cwi.insideAPI.solveMegaminxToString(pattern.patternData),\n );\n}\n\nexport interface SolveTwsearchOptions {\n generatorMoves?: string[];\n targetPattern?: KPattern;\n minDepth?: number;\n maxDepth?: number;\n}\n\nexport async function solveTwsearch(\n kpuzzle: KPuzzle,\n pattern: KPattern,\n options?: SolveTwsearchOptions,\n): Promise<Alg> {\n const { targetPattern, ...otherOptions } = options ?? {};\n const apiOptions: TwsearchOptions = 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 await dedicatedWorker.insideAPI.solveTwsearchToString(\n def,\n pattern.patternData,\n apiOptions,\n ),\n );\n } finally {\n console.log(\"Search ended, terminating dedicated `twsearch` worker.\");\n // TODO: support re-using the same worker for multiple searches..\n await dedicatedWorker.outsideAPI.terminate();\n }\n}\n\ninterface SearchOutsideDebugGlobals {\n logPerf: boolean;\n scramblePrefetchLevel: `${PrefetchLevel}`;\n disableStringWorker: boolean;\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 disableStringWorker: false,\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 mapToAllWorkers((worker) => worker.insideAPI.setDebugMeasurePerf(logPerf));\n }\n if (typeof scramblePrefetchLevel !== \"undefined\") {\n searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;\n mapToAllWorkers((worker) =>\n worker.insideAPI.setScramblePrefetchLevel(\n scramblePrefetchLevel as PrefetchLevel,\n ),\n );\n }\n for (const booleanField of [\n \"disableStringWorker\",\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;AAC7C,SAAO,MAAM;AACb,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,MAAM,OAAO,0BAA0B,GAAG;AACpD;AAEO,SAAS,gDAAwD;AACtE,SAAO,IAAI,OAAO,IAAI,IAAI,4BAA4B,YAAY,GAAG,GAAG;AAAA,IACtE,MAAM;AAAA,EACR,CAAC;AACH;;;ACNA,SAAS,oBAAoB,oBAAkC;AAC7D,MAAI;AAC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C,SAAO,IAAI;AAAA,IACT,MAAM,IAAI,UAAU,sBAAsB,QAAQ,WAAW;AAAA,EAC/D;AACF;AASA,eAAsB,cACpB,SACA,SACA,SACc;AACd,QAAM,EAAE,eAAe,GAAG,aAAa,IAAI,WAAW,CAAC;AACvD,QAAM,aAA8B;AACpC,MAAI,eAAe;AACjB,eAAW,gBAAgB,cAAc;AAAA,EAC3C;AACA,QAAM,EAAE,GAAG,IAAI,IAAI,QAAQ;AAC3B,SAAO,IAAI;AAEX,QAAM,kBAAkB,MAAM,kBAAkB;AAChD,MAAI;AACF,WAAO,IAAI;AAAA,MACT,MAAM,gBAAgB,UAAU;AAAA,QAC9B;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF,UAAE;AACA,YAAQ,IAAI,wDAAwD;AAEpE,UAAM,gBAAgB,WAAW,UAAU;AAAA,EAC7C;AACF;
|
|
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 {\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}\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?: import(\"worker_threads\").Worker;\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(wrapWithTerminate(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(wrapWithTerminate(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 wrapWithTerminate(worker: Worker): InsideOutsideAPI {\n const insideAPI = wrap<WorkerInsideAPI>(worker);\n const terminate = worker.terminate.bind(worker);\n return { insideAPI, outsideAPI: { terminate } };\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\nexport async function mapToAllWorkers(\n f: (worker: InsideOutsideAPI) => void,\n): Promise<void> {\n await Promise.all(\n allInsideOutsideAPIPromises.map((worker) => worker.then(f)),\n );\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 { TwsearchOptions } from \"./inside/solve/twsearch\";\nimport {\n type InsideOutsideAPI,\n instantiateWorker,\n mapToAllWorkers,\n} from \"./instantiator\";\n\nlet cachedWorkerInstance: Promise<InsideOutsideAPI> | undefined;\nfunction getCachedWorkerInstance(): Promise<InsideOutsideAPI> {\n return (cachedWorkerInstance ??= instantiateWorker());\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 (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 =\n await worker.insideAPI.randomScrambleStringForEvent(eventID);\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 worker.insideAPI.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(\n await cwi.insideAPI.solve333ToString(pattern.patternData),\n );\n}\n\nexport async function experimentalSolve2x2x2(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(\n await cwi.insideAPI.solve222ToString(pattern.patternData),\n );\n}\n\nexport async function solveSkewb(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(\n await cwi.insideAPI.solveSkewbToString(pattern.patternData),\n );\n}\n\nexport async function solvePyraminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(\n await cwi.insideAPI.solvePyraminxToString(pattern.patternData),\n );\n}\n\nexport async function solveMegaminx(pattern: KPattern): Promise<Alg> {\n const cwi = await getCachedWorkerInstance();\n return Alg.fromString(\n await cwi.insideAPI.solveMegaminxToString(pattern.patternData),\n );\n}\n\nexport interface SolveTwsearchOptions {\n generatorMoves?: string[];\n targetPattern?: KPattern;\n minDepth?: number;\n maxDepth?: number;\n}\n\nexport async function solveTwsearch(\n kpuzzle: KPuzzle,\n pattern: KPattern,\n options?: SolveTwsearchOptions,\n): Promise<Alg> {\n const { targetPattern, ...otherOptions } = options ?? {};\n const apiOptions: TwsearchOptions = 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 await dedicatedWorker.insideAPI.solveTwsearchToString(\n def,\n pattern.patternData,\n apiOptions,\n ),\n );\n } finally {\n console.log(\"Search ended, terminating dedicated `twsearch` worker.\");\n // TODO: support re-using the same worker for multiple searches..\n await 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 mapToAllWorkers((worker) => worker.insideAPI.setDebugMeasurePerf(logPerf));\n }\n if (typeof scramblePrefetchLevel !== \"undefined\") {\n searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;\n 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;AAC7C,SAAO,MAAM;AACb,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;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;AAAA,EACF;AACA,aAAW,gBAAgB;AAAA,IACzB;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
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// src/cubing/vendor/apache/comlink-everywhere/node-adapter.ts
|
|
2
|
-
function nodeEndpoint(
|
|
2
|
+
function nodeEndpoint(parentPort) {
|
|
3
3
|
const listeners = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const parentPortAsNodeWorker = parentPort;
|
|
5
|
+
const constructedWorker = {
|
|
6
|
+
postMessage: parentPort.postMessage.bind(parentPort),
|
|
6
7
|
addEventListener: (_, eh) => {
|
|
7
8
|
const l = (data) => {
|
|
8
9
|
if ("handleEvent" in eh) {
|
|
@@ -11,7 +12,7 @@ function nodeEndpoint(nep) {
|
|
|
11
12
|
eh({ data });
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
parentPort.on("message", l);
|
|
15
16
|
listeners.set(eh, l);
|
|
16
17
|
},
|
|
17
18
|
removeEventListener: (_, eh) => {
|
|
@@ -19,19 +20,21 @@ function nodeEndpoint(nep) {
|
|
|
19
20
|
if (!l) {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
parentPort.off("message", l);
|
|
23
24
|
listeners.delete(eh);
|
|
24
25
|
},
|
|
25
|
-
nodeWorker:
|
|
26
|
+
nodeWorker: parentPortAsNodeWorker,
|
|
26
27
|
terminate: () => {
|
|
27
|
-
|
|
28
|
+
parentPortAsNodeWorker.terminate();
|
|
28
29
|
}
|
|
29
30
|
// start: nep.start && nep.start.bind(nep),
|
|
30
31
|
};
|
|
32
|
+
parentPort.unref();
|
|
33
|
+
return constructedWorker;
|
|
31
34
|
}
|
|
32
35
|
var node_adapter_default = nodeEndpoint;
|
|
33
36
|
|
|
34
37
|
export {
|
|
35
38
|
node_adapter_default
|
|
36
39
|
};
|
|
37
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-NX2Q6B7Y.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cubing/vendor/apache/comlink-everywhere/node-adapter.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n MessagePort as NodeMessagePort,\n Worker as NodeWorker,\n} from \"node:worker_threads\";\n\n/**\n * Copyright 2019 Google Inc. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype EventHandler = EventListenerObject | ((event: any) => void);\n\nfunction nodeEndpoint(parentPort: NodeMessagePort | NodeWorker): Worker & {\n nodeWorker?: import(\"node:worker_threads\").Worker;\n} {\n const listeners = new WeakMap();\n const parentPortAsNodeWorker = parentPort as NodeWorker;\n const constructedWorker = {\n postMessage: parentPort.postMessage.bind(parentPort),\n addEventListener: (_: string, eh: EventHandler) => {\n const l = (data: Event) => {\n if (\"handleEvent\" in eh) {\n eh.handleEvent({ data } as any);\n } else {\n eh({ data });\n }\n };\n parentPort.on(\"message\", l);\n listeners.set(eh, l);\n },\n removeEventListener: (_: string, eh: EventHandler) => {\n const l = listeners.get(eh);\n if (!l) {\n return;\n }\n parentPort.off(\"message\", l);\n listeners.delete(eh);\n },\n nodeWorker: parentPortAsNodeWorker,\n terminate: () => {\n parentPortAsNodeWorker.terminate();\n },\n // start: nep.start && nep.start.bind(nep),\n } as Worker & {\n nodeWorker?: import(\"worker_threads\").Worker;\n };\n\n /** Unref the parent port to prevent `node` from hanging:\n *\n * - https://github.com/cubing/cubing.js/issues/358\n * - https://github.com/nodejs/node/issues/53036#issuecomment-2118106710\n */\n parentPort.unref();\n\n return constructedWorker;\n}\n\nexport default nodeEndpoint;\n//# sourceMappingURL=node-adapter.mjs.map\n"],
|
|
5
|
+
"mappings": ";AAoBA,SAAS,aAAa,YAEpB;AACA,QAAM,YAAY,oBAAI,QAAQ;AAC9B,QAAM,yBAAyB;AAC/B,QAAM,oBAAoB;AAAA,IACxB,aAAa,WAAW,YAAY,KAAK,UAAU;AAAA,IACnD,kBAAkB,CAAC,GAAW,OAAqB;AACjD,YAAM,IAAI,CAAC,SAAgB;AACzB,YAAI,iBAAiB,IAAI;AACvB,aAAG,YAAY,EAAE,KAAK,CAAQ;AAAA,QAChC,OAAO;AACL,aAAG,EAAE,KAAK,CAAC;AAAA,QACb;AAAA,MACF;AACA,iBAAW,GAAG,WAAW,CAAC;AAC1B,gBAAU,IAAI,IAAI,CAAC;AAAA,IACrB;AAAA,IACA,qBAAqB,CAAC,GAAW,OAAqB;AACpD,YAAM,IAAI,UAAU,IAAI,EAAE;AAC1B,UAAI,CAAC,GAAG;AACN;AAAA,MACF;AACA,iBAAW,IAAI,WAAW,CAAC;AAC3B,gBAAU,OAAO,EAAE;AAAA,IACrB;AAAA,IACA,YAAY;AAAA,IACZ,WAAW,MAAM;AACf,6BAAuB,UAAU;AAAA,IACnC;AAAA;AAAA,EAEF;AASA,aAAW,MAAM;AAEjB,SAAO;AACT;AAEA,IAAO,uBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
node_adapter_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NX2Q6B7Y.js";
|
|
4
4
|
|
|
5
5
|
// src/cubing/vendor/apache/comlink-everywhere/inside/index.ts
|
|
6
6
|
import { expose as comlinkExpose } from "comlink";
|
|
@@ -9,9 +9,7 @@ async function nodeEndpointPort() {
|
|
|
9
9
|
const { parentPort } = globalThis.process.getBuiltinModule(
|
|
10
10
|
"node:worker_threads"
|
|
11
11
|
);
|
|
12
|
-
return node_adapter_default(
|
|
13
|
-
parentPort
|
|
14
|
-
);
|
|
12
|
+
return node_adapter_default(parentPort);
|
|
15
13
|
}
|
|
16
14
|
function expose(api) {
|
|
17
15
|
if (useNodeWorkarounds) {
|
|
@@ -27,4 +25,4 @@ export {
|
|
|
27
25
|
nodeEndpointPort,
|
|
28
26
|
expose
|
|
29
27
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-REBGU5ET.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cubing/vendor/apache/comlink-everywhere/inside/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { expose as comlinkExpose } from \"comlink\";\nimport nodeEndpoint from \"../node-adapter\";\n\nconst useNodeWorkarounds =\n typeof globalThis.Worker === \"undefined\" &&\n typeof (globalThis as any).WorkerNavigator === \"undefined\";\n\nexport async function nodeEndpointPort(): Promise<\n Worker & {\n nodeWorker?: import(\"node:worker_threads\").Worker;\n }\n> {\n const { parentPort } = globalThis.process.getBuiltinModule(\n \"node:worker_threads\",\n );\n return nodeEndpoint(
|
|
5
|
-
"mappings": ";;;;;AAAA,SAAS,UAAU,qBAAqB;AAGxC,IAAM,qBACJ,OAAO,WAAW,WAAW,eAC7B,OAAQ,WAAmB,oBAAoB;AAEjD,eAAsB,mBAIpB;AACA,QAAM,EAAE,WAAW,IAAI,WAAW,QAAQ;AAAA,IACxC;AAAA,EACF;AACA,SAAO
|
|
4
|
+
"sourcesContent": ["import { expose as comlinkExpose } from \"comlink\";\nimport nodeEndpoint from \"../node-adapter\";\n\nconst useNodeWorkarounds =\n typeof globalThis.Worker === \"undefined\" &&\n typeof (globalThis as any).WorkerNavigator === \"undefined\";\n\nexport async function nodeEndpointPort(): Promise<\n Worker & {\n nodeWorker?: import(\"node:worker_threads\").Worker;\n }\n> {\n const { parentPort } = globalThis.process.getBuiltinModule(\n \"node:worker_threads\",\n );\n return nodeEndpoint(parentPort!);\n}\n\nexport function expose(api: any) {\n if (useNodeWorkarounds) {\n (async () => {\n comlinkExpose(api, await nodeEndpointPort());\n })();\n } else {\n comlinkExpose(api);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,SAAS,UAAU,qBAAqB;AAGxC,IAAM,qBACJ,OAAO,WAAW,WAAW,eAC7B,OAAQ,WAAmB,oBAAoB;AAEjD,eAAsB,mBAIpB;AACA,QAAM,EAAE,WAAW,IAAI,WAAW,QAAQ;AAAA,IACxC;AAAA,EACF;AACA,SAAO,qBAAa,UAAW;AACjC;AAEO,SAAS,OAAO,KAAU;AAC/B,MAAI,oBAAoB;AACtB,KAAC,YAAY;AACX,oBAAc,KAAK,MAAM,iBAAiB,CAAC;AAAA,IAC7C,GAAG;AAAA,EACL,OAAO;AACL,kBAAc,GAAG;AAAA,EACnB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
expose
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-REBGU5ET.js";
|
|
4
4
|
import {
|
|
5
5
|
countMoves
|
|
6
6
|
} from "./chunk-UD4LT3FY.js";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
setIsInsideWorker,
|
|
14
14
|
solve333
|
|
15
15
|
} from "./chunk-OJI4YUWF.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-NX2Q6B7Y.js";
|
|
17
17
|
import {
|
|
18
18
|
cube2x2x2,
|
|
19
19
|
puzzles
|
|
@@ -208,7 +208,7 @@ async function solve222(pattern) {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
// src/cubing/search/inside/solve/puzzles/dynamic/4x4x4/index.ts
|
|
211
|
-
var dynamic4x4x4Solver = from(() => import("./search-dynamic-solve-4x4x4-
|
|
211
|
+
var dynamic4x4x4Solver = from(() => import("./search-dynamic-solve-4x4x4-GNM5XEZR.js"));
|
|
212
212
|
|
|
213
213
|
// src/cubing/search/inside/solve/puzzles/4x4x4.ts
|
|
214
214
|
var randomSuffixes = [
|
|
@@ -569,4 +569,4 @@ var insideAPI = {
|
|
|
569
569
|
|
|
570
570
|
// src/cubing/search/inside/index.ts
|
|
571
571
|
expose(insideAPI);
|
|
572
|
-
//# sourceMappingURL=inside-
|
|
572
|
+
//# sourceMappingURL=inside-NS3PIQ5Z.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "./chunk-NAPITA3L.js";
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-2HSEQ2FC.js";
|
|
3
3
|
import {
|
|
4
4
|
random333Scramble
|
|
5
5
|
} from "./chunk-OJI4YUWF.js";
|
|
6
6
|
import "./chunk-7GUL3OBQ.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-NX2Q6B7Y.js";
|
|
8
8
|
import "./chunk-WIZJQ7QS.js";
|
|
9
9
|
import "./chunk-RUSWM2KK.js";
|
|
10
10
|
import "./chunk-PSQEELP4.js";
|
|
@@ -2921,4 +2921,4 @@ export {
|
|
|
2921
2921
|
initialize,
|
|
2922
2922
|
random444Scramble
|
|
2923
2923
|
};
|
|
2924
|
-
//# sourceMappingURL=search-dynamic-solve-4x4x4-
|
|
2924
|
+
//# sourceMappingURL=search-dynamic-solve-4x4x4-GNM5XEZR.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
nodeEndpointPort
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-REBGU5ET.js";
|
|
4
4
|
import {
|
|
5
5
|
exposeAPI
|
|
6
6
|
} from "./chunk-7GUL3OBQ.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-NX2Q6B7Y.js";
|
|
8
8
|
|
|
9
9
|
// src/cubing/search/worker-workarounds/search-worker-entry.js
|
|
10
10
|
if (exposeAPI.expose) {
|
|
11
11
|
(async () => {
|
|
12
|
-
await import("./inside-
|
|
12
|
+
await import("./inside-NS3PIQ5Z.js");
|
|
13
13
|
const messagePort = globalThis.postMessage ? globalThis : await nodeEndpointPort();
|
|
14
14
|
messagePort.postMessage("comlink-exposed");
|
|
15
15
|
})();
|
|
@@ -23,7 +23,6 @@ declare function solveTwsearch(kpuzzle: KPuzzle, pattern: KPattern, options?: So
|
|
|
23
23
|
interface SearchOutsideDebugGlobals {
|
|
24
24
|
logPerf: boolean;
|
|
25
25
|
scramblePrefetchLevel: `${PrefetchLevel}`;
|
|
26
|
-
disableStringWorker: boolean;
|
|
27
26
|
forceNewWorkerForEveryScramble: boolean;
|
|
28
27
|
showWorkerInstantiationWarnings: boolean;
|
|
29
28
|
prioritizeEsbuildWorkaroundForWorkerInstantiation: boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../KPattern-DEaZMwD9.js';
|
|
2
|
-
export { g as experimentalDeriveScrambleForEvent, r as randomScrambleForEvent } from '../index-
|
|
2
|
+
export { g as experimentalDeriveScrambleForEvent, r as randomScrambleForEvent } from '../index-B28YEQVF.js';
|
|
3
3
|
import 'three/src/Three.js';
|
|
@@ -2,10 +2,10 @@ import "../chunks/chunk-NAPITA3L.js";
|
|
|
2
2
|
import {
|
|
3
3
|
deriveScrambleForEvent,
|
|
4
4
|
randomScrambleForEvent
|
|
5
|
-
} from "../chunks/chunk-
|
|
5
|
+
} from "../chunks/chunk-2HSEQ2FC.js";
|
|
6
6
|
import "../chunks/chunk-OJI4YUWF.js";
|
|
7
7
|
import "../chunks/chunk-7GUL3OBQ.js";
|
|
8
|
-
import "../chunks/chunk-
|
|
8
|
+
import "../chunks/chunk-NX2Q6B7Y.js";
|
|
9
9
|
import "../chunks/chunk-WIZJQ7QS.js";
|
|
10
10
|
import "../chunks/chunk-RUSWM2KK.js";
|
|
11
11
|
import "../chunks/chunk-PSQEELP4.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { K as KPattern } from '../KPattern-DEaZMwD9.js';
|
|
2
|
-
export { e as experimentalSolve2x2x2, a as experimentalSolve3x3x3IgnoringCenters, f as experimentalSolveTwsearch, s as setSearchDebug, b as solveMegaminx, c as solvePyraminx, d as solveSkewb } from '../index-
|
|
2
|
+
export { e as experimentalSolve2x2x2, a as experimentalSolve3x3x3IgnoringCenters, f as experimentalSolveTwsearch, s as setSearchDebug, b as solveMegaminx, c as solvePyraminx, d as solveSkewb } from '../index-B28YEQVF.js';
|
|
3
3
|
import 'three/src/Three.js';
|
|
4
4
|
|
|
5
5
|
declare function random333Pattern(): Promise<KPattern>;
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
solvePyraminx,
|
|
7
7
|
solveSkewb,
|
|
8
8
|
solveTwsearch
|
|
9
|
-
} from "../chunks/chunk-
|
|
9
|
+
} from "../chunks/chunk-2HSEQ2FC.js";
|
|
10
10
|
import {
|
|
11
11
|
random333Pattern
|
|
12
12
|
} from "../chunks/chunk-OJI4YUWF.js";
|
|
13
13
|
import "../chunks/chunk-7GUL3OBQ.js";
|
|
14
|
-
import "../chunks/chunk-
|
|
14
|
+
import "../chunks/chunk-NX2Q6B7Y.js";
|
|
15
15
|
import "../chunks/chunk-WIZJQ7QS.js";
|
|
16
16
|
import "../chunks/chunk-RUSWM2KK.js";
|
|
17
17
|
import "../chunks/chunk-PSQEELP4.js";
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/cubing/vendor/apache/comlink-everywhere/node-adapter.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Worker as NodeWorker } from \"node:worker_threads\";\n\n/**\n * Copyright 2019 Google Inc. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype EventHandler = EventListenerObject | ((event: any) => void);\n\nfunction nodeEndpoint(nep: NodeWorker): Worker & {\n nodeWorker?: import(\"worker_threads\").Worker;\n} {\n const listeners = new WeakMap();\n return {\n postMessage: nep.postMessage.bind(nep),\n addEventListener: (_: string, eh: EventHandler) => {\n const l = (data: Event) => {\n if (\"handleEvent\" in eh) {\n eh.handleEvent({ data } as any);\n } else {\n eh({ data });\n }\n };\n nep.on(\"message\", l);\n listeners.set(eh, l);\n },\n removeEventListener: (_: string, eh: EventHandler) => {\n const l = listeners.get(eh);\n if (!l) {\n return;\n }\n nep.off(\"message\", l);\n listeners.delete(eh);\n },\n nodeWorker: nep,\n terminate: () => {\n nep.terminate();\n },\n // start: nep.start && nep.start.bind(nep),\n } as Worker & {\n nodeWorker?: import(\"worker_threads\").Worker;\n };\n}\n\nexport default nodeEndpoint;\n//# sourceMappingURL=node-adapter.mjs.map\n"],
|
|
5
|
-
"mappings": ";AAiBA,SAAS,aAAa,KAEpB;AACA,QAAM,YAAY,oBAAI,QAAQ;AAC9B,SAAO;AAAA,IACL,aAAa,IAAI,YAAY,KAAK,GAAG;AAAA,IACrC,kBAAkB,CAAC,GAAW,OAAqB;AACjD,YAAM,IAAI,CAAC,SAAgB;AACzB,YAAI,iBAAiB,IAAI;AACvB,aAAG,YAAY,EAAE,KAAK,CAAQ;AAAA,QAChC,OAAO;AACL,aAAG,EAAE,KAAK,CAAC;AAAA,QACb;AAAA,MACF;AACA,UAAI,GAAG,WAAW,CAAC;AACnB,gBAAU,IAAI,IAAI,CAAC;AAAA,IACrB;AAAA,IACA,qBAAqB,CAAC,GAAW,OAAqB;AACpD,YAAM,IAAI,UAAU,IAAI,EAAE;AAC1B,UAAI,CAAC,GAAG;AACN;AAAA,MACF;AACA,UAAI,IAAI,WAAW,CAAC;AACpB,gBAAU,OAAO,EAAE;AAAA,IACrB;AAAA,IACA,YAAY;AAAA,IACZ,WAAW,MAAM;AACf,UAAI,UAAU;AAAA,IAChB;AAAA;AAAA,EAEF;AAGF;AAEA,IAAO,uBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
File without changes
|