cubing 0.40.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/esm/bluetooth/index.js +41 -41
  2. package/dist/esm/bluetooth/index.js.map +3 -3
  3. package/dist/esm/{chunk-2UHC65GH.js → chunk-3B5ND2Z3.js} +25 -23
  4. package/dist/esm/chunk-3B5ND2Z3.js.map +7 -0
  5. package/dist/esm/{chunk-NZAWY3EU.js → chunk-3RHBVKV2.js} +98 -89
  6. package/dist/esm/chunk-3RHBVKV2.js.map +7 -0
  7. package/dist/esm/{chunk-45VMKYXT.js → chunk-6FC7BO5U.js} +3 -5
  8. package/dist/esm/chunk-6FC7BO5U.js.map +7 -0
  9. package/dist/esm/{chunk-TKIXG2EX.js → chunk-GXXHRHE5.js} +35 -35
  10. package/dist/esm/chunk-GXXHRHE5.js.map +7 -0
  11. package/dist/esm/{chunk-NBVZ7LEM.js → chunk-H66X47MG.js} +115 -125
  12. package/dist/esm/chunk-H66X47MG.js.map +7 -0
  13. package/dist/esm/{chunk-JXW26CFJ.js → chunk-LRYMCZVI.js} +3 -3
  14. package/dist/esm/{chunk-ZILJKTYP.js → chunk-Q7UVEISQ.js} +17 -17
  15. package/dist/esm/{chunk-IZJ3YK5S.js → chunk-RYRRMKVS.js} +14 -13
  16. package/dist/esm/chunk-RYRRMKVS.js.map +7 -0
  17. package/dist/esm/{chunk-F6V2QBMP.js → chunk-V4YTFIKT.js} +99 -89
  18. package/dist/esm/chunk-V4YTFIKT.js.map +7 -0
  19. package/dist/esm/{chunk-TBVTYIMY.js → chunk-XODLDV3Q.js} +25 -23
  20. package/dist/esm/chunk-XODLDV3Q.js.map +7 -0
  21. package/dist/esm/inside-GPSEWHK7.js +17 -0
  22. package/dist/esm/kpuzzle/index.js +3 -3
  23. package/dist/esm/notation/index.js +3 -3
  24. package/dist/esm/protocol/index.js +3 -3
  25. package/dist/esm/puzzle-geometry/index.js +43 -26
  26. package/dist/esm/puzzle-geometry/index.js.map +2 -2
  27. package/dist/esm/puzzles/index.js +3 -3
  28. package/dist/esm/{puzzles-dynamic-side-events-DHAI7HWB.js → puzzles-dynamic-side-events-42Q52YAB.js} +157 -85
  29. package/dist/esm/puzzles-dynamic-side-events-42Q52YAB.js.map +7 -0
  30. package/dist/esm/{puzzles-dynamic-unofficial-QXSDLTK5.js → puzzles-dynamic-unofficial-PCHNKY4Y.js} +13 -13
  31. package/dist/esm/{puzzles-dynamic-unofficial-QXSDLTK5.js.map → puzzles-dynamic-unofficial-PCHNKY4Y.js.map} +2 -2
  32. package/dist/esm/scramble/index.js +7 -7
  33. package/dist/esm/search/index.js +9 -9
  34. package/dist/esm/{search-dynamic-sgs-side-events-LBEIUPJE.js → search-dynamic-sgs-side-events-4ZHROANX.js} +5 -5
  35. package/dist/esm/{search-dynamic-sgs-unofficial-PHDE4BVE.js → search-dynamic-sgs-unofficial-VKBYULK5.js} +5 -5
  36. package/dist/esm/{search-dynamic-solve-3x3x3-7EEK52SV.js → search-dynamic-solve-3x3x3-NULYS7OL.js} +3 -3
  37. package/dist/esm/{search-dynamic-solve-3x3x3-7EEK52SV.js.map → search-dynamic-solve-3x3x3-NULYS7OL.js.map} +2 -2
  38. package/dist/esm/{search-dynamic-solve-4x4x4-EJB3WWMV.js → search-dynamic-solve-4x4x4-KASG5V7K.js} +5 -5
  39. package/dist/esm/{search-dynamic-solve-sq1-CWJPRQVZ.js → search-dynamic-solve-sq1-TO7UHE6Y.js} +6 -6
  40. package/dist/esm/{search-dynamic-solve-sq1-CWJPRQVZ.js.map → search-dynamic-solve-sq1-TO7UHE6Y.js.map} +2 -2
  41. package/dist/esm/search-worker-entry.js.js +1 -1
  42. package/dist/esm/twisty/index.js +74 -66
  43. package/dist/esm/twisty/index.js.map +3 -3
  44. package/dist/esm/{twisty-dynamic-3d-EI5ZUVCP.js → twisty-dynamic-3d-5VC2L2WS.js} +19 -19
  45. package/dist/esm/twisty-dynamic-3d-5VC2L2WS.js.map +7 -0
  46. package/dist/esm/{twsearch-ZALDQ4TE.js → twsearch-OMTTOVJO.js} +15 -15
  47. package/dist/esm/twsearch-OMTTOVJO.js.map +7 -0
  48. package/dist/types/{KState-33ce1f57.d.ts → KPattern-12e23b1f.d.ts} +37 -33
  49. package/dist/types/{TwizzleLink-19143923.d.ts → TwizzleLink-8eaf164c.d.ts} +10 -10
  50. package/dist/types/bluetooth/index.d.ts +8 -8
  51. package/dist/types/{bluetooth-puzzle-29072a56.d.ts → bluetooth-puzzle-91e73b7f.d.ts} +3 -3
  52. package/dist/types/kpuzzle/index.d.ts +1 -1
  53. package/dist/types/notation/index.d.ts +2 -2
  54. package/dist/types/{outside-b7760f77.d.ts → outside-deaac55d.d.ts} +8 -8
  55. package/dist/types/protocol/index.d.ts +5 -5
  56. package/dist/types/puzzle-geometry/index.d.ts +2 -2
  57. package/dist/types/puzzles/index.d.ts +3 -3
  58. package/dist/types/scramble/index.d.ts +2 -2
  59. package/dist/types/search/index.d.ts +4 -4
  60. package/dist/types/stream/index.d.ts +2 -2
  61. package/dist/types/twisty/index.d.ts +7 -7
  62. package/package.json +1 -1
  63. package/dist/esm/chunk-2UHC65GH.js.map +0 -7
  64. package/dist/esm/chunk-45VMKYXT.js.map +0 -7
  65. package/dist/esm/chunk-F6V2QBMP.js.map +0 -7
  66. package/dist/esm/chunk-IZJ3YK5S.js.map +0 -7
  67. package/dist/esm/chunk-NBVZ7LEM.js.map +0 -7
  68. package/dist/esm/chunk-NZAWY3EU.js.map +0 -7
  69. package/dist/esm/chunk-TBVTYIMY.js.map +0 -7
  70. package/dist/esm/chunk-TKIXG2EX.js.map +0 -7
  71. package/dist/esm/inside-BGMQCQ2A.js +0 -17
  72. package/dist/esm/puzzles-dynamic-side-events-DHAI7HWB.js.map +0 -7
  73. package/dist/esm/twisty-dynamic-3d-EI5ZUVCP.js.map +0 -7
  74. package/dist/esm/twsearch-ZALDQ4TE.js.map +0 -7
  75. /package/dist/esm/{chunk-JXW26CFJ.js.map → chunk-LRYMCZVI.js.map} +0 -0
  76. /package/dist/esm/{chunk-ZILJKTYP.js.map → chunk-Q7UVEISQ.js.map} +0 -0
  77. /package/dist/esm/{inside-BGMQCQ2A.js.map → inside-GPSEWHK7.js.map} +0 -0
  78. /package/dist/esm/{search-dynamic-sgs-side-events-LBEIUPJE.js.map → search-dynamic-sgs-side-events-4ZHROANX.js.map} +0 -0
  79. /package/dist/esm/{search-dynamic-sgs-unofficial-PHDE4BVE.js.map → search-dynamic-sgs-unofficial-VKBYULK5.js.map} +0 -0
  80. /package/dist/esm/{search-dynamic-solve-4x4x4-EJB3WWMV.js.map → search-dynamic-solve-4x4x4-KASG5V7K.js.map} +0 -0
@@ -1,12 +1,7 @@
1
1
  import { M as Move, a as Alg } from './Alg-c6770822.js';
2
2
 
3
- type KTransformationData = Record<string, KTransformationOrbitData>;
4
- interface KTransformationOrbitData {
5
- permutation: number[];
6
- orientation: number[];
7
- }
8
- type KStateData = Record<string, KStateOrbitData>;
9
- interface KStateOrbitData {
3
+ type KPatternData = Record<string, KPatternOrbitData>;
4
+ interface KPatternOrbitData {
10
5
  pieces: number[];
11
6
  orientation: number[];
12
7
  /** Each piece may have an "orientation mod" that means "the orientation of
@@ -23,7 +18,7 @@ interface KStateOrbitData {
23
18
  * - This indicates that the orientation of a piece is fully known, i.e.
24
19
  * that its "orientation mod" is the default value (N). However, such a
25
20
  * value is recorded as 0 instead of N, in order to make it simpler to
26
- * implement and debug state logic involving the default value.
21
+ * implement and debug pattern logic involving the default value.
27
22
  * - If `.orientationMod[i]` is a proper divisor of N (i.e. not 0), then
28
23
  * `.orientation[i]` must be less than `.orientationMod[i]`. That is, the
29
24
  * orientation values must be individually "normalized" for each piece.
@@ -42,7 +37,7 @@ interface KStateOrbitData {
42
37
  * imagine a 24-hour clock with 24 hour marks around the dial, but where the
43
38
  * hour hand is symmetric and points equally at the current hour as well as
44
39
  * its diametic opposite (like a compass needle but painted all in one color).
45
- * This has the same set of "valid states" as a normal 12-hour clock. Such a
40
+ * This has the same set of "valid patterns" as a normal 12-hour clock. Such a
46
41
  * clock also has an "orientation mod" of 12, but where the multiples of the
47
42
  * modulus have been "unfolded" to show their full symmetry instead of being
48
43
  * implicit.
@@ -89,18 +84,18 @@ interface KStateOrbitData {
89
84
  *
90
85
  * For those with a mathematical background, you may notice a relationship to
91
86
  * the concept of a coset (https://en.wikipedia.org/wiki/Coset). For example,
92
- * consider the group of states of a `KPuzzle` (without indistinguishable
87
+ * consider the group of patterns of a `KPuzzle` (without indistinguishable
93
88
  * pieces) generated by a set of transformations. We can assign each set of
94
89
  * piece orbits an orientation mod value (which must be identical for all
95
90
  * constituent pieces of the same orbit). Each such choice generates a set of
96
- * valid `KState`s that forms a subgroup, and each set of valid `.orientation`
91
+ * valid `KPattern`s that forms a subgroup, and each set of valid `.orientation`
97
92
  * values defines one coset of this set. However, note that the set of valid
98
- * `KState`s does *not* form a group when there are any pieces with different
93
+ * `KPattern`s does *not* form a group when there are any pieces with different
99
94
  * `.orientationMod` values that share an orbit.
100
95
  *
101
96
  * --------
102
97
  *
103
- * Note that the concept of "orientation mod" exclusively applies to `KState`,
98
+ * Note that the concept of "orientation mod" exclusively applies to `KPattern`,
104
99
  * not `KTransformation`. If we tried to apply the orientation mod
105
100
  * calculations to the *transformations* of Eitan's FisherTwist, then `SWAP =
106
101
  * [U, M' E2 M]` would be indistinguishable from the identity. This would mean
@@ -130,21 +125,27 @@ interface KStateOrbitData {
130
125
  *
131
126
  * Informally, the `KTransformation` has the full responsibility for tracking
132
127
  * "what really happens" — even if the effect is invisible in some cases,
133
- * while the `KState` tracks both what "is" and what "isn't" known.
128
+ * while the `KPattern` tracks both what "is" and what "isn't" known.
134
129
  **/
135
130
  orientationMod?: number[];
136
131
  }
132
+ type KTransformationData = Record<string, KTransformationOrbitData>;
133
+ interface KTransformationOrbitData {
134
+ permutation: number[];
135
+ orientationDelta: number[];
136
+ }
137
137
  interface KPuzzleOrbitDefinition {
138
+ orbitName: string;
138
139
  numPieces: number;
139
140
  numOrientations: number;
140
141
  }
141
142
  interface KPuzzleDefinition {
142
143
  name: string;
143
- orbits: Record<string, KPuzzleOrbitDefinition>;
144
- startStateData: KStateData;
144
+ orbits: KPuzzleOrbitDefinition[];
145
+ defaultPattern: KPatternData;
145
146
  moves: Record<string, KTransformationData>;
146
- experimentalDerivedMoves?: Record<string, string>;
147
- experimentalIsStateSolved?: (kstate: KState, options: {
147
+ derivedMoves?: Record<string, string>;
148
+ experimentalIsPatternSolved?: (kpattern: KPattern, options: {
148
149
  ignorePuzzleOrientation: boolean;
149
150
  ignoreCenterOrientation: boolean;
150
151
  }) => boolean;
@@ -166,7 +167,7 @@ declare class KTransformation {
166
167
  applyTransformation(t2: KTransformation): KTransformation;
167
168
  applyMove(move: Move | string): KTransformation;
168
169
  applyAlg(alg: Alg | string): KTransformation;
169
- toKState(): KState;
170
+ toKPattern(): KPattern;
170
171
  repetitionOrder(): number;
171
172
  selfMultiply(amount: number): KTransformation;
172
173
  }
@@ -248,7 +249,8 @@ declare class PGOrbitsDef {
248
249
  isRotation: boolean[];
249
250
  forcenames: boolean[];
250
251
  constructor(orbitnames: string[], orbitdefs: PGOrbitDef[], solved: VisibleState, movenames: string[], moveops: PGTransform[], isRotation: boolean[], forcenames: boolean[]);
251
- transformToKTransformationData(t: PGTransform): KTransformationData;
252
+ toKTransformationData(t: PGTransform): KTransformationData;
253
+ toKPatternData(t: PGTransform): KPatternData;
252
254
  static transformToKTransformationData(orbitnames: string[], t: PGTransform): KTransformationData;
253
255
  private describeSet;
254
256
  toKsolve(name: string, mapper?: NotationMapper): string[];
@@ -262,7 +264,7 @@ declare class PGOrbit {
262
264
  perm: number[];
263
265
  ori: number[];
264
266
  orimod: number;
265
- private static kcache;
267
+ private static ktransformationCache;
266
268
  static e(n: number, mod: number): PGOrbit;
267
269
  constructor(perm: number[], ori: number[], orimod: number);
268
270
  mul(b: PGOrbit): PGOrbit;
@@ -277,7 +279,8 @@ declare class PGOrbit {
277
279
  remap(no: number[], on: number[], nv: number): PGOrbit;
278
280
  remapVS(no: number[], nv: number): PGOrbit;
279
281
  appendDefinition(result: string[], name: string, useVS: boolean, concise?: boolean): void;
280
- toKPuzzle(): Record<string, number[]>;
282
+ toKTransformationOrbitData(): KTransformationOrbitData;
283
+ toKPatternOrbitData(): KPatternOrbitData;
281
284
  }
282
285
  declare class PGTransformBase {
283
286
  orbits: PGOrbit[];
@@ -512,27 +515,28 @@ declare class KPuzzle {
512
515
  constructor(definition: KPuzzleDefinition, options?: {
513
516
  experimentalPGNotation?: PGNotation;
514
517
  });
518
+ lookupOrbitDefinition(orbitName: string): KPuzzleOrbitDefinition;
515
519
  name(): string;
516
520
  identityTransformation(): KTransformation;
517
521
  moveToTransformation(move: Move | string): KTransformation;
518
522
  algToTransformation(alg: Alg | string): KTransformation;
519
523
  /** @deprecated */
520
524
  toTransformation(source: KTransformationSource): KTransformation;
521
- startState(): KState;
522
- canConvertStateToUniqueTransformation(): boolean;
525
+ defaultPattern(): KPattern;
526
+ canConvertDefaultPatternToUniqueTransformation(): boolean;
523
527
  }
524
528
 
525
- declare class KState {
529
+ declare class KPattern {
526
530
  readonly kpuzzle: KPuzzle;
527
- readonly stateData: KStateData;
528
- constructor(kpuzzle: KPuzzle, stateData: KStateData);
531
+ readonly patternData: KPatternData;
532
+ constructor(kpuzzle: KPuzzle, patternData: KPatternData);
529
533
  toJSON(): any;
530
- static fromTransformation(transformation: KTransformation): KState;
534
+ static fromTransformation(transformation: KTransformation): KPattern;
531
535
  /** @deprecated */
532
- apply(source: KTransformationSource): KState;
533
- applyTransformation(transformation: KTransformation): KState;
534
- applyMove(move: Move | string): KState;
535
- applyAlg(alg: Alg | string): KState;
536
+ apply(source: KTransformationSource): KPattern;
537
+ applyTransformation(transformation: KTransformation): KPattern;
538
+ applyMove(move: Move | string): KPattern;
539
+ applyAlg(alg: Alg | string): KPattern;
536
540
  /** @deprecated */
537
541
  experimentalToTransformation(): KTransformation | null;
538
542
  experimentalIsSolved(options: {
@@ -541,4 +545,4 @@ declare class KState {
541
545
  }): boolean;
542
546
  }
543
547
 
544
- export { KState as K, PuzzleGeometry as P, Quat as Q, StickerDat as S, KPuzzle as a, KPuzzleDefinition as b, KStateData as c, KStateOrbitData as d, KTransformationData as e, KTransformationOrbitData as f, KTransformation as g, PuzzleDescriptionString as h, Perm as i, getPuzzleDescriptionString as j, getPuzzleGeometryByDesc as k, getPuzzleGeometryByName as l, getPG3DNamedPuzzles as m, StickerDatAxis as n, StickerDatFace as o, parsePuzzleDescription as p, StickerDatSticker as q, parseOptions as r, PGNotation as s, PuzzleCutDescription as t, PuzzleDescription as u, PUZZLE_CUT_TYPES as v, PuzzleCutType as w, PUZZLE_BASE_SHAPES as x, PuzzleBaseShape as y };
548
+ export { KPattern as K, PuzzleGeometry as P, Quat as Q, StickerDat as S, KPuzzle as a, KPuzzleDefinition as b, KPatternData as c, KPatternOrbitData as d, KTransformationData as e, KTransformationOrbitData as f, KTransformation as g, PuzzleDescriptionString as h, Perm as i, getPuzzleDescriptionString as j, getPuzzleGeometryByDesc as k, getPuzzleGeometryByName as l, getPG3DNamedPuzzles as m, StickerDatAxis as n, StickerDatFace as o, parsePuzzleDescription as p, StickerDatSticker as q, parseOptions as r, PGNotation as s, PuzzleCutDescription as t, PuzzleDescription as u, PUZZLE_CUT_TYPES as v, PuzzleCutType as w, PUZZLE_BASE_SHAPES as x, PuzzleBaseShape as y };
@@ -1,7 +1,7 @@
1
1
  import { Texture, Object3D, Raycaster, PerspectiveCamera, Scene, WebGLRenderer } from 'three';
2
2
  import { g as PuzzleSpecificSimplifyOptions, M as Move, a as Alg, P as Pause, h as AppendCancelOptions, d as AlgLeaf, b as AppendOptions, A as AlgNode, I as IterationDirection } from './Alg-c6770822.js';
3
3
  import { P as Parsed } from './parseAlg-d2c83795.js';
4
- import { a as KPuzzle, P as PuzzleGeometry, K as KState, g as KTransformation, h as PuzzleDescriptionString } from './KState-33ce1f57.js';
4
+ import { a as KPuzzle, P as PuzzleGeometry, K as KPattern, g as KTransformation, h as PuzzleDescriptionString } from './KPattern-12e23b1f.js';
5
5
 
6
6
  type FaceletMeshStickeringMask = "regular" | "dim" | "oriented" | "ignored" | "invisible";
7
7
  type FaceletStickeringMask = {
@@ -55,7 +55,7 @@ interface MoveInProgress {
55
55
  fraction: number;
56
56
  }
57
57
  type PuzzlePosition = {
58
- state: KState;
58
+ pattern: KPattern;
59
59
  movesInProgress: MoveInProgress[];
60
60
  };
61
61
  declare enum BoundaryType {
@@ -192,7 +192,7 @@ interface CurrentMove {
192
192
  endTimestamp: MillisecondTimestamp;
193
193
  }
194
194
  interface CurrentMoveInfo {
195
- stateIndex: number;
195
+ patternIndex: number;
196
196
  currentMoves: CurrentMove[];
197
197
  movesFinishing: CurrentMove[];
198
198
  movesFinished: CurrentMove[];
@@ -203,13 +203,13 @@ interface CurrentMoveInfo {
203
203
  interface AlgIndexer {
204
204
  getAnimLeaf(index: number): AnimatedLeafAlgNode | null;
205
205
  indexToMoveStartTimestamp(index: number): Timestamp;
206
- stateAtIndex(index: number, startSTate?: KState): KState;
206
+ patternAtIndex(index: number, startPattern?: KPattern): KPattern;
207
207
  transformationAtIndex(index: number): KTransformation;
208
208
  numAnimatedLeaves(): number;
209
209
  timestampToIndex(timestamp: Timestamp): number;
210
210
  algDuration(): Duration;
211
211
  moveDuration(index: number): number;
212
- timestampToPosition?: (timestamp: Timestamp, startState?: KState) => PuzzlePosition;
212
+ timestampToPosition?: (timestamp: Timestamp, startPattern?: KPattern) => PuzzlePosition;
213
213
  currentMoveInfo?: (timestamp: Timestamp) => CurrentMoveInfo;
214
214
  }
215
215
 
@@ -245,7 +245,7 @@ interface CurrentLeavesSimplifiedPropInputs {
245
245
  currentMoveInfo: CurrentMoveInfo;
246
246
  }
247
247
  interface CurrentLeavesSimplified {
248
- stateIndex: number;
248
+ patternIndex: number;
249
249
  movesFinishing: Move[];
250
250
  movesFinished: Move[];
251
251
  }
@@ -300,8 +300,8 @@ interface CurrentTransformationPropInputs {
300
300
  currentLeavesSimplified: CurrentLeavesSimplified;
301
301
  indexer: AlgIndexer;
302
302
  }
303
- declare class CurrentStateProp extends TwistyPropDerived<CurrentTransformationPropInputs, KState> {
304
- derive(inputs: CurrentTransformationPropInputs): KState;
303
+ declare class CurrentPatternProp extends TwistyPropDerived<CurrentTransformationPropInputs, KPattern> {
304
+ derive(inputs: CurrentTransformationPropInputs): KPattern;
305
305
  }
306
306
 
307
307
  declare const visualizationFormats: {
@@ -384,7 +384,7 @@ declare class IndexerProp extends TwistyPropDerived<IndexerPropInputs, AlgIndexe
384
384
 
385
385
  interface LegacyPositionPropInputs {
386
386
  currentMoveInfo: CurrentMoveInfo;
387
- state: KState;
387
+ currentPattern: KPattern;
388
388
  }
389
389
  declare class LegacyPositionProp extends TwistyPropDerived<LegacyPositionPropInputs, PuzzlePosition> {
390
390
  derive(inputs: LegacyPositionPropInputs): PuzzlePosition;
@@ -771,7 +771,7 @@ declare class TwistyPlayerModel {
771
771
  currentMoveInfo: CurrentMoveInfoProp;
772
772
  buttonAppearance: ButtonAppearanceProp;
773
773
  currentLeavesSimplified: CurrentLeavesSimplifiedProp;
774
- currentState: CurrentStateProp;
774
+ currentPattern: CurrentPatternProp;
775
775
  legacyPosition: LegacyPositionProp;
776
776
  twistySceneModel: TwistySceneModel;
777
777
  twizzleLink(): Promise<string>;
@@ -1,6 +1,6 @@
1
- import { K as KState } from '../KState-33ce1f57.js';
2
- import { B as BluetoothPuzzle } from '../bluetooth-puzzle-29072a56.js';
3
- export { B as BluetoothPuzzle, A as MoveEvent, O as OrientationEvent } from '../bluetooth-puzzle-29072a56.js';
1
+ import { K as KPattern } from '../KPattern-12e23b1f.js';
2
+ import { B as BluetoothPuzzle } from '../bluetooth-puzzle-91e73b7f.js';
3
+ export { B as BluetoothPuzzle, A as MoveEvent, O as OrientationEvent } from '../bluetooth-puzzle-91e73b7f.js';
4
4
  import { a as Alg, M as Move } from '../Alg-c6770822.js';
5
5
 
6
6
  declare function enableDebugLogging(enable: boolean): void;
@@ -9,12 +9,12 @@ declare function enableDebugLogging(enable: boolean): void;
9
9
  declare class KeyboardPuzzle extends BluetoothPuzzle {
10
10
  private target;
11
11
  private puzzle;
12
- private state;
12
+ private pattern;
13
13
  listener: (e: KeyboardEvent) => Promise<void>;
14
14
  constructor(target: Element);
15
15
  name(): string | undefined;
16
16
  disconnect(): void;
17
- getState(): Promise<KState>;
17
+ getPattern(): Promise<KPattern>;
18
18
  private onKeyDown;
19
19
  }
20
20
  /** @category Keyboard Puzzles */
@@ -39,7 +39,7 @@ declare class GanCube extends BluetoothPuzzle {
39
39
  static connect(server: BluetoothRemoteGATTServer): Promise<GanCube>;
40
40
  INTERVAL_MS: number;
41
41
  private intervalHandle;
42
- private state;
42
+ private pattern;
43
43
  private cachedFaceletStatus1Characteristic;
44
44
  private cachedFaceletStatus2Characteristic;
45
45
  private cachedActualAngleAndBatteryCharacteristic;
@@ -50,7 +50,7 @@ declare class GanCube extends BluetoothPuzzle {
50
50
  stopTrackingMoves(): void;
51
51
  intervalHandler(): Promise<void>;
52
52
  getBattery(): Promise<number>;
53
- getState(): Promise<KState>;
53
+ getPattern(): Promise<KPattern>;
54
54
  faceletStatus1Characteristic(): Promise<BluetoothRemoteGATTCharacteristic>;
55
55
  faceletStatus2Characteristic(): Promise<BluetoothRemoteGATTCharacteristic>;
56
56
  actualAngleAndBatteryCharacteristic(): Promise<BluetoothRemoteGATTCharacteristic>;
@@ -69,7 +69,7 @@ declare class GiiKERCube extends BluetoothPuzzle {
69
69
  private constructor();
70
70
  name(): string | undefined;
71
71
  disconnect(): void;
72
- getState(): Promise<KState>;
72
+ getPattern(): Promise<KPattern>;
73
73
  private getBit;
74
74
  private toReid333;
75
75
  private onCubeCharacteristicChanged;
@@ -1,5 +1,5 @@
1
1
  import { d as AlgLeaf } from './Alg-c6770822.js';
2
- import { K as KState } from './KState-33ce1f57.js';
2
+ import { K as KPattern } from './KPattern-12e23b1f.js';
3
3
 
4
4
  interface StreamTransformer {
5
5
  transformAlgLeaf(algLeafEvent: AlgLeafEvent): void;
@@ -12,7 +12,7 @@ interface AlgLeafEvent {
12
12
  latestAlgLeaf: AlgLeaf;
13
13
  timeStamp: number;
14
14
  debug?: Record<string, unknown>;
15
- state?: KState;
15
+ pattern?: KPattern;
16
16
  quaternion?: any;
17
17
  }
18
18
  /** @category Smart Puzzles */
@@ -33,7 +33,7 @@ declare abstract class BluetoothPuzzle extends EventTarget {
33
33
  protected orientationListeners: Array<(e: OrientationEvent) => void>;
34
34
  abstract name(): string | undefined;
35
35
  abstract disconnect(): void;
36
- getState(): Promise<KState>;
36
+ getPattern(): Promise<KPattern>;
37
37
  addAlgLeafListener(listener: (e: AlgLeafEvent) => void): void;
38
38
  addOrientationListener(listener: (e: OrientationEvent) => void): void;
39
39
  experimentalAddBasicRotationTransformer(): void;
@@ -1,2 +1,2 @@
1
- export { a as KPuzzle, b as KPuzzleDefinition, K as KState, c as KStateData, d as KStateOrbitData, g as KTransformation, e as KTransformationData, f as KTransformationOrbitData } from '../KState-33ce1f57.js';
1
+ export { K as KPattern, c as KPatternData, d as KPatternOrbitData, a as KPuzzle, b as KPuzzleDefinition, g as KTransformation, e as KTransformationData, f as KTransformationOrbitData } from '../KPattern-12e23b1f.js';
2
2
  import '../Alg-c6770822.js';
@@ -1,8 +1,8 @@
1
1
  import { a as Alg } from '../Alg-c6770822.js';
2
- import { P as PuzzleLoader } from '../TwizzleLink-19143923.js';
2
+ import { P as PuzzleLoader } from '../TwizzleLink-8eaf164c.js';
3
3
  import 'three';
4
4
  import '../parseAlg-d2c83795.js';
5
- import '../KState-33ce1f57.js';
5
+ import '../KPattern-12e23b1f.js';
6
6
 
7
7
  declare enum CommonMetric {
8
8
  OuterBlockTurnMetric = "OBTM",
@@ -1,5 +1,5 @@
1
1
  import { a as Alg } from './Alg-c6770822.js';
2
- import { K as KState, a as KPuzzle } from './KState-33ce1f57.js';
2
+ import { K as KPattern, a as KPuzzle } from './KPattern-12e23b1f.js';
3
3
 
4
4
  declare enum PrefetchLevel {
5
5
  Auto = "auto",
@@ -8,17 +8,17 @@ declare enum PrefetchLevel {
8
8
  }
9
9
 
10
10
  declare function randomScrambleForEvent(eventID: string): Promise<Alg>;
11
- declare function experimentalSolve3x3x3IgnoringCenters(state: KState): Promise<Alg>;
12
- declare function experimentalSolve2x2x2(state: KState): Promise<Alg>;
13
- declare function solveSkewb(state: KState): Promise<Alg>;
14
- declare function solvePyraminx(state: KState): Promise<Alg>;
15
- declare function solveMegaminx(state: KState): Promise<Alg>;
11
+ declare function experimentalSolve3x3x3IgnoringCenters(pattern: KPattern): Promise<Alg>;
12
+ declare function experimentalSolve2x2x2(pattern: KPattern): Promise<Alg>;
13
+ declare function solveSkewb(pattern: KPattern): Promise<Alg>;
14
+ declare function solvePyraminx(pattern: KPattern): Promise<Alg>;
15
+ declare function solveMegaminx(pattern: KPattern): Promise<Alg>;
16
16
  interface SolveTwsearchOptions {
17
17
  moveSubset?: string[];
18
- startState?: KState;
18
+ startPattern?: KPattern;
19
19
  minDepth?: number;
20
20
  }
21
- declare function solveTwsearch(kpuzzle: KPuzzle, state: KState, options?: SolveTwsearchOptions): Promise<Alg>;
21
+ declare function solveTwsearch(kpuzzle: KPuzzle, pattern: KPattern, options?: SolveTwsearchOptions): Promise<Alg>;
22
22
  interface SearchOutsideDebugGlobals {
23
23
  logPerf: boolean;
24
24
  scramblePrefetchLevel: `${PrefetchLevel}`;
@@ -1,7 +1,7 @@
1
- import { K as KState } from '../KState-33ce1f57.js';
1
+ import { K as KPattern } from '../KPattern-12e23b1f.js';
2
2
  import '../Alg-c6770822.js';
3
3
 
4
- type Binary3x3x3State = ArrayBuffer;
4
+ type Binary3x3x3Pattern = ArrayBuffer;
5
5
  interface Binary3x3x3Components {
6
6
  epLex: number;
7
7
  eoMask: number;
@@ -13,13 +13,13 @@ interface Binary3x3x3Components {
13
13
  moMask: number;
14
14
  }
15
15
  /** @category Binary 3x3x3 Format */
16
- declare function reid3x3x3ToTwizzleBinary(state: KState): Binary3x3x3State;
16
+ declare function reid3x3x3ToTwizzleBinary(pattern: KPattern): Binary3x3x3Pattern;
17
17
  /** @category Binary 3x3x3 Format */
18
18
  declare function twizzleBinaryToBinaryComponents(buffer: ArrayBuffer): Binary3x3x3Components;
19
19
  /** @category Binary 3x3x3 Format */
20
- declare function binaryComponentsToReid3x3x3(components: Binary3x3x3Components): KState;
20
+ declare function binaryComponentsToReid3x3x3(components: Binary3x3x3Components): KPattern;
21
21
  /** @category Binary 3x3x3 Format */
22
- declare function twizzleBinaryToReid3x3x3(buffy: ArrayBuffer): KState;
22
+ declare function twizzleBinaryToReid3x3x3(buffy: ArrayBuffer): KPattern;
23
23
 
24
24
  declare function bufferToSpacedHex(buffer: ArrayBuffer): string;
25
25
  declare function spacedHexToBuffer(hex: string): Uint8Array;
@@ -1,5 +1,5 @@
1
- import { i as Perm } from '../KState-33ce1f57.js';
2
- export { x as EXPERIMENTAL_PUZZLE_BASE_SHAPES, v as EXPERIMENTAL_PUZZLE_CUT_TYPES, s as ExperimentalPGNotation, y as ExperimentalPuzzleBaseShape, t as ExperimentalPuzzleCutDescription, w as ExperimentalPuzzleCutType, u as ExperimentalPuzzleDescription, P as PuzzleGeometry, Q as Quat, S as StickerDat, n as StickerDatAxis, o as StickerDatFace, q as StickerDatSticker, m as getPG3DNamedPuzzles, j as getPuzzleDescriptionString, k as getPuzzleGeometryByDesc, l as getPuzzleGeometryByName, r as parseOptions, p as parsePuzzleDescription } from '../KState-33ce1f57.js';
1
+ import { i as Perm } from '../KPattern-12e23b1f.js';
2
+ export { x as EXPERIMENTAL_PUZZLE_BASE_SHAPES, v as EXPERIMENTAL_PUZZLE_CUT_TYPES, s as ExperimentalPGNotation, y as ExperimentalPuzzleBaseShape, t as ExperimentalPuzzleCutDescription, w as ExperimentalPuzzleCutType, u as ExperimentalPuzzleDescription, P as PuzzleGeometry, Q as Quat, S as StickerDat, n as StickerDatAxis, o as StickerDatFace, q as StickerDatSticker, m as getPG3DNamedPuzzles, j as getPuzzleDescriptionString, k as getPuzzleGeometryByDesc, l as getPuzzleGeometryByName, r as parseOptions, p as parsePuzzleDescription } from '../KPattern-12e23b1f.js';
3
3
  import '../Alg-c6770822.js';
4
4
 
5
5
  declare function schreierSims(g: Perm[], disp: (s: string) => void): bigint;
@@ -1,7 +1,7 @@
1
- import { a as PuzzleID, P as PuzzleLoader, E as ExperimentalStickering, S as StickeringMask } from '../TwizzleLink-19143923.js';
2
- export { P as PuzzleLoader } from '../TwizzleLink-19143923.js';
1
+ import { a as PuzzleID, P as PuzzleLoader, E as ExperimentalStickering, S as StickeringMask } from '../TwizzleLink-8eaf164c.js';
2
+ export { P as PuzzleLoader } from '../TwizzleLink-8eaf164c.js';
3
3
  import { g as PuzzleSpecificSimplifyOptions } from '../Alg-c6770822.js';
4
- import { a as KPuzzle, P as PuzzleGeometry } from '../KState-33ce1f57.js';
4
+ import { a as KPuzzle, P as PuzzleGeometry } from '../KPattern-12e23b1f.js';
5
5
  import 'three';
6
6
  import '../parseAlg-d2c83795.js';
7
7
 
@@ -1,3 +1,3 @@
1
- export { r as randomScrambleForEvent } from '../outside-b7760f77.js';
1
+ export { r as randomScrambleForEvent } from '../outside-deaac55d.js';
2
2
  import '../Alg-c6770822.js';
3
- import '../KState-33ce1f57.js';
3
+ import '../KPattern-12e23b1f.js';
@@ -1,7 +1,7 @@
1
- export { a as experimentalSolve2x2x2, e as experimentalSolve3x3x3IgnoringCenters, f as experimentalSolveTwsearch, d as setSearchDebug, c as solveMegaminx, b as solvePyraminx, s as solveSkewb } from '../outside-b7760f77.js';
2
- import { K as KState } from '../KState-33ce1f57.js';
1
+ export { a as experimentalSolve2x2x2, e as experimentalSolve3x3x3IgnoringCenters, f as experimentalSolveTwsearch, d as setSearchDebug, c as solveMegaminx, b as solvePyraminx, s as solveSkewb } from '../outside-deaac55d.js';
2
+ import { K as KPattern } from '../KPattern-12e23b1f.js';
3
3
  import '../Alg-c6770822.js';
4
4
 
5
- declare function random333State(): Promise<KState>;
5
+ declare function random333Pattern(): Promise<KPattern>;
6
6
 
7
- export { random333State };
7
+ export { random333Pattern };
@@ -1,6 +1,6 @@
1
- import { A as AlgLeafEvent, O as OrientationEvent } from '../bluetooth-puzzle-29072a56.js';
1
+ import { A as AlgLeafEvent, O as OrientationEvent } from '../bluetooth-puzzle-91e73b7f.js';
2
2
  import '../Alg-c6770822.js';
3
- import '../KState-33ce1f57.js';
3
+ import '../KPattern-12e23b1f.js';
4
4
 
5
5
  interface ProxyMoveEvent {
6
6
  event: "move";
@@ -1,7 +1,7 @@
1
- import { A as AlgIndexer, T as Timestamp, D as Duration, S as StickeringMask } from '../TwizzleLink-19143923.js';
2
- export { A as AlgIndexer, B as BackViewLayout, N as EXPERIMENTAL_PROP_NO_VALUE, M as ExperimentalMillisecondTimestamp, E as ExperimentalStickering, a as PuzzleID, d as TwistyAlgEditor, c as TwistyAlgViewer, b as TwistyPlayer, e as TwistyPlayerConfig, g as TwizzleLink, V as VisualizationFormat, f as backViewLayouts } from '../TwizzleLink-19143923.js';
1
+ import { A as AlgIndexer, T as Timestamp, D as Duration, S as StickeringMask } from '../TwizzleLink-8eaf164c.js';
2
+ export { A as AlgIndexer, B as BackViewLayout, N as EXPERIMENTAL_PROP_NO_VALUE, M as ExperimentalMillisecondTimestamp, E as ExperimentalStickering, a as PuzzleID, d as TwistyAlgEditor, c as TwistyAlgViewer, b as TwistyPlayer, e as TwistyPlayerConfig, g as TwizzleLink, V as VisualizationFormat, f as backViewLayouts } from '../TwizzleLink-8eaf164c.js';
3
3
  import { a as Alg, M as Move } from '../Alg-c6770822.js';
4
- import { a as KPuzzle, K as KState, g as KTransformation } from '../KState-33ce1f57.js';
4
+ import { a as KPuzzle, K as KPattern, g as KTransformation } from '../KPattern-12e23b1f.js';
5
5
  import 'three';
6
6
  import '../parseAlg-d2c83795.js';
7
7
 
@@ -19,7 +19,7 @@ declare class SimpleAlgIndexer implements AlgIndexer {
19
19
  getAnimLeaf(index: number): Move;
20
20
  indexToMoveStartTimestamp(index: number): Timestamp;
21
21
  timestampToIndex(timestamp: Timestamp): number;
22
- stateAtIndex(index: number): KState;
22
+ patternAtIndex(index: number): KPattern;
23
23
  transformationAtIndex(index: number): KTransformation;
24
24
  algDuration(): Duration;
25
25
  numAnimatedLeaves(): number;
@@ -34,7 +34,7 @@ declare class TreeAlgIndexer implements AlgIndexer {
34
34
  getAnimLeaf(index: number): Move | null;
35
35
  indexToMoveStartTimestamp(index: number): Timestamp;
36
36
  indexToMovesInProgress(index: number): Timestamp;
37
- stateAtIndex(index: number, startState?: KState): KState;
37
+ patternAtIndex(index: number, startPattern?: KPattern): KPattern;
38
38
  transformationAtIndex(index: number): KTransformation;
39
39
  numAnimatedLeaves(): number;
40
40
  timestampToIndex(timestamp: Timestamp): number;
@@ -52,8 +52,8 @@ declare class TwistyAnimatedSVG {
52
52
  private gradients;
53
53
  private svgID;
54
54
  constructor(kpuzzle: KPuzzle, svgSource: string, experimentalStickeringMask?: StickeringMask, showUnknownOrientations?: boolean);
55
- drawState(state: KState, nextState?: KState, fraction?: number): void;
56
- draw(state: KState, nextState?: KState, fraction?: number): void;
55
+ drawPattern(pattern: KPattern, nextPattern?: KPattern, fraction?: number): void;
56
+ draw(pattern: KPattern, nextPattern?: KPattern, fraction?: number): void;
57
57
  private newGradient;
58
58
  private elementID;
59
59
  private elementByID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cubing",
3
- "version": "0.40.0",
3
+ "version": "0.41.1",
4
4
  "description": "A collection of JavaScript cubing libraries.",
5
5
  "author": "The js.cubing.net team",
6
6
  "type": "module",
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/cubing/protocol/binary/orbit-indexing.ts", "../../src/cubing/protocol/binary/binary3x3x3.ts", "../../src/cubing/protocol/binary/hex.ts"],
4
- "sourcesContent": ["export function identityPermutation(numElems: number): number[] {\n const arr = new Array<number>(numElems);\n for (let i = 0; i < numElems; i++) {\n arr[i] = i;\n }\n return arr;\n}\n\n// Inclusive start, exclusive end (similar to `Array.prototype.slice`)\nexport function orientationsToMask(\n radix: number,\n orientations: number[],\n): number {\n let val = 0;\n for (const orientation of orientations) {\n val *= radix;\n val += orientation;\n }\n return val;\n}\n\n// Inclusive start, exclusive end (similar to `Array.prototype.slice`)\nexport function maskToOrientations(\n radix: number,\n numElems: number,\n mask: number,\n): number[] {\n const arr = [];\n while (mask > 0) {\n arr.push(mask % radix);\n mask = Math.floor(mask / radix);\n }\n return new Array<number>(numElems - arr.length).fill(0).concat(arr.reverse());\n}\n\n// From https://www.jaapsch.net/puzzles/compindx.htm#perm\nexport function permutationToLex(permutation: number[]): number {\n const n = permutation.length;\n let lexicographicIdx = 0;\n for (let i = 0; i < n - 1; i++) {\n lexicographicIdx = lexicographicIdx * (n - i);\n for (let j = i + 1; j < n; j++) {\n if (permutation[i] > permutation[j]) {\n lexicographicIdx += 1;\n }\n }\n }\n return lexicographicIdx;\n}\n\n// From https://www.jaapsch.net/puzzles/compindx.htm#perm\nexport function lexToPermutation(\n numPieces: number,\n lexicographicIdx: number,\n): number[] {\n const permutation: number[] = new Array(numPieces);\n permutation[numPieces - 1] = 0;\n for (let i = numPieces - 2; i >= 0; i--) {\n permutation[i] = lexicographicIdx % (numPieces - i);\n lexicographicIdx = Math.floor(lexicographicIdx / (numPieces - i));\n for (let j = i + 1; j < numPieces; j++) {\n if (permutation[j] >= permutation[i]) {\n permutation[j] = permutation[j] + 1;\n }\n }\n }\n return permutation;\n}\n", "import { KState, type KStateData } from \"../../kpuzzle\";\nimport {\n experimental3x3x3KPuzzle,\n experimentalNormalize3x3x3Orientation,\n experimentalPuzzleOrientation3x3x3Cache,\n experimentalPuzzleOrientation3x3x3Idx,\n} from \"../../puzzles/cubing-private\";\nimport {\n identityPermutation,\n lexToPermutation,\n maskToOrientations,\n orientationsToMask,\n permutationToLex,\n} from \"./orbit-indexing\";\n\n// TODO: combine with `orientPuzzle`?\nexport function reorientPuzzle(\n state: KState,\n idxU: number,\n idxL: number,\n): KState {\n return state.applyTransformation(\n experimentalPuzzleOrientation3x3x3Cache()[idxU][idxL].invert(),\n );\n}\n\ntype Binary3x3x3State = ArrayBuffer;\n\n// Bit lengths of the encoded components, in order.\nconst BIT_LENGTHS = [29, 12, 16, 13, 3, 2, 1, 12];\n\n// These fields are sorted by the order in which they appear in the binary format.\nexport interface Binary3x3x3Components {\n epLex: number; // 29 bits, edge permutation\n eoMask: number; // 12 bits, edge orientation\n cpLex: number; // 16 bits, corner permutation\n coMask: number; // 13 bits, corner orientation\n poIdxU: number; // 3 bits, puzzle orientation (U face)\n poIdxL: number; // 2 bits, puzzle orientation (L face)\n moSupport: number; // 1 bit, center orientation support\n moMask: number; // 12 bits, center orientation\n}\n\n// There are various clever ways to do this, but this is simple and efficient.\nfunction arraySum(arr: number[]): number {\n let total = 0;\n for (const entry of arr) {\n total += entry;\n }\n return total;\n}\n\n// Due to limitations in JS bit operations, this is unsafe if any of the bit lengths span across the contents of more than 4 bytes.\n// - Safe: [8, 32]\n// - Unsafe: [4, 32, 4]\n// - Unsafe: [40, 4]\nfunction splitBinary(bitLengths: number[], buffy: ArrayBuffer): number[] {\n const u8buffy = new Uint8Array(buffy);\n let at = 0;\n let bits = 0;\n let accum = 0;\n const values: number[] = [];\n for (const bitLength of bitLengths) {\n while (bits < bitLength) {\n accum = (accum << 8) | u8buffy[at++];\n bits += 8;\n }\n values.push((accum >> (bits - bitLength)) & ((1 << bitLength) - 1));\n bits -= bitLength;\n }\n return values;\n}\n\n// See above for safety notes.\nfunction concatBinary(bitLengths: number[], values: number[]): ArrayBuffer {\n const buffy = new Uint8Array(Math.ceil(arraySum(bitLengths) / 8));\n let at = 0;\n let bits = 0;\n let accum = 0;\n for (let i = 0; i < bitLengths.length; i++) {\n accum = (accum << bitLengths[i]) | values[i];\n bits += bitLengths[i];\n while (bits >= 8) {\n buffy[at++] = accum >> (bits - 8);\n bits -= 8;\n }\n }\n if (bits > 0) {\n buffy[at++] = accum << (8 - bits);\n }\n return buffy;\n}\n\n// 0x111 (for idxU) means \"not supported\"\nfunction supportsPuzzleOrientation(components: Binary3x3x3Components): boolean {\n return components.poIdxU !== 7;\n}\n\nfunction hasFullMOData(centerOrientationModData: number[] | undefined): 0 | 1 {\n if (!centerOrientationModData) {\n return 1;\n }\n for (let i = 0; i < 6; i++) {\n if (centerOrientationModData[i] !== 0) {\n return 0;\n }\n }\n return 1;\n}\n\nexport function reid3x3x3ToBinaryComponents(\n state: KState,\n): Binary3x3x3Components {\n const normedState = experimentalNormalize3x3x3Orientation(state);\n\n const epLex = permutationToLex(normedState.stateData[\"EDGES\"].pieces);\n const eoMask = orientationsToMask(\n 2,\n normedState.stateData[\"EDGES\"].orientation,\n );\n const cpLex = permutationToLex(normedState.stateData[\"CORNERS\"].pieces);\n const coMask = orientationsToMask(\n 3,\n normedState.stateData[\"CORNERS\"].orientation,\n );\n const [poIdxU, poIdxL] = experimentalPuzzleOrientation3x3x3Idx(state);\n\n const moSupport = hasFullMOData(state.stateData[\"CENTERS\"].orientationMod); // Required for now.\n const moMask = moSupport\n ? orientationsToMask(4, normedState.stateData[\"CENTERS\"].orientation)\n : 0;\n\n return {\n epLex,\n eoMask,\n cpLex,\n coMask,\n poIdxU,\n poIdxL,\n moSupport,\n moMask,\n };\n}\n\nexport function binaryComponentsToTwizzleBinary(\n components: Binary3x3x3Components,\n): Binary3x3x3State {\n const { epLex, eoMask, cpLex, coMask, poIdxU, poIdxL, moSupport, moMask } =\n components;\n\n return concatBinary(BIT_LENGTHS, [\n epLex,\n eoMask,\n cpLex,\n coMask,\n poIdxU,\n poIdxL,\n moSupport,\n moMask,\n ]);\n}\n\n/** @category Binary 3x3x3 Format */\nexport function reid3x3x3ToTwizzleBinary(state: KState): Binary3x3x3State {\n const components: Binary3x3x3Components = reid3x3x3ToBinaryComponents(state);\n return binaryComponentsToTwizzleBinary(components);\n}\n\n/** @category Binary 3x3x3 Format */\nexport function twizzleBinaryToBinaryComponents(\n buffer: ArrayBuffer,\n): Binary3x3x3Components {\n const [epLex, eoMask, cpLex, coMask, poIdxU, poIdxL, moSupport, moMask] =\n splitBinary(BIT_LENGTHS, buffer);\n\n return {\n epLex,\n eoMask,\n cpLex,\n coMask,\n poIdxU,\n poIdxL,\n moSupport,\n moMask,\n };\n}\n\n/** @category Binary 3x3x3 Format */\nexport function binaryComponentsToReid3x3x3(\n components: Binary3x3x3Components,\n): KState {\n const stateData: KStateData = {\n EDGES: {\n pieces: lexToPermutation(12, components.epLex),\n orientation: maskToOrientations(2, 12, components.eoMask),\n },\n CORNERS: {\n pieces: lexToPermutation(8, components.cpLex),\n orientation: maskToOrientations(3, 8, components.coMask),\n },\n CENTERS: {\n pieces: identityPermutation(6),\n orientation: maskToOrientations(4, 6, components.moMask),\n },\n };\n if (!components.moSupport) {\n stateData.CENTERS.orientationMod = new Array(6).fill(1);\n }\n const normedState = new KState(experimental3x3x3KPuzzle, stateData);\n\n if (!supportsPuzzleOrientation(components)) {\n return normedState;\n }\n\n return reorientPuzzle(normedState, components.poIdxU, components.poIdxL);\n}\n\n// Returns a list of error string.\n// An empty list means validation success.\nfunction validateComponents(components: Binary3x3x3Components): string[] {\n const errors = [];\n if (components.epLex < 0 || components.epLex >= 479001600) {\n errors.push(`epLex (${components.epLex}) out of range`);\n }\n if (components.cpLex < 0 || components.cpLex >= 40320) {\n errors.push(`cpLex (${components.cpLex}) out of range`);\n }\n if (components.coMask < 0 || components.coMask >= 6561) {\n errors.push(`coMask (${components.coMask}) out of range`);\n }\n if (components.poIdxU < 0 || components.poIdxU >= 6) {\n // 0x111 (for idxU) means \"not supported\"\n if (supportsPuzzleOrientation(components)) {\n errors.push(`poIdxU (${components.poIdxU}) out of range`);\n }\n }\n // The following cannot be (f decoded from binary properl) out of rangey.\n if (components.eoMask < 0 || components.eoMask >= 4096) {\n errors.push(`eoMask (${components.eoMask}) out of range`);\n }\n if (components.moMask < 0 || components.moMask >= 4096) {\n errors.push(`moMask (${components.moMask}) out of range`);\n }\n if (components.poIdxL < 0 || components.poIdxL >= 4) {\n errors.push(`poIdxL (${components.poIdxL}) out of range`);\n }\n if (components.moSupport < 0 || components.moSupport >= 2) {\n errors.push(`moSupport (${components.moSupport}) out of range`);\n }\n return errors;\n}\n\n/** @category Binary 3x3x3 Format */\nexport function twizzleBinaryToReid3x3x3(buffy: ArrayBuffer): KState {\n const components = twizzleBinaryToBinaryComponents(buffy);\n const errors = validateComponents(components);\n if (errors.length !== 0) {\n throw new Error(`Invalid binary state components: ${errors.join(\", \")}`);\n }\n return binaryComponentsToReid3x3x3(components);\n}\n", "export function bufferToSpacedHex(buffer: ArrayBuffer): string {\n // buffer is an ArrayBuffer\n return (\n Array.prototype.map.call(new Uint8Array(buffer), (x: number) =>\n `00${x.toString(16)}`.slice(-2),\n ) as string[]\n ).join(\" \");\n}\n\nexport function spacedHexToBuffer(hex: string): Uint8Array {\n return new Uint8Array(hex.split(\" \").map((c) => parseInt(c, 16)));\n}\n"],
5
- "mappings": ";;;;;;;;;;;AAAO,SAAS,oBAAoB,UAA4B;AAC9D,QAAM,MAAM,IAAI,MAAc,QAAQ;AACtC,WAAS,IAAI,GAAG,IAAI,UAAU,KAAK;AACjC,QAAI,CAAC,IAAI;AAAA,EACX;AACA,SAAO;AACT;AAGO,SAAS,mBACd,OACA,cACQ;AACR,MAAI,MAAM;AACV,aAAW,eAAe,cAAc;AACtC,WAAO;AACP,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAGO,SAAS,mBACd,OACA,UACA,MACU;AACV,QAAM,MAAM,CAAC;AACb,SAAO,OAAO,GAAG;AACf,QAAI,KAAK,OAAO,KAAK;AACrB,WAAO,KAAK,MAAM,OAAO,KAAK;AAAA,EAChC;AACA,SAAO,IAAI,MAAc,WAAW,IAAI,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,IAAI,QAAQ,CAAC;AAC9E;AAGO,SAAS,iBAAiB,aAA+B;AAC9D,QA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yB,OAA4B;AACnE,QAAM,aAAa,gCAAgC,KAAK;AACxD,QAAM,SAAS,mBAAmB,UAAU;AAC5C,MAAI,OAAO,WAAW,GAAG;AACvB,UAAM,IAAI,MAAM,oCAAoC,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EACzE;AACA,SAAO,4BAA4B,UAAU;AAC/C;;;ACpQO,SAAS,kBAAkB,QAA6B;AAE7D,SACE,MAAM,UAAU,IAAI;AAAA,IAAK,IAAI,WAAW,MAAM;AAAA,IAAG,CAAC,MAChD,KAAK,EAAE,SAAS,EAAE,CAAC,GAAG,MAAM,EAAE;AAAA,EAChC,EACA,KAAK,GAAG;AACZ;AAEO,SAAS,kBAAkB,KAAyB;AACzD,SAAO,IAAI,WAAW,IAAI,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC;AAClE;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/cubing/notation/commonMetrics.ts", "../../src/cubing/notation/cube3x3x3Metrics.ts", "../../src/cubing/notation/CountMoves.ts", "../../src/cubing/notation/CountAnimatedLeaves.ts"],
4
- "sourcesContent": ["export enum CommonMetric {\n // OBTM (Outer Block Turn Metric)\n OuterBlockTurnMetric = \"OBTM\",\n // RBTM (Range Block Turn Metric)\n RangeBlockTurnMetric = \"RBTM\",\n // SSTM (Single Slice Turn Metric)\n SingleSliceTurnMetric = \"SSTM\",\n // OBQTM (Outer Block Quantum Turn Metric)\n OuterBlockQuantumTurnMetric = \"OBQTM\",\n // RBQTM (Range Block Quantum Turn Metric)\n RangeBlockQuantumTurnMetric = \"RBQTM\",\n // SSQTM (Single Slice Quantum Turn Metric)\n SingleSliceQuantumTurnMetric = \"SSQTM\",\n ExecutionTurnMetric = \"ETM\",\n}\n\nexport enum CommonMetricAlias {\n // QTM (Quantum Turn Metric)\n QuantumTurnMetric = \"OBQTM\",\n // HTM (Hand Turn Metric)\n HandTurnMetric = \"OBTM\",\n // STM (Slice Turn Metric)\n SliceTurnMetric = \"RBTM\",\n}\n", "// TODO: move this into the 3x3x3 puzzle loader.\n\nimport type { Move } from \"../alg\";\nimport { experimentalCube3x3x3KPuzzleDefinition } from \"../puzzles/cubing-private\";\nimport { CommonMetric } from \"./commonMetrics\";\n\nenum MoveType {\n Rotation = \"Rotation\",\n Outer = \"Outer\",\n Inner = \"Inner\",\n}\n\nfunction uncachedMoveCount(moveQuantumString: string): MoveType {\n if (\n moveQuantumString.endsWith(\"v\") ||\n [\"x\", \"y\", \"z\"].includes(moveQuantumString)\n ) {\n // Rv\n return MoveType.Rotation;\n }\n if (\n moveQuantumString.startsWith(\"2\") ||\n [\"M\", \"E\", \"S\"].includes(moveQuantumString)\n ) {\n return MoveType.Inner;\n }\n return MoveType.Outer;\n}\n\nlet cache: Record<string, MoveType> | undefined;\nfunction getCache(): Record<string, MoveType> {\n if (cache) {\n return cache;\n }\n cache = {};\n const moveQuantumStrings = [\n ...Object.keys(experimentalCube3x3x3KPuzzleDefinition.moves),\n ...Object.keys(\n experimentalCube3x3x3KPuzzleDefinition.experimentalDerivedMoves!,\n ),\n ];\n for (const moveQuantumString of moveQuantumStrings) {\n cache[moveQuantumString] = uncachedMoveCount(moveQuantumString);\n }\n return cache;\n}\n\n// Ancient wisdom: https://github.com/cubing/alg.js/blob/0599fad84d81b8d943ad3ea3e5dc191db8b6c157/alg.js#L638-L651\n/**\n * A move with an amount of 0 always has 0 cost. Else, the cost is\n *\n * constantFactor + amountFactor * Math.abs(move.amount)\n *\n */\nexport const costFactorsByMetric: Partial<\n Record<\n CommonMetric,\n Record<\n MoveType,\n {\n constantFactor: number;\n amountFactor: number;\n }\n >\n >\n> = {\n // Note: these are hardcoded for 3x3x3. They will not automatically generalize to any other puzzles.\n [CommonMetric.OuterBlockTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 0, amountFactor: 0 },\n [MoveType.Outer]: { constantFactor: 1, amountFactor: 0 },\n [MoveType.Inner]: { constantFactor: 2, amountFactor: 0 },\n },\n [CommonMetric.RangeBlockTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 0, amountFactor: 0 },\n [MoveType.Outer]: { constantFactor: 1, amountFactor: 0 },\n [MoveType.Inner]: { constantFactor: 1, amountFactor: 0 },\n },\n [CommonMetric.OuterBlockQuantumTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 0, amountFactor: 0 },\n [MoveType.Outer]: { constantFactor: 0, amountFactor: 1 },\n [MoveType.Inner]: { constantFactor: 0, amountFactor: 2 },\n },\n [CommonMetric.RangeBlockQuantumTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 0, amountFactor: 0 },\n [MoveType.Outer]: { constantFactor: 0, amountFactor: 1 },\n [MoveType.Inner]: { constantFactor: 0, amountFactor: 1 },\n },\n [CommonMetric.ExecutionTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 1, amountFactor: 0 },\n [MoveType.Outer]: { constantFactor: 1, amountFactor: 0 },\n [MoveType.Inner]: { constantFactor: 1, amountFactor: 0 },\n },\n};\n\nexport function countMove3x3x3(metric: CommonMetric, move: Move): number {\n const costFactors = costFactorsByMetric[metric];\n if (!costFactors) {\n throw new Error(`Invalid metric for 3x3x3: ${metric}`);\n }\n const cache = getCache();\n const moveQuantumString = move.quantum.toString();\n if (!(moveQuantumString in cache)) {\n throw new Error(`Invalid move for 3x3x3 ${metric}: ${moveQuantumString}`);\n }\n const costType = cache[moveQuantumString];\n const { constantFactor, amountFactor } = costFactors[costType];\n return constantFactor + amountFactor * Math.abs(move.amount);\n}\n", "// TODO: move this file somewhere permanent.\nimport {\n Alg,\n Commutator,\n Conjugate,\n functionFromTraversal,\n Grouping,\n LineComment,\n Move,\n Newline,\n Pause,\n TraversalUp,\n} from \"../alg\";\nimport type { PuzzleLoader } from \"../puzzles\";\nimport { CommonMetric } from \"./commonMetrics\";\nimport { costFactorsByMetric, countMove3x3x3 } from \"./cube3x3x3Metrics\";\n\n/*\n * For movecount, that understands puzzle rotations. This code\n * should be moved to the alg class, probably.\n */\nclass CountMoves extends TraversalUp<number> {\n constructor(private metric: (move: Move) => number) {\n super();\n }\n\n public traverseAlg(alg: Alg): number {\n let r = 0;\n for (const algNode of alg.childAlgNodes()) {\n r += this.traverseAlgNode(algNode);\n }\n return r;\n }\n\n public traverseGrouping(grouping: Grouping): number {\n const alg: Alg = grouping.alg;\n return this.traverseAlg(alg) * Math.abs(grouping.amount);\n }\n\n public traverseMove(move: Move): number {\n return this.metric(move);\n }\n\n public traverseCommutator(commutator: Commutator): number {\n return (\n 2 * (this.traverseAlg(commutator.A) + this.traverseAlg(commutator.B))\n );\n }\n\n public traverseConjugate(conjugate: Conjugate): number {\n return 2 * this.traverseAlg(conjugate.A) + this.traverseAlg(conjugate.B);\n }\n\n // TODO: Remove spaces between repeated pauses (in traverseSequence)\n public traversePause(_pause: Pause): number {\n return 0;\n }\n\n public traverseNewline(_newLine: Newline): number {\n return 0;\n }\n\n // TODO: Enforce being followed by a newline (or the end of the alg)?\n public traverseLineComment(_comment: LineComment): number {\n return 0;\n }\n}\n\nfunction isCharUppercase(c: string): boolean {\n return \"A\" <= c && c <= \"Z\";\n}\n\n// TODO: Implement a puzzle-specific way to calculate this.\nfunction baseMetric(move: Move): number {\n const fam = move.family;\n if (\n (isCharUppercase(fam[0]) && fam[fam.length - 1] === \"v\") ||\n fam === \"x\" ||\n fam === \"y\" ||\n fam === \"z\" ||\n fam === \"T\"\n ) {\n return 0;\n } else {\n return 1;\n }\n}\n\nfunction etmMetric(_move: Move): number {\n return 1;\n}\n\n// TODO: Implement a puzzle-specific way to calculate this.\nfunction rangeBlockTurnMetric(move: Move): number {\n const fam = move.family;\n if (\n (isCharUppercase(fam[0]) && fam[fam.length - 1] === \"v\") ||\n fam === \"x\" ||\n fam === \"y\" ||\n fam === \"z\" ||\n fam === \"T\"\n ) {\n return 0;\n } else {\n return 1;\n }\n}\n\n// TODO: Implement a puzzle-specific way to calculate this.\nfunction quantumMetric(move: Move): number {\n return Math.abs(move.amount) * rangeBlockTurnMetric(move);\n}\n\nexport const countMoves = functionFromTraversal(CountMoves, [baseMetric]);\nexport const countMovesETM = functionFromTraversal(CountMoves, [etmMetric]);\nexport const countRangeBlockQuantumMovesPG = functionFromTraversal(CountMoves, [\n quantumMetric,\n]);\nexport const countRangeBlockMovesPG = functionFromTraversal(CountMoves, [\n rangeBlockTurnMetric,\n]);\n\n/**\n * Only implemented so far:\n *\n * - 3x3x3: OBTM, RBTM, ETM\n */\nexport function countMetricMoves(\n puzzleLoader: PuzzleLoader,\n metric: CommonMetric,\n alg: Alg,\n): number {\n if (puzzleLoader.id === \"3x3x3\") {\n if (metric in costFactorsByMetric) {\n return functionFromTraversal(CountMoves, [\n (move: Move) => countMove3x3x3(metric, move),\n ])(alg);\n }\n } else {\n switch (metric) {\n case CommonMetric.ExecutionTurnMetric:\n return countMovesETM(alg);\n case CommonMetric.RangeBlockTurnMetric:\n if (puzzleLoader.pg) {\n return countRangeBlockMovesPG(alg);\n }\n case CommonMetric.RangeBlockQuantumTurnMetric:\n if (puzzleLoader.pg) {\n return countRangeBlockQuantumMovesPG(alg);\n }\n }\n }\n throw new Error(\"Unsupported puzzle or metric.\");\n}\n", "import {\n Alg,\n Commutator,\n Conjugate,\n Grouping,\n LineComment,\n Move,\n Newline,\n Pause,\n TraversalUp,\n} from \"../alg\";\nimport { functionFromTraversal } from \"../alg\";\n\n// TODO: Include Pause, include amounts\nclass CountAnimatedLeaves extends TraversalUp<number, number> {\n public traverseAlg(alg: Alg): number {\n let total = 0;\n for (const part of alg.childAlgNodes()) {\n total += this.traverseAlgNode(part);\n }\n return total;\n }\n\n public traverseGrouping(grouping: Grouping): number {\n return this.traverseAlg(grouping.alg) * Math.abs(grouping.amount);\n }\n\n public traverseMove(_move: Move): number {\n return 1;\n }\n\n public traverseCommutator(commutator: Commutator): number {\n return (\n 2 * (this.traverseAlg(commutator.A) + this.traverseAlg(commutator.B))\n );\n }\n\n public traverseConjugate(conjugate: Conjugate): number {\n return 2 * this.traverseAlg(conjugate.A) + this.traverseAlg(conjugate.B);\n }\n\n public traversePause(_pause: Pause): number {\n return 1;\n }\n\n public traverseNewline(_newline: Newline): number {\n return 0;\n }\n\n public traverseLineComment(_comment: LineComment): number {\n return 0;\n }\n}\n\nexport const countAnimatedLeaves = functionFromTraversal(CountAnimatedLeaves);\n"],
5
- "mappings": ";;;;;;;;;AAAO,IAAK,eAAL,kBAAKA,kBAAL;AAEL,EAAAA,cAAA,0BAAuB;AAEvB,EAAAA,cAAA,0BAAuB;AAEvB,EAAAA,cAAA,2BAAwB;AAExB,EAAAA,cAAA,iCAA8B;AAE9B,EAAAA,cAAA,iCAA8B;AAE9B,EAAAA,cAAA,kCAA+B;AAC/B,EAAAA,cAAA,yBAAsB;AAbZ,SAAAA;AAAA,GAAA;AAgBL,IAAK,oBAAL,kBAAKC,uBAAL;AAEL,EAAAA,mBAAA,uBAAoB;AAEpB,EAAAA,mBAAA,oBAAiB;AAEjB,EAAAA,mBAAA,qBAAkB;AANR,SAAAA;AAAA,GAAA;;;ACJZ,SAAS,kBAAkB,mBAAqC;AAC9D,MACE,kBAAkB,SAAS,GAAG,KAC9B,CAAC,KAAK,KAAK,GAAG,EAAE,SAAS,iBAAiB,GAC1C;AAEA,WAAO;AAAA,EACT;AACA,MACE,kBAAkB,WAAW,GAAG,KAChC,CAAC,KAAK,KAAK,GAAG,EAAE,SAAS,iBAAiB,GAC1C;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAI;AACJ,SAAS,WAAqC;AAC5C,MAAI,OAAO;AACT,WAAO;AAAA,EACT;AACA,UAAQ,CAAC;AACT,QAAM,qBAAqB;AAAA,IACzB,GAAG,OAAO,KAAK,2BAAuC,KAAK;AAAA,IAC3D,GAAG,OAAO;AAAA,MACR,2BAAuC;AAAA,IACzC;AAAA,EACF;AACA,aAAW,qBAAqB,oBAAoB;AAClD,UAAM,iBAAiB,IAAI,kBAAkB,iBAAiB;AAAA,EACh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