cubing 0.35.17 → 0.35.19

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 (81) hide show
  1. package/dist/esm/alg/index.js +1 -1
  2. package/dist/esm/bluetooth/index.js +53 -5
  3. package/dist/esm/bluetooth/index.js.map +2 -2
  4. package/dist/esm/{chunk-Z6WT2ASL.js → chunk-6OUID4YZ.js} +6 -3
  5. package/dist/esm/{chunk-Z6WT2ASL.js.map → chunk-6OUID4YZ.js.map} +1 -1
  6. package/dist/esm/{chunk-2L5M5LFU.js → chunk-7C5DKKWG.js} +35 -3
  7. package/dist/esm/chunk-7C5DKKWG.js.map +7 -0
  8. package/dist/esm/{chunk-QXTTYMT4.js → chunk-7LQBLROH.js} +11 -7
  9. package/dist/esm/chunk-7LQBLROH.js.map +7 -0
  10. package/dist/esm/{chunk-E4WRDOVK.js → chunk-BI4IALY5.js} +99 -6
  11. package/dist/esm/{chunk-E4WRDOVK.js.map → chunk-BI4IALY5.js.map} +1 -1
  12. package/dist/esm/{chunk-VZP3KFTU.js → chunk-CFNRQVBC.js} +191 -7
  13. package/dist/esm/chunk-CFNRQVBC.js.map +7 -0
  14. package/dist/esm/{chunk-IKR3E575.js → chunk-EXWFZEJA.js} +6 -3
  15. package/dist/esm/{chunk-IKR3E575.js.map → chunk-EXWFZEJA.js.map} +1 -1
  16. package/dist/esm/{chunk-UMKR43AG.js → chunk-IBLLQ5L6.js} +2 -2
  17. package/dist/esm/{chunk-UMKR43AG.js.map → chunk-IBLLQ5L6.js.map} +1 -1
  18. package/dist/esm/{chunk-H4AV2PB4.js → chunk-LCARNWZG.js} +27 -17
  19. package/dist/esm/chunk-LCARNWZG.js.map +7 -0
  20. package/dist/esm/{chunk-VKWWBFBQ.js → chunk-OZ7BVDDY.js} +32 -3
  21. package/dist/esm/{chunk-VKWWBFBQ.js.map → chunk-OZ7BVDDY.js.map} +2 -2
  22. package/dist/esm/{chunk-K52WWDXQ.js → chunk-RCFH7AT2.js} +3 -3
  23. package/dist/esm/{chunk-K52WWDXQ.js.map → chunk-RCFH7AT2.js.map} +1 -1
  24. package/dist/esm/{chunk-AORLJ3RN.js → chunk-TF2GO5ZC.js} +43 -14
  25. package/dist/esm/chunk-TF2GO5ZC.js.map +7 -0
  26. package/dist/esm/{chunk-HFSPQPHF.js → chunk-UOAT7IN5.js} +16 -2
  27. package/dist/esm/{chunk-HFSPQPHF.js.map → chunk-UOAT7IN5.js.map} +1 -1
  28. package/dist/esm/{chunk-EV25IJFC.js → chunk-ZYCJIZDN.js} +2 -1
  29. package/dist/esm/{chunk-EV25IJFC.js.map → chunk-ZYCJIZDN.js.map} +1 -1
  30. package/dist/esm/kpuzzle/index.js +2 -2
  31. package/dist/esm/notation/index.js +4 -4
  32. package/dist/esm/protocol/index.js +4 -4
  33. package/dist/esm/puzzle-geometry/index.js +116 -1
  34. package/dist/esm/puzzle-geometry/index.js.map +2 -2
  35. package/dist/esm/puzzles/index.js +4 -4
  36. package/dist/esm/{puzzles-dynamic-side-events-TEAE45HA.js → puzzles-dynamic-side-events-SRPR4BEO.js} +8 -1
  37. package/dist/esm/{puzzles-dynamic-side-events-TEAE45HA.js.map → puzzles-dynamic-side-events-SRPR4BEO.js.map} +1 -1
  38. package/dist/esm/scramble/index.js +9 -9
  39. package/dist/esm/search/index.js +9 -9
  40. package/dist/esm/{search-dynamic-sgs-side-events-E6B6CTUZ.js → search-dynamic-sgs-side-events-QD7TLXPV.js} +6 -6
  41. package/dist/esm/search-dynamic-sgs-side-events-QD7TLXPV.js.map +7 -0
  42. package/dist/esm/{search-dynamic-sgs-unofficial-NCIX7MEZ.js → search-dynamic-sgs-unofficial-UEIZW7YS.js} +6 -6
  43. package/dist/esm/search-dynamic-sgs-unofficial-UEIZW7YS.js.map +7 -0
  44. package/dist/esm/{search-dynamic-solve-3x3x3-VY7R3CDP.js → search-dynamic-solve-3x3x3-FJI2OWOW.js} +1 -1
  45. package/dist/esm/{search-dynamic-solve-3x3x3-VY7R3CDP.js.map → search-dynamic-solve-3x3x3-FJI2OWOW.js.map} +1 -1
  46. package/dist/esm/{search-dynamic-solve-4x4x4-LBWZXU5M.js → search-dynamic-solve-4x4x4-USNQSEDX.js} +6 -6
  47. package/dist/esm/{search-dynamic-solve-4x4x4-LBWZXU5M.js.map → search-dynamic-solve-4x4x4-USNQSEDX.js.map} +1 -1
  48. package/dist/esm/{search-dynamic-solve-fto-JJ32OJVM.js → search-dynamic-solve-fto-IDE3JR5R.js} +36 -1
  49. package/dist/esm/{search-dynamic-solve-fto-JJ32OJVM.js.map → search-dynamic-solve-fto-IDE3JR5R.js.map} +1 -1
  50. package/dist/esm/{search-dynamic-solve-kilominx-I7ZZOZ6H.js → search-dynamic-solve-kilominx-DUXFWYAF.js} +2 -2
  51. package/dist/esm/{search-dynamic-solve-kilominx-I7ZZOZ6H.js.map → search-dynamic-solve-kilominx-DUXFWYAF.js.map} +1 -1
  52. package/dist/esm/{search-dynamic-solve-master_tetraminx-UF5FKJW6.js → search-dynamic-solve-master_tetraminx-N2NAFS2P.js} +2 -1
  53. package/dist/esm/{search-dynamic-solve-master_tetraminx-UF5FKJW6.js.map → search-dynamic-solve-master_tetraminx-N2NAFS2P.js.map} +1 -1
  54. package/dist/esm/{search-dynamic-solve-sq1-S6V3FTO2.js → search-dynamic-solve-sq1-OKRDTBN4.js} +1 -1
  55. package/dist/esm/{search-dynamic-solve-sq1-S6V3FTO2.js.map → search-dynamic-solve-sq1-OKRDTBN4.js.map} +1 -1
  56. package/dist/esm/{search-worker-inside-generated-string-UDROZURX.js → search-worker-inside-generated-string-BOLAH6BY.js} +45 -36
  57. package/dist/esm/search-worker-inside-generated-string-BOLAH6BY.js.map +7 -0
  58. package/dist/esm/search-worker-js-entry-XBNFXQ5S.js +17 -0
  59. package/dist/esm/{search-worker-ts-entry-2DDM3O5C.js → search-worker-ts-entry-ERCMEK5N.js} +4 -4
  60. package/dist/esm/{search-worker-ts-entry-2DDM3O5C.js.map → search-worker-ts-entry-ERCMEK5N.js.map} +1 -1
  61. package/dist/esm/stream/index.js +1 -1
  62. package/dist/esm/twisty/index.js +150 -7
  63. package/dist/esm/twisty/index.js.map +2 -2
  64. package/dist/esm/{twisty-dynamic-3d-TMPJWZQG.js → twisty-dynamic-3d-GJKWHMDR.js} +40 -6
  65. package/dist/esm/twisty-dynamic-3d-GJKWHMDR.js.map +7 -0
  66. package/dist/esm/{twsearch-BDAXZGZU-WI6J7JNA.js → twsearch-BDAXZGZU-4Y6SSRS3.js} +1 -1
  67. package/dist/esm/{twsearch-BDAXZGZU-WI6J7JNA.js.map → twsearch-BDAXZGZU-4Y6SSRS3.js.map} +1 -1
  68. package/dist/esm/{twsearch-FLMI3OQH.js → twsearch-GXY4U67H.js} +3 -3
  69. package/dist/esm/{twsearch-FLMI3OQH.js.map → twsearch-GXY4U67H.js.map} +1 -1
  70. package/package.json +17 -17
  71. package/dist/esm/chunk-2L5M5LFU.js.map +0 -7
  72. package/dist/esm/chunk-AORLJ3RN.js.map +0 -7
  73. package/dist/esm/chunk-H4AV2PB4.js.map +0 -7
  74. package/dist/esm/chunk-QXTTYMT4.js.map +0 -7
  75. package/dist/esm/chunk-VZP3KFTU.js.map +0 -7
  76. package/dist/esm/search-dynamic-sgs-side-events-E6B6CTUZ.js.map +0 -7
  77. package/dist/esm/search-dynamic-sgs-unofficial-NCIX7MEZ.js.map +0 -7
  78. package/dist/esm/search-worker-inside-generated-string-UDROZURX.js.map +0 -7
  79. package/dist/esm/search-worker-js-entry-XLCVV7MT.js +0 -17
  80. package/dist/esm/twisty-dynamic-3d-TMPJWZQG.js.map +0 -7
  81. /package/dist/esm/{search-worker-js-entry-XLCVV7MT.js.map → search-worker-js-entry-XBNFXQ5S.js.map} +0 -0
@@ -58,23 +58,27 @@ var MIN_INT = -2147483648;
58
58
 
59
59
  // src/cubing/alg/AlgBuilder.ts
60
60
  var AlgBuilder = class {
61
- #algNode = [];
61
+ #algNodes = [];
62
62
  push(u) {
63
- this.#algNode.push(u);
63
+ this.#algNodes.push(u);
64
64
  }
65
+ // TODO: Allow FlexibleAlgSource?
66
+ /** @deprecated */
65
67
  experimentalPushAlg(alg) {
66
68
  for (const u of alg.childAlgNodes()) {
67
69
  this.push(u);
68
70
  }
69
71
  }
72
+ // TODO: can we guarantee this to be fast in the permanent API?
70
73
  experimentalNumAlgNodes() {
71
- return this.#algNode.length;
74
+ return this.#algNodes.length;
72
75
  }
76
+ // can be called multiple times, even if you push alg nodes inbetween.
73
77
  toAlg() {
74
- return new Alg(this.#algNode);
78
+ return new Alg(this.#algNodes);
75
79
  }
76
80
  reset() {
77
- this.#algNode = [];
81
+ this.#algNodes = [];
78
82
  }
79
83
  };
80
84
 
@@ -220,6 +224,12 @@ var LineComment = class extends AlgCommon {
220
224
  toString() {
221
225
  return `//${this.#text}`;
222
226
  }
227
+ // toJSON(): LineCommentJSON {
228
+ // return {
229
+ // type: "comment",
230
+ // text: this.#text,
231
+ // };
232
+ // }
223
233
  };
224
234
 
225
235
  // src/cubing/alg/alg-nodes/leaves/Newline.ts
@@ -240,6 +250,7 @@ var Newline = class extends AlgCommon {
240
250
 
241
251
  // src/cubing/alg/alg-nodes/leaves/Pause.ts
242
252
  var Pause = class extends AlgCommon {
253
+ // TODO: tie this to the alg
243
254
  toString() {
244
255
  return ".";
245
256
  }
@@ -523,11 +534,13 @@ var AlgParser = class {
523
534
  if (suffix.startsWith("+")) {
524
535
  quantumMove = quantumMove.modified({
525
536
  family: `${quantumMove.family}_${suffix === "+" ? "PLUS" : "PLUSPLUS"}_`
537
+ // TODO
526
538
  });
527
539
  }
528
540
  if (suffix.startsWith("-")) {
529
541
  quantumMove = quantumMove.modified({
530
542
  family: `${quantumMove.family}_${suffix === "-" ? "PLUS" : "PLUSPLUS"}_`
543
+ // TODO
531
544
  });
532
545
  amount *= -1;
533
546
  }
@@ -585,6 +598,7 @@ var AlgParser = class {
585
598
  this.#idx += arr[0].length;
586
599
  return arr;
587
600
  }
601
+ // TOD: can we avoid this?
588
602
  tryRegex(regex) {
589
603
  const arr = regex.exec(this.remaining());
590
604
  if (arr === null) {
@@ -653,6 +667,7 @@ var QuantumWithAmount = class {
653
667
  isIdentical(other) {
654
668
  return this.quantum.isIdentical(other.quantum) && this.amount === other.amount;
655
669
  }
670
+ // TODO: `Conjugate` and `Commutator` decrement `depth` inside the quantum, `Grouping` has to do it outside the quantum.
656
671
  *experimentalExpand(iterDir, depth) {
657
672
  const absAmount = Math.abs(this.amount);
658
673
  const newIterDir = toggleDirection(iterDir, this.amount < 0);
@@ -697,6 +712,7 @@ var QuantumMove = class extends Comparable {
697
712
  static fromString(s) {
698
713
  return parseQuantumMove(s);
699
714
  }
715
+ // TODO: `modify`?
700
716
  modified(modifications) {
701
717
  return new QuantumMove(
702
718
  modifications.family ?? this.#family,
@@ -708,12 +724,18 @@ var QuantumMove = class extends Comparable {
708
724
  const otherAsQuantumMove = other;
709
725
  return other.is(QuantumMove) && this.#family === otherAsQuantumMove.#family && this.#innerLayer === otherAsQuantumMove.#innerLayer && this.#outerLayer === otherAsQuantumMove.#outerLayer;
710
726
  }
727
+ // TODO: provide something more useful on average.
728
+ /** @deprecated */
711
729
  get family() {
712
730
  return this.#family;
713
731
  }
732
+ // TODO: provide something more useful on average.
733
+ /** @deprecated */
714
734
  get outerLayer() {
715
735
  return this.#outerLayer;
716
736
  }
737
+ // TODO: provide something more useful on average.
738
+ /** @deprecated */
717
739
  get innerLayer() {
718
740
  return this.#innerLayer;
719
741
  }
@@ -775,6 +797,7 @@ var Move = class extends AlgCommon {
775
797
  get quantum() {
776
798
  return this.#quantumWithAmount.quantum;
777
799
  }
800
+ // TODO: `modify`?
778
801
  modified(modifications) {
779
802
  return new Move(
780
803
  this.#quantumWithAmount.quantum.modified(modifications),
@@ -787,16 +810,20 @@ var Move = class extends AlgCommon {
787
810
  get amount() {
788
811
  return this.#quantumWithAmount.amount;
789
812
  }
813
+ /** @deprecated */
790
814
  get type() {
791
815
  warnOnce("deprecated: type");
792
816
  return "blockMove";
793
817
  }
818
+ /** @deprecated */
794
819
  get family() {
795
820
  return this.#quantumWithAmount.quantum.family ?? void 0;
796
821
  }
822
+ /** @deprecated */
797
823
  get outerLayer() {
798
824
  return this.#quantumWithAmount.quantum.outerLayer ?? void 0;
799
825
  }
826
+ /** @deprecated */
800
827
  get innerLayer() {
801
828
  return this.#quantumWithAmount.quantum.innerLayer ?? void 0;
802
829
  }
@@ -813,6 +840,15 @@ var Move = class extends AlgCommon {
813
840
  }
814
841
  return this.#quantumWithAmount.quantum.toString() + this.#quantumWithAmount.suffix();
815
842
  }
843
+ // // TODO: Serialize as a string?
844
+ // toJSON(): MoveJSON {
845
+ // return {
846
+ // type: "move",
847
+ // family: this.family,
848
+ // innerLayer: this.innerLayer,
849
+ // outerLayer: this.outerLayer,
850
+ // };
851
+ // }
816
852
  };
817
853
 
818
854
  // src/cubing/alg/alg-nodes/containers/Grouping.ts
@@ -848,6 +884,7 @@ var Square1TupleFormatter = class {
848
884
  };
849
885
  var square1TupleFormatterInstance = new Square1TupleFormatter();
850
886
  var Grouping = class extends AlgCommon {
887
+ // TODO: tie this to the alg
851
888
  constructor(algSource, amount) {
852
889
  super();
853
890
  const alg = experimentalEnsureAlg(algSource);
@@ -864,6 +901,7 @@ var Grouping = class extends AlgCommon {
864
901
  get amount() {
865
902
  return this.#quantumWithAmount.amount;
866
903
  }
904
+ /** @deprecated */
867
905
  get experimentalRepetitionSuffix() {
868
906
  return this.#quantumWithAmount.suffix();
869
907
  }
@@ -890,6 +928,12 @@ var Grouping = class extends AlgCommon {
890
928
  experimentalAsSquare1Tuple() {
891
929
  return square1TupleFormatterInstance.tuple(this);
892
930
  }
931
+ // toJSON(): GroupingJSON {
932
+ // return {
933
+ // type: "grouping",
934
+ // alg: this.#quanta.quantum.toJSON(),
935
+ // };
936
+ // }
893
937
  };
894
938
 
895
939
  // src/cubing/alg/is.ts
@@ -932,6 +976,7 @@ function mustBeAlgNode(t) {
932
976
  throw new Error("internal error: expected AlgNode");
933
977
  }
934
978
  var TraversalDownUp = class {
979
+ // Immediate subclasses should overwrite this.
935
980
  traverseAlgNode(algNode, dataDown) {
936
981
  return dispatch(this, algNode, dataDown);
937
982
  }
@@ -1067,7 +1112,8 @@ function experimentalAppendMove(alg, addedMove, options) {
1067
1112
  const quantumKey = move.quantum.toString();
1068
1113
  if (sameDirectionOnly) {
1069
1114
  const existingQuantumDirectionOnAxis = quantumDirections.get(quantumKey);
1070
- if (existingQuantumDirectionOnAxis && !areSameDirection(existingQuantumDirectionOnAxis, move)) {
1115
+ if (existingQuantumDirectionOnAxis && // Short-circuits, but that's actually okay here.
1116
+ !areSameDirection(existingQuantumDirectionOnAxis, move)) {
1071
1117
  break;
1072
1118
  }
1073
1119
  quantumDirections.set(quantumKey, Math.sign(move.amount));
@@ -1110,12 +1156,14 @@ var Simplify = class extends TraversalDownUp {
1110
1156
  #newPlaceholderAssociations() {
1111
1157
  return this.#newPlaceholderAssociationsMap ?? (this.#newPlaceholderAssociationsMap = /* @__PURE__ */ new Map());
1112
1158
  }
1159
+ // TODO: avoid allocations?
1113
1160
  #descendOptions(options) {
1114
1161
  return {
1115
1162
  ...options,
1116
1163
  depth: options.depth ? options.depth - 1 : null
1117
1164
  };
1118
1165
  }
1166
+ // TODO: Handle
1119
1167
  *traverseAlg(alg, options) {
1120
1168
  if (options.depth === 0) {
1121
1169
  yield* alg.childAlgNodes();
@@ -1259,7 +1307,9 @@ function experimentalEnsureAlg(alg) {
1259
1307
  return new Alg(alg);
1260
1308
  }
1261
1309
  var Alg = class extends AlgCommon {
1310
+ // #debugString: string;
1262
1311
  #algNodes;
1312
+ // TODO: freeze?
1263
1313
  constructor(alg) {
1264
1314
  super();
1265
1315
  this.#algNodes = Array.from(toIterable(alg));
@@ -1269,6 +1319,36 @@ var Alg = class extends AlgCommon {
1269
1319
  }
1270
1320
  }
1271
1321
  }
1322
+ /**
1323
+ * Checks whether this Alg is structurally identical to another Alg. This
1324
+ * essentially means that they are written identically apart from whitespace.
1325
+ *
1326
+ * const alg1 = new Alg("R U L'");
1327
+ * const alg2 = new Alg("L U' R'").invert();
1328
+ * // true
1329
+ * alg1.isIdentical(alg2);
1330
+ *
1331
+ * // false
1332
+ * new Alg("[R, U]").isIdentical(new Alg("R U R' U'"));
1333
+ * // true
1334
+ * new Alg("[R, U]").expand().isIdentical(new Alg("R U R' U'"));
1335
+ *
1336
+ * Note that .isIdentical() efficiently compares algorithms, but mainly exists
1337
+ * to help optimize code when the structure of an algorithm hasn't changed.
1338
+ * There are many ways to write the "same" alg on most puzzles, but is
1339
+ * *highly* recommended to avoid expanding two Alg instances to compare them,
1340
+ * since that can easily slow your program to a crawl if someone inputs an alg
1341
+ * containing a large repetition. In general, you should use `cubing/kpuzzle`
1342
+ * to compare if two algs have the same effect on a puzzle.
1343
+ *
1344
+ * Also note that parser annotations are not taken into account while comparing
1345
+ * algs:
1346
+ *
1347
+ * const alg = new Alg([new Move("R"), new Move("U2")]);
1348
+ * // true, even though one of the algs has parser annotations
1349
+ * alg.isIdentical(new Alg("R U2"))
1350
+ *
1351
+ */
1272
1352
  isIdentical(other) {
1273
1353
  const otherAsAlg = other;
1274
1354
  if (!other.is(Alg)) {
@@ -1286,15 +1366,44 @@ var Alg = class extends AlgCommon {
1286
1366
  }
1287
1367
  return true;
1288
1368
  }
1369
+ /**
1370
+ * Returns the inverse of the given alg.
1371
+ *
1372
+ * Note that that this does not make any assumptions about what puzzle the alg
1373
+ * is for. For example, U2 is its own inverse on a cube, but U2' has the same
1374
+ * effect U3 (and not U2) on Megaminx:
1375
+ *
1376
+ * // Outputs: R U2' L'
1377
+ * new Alg("L U2 R'").invert().log();
1378
+ */
1289
1379
  invert() {
1290
1380
  return new Alg(reverse(Array.from(this.#algNodes).map((u) => u.invert())));
1291
1381
  }
1382
+ /** @deprecated Use {@link Alg.expand} instead. */
1292
1383
  *experimentalExpand(iterDir = 1 /* Forwards */, depth) {
1293
1384
  depth ?? (depth = Infinity);
1294
1385
  for (const algNode of direct(this.#algNodes, iterDir)) {
1295
1386
  yield* algNode.experimentalExpand(iterDir, depth);
1296
1387
  }
1297
1388
  }
1389
+ /**
1390
+ * Expands all Grouping, Commutator, and Conjugate parts nested inside the
1391
+ * alg.
1392
+ *
1393
+ * // F R U R' U' F'
1394
+ * new Alg("[F: [R, U]]").expand().log();
1395
+ *
1396
+ * // F [R, U] F'
1397
+ * new Alg("[F: [R, U]]").expand(({ depth: 1 }).log();
1398
+ *
1399
+ * Avoid calling this on a user-provided alg unless the user explicitly asks
1400
+ * to see the expanded alg. Otherwise, it's easy to make your program freeze
1401
+ * when someone passes in an alg like: (R U)10000000
1402
+ *
1403
+ * Generally, if you want to perform an operation on an entire alg, you'll
1404
+ * want to use something based on the `Traversal` mechanism, like countMoves()
1405
+ * from `cubing/notation`.
1406
+ */
1298
1407
  expand(options) {
1299
1408
  return new Alg(
1300
1409
  this.experimentalExpand(
@@ -1303,6 +1412,7 @@ var Alg = class extends AlgCommon {
1303
1412
  )
1304
1413
  );
1305
1414
  }
1415
+ /** @deprecated */
1306
1416
  *experimentalLeafMoves() {
1307
1417
  for (const leaf of this.experimentalExpand()) {
1308
1418
  if (leaf.is(Move)) {
@@ -1315,6 +1425,7 @@ var Alg = class extends AlgCommon {
1315
1425
  Array.from(this.#algNodes).concat(Array.from(toIterable(input)))
1316
1426
  );
1317
1427
  }
1428
+ /** @deprecated */
1318
1429
  experimentalIsEmpty() {
1319
1430
  for (const _ of this.#algNodes) {
1320
1431
  return false;
@@ -1324,6 +1435,7 @@ var Alg = class extends AlgCommon {
1324
1435
  static fromString(s) {
1325
1436
  return parseAlg(s);
1326
1437
  }
1438
+ /** @deprecated */
1327
1439
  units() {
1328
1440
  return this.childAlgNodes();
1329
1441
  }
@@ -1332,16 +1444,25 @@ var Alg = class extends AlgCommon {
1332
1444
  yield algNode;
1333
1445
  }
1334
1446
  }
1447
+ /** @deprecated */
1335
1448
  experimentalNumUnits() {
1336
1449
  return this.experimentalNumChildAlgNodes();
1337
1450
  }
1338
1451
  experimentalNumChildAlgNodes() {
1339
1452
  return Array.from(this.#algNodes).length;
1340
1453
  }
1454
+ /** @deprecated */
1341
1455
  get type() {
1342
1456
  warnOnce("deprecated: type");
1343
1457
  return "sequence";
1344
1458
  }
1459
+ /**
1460
+ * Converts the Alg to a string:
1461
+ *
1462
+ * const alg = new Alg([new Move("R"), new Move("U2"), new Move("L")])
1463
+ * // R U2 L
1464
+ * console.log(alg.toString())
1465
+ */
1345
1466
  toString() {
1346
1467
  let output = "";
1347
1468
  let previousVisibleAlgNode = null;
@@ -1363,9 +1484,60 @@ var Alg = class extends AlgCommon {
1363
1484
  }
1364
1485
  return output;
1365
1486
  }
1487
+ /**
1488
+ * `experimentalSimplify` can perform several mostly-syntactic simplifications on an alg:
1489
+ *
1490
+ * // Logs: R' U3
1491
+ * import { Alg } from "cubing/alg";
1492
+ * new Alg("R R2' U U2").experimentalSimplify({ cancel: true }).log()
1493
+ *
1494
+ * You can pass in a `PuzzleLoader` (currently only for 3x3x3) for puzzle-specific simplifications:
1495
+ *
1496
+ * // Logs: R' U'
1497
+ * import { Alg } from "cubing/alg";
1498
+ * import { cube3x3x3 } from "cubing/puzzles";
1499
+ * new Alg("R R2' U U2").experimentalSimplify({ cancel: true, puzzleLoader: cube3x3x3 }).log()
1500
+ *
1501
+ * You can also cancel only moves that are in the same direction:
1502
+ *
1503
+ * // Logs: R R2' U'
1504
+ * import { Alg } from "cubing/alg";
1505
+ * import { cube3x3x3 } from "cubing/puzzles";
1506
+ * new Alg("R R2' U U2").experimentalSimplify({
1507
+ * cancel: { directional: "same-direction" },
1508
+ * puzzleLoader: cube3x3x3
1509
+ * }).log()
1510
+ *
1511
+ * Additionally, you can specify how moves are "wrapped":
1512
+ *
1513
+ * import { Alg } from "cubing/alg";
1514
+ * import { cube3x3x3 } from "cubing/puzzles";
1515
+ *
1516
+ * function example(puzzleSpecificModWrap) {
1517
+ * alg.experimentalSimplify({
1518
+ * cancel: { puzzleSpecificModWrap },
1519
+ * puzzleLoader: cube3x3x3
1520
+ * }).log()
1521
+ * }
1522
+ *
1523
+ * const alg = new Alg("R7' . R6' . R5' . R6")
1524
+ * example("none") // R7' . R6' . R5' . R6
1525
+ * example("gravity") // R . R2' . R' . R2
1526
+ * example("canonical-centered") // R . R2 . R' . R2
1527
+ * example("canonical-positive") // R . R2 . R3 . R2
1528
+ * example("preserve-sign") // R3' . R2' . R' . R2
1529
+ *
1530
+ * Same-axis and simultaneous move canonicalization is not implemented yet:
1531
+ *
1532
+ * // Logs: R L R
1533
+ * import { Alg } from "cubing/alg";
1534
+ * import { cube3x3x3 } from "cubing/puzzles";
1535
+ * new Alg("R L R").experimentalSimplify({ cancel: true, puzzleLoader: cube3x3x3 }).log()
1536
+ */
1366
1537
  experimentalSimplify(options) {
1367
1538
  return new Alg(simplify(this, options ?? {}));
1368
1539
  }
1540
+ /** @deprecated See {@link experimentalSimplify} */
1369
1541
  simplify(options) {
1370
1542
  return this.experimentalSimplify(options);
1371
1543
  }
@@ -1503,6 +1675,17 @@ var Example = {
1503
1675
  )
1504
1676
  ]),
1505
1677
  TriplePause: new Alg([new Pause(), new Pause(), new Pause()])
1678
+ // AllAlgParts: [
1679
+ // new Alg([new Move("R", 1), new Move("U", -1)]),
1680
+ // new Grouping(new Alg([new Move("F", 1)]), 2),
1681
+ // // new Rotation("y", -1),
1682
+ // new Move("R", 2),
1683
+ // new Commutator(new Alg([new Move("R", 2)]), new Alg([new Move("U", 2)]), 2),
1684
+ // new Conjugate(new Alg([new Move("L", 2)]), new Alg([new Move("D", -1)]), 2),
1685
+ // new Pause(),
1686
+ // new Newline(),
1687
+ // new LineComment("line comment"),
1688
+ // ],
1506
1689
  };
1507
1690
 
1508
1691
  // src/cubing/alg/keyboard.ts
@@ -1532,6 +1715,7 @@ var cubeKeyMapping = {
1532
1715
  186: new Move("y"),
1533
1716
  59: new Move("y"),
1534
1717
  65: new Move("y'"),
1718
+ // 186 is WebKit, 59 is Mozilla; see http://unixpapa.com/js/key.html
1535
1719
  80: new Move("z"),
1536
1720
  81: new Move("z'"),
1537
1721
  90: new Move("M'"),
@@ -1651,4 +1835,4 @@ export {
1651
1835
  keyToMove,
1652
1836
  experimentalAlgCubingNetLink
1653
1837
  };
1654
- //# sourceMappingURL=chunk-VZP3KFTU.js.map
1838
+ //# sourceMappingURL=chunk-CFNRQVBC.js.map