@tldraw/editor 4.6.0-next.5a871ec02ff3 → 4.6.0-next.6594d48ace27

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 (448) hide show
  1. package/dist-cjs/index.d.ts +1316 -285
  2. package/dist-cjs/index.js +31 -26
  3. package/dist-cjs/index.js.map +3 -3
  4. package/dist-cjs/lib/TldrawEditor.js +62 -14
  5. package/dist-cjs/lib/TldrawEditor.js.map +3 -3
  6. package/dist-cjs/lib/components/MenuClickCapture.js +99 -38
  7. package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
  8. package/dist-cjs/lib/components/default-components/CanvasOverlays.js +180 -0
  9. package/dist-cjs/lib/components/default-components/CanvasOverlays.js.map +7 -0
  10. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +33 -236
  11. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +3 -3
  12. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
  13. package/dist-cjs/lib/config/{createTLUser.js → createTLCurrentUser.js} +9 -9
  14. package/dist-cjs/lib/config/createTLCurrentUser.js.map +7 -0
  15. package/dist-cjs/lib/config/createTLStore.js +31 -1
  16. package/dist-cjs/lib/config/createTLStore.js.map +2 -2
  17. package/dist-cjs/lib/{components/default-components/DefaultShapeIndicatorErrorFallback.js → config/defaultAssets.js} +17 -9
  18. package/dist-cjs/lib/config/defaultAssets.js.map +7 -0
  19. package/dist-cjs/lib/config/defaultShapes.js.map +2 -2
  20. package/dist-cjs/lib/editor/Editor.js +921 -386
  21. package/dist-cjs/lib/editor/Editor.js.map +3 -3
  22. package/dist-cjs/lib/editor/assets/AssetUtil.js +67 -0
  23. package/dist-cjs/lib/editor/assets/AssetUtil.js.map +7 -0
  24. package/dist-cjs/lib/editor/bindings/BindingUtil.js +1 -0
  25. package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +1 -1
  26. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +26 -64
  27. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
  28. package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +98 -0
  29. package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +7 -0
  30. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +2 -1
  31. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
  32. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +15 -53
  33. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +1 -1
  34. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js +2 -0
  35. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
  36. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +2 -0
  37. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +1 -1
  38. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +83 -112
  39. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +2 -2
  40. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js +80 -0
  41. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js.map +7 -0
  42. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +466 -0
  43. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +7 -0
  44. package/dist-cjs/lib/{components/default-components/DefaultHandles.js → editor/managers/PerformanceManager/perf-types.js} +3 -14
  45. package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js.map +7 -0
  46. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js +1 -0
  47. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +1 -1
  48. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +22 -56
  49. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
  50. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +12 -52
  51. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
  52. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +21 -57
  53. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
  54. package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +5 -4
  55. package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
  56. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +103 -30
  57. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
  58. package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js +107 -0
  59. package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js.map +7 -0
  60. package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +600 -0
  61. package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +7 -0
  62. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +17 -55
  63. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +1 -1
  64. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +65 -72
  65. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
  66. package/dist-cjs/lib/editor/overlays/OverlayManager.js +154 -0
  67. package/dist-cjs/lib/editor/overlays/OverlayManager.js.map +7 -0
  68. package/dist-cjs/lib/editor/overlays/OverlayUtil.js +92 -0
  69. package/dist-cjs/lib/editor/overlays/OverlayUtil.js.map +7 -0
  70. package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js +161 -0
  71. package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js.map +7 -0
  72. package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js +76 -0
  73. package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js.map +7 -0
  74. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +35 -20
  75. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  76. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +33 -3
  77. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
  78. package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js +6 -0
  79. package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js.map +2 -2
  80. package/dist-cjs/lib/editor/tools/StateNode.js +15 -17
  81. package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
  82. package/dist-cjs/lib/editor/types/SvgExportContext.js.map +2 -2
  83. package/dist-cjs/lib/editor/types/clipboard-types.js.map +1 -1
  84. package/dist-cjs/lib/editor/types/event-types.js.map +2 -2
  85. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  86. package/dist-cjs/lib/exports/ExportDelay.js +13 -53
  87. package/dist-cjs/lib/exports/ExportDelay.js.map +1 -1
  88. package/dist-cjs/lib/exports/FontEmbedder.js +14 -57
  89. package/dist-cjs/lib/exports/FontEmbedder.js.map +1 -1
  90. package/dist-cjs/lib/exports/StyleEmbedder.js +2 -1
  91. package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
  92. package/dist-cjs/lib/exports/fetchCache.js +1 -1
  93. package/dist-cjs/lib/exports/fetchCache.js.map +2 -2
  94. package/dist-cjs/lib/exports/getSvgJsx.js +14 -8
  95. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  96. package/dist-cjs/lib/globals/environment.js +18 -1
  97. package/dist-cjs/lib/globals/environment.js.map +2 -2
  98. package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
  99. package/dist-cjs/lib/hooks/useCanvasEvents.js +25 -4
  100. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  101. package/dist-cjs/lib/hooks/{useIsDarkMode.js → useColorMode.js} +14 -10
  102. package/dist-cjs/lib/hooks/useColorMode.js.map +7 -0
  103. package/dist-cjs/lib/hooks/useCursor.js +3 -7
  104. package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
  105. package/dist-cjs/lib/hooks/useDarkMode.js +4 -4
  106. package/dist-cjs/lib/hooks/useDarkMode.js.map +2 -2
  107. package/dist-cjs/lib/hooks/useEditorComponents.js +0 -28
  108. package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
  109. package/dist-cjs/lib/hooks/useGestureEvents.js +171 -127
  110. package/dist-cjs/lib/hooks/useGestureEvents.js.map +3 -3
  111. package/dist-cjs/lib/hooks/useLocalStore.js.map +2 -2
  112. package/dist-cjs/lib/hooks/usePeerIds.js +1 -36
  113. package/dist-cjs/lib/hooks/usePeerIds.js.map +2 -2
  114. package/dist-cjs/lib/hooks/useShapeCulling.js +2 -1
  115. package/dist-cjs/lib/hooks/useShapeCulling.js.map +2 -2
  116. package/dist-cjs/lib/options.js +4 -0
  117. package/dist-cjs/lib/options.js.map +2 -2
  118. package/dist-cjs/lib/primitives/Box.js +26 -26
  119. package/dist-cjs/lib/primitives/Box.js.map +2 -2
  120. package/dist-cjs/lib/primitives/Vec.js +4 -1
  121. package/dist-cjs/lib/primitives/Vec.js.map +2 -2
  122. package/dist-cjs/lib/primitives/geometry/Arc2d.js +2 -2
  123. package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
  124. package/dist-cjs/lib/primitives/geometry/Circle2d.js +3 -2
  125. package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
  126. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +1 -1
  127. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +1 -1
  128. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +4 -3
  129. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
  130. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +12 -9
  131. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  132. package/dist-cjs/lib/primitives/geometry/Polyline2d.js +2 -2
  133. package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
  134. package/dist-cjs/lib/primitives/geometry/Stadium2d.js +2 -1
  135. package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
  136. package/dist-cjs/lib/utils/EditorAtom.js +2 -0
  137. package/dist-cjs/lib/utils/EditorAtom.js.map +1 -1
  138. package/dist-cjs/lib/utils/SharedStylesMap.js +1 -1
  139. package/dist-cjs/lib/utils/SharedStylesMap.js.map +1 -1
  140. package/dist-cjs/lib/utils/getSvgPathFromPoints.js.map +2 -2
  141. package/dist-cjs/lib/utils/reparenting.js +2 -1
  142. package/dist-cjs/lib/utils/reparenting.js.map +2 -2
  143. package/dist-cjs/lib/utils/richText.js.map +2 -2
  144. package/dist-cjs/lib/utils/runtime.js +2 -1
  145. package/dist-cjs/lib/utils/runtime.js.map +2 -2
  146. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +8 -2
  147. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
  148. package/dist-cjs/lib/utils/sync/hardReset.js +0 -8
  149. package/dist-cjs/lib/utils/sync/hardReset.js.map +2 -2
  150. package/dist-cjs/version.js +3 -3
  151. package/dist-cjs/version.js.map +1 -1
  152. package/dist-esm/index.d.mts +1316 -285
  153. package/dist-esm/index.mjs +44 -48
  154. package/dist-esm/index.mjs.map +2 -2
  155. package/dist-esm/lib/TldrawEditor.mjs +65 -14
  156. package/dist-esm/lib/TldrawEditor.mjs.map +3 -3
  157. package/dist-esm/lib/components/MenuClickCapture.mjs +100 -39
  158. package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
  159. package/dist-esm/lib/components/default-components/CanvasOverlays.mjs +160 -0
  160. package/dist-esm/lib/components/default-components/CanvasOverlays.mjs.map +7 -0
  161. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +34 -237
  162. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +3 -3
  163. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
  164. package/dist-esm/lib/config/{createTLUser.mjs → createTLCurrentUser.mjs} +6 -6
  165. package/dist-esm/lib/config/createTLCurrentUser.mjs.map +7 -0
  166. package/dist-esm/lib/config/createTLStore.mjs +37 -2
  167. package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
  168. package/dist-esm/lib/config/defaultAssets.mjs +16 -0
  169. package/dist-esm/lib/config/defaultAssets.mjs.map +7 -0
  170. package/dist-esm/lib/config/defaultShapes.mjs.map +2 -2
  171. package/dist-esm/lib/editor/Editor.mjs +924 -389
  172. package/dist-esm/lib/editor/Editor.mjs.map +3 -3
  173. package/dist-esm/lib/editor/assets/AssetUtil.mjs +47 -0
  174. package/dist-esm/lib/editor/assets/AssetUtil.mjs.map +7 -0
  175. package/dist-esm/lib/editor/bindings/BindingUtil.mjs +1 -0
  176. package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +1 -1
  177. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +26 -64
  178. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
  179. package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +83 -0
  180. package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +7 -0
  181. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +2 -1
  182. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
  183. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +15 -53
  184. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +1 -1
  185. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs +2 -0
  186. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
  187. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +2 -0
  188. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +1 -1
  189. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +83 -112
  190. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +2 -2
  191. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs +60 -0
  192. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs.map +7 -0
  193. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +438 -0
  194. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +7 -0
  195. package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs +1 -0
  196. package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs.map +7 -0
  197. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs +1 -0
  198. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +1 -1
  199. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +22 -56
  200. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
  201. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +12 -52
  202. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
  203. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +21 -57
  204. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
  205. package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +5 -4
  206. package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
  207. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +103 -30
  208. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
  209. package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs +89 -0
  210. package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs.map +7 -0
  211. package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +582 -0
  212. package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +7 -0
  213. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +17 -55
  214. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +1 -1
  215. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +65 -72
  216. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
  217. package/dist-esm/lib/editor/overlays/OverlayManager.mjs +136 -0
  218. package/dist-esm/lib/editor/overlays/OverlayManager.mjs.map +7 -0
  219. package/dist-esm/lib/editor/overlays/OverlayUtil.mjs +72 -0
  220. package/dist-esm/lib/editor/overlays/OverlayUtil.mjs.map +7 -0
  221. package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs +141 -0
  222. package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs.map +7 -0
  223. package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs +56 -0
  224. package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs.map +7 -0
  225. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +35 -20
  226. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  227. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +33 -3
  228. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
  229. package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs +6 -0
  230. package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs.map +2 -2
  231. package/dist-esm/lib/editor/tools/StateNode.mjs +15 -17
  232. package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
  233. package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +2 -2
  234. package/dist-esm/lib/editor/types/event-types.mjs.map +2 -2
  235. package/dist-esm/lib/exports/ExportDelay.mjs +13 -53
  236. package/dist-esm/lib/exports/ExportDelay.mjs.map +1 -1
  237. package/dist-esm/lib/exports/FontEmbedder.mjs +14 -57
  238. package/dist-esm/lib/exports/FontEmbedder.mjs.map +1 -1
  239. package/dist-esm/lib/exports/StyleEmbedder.mjs +2 -1
  240. package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
  241. package/dist-esm/lib/exports/fetchCache.mjs +2 -2
  242. package/dist-esm/lib/exports/fetchCache.mjs.map +2 -2
  243. package/dist-esm/lib/exports/getSvgJsx.mjs +14 -11
  244. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  245. package/dist-esm/lib/globals/environment.mjs +18 -1
  246. package/dist-esm/lib/globals/environment.mjs.map +2 -2
  247. package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
  248. package/dist-esm/lib/hooks/useCanvasEvents.mjs +25 -4
  249. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  250. package/dist-esm/lib/hooks/useColorMode.mjs +19 -0
  251. package/dist-esm/lib/hooks/useColorMode.mjs.map +7 -0
  252. package/dist-esm/lib/hooks/useCursor.mjs +3 -7
  253. package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
  254. package/dist-esm/lib/hooks/useDarkMode.mjs +4 -4
  255. package/dist-esm/lib/hooks/useDarkMode.mjs.map +2 -2
  256. package/dist-esm/lib/hooks/useEditorComponents.mjs +0 -28
  257. package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
  258. package/dist-esm/lib/hooks/useGestureEvents.mjs +171 -127
  259. package/dist-esm/lib/hooks/useGestureEvents.mjs.map +3 -3
  260. package/dist-esm/lib/hooks/useLocalStore.mjs.map +2 -2
  261. package/dist-esm/lib/hooks/usePeerIds.mjs +2 -40
  262. package/dist-esm/lib/hooks/usePeerIds.mjs.map +2 -2
  263. package/dist-esm/lib/hooks/useShapeCulling.mjs +2 -1
  264. package/dist-esm/lib/hooks/useShapeCulling.mjs.map +2 -2
  265. package/dist-esm/lib/options.mjs +4 -0
  266. package/dist-esm/lib/options.mjs.map +2 -2
  267. package/dist-esm/lib/primitives/Box.mjs +26 -26
  268. package/dist-esm/lib/primitives/Box.mjs.map +2 -2
  269. package/dist-esm/lib/primitives/Vec.mjs +4 -1
  270. package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
  271. package/dist-esm/lib/primitives/geometry/Arc2d.mjs +2 -2
  272. package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
  273. package/dist-esm/lib/primitives/geometry/Circle2d.mjs +3 -2
  274. package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
  275. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +1 -1
  276. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +1 -1
  277. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +4 -3
  278. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
  279. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +12 -9
  280. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  281. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +2 -2
  282. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
  283. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +2 -1
  284. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
  285. package/dist-esm/lib/utils/EditorAtom.mjs +2 -0
  286. package/dist-esm/lib/utils/EditorAtom.mjs.map +1 -1
  287. package/dist-esm/lib/utils/SharedStylesMap.mjs +1 -1
  288. package/dist-esm/lib/utils/SharedStylesMap.mjs.map +1 -1
  289. package/dist-esm/lib/utils/getSvgPathFromPoints.mjs.map +2 -2
  290. package/dist-esm/lib/utils/reparenting.mjs +2 -1
  291. package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
  292. package/dist-esm/lib/utils/richText.mjs.map +2 -2
  293. package/dist-esm/lib/utils/runtime.mjs +2 -1
  294. package/dist-esm/lib/utils/runtime.mjs.map +2 -2
  295. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +8 -2
  296. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
  297. package/dist-esm/lib/utils/sync/hardReset.mjs +0 -8
  298. package/dist-esm/lib/utils/sync/hardReset.mjs.map +2 -2
  299. package/dist-esm/version.mjs +3 -3
  300. package/dist-esm/version.mjs.map +1 -1
  301. package/editor.css +16 -256
  302. package/package.json +7 -8
  303. package/src/index.ts +58 -52
  304. package/src/lib/TldrawEditor.tsx +108 -20
  305. package/src/lib/components/MenuClickCapture.tsx +129 -49
  306. package/src/lib/components/default-components/CanvasOverlays.tsx +208 -0
  307. package/src/lib/components/default-components/DefaultCanvas.tsx +38 -310
  308. package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -0
  309. package/src/lib/config/TLEditorSnapshot.test.ts +1 -1
  310. package/src/lib/config/{createTLUser.ts → createTLCurrentUser.ts} +9 -9
  311. package/src/lib/config/createTLStore.ts +58 -3
  312. package/src/lib/config/defaultAssets.ts +19 -0
  313. package/src/lib/config/defaultShapes.ts +1 -1
  314. package/src/lib/editor/Editor.test.ts +3 -1
  315. package/src/lib/editor/Editor.ts +610 -69
  316. package/src/lib/editor/assets/AssetUtil.ts +85 -0
  317. package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
  318. package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +98 -0
  319. package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
  320. package/src/lib/editor/managers/FontManager/FontManager.test.ts +9 -2
  321. package/src/lib/editor/managers/FontManager/FontManager.ts +1 -67
  322. package/src/lib/editor/managers/InputsManager/InputsManager.ts +42 -30
  323. package/src/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.ts +82 -0
  324. package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +522 -0
  325. package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +583 -0
  326. package/src/lib/editor/managers/PerformanceManager/perf-types.ts +196 -0
  327. package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +1 -1
  328. package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +1 -1
  329. package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +13 -2
  330. package/src/lib/editor/managers/SnapManager/SnapManager.ts +1 -1
  331. package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +5 -5
  332. package/src/lib/editor/managers/TextManager/TextManager.test.ts +18 -4
  333. package/src/lib/editor/managers/TextManager/TextManager.ts +140 -34
  334. package/src/lib/editor/managers/ThemeManager/ThemeManager.ts +116 -0
  335. package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +619 -0
  336. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +25 -31
  337. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +7 -5
  338. package/src/lib/editor/overlays/OverlayManager.ts +183 -0
  339. package/src/lib/editor/overlays/OverlayUtil.ts +143 -0
  340. package/src/lib/editor/overlays/ShapeIndicatorOverlayUtil.ts +216 -0
  341. package/src/lib/editor/shapes/BaseFrameLikeShapeUtil.tsx +123 -0
  342. package/src/lib/editor/shapes/ShapeUtil.ts +67 -30
  343. package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +41 -4
  344. package/src/lib/editor/shapes/shared/getPerfectDashProps.ts +7 -0
  345. package/src/lib/editor/tools/StateNode.ts +16 -18
  346. package/src/lib/editor/types/SvgExportContext.tsx +5 -0
  347. package/src/lib/editor/types/clipboard-types.ts +2 -1
  348. package/src/lib/editor/types/event-types.ts +2 -0
  349. package/src/lib/editor/types/external-content.ts +1 -0
  350. package/src/lib/exports/StyleEmbedder.ts +1 -1
  351. package/src/lib/exports/fetchCache.ts +2 -4
  352. package/src/lib/exports/getSvgJsx.test.ts +3 -1
  353. package/src/lib/exports/getSvgJsx.tsx +24 -17
  354. package/src/lib/globals/environment.ts +18 -0
  355. package/src/lib/hooks/EditorComponentsContext.tsx +0 -27
  356. package/src/lib/hooks/useCanvasEvents.ts +40 -3
  357. package/src/lib/hooks/{useIsDarkMode.ts → useColorMode.ts} +9 -5
  358. package/src/lib/hooks/useCursor.ts +3 -7
  359. package/src/lib/hooks/useDarkMode.ts +4 -4
  360. package/src/lib/hooks/useEditorComponents.tsx +1 -29
  361. package/src/lib/hooks/useGestureEvents.ts +240 -168
  362. package/src/lib/hooks/useLocalStore.ts +1 -1
  363. package/src/lib/hooks/usePeerIds.ts +6 -55
  364. package/src/lib/hooks/useShapeCulling.tsx +3 -1
  365. package/src/lib/options.ts +115 -0
  366. package/src/lib/primitives/Box.test.ts +30 -0
  367. package/src/lib/primitives/Box.ts +26 -26
  368. package/src/lib/primitives/Vec.ts +1 -1
  369. package/src/lib/primitives/geometry/Arc2d.ts +2 -2
  370. package/src/lib/primitives/geometry/Circle2d.ts +2 -2
  371. package/src/lib/primitives/geometry/CubicSpline2d.ts +1 -1
  372. package/src/lib/primitives/geometry/Ellipse2d.ts +3 -3
  373. package/src/lib/primitives/geometry/Geometry2d.test.ts +21 -0
  374. package/src/lib/primitives/geometry/Geometry2d.ts +10 -9
  375. package/src/lib/primitives/geometry/Polyline2d.ts +2 -2
  376. package/src/lib/primitives/geometry/Stadium2d.ts +1 -1
  377. package/src/lib/utils/SharedStylesMap.ts +1 -1
  378. package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
  379. package/src/lib/utils/reparenting.ts +6 -2
  380. package/src/lib/utils/richText.ts +1 -1
  381. package/src/lib/utils/runtime.ts +3 -1
  382. package/src/lib/utils/sync/TLLocalSyncClient.test.ts +1 -1
  383. package/src/lib/utils/sync/TLLocalSyncClient.ts +5 -1
  384. package/src/lib/utils/sync/hardReset.ts +0 -8
  385. package/src/version.ts +3 -3
  386. package/dist-cjs/lib/components/LiveCollaborators.js +0 -151
  387. package/dist-cjs/lib/components/LiveCollaborators.js.map +0 -7
  388. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +0 -227
  389. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +0 -7
  390. package/dist-cjs/lib/components/default-components/DefaultBrush.js +0 -38
  391. package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +0 -7
  392. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +0 -71
  393. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +0 -7
  394. package/dist-cjs/lib/components/default-components/DefaultHandle.js +0 -56
  395. package/dist-cjs/lib/components/default-components/DefaultHandle.js.map +0 -7
  396. package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +0 -7
  397. package/dist-cjs/lib/components/default-components/DefaultScribble.js +0 -51
  398. package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +0 -7
  399. package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js +0 -69
  400. package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js.map +0 -7
  401. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +0 -107
  402. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +0 -7
  403. package/dist-cjs/lib/components/default-components/DefaultShapeIndicatorErrorFallback.js.map +0 -7
  404. package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +0 -101
  405. package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +0 -7
  406. package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +0 -170
  407. package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +0 -7
  408. package/dist-cjs/lib/config/createTLUser.js.map +0 -7
  409. package/dist-cjs/lib/hooks/useIsDarkMode.js.map +0 -7
  410. package/dist-esm/lib/components/LiveCollaborators.mjs +0 -134
  411. package/dist-esm/lib/components/LiveCollaborators.mjs.map +0 -7
  412. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +0 -207
  413. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +0 -7
  414. package/dist-esm/lib/components/default-components/DefaultBrush.mjs +0 -18
  415. package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +0 -7
  416. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +0 -41
  417. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +0 -7
  418. package/dist-esm/lib/components/default-components/DefaultHandle.mjs +0 -26
  419. package/dist-esm/lib/components/default-components/DefaultHandle.mjs.map +0 -7
  420. package/dist-esm/lib/components/default-components/DefaultHandles.mjs +0 -8
  421. package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +0 -7
  422. package/dist-esm/lib/components/default-components/DefaultScribble.mjs +0 -21
  423. package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +0 -7
  424. package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs +0 -39
  425. package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs.map +0 -7
  426. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +0 -77
  427. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +0 -7
  428. package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs +0 -8
  429. package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs.map +0 -7
  430. package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +0 -81
  431. package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +0 -7
  432. package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +0 -142
  433. package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +0 -7
  434. package/dist-esm/lib/config/createTLUser.mjs.map +0 -7
  435. package/dist-esm/lib/hooks/useIsDarkMode.mjs +0 -15
  436. package/dist-esm/lib/hooks/useIsDarkMode.mjs.map +0 -7
  437. package/src/lib/components/LiveCollaborators.tsx +0 -174
  438. package/src/lib/components/default-components/CanvasShapeIndicators.tsx +0 -289
  439. package/src/lib/components/default-components/DefaultBrush.tsx +0 -35
  440. package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +0 -52
  441. package/src/lib/components/default-components/DefaultHandle.tsx +0 -42
  442. package/src/lib/components/default-components/DefaultHandles.tsx +0 -15
  443. package/src/lib/components/default-components/DefaultScribble.tsx +0 -31
  444. package/src/lib/components/default-components/DefaultSelectionForeground.tsx +0 -50
  445. package/src/lib/components/default-components/DefaultShapeIndicator.tsx +0 -104
  446. package/src/lib/components/default-components/DefaultShapeIndicatorErrorFallback.tsx +0 -9
  447. package/src/lib/components/default-components/DefaultShapeIndicators.tsx +0 -116
  448. package/src/lib/components/default-components/DefaultSnapIndictor.tsx +0 -174
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/SharedStylesMap.ts"],
4
- "sourcesContent": ["import { StyleProp } from '@tldraw/tlschema'\nimport { exhaustiveSwitchError } from '@tldraw/utils'\n\n/**\n * The value of a particular {@link @tldraw/tlschema#StyleProp}.\n *\n * A `mixed` style means that in the current selection, there are lots of different values for the\n * same style prop - e.g. a red and a blue shape are selected.\n *\n * A `shared` style means that all shapes in the selection share the same value for this style prop.\n *\n * @public\n */\nexport type SharedStyle<T> =\n\t| { readonly type: 'mixed' }\n\t| { readonly type: 'shared'; readonly value: T }\n\nfunction sharedStyleEquals<T>(a: SharedStyle<T>, b: SharedStyle<T> | undefined) {\n\tif (!b) return false\n\tswitch (a.type) {\n\t\tcase 'mixed':\n\t\t\treturn b.type === 'mixed'\n\t\tcase 'shared':\n\t\t\treturn b.type === 'shared' && a.value === b.value\n\t\tdefault:\n\t\t\tthrow exhaustiveSwitchError(a)\n\t}\n}\n\n/**\n * A map of {@link @tldraw/tlschema#StyleProp | StyleProps} to their {@link SharedStyle} values. See\n * {@link Editor.getSharedStyles}.\n *\n * @public\n */\nexport class ReadonlySharedStyleMap {\n\t/** @internal */\n\tprotected map: Map<StyleProp<any>, SharedStyle<unknown>>\n\n\tconstructor(entries?: Iterable<[StyleProp<unknown>, SharedStyle<unknown>]>) {\n\t\tthis.map = new Map(entries)\n\t}\n\n\tget<T>(prop: StyleProp<T>): SharedStyle<T> | undefined {\n\t\treturn this.map.get(prop) as SharedStyle<T> | undefined\n\t}\n\n\tgetAsKnownValue<T>(prop: StyleProp<T>): T | undefined {\n\t\tconst value = this.get(prop)\n\t\tif (!value) return undefined\n\t\tif (value.type === 'mixed') return undefined\n\t\treturn value.value\n\t}\n\n\t// eslint-disable-next-line no-restricted-syntax\n\tget size() {\n\t\treturn this.map.size\n\t}\n\n\tequals(other: ReadonlySharedStyleMap) {\n\t\tif (this.size !== other.size) return false\n\n\t\tconst checkedKeys = new Set()\n\t\tfor (const [styleProp, value] of this) {\n\t\t\tif (!sharedStyleEquals(value, other.get(styleProp))) return false\n\t\t\tcheckedKeys.add(styleProp)\n\t\t}\n\t\tfor (const [styleProp, value] of other) {\n\t\t\tif (checkedKeys.has(styleProp)) continue\n\t\t\tif (!sharedStyleEquals(value, this.get(styleProp))) return false\n\t\t}\n\n\t\treturn true\n\t}\n\n\tkeys() {\n\t\treturn this.map.keys()\n\t}\n\n\tvalues() {\n\t\treturn this.map.values()\n\t}\n\n\tentries() {\n\t\treturn this.map.entries()\n\t}\n\n\t[Symbol.iterator]() {\n\t\treturn this.map[Symbol.iterator]()\n\t}\n}\n\n/** @internal */\nexport class SharedStyleMap extends ReadonlySharedStyleMap {\n\tset<T>(prop: StyleProp<T>, value: SharedStyle<T>) {\n\t\tthis.map.set(prop, value)\n\t}\n\n\tapplyValue<T>(prop: StyleProp<T>, value: T) {\n\t\tconst existingValue = this.get(prop)\n\n\t\t// if we don't have a value yet, set it\n\t\tif (!existingValue) {\n\t\t\tthis.set(prop, { type: 'shared', value })\n\t\t\treturn\n\t\t}\n\n\t\tswitch (existingValue.type) {\n\t\t\tcase 'mixed':\n\t\t\t\t// we're already mixed, adding new values won't help\n\t\t\t\treturn\n\t\t\tcase 'shared':\n\t\t\t\tif (existingValue.value !== value) {\n\t\t\t\t\t// if the value is different, we're now mixed:\n\t\t\t\t\tthis.set(prop, { type: 'mixed' })\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\texhaustiveSwitchError(existingValue, 'type')\n\t\t}\n\t}\n}\n"],
4
+ "sourcesContent": ["import { StyleProp } from '@tldraw/tlschema'\nimport { exhaustiveSwitchError } from '@tldraw/utils'\n\n/**\n * The value of a particular {@link @tldraw/tlschema#StyleProp}.\n *\n * A `mixed` style means that in the current selection, there are lots of different values for the\n * same style prop - e.g. a red and a blue shape are selected.\n *\n * A `shared` style means that all shapes in the selection share the same value for this style prop.\n *\n * @public\n */\nexport type SharedStyle<T> =\n\t| { readonly type: 'mixed' }\n\t| { readonly type: 'shared'; readonly value: T }\n\nfunction sharedStyleEquals<T>(a: SharedStyle<T>, b: SharedStyle<T> | undefined) {\n\tif (!b) return false\n\tswitch (a.type) {\n\t\tcase 'mixed':\n\t\t\treturn b.type === 'mixed'\n\t\tcase 'shared':\n\t\t\treturn b.type === 'shared' && a.value === b.value\n\t\tdefault:\n\t\t\tthrow exhaustiveSwitchError(a)\n\t}\n}\n\n/**\n * A map of {@link @tldraw/tlschema#StyleProp | StyleProps} to their {@link SharedStyle} values. See\n * {@link Editor.getSharedStyles}.\n *\n * @public\n */\nexport class ReadonlySharedStyleMap {\n\t/** @internal */\n\tprotected map: Map<StyleProp<any>, SharedStyle<unknown>>\n\n\tconstructor(entries?: Iterable<[StyleProp<unknown>, SharedStyle<unknown>]>) {\n\t\tthis.map = new Map(entries)\n\t}\n\n\tget<T>(prop: StyleProp<T>): SharedStyle<T> | undefined {\n\t\treturn this.map.get(prop) as SharedStyle<T> | undefined\n\t}\n\n\tgetAsKnownValue<T>(prop: StyleProp<T>): T | undefined {\n\t\tconst value = this.get(prop)\n\t\tif (!value) return undefined\n\t\tif (value.type === 'mixed') return undefined\n\t\treturn value.value\n\t}\n\n\t// eslint-disable-next-line tldraw/no-setter-getter\n\tget size() {\n\t\treturn this.map.size\n\t}\n\n\tequals(other: ReadonlySharedStyleMap) {\n\t\tif (this.size !== other.size) return false\n\n\t\tconst checkedKeys = new Set()\n\t\tfor (const [styleProp, value] of this) {\n\t\t\tif (!sharedStyleEquals(value, other.get(styleProp))) return false\n\t\t\tcheckedKeys.add(styleProp)\n\t\t}\n\t\tfor (const [styleProp, value] of other) {\n\t\t\tif (checkedKeys.has(styleProp)) continue\n\t\t\tif (!sharedStyleEquals(value, this.get(styleProp))) return false\n\t\t}\n\n\t\treturn true\n\t}\n\n\tkeys() {\n\t\treturn this.map.keys()\n\t}\n\n\tvalues() {\n\t\treturn this.map.values()\n\t}\n\n\tentries() {\n\t\treturn this.map.entries()\n\t}\n\n\t[Symbol.iterator]() {\n\t\treturn this.map[Symbol.iterator]()\n\t}\n}\n\n/** @internal */\nexport class SharedStyleMap extends ReadonlySharedStyleMap {\n\tset<T>(prop: StyleProp<T>, value: SharedStyle<T>) {\n\t\tthis.map.set(prop, value)\n\t}\n\n\tapplyValue<T>(prop: StyleProp<T>, value: T) {\n\t\tconst existingValue = this.get(prop)\n\n\t\t// if we don't have a value yet, set it\n\t\tif (!existingValue) {\n\t\t\tthis.set(prop, { type: 'shared', value })\n\t\t\treturn\n\t\t}\n\n\t\tswitch (existingValue.type) {\n\t\t\tcase 'mixed':\n\t\t\t\t// we're already mixed, adding new values won't help\n\t\t\t\treturn\n\t\t\tcase 'shared':\n\t\t\t\tif (existingValue.value !== value) {\n\t\t\t\t\t// if the value is different, we're now mixed:\n\t\t\t\t\tthis.set(prop, { type: 'mixed' })\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\texhaustiveSwitchError(existingValue, 'type')\n\t\t}\n\t}\n}\n"],
5
5
  "mappings": "AACA,SAAS,6BAA6B;AAgBtC,SAAS,kBAAqB,GAAmB,GAA+B;AAC/E,MAAI,CAAC,EAAG,QAAO;AACf,UAAQ,EAAE,MAAM;AAAA,IACf,KAAK;AACJ,aAAO,EAAE,SAAS;AAAA,IACnB,KAAK;AACJ,aAAO,EAAE,SAAS,YAAY,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EAC1D,IAAO,MAAoB,OAAuB;AACjD,SAAK,IAAI,IAAI,MAAM,KAAK;AAAA,EACzB;AAAA,EAEA,WAAc,MAAoB,OAAU;AAC3C,UAAM,gBAAgB,KAAK,IAAI,IAAI;AAGnC,QAAI,CAAC,eAAe;AACnB,WAAK,IAAI,MAAM,EAAE,MAAM,UAAU,MAAM,CAAC;AACxC;AAAA,IACD;AAEA,YAAQ,cAAc,MAAM;AAAA,MAC3B,KAAK;AAEJ;AAAA,MACD,KAAK;AACJ,YAAI,cAAc,UAAU,OAAO;AAElC,eAAK,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAAA,QACjC;AACA;AAAA,MACD;AACC,8BAAsB,eAAe,MAAM;AAAA,IAC7C;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/getSvgPathFromPoints.ts"],
4
- "sourcesContent": ["import { VecLike } from '../primitives/Vec'\nimport { average, precise } from '../primitives/utils'\n\n/**\n * Turn an array of points into a path of quadratic curves.\n *\n * @param points - The points returned from perfect-freehand\n * @param closed - Whether the stroke is closed\n *\n * @public\n */\nexport function getSvgPathFromPoints(points: VecLike[], closed = true): string {\n\tconst len = points.length\n\n\tif (len < 2) {\n\t\treturn ''\n\t}\n\n\tlet a = points[0]\n\tlet b = points[1]\n\n\tif (len === 2) {\n\t\t// If only two points, just draw a line\n\t\treturn `M${precise(a)}L${precise(b)}`\n\t}\n\n\tlet result = ''\n\n\tfor (let i = 2, max = len - 1; i < max; i++) {\n\t\ta = points[i]\n\t\tb = points[i + 1]\n\t\tresult += average(a, b)\n\t}\n\n\tif (closed) {\n\t\t// If closed, draw a curve from the last point to the first\n\t\treturn `M${average(points[0], points[1])}Q${precise(points[1])}${average(\n\t\t\tpoints[1],\n\t\t\tpoints[2]\n\t\t)}T${result}${average(points[len - 1], points[0])}${average(points[0], points[1])}Z`\n\t} else {\n\t\t// If not closed, draw a curve starting at the first point and\n\t\t// ending at the midpoint of the last and second-last point, then\n\t\t// complete the curve with a line segment to the last point.\n\t\treturn `M${precise(points[0])}Q${precise(points[1])}${average(points[1], points[2])}${\n\t\t\tpoints.length > 3 ? 'T' : ''\n\t\t}${result}L${precise(points[len - 1])}`\n\t}\n}\n"],
5
- "mappings": "AACA,SAAS,SAAS,eAAe;AAU1B,SAAS,qBAAqB,QAAmB,SAAS,MAAc;AAC9E,QAAM,MAAM,OAAO;AAEnB,MAAI,MAAM,GAAG;AACZ,WAAO;AAAA,EACR;AAEA,MAAI,IAAI,OAAO,CAAC;AAChB,MAAI,IAAI,OAAO,CAAC;AAEhB,MAAI,QAAQ,GAAG;AAEd,WAAO,IAAI,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC;AAAA,EACpC;AAEA,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,MAAM,MAAM,GAAG,IAAI,KAAK,KAAK;AAC5C,QAAI,OAAO,CAAC;AACZ,QAAI,OAAO,IAAI,CAAC;AAChB,cAAU,QAAQ,GAAG,CAAC;AAAA,EACvB;AAEA,MAAI,QAAQ;AAEX,WAAO,IAAI,QAAQ,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ,OAAO,CAAC,CAAC,CAAC,GAAG;AAAA,MAChE,OAAO,CAAC;AAAA,MACR,OAAO,CAAC;AAAA,IACT,CAAC,IAAI,MAAM,GAAG,QAAQ,OAAO,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AAAA,EAClF,OAAO;AAIN,WAAO,IAAI,QAAQ,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAClF,OAAO,SAAS,IAAI,MAAM,EAC3B,GAAG,MAAM,IAAI,QAAQ,OAAO,MAAM,CAAC,CAAC,CAAC;AAAA,EACtC;AACD;",
4
+ "sourcesContent": ["import { average, precise } from '../primitives/utils'\nimport { VecLike } from '../primitives/Vec'\n\n/**\n * Turn an array of points into a path of quadratic curves.\n *\n * @param points - The points returned from perfect-freehand\n * @param closed - Whether the stroke is closed\n *\n * @public\n */\nexport function getSvgPathFromPoints(points: VecLike[], closed = true): string {\n\tconst len = points.length\n\n\tif (len < 2) {\n\t\treturn ''\n\t}\n\n\tlet a = points[0]\n\tlet b = points[1]\n\n\tif (len === 2) {\n\t\t// If only two points, just draw a line\n\t\treturn `M${precise(a)}L${precise(b)}`\n\t}\n\n\tlet result = ''\n\n\tfor (let i = 2, max = len - 1; i < max; i++) {\n\t\ta = points[i]\n\t\tb = points[i + 1]\n\t\tresult += average(a, b)\n\t}\n\n\tif (closed) {\n\t\t// If closed, draw a curve from the last point to the first\n\t\treturn `M${average(points[0], points[1])}Q${precise(points[1])}${average(\n\t\t\tpoints[1],\n\t\t\tpoints[2]\n\t\t)}T${result}${average(points[len - 1], points[0])}${average(points[0], points[1])}Z`\n\t} else {\n\t\t// If not closed, draw a curve starting at the first point and\n\t\t// ending at the midpoint of the last and second-last point, then\n\t\t// complete the curve with a line segment to the last point.\n\t\treturn `M${precise(points[0])}Q${precise(points[1])}${average(points[1], points[2])}${\n\t\t\tpoints.length > 3 ? 'T' : ''\n\t\t}${result}L${precise(points[len - 1])}`\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,SAAS,eAAe;AAW1B,SAAS,qBAAqB,QAAmB,SAAS,MAAc;AAC9E,QAAM,MAAM,OAAO;AAEnB,MAAI,MAAM,GAAG;AACZ,WAAO;AAAA,EACR;AAEA,MAAI,IAAI,OAAO,CAAC;AAChB,MAAI,IAAI,OAAO,CAAC;AAEhB,MAAI,QAAQ,GAAG;AAEd,WAAO,IAAI,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC;AAAA,EACpC;AAEA,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,MAAM,MAAM,GAAG,IAAI,KAAK,KAAK;AAC5C,QAAI,OAAO,CAAC;AACZ,QAAI,OAAO,IAAI,CAAC;AAChB,cAAU,QAAQ,GAAG,CAAC;AAAA,EACvB;AAEA,MAAI,QAAQ;AAEX,WAAO,IAAI,QAAQ,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ,OAAO,CAAC,CAAC,CAAC,GAAG;AAAA,MAChE,OAAO,CAAC;AAAA,MACR,OAAO,CAAC;AAAA,IACT,CAAC,IAAI,MAAM,GAAG,QAAQ,OAAO,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AAAA,EAClF,OAAO;AAIN,WAAO,IAAI,QAAQ,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAClF,OAAO,SAAS,IAAI,MAAM,EAC3B,GAAG,MAAM,IAAI,QAAQ,OAAO,MAAM,CAAC,CAAC,CAAC;AAAA,EACtC;AACD;",
6
6
  "names": []
7
7
  }
@@ -57,7 +57,8 @@ function kickoutOccludedShapes(editor, shapeIds, opts) {
57
57
  const oldParentIndex = oldParentSiblingIds.indexOf(prevParent.id);
58
58
  if (oldParentIndex > -1) {
59
59
  const siblingsIndexAbove = oldParentSiblingIds[oldParentIndex + 1];
60
- const indexKeyAbove = siblingsIndexAbove ? editor.getShape(siblingsIndexAbove).index : getIndexAbove(prevParent.index);
60
+ const siblingAboveIndex = siblingsIndexAbove ? editor.getShape(siblingsIndexAbove).index : void 0;
61
+ const indexKeyAbove = siblingAboveIndex && siblingAboveIndex > prevParent.index ? siblingAboveIndex : getIndexAbove(prevParent.index);
61
62
  insertIndexKey = getIndexBetween(prevParent.index, indexKeyAbove);
62
63
  } else {
63
64
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/reparenting.ts"],
4
- "sourcesContent": ["import { EMPTY_ARRAY } from '@tldraw/state'\nimport { TLGroupShape, TLParentId, TLShape, TLShapeId } from '@tldraw/tlschema'\nimport { IndexKey, compact, getIndexAbove, getIndexBetween } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\nimport { intersectPolygonPolygon } from '../primitives/intersect'\n\n/**\n * Reparents shapes that are no longer contained within their parent shapes.\n *\n * @param editor - The editor instance.\n * @param shapeIds - The IDs of the shapes to reparent.\n * @param opts - Optional options, including a callback to filter out certain parents, such as when removing a frame.\n *\n * @public\n */\nexport function kickoutOccludedShapes(\n\teditor: Editor,\n\tshapeIds: TLShapeId[],\n\topts?: { filter?(parent: TLShape): boolean }\n) {\n\tconst parentsToCheck = new Set<TLShape>()\n\n\tfor (const id of shapeIds) {\n\t\tconst shape = editor.getShape(id)\n\n\t\tif (!shape) continue\n\t\tparentsToCheck.add(shape)\n\n\t\tconst parent = editor.getShape(shape.parentId)\n\t\tif (!parent) continue\n\t\tparentsToCheck.add(parent)\n\t}\n\n\t// Check all of the parents and gather up parents who have lost children\n\tconst parentsToLostChildren = new Map<TLShape, TLShapeId[]>()\n\n\tfor (const parent of parentsToCheck) {\n\t\tconst childIds = editor.getSortedChildIdsForParent(parent)\n\t\tif (opts?.filter && !opts.filter(parent)) {\n\t\t\t// If the shape is filtered out, we kick out all of its children\n\t\t\tparentsToLostChildren.set(parent, childIds)\n\t\t} else {\n\t\t\tconst overlappingChildren = getOverlappingShapes(editor, parent.id, childIds)\n\t\t\tif (overlappingChildren.length < childIds.length) {\n\t\t\t\tparentsToLostChildren.set(\n\t\t\t\t\tparent,\n\t\t\t\t\tchildIds.filter((id) => !overlappingChildren.includes(id))\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Get all of the shapes on the current page, sorted by their index\n\tconst sortedShapeIds = editor.getCurrentPageShapesSorted().map((s) => s.id)\n\n\tconst parentsToNewChildren: Record<\n\t\tTLParentId,\n\t\t{ parentId: TLParentId; shapeIds: TLShapeId[]; index?: IndexKey }\n\t> = {}\n\n\tfor (const [prevParent, lostChildrenIds] of parentsToLostChildren) {\n\t\tconst lostChildren = compact(lostChildrenIds.map((id) => editor.getShape(id)))\n\n\t\t// Otherwise, we have no next dropping shape under the cursor, so go find\n\t\t// all the frames on the page where the moving shapes will fall into\n\t\tconst { reparenting, remainingShapesToReparent } = getDroppedShapesToNewParents(\n\t\t\teditor,\n\t\t\tlostChildren,\n\t\t\t(shape, maybeNewParent) => {\n\t\t\t\t// If we're filtering out a potential parent, don't reparent shapes to the filtered out shape\n\t\t\t\tif (opts?.filter && !opts.filter(maybeNewParent)) return false\n\t\t\t\treturn (\n\t\t\t\t\tmaybeNewParent.id !== prevParent.id &&\n\t\t\t\t\tsortedShapeIds.indexOf(maybeNewParent.id) < sortedShapeIds.indexOf(shape.id)\n\t\t\t\t)\n\t\t\t}\n\t\t)\n\n\t\treparenting.forEach((childrenToReparent, newParentId) => {\n\t\t\tif (childrenToReparent.length === 0) return\n\t\t\tif (!parentsToNewChildren[newParentId]) {\n\t\t\t\tparentsToNewChildren[newParentId] = {\n\t\t\t\t\tparentId: newParentId,\n\t\t\t\t\tshapeIds: [],\n\t\t\t\t}\n\t\t\t}\n\t\t\tparentsToNewChildren[newParentId].shapeIds.push(...childrenToReparent.map((s) => s.id))\n\t\t})\n\n\t\t// Reparent the rest to the page (or containing group)\n\t\tif (remainingShapesToReparent.size > 0) {\n\t\t\t// The remaining shapes are going to be reparented to the old parent's containing group, if there was one, or else to the page\n\t\t\tconst newParentId =\n\t\t\t\teditor.findShapeAncestor(prevParent, (s) => editor.isShapeOfType(s, 'group'))?.id ??\n\t\t\t\teditor.getCurrentPageId()\n\n\t\t\tremainingShapesToReparent.forEach((shape) => {\n\t\t\t\tif (!parentsToNewChildren[newParentId]) {\n\t\t\t\t\tlet insertIndexKey: IndexKey | undefined\n\n\t\t\t\t\tconst oldParentSiblingIds = editor.getSortedChildIdsForParent(newParentId)\n\t\t\t\t\tconst oldParentIndex = oldParentSiblingIds.indexOf(prevParent.id)\n\t\t\t\t\tif (oldParentIndex > -1) {\n\t\t\t\t\t\t// If the old parent is a direct child of the new parent, then we'll add them above the old parent but below the next sibling.\n\t\t\t\t\t\tconst siblingsIndexAbove = oldParentSiblingIds[oldParentIndex + 1]\n\t\t\t\t\t\tconst indexKeyAbove = siblingsIndexAbove\n\t\t\t\t\t\t\t? editor.getShape(siblingsIndexAbove)!.index\n\t\t\t\t\t\t\t: getIndexAbove(prevParent.index)\n\t\t\t\t\t\tinsertIndexKey = getIndexBetween(prevParent.index, indexKeyAbove)\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the old parent is not a direct child of the new parent, then we'll add them to the \"top\" of the new parent's children.\n\t\t\t\t\t\t// This is done automatically if we leave the index undefined, so let's do that.\n\t\t\t\t\t}\n\n\t\t\t\t\tparentsToNewChildren[newParentId] = {\n\t\t\t\t\t\tparentId: newParentId,\n\t\t\t\t\t\tshapeIds: [],\n\t\t\t\t\t\tindex: insertIndexKey,\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tparentsToNewChildren[newParentId].shapeIds.push(shape.id)\n\t\t\t})\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\tObject.values(parentsToNewChildren).forEach(({ parentId, shapeIds, index }) => {\n\t\t\tif (shapeIds.length === 0) return\n\t\t\t// Before we reparent, sort the new shape ids by their place in the original absolute order on the page\n\t\t\tshapeIds.sort((a, b) => (sortedShapeIds.indexOf(a) < sortedShapeIds.indexOf(b) ? -1 : 1))\n\t\t\teditor.reparentShapes(shapeIds, parentId, index)\n\t\t})\n\t})\n}\n\n/**\n * Get the shapes that overlap with a given shape.\n *\n * @param editor - The editor instance.\n * @param shape - The shapes or shape IDs to check against.\n * @param otherShapes - The shapes or shape IDs to check for overlap.\n * @returns An array of shapes or shape IDs that overlap with the given shape.\n */\nfunction getOverlappingShapes<T extends TLShape[] | TLShapeId[]>(\n\teditor: Editor,\n\tshape: T[number],\n\totherShapes: T\n) {\n\tif (otherShapes.length === 0) {\n\t\treturn EMPTY_ARRAY\n\t}\n\n\tconst parentPageBounds = editor.getShapePageBounds(shape)\n\tif (!parentPageBounds) return EMPTY_ARRAY\n\n\tconst _shape = editor.getShape(shape)\n\tif (!_shape) return EMPTY_ARRAY\n\n\tconst parentGeometry = editor.getShapeGeometry(shape)\n\tconst parentPageTransform = editor.getShapePageTransform(shape)\n\tconst parentPageCorners = parentPageTransform.applyToPoints(parentGeometry.vertices)\n\n\tconst clipPath = editor.getShapeUtil(_shape.type).getClipPath?.(_shape)\n\n\tconst parentPageMaskVertices = clipPath ? parentPageTransform.applyToPoints(clipPath) : undefined\n\tconst parentPagePolygon = parentPageMaskVertices\n\t\t? intersectPolygonPolygon(parentPageMaskVertices, parentPageCorners)\n\t\t: parentPageCorners\n\n\tif (!parentPagePolygon) return EMPTY_ARRAY\n\n\treturn otherShapes.filter((childId) => {\n\t\tconst shapePageBounds = editor.getShapePageBounds(childId)\n\t\tif (!shapePageBounds || !parentPageBounds.includes(shapePageBounds)) return false\n\n\t\tconst parentPolygonInShapeShape = editor\n\t\t\t.getShapePageTransform(childId)\n\t\t\t.clone()\n\t\t\t.invert()\n\t\t\t.applyToPoints(parentPagePolygon)\n\n\t\tconst geometry = editor.getShapeGeometry(childId)\n\n\t\treturn geometry.overlapsPolygon(parentPolygonInShapeShape)\n\t})\n}\n\n/**\n * Get the shapes that will be reparented to new parents when the shapes are dropped.\n *\n * @param editor - The editor instance.\n * @param shapes - The shapes to check.\n * @param cb - A callback to filter out certain shapes.\n * @returns An object with the shapes that will be reparented to new parents and the shapes that will be reparented to the page or their ancestral group.\n *\n * @public\n */\nexport function getDroppedShapesToNewParents(\n\teditor: Editor,\n\tshapes: Set<TLShape> | TLShape[],\n\tcb?: (shape: TLShape, parent: TLShape) => boolean\n) {\n\tconst shapesToActuallyCheck = new Set<TLShape>(shapes)\n\tconst movingGroups = new Set<TLGroupShape>()\n\n\tfor (const shape of shapes) {\n\t\tconst parent = editor.getShapeParent(shape)\n\t\tif (parent && editor.isShapeOfType(parent, 'group')) {\n\t\t\tif (!movingGroups.has(parent)) {\n\t\t\t\tmovingGroups.add(parent)\n\t\t\t}\n\t\t}\n\t}\n\n\t// If all of a group's children are moving, then move the group instead\n\tfor (const movingGroup of movingGroups) {\n\t\tconst children = compact(\n\t\t\teditor.getSortedChildIdsForParent(movingGroup).map((id) => editor.getShape(id))\n\t\t)\n\t\tfor (const child of children) {\n\t\t\tshapesToActuallyCheck.delete(child)\n\t\t}\n\t\tshapesToActuallyCheck.add(movingGroup)\n\t}\n\n\t// this could be cached and passed in\n\tconst shapeGroupIds = new Map<TLShapeId, TLShapeId | undefined>()\n\n\tconst reparenting = new Map<TLShapeId, TLShape[]>()\n\n\tconst remainingShapesToReparent = new Set(shapesToActuallyCheck)\n\n\tconst potentialParentShapes = editor\n\t\t.getCurrentPageShapesSorted()\n\t\t// filter out any shapes that aren't frames or that are included among the provided shapes\n\t\t.filter(\n\t\t\t(s) =>\n\t\t\t\teditor.getShapeUtil(s).canReceiveNewChildrenOfType?.(s, s.type) &&\n\t\t\t\t!remainingShapesToReparent.has(s)\n\t\t)\n\n\tparentCheck: for (let i = potentialParentShapes.length - 1; i >= 0; i--) {\n\t\tconst parentShape = potentialParentShapes[i]\n\t\tconst parentShapeContainingGroupId = editor.findShapeAncestor(parentShape, (s) =>\n\t\t\teditor.isShapeOfType(s, 'group')\n\t\t)?.id\n\n\t\tconst parentGeometry = editor.getShapeGeometry(parentShape)\n\t\tconst parentPageTransform = editor.getShapePageTransform(parentShape)\n\t\tconst parentPageMaskVertices = editor.getShapeMask(parentShape)\n\t\tconst parentPageCorners = parentPageTransform.applyToPoints(parentGeometry.vertices)\n\t\tconst parentPagePolygon = parentPageMaskVertices\n\t\t\t? intersectPolygonPolygon(parentPageMaskVertices, parentPageCorners)\n\t\t\t: parentPageCorners\n\n\t\tif (!parentPagePolygon) continue parentCheck\n\n\t\tconst childrenToReparent = []\n\n\t\t// For each of the dropping shapes...\n\t\tshapeCheck: for (const shape of remainingShapesToReparent) {\n\t\t\t// Don't reparent a frame to itself\n\t\t\tif (parentShape.id === shape.id) continue shapeCheck\n\n\t\t\t// Use the callback to filter out certain shapes\n\t\t\tif (cb && !cb(shape, parentShape)) continue shapeCheck\n\n\t\t\tif (!shapeGroupIds.has(shape.id)) {\n\t\t\t\tshapeGroupIds.set(\n\t\t\t\t\tshape.id,\n\t\t\t\t\teditor.findShapeAncestor(shape, (s) => editor.isShapeOfType(s, 'group'))?.id\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst shapeGroupId = shapeGroupIds.get(shape.id)\n\n\t\t\t// Are the shape and the parent part of different groups?\n\t\t\tif (shapeGroupId !== parentShapeContainingGroupId) continue shapeCheck\n\n\t\t\t// Is the shape actually the ancestor of the parent?\n\t\t\tif (editor.findShapeAncestor(parentShape, (s) => shape.id === s.id)) continue shapeCheck\n\n\t\t\t// Convert the parent polygon to the shape's space\n\t\t\tconst parentPolygonInShapeSpace = editor\n\t\t\t\t.getShapePageTransform(shape)\n\t\t\t\t.clone()\n\t\t\t\t.invert()\n\t\t\t\t.applyToPoints(parentPagePolygon)\n\n\t\t\t// If the shape overlaps the parent polygon, reparent it to that parent\n\t\t\tif (editor.getShapeGeometry(shape).overlapsPolygon(parentPolygonInShapeSpace)) {\n\t\t\t\t// Use the util to check if the shape can be reparented to the parent\n\t\t\t\tif (\n\t\t\t\t\t!editor.getShapeUtil(parentShape).canReceiveNewChildrenOfType?.(parentShape, shape.type)\n\t\t\t\t)\n\t\t\t\t\tcontinue shapeCheck\n\n\t\t\t\tif (shape.parentId !== parentShape.id) {\n\t\t\t\t\tchildrenToReparent.push(shape)\n\t\t\t\t}\n\t\t\t\tremainingShapesToReparent.delete(shape)\n\t\t\t\tcontinue shapeCheck\n\t\t\t}\n\t\t}\n\n\t\tif (childrenToReparent.length) {\n\t\t\treparenting.set(parentShape.id, childrenToReparent)\n\t\t}\n\t}\n\n\treturn {\n\t\t// these are the shapes that will be reparented to new parents\n\t\treparenting,\n\t\t// these are the shapes that will be reparented to the page or their ancestral group\n\t\tremainingShapesToReparent,\n\t}\n}\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB;AAE5B,SAAmB,SAAS,eAAe,uBAAuB;AAElE,SAAS,+BAA+B;AAWjC,SAAS,sBACf,QACA,UACA,MACC;AACD,QAAM,iBAAiB,oBAAI,IAAa;AAExC,aAAW,MAAM,UAAU;AAC1B,UAAM,QAAQ,OAAO,SAAS,EAAE;AAEhC,QAAI,CAAC,MAAO;AACZ,mBAAe,IAAI,KAAK;AAExB,UAAM,SAAS,OAAO,SAAS,MAAM,QAAQ;AAC7C,QAAI,CAAC,OAAQ;AACb,mBAAe,IAAI,MAAM;AAAA,EAC1B;AAGA,QAAM,wBAAwB,oBAAI,IAA0B;AAE5D,aAAW,UAAU,gBAAgB;AACpC,UAAM,WAAW,OAAO,2BAA2B,MAAM;AACzD,QAAI,MAAM,UAAU,CAAC,KAAK,OAAO,MAAM,GAAG;AAEzC,4BAAsB,IAAI,QAAQ,QAAQ;AAAA,IAC3C,OAAO;AACN,YAAM,sBAAsB,qBAAqB,QAAQ,OAAO,IAAI,QAAQ;AAC5E,UAAI,oBAAoB,SAAS,SAAS,QAAQ;AACjD,8BAAsB;AAAA,UACrB;AAAA,UACA,SAAS,OAAO,CAAC,OAAO,CAAC,oBAAoB,SAAS,EAAE,CAAC;AAAA,QAC1D;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAGA,QAAM,iBAAiB,OAAO,2BAA2B,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE;AAE1E,QAAM,uBAGF,CAAC;AAEL,aAAW,CAAC,YAAY,eAAe,KAAK,uBAAuB;AAClE,UAAM,eAAe,QAAQ,gBAAgB,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,CAAC,CAAC;AAI7E,UAAM,EAAE,aAAa,0BAA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import { IndexKey, compact, getIndexAbove, getIndexBetween } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\nimport { intersectPolygonPolygon } from '../primitives/intersect'\n\n/**\n * Reparents shapes that are no longer contained within their parent shapes.\n *\n * @param editor - The editor instance.\n * @param shapeIds - The IDs of the shapes to reparent.\n * @param opts - Optional options, including a callback to filter out certain parents, such as when removing a frame.\n *\n * @public\n */\nexport function kickoutOccludedShapes(\n\teditor: Editor,\n\tshapeIds: TLShapeId[],\n\topts?: { filter?(parent: TLShape): boolean }\n) {\n\tconst parentsToCheck = new Set<TLShape>()\n\n\tfor (const id of shapeIds) {\n\t\tconst shape = editor.getShape(id)\n\n\t\tif (!shape) continue\n\t\tparentsToCheck.add(shape)\n\n\t\tconst parent = editor.getShape(shape.parentId)\n\t\tif (!parent) continue\n\t\tparentsToCheck.add(parent)\n\t}\n\n\t// Check all of the parents and gather up parents who have lost children\n\tconst parentsToLostChildren = new Map<TLShape, TLShapeId[]>()\n\n\tfor (const parent of parentsToCheck) {\n\t\tconst childIds = editor.getSortedChildIdsForParent(parent)\n\t\tif (opts?.filter && !opts.filter(parent)) {\n\t\t\t// If the shape is filtered out, we kick out all of its children\n\t\t\tparentsToLostChildren.set(parent, childIds)\n\t\t} else {\n\t\t\tconst overlappingChildren = getOverlappingShapes(editor, parent.id, childIds)\n\t\t\tif (overlappingChildren.length < childIds.length) {\n\t\t\t\tparentsToLostChildren.set(\n\t\t\t\t\tparent,\n\t\t\t\t\tchildIds.filter((id) => !overlappingChildren.includes(id))\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Get all of the shapes on the current page, sorted by their index\n\tconst sortedShapeIds = editor.getCurrentPageShapesSorted().map((s) => s.id)\n\n\tconst parentsToNewChildren: Record<\n\t\tTLParentId,\n\t\t{ parentId: TLParentId; shapeIds: TLShapeId[]; index?: IndexKey }\n\t> = {}\n\n\tfor (const [prevParent, lostChildrenIds] of parentsToLostChildren) {\n\t\tconst lostChildren = compact(lostChildrenIds.map((id) => editor.getShape(id)))\n\n\t\t// Otherwise, we have no next dropping shape under the cursor, so go find\n\t\t// all the frames on the page where the moving shapes will fall into\n\t\tconst { reparenting, remainingShapesToReparent } = getDroppedShapesToNewParents(\n\t\t\teditor,\n\t\t\tlostChildren,\n\t\t\t(shape, maybeNewParent) => {\n\t\t\t\t// If we're filtering out a potential parent, don't reparent shapes to the filtered out shape\n\t\t\t\tif (opts?.filter && !opts.filter(maybeNewParent)) return false\n\t\t\t\treturn (\n\t\t\t\t\tmaybeNewParent.id !== prevParent.id &&\n\t\t\t\t\tsortedShapeIds.indexOf(maybeNewParent.id) < sortedShapeIds.indexOf(shape.id)\n\t\t\t\t)\n\t\t\t}\n\t\t)\n\n\t\treparenting.forEach((childrenToReparent, newParentId) => {\n\t\t\tif (childrenToReparent.length === 0) return\n\t\t\tif (!parentsToNewChildren[newParentId]) {\n\t\t\t\tparentsToNewChildren[newParentId] = {\n\t\t\t\t\tparentId: newParentId,\n\t\t\t\t\tshapeIds: [],\n\t\t\t\t}\n\t\t\t}\n\t\t\tparentsToNewChildren[newParentId].shapeIds.push(...childrenToReparent.map((s) => s.id))\n\t\t})\n\n\t\t// Reparent the rest to the page (or containing group)\n\t\tif (remainingShapesToReparent.size > 0) {\n\t\t\t// The remaining shapes are going to be reparented to the old parent's containing group, if there was one, or else to the page\n\t\t\tconst newParentId =\n\t\t\t\teditor.findShapeAncestor(prevParent, (s) => editor.isShapeOfType(s, 'group'))?.id ??\n\t\t\t\teditor.getCurrentPageId()\n\n\t\t\tremainingShapesToReparent.forEach((shape) => {\n\t\t\t\tif (!parentsToNewChildren[newParentId]) {\n\t\t\t\t\tlet insertIndexKey: IndexKey | undefined\n\n\t\t\t\t\tconst oldParentSiblingIds = editor.getSortedChildIdsForParent(newParentId)\n\t\t\t\t\tconst oldParentIndex = oldParentSiblingIds.indexOf(prevParent.id)\n\t\t\t\t\tif (oldParentIndex > -1) {\n\t\t\t\t\t\t// If the old parent is a direct child of the new parent, then we'll add them above the old parent but below the next sibling.\n\t\t\t\t\t\tconst siblingsIndexAbove = oldParentSiblingIds[oldParentIndex + 1]\n\t\t\t\t\t\tconst siblingAboveIndex = siblingsIndexAbove\n\t\t\t\t\t\t\t? editor.getShape(siblingsIndexAbove)!.index\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\tconst indexKeyAbove =\n\t\t\t\t\t\t\tsiblingAboveIndex && siblingAboveIndex > prevParent.index\n\t\t\t\t\t\t\t\t? siblingAboveIndex\n\t\t\t\t\t\t\t\t: getIndexAbove(prevParent.index)\n\t\t\t\t\t\tinsertIndexKey = getIndexBetween(prevParent.index, indexKeyAbove)\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the old parent is not a direct child of the new parent, then we'll add them to the \"top\" of the new parent's children.\n\t\t\t\t\t\t// This is done automatically if we leave the index undefined, so let's do that.\n\t\t\t\t\t}\n\n\t\t\t\t\tparentsToNewChildren[newParentId] = {\n\t\t\t\t\t\tparentId: newParentId,\n\t\t\t\t\t\tshapeIds: [],\n\t\t\t\t\t\tindex: insertIndexKey,\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tparentsToNewChildren[newParentId].shapeIds.push(shape.id)\n\t\t\t})\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\tObject.values(parentsToNewChildren).forEach(({ parentId, shapeIds, index }) => {\n\t\t\tif (shapeIds.length === 0) return\n\t\t\t// Before we reparent, sort the new shape ids by their place in the original absolute order on the page\n\t\t\tshapeIds.sort((a, b) => (sortedShapeIds.indexOf(a) < sortedShapeIds.indexOf(b) ? -1 : 1))\n\t\t\teditor.reparentShapes(shapeIds, parentId, index)\n\t\t})\n\t})\n}\n\n/**\n * Get the shapes that overlap with a given shape.\n *\n * @param editor - The editor instance.\n * @param shape - The shapes or shape IDs to check against.\n * @param otherShapes - The shapes or shape IDs to check for overlap.\n * @returns An array of shapes or shape IDs that overlap with the given shape.\n */\nfunction getOverlappingShapes<T extends TLShape[] | TLShapeId[]>(\n\teditor: Editor,\n\tshape: T[number],\n\totherShapes: T\n) {\n\tif (otherShapes.length === 0) {\n\t\treturn EMPTY_ARRAY\n\t}\n\n\tconst parentPageBounds = editor.getShapePageBounds(shape)\n\tif (!parentPageBounds) return EMPTY_ARRAY\n\n\tconst _shape = editor.getShape(shape)\n\tif (!_shape) return EMPTY_ARRAY\n\n\tconst parentGeometry = editor.getShapeGeometry(shape)\n\tconst parentPageTransform = editor.getShapePageTransform(shape)\n\tconst parentPageCorners = parentPageTransform.applyToPoints(parentGeometry.vertices)\n\n\tconst clipPath = editor.getShapeUtil(_shape.type).getClipPath?.(_shape)\n\n\tconst parentPageMaskVertices = clipPath ? parentPageTransform.applyToPoints(clipPath) : undefined\n\tconst parentPagePolygon = parentPageMaskVertices\n\t\t? intersectPolygonPolygon(parentPageMaskVertices, parentPageCorners)\n\t\t: parentPageCorners\n\n\tif (!parentPagePolygon) return EMPTY_ARRAY\n\n\treturn otherShapes.filter((childId) => {\n\t\tconst shapePageBounds = editor.getShapePageBounds(childId)\n\t\tif (!shapePageBounds || !parentPageBounds.includes(shapePageBounds)) return false\n\n\t\tconst parentPolygonInShapeShape = editor\n\t\t\t.getShapePageTransform(childId)\n\t\t\t.clone()\n\t\t\t.invert()\n\t\t\t.applyToPoints(parentPagePolygon)\n\n\t\tconst geometry = editor.getShapeGeometry(childId)\n\n\t\treturn geometry.overlapsPolygon(parentPolygonInShapeShape)\n\t})\n}\n\n/**\n * Get the shapes that will be reparented to new parents when the shapes are dropped.\n *\n * @param editor - The editor instance.\n * @param shapes - The shapes to check.\n * @param cb - A callback to filter out certain shapes.\n * @returns An object with the shapes that will be reparented to new parents and the shapes that will be reparented to the page or their ancestral group.\n *\n * @public\n */\nexport function getDroppedShapesToNewParents(\n\teditor: Editor,\n\tshapes: Set<TLShape> | TLShape[],\n\tcb?: (shape: TLShape, parent: TLShape) => boolean\n) {\n\tconst shapesToActuallyCheck = new Set<TLShape>(shapes)\n\tconst movingGroups = new Set<TLGroupShape>()\n\n\tfor (const shape of shapes) {\n\t\tconst parent = editor.getShapeParent(shape)\n\t\tif (parent && editor.isShapeOfType(parent, 'group')) {\n\t\t\tif (!movingGroups.has(parent)) {\n\t\t\t\tmovingGroups.add(parent)\n\t\t\t}\n\t\t}\n\t}\n\n\t// If all of a group's children are moving, then move the group instead\n\tfor (const movingGroup of movingGroups) {\n\t\tconst children = compact(\n\t\t\teditor.getSortedChildIdsForParent(movingGroup).map((id) => editor.getShape(id))\n\t\t)\n\t\tfor (const child of children) {\n\t\t\tshapesToActuallyCheck.delete(child)\n\t\t}\n\t\tshapesToActuallyCheck.add(movingGroup)\n\t}\n\n\t// this could be cached and passed in\n\tconst shapeGroupIds = new Map<TLShapeId, TLShapeId | undefined>()\n\n\tconst reparenting = new Map<TLShapeId, TLShape[]>()\n\n\tconst remainingShapesToReparent = new Set(shapesToActuallyCheck)\n\n\tconst potentialParentShapes = editor\n\t\t.getCurrentPageShapesSorted()\n\t\t// filter out any shapes that aren't frames or that are included among the provided shapes\n\t\t.filter(\n\t\t\t(s) =>\n\t\t\t\teditor.getShapeUtil(s).canReceiveNewChildrenOfType?.(s, s.type) &&\n\t\t\t\t!remainingShapesToReparent.has(s)\n\t\t)\n\n\tparentCheck: for (let i = potentialParentShapes.length - 1; i >= 0; i--) {\n\t\tconst parentShape = potentialParentShapes[i]\n\t\tconst parentShapeContainingGroupId = editor.findShapeAncestor(parentShape, (s) =>\n\t\t\teditor.isShapeOfType(s, 'group')\n\t\t)?.id\n\n\t\tconst parentGeometry = editor.getShapeGeometry(parentShape)\n\t\tconst parentPageTransform = editor.getShapePageTransform(parentShape)\n\t\tconst parentPageMaskVertices = editor.getShapeMask(parentShape)\n\t\tconst parentPageCorners = parentPageTransform.applyToPoints(parentGeometry.vertices)\n\t\tconst parentPagePolygon = parentPageMaskVertices\n\t\t\t? intersectPolygonPolygon(parentPageMaskVertices, parentPageCorners)\n\t\t\t: parentPageCorners\n\n\t\tif (!parentPagePolygon) continue parentCheck\n\n\t\tconst childrenToReparent = []\n\n\t\t// For each of the dropping shapes...\n\t\tshapeCheck: for (const shape of remainingShapesToReparent) {\n\t\t\t// Don't reparent a frame to itself\n\t\t\tif (parentShape.id === shape.id) continue shapeCheck\n\n\t\t\t// Use the callback to filter out certain shapes\n\t\t\tif (cb && !cb(shape, parentShape)) continue shapeCheck\n\n\t\t\tif (!shapeGroupIds.has(shape.id)) {\n\t\t\t\tshapeGroupIds.set(\n\t\t\t\t\tshape.id,\n\t\t\t\t\teditor.findShapeAncestor(shape, (s) => editor.isShapeOfType(s, 'group'))?.id\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst shapeGroupId = shapeGroupIds.get(shape.id)\n\n\t\t\t// Are the shape and the parent part of different groups?\n\t\t\tif (shapeGroupId !== parentShapeContainingGroupId) continue shapeCheck\n\n\t\t\t// Is the shape actually the ancestor of the parent?\n\t\t\tif (editor.findShapeAncestor(parentShape, (s) => shape.id === s.id)) continue shapeCheck\n\n\t\t\t// Convert the parent polygon to the shape's space\n\t\t\tconst parentPolygonInShapeSpace = editor\n\t\t\t\t.getShapePageTransform(shape)\n\t\t\t\t.clone()\n\t\t\t\t.invert()\n\t\t\t\t.applyToPoints(parentPagePolygon)\n\n\t\t\t// If the shape overlaps the parent polygon, reparent it to that parent\n\t\t\tif (editor.getShapeGeometry(shape).overlapsPolygon(parentPolygonInShapeSpace)) {\n\t\t\t\t// Use the util to check if the shape can be reparented to the parent\n\t\t\t\tif (\n\t\t\t\t\t!editor.getShapeUtil(parentShape).canReceiveNewChildrenOfType?.(parentShape, shape.type)\n\t\t\t\t)\n\t\t\t\t\tcontinue shapeCheck\n\n\t\t\t\tif (shape.parentId !== parentShape.id) {\n\t\t\t\t\tchildrenToReparent.push(shape)\n\t\t\t\t}\n\t\t\t\tremainingShapesToReparent.delete(shape)\n\t\t\t\tcontinue shapeCheck\n\t\t\t}\n\t\t}\n\n\t\tif (childrenToReparent.length) {\n\t\t\treparenting.set(parentShape.id, childrenToReparent)\n\t\t}\n\t}\n\n\treturn {\n\t\t// these are the shapes that will be reparented to new parents\n\t\treparenting,\n\t\t// these are the shapes that will be reparented to the page or their ancestral group\n\t\tremainingShapesToReparent,\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,mBAAmB;AAE5B,SAAmB,SAAS,eAAe,uBAAuB;AAElE,SAAS,+BAA+B;AAWjC,SAAS,sBACf,QACA,UACA,MACC;AACD,QAAM,iBAAiB,oBAAI,IAAa;AAExC,aAAW,MAAM,UAAU;AAC1B,UAAM,QAAQ,OAAO,SAAS,EAAE;AAEhC,QAAI,CAAC,MAAO;AACZ,mBAAe,IAAI,KAAK;AAExB,UAAM,SAAS,OAAO,SAAS,MAAM,QAAQ;AAC7C,QAAI,CAAC,OAAQ;AACb,mBAAe,IAAI,MAAM;AAAA,EAC1B;AAGA,QAAM,wBAAwB,oBAAI,IAA0B;AAE5D,aAAW,UAAU,gBAAgB;AACpC,UAAM,WAAW,OAAO,2BAA2B,MAAM;AACzD,QAAI,MAAM,UAAU,CAAC,KAAK,OAAO,MAAM,GAAG;AAEzC,4BAAsB,IAAI,QAAQ,QAAQ;AAAA,IAC3C,OAAO;AACN,YAAM,sBAAsB,qBAAqB,QAAQ,OAAO,IAAI,QAAQ;AAC5E,UAAI,oBAAoB,SAAS,SAAS,QAAQ;AACjD,8BAAsB;AAAA,UACrB;AAAA,UACA,SAAS,OAAO,CAAC,OAAO,CAAC,oBAAoB,SAAS,EAAE,CAAC;AAAA,QAC1D;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAGA,QAAM,iBAAiB,OAAO,2BAA2B,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE;AAE1E,QAAM,uBAGF,CAAC;AAEL,aAAW,CAAC,YAAY,eAAe,KAAK,uBAAuB;AAClE,UAAM,eAAe,QAAQ,gBAAgB,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,CAAC,CAAC;AAI7E,UAAM,EAAE,aAAa,0BAA0B,IAAI;AAAA,MAClD;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,
3
3
  "sources": ["../../../src/lib/utils/richText.ts"],
4
- "sourcesContent": ["import { getSchema, JSONContent, Editor as TTEditor } from '@tiptap/core'\nimport { Node, Schema } from '@tiptap/pm/model'\nimport { EditorProviderProps } from '@tiptap/react'\nimport { TLRichText } from '@tldraw/tlschema'\nimport { assert, WeakCache } from '@tldraw/utils'\nimport type { Editor } from '../editor/Editor'\nimport { TLFontFace } from '../editor/managers/FontManager/FontManager'\n\n/**\n * This is the TipTap editor! Docs are {@link https://tiptap.dev/docs}.\n *\n * @public\n */\nexport type TiptapEditor = TTEditor\n\n/**\n * A TipTap node. See {@link https://tiptap.dev/docs}.\n * @public\n */\nexport type TiptapNode = Node\n\n/** @public */\nexport interface TLTextOptions {\n\ttipTapConfig?: EditorProviderProps\n\taddFontsFromNode?: RichTextFontVisitor\n}\n\n/** @public */\nexport interface RichTextFontVisitorState {\n\treadonly family: string\n\treadonly weight: string\n\treadonly style: string\n}\n\n/** @public */\nexport type RichTextFontVisitor = (\n\tnode: TiptapNode,\n\tstate: RichTextFontVisitorState,\n\taddFont: (font: TLFontFace) => void\n) => RichTextFontVisitorState\n\nconst schemaCache = new WeakCache<EditorProviderProps, Schema>()\nexport function getTipTapSchema(tipTapConfig: EditorProviderProps) {\n\treturn schemaCache.get(tipTapConfig, () => getSchema(tipTapConfig.extensions ?? []))\n}\n\n/** @public */\nexport function getFontsFromRichText(\n\teditor: Editor,\n\trichText: TLRichText,\n\tinitialState: RichTextFontVisitorState\n) {\n\tconst { tipTapConfig, addFontsFromNode } = editor.getTextOptions()\n\tassert(tipTapConfig, 'textOptions.tipTapConfig must be set to use rich text')\n\tassert(addFontsFromNode, 'textOptions.addFontsFromNode must be set to use rich text')\n\n\tconst schema = getTipTapSchema(tipTapConfig)\n\n\tconst rootNode = Node.fromJSON(schema, richText as JSONContent)\n\n\tconst fonts = new Set<TLFontFace>()\n\n\tfunction addFont(font: TLFontFace) {\n\t\tfonts.add(font)\n\t}\n\n\tfunction visit(node: TiptapNode, state: RichTextFontVisitorState) {\n\t\tstate = addFontsFromNode!(node, state, addFont)\n\n\t\tfor (const child of node.children) {\n\t\t\tvisit(child, state)\n\t\t}\n\t}\n\n\tvisit(rootNode, initialState)\n\n\treturn Array.from(fonts)\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAAkD;AAC3D,SAAS,YAAoB;AAG7B,SAAS,QAAQ,iBAAiB;AAqClC,MAAM,cAAc,IAAI,UAAuC;AACxD,SAAS,gBAAgB,cAAmC;AAClE,SAAO,YAAY,IAAI,cAAc,MAAM,UAAU,aAAa,cAAc,CAAC,CAAC,CAAC;AACpF;AAGO,SAAS,qBACf,QACA,UACA,cACC;AACD,QAAM,EAAE,cAAc,iBAAiB,IAAI,OAAO,eAAe;AACjE,SAAO,cAAc,uDAAuD;AAC5E,SAAO,kBAAkB,2DAA2D;AAEpF,QAAM,SAAS,gBAAgB,YAAY;AAE3C,QAAM,WAAW,KAAK,SAAS,QAAQ,QAAuB;AAE9D,QAAM,QAAQ,oBAAI,IAAgB;AAElC,WAAS,QAAQ,MAAkB;AAClC,UAAM,IAAI,IAAI;AAAA,EACf;AAEA,WAAS,MAAM,MAAkB,OAAiC;AACjE,YAAQ,iBAAkB,MAAM,OAAO,OAAO;AAE9C,eAAW,SAAS,KAAK,UAAU;AAClC,YAAM,OAAO,KAAK;AAAA,IACnB;AAAA,EACD;AAEA,QAAM,UAAU,YAAY;AAE5B,SAAO,MAAM,KAAK,KAAK;AACxB;",
4
+ "sourcesContent": ["import { getSchema, JSONContent, Editor as TTEditor } from '@tiptap/core'\nimport { Node, Schema } from '@tiptap/pm/model'\nimport { EditorProviderProps } from '@tiptap/react'\nimport { TLRichText } from '@tldraw/tlschema'\nimport { TLFontFace } from '@tldraw/tlschema'\nimport { assert, WeakCache } from '@tldraw/utils'\nimport type { Editor } from '../editor/Editor'\n\n/**\n * This is the TipTap editor! Docs are {@link https://tiptap.dev/docs}.\n *\n * @public\n */\nexport type TiptapEditor = TTEditor\n\n/**\n * A TipTap node. See {@link https://tiptap.dev/docs}.\n * @public\n */\nexport type TiptapNode = Node\n\n/** @public */\nexport interface TLTextOptions {\n\ttipTapConfig?: EditorProviderProps\n\taddFontsFromNode?: RichTextFontVisitor\n}\n\n/** @public */\nexport interface RichTextFontVisitorState {\n\treadonly family: string\n\treadonly weight: string\n\treadonly style: string\n}\n\n/** @public */\nexport type RichTextFontVisitor = (\n\tnode: TiptapNode,\n\tstate: RichTextFontVisitorState,\n\taddFont: (font: TLFontFace) => void\n) => RichTextFontVisitorState\n\nconst schemaCache = new WeakCache<EditorProviderProps, Schema>()\nexport function getTipTapSchema(tipTapConfig: EditorProviderProps) {\n\treturn schemaCache.get(tipTapConfig, () => getSchema(tipTapConfig.extensions ?? []))\n}\n\n/** @public */\nexport function getFontsFromRichText(\n\teditor: Editor,\n\trichText: TLRichText,\n\tinitialState: RichTextFontVisitorState\n) {\n\tconst { tipTapConfig, addFontsFromNode } = editor.getTextOptions()\n\tassert(tipTapConfig, 'textOptions.tipTapConfig must be set to use rich text')\n\tassert(addFontsFromNode, 'textOptions.addFontsFromNode must be set to use rich text')\n\n\tconst schema = getTipTapSchema(tipTapConfig)\n\n\tconst rootNode = Node.fromJSON(schema, richText as JSONContent)\n\n\tconst fonts = new Set<TLFontFace>()\n\n\tfunction addFont(font: TLFontFace) {\n\t\tfonts.add(font)\n\t}\n\n\tfunction visit(node: TiptapNode, state: RichTextFontVisitorState) {\n\t\tstate = addFontsFromNode!(node, state, addFont)\n\n\t\tfor (const child of node.children) {\n\t\t\tvisit(child, state)\n\t\t}\n\t}\n\n\tvisit(rootNode, initialState)\n\n\treturn Array.from(fonts)\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAkD;AAC3D,SAAS,YAAoB;AAI7B,SAAS,QAAQ,iBAAiB;AAoClC,MAAM,cAAc,IAAI,UAAuC;AACxD,SAAS,gBAAgB,cAAmC;AAClE,SAAO,YAAY,IAAI,cAAc,MAAM,UAAU,aAAa,cAAc,CAAC,CAAC,CAAC;AACpF;AAGO,SAAS,qBACf,QACA,UACA,cACC;AACD,QAAM,EAAE,cAAc,iBAAiB,IAAI,OAAO,eAAe;AACjE,SAAO,cAAc,uDAAuD;AAC5E,SAAO,kBAAkB,2DAA2D;AAEpF,QAAM,SAAS,gBAAgB,YAAY;AAE3C,QAAM,WAAW,KAAK,SAAS,QAAQ,QAAuB;AAE9D,QAAM,QAAQ,oBAAI,IAAgB;AAElC,WAAS,QAAQ,MAAkB;AAClC,UAAM,IAAI,IAAI;AAAA,EACf;AAEA,WAAS,MAAM,MAAkB,OAAiC;AACjE,YAAQ,iBAAkB,MAAM,OAAO,OAAO;AAE9C,eAAW,SAAS,KAAK,UAAU;AAClC,YAAM,OAAO,KAAK;AAAA,IACnB;AAAA,EACD;AAEA,QAAM,UAAU,YAAY;AAE5B,SAAO,MAAM,KAAK,KAAK;AACxB;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ import { hardReset } from "./sync/hardReset.mjs";
1
2
  const runtime = {
2
3
  openWindow(url, target, allowReferrer = false) {
3
4
  return window.open(url, target, allowReferrer ? "noopener" : "noopener noreferrer");
@@ -6,7 +7,7 @@ const runtime = {
6
7
  window.location.reload();
7
8
  },
8
9
  async hardReset() {
9
- return await window.__tldraw__hardReset?.();
10
+ return await hardReset({ shouldReload: true });
10
11
  }
11
12
  };
12
13
  function setRuntimeOverrides(input) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/runtime.ts"],
4
- "sourcesContent": ["/** @public */\nexport const runtime: {\n\topenWindow(url: string, target: string, allowReferrer?: boolean): void\n\trefreshPage(): void\n\thardReset(): Promise<void>\n} = {\n\topenWindow(url, target, allowReferrer = false) {\n\t\treturn window.open(url, target, allowReferrer ? 'noopener' : 'noopener noreferrer')\n\t},\n\trefreshPage() {\n\t\twindow.location.reload()\n\t},\n\tasync hardReset() {\n\t\treturn await (window as any).__tldraw__hardReset?.()\n\t},\n}\n\n/** @public */\nexport function setRuntimeOverrides(input: Partial<typeof runtime>) {\n\tObject.assign(runtime, input)\n}\n\n/**\n * Open a new window with the given URL and target. Prefer this to the window.open function, as it\n * will work more reliably in embedded scenarios, such as our VS Code extension. See the runtime\n * object in tldraw/editor for more details.\n *\n * @param url - The URL to open.\n * @param target - The target window to open the URL in.\n * @param allowReferrer - Whether to allow the referrer to be sent to the new window.\n * @returns The new window object.\n * @public\n */\nexport function openWindow(url: string, target = '_blank', allowReferrer?: boolean) {\n\treturn runtime.openWindow(url, target, allowReferrer)\n}\n\n/** @public */\nexport function refreshPage() {\n\truntime.refreshPage()\n}\n\n/** @public */\nexport function hardResetEditor() {\n\truntime.hardReset()\n}\n"],
5
- "mappings": "AACO,MAAM,UAIT;AAAA,EACH,WAAW,KAAK,QAAQ,gBAAgB,OAAO;AAC9C,WAAO,OAAO,KAAK,KAAK,QAAQ,gBAAgB,aAAa,qBAAqB;AAAA,EACnF;AAAA,EACA,cAAc;AACb,WAAO,SAAS,OAAO;AAAA,EACxB;AAAA,EACA,MAAM,YAAY;AACjB,WAAO,MAAO,OAAe,sBAAsB;AAAA,EACpD;AACD;AAGO,SAAS,oBAAoB,OAAgC;AACnE,SAAO,OAAO,SAAS,KAAK;AAC7B;AAaO,SAAS,WAAW,KAAa,SAAS,UAAU,eAAyB;AACnF,SAAO,QAAQ,WAAW,KAAK,QAAQ,aAAa;AACrD;AAGO,SAAS,cAAc;AAC7B,UAAQ,YAAY;AACrB;AAGO,SAAS,kBAAkB;AACjC,UAAQ,UAAU;AACnB;",
4
+ "sourcesContent": ["import { hardReset } from './sync/hardReset'\n\n/** @public */\nexport const runtime: {\n\topenWindow(url: string, target: string, allowReferrer?: boolean): void\n\trefreshPage(): void\n\thardReset(): Promise<void>\n} = {\n\topenWindow(url, target, allowReferrer = false) {\n\t\treturn window.open(url, target, allowReferrer ? 'noopener' : 'noopener noreferrer')\n\t},\n\trefreshPage() {\n\t\twindow.location.reload()\n\t},\n\tasync hardReset() {\n\t\treturn await hardReset({ shouldReload: true })\n\t},\n}\n\n/** @public */\nexport function setRuntimeOverrides(input: Partial<typeof runtime>) {\n\tObject.assign(runtime, input)\n}\n\n/**\n * Open a new window with the given URL and target. Prefer this to the window.open function, as it\n * will work more reliably in embedded scenarios, such as our VS Code extension. See the runtime\n * object in tldraw/editor for more details.\n *\n * @param url - The URL to open.\n * @param target - The target window to open the URL in.\n * @param allowReferrer - Whether to allow the referrer to be sent to the new window.\n * @returns The new window object.\n * @public\n */\nexport function openWindow(url: string, target = '_blank', allowReferrer?: boolean) {\n\treturn runtime.openWindow(url, target, allowReferrer)\n}\n\n/** @public */\nexport function refreshPage() {\n\truntime.refreshPage()\n}\n\n/** @public */\nexport function hardResetEditor() {\n\truntime.hardReset()\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,UAIT;AAAA,EACH,WAAW,KAAK,QAAQ,gBAAgB,OAAO;AAC9C,WAAO,OAAO,KAAK,KAAK,QAAQ,gBAAgB,aAAa,qBAAqB;AAAA,EACnF;AAAA,EACA,cAAc;AACb,WAAO,SAAS,OAAO;AAAA,EACxB;AAAA,EACA,MAAM,YAAY;AACjB,WAAO,MAAM,UAAU,EAAE,cAAc,KAAK,CAAC;AAAA,EAC9C;AACD;AAGO,SAAS,oBAAoB,OAAgC;AACnE,SAAO,OAAO,SAAS,KAAK;AAC7B;AAaO,SAAS,WAAW,KAAa,SAAS,UAAU,eAAyB;AACnF,SAAO,QAAQ,WAAW,KAAK,QAAQ,aAAa;AACrD;AAGO,SAAS,cAAc;AAC7B,UAAQ,YAAY;AACrB;AAGO,SAAS,kBAAkB;AACjC,UAAQ,UAAU;AACnB;",
6
6
  "names": []
7
7
  }
@@ -7,11 +7,11 @@ import {
7
7
  extractSessionStateFromLegacySnapshot,
8
8
  loadSessionStateSnapshotIntoStore
9
9
  } from "../../config/TLSessionStateSnapshot.mjs";
10
- import { LocalIndexedDb } from "./LocalIndexedDb.mjs";
11
10
  import { showCantReadFromIndexDbAlert, showCantWriteToIndexDbAlert } from "./alerts.mjs";
11
+ import { LocalIndexedDb } from "./LocalIndexedDb.mjs";
12
12
  const PERSIST_THROTTLE_MS = 350;
13
13
  const PERSIST_RETRY_THROTTLE_MS = 1e4;
14
- const UPDATE_INSTANCE_STATE = Symbol("UPDATE_INSTANCE_STATE");
14
+ const UPDATE_INSTANCE_STATE = /* @__PURE__ */ Symbol("UPDATE_INSTANCE_STATE");
15
15
  const msg = (msg2) => msg2;
16
16
  class BroadcastChannelMock {
17
17
  onmessage;
@@ -77,6 +77,8 @@ class TLLocalSyncClient {
77
77
  Object.values(this.store.schema.types).filter((t) => t.scope === "document").map((t) => t.typeName)
78
78
  );
79
79
  }
80
+ store;
81
+ channel;
80
82
  disposables = /* @__PURE__ */ new Set();
81
83
  diffQueue = [];
82
84
  didDispose = false;
@@ -182,9 +184,13 @@ class TLLocalSyncClient {
182
184
  this.debug("closing");
183
185
  this.didDispose = true;
184
186
  this.disposables.forEach((d) => d());
187
+ if (typeof window !== "undefined" && window.tlsync === this) {
188
+ delete window.tlsync;
189
+ }
185
190
  }
186
191
  isPersisting = false;
187
192
  didLastWriteError = false;
193
+ // eslint-disable-next-line no-restricted-globals
188
194
  scheduledPersistTimeout = null;
189
195
  /**
190
196
  * Schedule a persist. Persists don't happen immediately: they are throttled to avoid writing too
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/utils/sync/TLLocalSyncClient.ts"],
4
- "sourcesContent": ["import { Signal, transact } from '@tldraw/state'\nimport { RecordsDiff, SerializedSchema, UnknownRecord, squashRecordDiffs } from '@tldraw/store'\nimport { TLStore } from '@tldraw/tlschema'\nimport { assert } from '@tldraw/utils'\nimport {\n\tTAB_ID,\n\tTLSessionStateSnapshot,\n\tcreateSessionStateSnapshotSignal,\n\textractSessionStateFromLegacySnapshot,\n\tloadSessionStateSnapshotIntoStore,\n} from '../../config/TLSessionStateSnapshot'\nimport { LocalIndexedDb } from './LocalIndexedDb'\nimport { showCantReadFromIndexDbAlert, showCantWriteToIndexDbAlert } from './alerts'\n\n/** How should we debounce persists? */\nconst PERSIST_THROTTLE_MS = 350\n/** If we're in an error state, how long should we wait before retrying a write? */\nconst PERSIST_RETRY_THROTTLE_MS = 10_000\n\nconst UPDATE_INSTANCE_STATE = Symbol('UPDATE_INSTANCE_STATE')\n\n/**\n * IMPORTANT!!!\n *\n * This is just a quick-n-dirty temporary solution that will be replaced with the remote sync client\n * once it has the db integrated\n */\n\ninterface SyncMessage {\n\ttype: 'diff'\n\tstoreId: string\n\tchanges: RecordsDiff<UnknownRecord>\n\tschema: SerializedSchema\n}\n\n// Sent by new clients when they connect\n// If another client is on the channel with a newer schema version\n// It will\ninterface AnnounceMessage {\n\ttype: 'announce'\n\tschema: SerializedSchema\n}\n\ntype Message = SyncMessage | AnnounceMessage\n\ntype UnpackPromise<T> = T extends Promise<infer U> ? U : T\n\nconst msg = (msg: Message) => msg\n\n/** @internal */\nexport class BroadcastChannelMock {\n\tonmessage?: (e: MessageEvent) => void\n\tconstructor(_name: string) {\n\t\t// noop\n\t}\n\tpostMessage(_msg: Message) {\n\t\t// noop\n\t}\n\tclose() {\n\t\t// noop\n\t}\n}\n\nconst BC = typeof BroadcastChannel === 'undefined' ? BroadcastChannelMock : BroadcastChannel\n\n/** @internal */\nexport class TLLocalSyncClient {\n\tprivate disposables = new Set<() => void>()\n\tprivate diffQueue: Array<RecordsDiff<UnknownRecord> | typeof UPDATE_INSTANCE_STATE> = []\n\tprivate didDispose = false\n\tprivate shouldDoFullDBWrite = true\n\tprivate isReloading = false\n\treadonly persistenceKey: string\n\treadonly sessionId: string\n\treadonly serializedSchema: SerializedSchema\n\tprivate isDebugging = false\n\tprivate readonly documentTypes: ReadonlySet<string>\n\tprivate readonly $sessionStateSnapshot: Signal<TLSessionStateSnapshot | null>\n\t/** @internal */\n\treadonly db: LocalIndexedDb\n\n\tinitTime = Date.now()\n\tprivate debug(...args: any[]) {\n\t\tif (this.isDebugging) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.debug(...args)\n\t\t}\n\t}\n\tconstructor(\n\t\tpublic readonly store: TLStore,\n\t\t{\n\t\t\tpersistenceKey,\n\t\t\tsessionId = TAB_ID,\n\t\t\tonLoad,\n\t\t\tonLoadError,\n\t\t}: {\n\t\t\tpersistenceKey: string\n\t\t\tsessionId?: string\n\t\t\tonLoad(self: TLLocalSyncClient): void\n\t\t\tonLoadError(error: Error): void\n\t\t},\n\t\tpublic readonly channel = new BC(`tldraw-tab-sync-${persistenceKey}`)\n\t) {\n\t\tif (typeof window !== 'undefined') {\n\t\t\t;(window as any).tlsync = this\n\t\t}\n\t\tthis.persistenceKey = persistenceKey\n\t\tthis.sessionId = sessionId\n\t\tthis.db = new LocalIndexedDb(persistenceKey)\n\t\tthis.disposables.add(() => this.db.close())\n\n\t\tthis.serializedSchema = this.store.schema.serialize()\n\t\tthis.$sessionStateSnapshot = createSessionStateSnapshotSignal(this.store)\n\n\t\tthis.disposables.add(\n\t\t\t// Set up a subscription to changes from the store: When\n\t\t\t// the store changes (and if the change was made by the user)\n\t\t\t// then immediately send the diff to other tabs via postMessage\n\t\t\t// and schedule a persist.\n\t\t\tstore.listen(\n\t\t\t\t({ changes }) => {\n\t\t\t\t\tthis.diffQueue.push(changes)\n\t\t\t\t\tthis.channel.postMessage(\n\t\t\t\t\t\tmsg({\n\t\t\t\t\t\t\ttype: 'diff',\n\t\t\t\t\t\t\tstoreId: this.store.id,\n\t\t\t\t\t\t\tchanges,\n\t\t\t\t\t\t\tschema: this.serializedSchema,\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t\tthis.schedulePersist()\n\t\t\t\t},\n\t\t\t\t{ source: 'user', scope: 'document' }\n\t\t\t)\n\t\t)\n\t\tthis.disposables.add(\n\t\t\tstore.listen(\n\t\t\t\t() => {\n\t\t\t\t\tthis.diffQueue.push(UPDATE_INSTANCE_STATE)\n\t\t\t\t\tthis.schedulePersist()\n\t\t\t\t},\n\t\t\t\t{ scope: 'session' }\n\t\t\t)\n\t\t)\n\n\t\tthis.connect(onLoad, onLoadError)\n\n\t\tthis.documentTypes = new Set(\n\t\t\tObject.values(this.store.schema.types)\n\t\t\t\t.filter((t) => t.scope === 'document')\n\t\t\t\t.map((t) => t.typeName)\n\t\t)\n\t}\n\n\tprivate async connect(onLoad: (client: this) => void, onLoadError: (error: Error) => void) {\n\t\tthis.debug('connecting')\n\t\tlet data: UnpackPromise<ReturnType<LocalIndexedDb['load']>> | undefined\n\n\t\ttry {\n\t\t\tdata = await this.db.load({ sessionId: this.sessionId })\n\t\t} catch (error: any) {\n\t\t\tonLoadError(error)\n\t\t\tshowCantReadFromIndexDbAlert()\n\t\t\treturn\n\t\t}\n\n\t\tthis.debug('loaded data from store', data, 'didDispose', this.didDispose)\n\t\tif (this.didDispose) return\n\n\t\ttry {\n\t\t\tif (data) {\n\t\t\t\tconst documentSnapshot = Object.fromEntries(data.records.map((r) => [r.id, r]))\n\t\t\t\tconst sessionStateSnapshot =\n\t\t\t\t\tdata.sessionStateSnapshot ?? extractSessionStateFromLegacySnapshot(documentSnapshot)\n\t\t\t\tconst migrationResult = this.store.schema.migrateStoreSnapshot({\n\t\t\t\t\tstore: documentSnapshot,\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\t\t\t\tschema: data.schema ?? this.store.schema.serializeEarliestVersion(),\n\t\t\t\t})\n\n\t\t\t\tif (migrationResult.type === 'error') {\n\t\t\t\t\tconsole.error('failed to migrate store', migrationResult)\n\t\t\t\t\tonLoadError(new Error(`Failed to migrate store: ${migrationResult.reason}`))\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst records = Object.values(migrationResult.value).filter((r) =>\n\t\t\t\t\tthis.documentTypes.has(r.typeName)\n\t\t\t\t)\n\t\t\t\tif (records.length > 0) {\n\t\t\t\t\t// 3. Merge the changes into the REAL STORE\n\t\t\t\t\tthis.store.mergeRemoteChanges(() => {\n\t\t\t\t\t\t// Calling put will validate the records!\n\t\t\t\t\t\tthis.store.put(records, 'initialize')\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tif (sessionStateSnapshot) {\n\t\t\t\t\tloadSessionStateSnapshotIntoStore(this.store, sessionStateSnapshot, {\n\t\t\t\t\t\tforceOverwrite: true,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.channel.onmessage = ({ data }) => {\n\t\t\t\tthis.debug('got message', data)\n\t\t\t\tconst msg = data as Message\n\t\t\t\t// if their schema is earlier than ours, we need to tell them so they can refresh\n\t\t\t\t// if their schema is later than ours, we need to refresh\n\t\t\t\tconst res = this.store.schema.getMigrationsSince(msg.schema)\n\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\t// we are older, refresh\n\t\t\t\t\t// but add a safety check to make sure we don't get in an infinite loop\n\t\t\t\t\tconst timeSinceInit = Date.now() - this.initTime\n\t\t\t\t\tif (timeSinceInit < 5000) {\n\t\t\t\t\t\t// This tab was just reloaded, but is out of date compared to other tabs.\n\t\t\t\t\t\t// Not expecting this to ever happen. It should only happen if we roll back a release that incremented\n\t\t\t\t\t\t// the schema version (which we should never do)\n\t\t\t\t\t\t// Or maybe during development if you have multiple local tabs open running the app on prod mode and you\n\t\t\t\t\t\t// check out an older commit. Dev server should be fine.\n\t\t\t\t\t\tonLoadError(new Error('Schema mismatch, please close other tabs and reload the page'))\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthis.debug('reloading')\n\t\t\t\t\tthis.isReloading = true\n\t\t\t\t\twindow?.location?.reload?.()\n\t\t\t\t\treturn\n\t\t\t\t} else if (res.value.length > 0) {\n\t\t\t\t\t// they are older, tell them to refresh and not write any more data\n\t\t\t\t\tthis.debug('telling them to reload')\n\t\t\t\t\tthis.channel.postMessage({ type: 'announce', schema: this.serializedSchema })\n\t\t\t\t\t// schedule a full db write in case they wrote data anyway\n\t\t\t\t\tthis.shouldDoFullDBWrite = true\n\t\t\t\t\tthis.persistIfNeeded()\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\t// otherwise, all good, same version :)\n\t\t\t\tif (msg.type === 'diff') {\n\t\t\t\t\tthis.debug('applying diff')\n\t\t\t\t\ttransact(() => {\n\t\t\t\t\t\tthis.store.mergeRemoteChanges(() => {\n\t\t\t\t\t\t\tthis.store.applyDiff(msg.changes as any)\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.channel.postMessage({ type: 'announce', schema: this.serializedSchema })\n\t\t\tthis.disposables.add(() => {\n\t\t\t\tthis.channel.close()\n\t\t\t})\n\t\t\tonLoad(this)\n\t\t} catch (e: any) {\n\t\t\tthis.debug('error loading data from store', e)\n\t\t\tif (this.didDispose) return\n\t\t\tonLoadError(e)\n\t\t\treturn\n\t\t}\n\t}\n\n\tclose() {\n\t\tthis.debug('closing')\n\t\tthis.didDispose = true\n\t\tthis.disposables.forEach((d) => d())\n\t}\n\n\tprivate isPersisting = false\n\tprivate didLastWriteError = false\n\tprivate scheduledPersistTimeout: ReturnType<typeof setTimeout> | null = null\n\n\t/**\n\t * Schedule a persist. Persists don't happen immediately: they are throttled to avoid writing too\n\t * often, and will retry if failed.\n\t *\n\t * @internal\n\t */\n\tprivate schedulePersist() {\n\t\tthis.debug('schedulePersist', this.scheduledPersistTimeout)\n\t\tif (this.scheduledPersistTimeout) return\n\t\t// eslint-disable-next-line no-restricted-globals\n\t\tthis.scheduledPersistTimeout = setTimeout(\n\t\t\t() => {\n\t\t\t\tthis.scheduledPersistTimeout = null\n\t\t\t\tthis.persistIfNeeded()\n\t\t\t},\n\t\t\tthis.didLastWriteError ? PERSIST_RETRY_THROTTLE_MS : PERSIST_THROTTLE_MS\n\t\t)\n\t}\n\n\t/**\n\t * Persist to IndexedDB only under certain circumstances:\n\t *\n\t * - If we're not already persisting\n\t * - If we're not reloading the page\n\t * - And we have something to persist (a full db write scheduled or changes in the diff queue)\n\t *\n\t * @internal\n\t */\n\tprivate persistIfNeeded() {\n\t\tthis.debug('persistIfNeeded', {\n\t\t\tisPersisting: this.isPersisting,\n\t\t\tisReloading: this.isReloading,\n\t\t\tshouldDoFullDBWrite: this.shouldDoFullDBWrite,\n\t\t\tdiffQueueLength: this.diffQueue.length,\n\t\t\tstoreIsPossiblyCorrupt: this.store.isPossiblyCorrupted(),\n\t\t})\n\n\t\t// if we've scheduled a persist for the future, that's no longer needed\n\t\tif (this.scheduledPersistTimeout) {\n\t\t\tclearTimeout(this.scheduledPersistTimeout)\n\t\t\tthis.scheduledPersistTimeout = null\n\t\t}\n\n\t\t// if a persist is already in progress, we don't need to do anything -\n\t\t// if there are still outstanding changes once it's finished, it'll\n\t\t// schedule another persist\n\t\tif (this.isPersisting) return\n\n\t\t// if we're reloading the page, it's because there's a newer client\n\t\t// present so lets not overwrite their changes\n\t\tif (this.isReloading) return\n\n\t\t// if the store is possibly corrupted, we don't want to persist\n\t\tif (this.store.isPossiblyCorrupted()) return\n\n\t\t// if we're scheduled for a full write or if we have changes outstanding, let's persist them!\n\t\tif (this.shouldDoFullDBWrite || this.diffQueue.length > 0) {\n\t\t\tthis.doPersist()\n\t\t}\n\t}\n\n\t/**\n\t * Actually persist to IndexedDB. If the write fails, then we'll retry with a full db write after\n\t * a short delay.\n\t */\n\tprivate async doPersist() {\n\t\tassert(!this.isPersisting, 'persist already in progress')\n\t\tif (this.didDispose) return\n\t\tthis.isPersisting = true\n\n\t\tthis.debug('doPersist start')\n\n\t\t// instantly empty the diff queue, but keep our own copy of it. this way\n\t\t// diffs that come in during the persist will still get tracked\n\t\tconst diffQueue = this.diffQueue\n\t\tthis.diffQueue = []\n\n\t\ttry {\n\t\t\tif (this.shouldDoFullDBWrite) {\n\t\t\t\tthis.shouldDoFullDBWrite = false\n\t\t\t\tawait this.db.storeSnapshot({\n\t\t\t\t\tschema: this.store.schema,\n\t\t\t\t\tsnapshot: this.store.serialize(),\n\t\t\t\t\tsessionId: this.sessionId,\n\t\t\t\t\tsessionStateSnapshot: this.$sessionStateSnapshot.get(),\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tconst diffs = squashRecordDiffs(\n\t\t\t\t\tdiffQueue.filter((d): d is RecordsDiff<UnknownRecord> => d !== UPDATE_INSTANCE_STATE)\n\t\t\t\t)\n\t\t\t\tawait this.db.storeChanges({\n\t\t\t\t\tchanges: diffs,\n\t\t\t\t\tschema: this.store.schema,\n\t\t\t\t\tsessionId: this.sessionId,\n\t\t\t\t\tsessionStateSnapshot: this.$sessionStateSnapshot.get(),\n\t\t\t\t})\n\t\t\t}\n\t\t\tthis.didLastWriteError = false\n\t\t} catch (e) {\n\t\t\t// set this.shouldDoFullDBWrite because we clear the diffQueue no matter what,\n\t\t\t// so if this is just a temporary error, we will still persist all changes\n\t\t\tthis.shouldDoFullDBWrite = true\n\t\t\tthis.didLastWriteError = true\n\t\t\tconsole.error('failed to store changes in indexed db', e)\n\n\t\t\tshowCantWriteToIndexDbAlert()\n\t\t\tif (typeof window !== 'undefined') {\n\t\t\t\t// adios\n\t\t\t\twindow.location.reload()\n\t\t\t}\n\t\t}\n\n\t\tthis.isPersisting = false\n\t\tthis.debug('doPersist end')\n\n\t\t// changes might have come in between when we started the persist and\n\t\t// now. we request another persist so any new changes can get written\n\t\tthis.schedulePersist()\n\t}\n}\n"],
5
- "mappings": "AAAA,SAAiB,gBAAgB;AACjC,SAAuD,yBAAyB;AAEhF,SAAS,cAAc;AACvB;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B,mCAAmC;AAG1E,MAAM,sBAAsB;AAE5B,MAAM,4BAA4B;AAElC,MAAM,wBAAwB,OAAO,uBAAuB;AA4B5D,MAAM,MAAM,CAACA,SAAiBA;AAGvB,MAAM,qBAAqB;AAAA,EACjC;AAAA,EACA,YAAY,OAAe;AAAA,EAE3B;AAAA,EACA,YAAY,MAA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YAAY;AACzB,WAAO,CAAC,KAAK,cAAc,6BAA6B;AACxD,QAAI,KAAK,WAAY;AACrB,SAAK,eAAe;AAEpB,SAAK,MAAM,iBAAiB;AAI5B,UAAM,YAAY,KAAK;AACvB,SAAK,YAAY,CAAC;AAElB,QAAI;AACH,UAAI,KAAK,qBAAqB;AAC7B,aAAK,sBAAsB;AAC3B,cAAM,KAAK,GAAG,cAAc;AAAA,UAC3B,QAAQ,KAAK,MAAM;AAAA,UACnB,UAAU,KAAK,MAAM,UAAU;AAAA,UAC/B,WAAW,KAAK;AAAA,UAChB,sBAAsB,KAAK,sBAAsB,IAAI;AAAA,QACtD,CAAC;AAAA,MACF,OAAO;AACN,cAAM,QAAQ;AAAA,UACb,UAAU,OAAO,CAAC,MAAuC,MAAM,qBAAqB;AAAA,QACrF;AACA,cAAM,KAAK,GAAG,aAAa;AAAA,UAC1B,SAAS;AAAA,UACT,QAAQ,KAAK,MAAM;AAAA,UACnB,WAAW,KAAK;AAAA,UAChB,sBAAsB,KAAK,sBAAsB,IAAI;AAAA,QACtD,CAAC;AAAA,MACF;AACA,WAAK,oBAAoB;AAAA,IAC1B,SAAS,GAAG;AAGX,WAAK,sBAAsB;AAC3B,WAAK,oBAAoB;AACzB,cAAQ,MAAM,yCAAyC,CAAC;AAExD,kCAA4B;AAC5B,UAAI,OAAO,WAAW,aAAa;AAElC,eAAO,SAAS,OAAO;AAAA,MACxB;AAAA,IACD;AAEA,SAAK,eAAe;AACpB,SAAK,MAAM,eAAe;AAI1B,SAAK,gBAAgB;AAAA,EACtB;AACD;",
4
+ "sourcesContent": ["import { Signal, transact } from '@tldraw/state'\nimport { RecordsDiff, SerializedSchema, UnknownRecord, squashRecordDiffs } from '@tldraw/store'\nimport { TLStore } from '@tldraw/tlschema'\nimport { assert } from '@tldraw/utils'\nimport {\n\tTAB_ID,\n\tTLSessionStateSnapshot,\n\tcreateSessionStateSnapshotSignal,\n\textractSessionStateFromLegacySnapshot,\n\tloadSessionStateSnapshotIntoStore,\n} from '../../config/TLSessionStateSnapshot'\nimport { showCantReadFromIndexDbAlert, showCantWriteToIndexDbAlert } from './alerts'\nimport { LocalIndexedDb } from './LocalIndexedDb'\n\n/** How should we debounce persists? */\nconst PERSIST_THROTTLE_MS = 350\n/** If we're in an error state, how long should we wait before retrying a write? */\nconst PERSIST_RETRY_THROTTLE_MS = 10_000\n\nconst UPDATE_INSTANCE_STATE = Symbol('UPDATE_INSTANCE_STATE')\n\n/**\n * IMPORTANT!!!\n *\n * This is just a quick-n-dirty temporary solution that will be replaced with the remote sync client\n * once it has the db integrated\n */\n\ninterface SyncMessage {\n\ttype: 'diff'\n\tstoreId: string\n\tchanges: RecordsDiff<UnknownRecord>\n\tschema: SerializedSchema\n}\n\n// Sent by new clients when they connect\n// If another client is on the channel with a newer schema version\n// It will\ninterface AnnounceMessage {\n\ttype: 'announce'\n\tschema: SerializedSchema\n}\n\ntype Message = SyncMessage | AnnounceMessage\n\ntype UnpackPromise<T> = T extends Promise<infer U> ? U : T\n\nconst msg = (msg: Message) => msg\n\n/** @internal */\nexport class BroadcastChannelMock {\n\tonmessage?: (e: MessageEvent) => void\n\tconstructor(_name: string) {\n\t\t// noop\n\t}\n\tpostMessage(_msg: Message) {\n\t\t// noop\n\t}\n\tclose() {\n\t\t// noop\n\t}\n}\n\nconst BC = typeof BroadcastChannel === 'undefined' ? BroadcastChannelMock : BroadcastChannel\n\n/** @internal */\nexport class TLLocalSyncClient {\n\tprivate disposables = new Set<() => void>()\n\tprivate diffQueue: Array<RecordsDiff<UnknownRecord> | typeof UPDATE_INSTANCE_STATE> = []\n\tprivate didDispose = false\n\tprivate shouldDoFullDBWrite = true\n\tprivate isReloading = false\n\treadonly persistenceKey: string\n\treadonly sessionId: string\n\treadonly serializedSchema: SerializedSchema\n\tprivate isDebugging = false\n\tprivate readonly documentTypes: ReadonlySet<string>\n\tprivate readonly $sessionStateSnapshot: Signal<TLSessionStateSnapshot | null>\n\t/** @internal */\n\treadonly db: LocalIndexedDb\n\n\tinitTime = Date.now()\n\tprivate debug(...args: any[]) {\n\t\tif (this.isDebugging) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.debug(...args)\n\t\t}\n\t}\n\tconstructor(\n\t\tpublic readonly store: TLStore,\n\t\t{\n\t\t\tpersistenceKey,\n\t\t\tsessionId = TAB_ID,\n\t\t\tonLoad,\n\t\t\tonLoadError,\n\t\t}: {\n\t\t\tpersistenceKey: string\n\t\t\tsessionId?: string\n\t\t\tonLoad(self: TLLocalSyncClient): void\n\t\t\tonLoadError(error: Error): void\n\t\t},\n\t\tpublic readonly channel = new BC(`tldraw-tab-sync-${persistenceKey}`)\n\t) {\n\t\tif (typeof window !== 'undefined') {\n\t\t\t;(window as any).tlsync = this\n\t\t}\n\t\tthis.persistenceKey = persistenceKey\n\t\tthis.sessionId = sessionId\n\t\tthis.db = new LocalIndexedDb(persistenceKey)\n\t\tthis.disposables.add(() => this.db.close())\n\n\t\tthis.serializedSchema = this.store.schema.serialize()\n\t\tthis.$sessionStateSnapshot = createSessionStateSnapshotSignal(this.store)\n\n\t\tthis.disposables.add(\n\t\t\t// Set up a subscription to changes from the store: When\n\t\t\t// the store changes (and if the change was made by the user)\n\t\t\t// then immediately send the diff to other tabs via postMessage\n\t\t\t// and schedule a persist.\n\t\t\tstore.listen(\n\t\t\t\t({ changes }) => {\n\t\t\t\t\tthis.diffQueue.push(changes)\n\t\t\t\t\tthis.channel.postMessage(\n\t\t\t\t\t\tmsg({\n\t\t\t\t\t\t\ttype: 'diff',\n\t\t\t\t\t\t\tstoreId: this.store.id,\n\t\t\t\t\t\t\tchanges,\n\t\t\t\t\t\t\tschema: this.serializedSchema,\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t\tthis.schedulePersist()\n\t\t\t\t},\n\t\t\t\t{ source: 'user', scope: 'document' }\n\t\t\t)\n\t\t)\n\t\tthis.disposables.add(\n\t\t\tstore.listen(\n\t\t\t\t() => {\n\t\t\t\t\tthis.diffQueue.push(UPDATE_INSTANCE_STATE)\n\t\t\t\t\tthis.schedulePersist()\n\t\t\t\t},\n\t\t\t\t{ scope: 'session' }\n\t\t\t)\n\t\t)\n\n\t\tthis.connect(onLoad, onLoadError)\n\n\t\tthis.documentTypes = new Set(\n\t\t\tObject.values(this.store.schema.types)\n\t\t\t\t.filter((t) => t.scope === 'document')\n\t\t\t\t.map((t) => t.typeName)\n\t\t)\n\t}\n\n\tprivate async connect(onLoad: (client: this) => void, onLoadError: (error: Error) => void) {\n\t\tthis.debug('connecting')\n\t\tlet data: UnpackPromise<ReturnType<LocalIndexedDb['load']>> | undefined\n\n\t\ttry {\n\t\t\tdata = await this.db.load({ sessionId: this.sessionId })\n\t\t} catch (error: any) {\n\t\t\tonLoadError(error)\n\t\t\tshowCantReadFromIndexDbAlert()\n\t\t\treturn\n\t\t}\n\n\t\tthis.debug('loaded data from store', data, 'didDispose', this.didDispose)\n\t\tif (this.didDispose) return\n\n\t\ttry {\n\t\t\tif (data) {\n\t\t\t\tconst documentSnapshot = Object.fromEntries(data.records.map((r) => [r.id, r]))\n\t\t\t\tconst sessionStateSnapshot =\n\t\t\t\t\tdata.sessionStateSnapshot ?? extractSessionStateFromLegacySnapshot(documentSnapshot)\n\t\t\t\tconst migrationResult = this.store.schema.migrateStoreSnapshot({\n\t\t\t\t\tstore: documentSnapshot,\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\t\t\t\tschema: data.schema ?? this.store.schema.serializeEarliestVersion(),\n\t\t\t\t})\n\n\t\t\t\tif (migrationResult.type === 'error') {\n\t\t\t\t\tconsole.error('failed to migrate store', migrationResult)\n\t\t\t\t\tonLoadError(new Error(`Failed to migrate store: ${migrationResult.reason}`))\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst records = Object.values(migrationResult.value).filter((r) =>\n\t\t\t\t\tthis.documentTypes.has(r.typeName)\n\t\t\t\t)\n\t\t\t\tif (records.length > 0) {\n\t\t\t\t\t// 3. Merge the changes into the REAL STORE\n\t\t\t\t\tthis.store.mergeRemoteChanges(() => {\n\t\t\t\t\t\t// Calling put will validate the records!\n\t\t\t\t\t\tthis.store.put(records, 'initialize')\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tif (sessionStateSnapshot) {\n\t\t\t\t\tloadSessionStateSnapshotIntoStore(this.store, sessionStateSnapshot, {\n\t\t\t\t\t\tforceOverwrite: true,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.channel.onmessage = ({ data }) => {\n\t\t\t\tthis.debug('got message', data)\n\t\t\t\tconst msg = data as Message\n\t\t\t\t// if their schema is earlier than ours, we need to tell them so they can refresh\n\t\t\t\t// if their schema is later than ours, we need to refresh\n\t\t\t\tconst res = this.store.schema.getMigrationsSince(msg.schema)\n\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\t// we are older, refresh\n\t\t\t\t\t// but add a safety check to make sure we don't get in an infinite loop\n\t\t\t\t\tconst timeSinceInit = Date.now() - this.initTime\n\t\t\t\t\tif (timeSinceInit < 5000) {\n\t\t\t\t\t\t// This tab was just reloaded, but is out of date compared to other tabs.\n\t\t\t\t\t\t// Not expecting this to ever happen. It should only happen if we roll back a release that incremented\n\t\t\t\t\t\t// the schema version (which we should never do)\n\t\t\t\t\t\t// Or maybe during development if you have multiple local tabs open running the app on prod mode and you\n\t\t\t\t\t\t// check out an older commit. Dev server should be fine.\n\t\t\t\t\t\tonLoadError(new Error('Schema mismatch, please close other tabs and reload the page'))\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthis.debug('reloading')\n\t\t\t\t\tthis.isReloading = true\n\t\t\t\t\twindow?.location?.reload?.()\n\t\t\t\t\treturn\n\t\t\t\t} else if (res.value.length > 0) {\n\t\t\t\t\t// they are older, tell them to refresh and not write any more data\n\t\t\t\t\tthis.debug('telling them to reload')\n\t\t\t\t\tthis.channel.postMessage({ type: 'announce', schema: this.serializedSchema })\n\t\t\t\t\t// schedule a full db write in case they wrote data anyway\n\t\t\t\t\tthis.shouldDoFullDBWrite = true\n\t\t\t\t\tthis.persistIfNeeded()\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\t// otherwise, all good, same version :)\n\t\t\t\tif (msg.type === 'diff') {\n\t\t\t\t\tthis.debug('applying diff')\n\t\t\t\t\ttransact(() => {\n\t\t\t\t\t\tthis.store.mergeRemoteChanges(() => {\n\t\t\t\t\t\t\tthis.store.applyDiff(msg.changes as any)\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.channel.postMessage({ type: 'announce', schema: this.serializedSchema })\n\t\t\tthis.disposables.add(() => {\n\t\t\t\tthis.channel.close()\n\t\t\t})\n\t\t\tonLoad(this)\n\t\t} catch (e: any) {\n\t\t\tthis.debug('error loading data from store', e)\n\t\t\tif (this.didDispose) return\n\t\t\tonLoadError(e)\n\t\t\treturn\n\t\t}\n\t}\n\n\tclose() {\n\t\tthis.debug('closing')\n\t\tthis.didDispose = true\n\t\tthis.disposables.forEach((d) => d())\n\t\tif (typeof window !== 'undefined' && (window as any).tlsync === this) {\n\t\t\tdelete (window as any).tlsync\n\t\t}\n\t}\n\n\tprivate isPersisting = false\n\tprivate didLastWriteError = false\n\t// eslint-disable-next-line no-restricted-globals\n\tprivate scheduledPersistTimeout: ReturnType<typeof setTimeout> | null = null\n\n\t/**\n\t * Schedule a persist. Persists don't happen immediately: they are throttled to avoid writing too\n\t * often, and will retry if failed.\n\t *\n\t * @internal\n\t */\n\tprivate schedulePersist() {\n\t\tthis.debug('schedulePersist', this.scheduledPersistTimeout)\n\t\tif (this.scheduledPersistTimeout) return\n\t\t// eslint-disable-next-line no-restricted-globals\n\t\tthis.scheduledPersistTimeout = setTimeout(\n\t\t\t() => {\n\t\t\t\tthis.scheduledPersistTimeout = null\n\t\t\t\tthis.persistIfNeeded()\n\t\t\t},\n\t\t\tthis.didLastWriteError ? PERSIST_RETRY_THROTTLE_MS : PERSIST_THROTTLE_MS\n\t\t)\n\t}\n\n\t/**\n\t * Persist to IndexedDB only under certain circumstances:\n\t *\n\t * - If we're not already persisting\n\t * - If we're not reloading the page\n\t * - And we have something to persist (a full db write scheduled or changes in the diff queue)\n\t *\n\t * @internal\n\t */\n\tprivate persistIfNeeded() {\n\t\tthis.debug('persistIfNeeded', {\n\t\t\tisPersisting: this.isPersisting,\n\t\t\tisReloading: this.isReloading,\n\t\t\tshouldDoFullDBWrite: this.shouldDoFullDBWrite,\n\t\t\tdiffQueueLength: this.diffQueue.length,\n\t\t\tstoreIsPossiblyCorrupt: this.store.isPossiblyCorrupted(),\n\t\t})\n\n\t\t// if we've scheduled a persist for the future, that's no longer needed\n\t\tif (this.scheduledPersistTimeout) {\n\t\t\tclearTimeout(this.scheduledPersistTimeout)\n\t\t\tthis.scheduledPersistTimeout = null\n\t\t}\n\n\t\t// if a persist is already in progress, we don't need to do anything -\n\t\t// if there are still outstanding changes once it's finished, it'll\n\t\t// schedule another persist\n\t\tif (this.isPersisting) return\n\n\t\t// if we're reloading the page, it's because there's a newer client\n\t\t// present so lets not overwrite their changes\n\t\tif (this.isReloading) return\n\n\t\t// if the store is possibly corrupted, we don't want to persist\n\t\tif (this.store.isPossiblyCorrupted()) return\n\n\t\t// if we're scheduled for a full write or if we have changes outstanding, let's persist them!\n\t\tif (this.shouldDoFullDBWrite || this.diffQueue.length > 0) {\n\t\t\tthis.doPersist()\n\t\t}\n\t}\n\n\t/**\n\t * Actually persist to IndexedDB. If the write fails, then we'll retry with a full db write after\n\t * a short delay.\n\t */\n\tprivate async doPersist() {\n\t\tassert(!this.isPersisting, 'persist already in progress')\n\t\tif (this.didDispose) return\n\t\tthis.isPersisting = true\n\n\t\tthis.debug('doPersist start')\n\n\t\t// instantly empty the diff queue, but keep our own copy of it. this way\n\t\t// diffs that come in during the persist will still get tracked\n\t\tconst diffQueue = this.diffQueue\n\t\tthis.diffQueue = []\n\n\t\ttry {\n\t\t\tif (this.shouldDoFullDBWrite) {\n\t\t\t\tthis.shouldDoFullDBWrite = false\n\t\t\t\tawait this.db.storeSnapshot({\n\t\t\t\t\tschema: this.store.schema,\n\t\t\t\t\tsnapshot: this.store.serialize(),\n\t\t\t\t\tsessionId: this.sessionId,\n\t\t\t\t\tsessionStateSnapshot: this.$sessionStateSnapshot.get(),\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tconst diffs = squashRecordDiffs(\n\t\t\t\t\tdiffQueue.filter((d): d is RecordsDiff<UnknownRecord> => d !== UPDATE_INSTANCE_STATE)\n\t\t\t\t)\n\t\t\t\tawait this.db.storeChanges({\n\t\t\t\t\tchanges: diffs,\n\t\t\t\t\tschema: this.store.schema,\n\t\t\t\t\tsessionId: this.sessionId,\n\t\t\t\t\tsessionStateSnapshot: this.$sessionStateSnapshot.get(),\n\t\t\t\t})\n\t\t\t}\n\t\t\tthis.didLastWriteError = false\n\t\t} catch (e) {\n\t\t\t// set this.shouldDoFullDBWrite because we clear the diffQueue no matter what,\n\t\t\t// so if this is just a temporary error, we will still persist all changes\n\t\t\tthis.shouldDoFullDBWrite = true\n\t\t\tthis.didLastWriteError = true\n\t\t\tconsole.error('failed to store changes in indexed db', e)\n\n\t\t\tshowCantWriteToIndexDbAlert()\n\t\t\tif (typeof window !== 'undefined') {\n\t\t\t\t// adios\n\t\t\t\twindow.location.reload()\n\t\t\t}\n\t\t}\n\n\t\tthis.isPersisting = false\n\t\tthis.debug('doPersist end')\n\n\t\t// changes might have come in between when we started the persist and\n\t\t// now. we request another persist so any new changes can get written\n\t\tthis.schedulePersist()\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAiB,gBAAgB;AACjC,SAAuD,yBAAyB;AAEhF,SAAS,cAAc;AACvB;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B,mCAAmC;AAC1E,SAAS,sBAAsB;AAG/B,MAAM,sBAAsB;AAE5B,MAAM,4BAA4B;AAElC,MAAM,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",
6
6
  "names": ["msg", "data"]
7
7
  }
@@ -12,14 +12,6 @@ async function hardReset({ shouldReload = true } = {}) {
12
12
  window.location.reload();
13
13
  }
14
14
  }
15
- if (typeof window !== "undefined") {
16
- if (process.env.NODE_ENV === "development") {
17
- ;
18
- window.hardReset = hardReset;
19
- }
20
- ;
21
- window.__tldraw__hardReset = hardReset;
22
- }
23
15
  export {
24
16
  hardReset
25
17
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/utils/sync/hardReset.ts"],
4
- "sourcesContent": ["import { clearLocalStorage, clearSessionStorage } from '@tldraw/utils'\nimport { deleteDB } from 'idb'\nimport { LocalIndexedDb, getAllIndexDbNames } from './LocalIndexedDb'\n\n/**\n * Clear the database of all data associated with tldraw.\n *\n * @public */\nexport async function hardReset({ shouldReload = true } = {}) {\n\tclearSessionStorage()\n\n\tfor (const instance of LocalIndexedDb.connectedInstances) {\n\t\tawait instance.close()\n\t}\n\tawait Promise.all(getAllIndexDbNames().map((db) => deleteDB(db)))\n\n\tclearLocalStorage()\n\tif (shouldReload) {\n\t\twindow.location.reload()\n\t}\n}\n\nif (typeof window !== 'undefined') {\n\tif (process.env.NODE_ENV === 'development') {\n\t\t;(window as any).hardReset = hardReset\n\t}\n\t// window.__tldraw__hardReset is used to inject the logic into the tldraw library\n\t;(window as any).__tldraw__hardReset = hardReset\n}\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB,2BAA2B;AACvD,SAAS,gBAAgB;AACzB,SAAS,gBAAgB,0BAA0B;AAMnD,eAAsB,UAAU,EAAE,eAAe,KAAK,IAAI,CAAC,GAAG;AAC7D,sBAAoB;AAEpB,aAAW,YAAY,eAAe,oBAAoB;AACzD,UAAM,SAAS,MAAM;AAAA,EACtB;AACA,QAAM,QAAQ,IAAI,mBAAmB,EAAE,IAAI,CAAC,OAAO,SAAS,EAAE,CAAC,CAAC;AAEhE,oBAAkB;AAClB,MAAI,cAAc;AACjB,WAAO,SAAS,OAAO;AAAA,EACxB;AACD;AAEA,IAAI,OAAO,WAAW,aAAa;AAClC,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC3C;AAAC,IAAC,OAAe,YAAY;AAAA,EAC9B;AAEA;AAAC,EAAC,OAAe,sBAAsB;AACxC;",
4
+ "sourcesContent": ["import { clearLocalStorage, clearSessionStorage } from '@tldraw/utils'\nimport { deleteDB } from 'idb'\nimport { LocalIndexedDb, getAllIndexDbNames } from './LocalIndexedDb'\n\n/**\n * Clear the database of all data associated with tldraw.\n *\n * @public */\nexport async function hardReset({ shouldReload = true } = {}) {\n\tclearSessionStorage()\n\n\tfor (const instance of LocalIndexedDb.connectedInstances) {\n\t\tawait instance.close()\n\t}\n\tawait Promise.all(getAllIndexDbNames().map((db) => deleteDB(db)))\n\n\tclearLocalStorage()\n\tif (shouldReload) {\n\t\twindow.location.reload()\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,mBAAmB,2BAA2B;AACvD,SAAS,gBAAgB;AACzB,SAAS,gBAAgB,0BAA0B;AAMnD,eAAsB,UAAU,EAAE,eAAe,KAAK,IAAI,CAAC,GAAG;AAC7D,sBAAoB;AAEpB,aAAW,YAAY,eAAe,oBAAoB;AACzD,UAAM,SAAS,MAAM;AAAA,EACtB;AACA,QAAM,QAAQ,IAAI,mBAAmB,EAAE,IAAI,CAAC,OAAO,SAAS,EAAE,CAAC,CAAC;AAEhE,oBAAkB;AAClB,MAAI,cAAc;AACjB,WAAO,SAAS,OAAO;AAAA,EACxB;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,8 @@
1
- const version = "4.6.0-next.5a871ec02ff3";
1
+ const version = "4.6.0-next.6594d48ace27";
2
2
  const publishDates = {
3
3
  major: "2025-09-18T14:39:22.803Z",
4
- minor: "2026-03-18T11:42:46.534Z",
5
- patch: "2026-03-18T11:42:46.534Z"
4
+ minor: "2026-04-30T07:10:31.073Z",
5
+ patch: "2026-04-30T07:10:31.073Z"
6
6
  };
7
7
  export {
8
8
  publishDates,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/version.ts"],
4
- "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '4.6.0-next.5a871ec02ff3'\nexport const publishDates = {\n\tmajor: '2025-09-18T14:39:22.803Z',\n\tminor: '2026-03-18T11:42:46.534Z',\n\tpatch: '2026-03-18T11:42:46.534Z',\n}\n"],
4
+ "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '4.6.0-next.6594d48ace27'\nexport const publishDates = {\n\tmajor: '2025-09-18T14:39:22.803Z',\n\tminor: '2026-04-30T07:10:31.073Z',\n\tpatch: '2026-04-30T07:10:31.073Z',\n}\n"],
5
5
  "mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }