@witchcraft/layout 1.0.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 (336) hide show
  1. package/README.md +474 -0
  2. package/dist/module.d.mts +14 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +26 -0
  5. package/dist/runtime/components/LayoutDecos.d.vue.ts +0 -0
  6. package/dist/runtime/components/LayoutDecos.vue +54 -0
  7. package/dist/runtime/components/LayoutDecos.vue.d.ts +0 -0
  8. package/dist/runtime/components/LayoutEdges.d.vue.ts +0 -0
  9. package/dist/runtime/components/LayoutEdges.vue +145 -0
  10. package/dist/runtime/components/LayoutEdges.vue.d.ts +0 -0
  11. package/dist/runtime/components/LayoutFrame.d.vue.ts +0 -0
  12. package/dist/runtime/components/LayoutFrame.vue +41 -0
  13. package/dist/runtime/components/LayoutFrame.vue.d.ts +0 -0
  14. package/dist/runtime/components/LayoutShapeSquare.d.vue.ts +0 -0
  15. package/dist/runtime/components/LayoutShapeSquare.vue +36 -0
  16. package/dist/runtime/components/LayoutShapeSquare.vue.d.ts +0 -0
  17. package/dist/runtime/components/LayoutWindow.d.vue.ts +0 -0
  18. package/dist/runtime/components/LayoutWindow.vue +183 -0
  19. package/dist/runtime/components/LayoutWindow.vue.d.ts +0 -0
  20. package/dist/runtime/composables/useFrames.d.ts +0 -0
  21. package/dist/runtime/composables/useFrames.js +184 -0
  22. package/dist/runtime/demo/App.d.vue.ts +0 -0
  23. package/dist/runtime/demo/App.vue +123 -0
  24. package/dist/runtime/demo/App.vue.d.ts +0 -0
  25. package/dist/runtime/demo/DemoControls.d.vue.ts +0 -0
  26. package/dist/runtime/demo/DemoControls.vue +14 -0
  27. package/dist/runtime/demo/DemoControls.vue.d.ts +0 -0
  28. package/dist/runtime/demo/README.md +1 -0
  29. package/dist/runtime/demo/main.d.ts +0 -0
  30. package/dist/runtime/demo/main.js +4 -0
  31. package/dist/runtime/demo/sharedLayoutInstance.d.ts +0 -0
  32. package/dist/runtime/demo/sharedLayoutInstance.js +5 -0
  33. package/dist/runtime/demo/tailwind.css +1 -0
  34. package/dist/runtime/drag/CloseAction.d.ts +0 -0
  35. package/dist/runtime/drag/CloseAction.js +121 -0
  36. package/dist/runtime/drag/DragActionHandler.d.ts +0 -0
  37. package/dist/runtime/drag/DragActionHandler.js +83 -0
  38. package/dist/runtime/drag/DragDirectionStore.d.ts +0 -0
  39. package/dist/runtime/drag/DragDirectionStore.js +45 -0
  40. package/dist/runtime/drag/SplitAction.d.ts +0 -0
  41. package/dist/runtime/drag/SplitAction.js +110 -0
  42. package/dist/runtime/drag/types.d.ts +0 -0
  43. package/dist/runtime/drag/types.js +0 -0
  44. package/dist/runtime/helpers/addPointsToIntersection.d.ts +0 -0
  45. package/dist/runtime/helpers/addPointsToIntersection.js +7 -0
  46. package/dist/runtime/helpers/assertEdgeSorted.d.ts +0 -0
  47. package/dist/runtime/helpers/assertEdgeSorted.js +7 -0
  48. package/dist/runtime/helpers/assertItemIn.d.ts +0 -0
  49. package/dist/runtime/helpers/assertItemIn.js +8 -0
  50. package/dist/runtime/helpers/assertItemNotIn.d.ts +0 -0
  51. package/dist/runtime/helpers/assertItemNotIn.js +7 -0
  52. package/dist/runtime/helpers/assertLayoutHasActiveWindow.d.ts +0 -0
  53. package/dist/runtime/helpers/assertLayoutHasActiveWindow.js +7 -0
  54. package/dist/runtime/helpers/assertValidWinAndFrame.d.ts +0 -0
  55. package/dist/runtime/helpers/assertValidWinAndFrame.js +5 -0
  56. package/dist/runtime/helpers/assertValidWinAndFrameIds.d.ts +0 -0
  57. package/dist/runtime/helpers/assertValidWinAndFrameIds.js +6 -0
  58. package/dist/runtime/helpers/assertWindowHasActiveFrame.d.ts +0 -0
  59. package/dist/runtime/helpers/assertWindowHasActiveFrame.js +7 -0
  60. package/dist/runtime/helpers/clampNumber.d.ts +0 -0
  61. package/dist/runtime/helpers/clampNumber.js +3 -0
  62. package/dist/runtime/helpers/cloneFrame.d.ts +0 -0
  63. package/dist/runtime/helpers/cloneFrame.js +3 -0
  64. package/dist/runtime/helpers/cloneFrames.d.ts +0 -0
  65. package/dist/runtime/helpers/cloneFrames.js +16 -0
  66. package/dist/runtime/helpers/containsEdge.d.ts +0 -0
  67. package/dist/runtime/helpers/containsEdge.js +13 -0
  68. package/dist/runtime/helpers/convertLayoutWindowToWorkspace.d.ts +0 -0
  69. package/dist/runtime/helpers/convertLayoutWindowToWorkspace.js +10 -0
  70. package/dist/runtime/helpers/copySize.d.ts +0 -0
  71. package/dist/runtime/helpers/copySize.js +5 -0
  72. package/dist/runtime/helpers/createEdge.d.ts +0 -0
  73. package/dist/runtime/helpers/createEdge.js +13 -0
  74. package/dist/runtime/helpers/dirToOrientation.d.ts +0 -0
  75. package/dist/runtime/helpers/dirToOrientation.js +10 -0
  76. package/dist/runtime/helpers/dirToSide.d.ts +0 -0
  77. package/dist/runtime/helpers/dirToSide.js +5 -0
  78. package/dist/runtime/helpers/doEdgesOverlap.d.ts +0 -0
  79. package/dist/runtime/helpers/doEdgesOverlap.js +22 -0
  80. package/dist/runtime/helpers/doesEdgeContinueEdge.d.ts +0 -0
  81. package/dist/runtime/helpers/doesEdgeContinueEdge.js +17 -0
  82. package/dist/runtime/helpers/edgeToPoints.d.ts +0 -0
  83. package/dist/runtime/helpers/edgeToPoints.js +3 -0
  84. package/dist/runtime/helpers/findDraggableEdge.d.ts +0 -0
  85. package/dist/runtime/helpers/findDraggableEdge.js +13 -0
  86. package/dist/runtime/helpers/findFrameDraggableEdges.d.ts +0 -0
  87. package/dist/runtime/helpers/findFrameDraggableEdges.js +18 -0
  88. package/dist/runtime/helpers/frameToEdges.d.ts +0 -0
  89. package/dist/runtime/helpers/frameToEdges.js +21 -0
  90. package/dist/runtime/helpers/frameToPoints.d.ts +0 -0
  91. package/dist/runtime/helpers/frameToPoints.js +7 -0
  92. package/dist/runtime/helpers/getEdgeOrientation.d.ts +0 -0
  93. package/dist/runtime/helpers/getEdgeOrientation.js +4 -0
  94. package/dist/runtime/helpers/getEdgeSharedDirection.d.ts +0 -0
  95. package/dist/runtime/helpers/getEdgeSharedDirection.js +7 -0
  96. package/dist/runtime/helpers/getEdgeSide.d.ts +0 -0
  97. package/dist/runtime/helpers/getEdgeSide.js +16 -0
  98. package/dist/runtime/helpers/getFrameById.d.ts +0 -0
  99. package/dist/runtime/helpers/getFrameById.js +5 -0
  100. package/dist/runtime/helpers/getFrameConstant.d.ts +0 -0
  101. package/dist/runtime/helpers/getFrameConstant.js +15 -0
  102. package/dist/runtime/helpers/getIntersections.d.ts +0 -0
  103. package/dist/runtime/helpers/getIntersections.js +63 -0
  104. package/dist/runtime/helpers/getIntersectionsCss.d.ts +0 -0
  105. package/dist/runtime/helpers/getIntersectionsCss.js +56 -0
  106. package/dist/runtime/helpers/getMoveEdgeInfo.d.ts +0 -0
  107. package/dist/runtime/helpers/getMoveEdgeInfo.js +42 -0
  108. package/dist/runtime/helpers/getResizeLimit.d.ts +0 -0
  109. package/dist/runtime/helpers/getResizeLimit.js +39 -0
  110. package/dist/runtime/helpers/getShapeSquareCss.d.ts +0 -0
  111. package/dist/runtime/helpers/getShapeSquareCss.js +17 -0
  112. package/dist/runtime/helpers/getSideTouching.d.ts +0 -0
  113. package/dist/runtime/helpers/getSideTouching.js +7 -0
  114. package/dist/runtime/helpers/getVisualEdgeCss.d.ts +0 -0
  115. package/dist/runtime/helpers/getVisualEdgeCss.js +40 -0
  116. package/dist/runtime/helpers/getVisualEdges.d.ts +0 -0
  117. package/dist/runtime/helpers/getVisualEdges.js +89 -0
  118. package/dist/runtime/helpers/getVisualEdgesCss.d.ts +0 -0
  119. package/dist/runtime/helpers/getVisualEdgesCss.js +4 -0
  120. package/dist/runtime/helpers/getWinAndFrameById.d.ts +0 -0
  121. package/dist/runtime/helpers/getWinAndFrameById.js +14 -0
  122. package/dist/runtime/helpers/getWinByFrameUuid.d.ts +0 -0
  123. package/dist/runtime/helpers/getWinByFrameUuid.js +13 -0
  124. package/dist/runtime/helpers/getWinById.d.ts +0 -0
  125. package/dist/runtime/helpers/getWinById.js +5 -0
  126. package/dist/runtime/helpers/getWindowConstant.d.ts +0 -0
  127. package/dist/runtime/helpers/getWindowConstant.js +14 -0
  128. package/dist/runtime/helpers/inRange.d.ts +0 -0
  129. package/dist/runtime/helpers/inRange.js +3 -0
  130. package/dist/runtime/helpers/index.d.ts +0 -0
  131. package/dist/runtime/helpers/index.js +62 -0
  132. package/dist/runtime/helpers/isEdgeEqual.d.ts +0 -0
  133. package/dist/runtime/helpers/isEdgeEqual.js +11 -0
  134. package/dist/runtime/helpers/isEdgeParallel.d.ts +0 -0
  135. package/dist/runtime/helpers/isEdgeParallel.js +7 -0
  136. package/dist/runtime/helpers/isPointEqual.d.ts +0 -0
  137. package/dist/runtime/helpers/isPointEqual.js +3 -0
  138. package/dist/runtime/helpers/isSizeAboveMin.d.ts +0 -0
  139. package/dist/runtime/helpers/isSizeAboveMin.js +3 -0
  140. package/dist/runtime/helpers/isSizeEqual.d.ts +0 -0
  141. package/dist/runtime/helpers/isSizeEqual.js +3 -0
  142. package/dist/runtime/helpers/isWindowEdge.d.ts +0 -0
  143. package/dist/runtime/helpers/isWindowEdge.js +7 -0
  144. package/dist/runtime/helpers/isWindowEdgePoint.d.ts +0 -0
  145. package/dist/runtime/helpers/isWindowEdgePoint.js +5 -0
  146. package/dist/runtime/helpers/moveEdge.d.ts +0 -0
  147. package/dist/runtime/helpers/moveEdge.js +8 -0
  148. package/dist/runtime/helpers/numberToScaledPercent.d.ts +0 -0
  149. package/dist/runtime/helpers/numberToScaledPercent.js +5 -0
  150. package/dist/runtime/helpers/numberToScaledSize.d.ts +0 -0
  151. package/dist/runtime/helpers/numberToScaledSize.js +19 -0
  152. package/dist/runtime/helpers/oppositeSide.d.ts +0 -0
  153. package/dist/runtime/helpers/oppositeSide.js +30 -0
  154. package/dist/runtime/helpers/resizeByEdge.d.ts +0 -0
  155. package/dist/runtime/helpers/resizeByEdge.js +29 -0
  156. package/dist/runtime/helpers/sideToDirection.d.ts +0 -0
  157. package/dist/runtime/helpers/sideToDirection.js +11 -0
  158. package/dist/runtime/helpers/sideToOrientation.d.ts +0 -0
  159. package/dist/runtime/helpers/sideToOrientation.js +10 -0
  160. package/dist/runtime/helpers/splitEdge.d.ts +0 -0
  161. package/dist/runtime/helpers/splitEdge.js +20 -0
  162. package/dist/runtime/helpers/toCoord.d.ts +0 -0
  163. package/dist/runtime/helpers/toCoord.js +10 -0
  164. package/dist/runtime/helpers/toId.d.ts +0 -0
  165. package/dist/runtime/helpers/toId.js +4 -0
  166. package/dist/runtime/helpers/toWindowCoord.d.ts +0 -0
  167. package/dist/runtime/helpers/toWindowCoord.js +14 -0
  168. package/dist/runtime/helpers/unionEdges.d.ts +0 -0
  169. package/dist/runtime/helpers/unionEdges.js +8 -0
  170. package/dist/runtime/helpers/updateWindowSizeWithEvent.d.ts +0 -0
  171. package/dist/runtime/helpers/updateWindowSizeWithEvent.js +8 -0
  172. package/dist/runtime/index.d.ts +0 -0
  173. package/dist/runtime/index.js +5 -0
  174. package/dist/runtime/layout/closeFrame.d.ts +0 -0
  175. package/dist/runtime/layout/closeFrame.js +13 -0
  176. package/dist/runtime/layout/closeFrames.d.ts +0 -0
  177. package/dist/runtime/layout/closeFrames.js +8 -0
  178. package/dist/runtime/layout/createSplitDecoEdge.d.ts +0 -0
  179. package/dist/runtime/layout/createSplitDecoEdge.js +24 -0
  180. package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +0 -0
  181. package/dist/runtime/layout/createSplitDecoFromDrag.js +14 -0
  182. package/dist/runtime/layout/debugFrame.d.ts +0 -0
  183. package/dist/runtime/layout/debugFrame.js +4 -0
  184. package/dist/runtime/layout/findFramesTouchingEdge.d.ts +0 -0
  185. package/dist/runtime/layout/findFramesTouchingEdge.js +33 -0
  186. package/dist/runtime/layout/findSafeSplitEdge.d.ts +0 -0
  187. package/dist/runtime/layout/findSafeSplitEdge.js +20 -0
  188. package/dist/runtime/layout/findVisualEdge.d.ts +0 -0
  189. package/dist/runtime/layout/findVisualEdge.js +9 -0
  190. package/dist/runtime/layout/frameCreate.d.ts +0 -0
  191. package/dist/runtime/layout/frameCreate.js +13 -0
  192. package/dist/runtime/layout/frameSplit.d.ts +0 -0
  193. package/dist/runtime/layout/frameSplit.js +9 -0
  194. package/dist/runtime/layout/getCloseFrameInfo.d.ts +0 -0
  195. package/dist/runtime/layout/getCloseFrameInfo.js +103 -0
  196. package/dist/runtime/layout/getFrameSplitInfo.d.ts +0 -0
  197. package/dist/runtime/layout/getFrameSplitInfo.js +40 -0
  198. package/dist/runtime/layout/getFrameTo.d.ts +0 -0
  199. package/dist/runtime/layout/getFrameTo.js +47 -0
  200. package/dist/runtime/layout/index.d.ts +0 -0
  201. package/dist/runtime/layout/index.js +22 -0
  202. package/dist/runtime/layout/isPointInFrame.d.ts +0 -0
  203. package/dist/runtime/layout/isPointInFrame.js +4 -0
  204. package/dist/runtime/layout/layoutAddWindow.d.ts +0 -0
  205. package/dist/runtime/layout/layoutAddWindow.js +4 -0
  206. package/dist/runtime/layout/layoutCreate.d.ts +0 -0
  207. package/dist/runtime/layout/layoutCreate.js +7 -0
  208. package/dist/runtime/layout/layoutRemoveWindow.d.ts +0 -0
  209. package/dist/runtime/layout/layoutRemoveWindow.js +5 -0
  210. package/dist/runtime/layout/resizeFrame.d.ts +0 -0
  211. package/dist/runtime/layout/resizeFrame.js +69 -0
  212. package/dist/runtime/layout/windowAddFrame.d.ts +0 -0
  213. package/dist/runtime/layout/windowAddFrame.js +4 -0
  214. package/dist/runtime/layout/windowCreate.d.ts +0 -0
  215. package/dist/runtime/layout/windowCreate.js +13 -0
  216. package/dist/runtime/layout/windowRemoveFrame.d.ts +0 -0
  217. package/dist/runtime/layout/windowRemoveFrame.js +5 -0
  218. package/dist/runtime/layout/windowSetActiveFrame.d.ts +0 -0
  219. package/dist/runtime/layout/windowSetActiveFrame.js +5 -0
  220. package/dist/runtime/settings.d.ts +0 -0
  221. package/dist/runtime/settings.js +54 -0
  222. package/dist/runtime/types/index.d.ts +0 -0
  223. package/dist/runtime/types/index.js +120 -0
  224. package/dist/runtime/utils/KnownError.d.ts +0 -0
  225. package/dist/runtime/utils/KnownError.js +9 -0
  226. package/dist/types.d.mts +5 -0
  227. package/package.json +153 -0
  228. package/src/module.ts +43 -0
  229. package/src/runtime/components/LayoutDecos.vue +62 -0
  230. package/src/runtime/components/LayoutEdges.vue +172 -0
  231. package/src/runtime/components/LayoutFrame.vue +47 -0
  232. package/src/runtime/components/LayoutShapeSquare.vue +38 -0
  233. package/src/runtime/components/LayoutWindow.vue +223 -0
  234. package/src/runtime/composables/useFrames.ts +251 -0
  235. package/src/runtime/demo/App.vue +140 -0
  236. package/src/runtime/demo/DemoControls.vue +17 -0
  237. package/src/runtime/demo/README.md +1 -0
  238. package/src/runtime/demo/main.ts +9 -0
  239. package/src/runtime/demo/sharedLayoutInstance.ts +7 -0
  240. package/src/runtime/demo/tailwind.css +4 -0
  241. package/src/runtime/drag/CloseAction.ts +158 -0
  242. package/src/runtime/drag/DragActionHandler.ts +146 -0
  243. package/src/runtime/drag/DragDirectionStore.ts +63 -0
  244. package/src/runtime/drag/SplitAction.ts +147 -0
  245. package/src/runtime/drag/types.ts +107 -0
  246. package/src/runtime/helpers/addPointsToIntersection.ts +9 -0
  247. package/src/runtime/helpers/assertEdgeSorted.ts +11 -0
  248. package/src/runtime/helpers/assertItemIn.ts +13 -0
  249. package/src/runtime/helpers/assertItemNotIn.ts +10 -0
  250. package/src/runtime/helpers/assertLayoutHasActiveWindow.ts +9 -0
  251. package/src/runtime/helpers/assertValidWinAndFrame.ts +16 -0
  252. package/src/runtime/helpers/assertValidWinAndFrameIds.ts +9 -0
  253. package/src/runtime/helpers/assertWindowHasActiveFrame.ts +9 -0
  254. package/src/runtime/helpers/clampNumber.ts +9 -0
  255. package/src/runtime/helpers/cloneFrame.ts +5 -0
  256. package/src/runtime/helpers/cloneFrames.ts +20 -0
  257. package/src/runtime/helpers/containsEdge.ts +16 -0
  258. package/src/runtime/helpers/convertLayoutWindowToWorkspace.ts +18 -0
  259. package/src/runtime/helpers/copySize.ts +7 -0
  260. package/src/runtime/helpers/createEdge.ts +19 -0
  261. package/src/runtime/helpers/dirToOrientation.ts +12 -0
  262. package/src/runtime/helpers/dirToSide.ts +7 -0
  263. package/src/runtime/helpers/doEdgesOverlap.ts +25 -0
  264. package/src/runtime/helpers/doesEdgeContinueEdge.ts +20 -0
  265. package/src/runtime/helpers/edgeToPoints.ts +5 -0
  266. package/src/runtime/helpers/findDraggableEdge.ts +24 -0
  267. package/src/runtime/helpers/findFrameDraggableEdges.ts +32 -0
  268. package/src/runtime/helpers/frameToEdges.ts +32 -0
  269. package/src/runtime/helpers/frameToPoints.ts +14 -0
  270. package/src/runtime/helpers/getEdgeOrientation.ts +6 -0
  271. package/src/runtime/helpers/getEdgeSharedDirection.ts +10 -0
  272. package/src/runtime/helpers/getEdgeSide.ts +27 -0
  273. package/src/runtime/helpers/getFrameById.ts +15 -0
  274. package/src/runtime/helpers/getFrameConstant.ts +22 -0
  275. package/src/runtime/helpers/getIntersections.ts +87 -0
  276. package/src/runtime/helpers/getIntersectionsCss.ts +65 -0
  277. package/src/runtime/helpers/getMoveEdgeInfo.ts +69 -0
  278. package/src/runtime/helpers/getResizeLimit.ts +60 -0
  279. package/src/runtime/helpers/getShapeSquareCss.ts +28 -0
  280. package/src/runtime/helpers/getSideTouching.ts +9 -0
  281. package/src/runtime/helpers/getVisualEdgeCss.ts +53 -0
  282. package/src/runtime/helpers/getVisualEdges.ts +155 -0
  283. package/src/runtime/helpers/getVisualEdgesCss.ts +13 -0
  284. package/src/runtime/helpers/getWinAndFrameById.ts +28 -0
  285. package/src/runtime/helpers/getWinByFrameUuid.ts +19 -0
  286. package/src/runtime/helpers/getWinById.ts +12 -0
  287. package/src/runtime/helpers/getWindowConstant.ts +21 -0
  288. package/src/runtime/helpers/inRange.ts +5 -0
  289. package/src/runtime/helpers/index.ts +64 -0
  290. package/src/runtime/helpers/isEdgeEqual.ts +14 -0
  291. package/src/runtime/helpers/isEdgeParallel.ts +10 -0
  292. package/src/runtime/helpers/isPointEqual.ts +5 -0
  293. package/src/runtime/helpers/isSizeAboveMin.ts +8 -0
  294. package/src/runtime/helpers/isSizeEqual.ts +5 -0
  295. package/src/runtime/helpers/isWindowEdge.ts +11 -0
  296. package/src/runtime/helpers/isWindowEdgePoint.ts +8 -0
  297. package/src/runtime/helpers/moveEdge.ts +21 -0
  298. package/src/runtime/helpers/numberToScaledPercent.ts +19 -0
  299. package/src/runtime/helpers/numberToScaledSize.ts +28 -0
  300. package/src/runtime/helpers/oppositeSide.ts +45 -0
  301. package/src/runtime/helpers/resizeByEdge.ts +45 -0
  302. package/src/runtime/helpers/sideToDirection.ts +15 -0
  303. package/src/runtime/helpers/sideToOrientation.ts +12 -0
  304. package/src/runtime/helpers/splitEdge.ts +23 -0
  305. package/src/runtime/helpers/toCoord.ts +13 -0
  306. package/src/runtime/helpers/toId.ts +9 -0
  307. package/src/runtime/helpers/toWindowCoord.ts +23 -0
  308. package/src/runtime/helpers/unionEdges.ts +11 -0
  309. package/src/runtime/helpers/updateWindowSizeWithEvent.ts +10 -0
  310. package/src/runtime/index.ts +5 -0
  311. package/src/runtime/layout/closeFrame.ts +33 -0
  312. package/src/runtime/layout/closeFrames.ts +14 -0
  313. package/src/runtime/layout/createSplitDecoEdge.ts +34 -0
  314. package/src/runtime/layout/createSplitDecoFromDrag.ts +24 -0
  315. package/src/runtime/layout/debugFrame.ts +6 -0
  316. package/src/runtime/layout/findFramesTouchingEdge.ts +92 -0
  317. package/src/runtime/layout/findSafeSplitEdge.ts +39 -0
  318. package/src/runtime/layout/findVisualEdge.ts +11 -0
  319. package/src/runtime/layout/frameCreate.ts +23 -0
  320. package/src/runtime/layout/frameSplit.ts +31 -0
  321. package/src/runtime/layout/getCloseFrameInfo.ts +193 -0
  322. package/src/runtime/layout/getFrameSplitInfo.ts +65 -0
  323. package/src/runtime/layout/getFrameTo.ts +65 -0
  324. package/src/runtime/layout/index.ts +24 -0
  325. package/src/runtime/layout/isPointInFrame.ts +7 -0
  326. package/src/runtime/layout/layoutAddWindow.ts +6 -0
  327. package/src/runtime/layout/layoutCreate.ts +12 -0
  328. package/src/runtime/layout/layoutRemoveWindow.ts +7 -0
  329. package/src/runtime/layout/resizeFrame.ts +106 -0
  330. package/src/runtime/layout/windowAddFrame.ts +10 -0
  331. package/src/runtime/layout/windowCreate.ts +18 -0
  332. package/src/runtime/layout/windowRemoveFrame.ts +7 -0
  333. package/src/runtime/layout/windowSetActiveFrame.ts +7 -0
  334. package/src/runtime/settings.ts +63 -0
  335. package/src/runtime/types/index.ts +293 -0
  336. package/src/runtime/utils/KnownError.ts +24 -0
@@ -0,0 +1,123 @@
1
+ <template>
2
+ <WRoot class="gap-2 p-2">
3
+ <DemoControls
4
+ :frames="frames"
5
+ />
6
+ <LayoutWindow v-if="win"
7
+ class="
8
+ flex-1 w-full
9
+ border-1
10
+ border-neutral-300
11
+ dark:border-neutral-700
12
+ rounded-md
13
+ flex-1
14
+ self-stretch
15
+ [&_.frame]:flex
16
+ [&_.frame]:flex-col
17
+ [&_.frame]:outline-hidden
18
+ [&_.active-frame-edge]:rounded-md
19
+ [&_.active-frame-edge]:border-none
20
+ [&_.drag-edge:hover+.edge]:bg-accent-500/20
21
+ [&_.grabbed-edge]:bg-accent-500
22
+ [&.request-split_.grabbed-edge]:hidden
23
+ [&.request-split_.drag-edge]:hidden
24
+ [&_.deco-split-new-frame]:rounded-md
25
+ [&_.deco-close-frame]:rounded-md
26
+ [&_.deco-close-frame]:bg-orange-500/50
27
+ "
28
+ :usage-instructions="usageInstructions"
29
+ instructions-teleport-to="#status-bar"
30
+ :win="win"
31
+ @is-showing-drag="isShowingDrag = $event"
32
+ @drag-state="dragState = $event"
33
+ @resize="win.pxWidth = $event.width;
34
+ win.pxHeight = $event.height"
35
+ >
36
+ <template #[`frame-${f.id}`] v-for="f in frames" :key="f.id">
37
+ <div
38
+ :data-is-active="win.activeFrame === f.id"
39
+ :class="twMerge(
40
+ `
41
+ border-2
42
+ border-neutral-500
43
+ h-full
44
+ rounded-md
45
+ overflow-auto
46
+ `,
47
+ win.activeFrame === f.id && `border-blue-500`
48
+ )"
49
+ @click="win.activeFrame = f.id"
50
+ >
51
+ <!--
52
+ Avoid placing the padding on the first div in the frame.
53
+ Set it on the first child instead, so that the frame can shrink as small as possible.
54
+ Too big a border can also be a problem, but usually it's small enough that it's beneath the min frame width/height allowed.
55
+ -->
56
+ <div class="p-2"> {{ debugFrame(f) }} </div>
57
+ </div>
58
+ </template>
59
+ </LayoutWindow>
60
+ </Wroot>
61
+ </template>
62
+
63
+ <script setup>
64
+ import { keys } from "@alanscodelog/utils/keys";
65
+ import WRoot from "@witchcraft/ui/components/LibRoot";
66
+ import { twMerge } from "@witchcraft/ui/utils/twMerge";
67
+ import { computed, onBeforeMount, ref } from "vue";
68
+ import DemoControls from "./DemoControls.vue";
69
+ import { app } from "./sharedLayoutInstance.js";
70
+ import LayoutWindow from "../components/LayoutWindow.vue";
71
+ import { debugFrame } from "../layout/debugFrame.js";
72
+ import {
73
+ frameCreate,
74
+ layoutAddWindow,
75
+ windowAddFrame,
76
+ windowCreate
77
+ } from "../layout/index.js";
78
+ import { getMaxInt } from "../settings.js";
79
+ import {} from "../types/index.js";
80
+ const winId = ref(void 0);
81
+ const win = computed(() => winId.value !== void 0 ? app.layout.windows[winId.value] : void 0);
82
+ const frames = computed(() => {
83
+ if (!win.value) return;
84
+ return Object.values(win.value.frames);
85
+ });
86
+ onBeforeMount(() => {
87
+ layoutInitialize(app.layout);
88
+ winId.value = keys(app.layout.windows)[0];
89
+ });
90
+ const isDragging = ref(false);
91
+ function layoutInitialize(layout, { defaultPos, defaultSize } = {
92
+ defaultPos: { x: 0, y: 0 },
93
+ defaultSize: { width: 0, height: 0 }
94
+ }) {
95
+ const w = layoutAddWindow(
96
+ layout,
97
+ windowCreate({
98
+ ...defaultPos,
99
+ ...defaultSize,
100
+ frames: {}
101
+ })
102
+ );
103
+ layout.activeWindow = w.id;
104
+ const max = getMaxInt();
105
+ const frame = windowAddFrame(w, frameCreate({
106
+ x: 0,
107
+ y: 0,
108
+ width: max,
109
+ height: max
110
+ }));
111
+ w.activeFrame = frame.id;
112
+ }
113
+ const isShowingDrag = ref(false);
114
+ const dragState = ref(void 0);
115
+ const usageInstructions = computed(() => ({
116
+ // names are arbitrary and don't mean anything, they just make things easier
117
+ // if a key is undefined, it's ignored
118
+ none: !dragState.value?.isDragging ? "Drag from an edge to create a new frame." : void 0,
119
+ split: dragState.value?.isDragging ? "Hold Alt to Split" : void 0,
120
+ close: dragState.value?.isDragging ? "Shift+Drag to Close" : void 0,
121
+ forceClose: dragState.value?.isDragging ? "Ctrl+Shift+Drag to Force Close" : void 0
122
+ }));
123
+ </script>
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <div class="border-2 border-neutral-500 p-2 rounded-md flex">
3
+ <div class="">Instruction/status bar:</div>
4
+ <div id="status-bar" class="px-2 flex-1 overflow-x-auto scrollbar-hidden"/>
5
+ <WDarkModeSwitcher :show-label="false"/>
6
+ </div>
7
+ </template>
8
+
9
+ <script setup>
10
+ import WDarkModeSwitcher from "@witchcraft/ui/components/LibDarkModeSwitcher";
11
+ defineProps({
12
+ frames: { type: Array, required: true }
13
+ });
14
+ </script>
File without changes
@@ -0,0 +1 @@
1
+ This is structured like this so we can check the demo is both buildable from nuxt and vite.
File without changes
@@ -0,0 +1,4 @@
1
+ import "./tailwind.css";
2
+ import { createApp } from "vue";
3
+ import App from "./App.vue";
4
+ createApp(App).mount("#app");
File without changes
@@ -0,0 +1,5 @@
1
+ import { reactive } from "vue";
2
+ import { layoutCreate } from "../layout/layoutCreate.js";
3
+ export const app = reactive({
4
+ layout: layoutCreate()
5
+ });
@@ -0,0 +1 @@
1
+ @import "tailwindcss" source("../");@import "../../../playground/.nuxt/witchcraft-ui.css";@import "../../../playground/.nuxt/witchcraft-layout.css";
File without changes
@@ -0,0 +1,121 @@
1
+ import { dirToOrientation } from "../helpers/dirToOrientation.js";
2
+ import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js";
3
+ import { oppositeSide } from "../helpers/oppositeSide.js";
4
+ import { closeFrames } from "../layout/closeFrames.js";
5
+ import { findFramesTouchingEdge } from "../layout/findFramesTouchingEdge.js";
6
+ import { getCloseFrameInfo } from "../layout/getCloseFrameInfo.js";
7
+ export class CloseAction {
8
+ name = "close";
9
+ state = {};
10
+ // this is initialized by this.reset()
11
+ handleEvent;
12
+ updateCloseDecos;
13
+ hooks;
14
+ constructor(handleEvent, updateCloseDecos, hooks = {}) {
15
+ this.handleEvent = handleEvent;
16
+ this.updateCloseDecos = updateCloseDecos;
17
+ this.hooks = hooks;
18
+ this.reset();
19
+ }
20
+ reset() {
21
+ this.state = {
22
+ allowed: false,
23
+ force: false,
24
+ res: void 0,
25
+ cacheKey: void 0
26
+ };
27
+ this.updateCloseDecos([]);
28
+ }
29
+ updateDecos(state) {
30
+ const {
31
+ isDragging
32
+ } = state;
33
+ if (isDragging && this.state.allowed && this.state.res) {
34
+ const { force } = this.state;
35
+ const decos = this.state.res.deletedFrames.map((_) => ({ id: _.id, type: "close", force }));
36
+ this.updateCloseDecos(decos);
37
+ } else {
38
+ this.updateCloseDecos([]);
39
+ }
40
+ }
41
+ canHandleRequest(e, state) {
42
+ const { draggingEdges } = state;
43
+ if (draggingEdges.length !== 1) return false;
44
+ const res = this.handleEvent(e, state);
45
+ if (res === "force") {
46
+ this.state.force = true;
47
+ } else {
48
+ this.state.force = false;
49
+ }
50
+ if (res) {
51
+ this.hooks.onStart?.(true);
52
+ return true;
53
+ }
54
+ this.reset();
55
+ return false;
56
+ }
57
+ onDragChange(_type, _e, state) {
58
+ const {
59
+ touchingFramesArrays,
60
+ dragDirections,
61
+ isDragging,
62
+ draggingEdges,
63
+ visualEdges,
64
+ frames,
65
+ isDraggingFromWindowEdge
66
+ } = state;
67
+ const oppositeOrientation = oppositeSide(getEdgeOrientation(draggingEdges[0]));
68
+ let ok = false;
69
+ if (isDragging && draggingEdges.length === 1) {
70
+ const res = findFramesTouchingEdge(
71
+ draggingEdges[0],
72
+ touchingFramesArrays[0],
73
+ {
74
+ // referencePoint: dragPoint.value, // if force pick smallest frame?
75
+ searchDirections: [dragDirections[oppositeOrientation]]
76
+ }
77
+ );
78
+ if (res.length > 0) {
79
+ const orientation = dirToOrientation(dragDirections[oppositeOrientation]);
80
+ const sizeKey = orientation === "horizontal" ? "width" : "height";
81
+ const smallestFrameSize = Math.min(...res.map((_) => _.frame[sizeKey]));
82
+ const frame = res.find((_) => _.frame[sizeKey] === smallestFrameSize).frame;
83
+ const cacheKey = `${frame.id}-${dragDirections[oppositeOrientation]}`;
84
+ if (this.state.allowed) {
85
+ if (this.state.cacheKey === cacheKey) {
86
+ this.updateDecos(state);
87
+ return true;
88
+ }
89
+ }
90
+ const closeInfo = getCloseFrameInfo(Object.values(frames), visualEdges, frame, dragDirections[oppositeOrientation], "dir", this.state.force);
91
+ if (!(closeInfo instanceof Error)) {
92
+ this.state.allowed = true;
93
+ this.state.res = closeInfo;
94
+ this.state.cacheKey = cacheKey;
95
+ ok = true;
96
+ } else {
97
+ this.hooks.onError?.(closeInfo);
98
+ }
99
+ }
100
+ }
101
+ this.updateDecos(state);
102
+ if (!ok) {
103
+ this.state.allowed = false;
104
+ }
105
+ return !isDraggingFromWindowEdge;
106
+ }
107
+ onDragApply(state) {
108
+ if (this.state.res) {
109
+ const { deletedFrames, modifiedFrames } = this.state.res;
110
+ const win = state.win;
111
+ closeFrames(win, deletedFrames, modifiedFrames);
112
+ this.reset();
113
+ return true;
114
+ }
115
+ return false;
116
+ }
117
+ cancel() {
118
+ this.reset();
119
+ this.hooks.onCancel?.();
120
+ }
121
+ }
File without changes
@@ -0,0 +1,83 @@
1
+ export class DragActionHandler {
2
+ activeAction;
3
+ actions;
4
+ eventCanceller = void 0;
5
+ boundCancel;
6
+ defaultOnDragChange;
7
+ hooks;
8
+ constructor(defaultOnDragChange, actions, hooks = {}) {
9
+ this.defaultOnDragChange = defaultOnDragChange;
10
+ this.hooks = hooks;
11
+ this.actions = {};
12
+ for (const action of actions) {
13
+ this.actions[action.name] = action;
14
+ }
15
+ this.boundCancel = this.cancel.bind(this);
16
+ }
17
+ eventHandler(e, state, forceRecalculateEdges) {
18
+ if (state.isDragging) {
19
+ e.preventDefault();
20
+ }
21
+ let cancelled = false;
22
+ this.hooks.onEvent?.(e, () => {
23
+ cancelled = true;
24
+ this.cancel();
25
+ });
26
+ if (cancelled) return;
27
+ let found = false;
28
+ const oldActiveAction = this.activeAction;
29
+ for (const action of Object.values(this.actions)) {
30
+ if (action.canHandleRequest(e, state, forceRecalculateEdges)) {
31
+ found = true;
32
+ this.activeAction = action.name;
33
+ break;
34
+ }
35
+ }
36
+ if (!found) {
37
+ this.activeAction = void 0;
38
+ }
39
+ if (oldActiveAction !== this.activeAction) {
40
+ if (oldActiveAction) {
41
+ this.actions[oldActiveAction].cancel();
42
+ }
43
+ this.hooks.onRequestChange?.(this.activeAction);
44
+ }
45
+ if (state.isDragging) {
46
+ forceRecalculateEdges();
47
+ this.hooks.onRecalculate?.();
48
+ }
49
+ return void 0;
50
+ }
51
+ onDragChange(type, e, state, forceRecalculateEdges, cancel) {
52
+ if (type === "start") {
53
+ this.eventCanceller = cancel;
54
+ state.isDragging = true;
55
+ this.eventHandler(e, state, forceRecalculateEdges);
56
+ }
57
+ if (type === "end") {
58
+ state.isDragging = false;
59
+ this.activeAction = void 0;
60
+ }
61
+ if (this.activeAction) {
62
+ return this.actions[this.activeAction].onDragChange(type, e, state, forceRecalculateEdges, this.boundCancel);
63
+ }
64
+ return this.defaultOnDragChange(type, e, state, forceRecalculateEdges, this.boundCancel);
65
+ }
66
+ onDragApply(state, forceRecalculateEdges) {
67
+ if (this.activeAction) {
68
+ const res = this.actions[this.activeAction].onDragApply(state, forceRecalculateEdges);
69
+ this.hooks.onEnd?.({ cancelled: false, applied: res });
70
+ return false;
71
+ }
72
+ this.hooks.onEnd?.({ cancelled: false, applied: false });
73
+ return true;
74
+ }
75
+ cancel() {
76
+ if (this.activeAction) {
77
+ this.actions[this.activeAction].cancel();
78
+ }
79
+ this.activeAction = void 0;
80
+ this.eventCanceller?.();
81
+ this.hooks.onEnd?.({ cancelled: true, applied: false });
82
+ }
83
+ }
File without changes
@@ -0,0 +1,45 @@
1
+ export class DragDirectionStore {
2
+ hooks;
3
+ constructor(hooks) {
4
+ this.hooks = hooks;
5
+ }
6
+ lastPoint;
7
+ dragDirection = {};
8
+ lesser = {
9
+ x: "left",
10
+ y: "up"
11
+ };
12
+ greater = {
13
+ x: "right",
14
+ y: "down"
15
+ };
16
+ reset() {
17
+ this.lastPoint = void 0;
18
+ this.dragDirection = {};
19
+ }
20
+ update(point) {
21
+ const newXDirection = this.getDragDirection("x", point);
22
+ const newYDirection = this.getDragDirection("y", point);
23
+ let changed = false;
24
+ if (newXDirection) {
25
+ this.dragDirection.horizontal = newXDirection;
26
+ }
27
+ if (newYDirection) {
28
+ this.dragDirection.vertical = newYDirection;
29
+ }
30
+ if (this.lastPoint?.x !== point.x || this.lastPoint?.y !== point.y) {
31
+ this.lastPoint = point;
32
+ changed = true;
33
+ }
34
+ if (!changed) return false;
35
+ this.hooks.onUpdate(this.dragDirection);
36
+ return true;
37
+ }
38
+ getDragDirection(coord, point) {
39
+ if (!this.lastPoint) return false;
40
+ const diff = point[coord] - this.lastPoint[coord];
41
+ if (diff > 0) return this.greater[coord];
42
+ if (diff < 0) return this.lesser[coord];
43
+ return false;
44
+ }
45
+ }
File without changes
@@ -0,0 +1,110 @@
1
+ import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js";
2
+ import { oppositeSide } from "../helpers/oppositeSide.js";
3
+ import { createSplitDecoFromDrag } from "../layout/createSplitDecoFromDrag.js";
4
+ import { frameSplit } from "../layout/frameSplit.js";
5
+ import { getFrameSplitInfo } from "../layout/getFrameSplitInfo.js";
6
+ export class SplitAction {
7
+ name = "split";
8
+ state = {};
9
+ // this is initialized by `this.reset()`
10
+ handleEvent;
11
+ updateSplitDecos;
12
+ hooks;
13
+ constructor(handleEvent, updateSplitDecos, hooks = {}) {
14
+ this.handleEvent = handleEvent;
15
+ this.updateSplitDecos = updateSplitDecos;
16
+ this.hooks = hooks;
17
+ this.reset();
18
+ }
19
+ reset() {
20
+ this.state = {
21
+ allowed: false,
22
+ res: void 0,
23
+ cacheKey: void 0
24
+ };
25
+ this.updateSplitDecos([]);
26
+ }
27
+ updateDecos(state) {
28
+ const {
29
+ win,
30
+ isDragging,
31
+ dragHoveredFrame,
32
+ dragDirections,
33
+ draggingEdges,
34
+ dragPoint
35
+ } = state;
36
+ if (isDragging && this.state.allowed && dragHoveredFrame && draggingEdges.length === 1) {
37
+ const oppositeOrientation = oppositeSide(getEdgeOrientation(draggingEdges[0]));
38
+ const deco = createSplitDecoFromDrag(
39
+ win.frames,
40
+ dragHoveredFrame,
41
+ dragDirections[oppositeOrientation],
42
+ dragPoint
43
+ );
44
+ this.updateSplitDecos([deco]);
45
+ } else {
46
+ this.updateSplitDecos([]);
47
+ }
48
+ }
49
+ canHandleRequest(e, state) {
50
+ const { draggingEdges } = state;
51
+ if (draggingEdges.length !== 1) return false;
52
+ if (this.handleEvent(e, state)) {
53
+ this.hooks.onStart?.();
54
+ return true;
55
+ }
56
+ this.reset();
57
+ return false;
58
+ }
59
+ calculateSplitRequest(state) {
60
+ const {
61
+ dragHoveredFrame,
62
+ dragDirections,
63
+ draggingEdges,
64
+ dragPoint
65
+ } = state;
66
+ const oppositeOrientation = oppositeSide(getEdgeOrientation(draggingEdges[0]));
67
+ const canSplit = getFrameSplitInfo(
68
+ dragHoveredFrame,
69
+ dragDirections[oppositeOrientation],
70
+ dragPoint
71
+ );
72
+ if (!(canSplit instanceof Error)) {
73
+ this.state.allowed = true;
74
+ this.state.res = canSplit;
75
+ this.state.cacheKey = dragHoveredFrame?.id;
76
+ return true;
77
+ } else {
78
+ this.hooks.onError?.(canSplit);
79
+ return false;
80
+ }
81
+ }
82
+ onDragChange(_type, _e, state) {
83
+ const { dragHoveredFrame } = state;
84
+ let ok = false;
85
+ if (dragHoveredFrame) {
86
+ if (this.state.cacheKey === dragHoveredFrame.id) {
87
+ this.updateDecos(state);
88
+ return true;
89
+ }
90
+ ok = this.calculateSplitRequest(state);
91
+ }
92
+ this.updateDecos(state);
93
+ if (!ok) {
94
+ this.state.allowed = false;
95
+ }
96
+ return true;
97
+ }
98
+ onDragApply(state) {
99
+ if (this.state.res) {
100
+ this.calculateSplitRequest(state);
101
+ frameSplit(state.win, this.state.res);
102
+ }
103
+ this.reset();
104
+ return true;
105
+ }
106
+ cancel() {
107
+ this.reset();
108
+ this.hooks.onCancel?.();
109
+ }
110
+ }
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ export function addPointsToIntersection(intersections, points) {
2
+ for (const point of points) {
3
+ intersections[point.x] ??= {};
4
+ intersections[point.x][point.y] ??= 0;
5
+ intersections[point.x][point.y]++;
6
+ }
7
+ }
File without changes
@@ -0,0 +1,7 @@
1
+ import { getEdgeOrientation } from "./getEdgeOrientation.js";
2
+ export function assertEdgeSorted(edge) {
3
+ const dir = getEdgeOrientation(edge);
4
+ if (dir === "horizontal" && edge.startX > edge.endX || dir === "vertical" && edge.startY > edge.endY) {
5
+ throw new Error("Edge start/end is revered.");
6
+ }
7
+ }
File without changes
@@ -0,0 +1,8 @@
1
+ import { LAYOUT_ERROR } from "../types/index.js";
2
+ import { KnownError } from "../utils/KnownError.js";
3
+ export function assertItemIn(entries, id) {
4
+ if (id === void 0 || entries[id] === void 0) {
5
+ const message = id === void 0 ? `Id cannot be undefined.` : `Could not find item by that id (${id}).`;
6
+ throw new KnownError(LAYOUT_ERROR.INVALID_ID, message, { id });
7
+ }
8
+ }
File without changes
@@ -0,0 +1,7 @@
1
+ import { LAYOUT_ERROR } from "../types/index.js";
2
+ import { KnownError } from "../utils/KnownError.js";
3
+ export function assertItemNotIn(entries, id) {
4
+ if (id !== void 0 && entries[id] !== void 0) {
5
+ throw new KnownError(LAYOUT_ERROR.ID_ALREADY_EXISTS, `Item with id ${id} already exists`, { id });
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ import { LAYOUT_ERROR } from "../types/index.js";
2
+ import { KnownError } from "../utils/KnownError.js";
3
+ export function assertLayoutHasActiveWindow(layout) {
4
+ if (layout.activeWindow === void 0) {
5
+ throw new KnownError(LAYOUT_ERROR.NO_ACTIVE_WINDOW, "Layout has not active window.", {});
6
+ }
7
+ }
@@ -0,0 +1,5 @@
1
+ import { assertValidWinAndFrameIds } from "./assertValidWinAndFrameIds.js";
2
+ export function assertValidWinAndFrame(layout, win, frame) {
3
+ assertValidWinAndFrameIds(layout.windows, win?.id, frame?.id);
4
+ return { win, frame };
5
+ }
@@ -0,0 +1,6 @@
1
+ import { assertItemIn } from "./assertItemIn.js";
2
+ export function assertValidWinAndFrameIds(windows, winId, frameId) {
3
+ assertItemIn(windows, winId);
4
+ const win = windows[winId];
5
+ assertItemIn(win.frames, frameId);
6
+ }
@@ -0,0 +1,7 @@
1
+ import { LAYOUT_ERROR } from "../types/index.js";
2
+ import { KnownError } from "../utils/KnownError.js";
3
+ export function assertWindowHasActiveFrame(win) {
4
+ if (win.activeFrame === void 0) {
5
+ throw new KnownError(LAYOUT_ERROR.NO_ACTIVE_WINDOW, "Layout has no active window.", {});
6
+ }
7
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ export function clampNumber(num, lowerLimit, upperLimit) {
2
+ return num <= lowerLimit ? lowerLimit : num >= upperLimit ? upperLimit : num;
3
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ export function cloneFrame(frame) {
2
+ return { ...frame };
3
+ }
File without changes
@@ -0,0 +1,16 @@
1
+ import { isArray } from "@alanscodelog/utils/isArray";
2
+ import { cloneFrame } from "./cloneFrame.js";
3
+ export function cloneFrames(frames) {
4
+ const framesIsArray = isArray(frames);
5
+ const clone = framesIsArray ? [] : {};
6
+ if (framesIsArray) {
7
+ for (const frame of frames) {
8
+ clone.push(cloneFrame(frame));
9
+ }
10
+ } else {
11
+ for (const id of Object.keys(frames)) {
12
+ clone[id] = cloneFrame(frames[id]);
13
+ }
14
+ }
15
+ return clone;
16
+ }
File without changes