cubing 0.60.1 → 0.61.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/chunks/chunk-ZQLNUW2N.js +14 -0
- package/dist/bin/chunks/chunk-ZQLNUW2N.js.map +7 -0
- package/dist/bin/order.js +46 -42
- package/dist/bin/order.js.map +2 -2
- package/dist/bin/puzzle-geometry-bin.js +379 -257
- package/dist/bin/puzzle-geometry-bin.js.map +3 -3
- package/dist/bin/scramble.js +124 -102
- package/dist/bin/scramble.js.map +3 -3
- package/dist/lib/cubing/{PuzzleLoader-ApHCdGgn.d.ts → PuzzleLoader-CkghxdIL.d.ts} +166 -159
- package/dist/lib/cubing/alg/index.d.ts +2 -2
- package/dist/lib/cubing/bluetooth/index.d.ts +3 -3
- package/dist/lib/cubing/bluetooth/index.js +4 -4
- package/dist/lib/cubing/{bluetooth-puzzle-CN0X1-Rm.d.ts → bluetooth-puzzle-c-_IBAdu.d.ts} +1 -1
- package/dist/lib/cubing/chunks/{chunk-ABQAUY7H.js → chunk-557DMXD6.js} +3 -3
- package/dist/lib/cubing/chunks/{chunk-UWBMBZER.js → chunk-7DT3G3FA.js} +6 -6
- package/dist/lib/cubing/chunks/{chunk-UWBMBZER.js.map → chunk-7DT3G3FA.js.map} +2 -2
- package/dist/lib/cubing/chunks/{chunk-QDEGPHPS.js → chunk-FKKRSXUI.js} +2 -2
- package/dist/lib/cubing/chunks/chunk-FKKRSXUI.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-BUZPONAW.js → chunk-I5QO52OG.js} +2 -2
- package/dist/lib/cubing/chunks/{chunk-PVOSBZRD.js → chunk-KZGAQEPN.js} +3 -3
- package/dist/lib/cubing/chunks/{chunk-RUSWM2KK.js → chunk-ST4K23C3.js} +2 -2
- package/dist/lib/cubing/chunks/{chunk-RUSWM2KK.js.map → chunk-ST4K23C3.js.map} +1 -1
- package/dist/lib/cubing/chunks/{chunk-REBGU5ET.js → chunk-T3SF7NHB.js} +2 -2
- package/dist/lib/cubing/chunks/{chunk-OJI4YUWF.js → chunk-UMNYMJKD.js} +4 -4
- package/dist/lib/cubing/chunks/{chunk-WIZJQ7QS.js → chunk-UZ7SWKN6.js} +15 -15
- package/dist/lib/cubing/chunks/{chunk-PSQEELP4.js → chunk-WAYEJXCG.js} +1 -1
- package/dist/lib/cubing/chunks/chunk-WAYEJXCG.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-NX2Q6B7Y.js → chunk-ZKJKRQKY.js} +2 -2
- package/dist/lib/cubing/chunks/{chunk-NX2Q6B7Y.js.map → chunk-ZKJKRQKY.js.map} +2 -2
- package/dist/lib/cubing/chunks/{inside-7R2QE4L7.js → inside-K3VX2AIZ.js} +22 -22
- package/dist/lib/cubing/chunks/inside-K3VX2AIZ.js.map +7 -0
- package/dist/lib/cubing/chunks/{puzzles-dynamic-side-events-BOGUHF4Q.js → puzzles-dynamic-side-events-IMYJ533P.js} +1 -1
- package/dist/lib/cubing/chunks/puzzles-dynamic-side-events-IMYJ533P.js.map +7 -0
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-SYC27DSG.js → search-dynamic-sgs-side-events-RIRYKEP5.js} +4 -4
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-QGGV4PCJ.js → search-dynamic-sgs-unofficial-N4CRUF4Q.js} +4 -4
- package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-YZ3W3BZR.js → search-dynamic-solve-4x4x4-4UB4NMF3.js} +7 -7
- package/dist/lib/cubing/chunks/search-worker-entry.js +3 -3
- package/dist/lib/cubing/chunks/{twsearch-SXB7BAMF.js → twips-UDB2NAAU.js} +37 -37
- package/dist/lib/cubing/chunks/twips-UDB2NAAU.js.map +7 -0
- package/dist/lib/cubing/chunks/twips_wasm_bg-TPXD7W4R-2BXON3G5.js +10 -0
- package/dist/lib/cubing/chunks/twips_wasm_bg-TPXD7W4R-2BXON3G5.js.map +7 -0
- package/dist/lib/cubing/chunks/{twisty-dynamic-3d-LPZQIDD2.js → twisty-dynamic-3d-OCL53BVF.js} +5 -5
- package/dist/lib/cubing/{index-BFw0u55q.d.ts → index-B_8W-2zR.d.ts} +4 -4
- package/dist/lib/cubing/kpuzzle/index.d.ts +1 -1
- package/dist/lib/cubing/kpuzzle/index.js +1 -1
- package/dist/lib/cubing/notation/index.d.ts +1 -1
- package/dist/lib/cubing/notation/index.js +3 -3
- package/dist/lib/cubing/protocol/index.d.ts +1 -1
- package/dist/lib/cubing/protocol/index.js +3 -3
- package/dist/lib/cubing/puzzle-geometry/index.d.ts +2 -2
- package/dist/lib/cubing/puzzle-geometry/index.js +138 -179
- package/dist/lib/cubing/puzzle-geometry/index.js.map +3 -3
- package/dist/lib/cubing/puzzles/index.d.ts +1 -1
- package/dist/lib/cubing/puzzles/index.js +3 -3
- package/dist/lib/cubing/scramble/index.d.ts +2 -2
- package/dist/lib/cubing/scramble/index.js +6 -6
- package/dist/lib/cubing/search/index.d.ts +7 -3
- package/dist/lib/cubing/search/index.js +17 -8
- package/dist/lib/cubing/search/index.js.map +3 -3
- package/dist/lib/cubing/stream/index.d.ts +2 -2
- package/dist/lib/cubing/twisty/index.d.ts +2 -2
- package/dist/lib/cubing/twisty/index.js +5 -5
- package/dist/lib/cubing/twisty/index.js.map +1 -1
- package/experimental-json-schema/kpuzzle/KPatternData.schema.json +22 -30
- package/experimental-json-schema/kpuzzle/KPuzzleDefinition.schema.json +72 -89
- package/experimental-json-schema/kpuzzle/KTransformationData.schema.json +17 -26
- package/package.json +58 -102
- package/dist/bin/chunks/chunk-J53ID3VX.js +0 -26
- package/dist/bin/chunks/chunk-J53ID3VX.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-PSQEELP4.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-QDEGPHPS.js.map +0 -7
- package/dist/lib/cubing/chunks/inside-7R2QE4L7.js.map +0 -7
- package/dist/lib/cubing/chunks/puzzles-dynamic-side-events-BOGUHF4Q.js.map +0 -7
- package/dist/lib/cubing/chunks/twsearch-SXB7BAMF.js.map +0 -7
- package/dist/lib/cubing/chunks/twsearch_wasm_bg-2J7XXRGI-WOU3FVAE.js +0 -10
- package/dist/lib/cubing/chunks/twsearch_wasm_bg-2J7XXRGI-WOU3FVAE.js.map +0 -7
- /package/dist/lib/cubing/chunks/{chunk-ABQAUY7H.js.map → chunk-557DMXD6.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{chunk-BUZPONAW.js.map → chunk-I5QO52OG.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{chunk-PVOSBZRD.js.map → chunk-KZGAQEPN.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{chunk-REBGU5ET.js.map → chunk-T3SF7NHB.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{chunk-OJI4YUWF.js.map → chunk-UMNYMJKD.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{chunk-WIZJQ7QS.js.map → chunk-UZ7SWKN6.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-SYC27DSG.js.map → search-dynamic-sgs-side-events-RIRYKEP5.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-QGGV4PCJ.js.map → search-dynamic-sgs-unofficial-N4CRUF4Q.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-YZ3W3BZR.js.map → search-dynamic-solve-4x4x4-4UB4NMF3.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{twisty-dynamic-3d-LPZQIDD2.js.map → twisty-dynamic-3d-OCL53BVF.js.map} +0 -0
|
@@ -357,10 +357,6 @@ interface NotationMapper {
|
|
|
357
357
|
notationToExternal(move: Move): Move | null;
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
declare function parseOptions(argv: string[]): {
|
|
361
|
-
puzzleDescription: PuzzleDescription | null;
|
|
362
|
-
options: PuzzleGeometryOptions;
|
|
363
|
-
};
|
|
364
360
|
type FaceName = string;
|
|
365
361
|
type OrientationDirection = [number, number, number];
|
|
366
362
|
type FaceBasedOrientationDescription = [
|
|
@@ -381,7 +377,7 @@ declare class PuzzleGeometryFullOptions {
|
|
|
381
377
|
outerBlockMoves: boolean;
|
|
382
378
|
vertexMoves: boolean;
|
|
383
379
|
addRotations: boolean;
|
|
384
|
-
moveList: string[] | null;
|
|
380
|
+
moveList: (string | Move)[] | null;
|
|
385
381
|
fixedOrientation: boolean;
|
|
386
382
|
fixedPieceType: null | "e" | "v" | "f";
|
|
387
383
|
orientCenters: boolean;
|
|
@@ -414,157 +410,6 @@ declare class Perm {
|
|
|
414
410
|
order(): number;
|
|
415
411
|
}
|
|
416
412
|
|
|
417
|
-
type KPatternData = Record<string, KPatternOrbitData>;
|
|
418
|
-
interface KPatternOrbitData {
|
|
419
|
-
pieces: number[];
|
|
420
|
-
orientation: number[];
|
|
421
|
-
/** Each piece may have an "orientation mod" that means "the orientation of
|
|
422
|
-
* this piece is known mod [value]".
|
|
423
|
-
*
|
|
424
|
-
* Suppose `.numOrientations` for this orbit has a value of N. This is
|
|
425
|
-
* considered the default value for the orientation mod of each piece in the
|
|
426
|
-
* orbit.
|
|
427
|
-
*
|
|
428
|
-
* - Each entry must be one of the following:
|
|
429
|
-
* - A proper divisor of N.
|
|
430
|
-
* - For example: if N is 12, then one of: 1, 2, 3, 6
|
|
431
|
-
* - The special value 0, indicating the default value (N).
|
|
432
|
-
* - This indicates that the orientation of a piece is fully known, i.e.
|
|
433
|
-
* that its "orientation mod" is the default value (N). However, such a
|
|
434
|
-
* value is recorded as 0 instead of N, in order to make it simpler to
|
|
435
|
-
* implement and debug pattern logic involving the default value.
|
|
436
|
-
* - If `.orientationMod[i]` is a proper divisor of N (i.e. not 0), then
|
|
437
|
-
* `.orientation[i]` must be less than `.orientationMod[i]`. That is, the
|
|
438
|
-
* orientation values must be individually "normalized" for each piece.
|
|
439
|
-
* - If the `orientationMod` field is not present, then every piece is
|
|
440
|
-
* considered to have the default value for its "orientation mod".
|
|
441
|
-
*
|
|
442
|
-
* For a "real-world" example of this concept, consider a traditional analog
|
|
443
|
-
* 12-hour clock dial, like one that might hang on the wall in a school room.
|
|
444
|
-
* Although there are 24 hours in a day, A.M. and P.M. times are not
|
|
445
|
-
* distinguishable on such a clock. Since 3:00 (AM) and 15:00 are not
|
|
446
|
-
* distinguishable, we would read either of those times as 3:00 with an
|
|
447
|
-
* implicit "orientation mod" of 12.
|
|
448
|
-
*
|
|
449
|
-
* For most puzzles, however, we care about "visual" indistinguishability
|
|
450
|
-
* rather than "temporal" indistinguishability. To adapt the previous example,
|
|
451
|
-
* imagine a 24-hour clock with 24 hour marks around the dial, but where the
|
|
452
|
-
* hour hand is symmetric and points equally at the current hour as well as
|
|
453
|
-
* its diametic opposite (like a compass needle but painted all in one color).
|
|
454
|
-
* This has the same set of "valid patterns" as a normal 12-hour clock. Such a
|
|
455
|
-
* clock also has an "orientation mod" of 12, but where the multiples of the
|
|
456
|
-
* modulus have been "unfolded" to show their full symmetry instead of being
|
|
457
|
-
* implicit.
|
|
458
|
-
*
|
|
459
|
-
* For a non-trivial puzzle example, consider Eitan's FisherTwist, a shape mod
|
|
460
|
-
* of the 3x3x3 cube:
|
|
461
|
-
* https://www.hknowstore.com/locale/en-US/item.aspx?corpname=nowstore&itemid=97eb4e89-367e-4d02-b7f0-34e5e7f3cd12
|
|
462
|
-
*
|
|
463
|
-
* - The 4 equatorial centers have C₂ symmetry — it is possible to rotate any
|
|
464
|
-
* of these centers 180° without a visible change to the state. This means
|
|
465
|
-
* that the possible orientations "loop" after incrementing the orientation
|
|
466
|
-
* by 2 (two turns clockwise), and therefore the "orientation mod" of a
|
|
467
|
-
* given piece is only 2.
|
|
468
|
-
* - If we apply a counter-clockwise rotation to one of these centers, the
|
|
469
|
-
* transformation applies an orientation of 3. But the net orientation is
|
|
470
|
-
* recorded as a normalized value of 1 instead, because 3 (mod 2) ≡ 1 (mod
|
|
471
|
-
* 2).
|
|
472
|
-
* - The 2 polar centers (U and D) have no distinguishable rotations. This
|
|
473
|
-
* means that their orientation is "known mod 1" — any transformation of one
|
|
474
|
-
* of these centers is indistinguishable from another transformation of the
|
|
475
|
-
* same center, and all of them are mapped to a value of 0 (the only
|
|
476
|
-
* possible value that exists mod 1).
|
|
477
|
-
*
|
|
478
|
-
* For 3x3x3:
|
|
479
|
-
*
|
|
480
|
-
* - When solving a normal 3x3x3, center orientations are conventionally
|
|
481
|
-
* ignored. This is similar to the polar center case for Eitan's
|
|
482
|
-
* FisherTwist, and the "orientation mod" of each piece is 1. This is also
|
|
483
|
-
* the core motivating use case.
|
|
484
|
-
* - For a supercube
|
|
485
|
-
* (https://experiments.cubing.net/cubing.js/twisty/supercube.html) or the
|
|
486
|
-
* general case of a "picture cube", all four center orientations are
|
|
487
|
-
* distinguishable for every center. This means all centers have the default
|
|
488
|
-
* orientation mod of 4. As documented above, this can be recorded with a
|
|
489
|
-
* `.orientationMod` of `[0, 0, 0, 0, 0, 0]`, or equivalently by omitting
|
|
490
|
-
* the `.orientationMod` field.
|
|
491
|
-
* - When modeling a real 3x3x3 speedcube, it is common to have a logo on a
|
|
492
|
-
* single sticker. If you want to model the exact visually distinguishable
|
|
493
|
-
* states of such a puzzles, it is possible to use an `.orientationMod` such
|
|
494
|
-
* as `[0, 1, 1, 1, 1, 1]`. For example, this can make it easy to find an
|
|
495
|
-
* alg for a given case "while keeping the logo the same", without placing
|
|
496
|
-
* more restrictions on other centers (which could make the search slower or
|
|
497
|
-
* produce longer solutions).
|
|
498
|
-
*
|
|
499
|
-
* For those with a mathematical background, you may notice a relationship to
|
|
500
|
-
* the concept of a coset (https://en.wikipedia.org/wiki/Coset). For example,
|
|
501
|
-
* consider the group of patterns of a `KPuzzle` (without indistinguishable
|
|
502
|
-
* pieces) generated by a set of transformations. We can assign each set of
|
|
503
|
-
* piece orbits an orientation mod value (which must be identical for all
|
|
504
|
-
* constituent pieces of the same orbit). Each such choice generates a set of
|
|
505
|
-
* valid `KPattern`s that forms a subgroup, and each set of valid `.orientation`
|
|
506
|
-
* values defines one coset of this set. However, note that the set of valid
|
|
507
|
-
* `KPattern`s does *not* form a group when there are any pieces with different
|
|
508
|
-
* `.orientationMod` values that share an orbit.
|
|
509
|
-
*
|
|
510
|
-
* --------
|
|
511
|
-
*
|
|
512
|
-
* Note that the concept of "orientation mod" exclusively applies to `KPattern`,
|
|
513
|
-
* not `KTransformation`. If we tried to apply the orientation mod
|
|
514
|
-
* calculations to the *transformations* of Eitan's FisherTwist, then `SWAP =
|
|
515
|
-
* [U, M' E2 M]` would be indistinguishable from the identity. This would mean
|
|
516
|
-
* that if we calculated `SWAP` and then used this calculation for `S SWAP
|
|
517
|
-
* S'`, then we would conclude that it has no net effect. However, `S SWAP S'`
|
|
518
|
-
* does *not* have the same effect as doing nothing — it visibly rotates the L
|
|
519
|
-
* and R centers! (In mathematical terms: the set of `KTransformation`s would
|
|
520
|
-
* not form a valid set of semigroup actions, due to broken associativity.)
|
|
521
|
-
*
|
|
522
|
-
* Although there are times that we could theoretically save some time/space
|
|
523
|
-
* by ignoring some information when it's not needed for working with certain
|
|
524
|
-
* `KTransformation`s (e.g. ignoring all center orientations for 3x3x3), it is
|
|
525
|
-
* more practical for each `KTransformation` to always track the full range
|
|
526
|
-
* for each piece's `.orientation`. For example:
|
|
527
|
-
*
|
|
528
|
-
* - This is simpler, both conceptually and in code.
|
|
529
|
-
* - This allows changing the set of moves for a puzzle, without recalculating
|
|
530
|
-
* cached transformations or certain lookup tables (useful for alg
|
|
531
|
-
* searches).
|
|
532
|
-
* - This allows swapping out a normal 3x3x3 in a `<twisty-player>` for a
|
|
533
|
-
* picture cube, without re-calculating the center orientations of the
|
|
534
|
-
* current alg.
|
|
535
|
-
*
|
|
536
|
-
* These use cases may not be strictly "necessary", but the opposite behaviour
|
|
537
|
-
* might be surprising or frustrating if someone does not expect it. So we
|
|
538
|
-
* implement it this way.
|
|
539
|
-
*
|
|
540
|
-
* Informally, the `KTransformation` has the full responsibility for tracking
|
|
541
|
-
* "what really happens" — even if the effect is invisible in some cases,
|
|
542
|
-
* while the `KPattern` tracks both what "is" and what "isn't" known.
|
|
543
|
-
**/
|
|
544
|
-
orientationMod?: number[];
|
|
545
|
-
}
|
|
546
|
-
type KTransformationData = Record<string, KTransformationOrbitData>;
|
|
547
|
-
interface KTransformationOrbitData {
|
|
548
|
-
permutation: number[];
|
|
549
|
-
orientationDelta: number[];
|
|
550
|
-
}
|
|
551
|
-
interface KPuzzleOrbitDefinition {
|
|
552
|
-
orbitName: string;
|
|
553
|
-
numPieces: number;
|
|
554
|
-
numOrientations: number;
|
|
555
|
-
}
|
|
556
|
-
interface KPuzzleDefinition {
|
|
557
|
-
name: string;
|
|
558
|
-
orbits: KPuzzleOrbitDefinition[];
|
|
559
|
-
defaultPattern: KPatternData;
|
|
560
|
-
moves: Record<string, KTransformationData>;
|
|
561
|
-
derivedMoves?: Record<string, string>;
|
|
562
|
-
experimentalIsPatternSolved?: (kpattern: KPattern, options: {
|
|
563
|
-
ignorePuzzleOrientation: boolean;
|
|
564
|
-
ignoreCenterOrientation: boolean;
|
|
565
|
-
}) => boolean;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
413
|
declare class PGOrbitDef {
|
|
569
414
|
size: number;
|
|
570
415
|
mod: number;
|
|
@@ -635,10 +480,10 @@ declare class VisibleState extends PGTransformBase {
|
|
|
635
480
|
}
|
|
636
481
|
|
|
637
482
|
type PuzzleDescriptionString = string;
|
|
638
|
-
declare const
|
|
483
|
+
declare const pgPuzzle: {
|
|
639
484
|
[name: string]: PuzzleDescriptionString;
|
|
640
485
|
};
|
|
641
|
-
type PuzzleName = keyof typeof
|
|
486
|
+
type PuzzleName = keyof typeof pgPuzzle;
|
|
642
487
|
|
|
643
488
|
declare class Quat {
|
|
644
489
|
a: number;
|
|
@@ -839,6 +684,168 @@ declare class PGNotation {
|
|
|
839
684
|
remapKPuzzleDefinition(kpuzzleDefinition: KPuzzleDefinition): KPuzzleDefinition;
|
|
840
685
|
}
|
|
841
686
|
|
|
687
|
+
type KPatternData = {
|
|
688
|
+
[orbitName: string]: KPatternOrbitData;
|
|
689
|
+
};
|
|
690
|
+
interface KPatternOrbitData {
|
|
691
|
+
pieces: number[];
|
|
692
|
+
orientation: number[];
|
|
693
|
+
/** Each piece may have an "orientation mod" that means "the orientation of
|
|
694
|
+
* this piece is known mod [value]".
|
|
695
|
+
*
|
|
696
|
+
* Suppose `.numOrientations` for this orbit has a value of N. This is
|
|
697
|
+
* considered the default value for the orientation mod of each piece in the
|
|
698
|
+
* orbit.
|
|
699
|
+
*
|
|
700
|
+
* - Each entry must be one of the following:
|
|
701
|
+
* - A proper divisor of N.
|
|
702
|
+
* - For example: if N is 12, then one of: 1, 2, 3, 6
|
|
703
|
+
* - The special value 0, indicating the default value (N).
|
|
704
|
+
* - This indicates that the orientation of a piece is fully known, i.e.
|
|
705
|
+
* that its "orientation mod" is the default value (N). However, such a
|
|
706
|
+
* value is recorded as 0 instead of N, in order to make it simpler to
|
|
707
|
+
* implement and debug pattern logic involving the default value.
|
|
708
|
+
* - If `.orientationMod[i]` is a proper divisor of N (i.e. not 0), then
|
|
709
|
+
* `.orientation[i]` must be less than `.orientationMod[i]`. That is, the
|
|
710
|
+
* orientation values must be individually "normalized" for each piece.
|
|
711
|
+
* - If the `orientationMod` field is not present, then every piece is
|
|
712
|
+
* considered to have the default value for its "orientation mod".
|
|
713
|
+
*
|
|
714
|
+
* For a "real-world" example of this concept, consider a traditional analog
|
|
715
|
+
* 12-hour clock dial, like one that might hang on the wall in a school room.
|
|
716
|
+
* Although there are 24 hours in a day, A.M. and P.M. times are not
|
|
717
|
+
* distinguishable on such a clock. Since 3:00 (AM) and 15:00 are not
|
|
718
|
+
* distinguishable, we would read either of those times as 3:00 with an
|
|
719
|
+
* implicit "orientation mod" of 12.
|
|
720
|
+
*
|
|
721
|
+
* For most puzzles, however, we care about "visual" indistinguishability
|
|
722
|
+
* rather than "temporal" indistinguishability. To adapt the previous example,
|
|
723
|
+
* imagine a 24-hour clock with 24 hour marks around the dial, but where the
|
|
724
|
+
* hour hand is symmetric and points equally at the current hour as well as
|
|
725
|
+
* its diametic opposite (like a compass needle but painted all in one color).
|
|
726
|
+
* This has the same set of "valid patterns" as a normal 12-hour clock. Such a
|
|
727
|
+
* clock also has an "orientation mod" of 12, but where the multiples of the
|
|
728
|
+
* modulus have been "unfolded" to show their full symmetry instead of being
|
|
729
|
+
* implicit.
|
|
730
|
+
*
|
|
731
|
+
* For a non-trivial puzzle example, consider Eitan's FisherTwist, a shape mod
|
|
732
|
+
* of the 3x3x3 cube:
|
|
733
|
+
* https://www.hknowstore.com/locale/en-US/item.aspx?corpname=nowstore&itemid=97eb4e89-367e-4d02-b7f0-34e5e7f3cd12
|
|
734
|
+
*
|
|
735
|
+
* - The 4 equatorial centers have C₂ symmetry — it is possible to rotate any
|
|
736
|
+
* of these centers 180° without a visible change to the state. This means
|
|
737
|
+
* that the possible orientations "loop" after incrementing the orientation
|
|
738
|
+
* by 2 (two turns clockwise), and therefore the "orientation mod" of a
|
|
739
|
+
* given piece is only 2.
|
|
740
|
+
* - If we apply a counter-clockwise rotation to one of these centers, the
|
|
741
|
+
* transformation applies an orientation of 3. But the net orientation is
|
|
742
|
+
* recorded as a normalized value of 1 instead, because 3 (mod 2) ≡ 1 (mod
|
|
743
|
+
* 2).
|
|
744
|
+
* - The 2 polar centers (U and D) have no distinguishable rotations. This
|
|
745
|
+
* means that their orientation is "known mod 1" — any transformation of one
|
|
746
|
+
* of these centers is indistinguishable from another transformation of the
|
|
747
|
+
* same center, and all of them are mapped to a value of 0 (the only
|
|
748
|
+
* possible value that exists mod 1).
|
|
749
|
+
*
|
|
750
|
+
* For 3x3x3:
|
|
751
|
+
*
|
|
752
|
+
* - When solving a normal 3x3x3, center orientations are conventionally
|
|
753
|
+
* ignored. This is similar to the polar center case for Eitan's
|
|
754
|
+
* FisherTwist, and the "orientation mod" of each piece is 1. This is also
|
|
755
|
+
* the core motivating use case.
|
|
756
|
+
* - For a supercube
|
|
757
|
+
* (https://experiments.cubing.net/cubing.js/twisty/supercube.html) or the
|
|
758
|
+
* general case of a "picture cube", all four center orientations are
|
|
759
|
+
* distinguishable for every center. This means all centers have the default
|
|
760
|
+
* orientation mod of 4. As documented above, this can be recorded with a
|
|
761
|
+
* `.orientationMod` of `[0, 0, 0, 0, 0, 0]`, or equivalently by omitting
|
|
762
|
+
* the `.orientationMod` field.
|
|
763
|
+
* - When modeling a real 3x3x3 speedcube, it is common to have a logo on a
|
|
764
|
+
* single sticker. If you want to model the exact visually distinguishable
|
|
765
|
+
* states of such a puzzles, it is possible to use an `.orientationMod` such
|
|
766
|
+
* as `[0, 1, 1, 1, 1, 1]`. For example, this can make it easy to find an
|
|
767
|
+
* alg for a given case "while keeping the logo the same", without placing
|
|
768
|
+
* more restrictions on other centers (which could make the search slower or
|
|
769
|
+
* produce longer solutions).
|
|
770
|
+
*
|
|
771
|
+
* For those with a mathematical background, you may notice a relationship to
|
|
772
|
+
* the concept of a coset (https://en.wikipedia.org/wiki/Coset). For example,
|
|
773
|
+
* consider the group of patterns of a `KPuzzle` (without indistinguishable
|
|
774
|
+
* pieces) generated by a set of transformations. We can assign each set of
|
|
775
|
+
* piece orbits an orientation mod value (which must be identical for all
|
|
776
|
+
* constituent pieces of the same orbit). Each such choice generates a set of
|
|
777
|
+
* valid `KPattern`s that forms a subgroup, and each set of valid `.orientation`
|
|
778
|
+
* values defines one coset of this set. However, note that the set of valid
|
|
779
|
+
* `KPattern`s does *not* form a group when there are any pieces with different
|
|
780
|
+
* `.orientationMod` values that share an orbit.
|
|
781
|
+
*
|
|
782
|
+
* --------
|
|
783
|
+
*
|
|
784
|
+
* Note that the concept of "orientation mod" exclusively applies to `KPattern`,
|
|
785
|
+
* not `KTransformation`. If we tried to apply the orientation mod
|
|
786
|
+
* calculations to the *transformations* of Eitan's FisherTwist, then `SWAP =
|
|
787
|
+
* [U, M' E2 M]` would be indistinguishable from the identity. This would mean
|
|
788
|
+
* that if we calculated `SWAP` and then used this calculation for `S SWAP
|
|
789
|
+
* S'`, then we would conclude that it has no net effect. However, `S SWAP S'`
|
|
790
|
+
* does *not* have the same effect as doing nothing — it visibly rotates the L
|
|
791
|
+
* and R centers! (In mathematical terms: the set of `KTransformation`s would
|
|
792
|
+
* not form a valid set of semigroup actions, due to broken associativity.)
|
|
793
|
+
*
|
|
794
|
+
* Although there are times that we could theoretically save some time/space
|
|
795
|
+
* by ignoring some information when it's not needed for working with certain
|
|
796
|
+
* `KTransformation`s (e.g. ignoring all center orientations for 3x3x3), it is
|
|
797
|
+
* more practical for each `KTransformation` to always track the full range
|
|
798
|
+
* for each piece's `.orientation`. For example:
|
|
799
|
+
*
|
|
800
|
+
* - This is simpler, both conceptually and in code.
|
|
801
|
+
* - This allows changing the set of moves for a puzzle, without recalculating
|
|
802
|
+
* cached transformations or certain lookup tables (useful for alg
|
|
803
|
+
* searches).
|
|
804
|
+
* - This allows swapping out a normal 3x3x3 in a `<twisty-player>` for a
|
|
805
|
+
* picture cube, without re-calculating the center orientations of the
|
|
806
|
+
* current alg.
|
|
807
|
+
*
|
|
808
|
+
* These use cases may not be strictly "necessary", but the opposite behaviour
|
|
809
|
+
* might be surprising or frustrating if someone does not expect it. So we
|
|
810
|
+
* implement it this way.
|
|
811
|
+
*
|
|
812
|
+
* Informally, the `KTransformation` has the full responsibility for tracking
|
|
813
|
+
* "what really happens" — even if the effect is invisible in some cases,
|
|
814
|
+
* while the `KPattern` tracks both what "is" and what "isn't" known.
|
|
815
|
+
**/
|
|
816
|
+
orientationMod?: number[];
|
|
817
|
+
}
|
|
818
|
+
type KTransformationData = {
|
|
819
|
+
[orbitName: string]: KTransformationOrbitData;
|
|
820
|
+
};
|
|
821
|
+
interface KTransformationOrbitData {
|
|
822
|
+
permutation: number[];
|
|
823
|
+
orientationDelta: number[];
|
|
824
|
+
}
|
|
825
|
+
interface KPuzzleOrbitDefinition {
|
|
826
|
+
orbitName: string;
|
|
827
|
+
numPieces: number;
|
|
828
|
+
numOrientations: number;
|
|
829
|
+
}
|
|
830
|
+
interface KPuzzleDefinitionJSON {
|
|
831
|
+
name: string;
|
|
832
|
+
orbits: KPuzzleOrbitDefinition[];
|
|
833
|
+
defaultPattern: KPatternData;
|
|
834
|
+
moves: {
|
|
835
|
+
[orbitName: string]: KTransformationData;
|
|
836
|
+
};
|
|
837
|
+
derivedMoves?: {
|
|
838
|
+
[derivedMove: string]: string;
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
interface KPuzzleDefinition extends KPuzzleDefinitionJSON {
|
|
843
|
+
experimentalIsPatternSolved?: (kpattern: KPattern, options: {
|
|
844
|
+
ignorePuzzleOrientation: boolean;
|
|
845
|
+
ignoreCenterOrientation: boolean;
|
|
846
|
+
}) => boolean;
|
|
847
|
+
}
|
|
848
|
+
|
|
842
849
|
declare class KTransformation {
|
|
843
850
|
#private;
|
|
844
851
|
readonly kpuzzle: KPuzzle;
|
|
@@ -2342,4 +2349,4 @@ interface PuzzleLoader {
|
|
|
2342
2349
|
algTransformData?: AlgTransformData;
|
|
2343
2350
|
}
|
|
2344
2351
|
|
|
2345
|
-
export {
|
|
2352
|
+
export { Pause as $, type AlgLeaf as A, type LeafIndex as B, KTransformation as C, type MillisecondDuration as D, type ExperimentalStickering as E, type BackViewLayout as F, backViewLayouts as G, TwistyAlgViewer as H, type TwistyPlayerConfig as I, TwistyPlayer as J, KPattern as K, type LeafCount as L, Move as M, NO_VALUE as N, TwizzleLink as O, Perm as P, Quat as Q, type AlgNode as R, type StickerDat as S, TwistyAlgEditor as T, type AppendOptions as U, type VisualizationFormat as V, Grouping as W, LineComment as X, Commutator as Y, Conjugate as Z, Newline as _, type PuzzleGeometryOptions as a, type KeyMapping as a0, type AlgBranch as a1, type GroupingModifications as a2, type MoveModifications as a3, type Parsed as a4, type ExperimentalNotationType as a5, type ExperimentalSerializationOptions as a6, type AppendCancelOptions as a7, type SimplifyOptions as a8, QuantumMove as a9, type KPuzzleDefinition as aa, type KPatternData as ab, type KPatternOrbitData as ac, type KPuzzleOrbitDefinition as ad, type KTransformationData as ae, type KTransformationOrbitData as af, type StickerDatAxis as b, type StickerDatFace as c, type StickerDatSticker as d, getPuzzleDescriptionString as e, getPuzzleGeometryByDesc as f, getPG3DNamedPuzzles as g, getPuzzleGeometryByName as h, PGNotation as i, PUZZLE_BASE_SHAPES as j, PUZZLE_CUT_TYPES as k, type PuzzleBaseShape as l, type PuzzleCutDescription as m, type PuzzleCutType as n, type PuzzleDescription as o, PuzzleGeometry as p, parsePuzzleDescription as q, Alg as r, type PuzzleLoader as s, type PuzzleID as t, KPuzzle as u, type StickeringMask as v, type PuzzleSpecificSimplifyOptions as w, type AlgTransformData as x, type AlgIndexer as y, type MillisecondTimestamp as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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-CkghxdIL.js';
|
|
2
|
+
export { a1 as AlgBranch, a7 as AppendCancelOptions, a5 as ExperimentalNotationType, a4 as ExperimentalParsed, a6 as ExperimentalSerializationOptions, a2 as GroupingModifications, a3 as MoveModifications, w as PuzzleSpecificSimplifyOptions, a9 as QuantumMove, a8 as SimplifyOptions } from '../PuzzleLoader-CkghxdIL.js';
|
|
3
3
|
import 'type-fest';
|
|
4
4
|
import 'three/src/Three.js';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BluetoothPuzzle } from '../bluetooth-puzzle-
|
|
3
|
-
export { A as MoveEvent, O as OrientationEvent } from '../bluetooth-puzzle-
|
|
1
|
+
import { t as PuzzleID, s as PuzzleLoader, a0 as KeyMapping, K as KPattern, r as Alg, M as Move, z as MillisecondTimestamp } from '../PuzzleLoader-CkghxdIL.js';
|
|
2
|
+
import { B as BluetoothPuzzle } from '../bluetooth-puzzle-c-_IBAdu.js';
|
|
3
|
+
export { A as MoveEvent, O as OrientationEvent } from '../bluetooth-puzzle-c-_IBAdu.js';
|
|
4
4
|
import 'type-fest';
|
|
5
5
|
import 'three/src/Three.js';
|
|
6
6
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
binaryComponentsToReid3x3x3,
|
|
3
3
|
twizzleBinaryToBinaryComponents
|
|
4
|
-
} from "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-557DMXD6.js";
|
|
5
5
|
import {
|
|
6
6
|
puzzles
|
|
7
|
-
} from "../chunks/chunk-
|
|
7
|
+
} from "../chunks/chunk-UZ7SWKN6.js";
|
|
8
8
|
import {
|
|
9
9
|
cube3x3x3,
|
|
10
10
|
experimental3x3x3KPuzzle
|
|
11
|
-
} from "../chunks/chunk-
|
|
11
|
+
} from "../chunks/chunk-ST4K23C3.js";
|
|
12
12
|
import {
|
|
13
13
|
KPattern
|
|
14
|
-
} from "../chunks/chunk-
|
|
14
|
+
} from "../chunks/chunk-WAYEJXCG.js";
|
|
15
15
|
import {
|
|
16
16
|
Alg,
|
|
17
17
|
Move,
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
normalize3x3x3Orientation,
|
|
4
4
|
puzzleOrientation3x3x3Cache,
|
|
5
5
|
puzzleOrientation3x3x3Idx
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ST4K23C3.js";
|
|
7
7
|
import {
|
|
8
8
|
KPattern
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WAYEJXCG.js";
|
|
10
10
|
|
|
11
11
|
// src/cubing/protocol/binary/orbit-indexing.ts
|
|
12
12
|
function identityPermutation(numElems) {
|
|
@@ -262,4 +262,4 @@ export {
|
|
|
262
262
|
bufferToSpacedHex,
|
|
263
263
|
spacedHexToBuffer
|
|
264
264
|
};
|
|
265
|
-
//# sourceMappingURL=chunk-
|
|
265
|
+
//# sourceMappingURL=chunk-557DMXD6.js.map
|
|
@@ -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-ZKJKRQKY.js";
|
|
7
7
|
import {
|
|
8
8
|
Alg
|
|
9
9
|
} from "./chunk-7D7ZUWUK.js";
|
|
@@ -281,7 +281,7 @@ async function solveMegaminx(pattern) {
|
|
|
281
281
|
await cwi.insideAPI.solveMegaminxToString(pattern.patternData)
|
|
282
282
|
);
|
|
283
283
|
}
|
|
284
|
-
async function
|
|
284
|
+
async function solveTwips(kpuzzle, pattern, options) {
|
|
285
285
|
const { targetPattern, ...otherOptions } = options ?? {};
|
|
286
286
|
const apiOptions = otherOptions;
|
|
287
287
|
if (targetPattern) {
|
|
@@ -292,14 +292,14 @@ async function solveTwsearch(kpuzzle, pattern, options) {
|
|
|
292
292
|
const dedicatedWorker = await instantiateWorker();
|
|
293
293
|
try {
|
|
294
294
|
return Alg.fromString(
|
|
295
|
-
await dedicatedWorker.insideAPI.
|
|
295
|
+
await dedicatedWorker.insideAPI.solveTwipsToString(
|
|
296
296
|
def,
|
|
297
297
|
pattern.patternData,
|
|
298
298
|
apiOptions
|
|
299
299
|
)
|
|
300
300
|
);
|
|
301
301
|
} finally {
|
|
302
|
-
console.log("Search ended, terminating dedicated `
|
|
302
|
+
console.log("Search ended, terminating dedicated `twips` worker.");
|
|
303
303
|
await dedicatedWorker.outsideAPI.terminate();
|
|
304
304
|
}
|
|
305
305
|
}
|
|
@@ -345,7 +345,7 @@ export {
|
|
|
345
345
|
solveSkewb,
|
|
346
346
|
solvePyraminx,
|
|
347
347
|
solveMegaminx,
|
|
348
|
-
|
|
348
|
+
solveTwips,
|
|
349
349
|
setSearchDebug
|
|
350
350
|
};
|
|
351
|
-
//# sourceMappingURL=chunk-
|
|
351
|
+
//# sourceMappingURL=chunk-7DT3G3FA.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 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;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;AACF,UAAM,eAAe,WAAW,UAAU;AAC1C,UAAM,eAAe,mBAAmB;AACxC,WAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC,gBAAgB,iBAAiB;AAAA,EA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eEndpoint 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 { TwipsOptions } from \"./inside/solve/twips\";\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 SolveTwipsOptions {\n generatorMoves?: string[];\n targetPattern?: KPattern;\n minDepth?: number;\n maxDepth?: number;\n}\n\nexport async function solveTwips(\n kpuzzle: KPuzzle,\n pattern: KPattern,\n options?: SolveTwipsOptions,\n): Promise<Alg> {\n const { targetPattern, ...otherOptions } = options ?? {};\n const apiOptions: TwipsOptions = otherOptions;\n if (targetPattern) {\n apiOptions.targetPattern = targetPattern.patternData;\n }\n const { ...def } = kpuzzle.definition;\n delete def.experimentalIsPatternSolved;\n // delete def.derivedMoves;\n const dedicatedWorker = await instantiateWorker();\n try {\n return Alg.fromString(\n await dedicatedWorker.insideAPI.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 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,eAC7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gBAAgB,UAAU;AAAA,QAC9B;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF,UAAE;AACA,YAAQ,IAAI,qDAAqD;AAEjE,UAAM,gBAAgB,WAAW,UAAU;AAAA,EAC7C;AACF;AAYO,IAAM,4BAAuD;AAAA,EAClE,SAAS;AAAA,EACT,uBAAuB;AAAA,EACvB,gCAAgC;AAAA,EAChC,iCAAiC;AAAA,EACjC,mDAAmD;AAAA,EACnD,uBAAuB;AACzB;AAEO,SAAS,eACd,SACM;AACN,QAAM,EAAE,SAAS,sBAAsB,IAAI;AAC3C,MAAI,OAAO,YAAY,aAAa;AAClC,8BAA0B,UAAU;AACpC,oBAAgB,CAAC,WAAW,OAAO,UAAU,oBAAoB,OAAO,CAAC;AAAA,EAC3E;AACA,MAAI,OAAO,0BAA0B,aAAa;AAChD,8BAA0B,wBAAwB;AAClD;AAAA,MAAgB,CAAC,WACf,OAAO,UAAU;AAAA,QACf;AAAA,MACF;AAAA,IACF;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,4 +1,4 @@
|
|
|
1
|
-
// src/cubing/vendor/mpl/
|
|
1
|
+
// src/cubing/vendor/mpl/twips/chunks/chunk-44VDESDN.js
|
|
2
2
|
var __toBinary = /* @__PURE__ */ (() => {
|
|
3
3
|
var table = new Uint8Array(128);
|
|
4
4
|
for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;
|
|
@@ -18,4 +18,4 @@ var __toBinary = /* @__PURE__ */ (() => {
|
|
|
18
18
|
export {
|
|
19
19
|
__toBinary
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-FKKRSXUI.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cubing/vendor/mpl/twips/chunks/chunk-44VDESDN.js"],
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\n\n// Generated from `twips` v0.9.99\nvar __toBinary = /* @__PURE__ */ (() => {\n var table = new Uint8Array(128);\n for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;\n return (base64) => {\n var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == \"=\") - (base64[n - 2] == \"=\")) * 3 / 4 | 0);\n for (var i2 = 0, j = 0; i2 < n; ) {\n var c0 = table[base64.charCodeAt(i2++)], c1 = table[base64.charCodeAt(i2++)];\n var c2 = table[base64.charCodeAt(i2++)], c3 = table[base64.charCodeAt(i2++)];\n bytes[j++] = c0 << 2 | c1 >> 4;\n bytes[j++] = c1 << 4 | c2 >> 2;\n bytes[j++] = c2 << 6 | c3;\n }\n return bytes;\n };\n})();\n\nexport {\n __toBinary\n};\n//# sourceMappingURL=chunk-44VDESDN.js.map\n"],
|
|
5
|
+
"mappings": ";AAGA,IAAI,aAA8B,uBAAM;AACtC,MAAI,QAAQ,IAAI,WAAW,GAAG;AAC9B,WAAS,IAAI,GAAG,IAAI,IAAI,IAAK,OAAM,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,IAAI;AACvG,SAAO,CAAC,WAAW;AACjB,QAAI,IAAI,OAAO,QAAQ,QAAQ,IAAI,YAAY,KAAK,OAAO,IAAI,CAAC,KAAK,QAAQ,OAAO,IAAI,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC;AAC/G,aAAS,KAAK,GAAG,IAAI,GAAG,KAAK,KAAK;AAChC,UAAI,KAAK,MAAM,OAAO,WAAW,IAAI,CAAC,GAAG,KAAK,MAAM,OAAO,WAAW,IAAI,CAAC;AAC3E,UAAI,KAAK,MAAM,OAAO,WAAW,IAAI,CAAC,GAAG,KAAK,MAAM,OAAO,WAAW,IAAI,CAAC;AAC3E,YAAM,GAAG,IAAI,MAAM,IAAI,MAAM;AAC7B,YAAM,GAAG,IAAI,MAAM,IAAI,MAAM;AAC7B,YAAM,GAAG,IAAI,MAAM,IAAI;AAAA,IACzB;AACA,WAAO;AAAA,EACT;AACF,GAAG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|