cubing 0.28.0 → 0.28.4

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 (107) hide show
  1. package/README.md +3 -1
  2. package/dist/esm/alg/index.js +4 -4
  3. package/dist/esm/bluetooth/index.js +222 -86
  4. package/dist/esm/bluetooth/index.js.map +3 -3
  5. package/dist/esm/{chunk-F4WWCPVE.js → chunk-2IZUSAXQ.js} +2 -2
  6. package/dist/esm/{chunk-F4WWCPVE.js.map → chunk-2IZUSAXQ.js.map} +1 -1
  7. package/dist/esm/{chunk-KBOIUBUE.js → chunk-DGJ3VGQO.js} +28 -12
  8. package/dist/esm/{chunk-KBOIUBUE.js.map → chunk-DGJ3VGQO.js.map} +1 -1
  9. package/dist/esm/{chunk-NJPSC7SH.js → chunk-GW4FGG42.js} +8 -4
  10. package/dist/esm/{chunk-NJPSC7SH.js.map → chunk-GW4FGG42.js.map} +1 -1
  11. package/dist/esm/{chunk-4KIZAW2Z.js → chunk-LSCTPPWV.js} +22 -8
  12. package/dist/esm/{chunk-4KIZAW2Z.js.map → chunk-LSCTPPWV.js.map} +1 -1
  13. package/dist/esm/{chunk-GXZIBFSN.js → chunk-NI7U4XAZ.js} +380 -242
  14. package/dist/esm/chunk-NI7U4XAZ.js.map +7 -0
  15. package/dist/esm/{chunk-GVPTO3OF.js → chunk-OX6O2ZO5.js} +1 -1
  16. package/dist/esm/{chunk-GVPTO3OF.js.map → chunk-OX6O2ZO5.js.map} +1 -1
  17. package/dist/esm/{chunk-LTPPXK6F.js → chunk-PYWGREIP.js} +44 -13
  18. package/dist/esm/chunk-PYWGREIP.js.map +7 -0
  19. package/dist/esm/{chunk-JAGHV77R.js → chunk-QDVCP6G7.js} +179 -76
  20. package/dist/esm/chunk-QDVCP6G7.js.map +7 -0
  21. package/dist/esm/chunk-RQGVI4ZL.js +1137 -0
  22. package/dist/esm/chunk-RQGVI4ZL.js.map +7 -0
  23. package/dist/esm/{chunk-MGJA5U5O.js → chunk-SBZRVSPK.js} +1 -12
  24. package/dist/esm/{chunk-MGJA5U5O.js.map → chunk-SBZRVSPK.js.map} +0 -0
  25. package/dist/esm/{chunk-V55YSWJY.js → chunk-WXCNEGW3.js} +10 -4
  26. package/dist/esm/{chunk-V55YSWJY.js.map → chunk-WXCNEGW3.js.map} +1 -1
  27. package/dist/esm/{chunk-UP6RBLG2.js → chunk-XU5ILFX5.js} +137 -66
  28. package/dist/esm/{chunk-UP6RBLG2.js.map → chunk-XU5ILFX5.js.map} +3 -3
  29. package/dist/esm/{chunk-4V4RM3YJ.js → chunk-Y22I7F7D.js} +21 -12
  30. package/dist/esm/{chunk-4V4RM3YJ.js.map → chunk-Y22I7F7D.js.map} +2 -2
  31. package/dist/esm/{chunk-ALBEW4DJ.js → chunk-ZB3P5AZN.js} +1 -1
  32. package/dist/esm/{chunk-ALBEW4DJ.js.map → chunk-ZB3P5AZN.js.map} +1 -1
  33. package/dist/esm/{chunk-47SWOA3X.js → chunk-ZNAYJGVL.js} +2 -2
  34. package/dist/esm/{chunk-47SWOA3X.js.map → chunk-ZNAYJGVL.js.map} +1 -1
  35. package/dist/esm/kpuzzle/index.js +3 -3
  36. package/dist/esm/notation/index.js +3 -3
  37. package/dist/esm/protocol/index.js +5 -5
  38. package/dist/esm/puzzle-geometry/index.js +4570 -15
  39. package/dist/esm/puzzle-geometry/index.js.map +4 -4
  40. package/dist/esm/puzzles/index.js +5 -5
  41. package/dist/esm/{puzzles-dynamic-3x3x3-NB2PEZTV.js → puzzles-dynamic-3x3x3-KIG5A6QR.js} +2 -2
  42. package/dist/esm/{puzzles-dynamic-3x3x3-NB2PEZTV.js.map → puzzles-dynamic-3x3x3-KIG5A6QR.js.map} +0 -0
  43. package/dist/esm/puzzles-dynamic-4x4x4-PEDAPUZK.js +126 -0
  44. package/dist/esm/puzzles-dynamic-4x4x4-PEDAPUZK.js.map +7 -0
  45. package/dist/esm/{puzzles-dynamic-side-events-WZI4Y3N6.js → puzzles-dynamic-side-events-5C7LMBWX.js} +2 -2
  46. package/dist/esm/{puzzles-dynamic-side-events-WZI4Y3N6.js.map → puzzles-dynamic-side-events-5C7LMBWX.js.map} +0 -0
  47. package/dist/esm/{puzzles-dynamic-unofficial-FUG3JBMH.js → puzzles-dynamic-unofficial-WWJ4NJMX.js} +2 -2
  48. package/dist/esm/{puzzles-dynamic-unofficial-FUG3JBMH.js.map → puzzles-dynamic-unofficial-WWJ4NJMX.js.map} +0 -0
  49. package/dist/esm/scramble/index.js +5 -5
  50. package/dist/esm/search/index.js +10 -10
  51. package/dist/esm/{search-dynamic-sgs-side-events-ZTOWSMQT.js → search-dynamic-sgs-side-events-MZN22QGN.js} +37 -21
  52. package/dist/esm/search-dynamic-sgs-side-events-MZN22QGN.js.map +7 -0
  53. package/dist/esm/{search-dynamic-sgs-unofficial-V6HZTLGM.js → search-dynamic-sgs-unofficial-AHPCH5XJ.js} +35 -14
  54. package/dist/esm/{search-dynamic-sgs-unofficial-V6HZTLGM.js.map → search-dynamic-sgs-unofficial-AHPCH5XJ.js.map} +2 -2
  55. package/dist/esm/{search-dynamic-solve-3x3x3-K42IWMQV.js → search-dynamic-solve-3x3x3-7XZTYQMO.js} +795 -142
  56. package/dist/esm/{search-dynamic-solve-3x3x3-K42IWMQV.js.map → search-dynamic-solve-3x3x3-7XZTYQMO.js.map} +1 -1
  57. package/dist/esm/{search-dynamic-solve-4x4x4-YH6SB2WB.js → search-dynamic-solve-4x4x4-IBS66QTP.js} +135 -29
  58. package/dist/esm/{search-dynamic-solve-4x4x4-YH6SB2WB.js.map → search-dynamic-solve-4x4x4-IBS66QTP.js.map} +1 -1
  59. package/dist/esm/{search-dynamic-solve-fto-O6UXF7EC.js → search-dynamic-solve-fto-4LI23P6K.js} +253 -69
  60. package/dist/esm/{search-dynamic-solve-fto-O6UXF7EC.js.map → search-dynamic-solve-fto-4LI23P6K.js.map} +2 -2
  61. package/dist/esm/{search-dynamic-solve-kilominx-ZPEOK4DY.js → search-dynamic-solve-kilominx-3HEVQ4MC.js} +32 -8
  62. package/dist/esm/{search-dynamic-solve-kilominx-ZPEOK4DY.js.map → search-dynamic-solve-kilominx-3HEVQ4MC.js.map} +2 -2
  63. package/dist/esm/{search-dynamic-solve-master_tetraminx-3RKD3IAN.js → search-dynamic-solve-master_tetraminx-UB32C7MM.js} +111 -42
  64. package/dist/esm/{search-dynamic-solve-master_tetraminx-3RKD3IAN.js.map → search-dynamic-solve-master_tetraminx-UB32C7MM.js.map} +2 -2
  65. package/dist/esm/{search-dynamic-solve-sq1-WIJEGVLP.js → search-dynamic-solve-sq1-HA72TYF2.js} +54 -9
  66. package/dist/esm/{search-dynamic-solve-sq1-WIJEGVLP.js.map → search-dynamic-solve-sq1-HA72TYF2.js.map} +2 -2
  67. package/dist/esm/search-worker-inside-generated-string-AMEXYCKK.js +3886 -0
  68. package/dist/esm/search-worker-inside-generated-string-AMEXYCKK.js.map +7 -0
  69. package/dist/esm/{search-worker-js-entry-3VKCL3RX.js → search-worker-js-entry-HUD3PWTB.js} +147 -53
  70. package/dist/esm/{search-worker-js-entry-3VKCL3RX.js.map → search-worker-js-entry-HUD3PWTB.js.map} +2 -2
  71. package/dist/esm/{search-worker-ts-entry-J3TDBCMV.js → search-worker-ts-entry-HER6WT5D.js} +5 -5
  72. package/dist/esm/{search-worker-ts-entry-J3TDBCMV.js.map → search-worker-ts-entry-HER6WT5D.js.map} +1 -1
  73. package/dist/esm/stream/index.js +12 -8
  74. package/dist/esm/stream/index.js.map +1 -1
  75. package/dist/esm/twisty/index.js +1164 -1513
  76. package/dist/esm/twisty/index.js.map +4 -4
  77. package/dist/esm/{twisty-dynamic-3d-UQJETF7O.js → twisty-dynamic-3d-NJUXK7KI.js} +358 -146
  78. package/dist/esm/twisty-dynamic-3d-NJUXK7KI.js.map +7 -0
  79. package/dist/types/{Alg-e2a80975.d.ts → Alg-137fb0d5.d.ts} +19 -16
  80. package/dist/types/{KState-a2f0e651.d.ts → KState-a73111d7.d.ts} +1 -9
  81. package/dist/types/{TwizzleLink-cd0fa192.d.ts → TwizzleLink-bef52ecd.d.ts} +47 -13
  82. package/dist/types/alg/index.d.ts +7 -6
  83. package/dist/types/bluetooth/index.d.ts +4 -4
  84. package/dist/types/{bluetooth-puzzle-3670a6a1.d.ts → bluetooth-puzzle-8a678993.d.ts} +9 -9
  85. package/dist/types/kpuzzle/index.d.ts +2 -2
  86. package/dist/types/notation/index.d.ts +1 -1
  87. package/dist/types/{outside-0ce1b145.d.ts → outside-e55f28a0.d.ts} +2 -2
  88. package/dist/types/{parse-ec97687c.d.ts → parseAlg-a28f7568.d.ts} +1 -1
  89. package/dist/types/protocol/index.d.ts +2 -2
  90. package/dist/types/puzzle-geometry/index.d.ts +3 -3
  91. package/dist/types/puzzles/index.d.ts +5 -5
  92. package/dist/types/scramble/index.d.ts +3 -3
  93. package/dist/types/search/index.d.ts +3 -3
  94. package/dist/types/stream/index.d.ts +5 -5
  95. package/dist/types/twisty/index.d.ts +13 -6
  96. package/package.json +43 -40
  97. package/dist/esm/chunk-7BLWQDZX.js +0 -342
  98. package/dist/esm/chunk-7BLWQDZX.js.map +0 -7
  99. package/dist/esm/chunk-GXZIBFSN.js.map +0 -7
  100. package/dist/esm/chunk-JAGHV77R.js.map +0 -7
  101. package/dist/esm/chunk-LTPPXK6F.js.map +0 -7
  102. package/dist/esm/chunk-ROGN5SXC.js +0 -4386
  103. package/dist/esm/chunk-ROGN5SXC.js.map +0 -7
  104. package/dist/esm/search-dynamic-sgs-side-events-ZTOWSMQT.js.map +0 -7
  105. package/dist/esm/search-worker-inside-generated-string-T43JGYSP.js +0 -3768
  106. package/dist/esm/search-worker-inside-generated-string-T43JGYSP.js.map +0 -7
  107. package/dist/esm/twisty-dynamic-3d-UQJETF7O.js.map +0 -7
@@ -1,4 +1,4 @@
1
- import { a as Alg, A as AlgNode } from './Alg-e2a80975.js';
1
+ import { a as Alg, A as AlgNode } from './Alg-137fb0d5.js';
2
2
 
3
3
  interface ParserIndexed {
4
4
  startCharIndex: number;
@@ -1,5 +1,5 @@
1
- import { K as KState } from '../KState-a2f0e651.js';
2
- import '../Alg-e2a80975.js';
1
+ import { K as KState } from '../KState-a73111d7.js';
2
+ import '../Alg-137fb0d5.js';
3
3
 
4
4
  declare type Binary3x3x3State = ArrayBuffer;
5
5
  interface Binary3x3x3Components {
@@ -1,6 +1,6 @@
1
- import { P as Perm } from '../KState-a2f0e651.js';
2
- export { u as EXPERIMENTAL_PUZZLE_BASE_SHAPES, s as EXPERIMENTAL_PUZZLE_CUT_TYPES, o as ExperimentalPGNotation, v as ExperimentalPuzzleBaseShape, q as ExperimentalPuzzleCutDescription, t as ExperimentalPuzzleCutType, r as ExperimentalPuzzleDescription, j as PuzzleGeometry, Q as Quat, S as StickerDat, k as StickerDatAxis, l as StickerDatFace, m as StickerDatSticker, i as getPG3DNamedPuzzles, g as getPuzzleDescriptionString, f as getPuzzleGeometryByDesc, h as getPuzzleGeometryByName, n as parseOptions, p as parsePuzzleDescription } from '../KState-a2f0e651.js';
3
- import '../Alg-e2a80975.js';
1
+ import { P as Perm } from '../KState-a73111d7.js';
2
+ export { u as EXPERIMENTAL_PUZZLE_BASE_SHAPES, s as EXPERIMENTAL_PUZZLE_CUT_TYPES, o as ExperimentalPGNotation, v as ExperimentalPuzzleBaseShape, q as ExperimentalPuzzleCutDescription, t as ExperimentalPuzzleCutType, r as ExperimentalPuzzleDescription, j as PuzzleGeometry, Q as Quat, S as StickerDat, k as StickerDatAxis, l as StickerDatFace, m as StickerDatSticker, i as getPG3DNamedPuzzles, g as getPuzzleDescriptionString, f as getPuzzleGeometryByDesc, h as getPuzzleGeometryByName, n as parseOptions, p as parsePuzzleDescription } from '../KState-a73111d7.js';
3
+ import '../Alg-137fb0d5.js';
4
4
 
5
5
  declare function schreierSims(g: Perm[], disp: (s: string) => void): bigint;
6
6
 
@@ -1,9 +1,9 @@
1
- import { P as PuzzleID, a as PuzzleLoader } from '../TwizzleLink-cd0fa192.js';
2
- export { a as PuzzleLoader } from '../TwizzleLink-cd0fa192.js';
1
+ import { P as PuzzleID, a as PuzzleLoader } from '../TwizzleLink-bef52ecd.js';
2
+ export { a as PuzzleLoader } from '../TwizzleLink-bef52ecd.js';
3
3
  import 'three';
4
- import '../Alg-e2a80975.js';
5
- import '../parse-ec97687c.js';
6
- import '../KState-a2f0e651.js';
4
+ import '../Alg-137fb0d5.js';
5
+ import '../parseAlg-a28f7568.js';
6
+ import '../KState-a73111d7.js';
7
7
 
8
8
  interface EventInfo {
9
9
  puzzleID: PuzzleID;
@@ -1,3 +1,3 @@
1
- export { r as randomScrambleForEvent } from '../outside-0ce1b145.js';
2
- import '../Alg-e2a80975.js';
3
- import '../KState-a2f0e651.js';
1
+ export { r as randomScrambleForEvent } from '../outside-e55f28a0.js';
2
+ import '../Alg-137fb0d5.js';
3
+ import '../KState-a73111d7.js';
@@ -1,6 +1,6 @@
1
- export { a as experimentalSolve2x2x2, e as experimentalSolve3x3x3IgnoringCenters, d as setDebug, c as solveMegaminx, b as solvePyraminx, s as solveSkewb } from '../outside-0ce1b145.js';
2
- import { K as KState } from '../KState-a2f0e651.js';
3
- import '../Alg-e2a80975.js';
1
+ export { a as experimentalSolve2x2x2, e as experimentalSolve3x3x3IgnoringCenters, d as setDebug, c as solveMegaminx, b as solvePyraminx, s as solveSkewb } from '../outside-e55f28a0.js';
2
+ import { K as KState } from '../KState-a73111d7.js';
3
+ import '../Alg-137fb0d5.js';
4
4
 
5
5
  declare function random333State(): Promise<KState>;
6
6
 
@@ -1,10 +1,10 @@
1
- import { M as MoveEvent, O as OrientationEvent } from '../bluetooth-puzzle-3670a6a1.js';
2
- import '../Alg-e2a80975.js';
3
- import '../KState-a2f0e651.js';
1
+ import { A as AlgLeafEvent, O as OrientationEvent } from '../bluetooth-puzzle-8a678993.js';
2
+ import '../Alg-137fb0d5.js';
3
+ import '../KState-a73111d7.js';
4
4
 
5
5
  interface ProxyMoveEvent {
6
6
  event: "move";
7
- data: MoveEvent;
7
+ data: AlgLeafEvent;
8
8
  }
9
9
  interface ProxyOrientationEvent {
10
10
  event: "orientation";
@@ -18,7 +18,7 @@ declare type ProxyEvent = ProxyMoveEvent | ProxyOrientationEvent | ProxyResetEve
18
18
  declare class WebSocketProxySender {
19
19
  protected websocket: WebSocket;
20
20
  constructor(url: string);
21
- sendMoveEvent(e: MoveEvent): void;
21
+ sendMoveEvent(e: AlgLeafEvent): void;
22
22
  sendOrientationEvent(e: OrientationEvent): void;
23
23
  sendResetEvent(): void;
24
24
  protected sendProxyEvent(proxyEvent: ProxyEvent): void;
@@ -1,9 +1,16 @@
1
- import { A as AlgIndexer, T as Timestamp, D as Duration, b as PuzzleAppearance } from '../TwizzleLink-cd0fa192.js';
2
- export { A as AlgIndexer, B as BackViewLayout, N as EXPERIMENTAL_PROP_NO_VALUE, M as ExperimentalMillisecondTimestamp, E as ExperimentalStickering, P as PuzzleID, e as TwistyAlgEditor, d as TwistyAlgViewer, c as TwistyPlayer, f as TwistyPlayerConfig, i as TwizzleLink, V as VisualizationFormat, h as backViewLayouts, j as experimentalDebugShowRenderStats, g as experimentalForceNewRendererSharing } from '../TwizzleLink-cd0fa192.js';
3
- import { a as Alg, M as Move } from '../Alg-e2a80975.js';
4
- import { a as KPuzzle, K as KState, e as KTransformation } from '../KState-a2f0e651.js';
1
+ import { A as AlgIndexer, T as Timestamp, D as Duration, b as PuzzleAppearance } from '../TwizzleLink-bef52ecd.js';
2
+ export { A as AlgIndexer, B as BackViewLayout, N as EXPERIMENTAL_PROP_NO_VALUE, M as ExperimentalMillisecondTimestamp, E as ExperimentalStickering, P as PuzzleID, e as TwistyAlgEditor, d as TwistyAlgViewer, c as TwistyPlayer, f as TwistyPlayerConfig, h as TwizzleLink, V as VisualizationFormat, g as backViewLayouts } from '../TwizzleLink-bef52ecd.js';
3
+ import { a as Alg, M as Move } from '../Alg-137fb0d5.js';
4
+ import { a as KPuzzle, K as KState, e as KTransformation } from '../KState-a73111d7.js';
5
5
  import 'three';
6
- import '../parse-ec97687c.js';
6
+ import '../parseAlg-a28f7568.js';
7
+
8
+ declare const twistyDebugGlobals: {
9
+ animateRaiseHintFacelets: boolean;
10
+ shareAllNewRenderers: "auto" | "always" | "never";
11
+ showRenderStats: boolean;
12
+ };
13
+ declare function setTwistyDebug(options: Partial<typeof twistyDebugGlobals>): void;
7
14
 
8
15
  declare class SimpleAlgIndexer implements AlgIndexer {
9
16
  private kpuzzle;
@@ -52,4 +59,4 @@ declare class KPuzzleSVGWrapper {
52
59
  private elementByID;
53
60
  }
54
61
 
55
- export { KPuzzleSVGWrapper as ExperimentalKPuzzleSVGWrapper, SimpleAlgIndexer, TreeAlgIndexer };
62
+ export { KPuzzleSVGWrapper as ExperimentalKPuzzleSVGWrapper, SimpleAlgIndexer, TreeAlgIndexer, setTwistyDebug };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cubing",
3
- "version": "0.28.0",
3
+ "version": "0.28.4",
4
4
  "description": "A collection of JavaScript cubing libraries.",
5
5
  "author": "The js.cubing.net team",
6
6
  "type": "module",
@@ -53,35 +53,36 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@types/three": "^0.141.0",
57
- "@types/web-bluetooth": "^0.0.14",
56
+ "@types/three": "^0.143.0",
57
+ "@types/web-bluetooth": "^0.0.15",
58
58
  "comlink": "^4.3.1",
59
- "jest-environment-jsdom": "^28.1.3",
60
- "three": "^0.142.0"
59
+ "three": "^0.143.0"
61
60
  },
62
61
  "devDependencies": {
63
62
  "@babel/eslint-parser": "^7.18.9",
64
- "@babel/preset-env": "^7.18.9",
63
+ "@babel/preset-env": "^7.18.10",
65
64
  "@babel/preset-typescript": "^7.18.6",
65
+ "@esm-bundle/chai": "^4.3.4-fix.0",
66
+ "@types/chai": "^4.3.3",
66
67
  "@types/dom-speech-recognition": "^0.0.1",
67
- "@types/jest": "^28.1.6",
68
- "@types/node": "^18.0.6",
69
- "@typescript-eslint/eslint-plugin": "^5.30.7",
70
- "@typescript-eslint/parser": "^5.30.7",
71
- "babel-jest": "^28.1.3",
72
- "barely-a-dev-server": "^0.2.6",
73
- "esbuild": "^0.14.49",
74
- "eslint": "^8.20.0",
68
+ "@types/node": "^18.7.2",
69
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
70
+ "@typescript-eslint/parser": "^5.33.0",
71
+ "@web/dev-server-esbuild": "^0.3.2",
72
+ "@web/test-runner": "^0.14.0",
73
+ "barely-a-dev-server": "^0.3.4",
74
+ "chai": "^4.3.6",
75
+ "esbuild": "^0.15.3",
76
+ "eslint": "^8.21.0",
75
77
  "eslint-config-prettier": "^8.5.0",
76
- "eslint-plugin-html": "^7.0.0",
78
+ "eslint-plugin-html": "^7.1.0",
77
79
  "eslint-plugin-prettier": "^4.2.1",
78
- "jest": "^28.1.3",
79
- "jszip": "^3.10.0",
80
+ "jszip": "^3.10.1",
80
81
  "peggy": "^2.0.1",
81
82
  "prettier": "^2.7.1",
82
- "puppeteer": "^15.4.0",
83
- "tsup": "^6.1.3",
84
- "typedoc": "^0.23.8",
83
+ "puppeteer": "^16.1.0",
84
+ "tsup": "^6.2.2",
85
+ "typedoc": "^0.23.10",
85
86
  "typescript": "^4.7.4",
86
87
  "yargs": "^17.5.1"
87
88
  },
@@ -91,7 +92,7 @@
91
92
  "jszip"
92
93
  ],
93
94
  "engines": {
94
- "node": "^14.18 || ^16.13 || >=18"
95
+ "node": "^16.13 || >=18"
95
96
  },
96
97
  "files": [
97
98
  "/LICENSE.md",
@@ -117,24 +118,33 @@
117
118
  "generate-js": "npm run generate-js-parsers && npm run generate-js-svg",
118
119
  "generate-js-parsers": "npx peggy --format es src/cubing/kpuzzle/parser/parser-peggy.peggy",
119
120
  "generate-js-svg": "echo \"TODO: Generating JS for SVGs is not implemented yet.\"",
120
- "dev": "npm run initial-setup && node ./script/build/main.js sites dev",
121
+ "dev": "npm run quick-setup && node ./script/build/main.js sites dev",
121
122
  "link": "npm run build && npm link",
122
123
  "clean": "rm -rf dist .temp coverage src/cubing/search/search-worker-inside-generated* ./alg ./bluetooth ./kpuzzle ./notation ./protocol ./puzzle-geometry ./puzzles ./scramble ./search ./stream ./twisty",
123
- "test": "npm run test-jest && npm run lint && npm run test-import-restrictions && npm run test-tsc # keep test.yml in sync with this",
124
+ "test": "echo \"Run one of the following.\n(Time estimates are based on a fast computer.)\n\n make test-spec (≈4s, \\`*.spec.ts\\` files only)\n\n make test-src (≈30s, includes \\`make test-spec\\`)\n make test-build (≈10s)\n make test-dist (≈30s)\n\n make test-all (≈70s, runs all of the above)\n make test-fast (≈6s, runs a subset of the above)\n\"",
125
+ "test-fast": "npm run build-esm && npm run build-sites && npm run build-bin && npm run test-spec",
126
+ "test-all": "npm run test-src && npm run test-build && npm run test-dist",
127
+ "test-src": "npm run test-spec && npm run lint && npm run test-src-tsc && npm run test-src-internal-import-restrictions && npm run test-src-does-not-import-dist # keep CI.yml in sync with this",
128
+ "test-spec": "npx web-test-runner",
129
+ "test-spec-watch": "npx web-test-runner --watch",
130
+ "test-src-internal-import-restrictions": "node ./script/test/src/internal-import-restrictions/main.js",
131
+ "test-src-does-not-import-dist": "node ./script/test/src/does-not-import-dist/main.js",
132
+ "test-src-tsc": "npm run build-types && npx tsc --project ./tsconfig.json",
133
+ "test-build": "npm run build-esm && npm run build-bin && npm run build-bundle-global && npm run build-types && npm run build-sites && npm run build-site-typedoc # keep CI.yml in sync with this",
134
+ "test-dist": "npm run build-esm && npm run test-dist-esm-node-import && npm run test-dist-esm-scramble-all-events && npm run test-dist-esm-perf && npm run test-dist-esm-plain-esbuild-compat && npm run test-dist-esm-parcel && npm run test-dist-esm-vite && npm run test-dist-sites-experiments && npm run build-sites && npm run test-dist-sites-experiments # keep CI.yml in sync with this",
124
135
  "test-dist-esm-node-import": "node script/test/dist/esm/node-import/main.mjs",
125
- "test-dist-esm-parcel": "node ./script/test/dist/esm/parcel/main.js",
136
+ "test-dist-esm-scramble-all-events": "node script/test/dist/esm/scramble-all-events/main.mjs",
126
137
  "test-dist-esm-perf": "node script/test/dist/esm/perf/*.mjs",
127
- "test-dist-experiments": "node ./script/test/dist/experiments/main.js",
128
- "test-dist-not-imported-from-src": "node ./script/test/dist/not-imported-from-src/main.js",
129
- "test-import-restrictions": "node ./script/test/import-restrictions/main.js",
130
- "test-jest": "npx jest --collectCoverage",
131
- "test-tsc": "npm run build-types && npx tsc --project ./tsconfig.json",
138
+ "test-dist-esm-plain-esbuild-compat": "node script/test/dist/esm/plain-esbuild-compat/main.js",
139
+ "test-dist-esm-parcel": "node ./script/test/dist/esm/parcel/main.js",
140
+ "test-dist-esm-vite": "node ./script/test/dist/esm/vite/main.js",
141
+ "test-dist-sites-experiments": "node ./script/test/dist/experiments/main.js",
132
142
  "format": "npx eslint --fix --ext=js,ts src script; npx prettier --write src script",
133
- "setup": "npm install",
134
- "initial-setup": "node ./script/initial-setup/main.js",
143
+ "setup": "npm ci",
144
+ "quick-setup": "node ./script/quick-setup/main.js",
135
145
  "lint": "npx eslint --ext=js,ts src script",
136
- "prepack": "npm run clean && npm run build && npm run test-dist-esm-node-import",
137
- "postpublish": "echo -e '\n\nConsider updating `cdn.cubing.net` if you have access:\nhttps://github.com/cubing/cdn.cubing.net/blob/main/docs/maintenance.md#updating-cdncubingnet-to-a-new-cubing-version\n'"
146
+ "prepack": "npm run clean && npm run build && npm run test-dist-esm-node-import && npm run test-dist-esm-plain-esbuild-compat",
147
+ "postpublish": "echo -e '\n\nConsider updating \\`cdn.cubing.net\\` if you have access:\nhttps://github.com/cubing/cdn.cubing.net/blob/main/docs/maintenance.md#updating-cdncubingnet-to-a-new-cubing-version\n'"
138
148
  },
139
149
  "keywords": [
140
150
  "cubing",
@@ -238,12 +248,5 @@
238
248
  ],
239
249
  "@babel/preset-typescript"
240
250
  ]
241
- },
242
- "jest": {
243
- "roots": [
244
- "<rootDir>/src",
245
- "<rootDir>/script"
246
- ],
247
- "coverageDirectory": "<rootDir>/.temp/coverage"
248
251
  }
249
252
  }
@@ -1,342 +0,0 @@
1
- import {
2
- from
3
- } from "./chunk-GVPTO3OF.js";
4
- import {
5
- __privateAdd,
6
- __privateGet,
7
- __privateMethod,
8
- __privateSet,
9
- __privateWrapper
10
- } from "./chunk-MGJA5U5O.js";
11
-
12
- // src/cubing/twisty/model/PromiseFreshener.ts
13
- var _latestAssignedIdx, _latestResolvedIdx;
14
- var PromiseFreshener = class {
15
- constructor() {
16
- __privateAdd(this, _latestAssignedIdx, 0);
17
- __privateAdd(this, _latestResolvedIdx, 0);
18
- }
19
- async queue(p) {
20
- const idx = ++__privateWrapper(this, _latestAssignedIdx)._;
21
- const result = await p;
22
- if (idx > __privateGet(this, _latestResolvedIdx)) {
23
- __privateSet(this, _latestResolvedIdx, idx);
24
- return {
25
- fresh: true,
26
- result
27
- };
28
- } else {
29
- return { fresh: false };
30
- }
31
- }
32
- };
33
- _latestAssignedIdx = new WeakMap();
34
- _latestResolvedIdx = new WeakMap();
35
- var _latestAssignedIdx2, _latestResolvedIdx2;
36
- var StaleDropper = class {
37
- constructor() {
38
- __privateAdd(this, _latestAssignedIdx2, 0);
39
- __privateAdd(this, _latestResolvedIdx2, 0);
40
- }
41
- queue(p) {
42
- return new Promise(async (resolve, reject) => {
43
- try {
44
- const idx = ++__privateWrapper(this, _latestAssignedIdx2)._;
45
- const result = await p;
46
- if (idx > __privateGet(this, _latestResolvedIdx2)) {
47
- __privateSet(this, _latestResolvedIdx2, idx);
48
- resolve(result);
49
- }
50
- } catch (e) {
51
- reject(e);
52
- }
53
- });
54
- }
55
- };
56
- _latestAssignedIdx2 = new WeakMap();
57
- _latestResolvedIdx2 = new WeakMap();
58
-
59
- // src/cubing/twisty/model/props/TwistyProp.ts
60
- var globalSourceGeneration = 0;
61
- var _children, _rawListeners, _scheduleRawDispatch, scheduleRawDispatch_fn, _rawDispatchPending, _dispatchRawListeners, dispatchRawListeners_fn, _freshListeners;
62
- var TwistyPropParent = class {
63
- constructor() {
64
- __privateAdd(this, _scheduleRawDispatch);
65
- __privateAdd(this, _dispatchRawListeners);
66
- __privateAdd(this, _children, /* @__PURE__ */ new Set());
67
- this.lastSourceGeneration = 0;
68
- __privateAdd(this, _rawListeners, /* @__PURE__ */ new Set());
69
- __privateAdd(this, _rawDispatchPending, false);
70
- __privateAdd(this, _freshListeners, /* @__PURE__ */ new Map());
71
- }
72
- canReuse(v1, v2) {
73
- return v1 === v2 || this.canReuseValue(v1, v2);
74
- }
75
- canReuseValue(_v1, _v2) {
76
- return false;
77
- }
78
- debugGetChildren() {
79
- return Array.from(__privateGet(this, _children).values());
80
- }
81
- addChild(child) {
82
- __privateGet(this, _children).add(child);
83
- }
84
- removeChild(child) {
85
- __privateGet(this, _children).delete(child);
86
- }
87
- markStale(sourceEvent) {
88
- if (sourceEvent.detail.generation !== globalSourceGeneration) {
89
- throw new Error("A TwistyProp was marked stale too late!");
90
- }
91
- if (this.lastSourceGeneration === sourceEvent.detail.generation) {
92
- return;
93
- }
94
- this.lastSourceGeneration = sourceEvent.detail.generation;
95
- for (const child of __privateGet(this, _children)) {
96
- child.markStale(sourceEvent);
97
- }
98
- __privateMethod(this, _scheduleRawDispatch, scheduleRawDispatch_fn).call(this);
99
- }
100
- addRawListener(listener, options) {
101
- __privateGet(this, _rawListeners).add(listener);
102
- if (options?.initial) {
103
- listener();
104
- }
105
- }
106
- removeRawListener(listener) {
107
- __privateGet(this, _rawListeners).delete(listener);
108
- }
109
- addFreshListener(listener) {
110
- const staleDropper = new StaleDropper();
111
- let lastResult = null;
112
- const callback = async () => {
113
- const result = await staleDropper.queue(this.get());
114
- if (lastResult !== null && this.canReuse(lastResult, result)) {
115
- return;
116
- }
117
- lastResult = result;
118
- listener(result);
119
- };
120
- __privateGet(this, _freshListeners).set(listener, callback);
121
- this.addRawListener(callback, { initial: true });
122
- }
123
- removeFreshListener(listener) {
124
- this.removeRawListener(__privateGet(this, _freshListeners).get(listener));
125
- __privateGet(this, _freshListeners).delete(listener);
126
- }
127
- };
128
- _children = new WeakMap();
129
- _rawListeners = new WeakMap();
130
- _scheduleRawDispatch = new WeakSet();
131
- scheduleRawDispatch_fn = function() {
132
- if (!__privateGet(this, _rawDispatchPending)) {
133
- __privateSet(this, _rawDispatchPending, true);
134
- setTimeout(() => __privateMethod(this, _dispatchRawListeners, dispatchRawListeners_fn).call(this), 0);
135
- }
136
- };
137
- _rawDispatchPending = new WeakMap();
138
- _dispatchRawListeners = new WeakSet();
139
- dispatchRawListeners_fn = function() {
140
- if (!__privateGet(this, _rawDispatchPending)) {
141
- throw new Error("Invalid dispatch state!");
142
- }
143
- for (const listener of __privateGet(this, _rawListeners)) {
144
- listener();
145
- }
146
- __privateSet(this, _rawDispatchPending, false);
147
- };
148
- _freshListeners = new WeakMap();
149
- var _value;
150
- var TwistyPropSource = class extends TwistyPropParent {
151
- constructor(initialValue) {
152
- super();
153
- __privateAdd(this, _value, void 0);
154
- __privateSet(this, _value, from(() => this.getDefaultValue()));
155
- if (initialValue) {
156
- __privateSet(this, _value, this.deriveFromPromiseOrValue(initialValue, __privateGet(this, _value)));
157
- }
158
- }
159
- set(input) {
160
- __privateSet(this, _value, this.deriveFromPromiseOrValue(input, __privateGet(this, _value)));
161
- const sourceEventDetail = {
162
- sourceProp: this,
163
- value: __privateGet(this, _value),
164
- generation: ++globalSourceGeneration
165
- };
166
- this.markStale(new CustomEvent("stale", {
167
- detail: sourceEventDetail
168
- }));
169
- }
170
- async get() {
171
- return __privateGet(this, _value);
172
- }
173
- async deriveFromPromiseOrValue(input, oldValuePromise) {
174
- return this.derive(await input, oldValuePromise);
175
- }
176
- };
177
- _value = new WeakMap();
178
- var SimpleTwistyPropSource = class extends TwistyPropSource {
179
- derive(input) {
180
- return input;
181
- }
182
- };
183
- var NO_VALUE = Symbol("no value");
184
- var _parents, _cachedLastSuccessfulCalculation, _cachedLatestGenerationCalculation, _getParents, getParents_fn, _cacheDerive, cacheDerive_fn;
185
- var TwistyPropDerived = class extends TwistyPropParent {
186
- constructor(parents, userVisibleErrorTracker) {
187
- super();
188
- this.userVisibleErrorTracker = userVisibleErrorTracker;
189
- __privateAdd(this, _getParents);
190
- __privateAdd(this, _cacheDerive);
191
- __privateAdd(this, _parents, void 0);
192
- __privateAdd(this, _cachedLastSuccessfulCalculation, null);
193
- __privateAdd(this, _cachedLatestGenerationCalculation, null);
194
- __privateSet(this, _parents, parents);
195
- for (const parent of Object.values(parents)) {
196
- parent.addChild(this);
197
- }
198
- }
199
- async get() {
200
- const generation = this.lastSourceGeneration;
201
- if (__privateGet(this, _cachedLatestGenerationCalculation)?.generation === generation) {
202
- return __privateGet(this, _cachedLatestGenerationCalculation).output;
203
- }
204
- const latestGenerationCalculation = {
205
- generation,
206
- output: __privateMethod(this, _cacheDerive, cacheDerive_fn).call(this, __privateMethod(this, _getParents, getParents_fn).call(this), generation, __privateGet(this, _cachedLastSuccessfulCalculation))
207
- };
208
- __privateSet(this, _cachedLatestGenerationCalculation, latestGenerationCalculation);
209
- this.userVisibleErrorTracker?.reset();
210
- return latestGenerationCalculation.output;
211
- }
212
- };
213
- _parents = new WeakMap();
214
- _cachedLastSuccessfulCalculation = new WeakMap();
215
- _cachedLatestGenerationCalculation = new WeakMap();
216
- _getParents = new WeakSet();
217
- getParents_fn = async function() {
218
- const inputValuePromises = {};
219
- for (const [key, parent] of Object.entries(__privateGet(this, _parents))) {
220
- inputValuePromises[key] = parent.get();
221
- }
222
- const inputs = {};
223
- for (const key in __privateGet(this, _parents)) {
224
- inputs[key] = await inputValuePromises[key];
225
- }
226
- return inputs;
227
- };
228
- _cacheDerive = new WeakSet();
229
- cacheDerive_fn = async function(inputsPromise, generation, cachedLatestGenerationCalculation = null) {
230
- const inputs = await inputsPromise;
231
- const cache = (output) => {
232
- __privateSet(this, _cachedLastSuccessfulCalculation, {
233
- inputs,
234
- output: Promise.resolve(output),
235
- generation
236
- });
237
- return output;
238
- };
239
- if (!cachedLatestGenerationCalculation) {
240
- return cache(await this.derive(inputs));
241
- }
242
- const cachedInputs = cachedLatestGenerationCalculation.inputs;
243
- for (const key in __privateGet(this, _parents)) {
244
- const parent = __privateGet(this, _parents)[key];
245
- if (!parent.canReuse(inputs[key], cachedInputs[key])) {
246
- return cache(await this.derive(inputs));
247
- }
248
- }
249
- return cachedLatestGenerationCalculation.output;
250
- };
251
- var _disconnectionFunctions;
252
- var FreshListenerManager = class {
253
- constructor() {
254
- __privateAdd(this, _disconnectionFunctions, []);
255
- }
256
- addListener(prop, listener) {
257
- let disconnected = false;
258
- const wrappedListener = (value) => {
259
- if (disconnected) {
260
- return;
261
- }
262
- listener(value);
263
- };
264
- prop.addFreshListener(wrappedListener);
265
- __privateGet(this, _disconnectionFunctions).push(() => {
266
- prop.removeFreshListener(wrappedListener);
267
- disconnected = true;
268
- });
269
- }
270
- addMultiListener3(props, listener) {
271
- this.addMultiListener(props, listener);
272
- }
273
- addMultiListener(props, listener) {
274
- let disconnected = false;
275
- let initialIgnoresLeft = props.length - 1;
276
- const wrappedListener = async (_) => {
277
- if (initialIgnoresLeft > 0) {
278
- initialIgnoresLeft--;
279
- return;
280
- }
281
- if (disconnected) {
282
- return;
283
- }
284
- const promises = props.map((prop) => prop.get());
285
- const values = await Promise.all(promises);
286
- listener(values);
287
- };
288
- for (const prop of props) {
289
- prop.addFreshListener(wrappedListener);
290
- }
291
- __privateGet(this, _disconnectionFunctions).push(() => {
292
- for (const prop of props) {
293
- prop.removeFreshListener(wrappedListener);
294
- }
295
- disconnected = true;
296
- });
297
- }
298
- disconnect() {
299
- for (const disconnectionFunction of __privateGet(this, _disconnectionFunctions)) {
300
- disconnectionFunction();
301
- }
302
- }
303
- };
304
- _disconnectionFunctions = new WeakMap();
305
-
306
- // src/cubing/twisty/model/props/puzzle/display/HintFaceletProp.ts
307
- var hintFaceletStyles = {
308
- floating: true,
309
- none: true
310
- };
311
- var HintFaceletProp = class extends SimpleTwistyPropSource {
312
- getDefaultValue() {
313
- return "auto";
314
- }
315
- };
316
-
317
- // src/cubing/twisty/views/3D/TAU.ts
318
- var TAU = Math.PI * 2;
319
- var DEGREES_PER_RADIAN = 360 / TAU;
320
-
321
- // src/cubing/twisty/heavy-code-imports/3d.ts
322
- var cachedConstructorProxy = null;
323
- async function proxy3D() {
324
- return cachedConstructorProxy ?? (cachedConstructorProxy = import("./twisty-dynamic-3d-UQJETF7O.js"));
325
- }
326
- var THREEJS = from(async () => (await proxy3D()).T3I);
327
-
328
- export {
329
- StaleDropper,
330
- TwistyPropSource,
331
- SimpleTwistyPropSource,
332
- NO_VALUE,
333
- TwistyPropDerived,
334
- FreshListenerManager,
335
- hintFaceletStyles,
336
- HintFaceletProp,
337
- TAU,
338
- DEGREES_PER_RADIAN,
339
- proxy3D,
340
- THREEJS
341
- };
342
- //# sourceMappingURL=chunk-7BLWQDZX.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/cubing/twisty/model/PromiseFreshener.ts", "../../src/cubing/twisty/model/props/TwistyProp.ts", "../../src/cubing/twisty/model/props/puzzle/display/HintFaceletProp.ts", "../../src/cubing/twisty/views/3D/TAU.ts", "../../src/cubing/twisty/heavy-code-imports/3d.ts"],
4
- "sourcesContent": ["// TODO: Pick a much better name.\nexport class PromiseFreshener<T> {\n #latestAssignedIdx = 0;\n #latestResolvedIdx = 0;\n\n // TODO: reject instead? Drop?\n async queue(\n p: Promise<T>,\n ): Promise<{ fresh: false } | { fresh: true; result: T }> {\n const idx = ++this.#latestAssignedIdx;\n const result = await p;\n if (idx > this.#latestResolvedIdx) {\n this.#latestResolvedIdx = idx;\n return {\n fresh: true,\n result: result,\n };\n } else {\n return { fresh: false };\n }\n }\n}\n\n// This will silenty drop a queued Promise (i.e. not resolve it) if a\n// newer queued one already resolved first. This is useful for classes that want\n// to know the \"latest\" state of something without jumping back to an older\n// value by accident.\n// TODO: Remove this because it's too easy to misuse?\nexport class StaleDropper<T> {\n #latestAssignedIdx = 0;\n #latestResolvedIdx = 0;\n\n queue(p: Promise<T>): Promise<T> {\n // This is a very rare case where we *do* want to drop a Promise sometimes.\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n try {\n const idx = ++this.#latestAssignedIdx;\n const result = await p;\n if (idx > this.#latestResolvedIdx) {\n this.#latestResolvedIdx = idx;\n resolve(result);\n }\n } catch (e) {\n reject(e);\n }\n });\n }\n}\n", "import { from } from \"../../../vendor/p-lazy/p-lazy\";\nimport { StaleDropper } from \"../PromiseFreshener\";\nimport type { UserVisibleErrorTracker } from \"../UserVisibleErrorTracker\";\n\n/*eslint @typescript-eslint/ban-types:off */\ntype InputRecord = {};\n\nexport type InputProps<T extends InputRecord> = {\n [s in keyof T]: TwistyPropParent<T[s]>;\n};\n\ntype InputPromises<T extends InputRecord> = {\n [s in keyof T]: Promise<T[s]>;\n};\n\ninterface SourceEventDetail<OutputType> {\n sourceProp: TwistyPropSource<OutputType, any>;\n value: Promise<OutputType>; // TODO: remove?\n generation: number;\n}\n\ntype SourceEvent<T> = CustomEvent<SourceEventDetail<T>>;\n\ntype PromiseOrValue<T> = T | Promise<T>;\n\n// Values of T must be immutable.\nlet globalSourceGeneration = 0; // This is incremented before being used, so 1 will be the first active value.\nexport abstract class TwistyPropParent<T> {\n public abstract get(): Promise<T>;\n\n // Don't overwrite this. Overwrite `canReuseValue` instead.\n canReuse(v1: T, v2: T): boolean {\n return v1 === v2 || this.canReuseValue(v1, v2);\n }\n\n // Overwrite with a cheap semantic comparison when possible.\n // Note that this is not called if `v1 === v2` (in which case the value is automatically reused).\n canReuseValue(_v1: T, _v2: T): boolean {\n return false;\n }\n\n debugGetChildren(): Array<TwistyPropDerived<any, any>> {\n return Array.from(this.#children.values());\n }\n\n // Propagation\n\n #children: Set<TwistyPropDerived<any, any>> = new Set();\n protected addChild(child: TwistyPropDerived<any, any>): void {\n this.#children.add(child);\n }\n\n protected removeChild(child: TwistyPropDerived<any, any>): void {\n this.#children.delete(child);\n }\n\n protected lastSourceGeneration: number = 0;\n // Synchronously marks all descendants as stale. This doesn't actually\n // literally mark as stale, but it updates the last source generation, which\n // is used to tell if a cahced result is stale.\n protected markStale(sourceEvent: SourceEvent<any>): void {\n if (sourceEvent.detail.generation !== globalSourceGeneration) {\n // The full stale propagation is synchronous, so there should not be a new one yet.\n throw new Error(\"A TwistyProp was marked stale too late!\");\n }\n if (this.lastSourceGeneration === sourceEvent.detail.generation) {\n // Already propagated.\n return;\n }\n this.lastSourceGeneration = sourceEvent.detail.generation;\n for (const child of this.#children) {\n child.markStale(sourceEvent);\n }\n // We schedule sending out events *after* the (synchronous) propagation has happened, in\n // case one of the listeners updates a source again.\n this.#scheduleRawDispatch();\n }\n\n #rawListeners: Set<() => void> = new Set();\n /** @deprecated */\n addRawListener(listener: () => void, options?: { initial: boolean }): void {\n this.#rawListeners.add(listener);\n if (options?.initial) {\n listener(); // TODO: wrap in a try?\n }\n }\n\n /** @deprecated */\n removeRawListener(listener: () => void): void {\n this.#rawListeners.delete(listener);\n }\n\n /** @deprecated */\n #scheduleRawDispatch(): void {\n if (!this.#rawDispatchPending) {\n this.#rawDispatchPending = true;\n setTimeout(() => this.#dispatchRawListeners(), 0);\n }\n }\n\n #rawDispatchPending: boolean = false;\n #dispatchRawListeners(): void {\n if (!this.#rawDispatchPending) {\n throw new Error(\"Invalid dispatch state!\");\n }\n for (const listener of this.#rawListeners) {\n listener(); // TODO: wrap in a try?\n }\n this.#rawDispatchPending = false;\n }\n\n #freshListeners: Map<(value: T) => void, () => void> = new Map();\n // TODO: Pick a better name.\n addFreshListener(listener: (value: T) => void): void {\n const staleDropper: StaleDropper<T> = new StaleDropper<T>();\n let lastResult: T | null = null;\n const callback = async () => {\n const result = await staleDropper.queue(this.get());\n if (lastResult !== null && this.canReuse(lastResult, result)) {\n return;\n }\n lastResult = result;\n listener(result);\n };\n this.#freshListeners.set(listener, callback);\n this.addRawListener(callback, { initial: true });\n }\n\n removeFreshListener(listener: (value: T) => void): void {\n this.removeRawListener(this.#freshListeners.get(listener)!); // TODO: throw a custom error?\n this.#freshListeners.delete(listener);\n }\n}\n\nexport abstract class TwistyPropSource<\n OutputType,\n InputType = OutputType,\n> extends TwistyPropParent<OutputType> {\n #value: Promise<OutputType>;\n\n public abstract getDefaultValue(): PromiseOrValue<OutputType>;\n\n constructor(initialValue?: PromiseOrValue<InputType>) {\n super();\n this.#value = from(() => this.getDefaultValue());\n if (initialValue) {\n this.#value = this.deriveFromPromiseOrValue(initialValue, this.#value);\n }\n }\n\n set(input: PromiseOrValue<InputType>): void {\n this.#value = this.deriveFromPromiseOrValue(input, this.#value);\n\n const sourceEventDetail: SourceEventDetail<OutputType> = {\n sourceProp: this,\n value: this.#value,\n generation: ++globalSourceGeneration,\n };\n this.markStale(\n new CustomEvent<SourceEventDetail<OutputType>>(\"stale\", {\n detail: sourceEventDetail,\n }),\n );\n }\n\n async get(): Promise<OutputType> {\n return this.#value;\n }\n\n async deriveFromPromiseOrValue(\n input: PromiseOrValue<InputType>,\n oldValuePromise: Promise<OutputType>,\n ): Promise<OutputType> {\n return this.derive(await input, oldValuePromise);\n }\n\n // TODO: add an indirect layer to cache the derivation?\n protected abstract derive(\n input: InputType,\n oldValuePromise: Promise<OutputType>,\n ): PromiseOrValue<OutputType>;\n}\n\nexport abstract class SimpleTwistyPropSource<\n SimpleType,\n> extends TwistyPropSource<SimpleType> {\n derive(input: SimpleType): PromiseOrValue<SimpleType> {\n return input;\n }\n}\n\n// TODO: Can we support `null` as a valid output value without loosening type\n// safety?\nexport const NO_VALUE = Symbol(\"no value\");\nexport type NoValueType = typeof NO_VALUE;\n\nexport abstract class TwistyPropDerived<\n InputTypes extends InputRecord,\n OutputType,\n> extends TwistyPropParent<OutputType> {\n // cachedInputs:\n #parents: InputProps<InputTypes>;\n\n constructor(\n parents: InputProps<InputTypes>,\n protected userVisibleErrorTracker?: UserVisibleErrorTracker,\n ) {\n super();\n this.#parents = parents;\n for (const parent of Object.values(parents)) {\n (\n parent as TwistyPropDerived<InputProps<InputTypes>, OutputType>\n ).addChild(this);\n }\n }\n\n #cachedLastSuccessfulCalculation: {\n inputs: InputTypes;\n output: Promise<OutputType>;\n generation: number;\n } | null = null;\n\n #cachedLatestGenerationCalculation: {\n output: Promise<OutputType>;\n generation: number;\n } | null = null;\n\n public async get(): Promise<OutputType> {\n const generation = this.lastSourceGeneration;\n\n if (this.#cachedLatestGenerationCalculation?.generation === generation) {\n return this.#cachedLatestGenerationCalculation.output;\n }\n\n const latestGenerationCalculation = {\n generation,\n output: this.#cacheDerive(\n this.#getParents(),\n generation,\n this.#cachedLastSuccessfulCalculation,\n ),\n };\n this.#cachedLatestGenerationCalculation = latestGenerationCalculation;\n\n this.userVisibleErrorTracker?.reset();\n return latestGenerationCalculation.output;\n }\n\n async #getParents(): Promise<InputTypes> {\n const inputValuePromises: InputPromises<InputRecord> = {} as any; // TODO\n for (const [key, parent] of Object.entries(this.#parents)) {\n (inputValuePromises as Record<string, Promise<unknown>>)[key] = (\n parent as TwistyPropParent<unknown>\n ).get();\n }\n\n const inputs: InputTypes = {} as any; // TODO\n for (const key in this.#parents) {\n inputs[key] = (await (\n inputValuePromises as Record<string, Promise<unknown>>\n )[key]) as any;\n }\n return inputs;\n }\n\n async #cacheDerive(\n inputsPromise: PromiseOrValue<InputTypes>,\n generation: number,\n cachedLatestGenerationCalculation: {\n inputs: InputTypes;\n output: Promise<OutputType>;\n generation: number;\n } | null = null,\n ): Promise<OutputType> {\n const inputs = await inputsPromise;\n\n const cache = (output: OutputType): OutputType => {\n this.#cachedLastSuccessfulCalculation = {\n inputs,\n output: Promise.resolve(output),\n generation,\n };\n return output;\n };\n\n if (!cachedLatestGenerationCalculation) {\n return cache(await this.derive(inputs));\n }\n\n const cachedInputs = cachedLatestGenerationCalculation.inputs;\n for (const key in this.#parents) {\n const parent = this.#parents[key];\n if (!parent.canReuse(inputs[key], cachedInputs[key])) {\n return cache(await this.derive(inputs));\n }\n }\n\n return cachedLatestGenerationCalculation.output;\n }\n\n protected abstract derive(input: InputTypes): PromiseOrValue<OutputType>;\n}\n\nexport class FreshListenerManager {\n #disconnectionFunctions: (() => void)[] = [];\n\n addListener<T>(\n prop: TwistyPropParent<T>,\n listener: (value: T) => void,\n ): void {\n let disconnected = false;\n const wrappedListener = (value: T) => {\n if (disconnected) {\n // TODO\n // console.warn(\"Should be disconnected!\");\n return;\n }\n listener(value);\n };\n\n prop.addFreshListener(wrappedListener);\n\n this.#disconnectionFunctions.push(() => {\n prop.removeFreshListener(wrappedListener);\n disconnected = true;\n });\n }\n\n // TODO: Figure out the signature to let us do overloads\n /** @deprecated */\n addMultiListener3<U, V, W>(\n props: [TwistyPropParent<U>, TwistyPropParent<V>, TwistyPropParent<W>],\n listener: (values: [U, V, W]) => void,\n ): void {\n this.addMultiListener(props as any, listener as any); // TODO\n }\n addMultiListener<U, V>(\n props: [TwistyPropParent<U>, TwistyPropParent<V>],\n listener: (values: [U, V]) => void,\n ) {\n let disconnected = false;\n\n // We're going to get one initial call per prop. We'll ignore all but one.\n let initialIgnoresLeft = props.length - 1;\n const wrappedListener = async (_: any) => {\n if (initialIgnoresLeft > 0) {\n initialIgnoresLeft--;\n return;\n }\n if (disconnected) {\n // TODO\n // console.warn(\"Should be disconnected!\");\n return;\n }\n // We rely on `TwistyProp` caching to give us the full set of latest\n // values efficiently.\n const promises = (props as TwistyPropParent<any>[]).map((prop) =>\n prop.get(),\n );\n const values = await Promise.all(promises);\n listener(values as any); // TODO: fix up types\n };\n\n for (const prop of props) {\n prop.addFreshListener(wrappedListener);\n }\n\n this.#disconnectionFunctions.push(() => {\n for (const prop of props) {\n prop.removeFreshListener(wrappedListener);\n }\n disconnected = true;\n });\n }\n\n disconnect(): void {\n for (const disconnectionFunction of this.#disconnectionFunctions) {\n disconnectionFunction();\n }\n }\n}\n", "import { SimpleTwistyPropSource } from \"../../TwistyProp\";\n\n// TODO: turn these maps into lists?\nexport const hintFaceletStyles = {\n floating: true, // default\n none: true,\n};\nexport type HintFaceletStyle = keyof typeof hintFaceletStyles;\nexport type HintFaceletStyleWithAuto = HintFaceletStyle | \"auto\";\n\nexport class HintFaceletProp extends SimpleTwistyPropSource<HintFaceletStyleWithAuto> {\n getDefaultValue(): HintFaceletStyleWithAuto {\n return \"auto\";\n }\n}\n", "export const TAU = Math.PI * 2;\nexport const DEGREES_PER_RADIAN = 360 / TAU;\n", "import { from } from \"../../vendor/p-lazy/p-lazy\";\n\n// TODO can we remove the cached proxy?\n\n// In theory we can, but we've run into situations where imports are not properly cached.\nlet cachedConstructorProxy: Promise<\n typeof import(\"./dynamic-entries/twisty-dynamic-3d\")\n> | null = null;\n\nexport async function proxy3D(): Promise<\n typeof import(\"./dynamic-entries/twisty-dynamic-3d\")\n> {\n return (cachedConstructorProxy ??= import(\n \"./dynamic-entries/twisty-dynamic-3d\"\n ));\n}\n\nexport const THREEJS: Promise<typeof import(\"three\")> = from(\n async () => (await proxy3D()).T3I,\n);\n"],
5
- "mappings": ";;;;;;;;;;;;AAAA;AACO,IAAM,mBAAN,MAA0B;AAAA,EAA1B;AACL,2CAAqB;AACrB,2CAAqB;AAAA;AAAA,EAGrB,MAAM,MACJ,GACwD;AACxD,UAAM,MAAa,EAAL,uBAAK,oBAAL;AACd,UAAM,SAAS,MAAM;AACrB,QAAI,MAAM,mBAAK,qBAAoB;AACjC,yBAAK,oBAAqB;AAC1B,aAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO,EAAE,OAAO,MAAM;AAAA,IACxB;AAAA,EACF;AACF;AAnBE;AACA;AAHF;AA4BO,IAAM,eAAN,MAAsB;AAAA,EAAtB;AACL,4CAAqB;AACrB,4CAAqB;AAAA;AAAA,EAErB,MAAM,GAA2B;AAG/B,WAAO,IAAI,QAAQ,OAAO,SAAS,WAAW;AAC5C,UAAI;AACF,cAAM,MAAa,EAAL,uBAAK,qBAAL;AACd,cAAM,SAAS,MAAM;AACrB,YAAI,MAAM,mBAAK,sBAAoB;AACjC,6BAAK,qBAAqB;AAC1B,kBAAQ,MAAM;AAAA,QAChB;AAAA,MACF,SAAS,GAAP;AACA,eAAO,CAAC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