cubing 0.63.2 → 0.63.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/bin/chunks/{chunk-52ODPET6.js → chunk-OI3YIXMQ.js} +2 -2
  2. package/dist/bin/order.js +1 -1
  3. package/dist/bin/puzzle-geometry-bin.js +1 -1
  4. package/dist/bin/scramble.js +1 -1
  5. package/dist/lib/cubing/{PuzzleLoader-R-puDLmC.d.ts → PuzzleLoader-Bp8zngUn.d.ts} +10 -0
  6. package/dist/lib/cubing/alg/index.d.ts +2 -2
  7. package/dist/lib/cubing/bluetooth/index.d.ts +2 -2
  8. package/dist/lib/cubing/chunks/chunk-44CFF24P.js +239 -0
  9. package/dist/lib/cubing/chunks/chunk-44CFF24P.js.map +7 -0
  10. package/dist/lib/cubing/chunks/chunk-DQGYYYHZ.js +1180 -0
  11. package/dist/lib/cubing/chunks/chunk-DQGYYYHZ.js.map +7 -0
  12. package/dist/lib/cubing/chunks/chunk-FTE3QI5X.js +1074 -0
  13. package/dist/lib/cubing/chunks/chunk-FTE3QI5X.js.map +7 -0
  14. package/dist/lib/cubing/chunks/chunk-FZBKZ5ZB.js +265 -0
  15. package/dist/lib/cubing/chunks/chunk-FZBKZ5ZB.js.map +7 -0
  16. package/dist/lib/cubing/chunks/chunk-OUM32GEA.js +239 -0
  17. package/dist/lib/cubing/chunks/chunk-OUM32GEA.js.map +7 -0
  18. package/dist/lib/cubing/chunks/chunk-SGJ5WPE4.js +1074 -0
  19. package/dist/lib/cubing/chunks/chunk-SGJ5WPE4.js.map +7 -0
  20. package/dist/lib/cubing/chunks/chunk-TAVR35KU.js +265 -0
  21. package/dist/lib/cubing/chunks/chunk-TAVR35KU.js.map +7 -0
  22. package/dist/lib/cubing/chunks/chunk-VRTKWZPL.js +10084 -0
  23. package/dist/lib/cubing/chunks/chunk-VRTKWZPL.js.map +7 -0
  24. package/dist/lib/cubing/chunks/chunk-VSMFYTG6.js +10086 -0
  25. package/dist/lib/cubing/chunks/chunk-VSMFYTG6.js.map +7 -0
  26. package/dist/lib/cubing/chunks/inside-IHWQVDVU.js +564 -0
  27. package/dist/lib/cubing/chunks/inside-IHWQVDVU.js.map +7 -0
  28. package/dist/lib/cubing/chunks/inside-L2JI2BEY.js +564 -0
  29. package/dist/lib/cubing/chunks/inside-L2JI2BEY.js.map +7 -0
  30. package/dist/lib/cubing/chunks/search-dynamic-sgs-side-events-MXHP7O4R.js +1890 -0
  31. package/dist/lib/cubing/chunks/search-dynamic-sgs-side-events-MXHP7O4R.js.map +7 -0
  32. package/dist/lib/cubing/chunks/search-dynamic-sgs-side-events-XFECDWOF.js +1890 -0
  33. package/dist/lib/cubing/chunks/search-dynamic-sgs-side-events-XFECDWOF.js.map +7 -0
  34. package/dist/lib/cubing/chunks/search-dynamic-sgs-unofficial-CM33KT7L.js +1267 -0
  35. package/dist/lib/cubing/chunks/search-dynamic-sgs-unofficial-CM33KT7L.js.map +7 -0
  36. package/dist/lib/cubing/chunks/search-dynamic-sgs-unofficial-Q4LLHL2O.js +1267 -0
  37. package/dist/lib/cubing/chunks/search-dynamic-sgs-unofficial-Q4LLHL2O.js.map +7 -0
  38. package/dist/lib/cubing/chunks/search-dynamic-solve-4x4x4-COSEVJBV.js +2922 -0
  39. package/dist/lib/cubing/chunks/search-dynamic-solve-4x4x4-COSEVJBV.js.map +7 -0
  40. package/dist/lib/cubing/chunks/search-dynamic-solve-4x4x4-NANDMURR.js +2922 -0
  41. package/dist/lib/cubing/chunks/search-dynamic-solve-4x4x4-NANDMURR.js.map +7 -0
  42. package/dist/lib/cubing/chunks/twisty-dynamic-3d-5NZRNZ7C.js +1881 -0
  43. package/dist/lib/cubing/chunks/twisty-dynamic-3d-5NZRNZ7C.js.map +7 -0
  44. package/dist/lib/cubing/chunks/twisty-dynamic-3d-VGZIQ64W.js +1927 -0
  45. package/dist/lib/cubing/chunks/twisty-dynamic-3d-VGZIQ64W.js.map +7 -0
  46. package/dist/lib/cubing/chunks/twisty-dynamic-3d-XLUOPCLN.js +1881 -0
  47. package/dist/lib/cubing/chunks/twisty-dynamic-3d-XLUOPCLN.js.map +7 -0
  48. package/dist/lib/cubing/{events-IfSwQLYm.d.ts → events-CewDA1aS.d.ts} +1 -1
  49. package/dist/lib/cubing/{index-btIxbuNp.d.ts → index-DabjED-w.d.ts} +1 -1
  50. package/dist/lib/cubing/kpuzzle/index.d.ts +1 -1
  51. package/dist/lib/cubing/notation/index.d.ts +1 -1
  52. package/dist/lib/cubing/protocol/index.d.ts +1 -1
  53. package/dist/lib/cubing/puzzle-geometry/index.d.ts +2 -2
  54. package/dist/lib/cubing/puzzles/index.d.ts +1 -1
  55. package/dist/lib/cubing/scramble/index.d.ts +2 -2
  56. package/dist/lib/cubing/search/index.d.ts +3 -3
  57. package/dist/lib/cubing/stream/index.d.ts +3 -3
  58. package/dist/lib/cubing/twisty/index.d.ts +2 -2
  59. package/dist/lib/cubing/twisty/index.js +37 -4
  60. package/dist/lib/cubing/twisty/index.js.map +3 -3
  61. package/package.json +1 -1
  62. /package/dist/bin/chunks/{chunk-52ODPET6.js.map → chunk-OI3YIXMQ.js.map} +0 -0
@@ -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.2"
7
+ "0.63.3"
8
8
  );
9
9
 
10
10
  export {
11
11
  packageVersion
12
12
  };
13
- //# sourceMappingURL=chunk-52ODPET6.js.map
13
+ //# sourceMappingURL=chunk-OI3YIXMQ.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-52ODPET6.js";
4
+ } from "./chunks/chunk-OI3YIXMQ.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-52ODPET6.js";
4
+ } from "./chunks/chunk-OI3YIXMQ.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-52ODPET6.js";
4
+ } from "./chunks/chunk-OI3YIXMQ.js";
5
5
 
6
6
  // src/bin/scramble.ts
7
7
  import { basename } from "node:path";
@@ -1508,6 +1508,11 @@ declare class HintFaceletProp extends SimpleTwistyPropSource<HintFaceletStyleWit
1508
1508
  getDefaultValue(): HintFaceletStyleWithAuto;
1509
1509
  }
1510
1510
 
1511
+ type HintFaceletsElevationRequest = "auto" | number;
1512
+ declare class HintFaceletsElevationProp extends SimpleTwistyPropSource<"auto" | number> {
1513
+ getDefaultValue(): "auto" | number;
1514
+ }
1515
+
1511
1516
  type InitialHintFaceletsAnimation = "auto" | "always" | "none";
1512
1517
  declare class InitialHintFaceletsAnimationProp extends SimpleTwistyPropSource<InitialHintFaceletsAnimation> {
1513
1518
  getDefaultValue(): InitialHintFaceletsAnimation;
@@ -1619,6 +1624,7 @@ declare class TwistySceneModel {
1619
1624
  hintFacelet: HintFaceletProp;
1620
1625
  hintStickerSpriteURL: URLProp;
1621
1626
  initialHintFaceletsAnimation: InitialHintFaceletsAnimationProp;
1627
+ hintFaceletsElevation: HintFaceletsElevationProp;
1622
1628
  latitudeLimit: LatitudeLimitProp;
1623
1629
  movePressInput: MovePressInputProp;
1624
1630
  movePressCancelOptions: MovePressCancelOptions;
@@ -1983,6 +1989,8 @@ declare abstract class TwistyPlayerSettable extends ManagedCustomElement {
1983
1989
  get fullscreenElement(): never;
1984
1990
  set experimentalInitialHintFaceletsAnimation(anim: InitialHintFaceletsAnimation);
1985
1991
  get experimentalInitialHintFaceletsAnimation(): never;
1992
+ set experimentalHintFaceletsElevation(elevation: "auto" | number);
1993
+ get experimentalHintFaceletsElevation(): never;
1986
1994
  set experimentalDragInput(dragInputMode: DragInputMode);
1987
1995
  get experimentalDragInput(): never;
1988
1996
  experimentalGet: ExperimentalGetters;
@@ -2041,6 +2049,8 @@ interface TwistyPlayerConfig {
2041
2049
  controlPanel?: ControlPanelThemeWithAuto;
2042
2050
  backView?: BackViewLayoutWithAuto;
2043
2051
  experimentalInitialHintFaceletsAnimation?: InitialHintFaceletsAnimation;
2052
+ experimentalFaceletScale?: FaceletScale;
2053
+ experimentalHintFaceletsElevation?: HintFaceletsElevationRequest;
2044
2054
  viewerLink?: ViewerLinkPageWithAuto;
2045
2055
  experimentalMovePressInput?: MovePressInput;
2046
2056
  experimentalDragInput?: DragInputMode;
@@ -1,5 +1,5 @@
1
- import { R as AlgNode, r as Alg, M as Move, U as AppendOptions, W as Grouping, X as LineComment, Y as Commutator, Z as Conjugate, _ as Newline, $ as Pause, a0 as KeyMapping, A as AlgLeaf } from '../PuzzleLoader-R-puDLmC.js';
2
- export { a1 as AlgBranch, a2 as AppendCancelOptions, a3 as ExperimentalNotationType, a4 as ExperimentalParsed, a5 as ExperimentalSerializationOptions, a6 as GroupingModifications, a7 as MoveModifications, w as PuzzleSpecificSimplifyOptions, a8 as QuantumMove, a9 as SimplifyOptions } from '../PuzzleLoader-R-puDLmC.js';
1
+ import { R as AlgNode, r as Alg, M as Move, U as AppendOptions, W as Grouping, X as LineComment, Y as Commutator, Z as Conjugate, _ as Newline, $ as Pause, a0 as KeyMapping, A as AlgLeaf } from '../PuzzleLoader-Bp8zngUn.js';
2
+ export { a1 as AlgBranch, a2 as AppendCancelOptions, a3 as ExperimentalNotationType, a4 as ExperimentalParsed, a5 as ExperimentalSerializationOptions, a6 as GroupingModifications, a7 as MoveModifications, w as PuzzleSpecificSimplifyOptions, a8 as QuantumMove, a9 as SimplifyOptions } from '../PuzzleLoader-Bp8zngUn.js';
3
3
  import 'type-fest';
4
4
  import 'three/src/Three.js';
5
5
 
@@ -1,5 +1,5 @@
1
- import { A as AlgLeafEvent, O as OrientationEvent } from '../events-IfSwQLYm.js';
2
- import { K as KPattern, t as PuzzleID, s as PuzzleLoader, a0 as KeyMapping, r as Alg, M as Move, z as MillisecondTimestamp } from '../PuzzleLoader-R-puDLmC.js';
1
+ import { A as AlgLeafEvent, O as OrientationEvent } from '../events-CewDA1aS.js';
2
+ import { K as KPattern, t as PuzzleID, s as PuzzleLoader, a0 as KeyMapping, r as Alg, M as Move, z as MillisecondTimestamp } from '../PuzzleLoader-Bp8zngUn.js';
3
3
  import 'type-fest';
4
4
  import 'three/src/Three.js';
5
5
 
@@ -0,0 +1,239 @@
1
+ import {
2
+ PortableWorker,
3
+ wrap
4
+ } from "./chunk-FTE3QI5X.js";
5
+ import {
6
+ exposeAPI
7
+ } from "./chunk-7GUL3OBQ.js";
8
+ import {
9
+ Alg
10
+ } from "./chunk-O6HEZXGY.js";
11
+
12
+ // src/cubing/search/worker-workarounds/index.ts
13
+ function searchWorkerURLImportMetaResolve() {
14
+ return import.meta.resolve("./search-worker-entry.js");
15
+ }
16
+ function searchWorkerURLNewURLImportMetaURL() {
17
+ return new URL("./search-worker-entry.js", import.meta.url);
18
+ }
19
+ async function searchWorkerURLEsbuildWorkaround() {
20
+ exposeAPI.expose = false;
21
+ return (await import("./search-worker-entry.js")).WORKER_ENTRY_FILE_URL;
22
+ }
23
+
24
+ // src/cubing/search/instantiator.ts
25
+ function wrapAPI(worker) {
26
+ return wrap(worker);
27
+ }
28
+ async function instantiateModuleWorker(workerEntryFileURL) {
29
+ return new Promise(async (resolve, reject) => {
30
+ try {
31
+ const worker = new PortableWorker(workerEntryFileURL);
32
+ const onFirstMessage = (messageData) => {
33
+ if (messageData === "comlink-exposed") {
34
+ resolve(wrapAPI(worker));
35
+ } else {
36
+ reject(
37
+ new Error(`wrong module instantiation message ${messageData}`)
38
+ );
39
+ }
40
+ };
41
+ const onError = (e) => {
42
+ reject(e);
43
+ };
44
+ if ("once" in worker) {
45
+ worker.once("message", onFirstMessage);
46
+ } else {
47
+ worker.addEventListener("error", onError, {
48
+ once: true
49
+ });
50
+ worker.addEventListener(
51
+ "message",
52
+ (e) => onFirstMessage(e.data),
53
+ {
54
+ once: true
55
+ }
56
+ );
57
+ }
58
+ } catch (e) {
59
+ reject(e);
60
+ }
61
+ });
62
+ }
63
+ var allWorkerAPIPromises = [];
64
+ async function instantiateWorkerAPI() {
65
+ const workerAPIPromise = instantiateWorkerImplementation();
66
+ allWorkerAPIPromises.push(workerAPIPromise);
67
+ const insideAPI = await workerAPIPromise;
68
+ insideAPI.setDebugMeasurePerf(searchOutsideDebugGlobals.logPerf);
69
+ insideAPI.setScramblePrefetchLevel(
70
+ searchOutsideDebugGlobals.scramblePrefetchLevel
71
+ );
72
+ return workerAPIPromise;
73
+ }
74
+ async function instantiateWorkerImplementation() {
75
+ if (globalThis.location?.protocol === "file:") {
76
+ console.warn(
77
+ "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"
78
+ );
79
+ }
80
+ function failed(methodDescription) {
81
+ return `Module worker instantiation${methodDescription ? ` ${methodDescription}` : ""} failed`;
82
+ }
83
+ const importMetaResolveStrategy = [
84
+ async () => instantiateModuleWorker(searchWorkerURLImportMetaResolve()),
85
+ "using `import.meta.resolve(\u2026)",
86
+ null
87
+ ];
88
+ const esbuildWorkaroundStrategy = [
89
+ async () => instantiateModuleWorker(await searchWorkerURLEsbuildWorkaround()),
90
+ "using the `esbuild` workaround",
91
+ // TODO: we will hopefully discontinue the `esbuild` workaround at some
92
+ // point, but `esbuild` has been stuck for 3 years on this issue. Because
93
+ // `esbuild` and Vite (which uses `esbuild`) are now dominating the
94
+ // ecosystem, this just causes a warning for a lot of devs/users that they
95
+ // can't do anything about. As frustrating as the situation is, the
96
+ // workaround is semantically fine (even if it's convoluted) and is
97
+ // preserved by `esbuild`-based flows in practice. So we suppress the
98
+ // warning in the medium-term but maintain long-term hope that we can
99
+ // remove it (and the other fallbacks as well).
100
+ null
101
+ ];
102
+ const newURLStrategy = [
103
+ async () => instantiateModuleWorker(searchWorkerURLNewURLImportMetaURL()),
104
+ "using `new URL(\u2026, import.meta.url)`",
105
+ "will"
106
+ ];
107
+ const fallbackOrder = searchOutsideDebugGlobals.prioritizeEsbuildWorkaroundForWorkerInstantiation ? [esbuildWorkaroundStrategy, importMetaResolveStrategy, newURLStrategy] : [importMetaResolveStrategy, esbuildWorkaroundStrategy, newURLStrategy];
108
+ for (const [fn, description, warnOnSuccess] of fallbackOrder) {
109
+ try {
110
+ const worker = await fn();
111
+ if (warnOnSuccess) {
112
+ if (searchOutsideDebugGlobals.showWorkerInstantiationWarnings) {
113
+ console.warn(
114
+ `Module worker instantiation required ${description}. \`cubing.js\` ${warnOnSuccess} not support this fallback in the future.`
115
+ );
116
+ }
117
+ }
118
+ return worker;
119
+ } catch {
120
+ }
121
+ }
122
+ throw new Error(`${failed()}. There are no more fallbacks available.`);
123
+ }
124
+
125
+ // src/cubing/search/outside.ts
126
+ var cachedWorkerInstance;
127
+ function getCachedWorkerInstance() {
128
+ return cachedWorkerInstance ??= instantiateWorkerAPI();
129
+ }
130
+ async function mapToAllWorkers(f) {
131
+ await Promise.all(
132
+ allWorkerAPIPromises.map(async (worker) => {
133
+ f(await worker);
134
+ })
135
+ );
136
+ }
137
+ async function randomScrambleForEvent(eventID) {
138
+ const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble ? await instantiateWorkerAPI() : await getCachedWorkerInstance();
139
+ const scrambleString = await worker.randomScrambleStringForEvent(eventID);
140
+ return Alg.fromString(scrambleString);
141
+ }
142
+ async function deriveScrambleForEvent(derivationSeedHex, derivationSaltHierarchy, eventID) {
143
+ if (!searchOutsideDebugGlobals.allowDerivedScrambles) {
144
+ throw new Error("Derived scrambles are not allowed.");
145
+ }
146
+ const worker = searchOutsideDebugGlobals.forceNewWorkerForEveryScramble ? await instantiateWorkerAPI() : await getCachedWorkerInstance();
147
+ const scrambleString = await worker.deriveScrambleStringForEvent(
148
+ derivationSeedHex,
149
+ derivationSaltHierarchy,
150
+ eventID
151
+ );
152
+ return Alg.fromString(scrambleString);
153
+ }
154
+ async function experimentalSolve3x3x3IgnoringCenters(pattern) {
155
+ const cwi = await getCachedWorkerInstance();
156
+ return Alg.fromString(await cwi.solve333ToString(pattern.patternData));
157
+ }
158
+ async function experimentalSolve2x2x2(pattern) {
159
+ const cwi = await getCachedWorkerInstance();
160
+ return Alg.fromString(await cwi.solve222ToString(pattern.patternData));
161
+ }
162
+ async function solveSkewb(pattern) {
163
+ const cwi = await getCachedWorkerInstance();
164
+ return Alg.fromString(await cwi.solveSkewbToString(pattern.patternData));
165
+ }
166
+ async function solvePyraminx(pattern) {
167
+ const cwi = await getCachedWorkerInstance();
168
+ return Alg.fromString(await cwi.solvePyraminxToString(pattern.patternData));
169
+ }
170
+ async function solveMegaminx(pattern) {
171
+ const cwi = await getCachedWorkerInstance();
172
+ return Alg.fromString(await cwi.solveMegaminxToString(pattern.patternData));
173
+ }
174
+ async function solveTwips(kpuzzle, pattern, options) {
175
+ const { targetPattern, ...otherOptions } = options ?? {};
176
+ const apiOptions = otherOptions;
177
+ if (targetPattern) {
178
+ apiOptions.targetPattern = targetPattern.patternData;
179
+ }
180
+ const { ...def } = kpuzzle.definition;
181
+ delete def.experimentalIsPatternSolved;
182
+ const dedicatedWorker = await instantiateWorkerAPI();
183
+ try {
184
+ return Alg.fromString(
185
+ // TODO: unnecessary because we terminate the worker?
186
+ await dedicatedWorker.solveTwipsToString(
187
+ def,
188
+ pattern.patternData,
189
+ apiOptions
190
+ )
191
+ );
192
+ } finally {
193
+ console.log("Search ended, terminating dedicated `twips` worker.");
194
+ }
195
+ }
196
+ var searchOutsideDebugGlobals = {
197
+ logPerf: true,
198
+ scramblePrefetchLevel: "auto",
199
+ forceNewWorkerForEveryScramble: false,
200
+ showWorkerInstantiationWarnings: true,
201
+ prioritizeEsbuildWorkaroundForWorkerInstantiation: false,
202
+ allowDerivedScrambles: false
203
+ };
204
+ function setSearchDebug(options) {
205
+ const { logPerf, scramblePrefetchLevel } = options;
206
+ if (typeof logPerf !== "undefined") {
207
+ searchOutsideDebugGlobals.logPerf = logPerf;
208
+ void mapToAllWorkers((worker) => worker.setDebugMeasurePerf(logPerf));
209
+ }
210
+ if (typeof scramblePrefetchLevel !== "undefined") {
211
+ searchOutsideDebugGlobals.scramblePrefetchLevel = scramblePrefetchLevel;
212
+ void mapToAllWorkers(
213
+ (worker) => worker.setScramblePrefetchLevel(scramblePrefetchLevel)
214
+ );
215
+ }
216
+ for (const booleanField of [
217
+ "forceNewWorkerForEveryScramble",
218
+ "showWorkerInstantiationWarnings",
219
+ "prioritizeEsbuildWorkaroundForWorkerInstantiation",
220
+ "allowDerivedScrambles"
221
+ ]) {
222
+ if (booleanField in options) {
223
+ searchOutsideDebugGlobals[booleanField] = options[booleanField] ?? searchOutsideDebugGlobals[booleanField];
224
+ }
225
+ }
226
+ }
227
+
228
+ export {
229
+ randomScrambleForEvent,
230
+ deriveScrambleForEvent,
231
+ experimentalSolve3x3x3IgnoringCenters,
232
+ experimentalSolve2x2x2,
233
+ solveSkewb,
234
+ solvePyraminx,
235
+ solveMegaminx,
236
+ solveTwips,
237
+ setSearchDebug
238
+ };
239
+ //# sourceMappingURL=chunk-44CFF24P.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 \"../vendor/apache/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.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\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 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 const fallbackOrder: FallbackStrategyInfo[] =\n searchOutsideDebugGlobals.prioritizeEsbuildWorkaroundForWorkerInstantiation\n ? [esbuildWorkaroundStrategy, importMetaResolveStrategy, newURLStrategy]\n : [importMetaResolveStrategy, esbuildWorkaroundStrategy, newURLStrategy];\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, 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 // This can prevent a request to `search-worker-entry.js` when it doesn't exist, if the library semantics have been mangled by `esbuild`.\n prioritizeEsbuildWorkaroundForWorkerInstantiation: boolean;\n allowDerivedScrambles: boolean;\n}\n\nexport const searchOutsideDebugGlobals: SearchOutsideDebugGlobals = {\n logPerf: true,\n scramblePrefetchLevel: \"auto\",\n forceNewWorkerForEveryScramble: false,\n showWorkerInstantiationWarnings: true,\n prioritizeEsbuildWorkaroundForWorkerInstantiation: false,\n allowDerivedScrambles: false,\n};\n\nexport function setSearchDebug(\n options: Partial<SearchOutsideDebugGlobals>,\n): void {\n const { logPerf, scramblePrefetchLevel } = options;\n if (typeof logPerf !== \"undefined\") {\n searchOutsideDebugGlobals.logPerf = logPerf;\n void mapToAllWorkers((worker) => worker.setDebugMeasurePerf(logPerf));\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 \"allowDerivedScrambles\",\n ] as const) {\n if (booleanField in options) {\n searchOutsideDebugGlobals[booleanField] =\n options[booleanField] ?? searchOutsideDebugGlobals[booleanField];\n }\n }\n}\n"],
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;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