cubing 0.21.3 → 0.22.0

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 (406) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/bin/puzzle-geometry-bin.js +9 -5
  3. package/dist/bin/puzzle-geometry-bin.js.map +2 -2
  4. package/dist/bundle-global/cubing.bundle-global.js +284 -303
  5. package/dist/esm/.DS_Store +0 -0
  6. package/dist/esm/3d-3WQVOHX5.js +21 -0
  7. package/dist/esm/3d-3WQVOHX5.js.map +7 -0
  8. package/dist/esm/alg/index.js +1 -1
  9. package/dist/esm/bluetooth/index.js +3 -3
  10. package/dist/esm/bluetooth/index.js.map +1 -1
  11. package/dist/esm/{chunk-RE7MIN5R.js → chunk-4IUYLRHT.js} +2 -2
  12. package/dist/esm/{chunk-RE7MIN5R.js.map → chunk-4IUYLRHT.js.map} +0 -0
  13. package/dist/esm/{chunk-CSVAFZSB.js → chunk-7KI3I3Y7.js} +5 -5
  14. package/dist/esm/{chunk-CSVAFZSB.js.map → chunk-7KI3I3Y7.js.map} +0 -0
  15. package/dist/esm/{chunk-APIIMJG6.js → chunk-DLN5QS4V.js} +448 -1052
  16. package/dist/esm/chunk-DLN5QS4V.js.map +7 -0
  17. package/dist/esm/{chunk-BU5PUJK3.js → chunk-EWRBHQFX.js} +1 -1
  18. package/dist/esm/{chunk-BU5PUJK3.js.map → chunk-EWRBHQFX.js.map} +1 -1
  19. package/dist/esm/{chunk-MUQMBH2S.js → chunk-HXKINJ7U.js} +3 -3
  20. package/dist/esm/{chunk-MUQMBH2S.js.map → chunk-HXKINJ7U.js.map} +1 -1
  21. package/dist/esm/{chunk-YV3RT5PX.js → chunk-X6JHXPDX.js} +2 -2
  22. package/dist/esm/{chunk-YV3RT5PX.js.map → chunk-X6JHXPDX.js.map} +0 -0
  23. package/dist/esm/kpuzzle/index.js +2 -2
  24. package/dist/esm/notation/index.js +2 -2
  25. package/dist/esm/protocol/index.js +2 -2
  26. package/dist/esm/puzzle-geometry/index.js +10 -6
  27. package/dist/esm/puzzle-geometry/index.js.map +2 -2
  28. package/dist/esm/puzzles/index.js +3 -3
  29. package/dist/esm/scramble/index.js +4 -4
  30. package/dist/esm/search/index.js +4 -4
  31. package/dist/esm/stream/index.js +1 -1
  32. package/dist/esm/twisty/index.js +715 -2341
  33. package/dist/esm/twisty/index.js.map +3 -3
  34. package/dist/esm/{worker-inside-generated-string-KDZOUGJF.js → worker-inside-generated-string-ZA6E6672.js} +21 -21
  35. package/dist/esm/worker-inside-generated-string-ZA6E6672.js.map +7 -0
  36. package/dist/types/alg/index.d.ts +1 -0
  37. package/dist/types/alg/index.d.ts.map +1 -1
  38. package/dist/types/alg/units/leaves/Move.d.ts +1 -1
  39. package/dist/types/alg/units/leaves/Move.d.ts.map +1 -1
  40. package/dist/types/puzzle-geometry/PGPuzzles.spec.d.ts +3 -0
  41. package/dist/types/puzzle-geometry/PGPuzzles.spec.d.ts.map +1 -1
  42. package/dist/types/puzzle-geometry/PuzzleGeometry.d.ts +5 -1
  43. package/dist/types/puzzle-geometry/PuzzleGeometry.d.ts.map +1 -1
  44. package/dist/types/puzzles/index.d.ts +1 -1
  45. package/dist/types/puzzles/index.d.ts.map +1 -1
  46. package/dist/types/search/worker-inside-generated-string.d.ts +1 -1
  47. package/dist/types/search/worker-inside-generated-string.d.ts.map +1 -1
  48. package/dist/types/twisty/{old/animation/cursor/CursorTypes.d.ts → controllers/AnimationTypes.d.ts} +10 -3
  49. package/dist/types/twisty/controllers/AnimationTypes.d.ts.map +1 -0
  50. package/dist/types/twisty/{old/animation → controllers}/RenderScheduler.d.ts +0 -0
  51. package/dist/types/twisty/controllers/RenderScheduler.d.ts.map +1 -0
  52. package/dist/types/twisty/controllers/TwistyAnimationController.d.ts +1 -1
  53. package/dist/types/twisty/controllers/TwistyAnimationController.d.ts.map +1 -1
  54. package/dist/types/twisty/{old/animation → controllers}/easing.d.ts +0 -0
  55. package/dist/types/twisty/controllers/easing.d.ts.map +1 -0
  56. package/dist/types/twisty/{old/animation → controllers}/indexer/AlgDuration.d.ts +2 -2
  57. package/dist/types/twisty/controllers/indexer/AlgDuration.d.ts.map +1 -0
  58. package/dist/types/twisty/{old/animation → controllers}/indexer/AlgIndexer.d.ts +3 -3
  59. package/dist/types/twisty/controllers/indexer/AlgIndexer.d.ts.map +1 -0
  60. package/dist/types/twisty/{old/animation → controllers}/indexer/SimpleAlgIndexer.d.ts +3 -3
  61. package/dist/types/twisty/controllers/indexer/SimpleAlgIndexer.d.ts.map +1 -0
  62. package/dist/types/twisty/{old/animation → controllers}/indexer/simultaneous-moves/SimultaneousMoveIndexer.d.ts +3 -3
  63. package/dist/types/twisty/controllers/indexer/simultaneous-moves/SimultaneousMoveIndexer.d.ts.map +1 -0
  64. package/dist/types/twisty/{old/animation → controllers}/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.d.ts +3 -3
  65. package/dist/types/twisty/controllers/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.d.ts.map +1 -0
  66. package/dist/types/twisty/{old/animation → controllers}/indexer/simultaneous-moves/simul-moves.d.ts +2 -2
  67. package/dist/types/twisty/controllers/indexer/simultaneous-moves/simul-moves.d.ts.map +1 -0
  68. package/dist/types/twisty/{old/animation → controllers}/indexer/tree/AlgWalker.d.ts +2 -2
  69. package/dist/types/twisty/controllers/indexer/tree/AlgWalker.d.ts.map +1 -0
  70. package/dist/types/twisty/{old/animation → controllers}/indexer/tree/TreeAlgIndexer.d.ts +3 -3
  71. package/dist/types/twisty/controllers/indexer/tree/TreeAlgIndexer.d.ts.map +1 -0
  72. package/dist/types/twisty/controllers/indexer/tree/chunkAlgs.d.ts +3 -0
  73. package/dist/types/twisty/controllers/indexer/tree/chunkAlgs.d.ts.map +1 -0
  74. package/dist/types/twisty/{old/animation → controllers}/stream/timeline-move-calculation-draft.d.ts +2 -2
  75. package/dist/types/twisty/controllers/stream/timeline-move-calculation-draft.d.ts.map +1 -0
  76. package/dist/types/twisty/heavy-code-imports/dynamic-entries/3d.d.ts +1 -2
  77. package/dist/types/twisty/heavy-code-imports/dynamic-entries/3d.d.ts.map +1 -1
  78. package/dist/types/twisty/index.d.ts +8 -11
  79. package/dist/types/twisty/index.d.ts.map +1 -1
  80. package/dist/types/twisty/model/TwistyPlayerModel.d.ts +11 -0
  81. package/dist/types/twisty/model/TwistyPlayerModel.d.ts.map +1 -1
  82. package/dist/types/twisty/model/props/TwistyPropDebugger.d.ts +1 -1
  83. package/dist/types/twisty/model/props/TwistyPropDebugger.d.ts.map +1 -1
  84. package/dist/types/twisty/model/props/puzzle/display/FoundationDisplayProp.d.ts +6 -0
  85. package/dist/types/twisty/model/props/puzzle/display/FoundationDisplayProp.d.ts.map +1 -0
  86. package/dist/types/twisty/model/props/puzzle/display/HintFaceletProp.d.ts +5 -1
  87. package/dist/types/twisty/model/props/puzzle/display/HintFaceletProp.d.ts.map +1 -1
  88. package/dist/types/twisty/model/props/puzzle/display/StickeringProp.d.ts +44 -1
  89. package/dist/types/twisty/model/props/puzzle/display/StickeringProp.d.ts.map +1 -1
  90. package/dist/types/twisty/model/props/puzzle/state/AnchoredStartProp.d.ts +2 -2
  91. package/dist/types/twisty/model/props/puzzle/state/AnchoredStartProp.d.ts.map +1 -1
  92. package/dist/types/twisty/model/props/puzzle/state/CurrentLeavesProp.d.ts +1 -1
  93. package/dist/types/twisty/model/props/puzzle/state/CurrentLeavesProp.d.ts.map +1 -1
  94. package/dist/types/twisty/model/props/puzzle/state/CurrentLeavesSimplified.d.ts +1 -1
  95. package/dist/types/twisty/model/props/puzzle/state/CurrentLeavesSimplified.d.ts.map +1 -1
  96. package/dist/types/twisty/model/props/puzzle/state/CurrentTransformationProp.d.ts +1 -1
  97. package/dist/types/twisty/model/props/puzzle/state/CurrentTransformationProp.d.ts.map +1 -1
  98. package/dist/types/twisty/model/props/puzzle/state/IndexerConstructorProp.d.ts +5 -2
  99. package/dist/types/twisty/model/props/puzzle/state/IndexerConstructorProp.d.ts.map +1 -1
  100. package/dist/types/twisty/model/props/puzzle/state/IndexerProp.d.ts +2 -2
  101. package/dist/types/twisty/model/props/puzzle/state/IndexerProp.d.ts.map +1 -1
  102. package/dist/types/twisty/model/props/puzzle/state/LegacyPositionProp.d.ts +2 -2
  103. package/dist/types/twisty/model/props/puzzle/state/LegacyPositionProp.d.ts.map +1 -1
  104. package/dist/types/twisty/model/props/puzzle/state/MovePressInputProp.d.ts +6 -0
  105. package/dist/types/twisty/model/props/puzzle/state/MovePressInputProp.d.ts.map +1 -0
  106. package/dist/types/twisty/model/props/puzzle/state/NaiveMoveCountProp.d.ts +10 -0
  107. package/dist/types/twisty/model/props/puzzle/state/NaiveMoveCountProp.d.ts.map +1 -0
  108. package/dist/types/twisty/model/props/puzzle/state/SetupAnchorProp.d.ts +5 -1
  109. package/dist/types/twisty/model/props/puzzle/state/SetupAnchorProp.d.ts.map +1 -1
  110. package/dist/types/twisty/model/props/puzzle/structure/PuzzleIDProp.d.ts +1 -1
  111. package/dist/types/twisty/model/props/puzzle/structure/PuzzleIDProp.d.ts.map +1 -1
  112. package/dist/types/twisty/model/props/puzzle/structure/PuzzleIDRequestProp.d.ts +19 -1
  113. package/dist/types/twisty/model/props/puzzle/structure/PuzzleIDRequestProp.d.ts.map +1 -1
  114. package/dist/types/twisty/model/props/puzzle/structure/PuzzleLoaderProp.d.ts +1 -1
  115. package/dist/types/twisty/model/props/puzzle/structure/PuzzleLoaderProp.d.ts.map +1 -1
  116. package/dist/types/twisty/model/props/timeline/DetailedTimelineInfoProp.d.ts +2 -3
  117. package/dist/types/twisty/model/props/timeline/DetailedTimelineInfoProp.d.ts.map +1 -1
  118. package/dist/types/twisty/model/props/timeline/PlayingInfoProp.d.ts +1 -1
  119. package/dist/types/twisty/model/props/timeline/PlayingInfoProp.d.ts.map +1 -1
  120. package/dist/types/twisty/model/props/timeline/TimestampRequestProp.d.ts +1 -1
  121. package/dist/types/twisty/model/props/timeline/TimestampRequestProp.d.ts.map +1 -1
  122. package/dist/types/twisty/model/props/viewer/BackViewProp.d.ts +6 -1
  123. package/dist/types/twisty/model/props/viewer/BackViewProp.d.ts.map +1 -1
  124. package/dist/types/twisty/model/props/viewer/BackgroundProp.d.ts +5 -1
  125. package/dist/types/twisty/model/props/viewer/BackgroundProp.d.ts.map +1 -1
  126. package/dist/types/twisty/model/props/viewer/ControlPanelProp.d.ts +5 -1
  127. package/dist/types/twisty/model/props/viewer/ControlPanelProp.d.ts.map +1 -1
  128. package/dist/types/twisty/model/props/viewer/OrbitCoordinatesProp.d.ts +18 -5
  129. package/dist/types/twisty/model/props/viewer/OrbitCoordinatesProp.d.ts.map +1 -1
  130. package/dist/types/twisty/model/props/viewer/OrbitCoordinatesRequestProp.d.ts +6 -6
  131. package/dist/types/twisty/model/props/viewer/OrbitCoordinatesRequestProp.d.ts.map +1 -1
  132. package/dist/types/twisty/model/props/viewer/TimeRangeProp.d.ts +2 -2
  133. package/dist/types/twisty/model/props/viewer/TimeRangeProp.d.ts.map +1 -1
  134. package/dist/types/twisty/model/props/viewer/ViewerLinkProp.d.ts +5 -1
  135. package/dist/types/twisty/model/props/viewer/ViewerLinkProp.d.ts.map +1 -1
  136. package/dist/types/twisty/model/props/viewer/VisualizationProp.d.ts +7 -1
  137. package/dist/types/twisty/model/props/viewer/VisualizationProp.d.ts.map +1 -1
  138. package/dist/types/twisty/model/props/viewer/VisualizationStrategyProp.d.ts +1 -1
  139. package/dist/types/twisty/model/props/viewer/VisualizationStrategyProp.d.ts.map +1 -1
  140. package/dist/types/twisty/views/2D/Twisty2DPuzzle.css.d.ts +3 -0
  141. package/dist/types/twisty/views/2D/Twisty2DPuzzle.css.d.ts.map +1 -0
  142. package/dist/types/twisty/views/2D/Twisty2DPuzzle.d.ts +4 -6
  143. package/dist/types/twisty/views/2D/Twisty2DPuzzle.d.ts.map +1 -1
  144. package/dist/types/twisty/views/2D/Twisty2DPuzzleWrapper.d.ts +1 -1
  145. package/dist/types/twisty/views/2D/Twisty2DPuzzleWrapper.d.ts.map +1 -1
  146. package/dist/types/twisty/views/2D/Twisty2DSceneWrapper.d.ts +2 -2
  147. package/dist/types/twisty/views/2D/Twisty2DSceneWrapper.d.ts.map +1 -1
  148. package/dist/types/twisty/views/3D/DragTracker.d.ts +28 -0
  149. package/dist/types/twisty/views/3D/DragTracker.d.ts.map +1 -0
  150. package/dist/types/twisty/views/3D/RendererPool.d.ts.map +1 -1
  151. package/dist/types/twisty/views/3D/Twisty3DPuzzleWrapper.d.ts +6 -1
  152. package/dist/types/twisty/views/3D/Twisty3DPuzzleWrapper.d.ts.map +1 -1
  153. package/dist/types/twisty/views/3D/Twisty3DSceneWrapper.d.ts +9 -4
  154. package/dist/types/twisty/views/3D/Twisty3DSceneWrapper.d.ts.map +1 -1
  155. package/dist/types/twisty/views/3D/Twisty3DVantage.css.d.ts +3 -0
  156. package/dist/types/twisty/views/3D/Twisty3DVantage.css.d.ts.map +1 -0
  157. package/dist/types/twisty/views/3D/Twisty3DVantage.d.ts +11 -7
  158. package/dist/types/twisty/views/3D/Twisty3DVantage.d.ts.map +1 -1
  159. package/dist/types/twisty/views/3D/TwistyOrbitControls.d.ts +24 -0
  160. package/dist/types/twisty/views/3D/TwistyOrbitControls.d.ts.map +1 -0
  161. package/dist/types/twisty/views/3D/TwistyOrbitControls.spec.d.ts +5 -0
  162. package/dist/types/twisty/views/3D/TwistyOrbitControls.spec.d.ts.map +1 -0
  163. package/dist/types/twisty/views/3D/puzzles/Cube3D.d.ts +4 -4
  164. package/dist/types/twisty/views/3D/puzzles/Cube3D.d.ts.map +1 -1
  165. package/dist/types/twisty/views/3D/puzzles/PG3D.d.ts +17 -10
  166. package/dist/types/twisty/views/3D/puzzles/PG3D.d.ts.map +1 -1
  167. package/dist/types/twisty/views/3D/puzzles/Twisty3DPuzzle.d.ts +1 -1
  168. package/dist/types/twisty/views/3D/puzzles/Twisty3DPuzzle.d.ts.map +1 -1
  169. package/dist/types/twisty/{old/dom/element → views}/ClassListManager.d.ts +0 -0
  170. package/dist/types/twisty/views/ClassListManager.d.ts.map +1 -0
  171. package/dist/types/twisty/{old/dom/element → views}/ManagedCustomElement.d.ts +0 -0
  172. package/dist/types/twisty/views/ManagedCustomElement.d.ts.map +1 -0
  173. package/dist/types/twisty/views/TwistyAlgEditor/LeafTokens.d.ts +1 -1
  174. package/dist/types/twisty/views/TwistyAlgEditor/LeafTokens.d.ts.map +1 -1
  175. package/dist/types/twisty/views/TwistyAlgEditor/TwistyAlgEditor.css.d.ts +1 -1
  176. package/dist/types/twisty/views/TwistyAlgEditor/TwistyAlgEditor.css.d.ts.map +1 -1
  177. package/dist/types/twisty/views/TwistyAlgEditor/TwistyAlgEditor.d.ts +2 -1
  178. package/dist/types/twisty/views/TwistyAlgEditor/TwistyAlgEditor.d.ts.map +1 -1
  179. package/dist/types/twisty/views/TwistyAlgViewer.css.d.ts +1 -1
  180. package/dist/types/twisty/views/TwistyAlgViewer.css.d.ts.map +1 -1
  181. package/dist/types/twisty/views/TwistyAlgViewer.d.ts +2 -2
  182. package/dist/types/twisty/views/TwistyAlgViewer.d.ts.map +1 -1
  183. package/dist/types/twisty/views/TwistyPlayer.css.d.ts +3 -0
  184. package/dist/types/twisty/views/TwistyPlayer.css.d.ts.map +1 -0
  185. package/dist/types/twisty/views/TwistyPlayer.d.ts +7 -3
  186. package/dist/types/twisty/views/TwistyPlayer.d.ts.map +1 -1
  187. package/dist/types/twisty/views/TwistyPlayerSettable.d.ts +7 -4
  188. package/dist/types/twisty/views/TwistyPlayerSettable.d.ts.map +1 -1
  189. package/dist/types/twisty/views/TwistyViewerWrapper.css.d.ts +3 -0
  190. package/dist/types/twisty/views/TwistyViewerWrapper.css.d.ts.map +1 -0
  191. package/dist/types/twisty/{old/dom/viewers → views}/canvas.d.ts +0 -0
  192. package/dist/types/twisty/views/canvas.d.ts.map +1 -0
  193. package/dist/types/twisty/views/control-panel/TwistyButtonsV2.css.d.ts +4 -0
  194. package/dist/types/twisty/views/control-panel/TwistyButtonsV2.css.d.ts.map +1 -0
  195. package/dist/types/twisty/views/control-panel/TwistyButtonsV2.d.ts +1 -1
  196. package/dist/types/twisty/views/control-panel/TwistyButtonsV2.d.ts.map +1 -1
  197. package/dist/types/twisty/views/control-panel/TwistyScrubber.css.d.ts +3 -0
  198. package/dist/types/twisty/{old/dom/controls → views/control-panel}/TwistyScrubber.css.d.ts.map +1 -1
  199. package/dist/types/twisty/views/control-panel/TwistyScrubberV2.d.ts +1 -1
  200. package/dist/types/twisty/views/control-panel/TwistyScrubberV2.d.ts.map +1 -1
  201. package/dist/types/twisty/{old/dom/element → views}/node-custom-element-shims.d.ts +0 -0
  202. package/dist/types/twisty/views/node-custom-element-shims.d.ts.map +1 -0
  203. package/dist/types/twisty/views/stream/TwistyStreamSource.css.d.ts +3 -0
  204. package/dist/types/twisty/views/stream/TwistyStreamSource.css.d.ts.map +1 -0
  205. package/dist/types/twisty/{old/dom → views}/stream/TwistyStreamSource.d.ts +1 -1
  206. package/dist/types/twisty/views/stream/TwistyStreamSource.d.ts.map +1 -0
  207. package/docs/.DS_Store +0 -0
  208. package/docs/cubing/.DS_Store +0 -0
  209. package/docs/cubing/api/index.html +11 -52
  210. package/package.json +1 -1
  211. package/src/cubing/.DS_Store +0 -0
  212. package/src/cubing/alg/index.ts +1 -0
  213. package/src/cubing/alg/units/leaves/Move.ts +1 -1
  214. package/src/cubing/bluetooth/smart-timer/GanTimer.ts +1 -1
  215. package/src/cubing/puzzle-geometry/PGPuzzles.spec.ts +4 -0
  216. package/src/cubing/puzzle-geometry/PuzzleGeometry.ts +14 -6
  217. package/src/cubing/puzzles/index.ts +1 -1
  218. package/src/cubing/search/worker-inside-generated-string.js +1 -1
  219. package/src/cubing/twisty/.DS_Store +0 -0
  220. package/{dist/types → src/cubing/twisty/controllers}/.DS_Store +0 -0
  221. package/src/cubing/twisty/{old/animation/cursor/CursorTypes.ts → controllers/AnimationTypes.ts} +11 -2
  222. package/src/cubing/twisty/{old/animation → controllers}/RenderScheduler.ts +0 -0
  223. package/src/cubing/twisty/controllers/TwistyAnimationController.ts +4 -4
  224. package/src/cubing/twisty/controllers/animation/.DS_Store +0 -0
  225. package/src/cubing/twisty/{old/animation → controllers}/easing.ts +0 -0
  226. package/src/cubing/twisty/controllers/indexer/.DS_Store +0 -0
  227. package/src/cubing/twisty/{old/animation → controllers}/indexer/AlgDuration.ts +2 -2
  228. package/src/cubing/twisty/{old/animation → controllers}/indexer/AlgIndexer.ts +4 -4
  229. package/src/cubing/twisty/{old/animation → controllers}/indexer/SimpleAlgIndexer.ts +4 -4
  230. package/src/cubing/twisty/{old/animation → controllers}/indexer/simultaneous-moves/SimultaneousMoveIndexer.ts +3 -3
  231. package/src/cubing/twisty/{old/animation → controllers}/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.ts +3 -3
  232. package/src/cubing/twisty/{old/animation → controllers}/indexer/simultaneous-moves/simul-moves.ts +2 -2
  233. package/src/cubing/twisty/{old/animation → controllers}/indexer/tree/AlgWalker.ts +4 -4
  234. package/src/cubing/twisty/{old/animation → controllers}/indexer/tree/TreeAlgIndexer.ts +3 -3
  235. package/src/cubing/twisty/{old/animation → controllers}/indexer/tree/chunkAlgs.ts +2 -2
  236. package/src/cubing/twisty/{old/animation → controllers}/stream/timeline-move-calculation-draft.spec.ts.TODO +0 -0
  237. package/src/cubing/twisty/{old/animation → controllers}/stream/timeline-move-calculation-draft.ts +2 -2
  238. package/src/cubing/twisty/heavy-code-imports/.DS_Store +0 -0
  239. package/src/cubing/twisty/heavy-code-imports/dynamic-entries/3d.ts +2 -12
  240. package/src/cubing/twisty/index.ts +11 -18
  241. package/src/cubing/twisty/model/.DS_Store +0 -0
  242. package/src/cubing/twisty/model/TwistyPlayerModel.ts +30 -1
  243. package/src/cubing/twisty/model/props/.DS_Store +0 -0
  244. package/src/cubing/twisty/model/props/TwistyPropDebugger.ts +3 -3
  245. package/src/cubing/twisty/model/props/puzzle/.DS_Store +0 -0
  246. package/src/cubing/twisty/model/props/puzzle/display/FoundationDisplayProp.ts +9 -0
  247. package/src/cubing/twisty/model/props/puzzle/display/HintFaceletProp.ts +6 -1
  248. package/src/cubing/twisty/model/props/puzzle/display/StickeringProp.ts +47 -1
  249. package/src/cubing/twisty/model/props/puzzle/state/AlgTransformationProp.ts +1 -1
  250. package/src/cubing/twisty/model/props/puzzle/state/AnchoredStartProp.ts +2 -2
  251. package/src/cubing/twisty/model/props/puzzle/state/CurrentLeavesProp.ts +2 -2
  252. package/src/cubing/twisty/model/props/puzzle/state/CurrentLeavesSimplified.ts +1 -1
  253. package/src/cubing/twisty/model/props/puzzle/state/CurrentTransformationProp.ts +1 -1
  254. package/src/cubing/twisty/model/props/puzzle/state/IndexerConstructorProp.ts +12 -5
  255. package/src/cubing/twisty/model/props/puzzle/state/IndexerProp.ts +2 -2
  256. package/src/cubing/twisty/model/props/puzzle/state/LegacyPositionProp.ts +2 -2
  257. package/src/cubing/twisty/model/props/puzzle/state/MovePressInputProp.ts +9 -0
  258. package/src/cubing/twisty/model/props/puzzle/state/NaiveMoveCountProp.ts +20 -0
  259. package/src/cubing/twisty/model/props/puzzle/state/SetupAnchorProp.ts +7 -1
  260. package/src/cubing/twisty/model/props/puzzle/structure/PuzzleIDProp.ts +1 -1
  261. package/src/cubing/twisty/model/props/puzzle/structure/PuzzleIDRequestProp.ts +20 -1
  262. package/src/cubing/twisty/model/props/puzzle/structure/PuzzleLoaderProp.ts +1 -1
  263. package/src/cubing/twisty/model/props/timeline/DetailedTimelineInfoProp.ts +5 -3
  264. package/src/cubing/twisty/model/props/timeline/PlayingInfoProp.ts +1 -4
  265. package/src/cubing/twisty/model/props/timeline/TimestampRequestProp.ts +1 -1
  266. package/src/cubing/twisty/model/props/viewer/BackViewProp.ts +7 -1
  267. package/src/cubing/twisty/model/props/viewer/BackgroundProp.ts +6 -1
  268. package/src/cubing/twisty/model/props/viewer/ControlPanelProp.ts +5 -1
  269. package/src/cubing/twisty/model/props/viewer/OrbitCoordinatesProp.ts +83 -12
  270. package/src/cubing/twisty/model/props/viewer/OrbitCoordinatesRequestProp.ts +8 -8
  271. package/src/cubing/twisty/model/props/viewer/TimeRangeProp.ts +2 -2
  272. package/src/cubing/twisty/model/props/viewer/ViewerLinkProp.ts +5 -1
  273. package/src/cubing/twisty/model/props/viewer/VisualizationProp.ts +8 -1
  274. package/src/cubing/twisty/model/props/viewer/VisualizationStrategyProp.ts +1 -1
  275. package/src/cubing/twisty/old/.DS_Store +0 -0
  276. package/src/cubing/twisty/old/animation/.DS_Store +0 -0
  277. package/src/cubing/twisty/old/dom/.DS_Store +0 -0
  278. package/src/cubing/twisty/views/.DS_Store +0 -0
  279. package/src/cubing/twisty/{old/dom/viewers/Twisty2DSVGView.css.ts → views/2D/Twisty2DPuzzle.css.ts} +1 -1
  280. package/src/cubing/twisty/views/2D/Twisty2DPuzzle.ts +8 -12
  281. package/src/cubing/twisty/views/2D/Twisty2DPuzzleWrapper.ts +1 -1
  282. package/src/cubing/twisty/views/2D/Twisty2DSceneWrapper.ts +4 -4
  283. package/src/cubing/twisty/views/3D/.DS_Store +0 -0
  284. package/src/cubing/twisty/views/3D/DragTracker.ts +184 -0
  285. package/src/cubing/twisty/views/3D/RendererPool.ts +2 -1
  286. package/src/cubing/twisty/views/3D/Twisty3DPuzzleWrapper.ts +51 -5
  287. package/src/cubing/twisty/views/3D/Twisty3DSceneWrapper.ts +51 -10
  288. package/src/cubing/twisty/{old/dom/viewers/Twisty3DCanvas.css.ts → views/3D/Twisty3DVantage.css.ts} +2 -2
  289. package/src/cubing/twisty/views/3D/Twisty3DVantage.ts +88 -30
  290. package/src/cubing/twisty/views/3D/TwistyOrbitControls.spec.ts +213 -0
  291. package/src/cubing/twisty/views/3D/TwistyOrbitControls.ts +176 -0
  292. package/src/cubing/twisty/views/3D/puzzles/Cube3D.ts +5 -9
  293. package/src/cubing/twisty/views/3D/puzzles/PG3D.ts +127 -37
  294. package/src/cubing/twisty/views/3D/puzzles/Twisty3DPuzzle.ts +1 -1
  295. package/src/cubing/twisty/{old/dom/element → views}/ClassListManager.ts +0 -0
  296. package/src/cubing/twisty/{old/dom/element → views}/ManagedCustomElement.ts +0 -0
  297. package/src/cubing/twisty/views/TwistyAlgEditor/LeafTokens.ts +1 -1
  298. package/src/cubing/twisty/views/TwistyAlgEditor/TwistyAlgEditor.css.ts +1 -1
  299. package/src/cubing/twisty/views/TwistyAlgEditor/TwistyAlgEditor.ts +11 -4
  300. package/src/cubing/twisty/views/TwistyAlgViewer.css.ts +1 -1
  301. package/src/cubing/twisty/views/TwistyAlgViewer.ts +4 -4
  302. package/src/cubing/twisty/{old/dom → views}/TwistyPlayer.css.ts +4 -1
  303. package/src/cubing/twisty/views/TwistyPlayer.ts +16 -25
  304. package/src/cubing/twisty/views/TwistyPlayerSettable.ts +14 -10
  305. package/src/cubing/twisty/{old/dom/viewers → views}/TwistyViewerWrapper.css.ts +1 -1
  306. package/src/cubing/twisty/{old/dom/viewers → views}/canvas.ts +0 -0
  307. package/src/cubing/twisty/{old/dom/controls/buttons.css.ts → views/control-panel/TwistyButtonsV2.css.ts} +1 -1
  308. package/src/cubing/twisty/views/control-panel/TwistyButtonsV2.ts +5 -8
  309. package/src/cubing/twisty/{old/dom/controls → views/control-panel}/TwistyScrubber.css.ts +1 -1
  310. package/src/cubing/twisty/views/control-panel/TwistyScrubberV2.ts +3 -3
  311. package/src/cubing/twisty/{old/dom/element → views}/node-custom-element-shims.ts +0 -0
  312. package/src/cubing/twisty/{old/dom → views}/stream/TwistyStreamSource.css.ts +1 -1
  313. package/src/cubing/twisty/{old/dom → views}/stream/TwistyStreamSource.ts +9 -9
  314. package/dist/esm/3d-B25DP5PE.js +0 -39
  315. package/dist/esm/3d-B25DP5PE.js.map +0 -7
  316. package/dist/esm/chunk-APIIMJG6.js.map +0 -7
  317. package/dist/esm/worker-inside-generated-string-KDZOUGJF.js.map +0 -7
  318. package/dist/types/twisty/old/animation/RenderScheduler.d.ts.map +0 -1
  319. package/dist/types/twisty/old/animation/Timeline.d.ts +0 -72
  320. package/dist/types/twisty/old/animation/Timeline.d.ts.map +0 -1
  321. package/dist/types/twisty/old/animation/cursor/AlgCursor.d.ts +0 -53
  322. package/dist/types/twisty/old/animation/cursor/AlgCursor.d.ts.map +0 -1
  323. package/dist/types/twisty/old/animation/cursor/CursorTypes.d.ts.map +0 -1
  324. package/dist/types/twisty/old/animation/easing.d.ts.map +0 -1
  325. package/dist/types/twisty/old/animation/indexer/AlgDuration.d.ts.map +0 -1
  326. package/dist/types/twisty/old/animation/indexer/AlgIndexer.d.ts.map +0 -1
  327. package/dist/types/twisty/old/animation/indexer/SimpleAlgIndexer.d.ts.map +0 -1
  328. package/dist/types/twisty/old/animation/indexer/simultaneous-moves/SimultaneousMoveIndexer.d.ts.map +0 -1
  329. package/dist/types/twisty/old/animation/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.d.ts.map +0 -1
  330. package/dist/types/twisty/old/animation/indexer/simultaneous-moves/simul-moves.d.ts.map +0 -1
  331. package/dist/types/twisty/old/animation/indexer/tree/AlgWalker.d.ts.map +0 -1
  332. package/dist/types/twisty/old/animation/indexer/tree/TreeAlgIndexer.d.ts.map +0 -1
  333. package/dist/types/twisty/old/animation/indexer/tree/chunkAlgs.d.ts +0 -3
  334. package/dist/types/twisty/old/animation/indexer/tree/chunkAlgs.d.ts.map +0 -1
  335. package/dist/types/twisty/old/animation/stream/timeline-move-calculation-draft.d.ts.map +0 -1
  336. package/dist/types/twisty/old/dom/TwistyAlgViewerV1.css.d.ts +0 -3
  337. package/dist/types/twisty/old/dom/TwistyAlgViewerV1.css.d.ts.map +0 -1
  338. package/dist/types/twisty/old/dom/TwistyAlgViewerV1.d.ts +0 -52
  339. package/dist/types/twisty/old/dom/TwistyAlgViewerV1.d.ts.map +0 -1
  340. package/dist/types/twisty/old/dom/TwistyPlayer.css.d.ts +0 -3
  341. package/dist/types/twisty/old/dom/TwistyPlayer.css.d.ts.map +0 -1
  342. package/dist/types/twisty/old/dom/TwistyPlayer.d.ts +0 -92
  343. package/dist/types/twisty/old/dom/TwistyPlayer.d.ts.map +0 -1
  344. package/dist/types/twisty/old/dom/TwistyPlayer.spec.d.ts +0 -5
  345. package/dist/types/twisty/old/dom/TwistyPlayer.spec.d.ts.map +0 -1
  346. package/dist/types/twisty/old/dom/TwistyPlayerConfig.d.ts +0 -165
  347. package/dist/types/twisty/old/dom/TwistyPlayerConfig.d.ts.map +0 -1
  348. package/dist/types/twisty/old/dom/controls/TwistyControlElement.d.ts +0 -2
  349. package/dist/types/twisty/old/dom/controls/TwistyControlElement.d.ts.map +0 -1
  350. package/dist/types/twisty/old/dom/controls/TwistyScrubber.css.d.ts +0 -3
  351. package/dist/types/twisty/old/dom/controls/TwistyScrubber.d.ts +0 -14
  352. package/dist/types/twisty/old/dom/controls/TwistyScrubber.d.ts.map +0 -1
  353. package/dist/types/twisty/old/dom/controls/buttons.css.d.ts +0 -4
  354. package/dist/types/twisty/old/dom/controls/buttons.css.d.ts.map +0 -1
  355. package/dist/types/twisty/old/dom/controls/buttons.d.ts +0 -40
  356. package/dist/types/twisty/old/dom/controls/buttons.d.ts.map +0 -1
  357. package/dist/types/twisty/old/dom/controls/buttons.spec.d.ts +0 -5
  358. package/dist/types/twisty/old/dom/controls/buttons.spec.d.ts.map +0 -1
  359. package/dist/types/twisty/old/dom/element/ClassListManager.d.ts.map +0 -1
  360. package/dist/types/twisty/old/dom/element/ElementConfig.d.ts +0 -49
  361. package/dist/types/twisty/old/dom/element/ElementConfig.d.ts.map +0 -1
  362. package/dist/types/twisty/old/dom/element/ManagedCustomElement.d.ts.map +0 -1
  363. package/dist/types/twisty/old/dom/element/node-custom-element-shims.d.ts.map +0 -1
  364. package/dist/types/twisty/old/dom/stream/TwistyStreamSource.css.d.ts +0 -3
  365. package/dist/types/twisty/old/dom/stream/TwistyStreamSource.css.d.ts.map +0 -1
  366. package/dist/types/twisty/old/dom/stream/TwistyStreamSource.d.ts.map +0 -1
  367. package/dist/types/twisty/old/dom/viewers/Twisty2DSVG.d.ts +0 -26
  368. package/dist/types/twisty/old/dom/viewers/Twisty2DSVG.d.ts.map +0 -1
  369. package/dist/types/twisty/old/dom/viewers/Twisty2DSVGView.css.d.ts +0 -3
  370. package/dist/types/twisty/old/dom/viewers/Twisty2DSVGView.css.d.ts.map +0 -1
  371. package/dist/types/twisty/old/dom/viewers/Twisty3DCanvas.css.d.ts +0 -3
  372. package/dist/types/twisty/old/dom/viewers/Twisty3DCanvas.css.d.ts.map +0 -1
  373. package/dist/types/twisty/old/dom/viewers/Twisty3DCanvas.d.ts +0 -41
  374. package/dist/types/twisty/old/dom/viewers/Twisty3DCanvas.d.ts.map +0 -1
  375. package/dist/types/twisty/old/dom/viewers/TwistyOrbitControls.d.ts +0 -59
  376. package/dist/types/twisty/old/dom/viewers/TwistyOrbitControls.d.ts.map +0 -1
  377. package/dist/types/twisty/old/dom/viewers/TwistyViewerElement.d.ts +0 -4
  378. package/dist/types/twisty/old/dom/viewers/TwistyViewerElement.d.ts.map +0 -1
  379. package/dist/types/twisty/old/dom/viewers/TwistyViewerWrapper.css.d.ts +0 -3
  380. package/dist/types/twisty/old/dom/viewers/TwistyViewerWrapper.css.d.ts.map +0 -1
  381. package/dist/types/twisty/old/dom/viewers/TwistyViewerWrapper.d.ts +0 -18
  382. package/dist/types/twisty/old/dom/viewers/TwistyViewerWrapper.d.ts.map +0 -1
  383. package/dist/types/twisty/old/dom/viewers/canvas.d.ts.map +0 -1
  384. package/dist/types/twisty/views/3D/TwistyOrbitControlsV2.d.ts +0 -41
  385. package/dist/types/twisty/views/3D/TwistyOrbitControlsV2.d.ts.map +0 -1
  386. package/dist/types/twisty/views/3D/TwistyOrbitControlsV2.spec.d.ts +0 -5
  387. package/dist/types/twisty/views/3D/TwistyOrbitControlsV2.spec.d.ts.map +0 -1
  388. package/src/cubing/twisty/old/animation/Timeline.ts +0 -378
  389. package/src/cubing/twisty/old/animation/cursor/AlgCursor.ts +0 -252
  390. package/src/cubing/twisty/old/dom/TwistyAlgViewerV1.css.ts +0 -25
  391. package/src/cubing/twisty/old/dom/TwistyAlgViewerV1.ts +0 -516
  392. package/src/cubing/twisty/old/dom/TwistyPlayer.spec.ts +0 -25
  393. package/src/cubing/twisty/old/dom/TwistyPlayer.ts +0 -927
  394. package/src/cubing/twisty/old/dom/TwistyPlayerConfig.ts +0 -378
  395. package/src/cubing/twisty/old/dom/controls/TwistyControlElement.ts +0 -1
  396. package/src/cubing/twisty/old/dom/controls/TwistyScrubber.ts +0 -53
  397. package/src/cubing/twisty/old/dom/controls/buttons.spec.ts +0 -37
  398. package/src/cubing/twisty/old/dom/controls/buttons.ts +0 -326
  399. package/src/cubing/twisty/old/dom/element/ElementConfig.ts +0 -180
  400. package/src/cubing/twisty/old/dom/viewers/Twisty2DSVG.ts +0 -118
  401. package/src/cubing/twisty/old/dom/viewers/Twisty3DCanvas.ts +0 -256
  402. package/src/cubing/twisty/old/dom/viewers/TwistyOrbitControls.ts +0 -420
  403. package/src/cubing/twisty/old/dom/viewers/TwistyViewerElement.ts +0 -5
  404. package/src/cubing/twisty/old/dom/viewers/TwistyViewerWrapper.ts +0 -45
  405. package/src/cubing/twisty/views/3D/TwistyOrbitControlsV2.spec.ts +0 -209
  406. package/src/cubing/twisty/views/3D/TwistyOrbitControlsV2.ts +0 -270
@@ -1,378 +0,0 @@
1
- import { RenderScheduler } from "./RenderScheduler";
2
- import type { AlgCursor, TimeRange } from "./cursor/AlgCursor";
3
- import {
4
- BoundaryType,
5
- Direction,
6
- directionScalar,
7
- MillisecondTimestamp,
8
- } from "./cursor/CursorTypes";
9
-
10
- // YouTube keeps playing on jump, but it also stays frozen while the cursor is
11
- // down. So I think it would be good for this to be false, but only if we
12
- // implement a "start jumping" event that pauses until "finish jumping" while
13
- // the scrubber is active.
14
- const PAUSE_ON_JUMP = true;
15
-
16
- // TODO: We use symbols to avoid exposing `number` values. Is this performant enough? Should/can we use symbols?
17
- export enum TimelineAction {
18
- StartingToPlay = "StartingToPlay", // TODO playing backwards.
19
- Pausing = "Pausing",
20
- Jumping = "Jumping",
21
- }
22
-
23
- // TODO: We use symbols to avoid exposing `number` values. Is this performant enough? Should/can we use symbols?
24
- export enum TimestampLocationType {
25
- StartOfTimeline = "Start",
26
- EndOfTimeline = "End",
27
- StartOfMove = "StartOfMove",
28
- EndOfMove = "EndOfMove",
29
- MiddleOfMove = "MiddleOfMove",
30
- BetweenMoves = "BetweenMoves",
31
- }
32
-
33
- export interface TimelineActionEvent {
34
- action: TimelineAction;
35
- locationType: TimestampLocationType;
36
- }
37
-
38
- // This should be used by classes that (directly or indirectly) update puzzle
39
- // state based on a timestamp. It fires every time the timestamp is changed for
40
- // a new render (e.g. 60 times a second during animation), and only fires if the
41
- // timestamp has changed since the last call. This means you can use it as a
42
- // reliable callback telling you when to schedule a new render.
43
- export interface TimelineTimestampListener {
44
- onTimelineTimestampChange(timestamp: MillisecondTimestamp): void;
45
- onTimeRangeChange(timeRange: TimeRange): void;
46
- }
47
-
48
- // This should be used by classes that (directly or indirectly) update UI (e.g.
49
- // pause/play buttons).
50
- //
51
- // Note: the action events of a `Timeline` are not necessarily coordinated with
52
- // the timestamp events, since timestamp events are tied to animation frames.
53
- // For example, if you receive a "pausing" event, the final frame may already
54
- // have been drawn, or may be drawn in the near future.
55
- export interface TimelineActionListener {
56
- onTimelineAction(actionEvent: TimelineActionEvent): void;
57
- }
58
-
59
- export interface TimelineTimestampDispatcher {
60
- addTimestampListener(timestampListener: TimelineTimestampListener): void;
61
- }
62
-
63
- export interface TimelineActionDispatcher {
64
- addActionListener(actionListener: TimelineActionListener): void;
65
- }
66
-
67
- // `performance.now()` is rounded for security concerns, so it's usually not
68
- // accurate to the millisecond. So we round it, which lets us work with whole ms
69
- // everywhere.
70
- function getNow(): MillisecondTimestamp {
71
- return Math.round(performance.now());
72
- }
73
-
74
- export class Timeline
75
- implements TimelineTimestampDispatcher, TimelineActionDispatcher
76
- {
77
- animating: boolean = false;
78
- tempoScale: number = 1;
79
- private cursors: Set<AlgCursor> = new Set();
80
- private timestampListeners: Set<TimelineTimestampListener> = new Set();
81
- private actionListeners: Set<TimelineActionListener> = new Set();
82
- timestamp: number = 0;
83
- lastAnimFrameNow: DOMHighResTimeStamp = 0;
84
- lastAnimFrameTimestamp: MillisecondTimestamp;
85
- private scheduler: RenderScheduler;
86
-
87
- direction: Direction.Backwards | Direction.Forwards = Direction.Forwards; // TODO: handle pausing here?
88
-
89
- boundaryType: BoundaryType = BoundaryType.EntireTimeline;
90
- cachedNextBoundary: MillisecondTimestamp;
91
-
92
- constructor() {
93
- const animFrame = (_now: MillisecondTimestamp): void => {
94
- if (this.animating) {
95
- const now = getNow(); // TODO: See if we can use the rAF value without monotonicity issues.;
96
- this.timestamp =
97
- this.timestamp +
98
- this.tempoScale *
99
- directionScalar(this.direction) *
100
- (now - this.lastAnimFrameNow);
101
- this.lastAnimFrameNow = now;
102
-
103
- const atOrPastBoundary =
104
- this.direction === Direction.Backwards
105
- ? this.timestamp <= this.cachedNextBoundary
106
- : this.timestamp >= this.cachedNextBoundary;
107
- if (atOrPastBoundary) {
108
- this.timestamp = this.cachedNextBoundary;
109
- if (this.animating) {
110
- this.animating = false;
111
- this.dispatchAction(TimelineAction.Pausing);
112
- }
113
- }
114
- }
115
-
116
- if (this.timestamp !== this.lastAnimFrameTimestamp) {
117
- this.dispatchTimestamp();
118
- this.lastAnimFrameTimestamp = this.timestamp;
119
- }
120
-
121
- if (this.animating) {
122
- this.scheduler.requestAnimFrame();
123
- }
124
- };
125
- this.scheduler = new RenderScheduler(animFrame);
126
- }
127
-
128
- public addCursor(cursor: AlgCursor): void {
129
- this.cursors.add(cursor);
130
- this.dispatchTimeRange();
131
- }
132
-
133
- removeCursor(cursor: AlgCursor): void {
134
- this.cursors.delete(cursor);
135
- this.clampTimestampToRange();
136
- this.dispatchTimeRange();
137
- }
138
-
139
- // TODO: test
140
- private clampTimestampToRange(): void {
141
- const timeRange = this.timeRange();
142
- if (this.timestamp < timeRange.start) {
143
- this.setTimestamp(timeRange.start);
144
- }
145
- if (this.timestamp > timeRange.end) {
146
- this.setTimestamp(timeRange.end);
147
- }
148
- }
149
-
150
- // In the future, this might do some calculations or caching.
151
- public onCursorChange(_cursor: AlgCursor): void {
152
- if (this.timestamp > this.maxTimestamp()) {
153
- this.timestamp = this.maxTimestamp();
154
- }
155
- this.dispatchTimeRange();
156
- }
157
-
158
- timeRange(): TimeRange {
159
- let start = 0;
160
- let end = 0;
161
- for (const cursor of this.cursors) {
162
- const cursorTimeRange = cursor.timeRange();
163
- start = Math.min(start, cursorTimeRange.start);
164
- end = Math.max(end, cursorTimeRange.end);
165
- }
166
-
167
- return { start, end };
168
- }
169
-
170
- minTimestamp(): number {
171
- // TODO: Calculate and cache this value every time there's a new cursor.
172
- return this.timeRange().start;
173
- }
174
-
175
- maxTimestamp(): number {
176
- // TODO: Calculate and cache this value every time there's a new cursor.
177
- return this.timeRange().end;
178
- }
179
-
180
- private dispatchTimeRange(): void {
181
- const timeRange = this.timeRange();
182
- for (const listener of this.cursors) {
183
- // TODO: dedup in case the timestamp hasn't changed sine last time.
184
- listener.onTimeRangeChange(timeRange);
185
- }
186
- // TODO: Combine loops without extra memory?
187
- for (const listener of this.timestampListeners) {
188
- // TODO: dedup in case the timestamp hasn't changed sine last time.
189
- listener.onTimeRangeChange(timeRange);
190
- }
191
- }
192
-
193
- private dispatchTimestamp(): void {
194
- for (const listener of this.cursors) {
195
- // TODO: dedup in case the timestamp hasn't changed sine last time.
196
- listener.onTimelineTimestampChange(this.timestamp);
197
- }
198
- // TODO: Combine loops without extra memory?
199
- for (const listener of this.timestampListeners) {
200
- // TODO: dedup in case the timestamp hasn't changed sine last time.
201
- listener.onTimelineTimestampChange(this.timestamp);
202
- }
203
- }
204
-
205
- addTimestampListener(timestampListener: TimelineTimestampListener): void {
206
- this.timestampListeners.add(timestampListener);
207
- }
208
-
209
- removeTimestampListener(timestampListener: TimelineTimestampListener): void {
210
- this.timestampListeners.delete(timestampListener);
211
- }
212
-
213
- addActionListener(actionListener: TimelineActionListener): void {
214
- this.actionListeners.add(actionListener);
215
- }
216
-
217
- removeActionListener(actionListener: TimelineActionListener): void {
218
- this.actionListeners.delete(actionListener);
219
- }
220
-
221
- play(): void {
222
- this.experimentalPlay(Direction.Forwards, BoundaryType.EntireTimeline);
223
- }
224
-
225
- experimentalPlay(
226
- direction: Direction.Backwards | Direction.Forwards,
227
- boundaryType: BoundaryType = BoundaryType.EntireTimeline,
228
- ): void {
229
- this.direction = direction;
230
- this.boundaryType = boundaryType;
231
- const nextBoundary = this.nextBoundary(
232
- this.timestamp,
233
- direction,
234
- this.boundaryType,
235
- );
236
- if (nextBoundary === null) {
237
- return; // Nowhere to end, so we don't animate.
238
- }
239
- this.cachedNextBoundary = nextBoundary;
240
- if (!this.animating) {
241
- this.animating = true;
242
- this.lastAnimFrameNow = getNow();
243
- this.dispatchAction(TimelineAction.StartingToPlay);
244
- this.scheduler.requestAnimFrame();
245
- }
246
- }
247
-
248
- // Non-inclusive
249
- private nextBoundary(
250
- timestamp: MillisecondTimestamp,
251
- direction: Direction.Backwards | Direction.Forwards,
252
- boundaryType: BoundaryType = BoundaryType.EntireTimeline,
253
- ): MillisecondTimestamp | null {
254
- switch (boundaryType) {
255
- case BoundaryType.EntireTimeline: {
256
- switch (direction) {
257
- case Direction.Backwards:
258
- return timestamp <= this.minTimestamp()
259
- ? null
260
- : this.minTimestamp();
261
- case Direction.Forwards:
262
- return timestamp >= this.maxTimestamp()
263
- ? null
264
- : this.maxTimestamp();
265
- default:
266
- throw new Error("invalid direction");
267
- }
268
- }
269
- case BoundaryType.Move: {
270
- let result: null | MillisecondTimestamp = null;
271
- for (const cursor of this.cursors) {
272
- const boundaryTimestamp = cursor.moveBoundary(timestamp, direction);
273
- if (boundaryTimestamp !== null) {
274
- switch (direction) {
275
- case Direction.Backwards: {
276
- result = Math.min(
277
- result ?? boundaryTimestamp,
278
- boundaryTimestamp,
279
- );
280
- break;
281
- }
282
- case Direction.Forwards: {
283
- result = Math.max(
284
- result ?? boundaryTimestamp,
285
- boundaryTimestamp,
286
- );
287
- break;
288
- }
289
- default:
290
- throw new Error("invalid direction");
291
- }
292
- }
293
- }
294
- return result;
295
- }
296
- default:
297
- throw new Error("invalid boundary type");
298
- }
299
- }
300
-
301
- // One more render may be dispatched after this.
302
- pause(): void {
303
- // TODO: error if already paused?
304
- if (this.animating) {
305
- this.animating = false;
306
- this.dispatchAction(TimelineAction.Pausing);
307
- this.scheduler.requestAnimFrame();
308
- }
309
- }
310
-
311
- playPause(): void {
312
- if (this.animating) {
313
- this.pause();
314
- } else {
315
- if (this.timestamp >= this.maxTimestamp()) {
316
- this.timestamp = 0;
317
- }
318
- this.experimentalPlay(Direction.Forwards, BoundaryType.EntireTimeline);
319
- }
320
- }
321
-
322
- setTimestamp(timestamp: MillisecondTimestamp): void {
323
- const oldTimestamp = this.timestamp;
324
- this.timestamp = timestamp;
325
- this.lastAnimFrameNow = getNow();
326
-
327
- if (oldTimestamp !== timestamp) {
328
- this.dispatchAction(TimelineAction.Jumping);
329
- this.scheduler.requestAnimFrame();
330
- }
331
-
332
- if (PAUSE_ON_JUMP) {
333
- this.animating = false;
334
- this.dispatchAction(TimelineAction.Pausing);
335
- }
336
- }
337
-
338
- jumpToStart(): void {
339
- this.setTimestamp(this.minTimestamp());
340
- }
341
-
342
- jumpToEnd(): void {
343
- this.setTimestamp(this.maxTimestamp());
344
- }
345
-
346
- /** @deprecated */
347
- experimentalJumpToLastMove(): void {
348
- let max: MillisecondTimestamp = 0;
349
- for (const cursor of this.cursors) {
350
- max = Math.max(
351
- max,
352
- cursor.experimentalTimestampForStartOfLastMove() ?? 0,
353
- );
354
- }
355
- this.setTimestamp(max);
356
- }
357
-
358
- private dispatchAction(event: TimelineAction): void {
359
- let locationType = TimestampLocationType.MiddleOfMove; // TODO
360
- switch (this.timestamp) {
361
- // TODO
362
- case this.minTimestamp():
363
- locationType = TimestampLocationType.StartOfTimeline;
364
- break;
365
- case this.maxTimestamp():
366
- locationType = TimestampLocationType.EndOfTimeline;
367
- break;
368
- }
369
-
370
- const actionEvent: TimelineActionEvent = {
371
- action: event,
372
- locationType,
373
- };
374
- for (const listener of this.actionListeners) {
375
- listener.onTimelineAction(actionEvent);
376
- }
377
- }
378
- }
@@ -1,252 +0,0 @@
1
- /* eslint-disable no-case-declarations */
2
- // TODO: private vs. public properties/methods.
3
- // TODO: optional construtor arguments for DOM elements
4
- // TODO: figure out what can be moved into a worker using OffscreenCanvas https://developers.google.com/web/updates/2018/08/offscreen-canvas
5
-
6
- /* eslint-disable @typescript-eslint/no-empty-interface */
7
-
8
- // start of imports
9
- import { Alg, Move, Pause } from "../../../../alg";
10
- import {
11
- KPuzzle,
12
- KPuzzleDefinition,
13
- Transformation,
14
- } from "../../../../kpuzzle";
15
- import { KPuzzleWrapper } from "../../../views/3D/puzzles/KPuzzleWrapper";
16
- import type { AlgIndexer } from "../indexer/AlgIndexer";
17
- import { TreeAlgIndexer } from "../indexer/tree/TreeAlgIndexer";
18
- import type { Timeline, TimelineTimestampListener } from "../Timeline";
19
- import {
20
- Direction,
21
- directionScalar,
22
- MillisecondTimestamp,
23
- PuzzlePosition,
24
- } from "./CursorTypes";
25
- // end of imports
26
-
27
- // Model
28
-
29
- export interface PositionListener {
30
- onPositionChange(position: PuzzlePosition): void;
31
- }
32
-
33
- export interface PositionDispatcher {
34
- addPositionListener(positionListener: PositionListener): void;
35
- }
36
-
37
- export interface TimeRange {
38
- start: MillisecondTimestamp;
39
- end: MillisecondTimestamp;
40
- }
41
-
42
- export type IndexerConstructor = new (
43
- puzzle: KPuzzleWrapper,
44
- alg: Alg,
45
- ) => AlgIndexer<KPuzzleWrapper>;
46
-
47
- export class AlgCursor
48
- implements TimelineTimestampListener, PositionDispatcher
49
- {
50
- private indexer: AlgIndexer<KPuzzleWrapper>;
51
- private positionListeners: Set<PositionListener> = new Set(); // TODO: accessor instead of direct access
52
- private ksolvePuzzle: KPuzzleWrapper;
53
- private startState: Transformation;
54
- private indexerConstructor: IndexerConstructor = TreeAlgIndexer;
55
- constructor(
56
- private timeline: Timeline,
57
- private def: KPuzzleDefinition,
58
- private alg: Alg,
59
- startStateAlg?: Alg, // TODO: accept actual start state
60
- indexerConstructor?: IndexerConstructor,
61
- ) {
62
- this.ksolvePuzzle = new KPuzzleWrapper(def);
63
- if (indexerConstructor) {
64
- this.indexerConstructor = indexerConstructor;
65
- }
66
- this.instantiateIndexer(alg);
67
- this.startState = startStateAlg
68
- ? this.algToState(startStateAlg)
69
- : this.ksolvePuzzle.startState();
70
- timeline.addTimestampListener(this);
71
- }
72
-
73
- setStartState(startState: Transformation): void {
74
- this.startState = startState;
75
- this.dispatchPositionForTimestamp(this.timeline.timestamp);
76
- }
77
-
78
- /** @deprecated */
79
- public experimentalSetIndexer(indexerConstructor: IndexerConstructor): void {
80
- this.indexerConstructor = indexerConstructor;
81
- this.instantiateIndexer(this.alg);
82
- this.timeline.onCursorChange(this);
83
- this.dispatchPositionForTimestamp(this.timeline.timestamp);
84
- }
85
-
86
- private instantiateIndexer(alg: Alg): void {
87
- this.indexer = new this.indexerConstructor(this.ksolvePuzzle, alg);
88
- }
89
-
90
- /** @deprecated */
91
- algToState(s: Alg): Transformation {
92
- const kpuzzle = new KPuzzle(this.def);
93
- kpuzzle.applyAlg(s);
94
- return this.ksolvePuzzle.combine(this.def.startPieces, kpuzzle.state);
95
- }
96
-
97
- timeRange(): TimeRange {
98
- return {
99
- start: 0,
100
- end: this.indexer.algDuration(),
101
- };
102
- }
103
-
104
- /** @deprecated */
105
- experimentalTimestampForStartOfLastMove(): MillisecondTimestamp {
106
- const numMoves = this.indexer.numAnimatedLeaves();
107
- if (numMoves > 0) {
108
- return this.indexer.indexToMoveStartTimestamp(numMoves - 1);
109
- }
110
- return 0;
111
- }
112
-
113
- addPositionListener(positionListener: PositionListener): void {
114
- this.positionListeners.add(positionListener);
115
- this.dispatchPositionForTimestamp(this.timeline.timestamp, [
116
- positionListener,
117
- ]); // TODO: should this be a separate dispatch, or should the listener manually ask for the position?
118
- }
119
-
120
- removePositionListener(positionListener: PositionListener): void {
121
- this.positionListeners.delete(positionListener);
122
- }
123
-
124
- onTimelineTimestampChange(timestamp: MillisecondTimestamp): void {
125
- this.dispatchPositionForTimestamp(timestamp);
126
- }
127
-
128
- private dispatchPositionForTimestamp(
129
- timestamp: MillisecondTimestamp,
130
- listeners: PositionListener[] | Set<PositionListener> = this
131
- .positionListeners,
132
- ): void {
133
- let position: PuzzlePosition;
134
- if (this.indexer.timestampToPosition) {
135
- position = this.indexer.timestampToPosition(timestamp, this.startState);
136
- } else {
137
- const idx = this.indexer.timestampToIndex(timestamp);
138
- const state = this.indexer.stateAtIndex(
139
- idx,
140
- this.startState,
141
- ) as Transformation; // TODO
142
- position = {
143
- state,
144
- movesInProgress: [],
145
- };
146
-
147
- if (this.indexer.numAnimatedLeaves() > 0) {
148
- const move = this.indexer.getAnimLeaf(idx)?.as(Move);
149
- if (!move) {
150
- return; // TODO
151
- }
152
- const fraction =
153
- (timestamp - this.indexer.indexToMoveStartTimestamp(idx)) /
154
- this.indexer.moveDuration(idx);
155
- if (fraction === 1) {
156
- // TODO: push this into the indexer
157
- position.state = this.ksolvePuzzle.combine(
158
- state,
159
- this.ksolvePuzzle.stateFromMove(move),
160
- ) as Transformation;
161
- } else if (fraction > 0) {
162
- if (move) {
163
- position.movesInProgress.push({
164
- move,
165
- direction: Direction.Forwards,
166
- fraction,
167
- });
168
- }
169
- }
170
- }
171
- }
172
-
173
- for (const listener of listeners) {
174
- listener.onPositionChange(position);
175
- }
176
- }
177
-
178
- onTimeRangeChange(_timeRange: TimeRange): void {
179
- // nothing to do
180
- }
181
-
182
- setAlg(alg: Alg, indexerConstructor?: IndexerConstructor): void {
183
- indexerConstructor ??= this.indexerConstructor;
184
- if (
185
- alg.isIdentical(this.alg) &&
186
- this.indexerConstructor === indexerConstructor
187
- ) {
188
- // TODO: this is a hacky optimization.
189
- return;
190
- }
191
- this.indexerConstructor = indexerConstructor;
192
- this.alg = alg;
193
- this.instantiateIndexer(alg);
194
- this.timeline.onCursorChange(this);
195
- this.dispatchPositionForTimestamp(this.timeline.timestamp);
196
- // TODO: Handle state change.
197
- }
198
-
199
- moveBoundary(
200
- timestamp: MillisecondTimestamp,
201
- direction: Direction.Backwards | Direction.Forwards,
202
- ): MillisecondTimestamp | null {
203
- if (this.indexer.numAnimatedLeaves() === 0) {
204
- return null;
205
- }
206
- // TODO: define semantics of indexing edge cases and remove this hack.
207
- const offsetHack = directionScalar(direction) * 0.001;
208
- const idx = this.indexer.timestampToIndex(timestamp + offsetHack);
209
- const moveStart = this.indexer.indexToMoveStartTimestamp(idx);
210
-
211
- if (direction === Direction.Backwards) {
212
- return timestamp >= moveStart ? moveStart : null;
213
- } else {
214
- const moveEnd = moveStart + this.indexer.moveDuration(idx);
215
- return timestamp <= moveEnd ? moveEnd : null;
216
- }
217
- }
218
-
219
- setPuzzle(
220
- def: KPuzzleDefinition,
221
- alg: Alg = this.alg,
222
- startStateAlg?: Alg,
223
- ): void {
224
- this.ksolvePuzzle = new KPuzzleWrapper(def);
225
- this.def = def;
226
- this.indexer = new this.indexerConstructor(this.ksolvePuzzle, alg);
227
- if (alg !== this.alg) {
228
- this.timeline.onCursorChange(this);
229
- }
230
- this.setStartState(
231
- startStateAlg
232
- ? this.algToState(startStateAlg)
233
- : this.ksolvePuzzle.startState(),
234
- );
235
- this.alg = alg;
236
- }
237
-
238
- /** @deprecated */
239
- experimentalTimestampFromIndex(index: number): MillisecondTimestamp {
240
- return this.indexer.indexToMoveStartTimestamp(index);
241
- }
242
-
243
- /** @deprecated */
244
- experimentalIndexFromTimestamp(timestamp: MillisecondTimestamp): number {
245
- return this.indexer.timestampToIndex(timestamp);
246
- }
247
-
248
- /** @deprecated */
249
- experimentalLeafAtIndex(index: number): Move | Pause | null {
250
- return this.indexer.getAnimLeaf(index);
251
- }
252
- }
@@ -1,25 +0,0 @@
1
- import { CSSSource } from "./element/ManagedCustomElement";
2
-
3
- export const twistyAlgViewerCSS = new CSSSource(`
4
- :host {
5
- display: inline-grid;
6
- }
7
-
8
- a:not(:hover) {
9
- color: inherit;
10
- text-decoration: none;
11
- }
12
-
13
- twisty-alg-leaf-elem.twisty-alg-comment {
14
- color: rgba(0, 0, 0, 0.4);
15
- }
16
-
17
- .wrapper.current-move {
18
- background: rgba(66, 133, 244, 0.3);
19
- margin-left: -0.1em;
20
- margin-right: -0.1em;
21
- padding-left: 0.1em;
22
- padding-right: 0.1em;
23
- border-radius: 0.1em;
24
- }
25
- `);