@tldraw/editor 4.4.0 → 4.5.0-canary.034ea85352da

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 (224) hide show
  1. package/dist-cjs/index.d.ts +67 -49
  2. package/dist-cjs/index.js +4 -7
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +4 -3
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/components/ErrorBoundary.js.map +1 -1
  7. package/dist-cjs/lib/components/LiveCollaborators.js +2 -2
  8. package/dist-cjs/lib/components/LiveCollaborators.js.map +2 -2
  9. package/dist-cjs/lib/components/Shape.js +2 -2
  10. package/dist-cjs/lib/components/Shape.js.map +2 -2
  11. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +15 -15
  12. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  13. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +5 -6
  14. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
  15. package/dist-cjs/lib/components/default-components/DefaultLoadingScreen.js +3 -4
  16. package/dist-cjs/lib/components/default-components/DefaultLoadingScreen.js.map +2 -2
  17. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +2 -2
  18. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
  19. package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +2 -2
  20. package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +2 -2
  21. package/dist-cjs/lib/config/TLSessionStateSnapshot.js +3 -2
  22. package/dist-cjs/lib/config/TLSessionStateSnapshot.js.map +2 -2
  23. package/dist-cjs/lib/editor/Editor.js +12 -0
  24. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  25. package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +1 -1
  26. package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +1 -1
  27. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +1 -1
  28. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +1 -1
  29. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +1 -1
  30. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +1 -1
  31. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +1 -1
  32. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +1 -1
  33. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +1 -1
  34. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +1 -1
  35. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +1 -1
  36. package/dist-cjs/lib/editor/shapes/shared/resizeBox.js.map +1 -1
  37. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +1 -1
  38. package/dist-cjs/lib/editor/types/SvgExportContext.js.map +1 -1
  39. package/dist-cjs/lib/exports/exportToSvg.js.map +1 -1
  40. package/dist-cjs/lib/exports/getSvgJsx.js.map +1 -1
  41. package/dist-cjs/lib/{utils/hardResetEditor.js → hooks/EditorComponentsContext.js} +14 -8
  42. package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +7 -0
  43. package/dist-cjs/lib/hooks/useCanvasEvents.js +10 -2
  44. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  45. package/dist-cjs/lib/hooks/useEditor.js.map +1 -1
  46. package/dist-cjs/lib/hooks/useEditorComponents.js +4 -10
  47. package/dist-cjs/lib/hooks/useEditorComponents.js.map +3 -3
  48. package/dist-cjs/lib/options.js +2 -1
  49. package/dist-cjs/lib/options.js.map +2 -2
  50. package/dist-cjs/lib/primitives/Vec.js +10 -5
  51. package/dist-cjs/lib/primitives/Vec.js.map +2 -2
  52. package/dist-cjs/lib/utils/areShapesContentEqual.js +3 -1
  53. package/dist-cjs/lib/utils/areShapesContentEqual.js.map +2 -2
  54. package/dist-cjs/lib/utils/assets.js +4 -6
  55. package/dist-cjs/lib/utils/assets.js.map +2 -2
  56. package/dist-cjs/lib/utils/browserCanvasMaxSize.js +1 -2
  57. package/dist-cjs/lib/utils/browserCanvasMaxSize.js.map +2 -2
  58. package/dist-cjs/lib/utils/debug-flags.js.map +2 -2
  59. package/dist-cjs/lib/utils/deepLinks.js.map +1 -1
  60. package/dist-cjs/lib/utils/dom.js +3 -3
  61. package/dist-cjs/lib/utils/dom.js.map +2 -2
  62. package/dist-cjs/lib/utils/getIncrementedName.js +1 -1
  63. package/dist-cjs/lib/utils/getIncrementedName.js.map +2 -2
  64. package/dist-cjs/lib/utils/getPointerInfo.js.map +2 -2
  65. package/dist-cjs/lib/utils/getSvgPathFromPoints.js.map +1 -1
  66. package/dist-cjs/lib/utils/keyboard.js +2 -2
  67. package/dist-cjs/lib/utils/keyboard.js.map +2 -2
  68. package/dist-cjs/lib/utils/normalizeWheel.js +2 -5
  69. package/dist-cjs/lib/utils/normalizeWheel.js.map +2 -2
  70. package/dist-cjs/lib/utils/reorderShapes.js +6 -6
  71. package/dist-cjs/lib/utils/reorderShapes.js.map +2 -2
  72. package/dist-cjs/lib/utils/reparenting.js +3 -4
  73. package/dist-cjs/lib/utils/reparenting.js.map +2 -2
  74. package/dist-cjs/lib/utils/richText.js.map +1 -1
  75. package/dist-cjs/lib/utils/rotation.js.map +1 -1
  76. package/dist-cjs/lib/utils/runtime.js +12 -0
  77. package/dist-cjs/lib/utils/runtime.js.map +2 -2
  78. package/dist-cjs/version.js +3 -3
  79. package/dist-cjs/version.js.map +1 -1
  80. package/dist-esm/index.d.mts +67 -49
  81. package/dist-esm/index.mjs +8 -5
  82. package/dist-esm/index.mjs.map +2 -2
  83. package/dist-esm/lib/TldrawEditor.mjs +2 -4
  84. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  85. package/dist-esm/lib/components/ErrorBoundary.mjs.map +1 -1
  86. package/dist-esm/lib/components/LiveCollaborators.mjs +1 -1
  87. package/dist-esm/lib/components/LiveCollaborators.mjs.map +2 -2
  88. package/dist-esm/lib/components/Shape.mjs +1 -1
  89. package/dist-esm/lib/components/Shape.mjs.map +2 -2
  90. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
  91. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  92. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +2 -3
  93. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
  94. package/dist-esm/lib/components/default-components/DefaultLoadingScreen.mjs +2 -3
  95. package/dist-esm/lib/components/default-components/DefaultLoadingScreen.mjs.map +2 -2
  96. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +1 -1
  97. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
  98. package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +1 -1
  99. package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +2 -2
  100. package/dist-esm/lib/config/TLSessionStateSnapshot.mjs +3 -2
  101. package/dist-esm/lib/config/TLSessionStateSnapshot.mjs.map +2 -2
  102. package/dist-esm/lib/editor/Editor.mjs +12 -0
  103. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  104. package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +1 -1
  105. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +1 -1
  106. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +1 -1
  107. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +1 -1
  108. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +1 -1
  109. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +1 -1
  110. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +1 -1
  111. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +1 -1
  112. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +1 -1
  113. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +1 -1
  114. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +1 -1
  115. package/dist-esm/lib/editor/shapes/shared/resizeBox.mjs.map +1 -1
  116. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +1 -1
  117. package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +1 -1
  118. package/dist-esm/lib/exports/exportToSvg.mjs.map +1 -1
  119. package/dist-esm/lib/exports/getSvgJsx.mjs.map +1 -1
  120. package/dist-esm/lib/hooks/EditorComponentsContext.mjs +14 -0
  121. package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +7 -0
  122. package/dist-esm/lib/hooks/useCanvasEvents.mjs +10 -2
  123. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  124. package/dist-esm/lib/hooks/useEditor.mjs.map +1 -1
  125. package/dist-esm/lib/hooks/useEditorComponents.mjs +12 -36
  126. package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
  127. package/dist-esm/lib/options.mjs +2 -1
  128. package/dist-esm/lib/options.mjs.map +2 -2
  129. package/dist-esm/lib/primitives/Vec.mjs +6 -1
  130. package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
  131. package/dist-esm/lib/utils/areShapesContentEqual.mjs +3 -1
  132. package/dist-esm/lib/utils/areShapesContentEqual.mjs.map +2 -2
  133. package/dist-esm/lib/utils/assets.mjs +4 -6
  134. package/dist-esm/lib/utils/assets.mjs.map +2 -2
  135. package/dist-esm/lib/utils/browserCanvasMaxSize.mjs +1 -2
  136. package/dist-esm/lib/utils/browserCanvasMaxSize.mjs.map +2 -2
  137. package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
  138. package/dist-esm/lib/utils/deepLinks.mjs.map +1 -1
  139. package/dist-esm/lib/utils/dom.mjs +3 -3
  140. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  141. package/dist-esm/lib/utils/getIncrementedName.mjs +1 -1
  142. package/dist-esm/lib/utils/getIncrementedName.mjs.map +2 -2
  143. package/dist-esm/lib/utils/getPointerInfo.mjs.map +2 -2
  144. package/dist-esm/lib/utils/getSvgPathFromPoints.mjs.map +1 -1
  145. package/dist-esm/lib/utils/keyboard.mjs +2 -2
  146. package/dist-esm/lib/utils/keyboard.mjs.map +2 -2
  147. package/dist-esm/lib/utils/normalizeWheel.mjs +2 -5
  148. package/dist-esm/lib/utils/normalizeWheel.mjs.map +2 -2
  149. package/dist-esm/lib/utils/reorderShapes.mjs +6 -6
  150. package/dist-esm/lib/utils/reorderShapes.mjs.map +2 -2
  151. package/dist-esm/lib/utils/reparenting.mjs +3 -4
  152. package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
  153. package/dist-esm/lib/utils/richText.mjs.map +1 -1
  154. package/dist-esm/lib/utils/rotation.mjs.map +1 -1
  155. package/dist-esm/lib/utils/runtime.mjs +12 -0
  156. package/dist-esm/lib/utils/runtime.mjs.map +2 -2
  157. package/dist-esm/version.mjs +3 -3
  158. package/dist-esm/version.mjs.map +1 -1
  159. package/package.json +7 -7
  160. package/src/index.ts +7 -4
  161. package/src/lib/TldrawEditor.tsx +3 -5
  162. package/src/lib/components/ErrorBoundary.tsx +1 -1
  163. package/src/lib/components/LiveCollaborators.tsx +1 -1
  164. package/src/lib/components/Shape.tsx +1 -1
  165. package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
  166. package/src/lib/components/default-components/DefaultErrorFallback.tsx +2 -3
  167. package/src/lib/components/default-components/DefaultLoadingScreen.tsx +6 -3
  168. package/src/lib/components/default-components/DefaultShapeIndicator.tsx +1 -1
  169. package/src/lib/components/default-components/DefaultShapeIndicators.tsx +1 -1
  170. package/src/lib/config/TLSessionStateSnapshot.ts +3 -2
  171. package/src/lib/editor/Editor.ts +16 -0
  172. package/src/lib/editor/bindings/BindingUtil.ts +1 -1
  173. package/src/lib/editor/derivations/bindingsIndex.ts +1 -1
  174. package/src/lib/editor/derivations/notVisibleShapes.ts +1 -1
  175. package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
  176. package/src/lib/editor/managers/FontManager/FontManager.ts +1 -1
  177. package/src/lib/editor/managers/InputsManager/InputsManager.ts +1 -1
  178. package/src/lib/editor/managers/ScribbleManager/ScribbleManager.ts +1 -1
  179. package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +2 -2
  180. package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +2 -2
  181. package/src/lib/editor/managers/TextManager/TextManager.ts +1 -1
  182. package/src/lib/editor/managers/TickManager/TickManager.ts +1 -1
  183. package/src/lib/editor/shapes/shared/resizeBox.ts +1 -1
  184. package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +2 -2
  185. package/src/lib/editor/types/SvgExportContext.tsx +1 -1
  186. package/src/lib/exports/exportToSvg.tsx +1 -1
  187. package/src/lib/exports/getSvgJsx.tsx +1 -1
  188. package/src/lib/hooks/EditorComponentsContext.tsx +63 -0
  189. package/src/lib/hooks/useCanvasEvents.ts +13 -2
  190. package/src/lib/hooks/useEditor.tsx +1 -1
  191. package/src/lib/hooks/useEditorComponents.tsx +20 -89
  192. package/src/lib/options.ts +11 -0
  193. package/src/lib/primitives/Vec.ts +7 -1
  194. package/src/lib/utils/areShapesContentEqual.ts +9 -2
  195. package/src/lib/utils/assets.ts +15 -10
  196. package/src/lib/utils/browserCanvasMaxSize.ts +4 -2
  197. package/src/lib/utils/debug-flags.ts +0 -20
  198. package/src/lib/utils/deepLinks.ts +1 -1
  199. package/src/lib/utils/dom.ts +6 -7
  200. package/src/lib/utils/getIncrementedName.ts +1 -1
  201. package/src/lib/utils/getPointerInfo.ts +1 -0
  202. package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
  203. package/src/lib/utils/keyboard.ts +6 -4
  204. package/src/lib/utils/normalizeWheel.ts +8 -8
  205. package/src/lib/utils/reorderShapes.ts +17 -8
  206. package/src/lib/utils/reparenting.ts +5 -10
  207. package/src/lib/utils/richText.ts +1 -1
  208. package/src/lib/utils/rotation.ts +1 -1
  209. package/src/lib/utils/runtime.ts +26 -1
  210. package/src/version.ts +3 -3
  211. package/dist-cjs/lib/utils/hardResetEditor.js.map +0 -7
  212. package/dist-cjs/lib/utils/refreshPage.js +0 -28
  213. package/dist-cjs/lib/utils/refreshPage.js.map +0 -7
  214. package/dist-cjs/lib/utils/window-open.js +0 -28
  215. package/dist-cjs/lib/utils/window-open.js.map +0 -7
  216. package/dist-esm/lib/utils/hardResetEditor.mjs +0 -8
  217. package/dist-esm/lib/utils/hardResetEditor.mjs.map +0 -7
  218. package/dist-esm/lib/utils/refreshPage.mjs +0 -8
  219. package/dist-esm/lib/utils/refreshPage.mjs.map +0 -7
  220. package/dist-esm/lib/utils/window-open.mjs +0 -8
  221. package/dist-esm/lib/utils/window-open.mjs.map +0 -7
  222. package/src/lib/utils/hardResetEditor.ts +0 -6
  223. package/src/lib/utils/refreshPage.ts +0 -6
  224. package/src/lib/utils/window-open.ts +0 -16
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/editor/bindings/BindingUtil.ts"],
4
- "sourcesContent": ["import {\n\tRecordProps,\n\tTLBinding,\n\tTLPropsMigrations,\n\tTLShape,\n\tTLUnknownBinding,\n} from '@tldraw/tlschema'\nimport { Editor } from '../Editor'\n\n/** @public */\nexport interface TLBindingUtilConstructor<\n\tT extends TLBinding,\n\tU extends BindingUtil<T> = BindingUtil<T>,\n> {\n\tnew (editor: Editor): U\n\ttype: T['type']\n\t/** Validations for this binding's props. */\n\tprops?: RecordProps<T>\n\t/** Migrations for this binding's props. */\n\tmigrations?: TLPropsMigrations\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeCreate} and {@link BindingUtil.onAfterCreate},\n * describing a the creating a binding.\n *\n * @public\n */\nexport interface BindingOnCreateOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding being created. */\n\tbinding: Binding\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeChange} and {@link BindingUtil.onAfterChange},\n * describing the data associated with a binding being changed.\n *\n * @public\n */\nexport interface BindingOnChangeOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding record before the change is made. */\n\tbindingBefore: Binding\n\t/** The binding record after the change is made. */\n\tbindingAfter: Binding\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeDelete} and {@link BindingUtil.onAfterDelete},\n * describing a binding being deleted.\n *\n * @public\n */\nexport interface BindingOnDeleteOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding being deleted. */\n\tbinding: Binding\n}\n\n/**\n * Options passed to {@link BindingUtil.onAfterChangeFromShape} and\n * {@link BindingUtil.onAfterChangeToShape}, describing a bound shape being changed.\n *\n * @public\n */\nexport interface BindingOnShapeChangeOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding record linking these two shapes. */\n\tbinding: Binding\n\t/** The shape record before the change is made. */\n\tshapeBefore: TLShape\n\t/** The shape record after the change is made. */\n\tshapeAfter: TLShape\n\t/**\n\t * Why did this shape change?\n\t * - 'self': the shape itself changed\n\t * - 'ancestry': the ancestry of the shape changed, but the shape itself may not have done\n\t */\n\treason: 'self' | 'ancestry'\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeIsolateFromShape} and\n * {@link BindingUtil.onBeforeIsolateToShape}, describing a shape that is about to be isolated from\n * the one that it's bound to.\n *\n * Isolation happens whenever two bound shapes are separated. For example\n * 1. One is deleted, but the other is not.\n * 1. One is copied, but the other is not.\n * 1. One is duplicated, but the other is not.\n *\n * In each of these cases, if the remaining shape depends on the binding for its rendering, it may\n * now be in an inconsistent state. For example, tldraw's arrow shape depends on the binding to know\n * where the end of the arrow is. If we removed the binding without doing anything else, the arrow\n * would suddenly be pointing to the wrong location. Instead, when the shape the arrow is pointing\n * to is deleted, or the arrow is copied/duplicated, we use an isolation callback. The callback\n * updates the arrow based on the binding that's about to be removed, so it doesn't end up pointing\n * to the wrong place.\n *\n * For this style of consistency update, use isolation callbacks. For actions specific to deletion\n * (like deleting a sticker when the shape it's bound to is removed), use the delete callbacks\n * ({@link BindingUtil.onBeforeDeleteFromShape} and {@link BindingUtil.onBeforeDeleteToShape})\n * instead.\n *\n * @public\n */\nexport interface BindingOnShapeIsolateOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding record that refers to the shape in question. */\n\tbinding: Binding\n\t/**\n\t * The shape being removed. For deletion, this is the deleted shape. For copy/duplicate, this is\n\t * the shape that _isn't_ being copied/duplicated and is getting left behind.\n\t */\n\tremovedShape: TLShape\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeDeleteFromShape} and\n * {@link BindingUtil.onBeforeDeleteToShape}, describing a bound shape that is about to be deleted.\n *\n * See {@link BindingOnShapeIsolateOptions} for discussion on when to use the delete vs. the isolate\n * callbacks.\n *\n * @public\n */\nexport interface BindingOnShapeDeleteOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding record that refers to the shape in question. */\n\tbinding: Binding\n\t/** The shape that is about to be deleted. */\n\tshape: TLShape\n}\n\n/** @public */\nexport abstract class BindingUtil<Binding extends TLBinding = TLBinding> {\n\tconstructor(public editor: Editor) {}\n\tstatic props?: RecordProps<TLUnknownBinding>\n\tstatic migrations?: TLPropsMigrations\n\n\t/**\n\t * The type of the binding util, which should match the binding's type.\n\t *\n\t * @public\n\t */\n\tstatic type: string\n\n\t/**\n\t * Get the default props for a binding.\n\t *\n\t * @public\n\t */\n\tabstract getDefaultProps(): Partial<Binding['props']>\n\n\t/**\n\t * Called whenever a store operation involving this binding type has completed. This is useful\n\t * for working with networks of related bindings that may need to update together.\n\t *\n\t * @example\n\t * ```ts\n\t * class MyBindingUtil extends BindingUtil<MyBinding> {\n\t * changedBindingIds = new Set<TLBindingId>()\n\t *\n\t * onOperationComplete() {\n\t * doSomethingWithChangedBindings(this.changedBindingIds)\n\t * this.changedBindingIds.clear()\n\t * }\n\t *\n\t * onAfterChange({ bindingAfter }: BindingOnChangeOptions<MyBinding>) {\n\t * this.changedBindingIds.add(bindingAfter.id)\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t */\n\tonOperationComplete?(): void\n\n\t/**\n\t * Called when a binding is about to be created. See {@link BindingOnCreateOptions} for details.\n\t *\n\t * You can optionally return a new binding to replace the one being created - for example, to\n\t * set different initial props.\n\t *\n\t * @public\n\t */\n\tonBeforeCreate?(options: BindingOnCreateOptions<Binding>): Binding | void\n\n\t/**\n\t * Called after a binding has been created. See {@link BindingOnCreateOptions} for details.\n\t *\n\t * @public\n\t */\n\tonAfterCreate?(options: BindingOnCreateOptions<Binding>): void\n\n\t/**\n\t * Called when a binding is about to be changed. See {@link BindingOnChangeOptions} for details.\n\t *\n\t * Note that this only fires when the binding record is changing, not when the shapes\n\t * associated change. Use {@link BindingUtil.onAfterChangeFromShape} and\n\t * {@link BindingUtil.onAfterChangeToShape} for that.\n\t *\n\t * You can optionally return a new binding to replace the one being changed - for example, to\n\t * enforce constraints on the binding's props.\n\t *\n\t * @public\n\t */\n\tonBeforeChange?(options: BindingOnChangeOptions<Binding>): Binding | void\n\n\t/**\n\t * Called after a binding has been changed. See {@link BindingOnChangeOptions} for details.\n\t *\n\t * Note that this only fires when the binding record is changing, not when the shapes\n\t * associated change. Use {@link BindingUtil.onAfterChangeFromShape} and\n\t * {@link BindingUtil.onAfterChangeToShape} for that.\n\t *\n\t * @public\n\t */\n\tonAfterChange?(options: BindingOnChangeOptions<Binding>): void\n\n\t/**\n\t * Called when a binding is about to be deleted. See {@link BindingOnDeleteOptions} for details.\n\t *\n\t * @public\n\t */\n\tonBeforeDelete?(options: BindingOnDeleteOptions<Binding>): void\n\n\t/**\n\t * Called after a binding has been deleted. See {@link BindingOnDeleteOptions} for details.\n\t *\n\t * @public\n\t */\n\tonAfterDelete?(options: BindingOnDeleteOptions<Binding>): void\n\n\t/**\n\t * Called after the shape referenced in a binding's `fromId` is changed. Use this to propagate\n\t * any changes to the binding itself or the other shape as needed. See\n\t * {@link BindingOnShapeChangeOptions} for details.\n\t *\n\t * @public\n\t */\n\tonAfterChangeFromShape?(options: BindingOnShapeChangeOptions<Binding>): void\n\n\t/**\n\t * Called after the shape referenced in a binding's `toId` is changed. Use this to propagate any\n\t * changes to the binding itself or the other shape as needed. See\n\t * {@link BindingOnShapeChangeOptions} for details.\n\t *\n\t * @public\n\t */\n\tonAfterChangeToShape?(options: BindingOnShapeChangeOptions<Binding>): void\n\n\t/**\n\t * Called before the shape referenced in a binding's `fromId` is about to be deleted. Use this\n\t * with care - you may want to use {@link BindingUtil.onBeforeIsolateToShape} instead. See\n\t * {@link BindingOnShapeDeleteOptions} for details.\n\t *\n\t * @public\n\t */\n\tonBeforeDeleteFromShape?(options: BindingOnShapeDeleteOptions<Binding>): void\n\t/**\n\t * Called before the shape referenced in a binding's `toId` is about to be deleted. Use this\n\t * with care - you may want to use {@link BindingUtil.onBeforeIsolateFromShape} instead. See\n\t * {@link BindingOnShapeDeleteOptions} for details.\n\t *\n\t * @public\n\t */\n\tonBeforeDeleteToShape?(options: BindingOnShapeDeleteOptions<Binding>): void\n\n\t/**\n\t * Called before the shape referenced in a binding's `fromId` is about to be isolated from the\n\t * shape referenced in `toId`. See {@link BindingOnShapeIsolateOptions} for discussion on what\n\t * isolation means, and when/how to use this callback.\n\t */\n\tonBeforeIsolateFromShape?(options: BindingOnShapeIsolateOptions<Binding>): void\n\n\t/**\n\t * Called before the shape referenced in a binding's `toId` is about to be isolated from the\n\t * shape referenced in `fromId`. See {@link BindingOnShapeIsolateOptions} for discussion on what\n\t * isolation means, and when/how to use this callback.\n\t */\n\tonBeforeIsolateToShape?(options: BindingOnShapeIsolateOptions<Binding>): void\n}\n"],
4
+ "sourcesContent": ["import {\n\tRecordProps,\n\tTLBinding,\n\tTLPropsMigrations,\n\tTLShape,\n\tTLUnknownBinding,\n} from '@tldraw/tlschema'\nimport type { Editor } from '../Editor'\n\n/** @public */\nexport interface TLBindingUtilConstructor<\n\tT extends TLBinding,\n\tU extends BindingUtil<T> = BindingUtil<T>,\n> {\n\tnew (editor: Editor): U\n\ttype: T['type']\n\t/** Validations for this binding's props. */\n\tprops?: RecordProps<T>\n\t/** Migrations for this binding's props. */\n\tmigrations?: TLPropsMigrations\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeCreate} and {@link BindingUtil.onAfterCreate},\n * describing a the creating a binding.\n *\n * @public\n */\nexport interface BindingOnCreateOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding being created. */\n\tbinding: Binding\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeChange} and {@link BindingUtil.onAfterChange},\n * describing the data associated with a binding being changed.\n *\n * @public\n */\nexport interface BindingOnChangeOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding record before the change is made. */\n\tbindingBefore: Binding\n\t/** The binding record after the change is made. */\n\tbindingAfter: Binding\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeDelete} and {@link BindingUtil.onAfterDelete},\n * describing a binding being deleted.\n *\n * @public\n */\nexport interface BindingOnDeleteOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding being deleted. */\n\tbinding: Binding\n}\n\n/**\n * Options passed to {@link BindingUtil.onAfterChangeFromShape} and\n * {@link BindingUtil.onAfterChangeToShape}, describing a bound shape being changed.\n *\n * @public\n */\nexport interface BindingOnShapeChangeOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding record linking these two shapes. */\n\tbinding: Binding\n\t/** The shape record before the change is made. */\n\tshapeBefore: TLShape\n\t/** The shape record after the change is made. */\n\tshapeAfter: TLShape\n\t/**\n\t * Why did this shape change?\n\t * - 'self': the shape itself changed\n\t * - 'ancestry': the ancestry of the shape changed, but the shape itself may not have done\n\t */\n\treason: 'self' | 'ancestry'\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeIsolateFromShape} and\n * {@link BindingUtil.onBeforeIsolateToShape}, describing a shape that is about to be isolated from\n * the one that it's bound to.\n *\n * Isolation happens whenever two bound shapes are separated. For example\n * 1. One is deleted, but the other is not.\n * 1. One is copied, but the other is not.\n * 1. One is duplicated, but the other is not.\n *\n * In each of these cases, if the remaining shape depends on the binding for its rendering, it may\n * now be in an inconsistent state. For example, tldraw's arrow shape depends on the binding to know\n * where the end of the arrow is. If we removed the binding without doing anything else, the arrow\n * would suddenly be pointing to the wrong location. Instead, when the shape the arrow is pointing\n * to is deleted, or the arrow is copied/duplicated, we use an isolation callback. The callback\n * updates the arrow based on the binding that's about to be removed, so it doesn't end up pointing\n * to the wrong place.\n *\n * For this style of consistency update, use isolation callbacks. For actions specific to deletion\n * (like deleting a sticker when the shape it's bound to is removed), use the delete callbacks\n * ({@link BindingUtil.onBeforeDeleteFromShape} and {@link BindingUtil.onBeforeDeleteToShape})\n * instead.\n *\n * @public\n */\nexport interface BindingOnShapeIsolateOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding record that refers to the shape in question. */\n\tbinding: Binding\n\t/**\n\t * The shape being removed. For deletion, this is the deleted shape. For copy/duplicate, this is\n\t * the shape that _isn't_ being copied/duplicated and is getting left behind.\n\t */\n\tremovedShape: TLShape\n}\n\n/**\n * Options passed to {@link BindingUtil.onBeforeDeleteFromShape} and\n * {@link BindingUtil.onBeforeDeleteToShape}, describing a bound shape that is about to be deleted.\n *\n * See {@link BindingOnShapeIsolateOptions} for discussion on when to use the delete vs. the isolate\n * callbacks.\n *\n * @public\n */\nexport interface BindingOnShapeDeleteOptions<Binding extends TLBinding = TLBinding> {\n\t/** The binding record that refers to the shape in question. */\n\tbinding: Binding\n\t/** The shape that is about to be deleted. */\n\tshape: TLShape\n}\n\n/** @public */\nexport abstract class BindingUtil<Binding extends TLBinding = TLBinding> {\n\tconstructor(public editor: Editor) {}\n\tstatic props?: RecordProps<TLUnknownBinding>\n\tstatic migrations?: TLPropsMigrations\n\n\t/**\n\t * The type of the binding util, which should match the binding's type.\n\t *\n\t * @public\n\t */\n\tstatic type: string\n\n\t/**\n\t * Get the default props for a binding.\n\t *\n\t * @public\n\t */\n\tabstract getDefaultProps(): Partial<Binding['props']>\n\n\t/**\n\t * Called whenever a store operation involving this binding type has completed. This is useful\n\t * for working with networks of related bindings that may need to update together.\n\t *\n\t * @example\n\t * ```ts\n\t * class MyBindingUtil extends BindingUtil<MyBinding> {\n\t * changedBindingIds = new Set<TLBindingId>()\n\t *\n\t * onOperationComplete() {\n\t * doSomethingWithChangedBindings(this.changedBindingIds)\n\t * this.changedBindingIds.clear()\n\t * }\n\t *\n\t * onAfterChange({ bindingAfter }: BindingOnChangeOptions<MyBinding>) {\n\t * this.changedBindingIds.add(bindingAfter.id)\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t */\n\tonOperationComplete?(): void\n\n\t/**\n\t * Called when a binding is about to be created. See {@link BindingOnCreateOptions} for details.\n\t *\n\t * You can optionally return a new binding to replace the one being created - for example, to\n\t * set different initial props.\n\t *\n\t * @public\n\t */\n\tonBeforeCreate?(options: BindingOnCreateOptions<Binding>): Binding | void\n\n\t/**\n\t * Called after a binding has been created. See {@link BindingOnCreateOptions} for details.\n\t *\n\t * @public\n\t */\n\tonAfterCreate?(options: BindingOnCreateOptions<Binding>): void\n\n\t/**\n\t * Called when a binding is about to be changed. See {@link BindingOnChangeOptions} for details.\n\t *\n\t * Note that this only fires when the binding record is changing, not when the shapes\n\t * associated change. Use {@link BindingUtil.onAfterChangeFromShape} and\n\t * {@link BindingUtil.onAfterChangeToShape} for that.\n\t *\n\t * You can optionally return a new binding to replace the one being changed - for example, to\n\t * enforce constraints on the binding's props.\n\t *\n\t * @public\n\t */\n\tonBeforeChange?(options: BindingOnChangeOptions<Binding>): Binding | void\n\n\t/**\n\t * Called after a binding has been changed. See {@link BindingOnChangeOptions} for details.\n\t *\n\t * Note that this only fires when the binding record is changing, not when the shapes\n\t * associated change. Use {@link BindingUtil.onAfterChangeFromShape} and\n\t * {@link BindingUtil.onAfterChangeToShape} for that.\n\t *\n\t * @public\n\t */\n\tonAfterChange?(options: BindingOnChangeOptions<Binding>): void\n\n\t/**\n\t * Called when a binding is about to be deleted. See {@link BindingOnDeleteOptions} for details.\n\t *\n\t * @public\n\t */\n\tonBeforeDelete?(options: BindingOnDeleteOptions<Binding>): void\n\n\t/**\n\t * Called after a binding has been deleted. See {@link BindingOnDeleteOptions} for details.\n\t *\n\t * @public\n\t */\n\tonAfterDelete?(options: BindingOnDeleteOptions<Binding>): void\n\n\t/**\n\t * Called after the shape referenced in a binding's `fromId` is changed. Use this to propagate\n\t * any changes to the binding itself or the other shape as needed. See\n\t * {@link BindingOnShapeChangeOptions} for details.\n\t *\n\t * @public\n\t */\n\tonAfterChangeFromShape?(options: BindingOnShapeChangeOptions<Binding>): void\n\n\t/**\n\t * Called after the shape referenced in a binding's `toId` is changed. Use this to propagate any\n\t * changes to the binding itself or the other shape as needed. See\n\t * {@link BindingOnShapeChangeOptions} for details.\n\t *\n\t * @public\n\t */\n\tonAfterChangeToShape?(options: BindingOnShapeChangeOptions<Binding>): void\n\n\t/**\n\t * Called before the shape referenced in a binding's `fromId` is about to be deleted. Use this\n\t * with care - you may want to use {@link BindingUtil.onBeforeIsolateToShape} instead. See\n\t * {@link BindingOnShapeDeleteOptions} for details.\n\t *\n\t * @public\n\t */\n\tonBeforeDeleteFromShape?(options: BindingOnShapeDeleteOptions<Binding>): void\n\t/**\n\t * Called before the shape referenced in a binding's `toId` is about to be deleted. Use this\n\t * with care - you may want to use {@link BindingUtil.onBeforeIsolateFromShape} instead. See\n\t * {@link BindingOnShapeDeleteOptions} for details.\n\t *\n\t * @public\n\t */\n\tonBeforeDeleteToShape?(options: BindingOnShapeDeleteOptions<Binding>): void\n\n\t/**\n\t * Called before the shape referenced in a binding's `fromId` is about to be isolated from the\n\t * shape referenced in `toId`. See {@link BindingOnShapeIsolateOptions} for discussion on what\n\t * isolation means, and when/how to use this callback.\n\t */\n\tonBeforeIsolateFromShape?(options: BindingOnShapeIsolateOptions<Binding>): void\n\n\t/**\n\t * Called before the shape referenced in a binding's `toId` is about to be isolated from the\n\t * shape referenced in `fromId`. See {@link BindingOnShapeIsolateOptions} for discussion on what\n\t * isolation means, and when/how to use this callback.\n\t */\n\tonBeforeIsolateToShape?(options: BindingOnShapeIsolateOptions<Binding>): void\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkIO,MAAe,YAAmD;AAAA,EACxE,YAAmB,QAAgB;AAAhB;AAAA,EAAiB;AAAA,EACpC,OAAO;AAAA,EACP,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOP,OAAO;AAyIR;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/editor/derivations/bindingsIndex.ts"],
4
- "sourcesContent": ["import { Computed, RESET_VALUE, computed, isUninitialized } from '@tldraw/state'\nimport { TLBinding, TLShapeId } from '@tldraw/tlschema'\nimport { objectMapValues } from '@tldraw/utils'\nimport { Editor } from '../Editor'\n\ntype TLBindingsIndex = Map<TLShapeId, TLBinding[]>\n\nfunction fromScratch(bindingsQuery: Computed<TLBinding[], unknown>) {\n\tconst allBindings = bindingsQuery.get() as TLBinding[]\n\n\tconst shapesToBindings: TLBindingsIndex = new Map()\n\n\tfor (const binding of allBindings) {\n\t\tconst { fromId, toId } = binding\n\t\tconst bindingsForFromShape = shapesToBindings.get(fromId)\n\t\tif (!bindingsForFromShape) {\n\t\t\tshapesToBindings.set(fromId, [binding])\n\t\t} else {\n\t\t\tbindingsForFromShape.push(binding)\n\t\t}\n\t\tconst bindingsForToShape = shapesToBindings.get(toId)\n\t\tif (!bindingsForToShape) {\n\t\t\tshapesToBindings.set(toId, [binding])\n\t\t} else {\n\t\t\tbindingsForToShape.push(binding)\n\t\t}\n\t}\n\n\treturn shapesToBindings\n}\n\nexport const bindingsIndex = (editor: Editor): Computed<TLBindingsIndex> => {\n\tconst { store } = editor\n\tconst bindingsHistory = store.query.filterHistory('binding')\n\tconst bindingsQuery = store.query.records('binding')\n\n\treturn computed<TLBindingsIndex>('arrowBindingsIndex', (_lastValue, lastComputedEpoch) => {\n\t\tif (isUninitialized(_lastValue)) {\n\t\t\treturn fromScratch(bindingsQuery)\n\t\t}\n\n\t\tconst lastValue = _lastValue\n\n\t\tconst diff = bindingsHistory.getDiffSince(lastComputedEpoch)\n\n\t\tif (diff === RESET_VALUE) {\n\t\t\treturn fromScratch(bindingsQuery)\n\t\t}\n\n\t\tlet nextValue: TLBindingsIndex | undefined = undefined\n\n\t\tfunction removingBinding(binding: TLBinding) {\n\t\t\tnextValue ??= new Map(lastValue)\n\t\t\tconst prevFrom = nextValue.get(binding.fromId)\n\t\t\tconst nextFrom = prevFrom?.filter((b) => b.id !== binding.id)\n\t\t\tif (!nextFrom?.length) {\n\t\t\t\tnextValue.delete(binding.fromId)\n\t\t\t} else {\n\t\t\t\tnextValue.set(binding.fromId, nextFrom)\n\t\t\t}\n\t\t\tconst prevTo = nextValue.get(binding.toId)\n\t\t\tconst nextTo = prevTo?.filter((b) => b.id !== binding.id)\n\t\t\tif (!nextTo?.length) {\n\t\t\t\tnextValue.delete(binding.toId)\n\t\t\t} else {\n\t\t\t\tnextValue.set(binding.toId, nextTo)\n\t\t\t}\n\t\t}\n\n\t\tfunction ensureNewArray(shapeId: TLShapeId) {\n\t\t\tnextValue ??= new Map(lastValue)\n\n\t\t\tlet result = nextValue.get(shapeId)\n\t\t\tif (!result) {\n\t\t\t\tresult = []\n\t\t\t\tnextValue.set(shapeId, result)\n\t\t\t} else if (result === lastValue.get(shapeId)) {\n\t\t\t\tresult = result.slice(0)\n\t\t\t\tnextValue.set(shapeId, result)\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\n\t\tfunction addBinding(binding: TLBinding) {\n\t\t\tensureNewArray(binding.fromId).push(binding)\n\t\t\tensureNewArray(binding.toId).push(binding)\n\t\t}\n\n\t\tfor (const changes of diff) {\n\t\t\tfor (const newBinding of objectMapValues(changes.added)) {\n\t\t\t\taddBinding(newBinding)\n\t\t\t}\n\n\t\t\tfor (const [prev, next] of objectMapValues(changes.updated)) {\n\t\t\t\tremovingBinding(prev)\n\t\t\t\taddBinding(next)\n\t\t\t}\n\n\t\t\tfor (const prev of objectMapValues(changes.removed)) {\n\t\t\t\tremovingBinding(prev)\n\t\t\t}\n\t\t}\n\n\t\t// TODO: add diff entries if we need them\n\t\treturn nextValue ?? lastValue\n\t})\n}\n"],
4
+ "sourcesContent": ["import { Computed, RESET_VALUE, computed, isUninitialized } from '@tldraw/state'\nimport { TLBinding, TLShapeId } from '@tldraw/tlschema'\nimport { objectMapValues } from '@tldraw/utils'\nimport type { Editor } from '../Editor'\n\ntype TLBindingsIndex = Map<TLShapeId, TLBinding[]>\n\nfunction fromScratch(bindingsQuery: Computed<TLBinding[], unknown>) {\n\tconst allBindings = bindingsQuery.get() as TLBinding[]\n\n\tconst shapesToBindings: TLBindingsIndex = new Map()\n\n\tfor (const binding of allBindings) {\n\t\tconst { fromId, toId } = binding\n\t\tconst bindingsForFromShape = shapesToBindings.get(fromId)\n\t\tif (!bindingsForFromShape) {\n\t\t\tshapesToBindings.set(fromId, [binding])\n\t\t} else {\n\t\t\tbindingsForFromShape.push(binding)\n\t\t}\n\t\tconst bindingsForToShape = shapesToBindings.get(toId)\n\t\tif (!bindingsForToShape) {\n\t\t\tshapesToBindings.set(toId, [binding])\n\t\t} else {\n\t\t\tbindingsForToShape.push(binding)\n\t\t}\n\t}\n\n\treturn shapesToBindings\n}\n\nexport const bindingsIndex = (editor: Editor): Computed<TLBindingsIndex> => {\n\tconst { store } = editor\n\tconst bindingsHistory = store.query.filterHistory('binding')\n\tconst bindingsQuery = store.query.records('binding')\n\n\treturn computed<TLBindingsIndex>('arrowBindingsIndex', (_lastValue, lastComputedEpoch) => {\n\t\tif (isUninitialized(_lastValue)) {\n\t\t\treturn fromScratch(bindingsQuery)\n\t\t}\n\n\t\tconst lastValue = _lastValue\n\n\t\tconst diff = bindingsHistory.getDiffSince(lastComputedEpoch)\n\n\t\tif (diff === RESET_VALUE) {\n\t\t\treturn fromScratch(bindingsQuery)\n\t\t}\n\n\t\tlet nextValue: TLBindingsIndex | undefined = undefined\n\n\t\tfunction removingBinding(binding: TLBinding) {\n\t\t\tnextValue ??= new Map(lastValue)\n\t\t\tconst prevFrom = nextValue.get(binding.fromId)\n\t\t\tconst nextFrom = prevFrom?.filter((b) => b.id !== binding.id)\n\t\t\tif (!nextFrom?.length) {\n\t\t\t\tnextValue.delete(binding.fromId)\n\t\t\t} else {\n\t\t\t\tnextValue.set(binding.fromId, nextFrom)\n\t\t\t}\n\t\t\tconst prevTo = nextValue.get(binding.toId)\n\t\t\tconst nextTo = prevTo?.filter((b) => b.id !== binding.id)\n\t\t\tif (!nextTo?.length) {\n\t\t\t\tnextValue.delete(binding.toId)\n\t\t\t} else {\n\t\t\t\tnextValue.set(binding.toId, nextTo)\n\t\t\t}\n\t\t}\n\n\t\tfunction ensureNewArray(shapeId: TLShapeId) {\n\t\t\tnextValue ??= new Map(lastValue)\n\n\t\t\tlet result = nextValue.get(shapeId)\n\t\t\tif (!result) {\n\t\t\t\tresult = []\n\t\t\t\tnextValue.set(shapeId, result)\n\t\t\t} else if (result === lastValue.get(shapeId)) {\n\t\t\t\tresult = result.slice(0)\n\t\t\t\tnextValue.set(shapeId, result)\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\n\t\tfunction addBinding(binding: TLBinding) {\n\t\t\tensureNewArray(binding.fromId).push(binding)\n\t\t\tensureNewArray(binding.toId).push(binding)\n\t\t}\n\n\t\tfor (const changes of diff) {\n\t\t\tfor (const newBinding of objectMapValues(changes.added)) {\n\t\t\t\taddBinding(newBinding)\n\t\t\t}\n\n\t\t\tfor (const [prev, next] of objectMapValues(changes.updated)) {\n\t\t\t\tremovingBinding(prev)\n\t\t\t\taddBinding(next)\n\t\t\t}\n\n\t\t\tfor (const prev of objectMapValues(changes.removed)) {\n\t\t\t\tremovingBinding(prev)\n\t\t\t}\n\t\t}\n\n\t\t// TODO: add diff entries if we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7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/editor/derivations/notVisibleShapes.ts"],
4
- "sourcesContent": ["import { computed, isUninitialized } from '@tldraw/state'\nimport { TLShape, TLShapeId } from '@tldraw/tlschema'\nimport { Editor } from '../Editor'\n\n/**\n * Non visible shapes are shapes outside of the viewport page bounds.\n *\n * @param editor - Instance of the tldraw Editor.\n * @returns Incremental derivation of non visible shapes.\n */\nexport function notVisibleShapes(editor: Editor) {\n\tconst emptySet = new Set<TLShapeId>()\n\n\treturn computed<Set<TLShapeId>>('notVisibleShapes', function (prevValue) {\n\t\tconst allShapes = editor.getCurrentPageShapes()\n\t\tconst viewportPageBounds = editor.getViewportPageBounds()\n\t\tconst visibleIds = editor.getShapeIdsInsideBounds(viewportPageBounds)\n\n\t\tlet shape: TLShape | undefined\n\n\t\t// Fast path: if all shapes are visible, return empty set\n\t\tif (visibleIds.size === allShapes.length) {\n\t\t\tif (isUninitialized(prevValue) || prevValue.size > 0) {\n\t\t\t\treturn emptySet\n\t\t\t}\n\t\t\treturn prevValue\n\t\t}\n\n\t\t// First run: compute from scratch\n\t\tif (isUninitialized(prevValue)) {\n\t\t\tconst nextValue = new Set<TLShapeId>()\n\t\t\tfor (let i = 0; i < allShapes.length; i++) {\n\t\t\t\tshape = allShapes[i]\n\t\t\t\tif (visibleIds.has(shape.id)) continue\n\t\t\t\tif (!editor.getShapeUtil(shape.type).canCull(shape)) continue\n\t\t\t\tnextValue.add(shape.id)\n\t\t\t}\n\t\t\treturn nextValue\n\t\t}\n\n\t\t// Subsequent runs: single pass to collect IDs and detect changes\n\t\tconst notVisibleIds: TLShapeId[] = []\n\t\tfor (let i = 0; i < allShapes.length; i++) {\n\t\t\tshape = allShapes[i]\n\t\t\tif (visibleIds.has(shape.id)) continue\n\t\t\tif (!editor.getShapeUtil(shape.type).canCull(shape)) continue\n\t\t\tnotVisibleIds.push(shape.id)\n\t\t}\n\n\t\t// Check if the result changed\n\t\tif (notVisibleIds.length === prevValue.size) {\n\t\t\tlet same = true\n\t\t\tfor (let i = 0; i < notVisibleIds.length; i++) {\n\t\t\t\tif (!prevValue.has(notVisibleIds[i])) {\n\t\t\t\t\tsame = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (same) return prevValue\n\t\t}\n\n\t\treturn new Set(notVisibleIds)\n\t})\n}\n"],
4
+ "sourcesContent": ["import { computed, isUninitialized } from '@tldraw/state'\nimport { TLShape, TLShapeId } from '@tldraw/tlschema'\nimport type { Editor } from '../Editor'\n\n/**\n * Non visible shapes are shapes outside of the viewport page bounds.\n *\n * @param editor - Instance of the tldraw Editor.\n * @returns Incremental derivation of non visible shapes.\n */\nexport function notVisibleShapes(editor: Editor) {\n\tconst emptySet = new Set<TLShapeId>()\n\n\treturn computed<Set<TLShapeId>>('notVisibleShapes', function (prevValue) {\n\t\tconst allShapes = editor.getCurrentPageShapes()\n\t\tconst viewportPageBounds = editor.getViewportPageBounds()\n\t\tconst visibleIds = editor.getShapeIdsInsideBounds(viewportPageBounds)\n\n\t\tlet shape: TLShape | undefined\n\n\t\t// Fast path: if all shapes are visible, return empty set\n\t\tif (visibleIds.size === allShapes.length) {\n\t\t\tif (isUninitialized(prevValue) || prevValue.size > 0) {\n\t\t\t\treturn emptySet\n\t\t\t}\n\t\t\treturn prevValue\n\t\t}\n\n\t\t// First run: compute from scratch\n\t\tif (isUninitialized(prevValue)) {\n\t\t\tconst nextValue = new Set<TLShapeId>()\n\t\t\tfor (let i = 0; i < allShapes.length; i++) {\n\t\t\t\tshape = allShapes[i]\n\t\t\t\tif (visibleIds.has(shape.id)) continue\n\t\t\t\tif (!editor.getShapeUtil(shape.type).canCull(shape)) continue\n\t\t\t\tnextValue.add(shape.id)\n\t\t\t}\n\t\t\treturn nextValue\n\t\t}\n\n\t\t// Subsequent runs: single pass to collect IDs and detect changes\n\t\tconst notVisibleIds: TLShapeId[] = []\n\t\tfor (let i = 0; i < allShapes.length; i++) {\n\t\t\tshape = allShapes[i]\n\t\t\tif (visibleIds.has(shape.id)) continue\n\t\t\tif (!editor.getShapeUtil(shape.type).canCull(shape)) continue\n\t\t\tnotVisibleIds.push(shape.id)\n\t\t}\n\n\t\t// Check if the result changed\n\t\tif (notVisibleIds.length === prevValue.size) {\n\t\t\tlet same = true\n\t\t\tfor (let i = 0; i < notVisibleIds.length; i++) {\n\t\t\t\tif (!prevValue.has(notVisibleIds[i])) {\n\t\t\t\t\tsame = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (same) return prevValue\n\t\t}\n\n\t\treturn new Set(notVisibleIds)\n\t})\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAUnC,SAAS,iBAAiB,QAAgB;AAChD,QAAM,WAAW,oBAAI,IAAe;AAEpC,aAAO,uBAAyB,oBAAoB,SAAU,WAAW;AACxE,UAAM,YAAY,OAAO,qBAAqB;AAC9C,UAAM,qBAAqB,OAAO,sBAAsB;AACxD,UAAM,aAAa,OAAO,wBAAwB,kBAAkB;AAEpE,QAAI;AAGJ,QAAI,WAAW,SAAS,UAAU,QAAQ;AACzC,cAAI,8BAAgB,SAAS,KAAK,UAAU,OAAO,GAAG;AACrD,eAAO;AAAA,MACR;AACA,aAAO;AAAA,IACR;AAGA,YAAI,8BAAgB,SAAS,GAAG;AAC/B,YAAM,YAAY,oBAAI,IAAe;AACrC,eAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AAC1C,gBAAQ,UAAU,CAAC;AACnB,YAAI,WAAW,IAAI,MAAM,EAAE,EAAG;AAC9B,YAAI,CAAC,OAAO,aAAa,MAAM,IAAI,EAAE,QAAQ,KAAK,EAAG;AACrD,kBAAU,IAAI,MAAM,EAAE;AAAA,MACvB;AACA,aAAO;AAAA,IACR;AAGA,UAAM,gBAA6B,CAAC;AACpC,aAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AAC1C,cAAQ,UAAU,CAAC;AACnB,UAAI,WAAW,IAAI,MAAM,EAAE,EAAG;AAC9B,UAAI,CAAC,OAAO,aAAa,MAAM,IAAI,EAAE,QAAQ,KAAK,EAAG;AACrD,oBAAc,KAAK,MAAM,EAAE;AAAA,IAC5B;AAGA,QAAI,cAAc,WAAW,UAAU,MAAM;AAC5C,UAAI,OAAO;AACX,eAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC9C,YAAI,CAAC,UAAU,IAAI,cAAc,CAAC,CAAC,GAAG;AACrC,iBAAO;AACP;AAAA,QACD;AAAA,MACD;AACA,UAAI,KAAM,QAAO;AAAA,IAClB;AAEA,WAAO,IAAI,IAAI,aAAa;AAAA,EAC7B,CAAC;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts"],
4
- "sourcesContent": ["import { Vec } from '../../../primitives/Vec'\nimport { EASINGS } from '../../../primitives/easings'\nimport { Editor } from '../../Editor'\n\n/** @public */\nexport class EdgeScrollManager {\n\tconstructor(public editor: Editor) {}\n\n\tprivate _isEdgeScrolling = false\n\tprivate _edgeScrollDuration = -1\n\n\tgetIsEdgeScrolling() {\n\t\treturn this._isEdgeScrolling\n\t}\n\n\t/**\n\t * Update the camera position when the mouse is close to the edge of the screen.\n\t * Run this on every tick when in a state where edge scrolling is enabled.\n\t *\n\t * @public\n\t */\n\tupdateEdgeScrolling(elapsed: number) {\n\t\tconst { editor } = this\n\n\t\tif (editor.getCameraOptions().isLocked) return\n\n\t\tconst edgeScrollProximityFactor = this.getEdgeScroll()\n\t\tif (edgeScrollProximityFactor.x === 0 && edgeScrollProximityFactor.y === 0) {\n\t\t\tif (this._isEdgeScrolling) {\n\t\t\t\tthis._isEdgeScrolling = false\n\t\t\t\tthis._edgeScrollDuration = 0\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this._isEdgeScrolling) {\n\t\t\t\tthis._isEdgeScrolling = true\n\t\t\t\tthis._edgeScrollDuration = 0\n\t\t\t}\n\t\t\tthis._edgeScrollDuration += elapsed\n\t\t\tif (this._edgeScrollDuration > editor.options.edgeScrollDelay) {\n\t\t\t\tconst eased =\n\t\t\t\t\teditor.options.edgeScrollEaseDuration > 0\n\t\t\t\t\t\t? EASINGS.easeInCubic(\n\t\t\t\t\t\t\t\tMath.min(\n\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t\tthis._edgeScrollDuration /\n\t\t\t\t\t\t\t\t\t\t(editor.options.edgeScrollDelay + editor.options.edgeScrollEaseDuration)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: 1\n\t\t\t\tthis.moveCameraWhenCloseToEdge({\n\t\t\t\t\tx: edgeScrollProximityFactor.x * eased,\n\t\t\t\t\ty: edgeScrollProximityFactor.y * eased,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Helper function to get the scroll proximity factor for a given position.\n\t * @param position - The mouse position on the axis.\n\t * @param dimension - The component dimension on the axis.\n\t * @param isCoarse - Whether the pointer is coarse.\n\t * @param insetStart - Whether the pointer is inset at the start of the axis.\n\t * @param insetEnd - Whether the pointer is inset at the end of the axis.\n\t * @internal\n\t */\n\tprivate getEdgeProximityFactors(\n\t\tposition: number,\n\t\tdimension: number,\n\t\tisCoarse: boolean,\n\t\tinsetStart: boolean,\n\t\tinsetEnd: boolean\n\t) {\n\t\tconst { editor } = this\n\t\tconst dist = editor.options.edgeScrollDistance\n\t\tconst pw = isCoarse ? editor.options.coarsePointerWidth : 0 // pointer width\n\t\tconst pMin = position - pw\n\t\tconst pMax = position + pw\n\t\tconst min = insetStart ? 0 : dist\n\t\tconst max = insetEnd ? dimension : dimension - dist\n\t\tif (pMin < min) {\n\t\t\treturn Math.min(1, (min - pMin) / dist)\n\t\t} else if (pMax > max) {\n\t\t\treturn -Math.min(1, (pMax - max) / dist)\n\t\t}\n\t\treturn 0\n\t}\n\n\tprivate getEdgeScroll() {\n\t\tconst { editor } = this\n\t\tconst { x, y } = editor.inputs.getCurrentScreenPoint()\n\t\tconst screenBounds = editor.getViewportScreenBounds()\n\n\t\tconst {\n\t\t\tisCoarsePointer,\n\t\t\tinsets: [t, r, b, l],\n\t\t} = editor.getInstanceState()\n\t\tconst proximityFactorX = this.getEdgeProximityFactors(x, screenBounds.w, isCoarsePointer, l, r)\n\t\tconst proximityFactorY = this.getEdgeProximityFactors(y, screenBounds.h, isCoarsePointer, t, b)\n\n\t\treturn {\n\t\t\tx: proximityFactorX,\n\t\t\ty: proximityFactorY,\n\t\t}\n\t}\n\n\t/**\n\t * Moves the camera when the mouse is close to the edge of the screen.\n\t * @public\n\t */\n\tprivate moveCameraWhenCloseToEdge(proximityFactor: { x: number; y: number }) {\n\t\tif (proximityFactor.x === 0 && proximityFactor.y === 0) return\n\t\tconst { editor } = this\n\n\t\tconst screenBounds = editor.getViewportScreenBounds()\n\n\t\t// Determines how much the speed is affected by the screen size\n\t\tconst screenSizeFactorX = screenBounds.w < 1000 ? 0.612 : 1\n\t\tconst screenSizeFactorY = screenBounds.h < 1000 ? 0.612 : 1\n\n\t\t// Determines the base speed of the scroll\n\t\tconst zoomLevel = editor.getZoomLevel()\n\t\tconst pxSpeed = editor.user.getEdgeScrollSpeed() * editor.options.edgeScrollSpeed\n\t\tconst scrollDeltaX = (pxSpeed * proximityFactor.x * screenSizeFactorX) / zoomLevel\n\t\tconst scrollDeltaY = (pxSpeed * proximityFactor.y * screenSizeFactorY) / zoomLevel\n\n\t\t// update the camera\n\t\tconst { x, y, z } = editor.getCamera()\n\t\teditor.setCamera(new Vec(x + scrollDeltaX, y + scrollDeltaY, z))\n\t}\n}\n"],
4
+ "sourcesContent": ["import { Vec } from '../../../primitives/Vec'\nimport { EASINGS } from '../../../primitives/easings'\nimport type { Editor } from '../../Editor'\n\n/** @public */\nexport class EdgeScrollManager {\n\tconstructor(public editor: Editor) {}\n\n\tprivate _isEdgeScrolling = false\n\tprivate _edgeScrollDuration = -1\n\n\tgetIsEdgeScrolling() {\n\t\treturn this._isEdgeScrolling\n\t}\n\n\t/**\n\t * Update the camera position when the mouse is close to the edge of the screen.\n\t * Run this on every tick when in a state where edge scrolling is enabled.\n\t *\n\t * @public\n\t */\n\tupdateEdgeScrolling(elapsed: number) {\n\t\tconst { editor } = this\n\n\t\tif (editor.getCameraOptions().isLocked) return\n\n\t\tconst edgeScrollProximityFactor = this.getEdgeScroll()\n\t\tif (edgeScrollProximityFactor.x === 0 && edgeScrollProximityFactor.y === 0) {\n\t\t\tif (this._isEdgeScrolling) {\n\t\t\t\tthis._isEdgeScrolling = false\n\t\t\t\tthis._edgeScrollDuration = 0\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this._isEdgeScrolling) {\n\t\t\t\tthis._isEdgeScrolling = true\n\t\t\t\tthis._edgeScrollDuration = 0\n\t\t\t}\n\t\t\tthis._edgeScrollDuration += elapsed\n\t\t\tif (this._edgeScrollDuration > editor.options.edgeScrollDelay) {\n\t\t\t\tconst eased =\n\t\t\t\t\teditor.options.edgeScrollEaseDuration > 0\n\t\t\t\t\t\t? EASINGS.easeInCubic(\n\t\t\t\t\t\t\t\tMath.min(\n\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t\tthis._edgeScrollDuration /\n\t\t\t\t\t\t\t\t\t\t(editor.options.edgeScrollDelay + editor.options.edgeScrollEaseDuration)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: 1\n\t\t\t\tthis.moveCameraWhenCloseToEdge({\n\t\t\t\t\tx: edgeScrollProximityFactor.x * eased,\n\t\t\t\t\ty: edgeScrollProximityFactor.y * eased,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Helper function to get the scroll proximity factor for a given position.\n\t * @param position - The mouse position on the axis.\n\t * @param dimension - The component dimension on the axis.\n\t * @param isCoarse - Whether the pointer is coarse.\n\t * @param insetStart - Whether the pointer is inset at the start of the axis.\n\t * @param insetEnd - Whether the pointer is inset at the end of the axis.\n\t * @internal\n\t */\n\tprivate getEdgeProximityFactors(\n\t\tposition: number,\n\t\tdimension: number,\n\t\tisCoarse: boolean,\n\t\tinsetStart: boolean,\n\t\tinsetEnd: boolean\n\t) {\n\t\tconst { editor } = this\n\t\tconst dist = editor.options.edgeScrollDistance\n\t\tconst pw = isCoarse ? editor.options.coarsePointerWidth : 0 // pointer width\n\t\tconst pMin = position - pw\n\t\tconst pMax = position + pw\n\t\tconst min = insetStart ? 0 : dist\n\t\tconst max = insetEnd ? dimension : dimension - dist\n\t\tif (pMin < min) {\n\t\t\treturn Math.min(1, (min - pMin) / dist)\n\t\t} else if (pMax > max) {\n\t\t\treturn -Math.min(1, (pMax - max) / dist)\n\t\t}\n\t\treturn 0\n\t}\n\n\tprivate getEdgeScroll() {\n\t\tconst { editor } = this\n\t\tconst { x, y } = editor.inputs.getCurrentScreenPoint()\n\t\tconst screenBounds = editor.getViewportScreenBounds()\n\n\t\tconst {\n\t\t\tisCoarsePointer,\n\t\t\tinsets: [t, r, b, l],\n\t\t} = editor.getInstanceState()\n\t\tconst proximityFactorX = this.getEdgeProximityFactors(x, screenBounds.w, isCoarsePointer, l, r)\n\t\tconst proximityFactorY = this.getEdgeProximityFactors(y, screenBounds.h, isCoarsePointer, t, b)\n\n\t\treturn {\n\t\t\tx: proximityFactorX,\n\t\t\ty: proximityFactorY,\n\t\t}\n\t}\n\n\t/**\n\t * Moves the camera when the mouse is close to the edge of the screen.\n\t * @public\n\t */\n\tprivate moveCameraWhenCloseToEdge(proximityFactor: { x: number; y: number }) {\n\t\tif (proximityFactor.x === 0 && proximityFactor.y === 0) return\n\t\tconst { editor } = this\n\n\t\tconst screenBounds = editor.getViewportScreenBounds()\n\n\t\t// Determines how much the speed is affected by the screen size\n\t\tconst screenSizeFactorX = screenBounds.w < 1000 ? 0.612 : 1\n\t\tconst screenSizeFactorY = screenBounds.h < 1000 ? 0.612 : 1\n\n\t\t// Determines the base speed of the scroll\n\t\tconst zoomLevel = editor.getZoomLevel()\n\t\tconst pxSpeed = editor.user.getEdgeScrollSpeed() * editor.options.edgeScrollSpeed\n\t\tconst scrollDeltaX = (pxSpeed * proximityFactor.x * screenSizeFactorX) / zoomLevel\n\t\tconst scrollDeltaY = (pxSpeed * proximityFactor.y * screenSizeFactorY) / zoomLevel\n\n\t\t// update the camera\n\t\tconst { x, y, z } = editor.getCamera()\n\t\teditor.setCamera(new Vec(x + scrollDeltaX, y + scrollDeltaY, z))\n\t}\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AACpB,qBAAwB;AAIjB,MAAM,kBAAkB;AAAA,EAC9B,YAAmB,QAAgB;AAAhB;AAAA,EAAiB;AAAA,EAE5B,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EAE9B,qBAAqB;AACpB,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,oBAAoB,SAAiB;AACpC,UAAM,EAAE,OAAO,IAAI;AAEnB,QAAI,OAAO,iBAAiB,EAAE,SAAU;AAExC,UAAM,4BAA4B,KAAK,cAAc;AACrD,QAAI,0BAA0B,MAAM,KAAK,0BAA0B,MAAM,GAAG;AAC3E,UAAI,KAAK,kBAAkB;AAC1B,aAAK,mBAAmB;AACxB,aAAK,sBAAsB;AAAA,MAC5B;AAAA,IACD,OAAO;AACN,UAAI,CAAC,KAAK,kBAAkB;AAC3B,aAAK,mBAAmB;AACxB,aAAK,sBAAsB;AAAA,MAC5B;AACA,WAAK,uBAAuB;AAC5B,UAAI,KAAK,sBAAsB,OAAO,QAAQ,iBAAiB;AAC9D,cAAM,QACL,OAAO,QAAQ,yBAAyB,IACrC,uBAAQ;AAAA,UACR,KAAK;AAAA,YACJ;AAAA,YACA,KAAK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AA2C;AAC5E,QAAI,gBAAgB,MAAM,KAAK,gBAAgB,MAAM,EAAG;AACxD,UAAM,EAAE,OAAO,IAAI;AAEnB,UAAM,eAAe,OAAO,wBAAwB;AAGpD,UAAM,oBAAoB,aAAa,IAAI,MAAO,QAAQ;AAC1D,UAAM,oBAAoB,aAAa,IAAI,MAAO,QAAQ;AAG1D,UAAM,YAAY,OAAO,aAAa;AACtC,UAAM,UAAU,OAAO,KAAK,mBAAmB,IAAI,OAAO,QAAQ;AAClE,UAAM,eAAgB,UAAU,gBAAgB,IAAI,oBAAqB;AACzE,UAAM,eAAgB,UAAU,gBAAgB,IAAI,oBAAqB;AAGzE,UAAM,EAAE,GAAG,GAAG,EAAE,IAAI,OAAO,UAAU;AACrC,WAAO,UAAU,IAAI,eAAI,IAAI,cAAc,IAAI,cAAc,CAAC,CAAC;AAAA,EAChE;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/editor/managers/FontManager/FontManager.ts"],
4
- "sourcesContent": ["import { computed, EMPTY_ARRAY, transact } from '@tldraw/state'\nimport { AtomMap } from '@tldraw/store'\nimport { TLShape, TLShapeId } from '@tldraw/tlschema'\nimport {\n\tareArraysShallowEqual,\n\tcompact,\n\tFileHelpers,\n\tmapObjectMapValues,\n\tobjectMapEntries,\n} from '@tldraw/utils'\nimport { Editor } from '../../Editor'\n\n/**\n * Represents the `src` property of a {@link TLFontFace}.\n * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`} for details of the properties here.\n * @public\n */\nexport interface TLFontFaceSource {\n\t/**\n\t * A URL from which to load the font. If the value here is a key in\n\t * {@link tldraw#TLEditorAssetUrls.fonts}, the value from there will be used instead.\n\t */\n\turl: string\n\tformat?: string\n\ttech?: string\n}\n\n/**\n * A font face that can be used in the editor. The properties of this are largely the same as the\n * ones in the\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face | css `@font-face` rule}.\n * @public\n */\nexport interface TLFontFace {\n\t/**\n\t * How this font can be referred to in CSS.\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family | `font-family`}.\n\t */\n\treadonly family: string\n\t/**\n\t * The source of the font. This\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`}.\n\t */\n\treadonly src: TLFontFaceSource\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/ascent-override | `ascent-override`}.\n\t */\n\treadonly ascentOverride?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/descent-override | `descent-override`}.\n\t */\n\treadonly descentOverride?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch | `font-stretch`}.\n\t */\n\treadonly stretch?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style | `font-style`}.\n\t */\n\treadonly style?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight | `font-weight`}.\n\t */\n\treadonly weight?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings | `font-feature-settings`}.\n\t */\n\treadonly featureSettings?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/line-gap-override | `line-gap-override`}.\n\t */\n\treadonly lineGapOverride?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range | `unicode-range`}.\n\t */\n\treadonly unicodeRange?: string\n}\n\ninterface FontState {\n\treadonly state: 'loading' | 'ready' | 'error'\n\treadonly instance: FontFace\n\treadonly loadingPromise: Promise<void>\n}\n\n/** @public */\nexport class FontManager {\n\tconstructor(\n\t\tprivate readonly editor: Editor,\n\t\tprivate readonly assetUrls?: { [key: string]: string | undefined }\n\t) {\n\t\tthis.shapeFontFacesCache = editor.store.createComputedCache(\n\t\t\t'shape font faces',\n\t\t\t(shape: TLShape) => {\n\t\t\t\tconst shapeUtil = this.editor.getShapeUtil(shape)\n\t\t\t\treturn shapeUtil.getFontFaces(shape)\n\t\t\t},\n\t\t\t{\n\t\t\t\tareResultsEqual: areArraysShallowEqual,\n\t\t\t\tareRecordsEqual: (a, b) => a.props === b.props && a.meta === b.meta,\n\t\t\t}\n\t\t)\n\n\t\tthis.shapeFontLoadStateCache = editor.store.createCache<(FontState | null)[], TLShape>(\n\t\t\t(id: TLShapeId) => {\n\t\t\t\tconst fontFacesComputed = computed('font faces', () => this.getShapeFontFaces(id))\n\t\t\t\treturn computed(\n\t\t\t\t\t'font load state',\n\t\t\t\t\t() => {\n\t\t\t\t\t\tconst states = fontFacesComputed.get().map((face) => this.getFontState(face))\n\t\t\t\t\t\treturn states\n\t\t\t\t\t},\n\t\t\t\t\t{ isEqual: areArraysShallowEqual }\n\t\t\t\t)\n\t\t\t}\n\t\t)\n\t}\n\n\tprivate readonly shapeFontFacesCache\n\tprivate readonly shapeFontLoadStateCache\n\n\tgetShapeFontFaces(shape: TLShape | TLShapeId): TLFontFace[] {\n\t\tconst shapeId = typeof shape === 'string' ? shape : shape.id\n\t\treturn this.shapeFontFacesCache.get(shapeId) ?? EMPTY_ARRAY\n\t}\n\n\ttrackFontsForShape(shape: TLShape | TLShapeId) {\n\t\tconst shapeId = typeof shape === 'string' ? shape : shape.id\n\t\tthis.shapeFontLoadStateCache.get(shapeId)\n\t}\n\n\tasync loadRequiredFontsForCurrentPage(limit = Infinity) {\n\t\tconst neededFonts = new Set<TLFontFace>()\n\t\tfor (const shapeId of this.editor.getCurrentPageShapeIds()) {\n\t\t\tfor (const font of this.getShapeFontFaces(this.editor.getShape(shapeId)!)) {\n\t\t\t\tneededFonts.add(font)\n\t\t\t}\n\t\t}\n\n\t\tif (neededFonts.size > limit) {\n\t\t\treturn\n\t\t}\n\n\t\tconst promises = Array.from(neededFonts, (font) => this.ensureFontIsLoaded(font))\n\t\tawait Promise.all(promises)\n\t}\n\n\tprivate readonly fontStates = new AtomMap<TLFontFace, FontState>('font states')\n\tprivate getFontState(font: TLFontFace): FontState | null {\n\t\treturn this.fontStates.get(font) ?? null\n\t}\n\n\tensureFontIsLoaded(font: TLFontFace): Promise<void> {\n\t\tconst existingState = this.getFontState(font)\n\t\tif (existingState) return existingState.loadingPromise\n\n\t\tconst instance = this.findOrCreateFontFace(font)\n\t\tconst state: FontState = {\n\t\t\tstate: 'loading',\n\t\t\tinstance,\n\t\t\tloadingPromise: instance\n\t\t\t\t.load()\n\t\t\t\t.then(() => {\n\t\t\t\t\tdocument.fonts.add(instance)\n\t\t\t\t\tthis.fontStates.update(font, (s) => ({ ...s, state: 'ready' }))\n\t\t\t\t})\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tconsole.error(err)\n\t\t\t\t\tthis.fontStates.update(font, (s) => ({ ...s, state: 'error' }))\n\t\t\t\t}),\n\t\t}\n\n\t\tthis.fontStates.set(font, state)\n\t\treturn state.loadingPromise\n\t}\n\n\tprivate fontsToLoad = new Set<TLFontFace>()\n\trequestFonts(fonts: TLFontFace[]) {\n\t\tif (!this.fontsToLoad.size) {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (this.editor.isDisposed) return\n\t\t\t\tconst toLoad = this.fontsToLoad\n\t\t\t\tthis.fontsToLoad = new Set()\n\t\t\t\ttransact(() => {\n\t\t\t\t\tfor (const font of toLoad) {\n\t\t\t\t\t\tthis.ensureFontIsLoaded(font)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t\tfor (const font of fonts) {\n\t\t\tthis.fontsToLoad.add(font)\n\t\t}\n\t}\n\n\tprivate findOrCreateFontFace(font: TLFontFace) {\n\t\tfor (const existing of document.fonts) {\n\t\t\tif (\n\t\t\t\texisting.family === font.family &&\n\t\t\t\tobjectMapEntries(defaultFontFaceDescriptors).every(\n\t\t\t\t\t([key, defaultValue]) => existing[key] === (font[key] ?? defaultValue)\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn existing\n\t\t\t}\n\t\t}\n\n\t\tconst url = this.assetUrls?.[font.src.url] ?? font.src.url\n\t\tconst instance = new FontFace(font.family, `url(${JSON.stringify(url)})`, {\n\t\t\t...mapObjectMapValues(defaultFontFaceDescriptors, (key) => font[key]),\n\t\t\tdisplay: 'swap',\n\t\t})\n\n\t\tdocument.fonts.add(instance)\n\n\t\treturn instance\n\t}\n\n\tasync toEmbeddedCssDeclaration(font: TLFontFace) {\n\t\tconst url = this.assetUrls?.[font.src.url] ?? font.src.url\n\t\tconst dataUrl = await FileHelpers.urlToDataUrl(url)\n\n\t\tconst src = compact([\n\t\t\t`url(\"${dataUrl}\")`,\n\t\t\tfont.src.format ? `format(${font.src.format})` : null,\n\t\t\tfont.src.tech ? `tech(${font.src.tech})` : null,\n\t\t]).join(' ')\n\t\treturn compact([\n\t\t\t`@font-face {`,\n\t\t\t` font-family: \"${font.family}\";`,\n\t\t\tfont.ascentOverride ? ` ascent-override: ${font.ascentOverride};` : null,\n\t\t\tfont.descentOverride ? ` descent-override: ${font.descentOverride};` : null,\n\t\t\tfont.stretch ? ` font-stretch: ${font.stretch};` : null,\n\t\t\tfont.style ? ` font-style: ${font.style};` : null,\n\t\t\tfont.weight ? ` font-weight: ${font.weight};` : null,\n\t\t\tfont.featureSettings ? ` font-feature-settings: ${font.featureSettings};` : null,\n\t\t\tfont.lineGapOverride ? ` line-gap-override: ${font.lineGapOverride};` : null,\n\t\t\tfont.unicodeRange ? ` unicode-range: ${font.unicodeRange};` : null,\n\t\t\t` src: ${src};`,\n\t\t\t`}`,\n\t\t]).join('\\n')\n\t}\n}\n\n// From https://drafts.csswg.org/css-font-loading/#fontface-interface\nconst defaultFontFaceDescriptors = {\n\tstyle: 'normal',\n\tweight: 'normal',\n\tstretch: 'normal',\n\tunicodeRange: 'U+0-10FFFF',\n\tfeatureSettings: 'normal',\n\tascentOverride: 'normal',\n\tdescentOverride: 'normal',\n\tlineGapOverride: 'normal',\n}\n"],
4
+ "sourcesContent": ["import { computed, EMPTY_ARRAY, transact } from '@tldraw/state'\nimport { AtomMap } from '@tldraw/store'\nimport { TLShape, TLShapeId } from '@tldraw/tlschema'\nimport {\n\tareArraysShallowEqual,\n\tcompact,\n\tFileHelpers,\n\tmapObjectMapValues,\n\tobjectMapEntries,\n} from '@tldraw/utils'\nimport type { Editor } from '../../Editor'\n\n/**\n * Represents the `src` property of a {@link TLFontFace}.\n * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`} for details of the properties here.\n * @public\n */\nexport interface TLFontFaceSource {\n\t/**\n\t * A URL from which to load the font. If the value here is a key in\n\t * {@link tldraw#TLEditorAssetUrls.fonts}, the value from there will be used instead.\n\t */\n\turl: string\n\tformat?: string\n\ttech?: string\n}\n\n/**\n * A font face that can be used in the editor. The properties of this are largely the same as the\n * ones in the\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face | css `@font-face` rule}.\n * @public\n */\nexport interface TLFontFace {\n\t/**\n\t * How this font can be referred to in CSS.\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family | `font-family`}.\n\t */\n\treadonly family: string\n\t/**\n\t * The source of the font. This\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`}.\n\t */\n\treadonly src: TLFontFaceSource\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/ascent-override | `ascent-override`}.\n\t */\n\treadonly ascentOverride?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/descent-override | `descent-override`}.\n\t */\n\treadonly descentOverride?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch | `font-stretch`}.\n\t */\n\treadonly stretch?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style | `font-style`}.\n\t */\n\treadonly style?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight | `font-weight`}.\n\t */\n\treadonly weight?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings | `font-feature-settings`}.\n\t */\n\treadonly featureSettings?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/line-gap-override | `line-gap-override`}.\n\t */\n\treadonly lineGapOverride?: string\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range | `unicode-range`}.\n\t */\n\treadonly unicodeRange?: string\n}\n\ninterface FontState {\n\treadonly state: 'loading' | 'ready' | 'error'\n\treadonly instance: FontFace\n\treadonly loadingPromise: Promise<void>\n}\n\n/** @public */\nexport class FontManager {\n\tconstructor(\n\t\tprivate readonly editor: Editor,\n\t\tprivate readonly assetUrls?: { [key: string]: string | undefined }\n\t) {\n\t\tthis.shapeFontFacesCache = editor.store.createComputedCache(\n\t\t\t'shape font faces',\n\t\t\t(shape: TLShape) => {\n\t\t\t\tconst shapeUtil = this.editor.getShapeUtil(shape)\n\t\t\t\treturn shapeUtil.getFontFaces(shape)\n\t\t\t},\n\t\t\t{\n\t\t\t\tareResultsEqual: areArraysShallowEqual,\n\t\t\t\tareRecordsEqual: (a, b) => a.props === b.props && a.meta === b.meta,\n\t\t\t}\n\t\t)\n\n\t\tthis.shapeFontLoadStateCache = editor.store.createCache<(FontState | null)[], TLShape>(\n\t\t\t(id: TLShapeId) => {\n\t\t\t\tconst fontFacesComputed = computed('font faces', () => this.getShapeFontFaces(id))\n\t\t\t\treturn computed(\n\t\t\t\t\t'font load state',\n\t\t\t\t\t() => {\n\t\t\t\t\t\tconst states = fontFacesComputed.get().map((face) => this.getFontState(face))\n\t\t\t\t\t\treturn states\n\t\t\t\t\t},\n\t\t\t\t\t{ isEqual: areArraysShallowEqual }\n\t\t\t\t)\n\t\t\t}\n\t\t)\n\t}\n\n\tprivate readonly shapeFontFacesCache\n\tprivate readonly shapeFontLoadStateCache\n\n\tgetShapeFontFaces(shape: TLShape | TLShapeId): TLFontFace[] {\n\t\tconst shapeId = typeof shape === 'string' ? shape : shape.id\n\t\treturn this.shapeFontFacesCache.get(shapeId) ?? EMPTY_ARRAY\n\t}\n\n\ttrackFontsForShape(shape: TLShape | TLShapeId) {\n\t\tconst shapeId = typeof shape === 'string' ? shape : shape.id\n\t\tthis.shapeFontLoadStateCache.get(shapeId)\n\t}\n\n\tasync loadRequiredFontsForCurrentPage(limit = Infinity) {\n\t\tconst neededFonts = new Set<TLFontFace>()\n\t\tfor (const shapeId of this.editor.getCurrentPageShapeIds()) {\n\t\t\tfor (const font of this.getShapeFontFaces(this.editor.getShape(shapeId)!)) {\n\t\t\t\tneededFonts.add(font)\n\t\t\t}\n\t\t}\n\n\t\tif (neededFonts.size > limit) {\n\t\t\treturn\n\t\t}\n\n\t\tconst promises = Array.from(neededFonts, (font) => this.ensureFontIsLoaded(font))\n\t\tawait Promise.all(promises)\n\t}\n\n\tprivate readonly fontStates = new AtomMap<TLFontFace, FontState>('font states')\n\tprivate getFontState(font: TLFontFace): FontState | null {\n\t\treturn this.fontStates.get(font) ?? null\n\t}\n\n\tensureFontIsLoaded(font: TLFontFace): Promise<void> {\n\t\tconst existingState = this.getFontState(font)\n\t\tif (existingState) return existingState.loadingPromise\n\n\t\tconst instance = this.findOrCreateFontFace(font)\n\t\tconst state: FontState = {\n\t\t\tstate: 'loading',\n\t\t\tinstance,\n\t\t\tloadingPromise: instance\n\t\t\t\t.load()\n\t\t\t\t.then(() => {\n\t\t\t\t\tdocument.fonts.add(instance)\n\t\t\t\t\tthis.fontStates.update(font, (s) => ({ ...s, state: 'ready' }))\n\t\t\t\t})\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tconsole.error(err)\n\t\t\t\t\tthis.fontStates.update(font, (s) => ({ ...s, state: 'error' }))\n\t\t\t\t}),\n\t\t}\n\n\t\tthis.fontStates.set(font, state)\n\t\treturn state.loadingPromise\n\t}\n\n\tprivate fontsToLoad = new Set<TLFontFace>()\n\trequestFonts(fonts: TLFontFace[]) {\n\t\tif (!this.fontsToLoad.size) {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (this.editor.isDisposed) return\n\t\t\t\tconst toLoad = this.fontsToLoad\n\t\t\t\tthis.fontsToLoad = new Set()\n\t\t\t\ttransact(() => {\n\t\t\t\t\tfor (const font of toLoad) {\n\t\t\t\t\t\tthis.ensureFontIsLoaded(font)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t\tfor (const font of fonts) {\n\t\t\tthis.fontsToLoad.add(font)\n\t\t}\n\t}\n\n\tprivate findOrCreateFontFace(font: TLFontFace) {\n\t\tfor (const existing of document.fonts) {\n\t\t\tif (\n\t\t\t\texisting.family === font.family &&\n\t\t\t\tobjectMapEntries(defaultFontFaceDescriptors).every(\n\t\t\t\t\t([key, defaultValue]) => existing[key] === (font[key] ?? defaultValue)\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn existing\n\t\t\t}\n\t\t}\n\n\t\tconst url = this.assetUrls?.[font.src.url] ?? font.src.url\n\t\tconst instance = new FontFace(font.family, `url(${JSON.stringify(url)})`, {\n\t\t\t...mapObjectMapValues(defaultFontFaceDescriptors, (key) => font[key]),\n\t\t\tdisplay: 'swap',\n\t\t})\n\n\t\tdocument.fonts.add(instance)\n\n\t\treturn instance\n\t}\n\n\tasync toEmbeddedCssDeclaration(font: TLFontFace) {\n\t\tconst url = this.assetUrls?.[font.src.url] ?? font.src.url\n\t\tconst dataUrl = await FileHelpers.urlToDataUrl(url)\n\n\t\tconst src = compact([\n\t\t\t`url(\"${dataUrl}\")`,\n\t\t\tfont.src.format ? `format(${font.src.format})` : null,\n\t\t\tfont.src.tech ? `tech(${font.src.tech})` : null,\n\t\t]).join(' ')\n\t\treturn compact([\n\t\t\t`@font-face {`,\n\t\t\t` font-family: \"${font.family}\";`,\n\t\t\tfont.ascentOverride ? ` ascent-override: ${font.ascentOverride};` : null,\n\t\t\tfont.descentOverride ? ` descent-override: ${font.descentOverride};` : null,\n\t\t\tfont.stretch ? ` font-stretch: ${font.stretch};` : null,\n\t\t\tfont.style ? ` font-style: ${font.style};` : null,\n\t\t\tfont.weight ? ` font-weight: ${font.weight};` : null,\n\t\t\tfont.featureSettings ? ` font-feature-settings: ${font.featureSettings};` : null,\n\t\t\tfont.lineGapOverride ? ` line-gap-override: ${font.lineGapOverride};` : null,\n\t\t\tfont.unicodeRange ? ` unicode-range: ${font.unicodeRange};` : null,\n\t\t\t` src: ${src};`,\n\t\t\t`}`,\n\t\t]).join('\\n')\n\t}\n}\n\n// From https://drafts.csswg.org/css-font-loading/#fontface-interface\nconst defaultFontFaceDescriptors = {\n\tstyle: 'normal',\n\tweight: 'normal',\n\tstretch: 'normal',\n\tunicodeRange: 'U+0-10FFFF',\n\tfeatureSettings: 'normal',\n\tascentOverride: 'normal',\n\tdescentOverride: 'normal',\n\tlineGapOverride: 'normal',\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAChD,mBAAwB;AAExB,mBAMO;AA4EA,MAAM,YAAY;AAAA,EACxB,YACkB,QACA,WAChB;AAFgB;AACA;AAEjB,SAAK,sBAAsB,OAAO,MAAM;AAAA,MACvC;AAAA,MACA,CAAC,UAAmB;AACnB,cAAM,YAAY,KAAK,OAAO,aAAa,KAAK;AAChD,eAAO,UAAU,aAAa,KAAK;AAAA,MACpC;AAAA,MACA;AAAA,QACC,iBAAiB;AAAA,QACjB,iBAAiB,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE;AAAA,MAChE;AAAA,IACD;AAEA,SAAK,0BAA0B,OAAO,MAAM;AAAA,MAC3C,CAAC,OAAkB;AAClB,cAAM,wBAAoB,uBAAS,cAAc,MAAM,KAAK,kBAAkB,EAAE,CAAC;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7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/editor/managers/InputsManager/InputsManager.ts"],
4
- "sourcesContent": ["import { atom, computed, unsafe__withoutCapture } from '@tldraw/state'\nimport { AtomSet } from '@tldraw/store'\nimport { TLINSTANCE_ID, TLPOINTER_ID } from '@tldraw/tlschema'\nimport { INTERNAL_POINTER_IDS } from '../../../constants'\nimport { Vec } from '../../../primitives/Vec'\nimport { isAccelKey } from '../../../utils/keyboard'\nimport { Editor } from '../../Editor'\nimport { TLPinchEventInfo, TLPointerEventInfo, TLWheelEventInfo } from '../../types/event-types'\n\n/** @public */\nexport class InputsManager {\n\tconstructor(private readonly editor: Editor) {}\n\n\tprivate _originPagePoint = atom<Vec>('originPagePoint', new Vec())\n\t/**\n\t * The most recent pointer down's position in the current page space.\n\t */\n\tgetOriginPagePoint() {\n\t\treturn this._originPagePoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getOriginPagePoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget originPagePoint() {\n\t\treturn this.getOriginPagePoint()\n\t}\n\n\tprivate _originScreenPoint = atom<Vec>('originScreenPoint', new Vec())\n\t/**\n\t * The most recent pointer down's position in screen space.\n\t */\n\tgetOriginScreenPoint() {\n\t\treturn this._originScreenPoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getOriginScreenPoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget originScreenPoint() {\n\t\treturn this.getOriginScreenPoint()\n\t}\n\n\tprivate _previousPagePoint = atom<Vec>('previousPagePoint', new Vec())\n\t/**\n\t * The previous pointer position in the current page space.\n\t */\n\tgetPreviousPagePoint() {\n\t\treturn this._previousPagePoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getPreviousPagePoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget previousPagePoint() {\n\t\treturn this.getPreviousPagePoint()\n\t}\n\n\tprivate _previousScreenPoint = atom<Vec>('previousScreenPoint', new Vec())\n\t/**\n\t * The previous pointer position in screen space.\n\t */\n\tgetPreviousScreenPoint() {\n\t\treturn this._previousScreenPoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getPreviousScreenPoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget previousScreenPoint() {\n\t\treturn this.getPreviousScreenPoint()\n\t}\n\n\tprivate _currentPagePoint = atom<Vec>('currentPagePoint', new Vec())\n\t/**\n\t * The most recent pointer position in the current page space.\n\t */\n\tgetCurrentPagePoint() {\n\t\treturn this._currentPagePoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getCurrentPagePoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget currentPagePoint() {\n\t\treturn this.getCurrentPagePoint()\n\t}\n\n\tprivate _currentScreenPoint = atom<Vec>('currentScreenPoint', new Vec())\n\t/**\n\t * The most recent pointer position in screen space.\n\t */\n\tgetCurrentScreenPoint() {\n\t\treturn this._currentScreenPoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getCurrentScreenPoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget currentScreenPoint() {\n\t\treturn this.getCurrentScreenPoint()\n\t}\n\n\tprivate _pointerVelocity = atom<Vec>('pointerVelocity', new Vec())\n\t/**\n\t * Velocity of mouse pointer, in pixels per millisecond.\n\t */\n\tgetPointerVelocity() {\n\t\treturn this._pointerVelocity.get()\n\t}\n\t/**\n\t * @deprecated Use `getPointerVelocity()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget pointerVelocity() {\n\t\treturn this.getPointerVelocity()\n\t}\n\n\t/**\n\t * Normally you shouldn't need to set the pointer velocity directly, this is set by the tick manager.\n\t * However, this is currently used in tests to fake pointer velocity.\n\t * @param pointerVelocity - The pointer velocity.\n\t * @internal\n\t */\n\tsetPointerVelocity(pointerVelocity: Vec) {\n\t\tthis._pointerVelocity.set(pointerVelocity)\n\t}\n\n\t/**\n\t * A set containing the currently pressed keys.\n\t */\n\treadonly keys = new AtomSet<string>('keys')\n\n\t/**\n\t * A set containing the currently pressed buttons.\n\t */\n\treadonly buttons = new AtomSet<number>('buttons')\n\n\tprivate _isPen = atom<boolean>('isPen', false)\n\n\t/**\n\t * Whether the input is from a pen.\n\t */\n\tgetIsPen() {\n\t\treturn this._isPen.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsPen()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isPen() {\n\t\treturn this.getIsPen()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isPen(isPen: boolean) {\n\t\tthis.setIsPen(isPen)\n\t}\n\t/**\n\t * @param isPen - Whether the input is from a pen.\n\t */\n\tsetIsPen(isPen: boolean) {\n\t\tthis._isPen.set(isPen)\n\t}\n\n\tprivate _shiftKey = atom<boolean>('shiftKey', false)\n\t/**\n\t * Whether the shift key is currently pressed.\n\t */\n\tgetShiftKey() {\n\t\treturn this._shiftKey.get()\n\t}\n\t/**\n\t * @deprecated Use `getShiftKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget shiftKey() {\n\t\treturn this.getShiftKey()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset shiftKey(shiftKey: boolean) {\n\t\tthis.setShiftKey(shiftKey)\n\t}\n\t/**\n\t * @param shiftKey - Whether the shift key is pressed.\n\t * @internal\n\t */\n\tsetShiftKey(shiftKey: boolean) {\n\t\tthis._shiftKey.set(shiftKey)\n\t}\n\n\tprivate _metaKey = atom<boolean>('metaKey', false)\n\t/**\n\t * Whether the meta key is currently pressed.\n\t */\n\tgetMetaKey() {\n\t\treturn this._metaKey.get()\n\t}\n\t/**\n\t * @deprecated Use `getMetaKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget metaKey() {\n\t\treturn this.getMetaKey()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset metaKey(metaKey: boolean) {\n\t\tthis.setMetaKey(metaKey)\n\t}\n\t/**\n\t * @param metaKey - Whether the meta key is pressed.\n\t * @internal\n\t */\n\tsetMetaKey(metaKey: boolean) {\n\t\tthis._metaKey.set(metaKey)\n\t}\n\n\tprivate _ctrlKey = atom<boolean>('ctrlKey', false)\n\t/**\n\t * Whether the ctrl or command key is currently pressed.\n\t */\n\tgetCtrlKey() {\n\t\treturn this._ctrlKey.get()\n\t}\n\t/**\n\t * @deprecated Use `getCtrlKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget ctrlKey() {\n\t\treturn this.getCtrlKey()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset ctrlKey(ctrlKey: boolean) {\n\t\tthis.setCtrlKey(ctrlKey)\n\t}\n\t/**\n\t * @param ctrlKey - Whether the ctrl key is pressed.\n\t * @internal\n\t */\n\tsetCtrlKey(ctrlKey: boolean) {\n\t\tthis._ctrlKey.set(ctrlKey)\n\t}\n\n\tprivate _altKey = atom<boolean>('altKey', false)\n\t/**\n\t * Whether the alt or option key is currently pressed.\n\t */\n\tgetAltKey() {\n\t\treturn this._altKey.get()\n\t}\n\t/**\n\t * @deprecated Use `getAltKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget altKey() {\n\t\treturn this.getAltKey()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset altKey(altKey: boolean) {\n\t\tthis.setAltKey(altKey)\n\t}\n\t/**\n\t * @param altKey - Whether the alt key is pressed.\n\t * @internal\n\t */\n\tsetAltKey(altKey: boolean) {\n\t\tthis._altKey.set(altKey)\n\t}\n\n\t/**\n\t * Is the accelerator key (cmd on mac, ctrl elsewhere) currently pressed.\n\t */\n\tgetAccelKey() {\n\t\treturn isAccelKey({ metaKey: this.getMetaKey(), ctrlKey: this.getCtrlKey() })\n\t}\n\t/**\n\t * @deprecated Use `getAccelKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget accelKey() {\n\t\treturn this.getAccelKey()\n\t}\n\n\tprivate _isDragging = atom<boolean>('isDragging', false)\n\t/**\n\t * Whether the user is dragging.\n\t */\n\tgetIsDragging() {\n\t\treturn this._isDragging.get()\n\t}\n\t/**\n\t * Soon to be deprecated, use `getIsDragging()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isDragging() {\n\t\treturn this.getIsDragging()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isDragging(isDragging: boolean) {\n\t\tthis.setIsDragging(isDragging)\n\t}\n\t/**\n\t * @param isDragging - Whether the user is dragging.\n\t */\n\tsetIsDragging(isDragging: boolean) {\n\t\tthis._isDragging.set(isDragging)\n\t}\n\n\tprivate _isPointing = atom<boolean>('isPointing', false)\n\t/**\n\t * Whether the user is pointing.\n\t */\n\tgetIsPointing() {\n\t\treturn this._isPointing.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsPointing()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isPointing() {\n\t\treturn this.getIsPointing()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isPointing(isPointing: boolean) {\n\t\tthis.setIsPointing(isPointing)\n\t}\n\t/**\n\t * @param isPointing - Whether the user is pointing.\n\t * @internal\n\t */\n\tsetIsPointing(isPointing: boolean) {\n\t\tthis._isPointing.set(isPointing)\n\t}\n\n\tprivate _isPinching = atom<boolean>('isPinching', false)\n\t/**\n\t * Whether the user is pinching.\n\t */\n\tgetIsPinching() {\n\t\treturn this._isPinching.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsPinching()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isPinching() {\n\t\treturn this.getIsPinching()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isPinching(isPinching: boolean) {\n\t\tthis.setIsPinching(isPinching)\n\t}\n\t/**\n\t * @param isPinching - Whether the user is pinching.\n\t * @internal\n\t */\n\tsetIsPinching(isPinching: boolean) {\n\t\tthis._isPinching.set(isPinching)\n\t}\n\n\tprivate _isEditing = atom<boolean>('isEditing', false)\n\t/**\n\t * Whether the user is editing.\n\t */\n\tgetIsEditing() {\n\t\treturn this._isEditing.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsEditing()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isEditing() {\n\t\treturn this.getIsEditing()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isEditing(isEditing: boolean) {\n\t\tthis.setIsEditing(isEditing)\n\t}\n\t/**\n\t * @param isEditing - Whether the user is editing.\n\t */\n\tsetIsEditing(isEditing: boolean) {\n\t\tthis._isEditing.set(isEditing)\n\t}\n\n\tprivate _isPanning = atom<boolean>('isPanning', false)\n\t/**\n\t * Whether the user is panning.\n\t */\n\tgetIsPanning() {\n\t\treturn this._isPanning.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsPanning()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isPanning() {\n\t\treturn this.getIsPanning()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isPanning(isPanning: boolean) {\n\t\tthis.setIsPanning(isPanning)\n\t}\n\t/**\n\t * @param isPanning - Whether the user is panning.\n\t * @internal\n\t */\n\tsetIsPanning(isPanning: boolean) {\n\t\tthis._isPanning.set(isPanning)\n\t}\n\n\tprivate _isSpacebarPanning = atom<boolean>('isSpacebarPanning', false)\n\t/**\n\t * Whether the user is spacebar panning.\n\t */\n\tgetIsSpacebarPanning() {\n\t\treturn this._isSpacebarPanning.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsSpacebarPanning()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isSpacebarPanning() {\n\t\treturn this.getIsSpacebarPanning()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isSpacebarPanning(isSpacebarPanning: boolean) {\n\t\tthis.setIsSpacebarPanning(isSpacebarPanning)\n\t}\n\t/**\n\t * @param isSpacebarPanning - Whether the user is spacebar panning.\n\t * @internal\n\t */\n\tsetIsSpacebarPanning(isSpacebarPanning: boolean) {\n\t\tthis._isSpacebarPanning.set(isSpacebarPanning)\n\t}\n\n\t@computed private _getHasCollaborators() {\n\t\treturn this.editor.getCollaborators().length > 0 // could we do this more efficiently?\n\t}\n\n\t/**\n\t * The previous point used for velocity calculation (updated each tick, not each pointer event).\n\t * @internal\n\t */\n\tprivate _velocityPrevPoint = new Vec()\n\n\t/**\n\t * Update the pointer velocity based on elapsed time. Called by the tick manager.\n\t * @param elapsed - The time elapsed since the last tick in milliseconds.\n\t * @internal\n\t */\n\tupdatePointerVelocity(elapsed: number) {\n\t\tconst currentScreenPoint = this.getCurrentScreenPoint()\n\t\tconst pointerVelocity = this.getPointerVelocity()\n\n\t\tif (elapsed === 0) return\n\n\t\tconst delta = Vec.Sub(currentScreenPoint, this._velocityPrevPoint)\n\t\tthis._velocityPrevPoint = currentScreenPoint.clone()\n\n\t\tconst length = delta.len()\n\t\tconst direction = length ? delta.div(length) : new Vec(0, 0)\n\n\t\t// consider adjusting this with an easing rather than a linear interpolation\n\t\tconst next = pointerVelocity.clone().lrp(direction.mul(length / elapsed), 0.5)\n\n\t\t// if the velocity is very small, just set it to 0\n\t\tif (Math.abs(next.x) < 0.01) next.x = 0\n\t\tif (Math.abs(next.y) < 0.01) next.y = 0\n\n\t\tif (!pointerVelocity.equals(next)) {\n\t\t\tthis._pointerVelocity.set(next)\n\t\t}\n\t}\n\n\t/**\n\t * Update the input points from a pointer, pinch, or wheel event.\n\t *\n\t * @param info - The event info.\n\t * @internal\n\t */\n\tupdateFromEvent(info: TLPointerEventInfo | TLPinchEventInfo | TLWheelEventInfo): void {\n\t\tconst currentScreenPoint = this._currentScreenPoint.__unsafe__getWithoutCapture()\n\t\tconst currentPagePoint = this._currentPagePoint.__unsafe__getWithoutCapture()\n\t\tconst isPinching = this._isPinching.__unsafe__getWithoutCapture()\n\t\tconst { screenBounds } = this.editor.store.unsafeGetWithoutCapture(TLINSTANCE_ID)!\n\t\tconst { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.editor.getCamera())\n\n\t\tconst sx = info.point.x - screenBounds.x\n\t\tconst sy = info.point.y - screenBounds.y\n\t\tconst sz = info.point.z ?? 0.5\n\n\t\tthis._previousScreenPoint.set(currentScreenPoint)\n\t\tthis._previousPagePoint.set(currentPagePoint)\n\n\t\t// The \"screen bounds\" is relative to the user's actual screen.\n\t\t// The \"screen point\" is relative to the \"screen bounds\";\n\t\t// it will be 0,0 when its actual screen position is equal\n\t\t// to screenBounds.point. This is confusing!\n\t\tthis._currentScreenPoint.set(new Vec(sx, sy))\n\t\tconst nx = sx / cz - cx\n\t\tconst ny = sy / cz - cy\n\t\tif (isFinite(nx) && isFinite(ny)) {\n\t\t\tthis._currentPagePoint.set(new Vec(nx, ny, sz))\n\t\t}\n\n\t\tthis._isPen.set(info.type === 'pointer' && info.isPen)\n\n\t\t// Reset velocity on pointer down, or when a pinch starts or ends\n\t\tif (info.name === 'pointer_down' || isPinching) {\n\t\t\tthis._pointerVelocity.set(new Vec())\n\t\t\tthis._originScreenPoint.set(this._currentScreenPoint.__unsafe__getWithoutCapture())\n\t\t\tthis._originPagePoint.set(this._currentPagePoint.__unsafe__getWithoutCapture())\n\t\t}\n\n\t\tif (this._getHasCollaborators()) {\n\t\t\tthis.editor.run(\n\t\t\t\t() => {\n\t\t\t\t\tconst pagePoint = this._currentPagePoint.__unsafe__getWithoutCapture()\n\t\t\t\t\tthis.editor.store.put([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: TLPOINTER_ID,\n\t\t\t\t\t\t\ttypeName: 'pointer',\n\t\t\t\t\t\t\tx: pagePoint.x,\n\t\t\t\t\t\t\ty: pagePoint.y,\n\t\t\t\t\t\t\tlastActivityTimestamp:\n\t\t\t\t\t\t\t\t// If our pointer moved only because we're following some other user, then don't\n\t\t\t\t\t\t\t\t// update our last activity timestamp; otherwise, update it to the current timestamp.\n\t\t\t\t\t\t\t\tinfo.type === 'pointer' && info.pointerId === INTERNAL_POINTER_IDS.CAMERA_MOVE\n\t\t\t\t\t\t\t\t\t? (this.editor.store.unsafeGetWithoutCapture(TLPOINTER_ID)\n\t\t\t\t\t\t\t\t\t\t\t?.lastActivityTimestamp ?? Date.now())\n\t\t\t\t\t\t\t\t\t: Date.now(),\n\t\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t},\n\t\t\t\t{ history: 'ignore' }\n\t\t\t)\n\t\t}\n\t}\n\n\ttoJson() {\n\t\treturn {\n\t\t\toriginPagePoint: this._originPagePoint.get().toJson(),\n\t\t\toriginScreenPoint: this._originScreenPoint.get().toJson(),\n\t\t\tpreviousPagePoint: this._previousPagePoint.get().toJson(),\n\t\t\tpreviousScreenPoint: this._previousScreenPoint.get().toJson(),\n\t\t\tcurrentPagePoint: this._currentPagePoint.get().toJson(),\n\t\t\tcurrentScreenPoint: this._currentScreenPoint.get().toJson(),\n\t\t\tpointerVelocity: this._pointerVelocity.get().toJson(),\n\t\t\tshiftKey: this._shiftKey.get(),\n\t\t\tmetaKey: this._metaKey.get(),\n\t\t\tctrlKey: this._ctrlKey.get(),\n\t\t\taltKey: this._altKey.get(),\n\t\t\tisPen: this._isPen.get(),\n\t\t\tisDragging: this._isDragging.get(),\n\t\t\tisPointing: this._isPointing.get(),\n\t\t\tisPinching: this._isPinching.get(),\n\t\t\tisEditing: this._isEditing.get(),\n\t\t\tisPanning: this._isPanning.get(),\n\t\t\tisSpacebarPanning: this._isSpacebarPanning.get(),\n\t\t\tkeys: Array.from(this.keys.keys()),\n\t\t\tbuttons: Array.from(this.buttons.keys()),\n\t\t}\n\t}\n}\n"],
4
+ "sourcesContent": ["import { atom, computed, unsafe__withoutCapture } from '@tldraw/state'\nimport { AtomSet } from '@tldraw/store'\nimport { TLINSTANCE_ID, TLPOINTER_ID } from '@tldraw/tlschema'\nimport { INTERNAL_POINTER_IDS } from '../../../constants'\nimport { Vec } from '../../../primitives/Vec'\nimport { isAccelKey } from '../../../utils/keyboard'\nimport type { Editor } from '../../Editor'\nimport { TLPinchEventInfo, TLPointerEventInfo, TLWheelEventInfo } from '../../types/event-types'\n\n/** @public */\nexport class InputsManager {\n\tconstructor(private readonly editor: Editor) {}\n\n\tprivate _originPagePoint = atom<Vec>('originPagePoint', new Vec())\n\t/**\n\t * The most recent pointer down's position in the current page space.\n\t */\n\tgetOriginPagePoint() {\n\t\treturn this._originPagePoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getOriginPagePoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget originPagePoint() {\n\t\treturn this.getOriginPagePoint()\n\t}\n\n\tprivate _originScreenPoint = atom<Vec>('originScreenPoint', new Vec())\n\t/**\n\t * The most recent pointer down's position in screen space.\n\t */\n\tgetOriginScreenPoint() {\n\t\treturn this._originScreenPoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getOriginScreenPoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget originScreenPoint() {\n\t\treturn this.getOriginScreenPoint()\n\t}\n\n\tprivate _previousPagePoint = atom<Vec>('previousPagePoint', new Vec())\n\t/**\n\t * The previous pointer position in the current page space.\n\t */\n\tgetPreviousPagePoint() {\n\t\treturn this._previousPagePoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getPreviousPagePoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget previousPagePoint() {\n\t\treturn this.getPreviousPagePoint()\n\t}\n\n\tprivate _previousScreenPoint = atom<Vec>('previousScreenPoint', new Vec())\n\t/**\n\t * The previous pointer position in screen space.\n\t */\n\tgetPreviousScreenPoint() {\n\t\treturn this._previousScreenPoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getPreviousScreenPoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget previousScreenPoint() {\n\t\treturn this.getPreviousScreenPoint()\n\t}\n\n\tprivate _currentPagePoint = atom<Vec>('currentPagePoint', new Vec())\n\t/**\n\t * The most recent pointer position in the current page space.\n\t */\n\tgetCurrentPagePoint() {\n\t\treturn this._currentPagePoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getCurrentPagePoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget currentPagePoint() {\n\t\treturn this.getCurrentPagePoint()\n\t}\n\n\tprivate _currentScreenPoint = atom<Vec>('currentScreenPoint', new Vec())\n\t/**\n\t * The most recent pointer position in screen space.\n\t */\n\tgetCurrentScreenPoint() {\n\t\treturn this._currentScreenPoint.get()\n\t}\n\t/**\n\t * @deprecated Use `getCurrentScreenPoint()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget currentScreenPoint() {\n\t\treturn this.getCurrentScreenPoint()\n\t}\n\n\tprivate _pointerVelocity = atom<Vec>('pointerVelocity', new Vec())\n\t/**\n\t * Velocity of mouse pointer, in pixels per millisecond.\n\t */\n\tgetPointerVelocity() {\n\t\treturn this._pointerVelocity.get()\n\t}\n\t/**\n\t * @deprecated Use `getPointerVelocity()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget pointerVelocity() {\n\t\treturn this.getPointerVelocity()\n\t}\n\n\t/**\n\t * Normally you shouldn't need to set the pointer velocity directly, this is set by the tick manager.\n\t * However, this is currently used in tests to fake pointer velocity.\n\t * @param pointerVelocity - The pointer velocity.\n\t * @internal\n\t */\n\tsetPointerVelocity(pointerVelocity: Vec) {\n\t\tthis._pointerVelocity.set(pointerVelocity)\n\t}\n\n\t/**\n\t * A set containing the currently pressed keys.\n\t */\n\treadonly keys = new AtomSet<string>('keys')\n\n\t/**\n\t * A set containing the currently pressed buttons.\n\t */\n\treadonly buttons = new AtomSet<number>('buttons')\n\n\tprivate _isPen = atom<boolean>('isPen', false)\n\n\t/**\n\t * Whether the input is from a pen.\n\t */\n\tgetIsPen() {\n\t\treturn this._isPen.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsPen()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isPen() {\n\t\treturn this.getIsPen()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isPen(isPen: boolean) {\n\t\tthis.setIsPen(isPen)\n\t}\n\t/**\n\t * @param isPen - Whether the input is from a pen.\n\t */\n\tsetIsPen(isPen: boolean) {\n\t\tthis._isPen.set(isPen)\n\t}\n\n\tprivate _shiftKey = atom<boolean>('shiftKey', false)\n\t/**\n\t * Whether the shift key is currently pressed.\n\t */\n\tgetShiftKey() {\n\t\treturn this._shiftKey.get()\n\t}\n\t/**\n\t * @deprecated Use `getShiftKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget shiftKey() {\n\t\treturn this.getShiftKey()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset shiftKey(shiftKey: boolean) {\n\t\tthis.setShiftKey(shiftKey)\n\t}\n\t/**\n\t * @param shiftKey - Whether the shift key is pressed.\n\t * @internal\n\t */\n\tsetShiftKey(shiftKey: boolean) {\n\t\tthis._shiftKey.set(shiftKey)\n\t}\n\n\tprivate _metaKey = atom<boolean>('metaKey', false)\n\t/**\n\t * Whether the meta key is currently pressed.\n\t */\n\tgetMetaKey() {\n\t\treturn this._metaKey.get()\n\t}\n\t/**\n\t * @deprecated Use `getMetaKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget metaKey() {\n\t\treturn this.getMetaKey()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset metaKey(metaKey: boolean) {\n\t\tthis.setMetaKey(metaKey)\n\t}\n\t/**\n\t * @param metaKey - Whether the meta key is pressed.\n\t * @internal\n\t */\n\tsetMetaKey(metaKey: boolean) {\n\t\tthis._metaKey.set(metaKey)\n\t}\n\n\tprivate _ctrlKey = atom<boolean>('ctrlKey', false)\n\t/**\n\t * Whether the ctrl or command key is currently pressed.\n\t */\n\tgetCtrlKey() {\n\t\treturn this._ctrlKey.get()\n\t}\n\t/**\n\t * @deprecated Use `getCtrlKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget ctrlKey() {\n\t\treturn this.getCtrlKey()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset ctrlKey(ctrlKey: boolean) {\n\t\tthis.setCtrlKey(ctrlKey)\n\t}\n\t/**\n\t * @param ctrlKey - Whether the ctrl key is pressed.\n\t * @internal\n\t */\n\tsetCtrlKey(ctrlKey: boolean) {\n\t\tthis._ctrlKey.set(ctrlKey)\n\t}\n\n\tprivate _altKey = atom<boolean>('altKey', false)\n\t/**\n\t * Whether the alt or option key is currently pressed.\n\t */\n\tgetAltKey() {\n\t\treturn this._altKey.get()\n\t}\n\t/**\n\t * @deprecated Use `getAltKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget altKey() {\n\t\treturn this.getAltKey()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset altKey(altKey: boolean) {\n\t\tthis.setAltKey(altKey)\n\t}\n\t/**\n\t * @param altKey - Whether the alt key is pressed.\n\t * @internal\n\t */\n\tsetAltKey(altKey: boolean) {\n\t\tthis._altKey.set(altKey)\n\t}\n\n\t/**\n\t * Is the accelerator key (cmd on mac, ctrl elsewhere) currently pressed.\n\t */\n\tgetAccelKey() {\n\t\treturn isAccelKey({ metaKey: this.getMetaKey(), ctrlKey: this.getCtrlKey() })\n\t}\n\t/**\n\t * @deprecated Use `getAccelKey()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget accelKey() {\n\t\treturn this.getAccelKey()\n\t}\n\n\tprivate _isDragging = atom<boolean>('isDragging', false)\n\t/**\n\t * Whether the user is dragging.\n\t */\n\tgetIsDragging() {\n\t\treturn this._isDragging.get()\n\t}\n\t/**\n\t * Soon to be deprecated, use `getIsDragging()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isDragging() {\n\t\treturn this.getIsDragging()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isDragging(isDragging: boolean) {\n\t\tthis.setIsDragging(isDragging)\n\t}\n\t/**\n\t * @param isDragging - Whether the user is dragging.\n\t */\n\tsetIsDragging(isDragging: boolean) {\n\t\tthis._isDragging.set(isDragging)\n\t}\n\n\tprivate _isPointing = atom<boolean>('isPointing', false)\n\t/**\n\t * Whether the user is pointing.\n\t */\n\tgetIsPointing() {\n\t\treturn this._isPointing.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsPointing()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isPointing() {\n\t\treturn this.getIsPointing()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isPointing(isPointing: boolean) {\n\t\tthis.setIsPointing(isPointing)\n\t}\n\t/**\n\t * @param isPointing - Whether the user is pointing.\n\t * @internal\n\t */\n\tsetIsPointing(isPointing: boolean) {\n\t\tthis._isPointing.set(isPointing)\n\t}\n\n\tprivate _isPinching = atom<boolean>('isPinching', false)\n\t/**\n\t * Whether the user is pinching.\n\t */\n\tgetIsPinching() {\n\t\treturn this._isPinching.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsPinching()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isPinching() {\n\t\treturn this.getIsPinching()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isPinching(isPinching: boolean) {\n\t\tthis.setIsPinching(isPinching)\n\t}\n\t/**\n\t * @param isPinching - Whether the user is pinching.\n\t * @internal\n\t */\n\tsetIsPinching(isPinching: boolean) {\n\t\tthis._isPinching.set(isPinching)\n\t}\n\n\tprivate _isEditing = atom<boolean>('isEditing', false)\n\t/**\n\t * Whether the user is editing.\n\t */\n\tgetIsEditing() {\n\t\treturn this._isEditing.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsEditing()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isEditing() {\n\t\treturn this.getIsEditing()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isEditing(isEditing: boolean) {\n\t\tthis.setIsEditing(isEditing)\n\t}\n\t/**\n\t * @param isEditing - Whether the user is editing.\n\t */\n\tsetIsEditing(isEditing: boolean) {\n\t\tthis._isEditing.set(isEditing)\n\t}\n\n\tprivate _isPanning = atom<boolean>('isPanning', false)\n\t/**\n\t * Whether the user is panning.\n\t */\n\tgetIsPanning() {\n\t\treturn this._isPanning.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsPanning()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isPanning() {\n\t\treturn this.getIsPanning()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isPanning(isPanning: boolean) {\n\t\tthis.setIsPanning(isPanning)\n\t}\n\t/**\n\t * @param isPanning - Whether the user is panning.\n\t * @internal\n\t */\n\tsetIsPanning(isPanning: boolean) {\n\t\tthis._isPanning.set(isPanning)\n\t}\n\n\tprivate _isSpacebarPanning = atom<boolean>('isSpacebarPanning', false)\n\t/**\n\t * Whether the user is spacebar panning.\n\t */\n\tgetIsSpacebarPanning() {\n\t\treturn this._isSpacebarPanning.get()\n\t}\n\t/**\n\t * @deprecated Use `getIsSpacebarPanning()` instead.\n\t */\n\t// eslint-disable-next-line no-restricted-syntax\n\tget isSpacebarPanning() {\n\t\treturn this.getIsSpacebarPanning()\n\t}\n\t// eslint-disable-next-line no-restricted-syntax\n\tset isSpacebarPanning(isSpacebarPanning: boolean) {\n\t\tthis.setIsSpacebarPanning(isSpacebarPanning)\n\t}\n\t/**\n\t * @param isSpacebarPanning - Whether the user is spacebar panning.\n\t * @internal\n\t */\n\tsetIsSpacebarPanning(isSpacebarPanning: boolean) {\n\t\tthis._isSpacebarPanning.set(isSpacebarPanning)\n\t}\n\n\t@computed private _getHasCollaborators() {\n\t\treturn this.editor.getCollaborators().length > 0 // could we do this more efficiently?\n\t}\n\n\t/**\n\t * The previous point used for velocity calculation (updated each tick, not each pointer event).\n\t * @internal\n\t */\n\tprivate _velocityPrevPoint = new Vec()\n\n\t/**\n\t * Update the pointer velocity based on elapsed time. Called by the tick manager.\n\t * @param elapsed - The time elapsed since the last tick in milliseconds.\n\t * @internal\n\t */\n\tupdatePointerVelocity(elapsed: number) {\n\t\tconst currentScreenPoint = this.getCurrentScreenPoint()\n\t\tconst pointerVelocity = this.getPointerVelocity()\n\n\t\tif (elapsed === 0) return\n\n\t\tconst delta = Vec.Sub(currentScreenPoint, this._velocityPrevPoint)\n\t\tthis._velocityPrevPoint = currentScreenPoint.clone()\n\n\t\tconst length = delta.len()\n\t\tconst direction = length ? delta.div(length) : new Vec(0, 0)\n\n\t\t// consider adjusting this with an easing rather than a linear interpolation\n\t\tconst next = pointerVelocity.clone().lrp(direction.mul(length / elapsed), 0.5)\n\n\t\t// if the velocity is very small, just set it to 0\n\t\tif (Math.abs(next.x) < 0.01) next.x = 0\n\t\tif (Math.abs(next.y) < 0.01) next.y = 0\n\n\t\tif (!pointerVelocity.equals(next)) {\n\t\t\tthis._pointerVelocity.set(next)\n\t\t}\n\t}\n\n\t/**\n\t * Update the input points from a pointer, pinch, or wheel event.\n\t *\n\t * @param info - The event info.\n\t * @internal\n\t */\n\tupdateFromEvent(info: TLPointerEventInfo | TLPinchEventInfo | TLWheelEventInfo): void {\n\t\tconst currentScreenPoint = this._currentScreenPoint.__unsafe__getWithoutCapture()\n\t\tconst currentPagePoint = this._currentPagePoint.__unsafe__getWithoutCapture()\n\t\tconst isPinching = this._isPinching.__unsafe__getWithoutCapture()\n\t\tconst { screenBounds } = this.editor.store.unsafeGetWithoutCapture(TLINSTANCE_ID)!\n\t\tconst { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.editor.getCamera())\n\n\t\tconst sx = info.point.x - screenBounds.x\n\t\tconst sy = info.point.y - screenBounds.y\n\t\tconst sz = info.point.z ?? 0.5\n\n\t\tthis._previousScreenPoint.set(currentScreenPoint)\n\t\tthis._previousPagePoint.set(currentPagePoint)\n\n\t\t// The \"screen bounds\" is relative to the user's actual screen.\n\t\t// The \"screen point\" is relative to the \"screen bounds\";\n\t\t// it will be 0,0 when its actual screen position is equal\n\t\t// to screenBounds.point. This is confusing!\n\t\tthis._currentScreenPoint.set(new Vec(sx, sy))\n\t\tconst nx = sx / cz - cx\n\t\tconst ny = sy / cz - cy\n\t\tif (isFinite(nx) && isFinite(ny)) {\n\t\t\tthis._currentPagePoint.set(new Vec(nx, ny, sz))\n\t\t}\n\n\t\tthis._isPen.set(info.type === 'pointer' && info.isPen)\n\n\t\t// Reset velocity on pointer down, or when a pinch starts or ends\n\t\tif (info.name === 'pointer_down' || isPinching) {\n\t\t\tthis._pointerVelocity.set(new Vec())\n\t\t\tthis._originScreenPoint.set(this._currentScreenPoint.__unsafe__getWithoutCapture())\n\t\t\tthis._originPagePoint.set(this._currentPagePoint.__unsafe__getWithoutCapture())\n\t\t}\n\n\t\tif (this._getHasCollaborators()) {\n\t\t\tthis.editor.run(\n\t\t\t\t() => {\n\t\t\t\t\tconst pagePoint = this._currentPagePoint.__unsafe__getWithoutCapture()\n\t\t\t\t\tthis.editor.store.put([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: TLPOINTER_ID,\n\t\t\t\t\t\t\ttypeName: 'pointer',\n\t\t\t\t\t\t\tx: pagePoint.x,\n\t\t\t\t\t\t\ty: pagePoint.y,\n\t\t\t\t\t\t\tlastActivityTimestamp:\n\t\t\t\t\t\t\t\t// If our pointer moved only because we're following some other user, then don't\n\t\t\t\t\t\t\t\t// update our last activity timestamp; otherwise, update it to the current timestamp.\n\t\t\t\t\t\t\t\tinfo.type === 'pointer' && info.pointerId === INTERNAL_POINTER_IDS.CAMERA_MOVE\n\t\t\t\t\t\t\t\t\t? (this.editor.store.unsafeGetWithoutCapture(TLPOINTER_ID)\n\t\t\t\t\t\t\t\t\t\t\t?.lastActivityTimestamp ?? Date.now())\n\t\t\t\t\t\t\t\t\t: Date.now(),\n\t\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t},\n\t\t\t\t{ history: 'ignore' }\n\t\t\t)\n\t\t}\n\t}\n\n\ttoJson() {\n\t\treturn {\n\t\t\toriginPagePoint: this._originPagePoint.get().toJson(),\n\t\t\toriginScreenPoint: this._originScreenPoint.get().toJson(),\n\t\t\tpreviousPagePoint: this._previousPagePoint.get().toJson(),\n\t\t\tpreviousScreenPoint: this._previousScreenPoint.get().toJson(),\n\t\t\tcurrentPagePoint: this._currentPagePoint.get().toJson(),\n\t\t\tcurrentScreenPoint: this._currentScreenPoint.get().toJson(),\n\t\t\tpointerVelocity: this._pointerVelocity.get().toJson(),\n\t\t\tshiftKey: this._shiftKey.get(),\n\t\t\tmetaKey: this._metaKey.get(),\n\t\t\tctrlKey: this._ctrlKey.get(),\n\t\t\taltKey: this._altKey.get(),\n\t\t\tisPen: this._isPen.get(),\n\t\t\tisDragging: this._isDragging.get(),\n\t\t\tisPointing: this._isPointing.get(),\n\t\t\tisPinching: this._isPinching.get(),\n\t\t\tisEditing: this._isEditing.get(),\n\t\t\tisPanning: this._isPanning.get(),\n\t\t\tisSpacebarPanning: this._isSpacebarPanning.get(),\n\t\t\tkeys: Array.from(this.keys.keys()),\n\t\t\tbuttons: Array.from(this.buttons.keys()),\n\t\t}\n\t}\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuD;AACvD,mBAAwB;AACxB,sBAA4C;AAC5C,uBAAqC;AACrC,iBAAoB;AACpB,sBAA2B;AAL3B;AAobC,6BAAC;AA1aK,MAAM,cAAc;AAAA,EAC1B,YAA6B,QAAgB;AAAhB;AADvB;AAGN,wBAAQ,wBAAmB,mBAAU,mBAAmB,IAAI,eAAI,CAAC;AAejE,wBAAQ,0BAAqB,mBAAU,qBAAqB,IAAI,eAAI,CAAC;AAerE,wBAAQ,0BAAqB,mBAAU,qBAAqB,IAAI,eAAI,CAAC;AAerE,wBAA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,KAAK,kBAAkB,IAAI,EAAE,OAAO;AAAA,MACtD,oBAAoB,KAAK,oBAAoB,IAAI,EAAE,OAAO;AAAA,MAC1D,iBAAiB,KAAK,iBAAiB,IAAI,EAAE,OAAO;AAAA,MACpD,UAAU,KAAK,UAAU,IAAI;AAAA,MAC7B,SAAS,KAAK,SAAS,IAAI;AAAA,MAC3B,SAAS,KAAK,SAAS,IAAI;AAAA,MAC3B,QAAQ,KAAK,QAAQ,IAAI;AAAA,MACzB,OAAO,KAAK,OAAO,IAAI;AAAA,MACvB,YAAY,KAAK,YAAY,IAAI;AAAA,MACjC,YAAY,KAAK,YAAY,IAAI;AAAA,MACjC,YAAY,KAAK,YAAY,IAAI;AAAA,MACjC,WAAW,KAAK,WAAW,IAAI;AAAA,MAC/B,WAAW,KAAK,WAAW,IAAI;AAAA,MAC/B,mBAAmB,KAAK,mBAAmB,IAAI;AAAA,MAC/C,MAAM,MAAM,KAAK,KAAK,KAAK,KAAK,CAAC;AAAA,MACjC,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,CAAC;AAAA,IACxC;AAAA,EACD;AACD;AA3iBO;AA0aI,4BAAQ,wBAAlB,2BA1aY;AAAN,2BAAM;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/editor/managers/ScribbleManager/ScribbleManager.ts"],
4
- "sourcesContent": ["import { TLScribble, VecModel } from '@tldraw/tlschema'\nimport { uniqueId } from '@tldraw/utils'\nimport { Vec } from '../../../primitives/Vec'\nimport { Editor } from '../../Editor'\n\n/** @public */\nexport interface ScribbleItem {\n\tid: string\n\tscribble: TLScribble\n\ttimeoutMs: number\n\tdelayRemaining: number\n\tprev: null | VecModel\n\tnext: null | VecModel\n}\n\n/** @public */\nexport interface ScribbleSessionOptions {\n\t/** Session id. Auto-generated if not provided. */\n\tid?: string\n\t/**\n\t * Whether scribbles self-consume (shrink from start) while drawing.\n\t * - true: scribbles eat their own tail as you draw (default, used for eraser/select)\n\t * - false: scribbles persist until session stops (used for laser)\n\t */\n\tselfConsume?: boolean\n\t/**\n\t * How long to wait after last activity before auto-stopping the session.\n\t * Only applies when selfConsume is false.\n\t */\n\tidleTimeoutMs?: number\n\t/**\n\t * How scribbles fade when stopping.\n\t * - 'individual': each scribble fades on its own (default)\n\t * - 'grouped': all scribbles fade together as one sequence\n\t */\n\tfadeMode?: 'individual' | 'grouped'\n\t/**\n\t * Easing for grouped fade.\n\t */\n\tfadeEasing?: 'linear' | 'ease-in'\n\t/**\n\t * Duration of the fade in milliseconds.\n\t */\n\tfadeDurationMs?: number\n}\n\n// Internal session state (not exported)\ninterface Session {\n\tid: string\n\titems: ScribbleItem[]\n\tstate: 'active' | 'stopping' | 'complete'\n\toptions: Required<Omit<ScribbleSessionOptions, 'id'>>\n\tidleTimeoutHandle?: number\n\tfadeElapsed: number\n\ttotalPointsAtFadeStart: number\n}\n\n/** @public */\nexport class ScribbleManager {\n\tprivate sessions = new Map<string, Session>()\n\n\tconstructor(private editor: Editor) {}\n\n\t// ==================== SESSION API ====================\n\n\t/**\n\t * Start a new session for grouping scribbles.\n\t * Returns a session ID that can be used with other session methods.\n\t *\n\t * @param options - Session configuration\n\t * @returns Session ID\n\t * @public\n\t */\n\tstartSession(options: ScribbleSessionOptions = {}): string {\n\t\tconst id = options.id ?? uniqueId()\n\t\tconst session: Session = {\n\t\t\tid,\n\t\t\titems: [],\n\t\t\tstate: 'active',\n\t\t\toptions: {\n\t\t\t\tselfConsume: options.selfConsume ?? true,\n\t\t\t\tidleTimeoutMs: options.idleTimeoutMs ?? 0,\n\t\t\t\tfadeMode: options.fadeMode ?? 'individual',\n\t\t\t\tfadeEasing: options.fadeEasing ?? (options.fadeMode === 'grouped' ? 'ease-in' : 'linear'),\n\t\t\t\tfadeDurationMs: options.fadeDurationMs ?? this.editor.options.laserFadeoutMs,\n\t\t\t},\n\t\t\tfadeElapsed: 0,\n\t\t\ttotalPointsAtFadeStart: 0,\n\t\t}\n\n\t\tthis.sessions.set(id, session)\n\n\t\t// Set up idle timeout if configured\n\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\tthis.resetIdleTimeout(session)\n\t\t}\n\n\t\treturn id\n\t}\n\n\t/**\n\t * Add a scribble to a session.\n\t *\n\t * @param sessionId - The session ID\n\t * @param scribble - Partial scribble properties\n\t * @param scribbleId - Optional scribble ID\n\t * @public\n\t */\n\taddScribbleToSession(\n\t\tsessionId: string,\n\t\tscribble: Partial<TLScribble>,\n\t\tscribbleId = uniqueId()\n\t): ScribbleItem {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session) throw Error(`Session ${sessionId} not found`)\n\n\t\tconst item: ScribbleItem = {\n\t\t\tid: scribbleId,\n\t\t\tscribble: {\n\t\t\t\tid: scribbleId,\n\t\t\t\tsize: 20,\n\t\t\t\tcolor: 'accent',\n\t\t\t\topacity: 0.8,\n\t\t\t\tdelay: 0,\n\t\t\t\tpoints: [],\n\t\t\t\tshrink: 0.1,\n\t\t\t\ttaper: true,\n\t\t\t\t...scribble,\n\t\t\t\tstate: 'starting',\n\t\t\t},\n\t\t\ttimeoutMs: 0,\n\t\t\tdelayRemaining: scribble.delay ?? 0,\n\t\t\tprev: null,\n\t\t\tnext: null,\n\t\t}\n\n\t\tsession.items.push(item)\n\n\t\t// Reset idle timeout on activity\n\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\tthis.resetIdleTimeout(session)\n\t\t}\n\n\t\treturn item\n\t}\n\n\t/**\n\t * Add a point to a scribble in a session.\n\t *\n\t * @param sessionId - The session ID\n\t * @param scribbleId - The scribble ID\n\t * @param x - X coordinate\n\t * @param y - Y coordinate\n\t * @param z - Z coordinate (pressure)\n\t * @public\n\t */\n\taddPointToSession(\n\t\tsessionId: string,\n\t\tscribbleId: string,\n\t\tx: number,\n\t\ty: number,\n\t\tz = 0.5\n\t): ScribbleItem {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session) throw Error(`Session ${sessionId} not found`)\n\n\t\tconst item = session.items.find((i) => i.id === scribbleId)\n\t\tif (!item) throw Error(`Scribble ${scribbleId} not found in session ${sessionId}`)\n\n\t\tconst point = { x, y, z }\n\t\tif (!item.prev || Vec.Dist(item.prev, point) >= 1) {\n\t\t\titem.next = point\n\t\t}\n\n\t\t// Reset idle timeout on activity\n\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\tthis.resetIdleTimeout(session)\n\t\t}\n\n\t\treturn item\n\t}\n\n\t/**\n\t * Extend a session, resetting its idle timeout.\n\t *\n\t * @param sessionId - The session ID\n\t * @public\n\t */\n\textendSession(sessionId: string): void {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session) return\n\n\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\tthis.resetIdleTimeout(session)\n\t\t}\n\t}\n\n\t/**\n\t * Stop a session, triggering fade-out.\n\t *\n\t * @param sessionId - The session ID\n\t * @public\n\t */\n\tstopSession(sessionId: string): void {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session || session.state !== 'active') return\n\n\t\tthis.clearIdleTimeout(session)\n\t\tsession.state = 'stopping'\n\n\t\tif (session.options.fadeMode === 'grouped') {\n\t\t\tsession.totalPointsAtFadeStart = session.items.reduce(\n\t\t\t\t(sum, item) => sum + item.scribble.points.length,\n\t\t\t\t0\n\t\t\t)\n\t\t\tsession.fadeElapsed = 0\n\t\t\tfor (const item of session.items) {\n\t\t\t\titem.scribble.state = 'stopping'\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const item of session.items) {\n\t\t\t\titem.delayRemaining = Math.min(item.delayRemaining, 200)\n\t\t\t\titem.scribble.state = 'stopping'\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clear all scribbles in a session immediately.\n\t *\n\t * @param sessionId - The session ID\n\t * @public\n\t */\n\tclearSession(sessionId: string): void {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session) return\n\n\t\tthis.clearIdleTimeout(session)\n\t\tfor (const item of session.items) {\n\t\t\titem.scribble.points.length = 0\n\t\t}\n\t\tsession.state = 'complete'\n\t}\n\n\t/**\n\t * Check if a session is active.\n\t *\n\t * @param sessionId - The session ID\n\t * @public\n\t */\n\tisSessionActive(sessionId: string): boolean {\n\t\tconst session = this.sessions.get(sessionId)\n\t\treturn session?.state === 'active'\n\t}\n\n\t// ==================== SIMPLE API (for eraser, select, etc.) ====================\n\n\t/**\n\t * Add a scribble using the default self-consuming behavior.\n\t * Creates an implicit session for the scribble.\n\t *\n\t * @param scribble - Partial scribble properties\n\t * @param id - Optional scribble id\n\t * @returns The created scribble item\n\t * @public\n\t */\n\taddScribble(scribble: Partial<TLScribble>, id = uniqueId()): ScribbleItem {\n\t\tconst sessionId = this.startSession()\n\t\treturn this.addScribbleToSession(sessionId, scribble, id)\n\t}\n\n\t/**\n\t * Add a point to a scribble. Searches all sessions.\n\t *\n\t * @param id - The scribble id\n\t * @param x - X coordinate\n\t * @param y - Y coordinate\n\t * @param z - Z coordinate (pressure)\n\t * @public\n\t */\n\taddPoint(id: string, x: number, y: number, z = 0.5): ScribbleItem {\n\t\tfor (const session of this.sessions.values()) {\n\t\t\tconst item = session.items.find((i) => i.id === id)\n\t\t\tif (item) {\n\t\t\t\tconst point = { x, y, z }\n\t\t\t\tif (!item.prev || Vec.Dist(item.prev, point) >= 1) {\n\t\t\t\t\titem.next = point\n\t\t\t\t}\n\t\t\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\t\t\tthis.resetIdleTimeout(session)\n\t\t\t\t}\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t\tthrow Error(`Scribble with id ${id} not found`)\n\t}\n\n\t/**\n\t * Mark a scribble as complete (done being drawn but not yet fading).\n\t * Searches all sessions.\n\t *\n\t * @param id - The scribble id\n\t * @public\n\t */\n\tcomplete(id: string): ScribbleItem {\n\t\tfor (const session of this.sessions.values()) {\n\t\t\tconst item = session.items.find((i) => i.id === id)\n\t\t\tif (item) {\n\t\t\t\tif (item.scribble.state === 'starting' || item.scribble.state === 'active') {\n\t\t\t\t\titem.scribble.state = 'complete'\n\t\t\t\t}\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t\tthrow Error(`Scribble with id ${id} not found`)\n\t}\n\n\t/**\n\t * Stop a scribble. Searches all sessions.\n\t *\n\t * @param id - The scribble id\n\t * @public\n\t */\n\tstop(id: string): ScribbleItem {\n\t\tfor (const session of this.sessions.values()) {\n\t\t\tconst item = session.items.find((i) => i.id === id)\n\t\t\tif (item) {\n\t\t\t\titem.delayRemaining = Math.min(item.delayRemaining, 200)\n\t\t\t\titem.scribble.state = 'stopping'\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t\tthrow Error(`Scribble with id ${id} not found`)\n\t}\n\n\t/**\n\t * Stop and remove all sessions.\n\t *\n\t * @public\n\t */\n\treset(): void {\n\t\tfor (const session of this.sessions.values()) {\n\t\t\tthis.clearIdleTimeout(session)\n\t\t}\n\t\tthis.sessions.clear()\n\t\tthis.editor.updateInstanceState({ scribbles: [] })\n\t}\n\n\t/**\n\t * Update on each animation frame.\n\t *\n\t * @param elapsed - The number of milliseconds since the last tick.\n\t * @public\n\t */\n\ttick(elapsed: number): void {\n\t\tconst currentScribbles = this.editor.getInstanceState().scribbles\n\t\tif (this.sessions.size === 0 && currentScribbles.length === 0) return\n\n\t\tthis.editor.run(() => {\n\t\t\t// Tick all sessions\n\t\t\tfor (const session of this.sessions.values()) {\n\t\t\t\tthis.tickSession(session, elapsed)\n\t\t\t}\n\n\t\t\t// Remove completed sessions\n\t\t\tfor (const [id, session] of this.sessions) {\n\t\t\t\tif (session.state === 'complete') {\n\t\t\t\t\tthis.clearIdleTimeout(session)\n\t\t\t\t\tthis.sessions.delete(id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Collect scribbles from all sessions\n\t\t\tconst scribbles: TLScribble[] = []\n\t\t\tfor (const session of this.sessions.values()) {\n\t\t\t\tfor (const item of session.items) {\n\t\t\t\t\tif (item.scribble.points.length > 0) {\n\t\t\t\t\t\tscribbles.push({\n\t\t\t\t\t\t\t...item.scribble,\n\t\t\t\t\t\t\tpoints: [...item.scribble.points],\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.editor.updateInstanceState({ scribbles })\n\t\t})\n\t}\n\n\t// ==================== PRIVATE HELPERS ====================\n\n\tprivate resetIdleTimeout(session: Session): void {\n\t\tthis.clearIdleTimeout(session)\n\t\tsession.idleTimeoutHandle = this.editor.timers.setTimeout(() => {\n\t\t\tthis.stopSession(session.id)\n\t\t}, session.options.idleTimeoutMs)\n\t}\n\n\tprivate clearIdleTimeout(session: Session): void {\n\t\tif (session.idleTimeoutHandle !== undefined) {\n\t\t\tclearTimeout(session.idleTimeoutHandle)\n\t\t\tsession.idleTimeoutHandle = undefined\n\t\t}\n\t}\n\n\tprivate tickSession(session: Session, elapsed: number): void {\n\t\tif (session.state === 'complete') return\n\n\t\tif (session.state === 'stopping' && session.options.fadeMode === 'grouped') {\n\t\t\tthis.tickGroupedFade(session, elapsed)\n\t\t} else {\n\t\t\tthis.tickSessionItems(session, elapsed)\n\t\t}\n\n\t\t// Check if session is complete\n\t\tconst hasContent = session.items.some((item) => item.scribble.points.length > 0)\n\t\tif (!hasContent && (session.state === 'stopping' || session.items.length === 0)) {\n\t\t\tsession.state = 'complete'\n\t\t}\n\t}\n\n\tprivate tickSessionItems(session: Session, elapsed: number): void {\n\t\tfor (const item of session.items) {\n\t\t\tconst shouldSelfConsume =\n\t\t\t\tsession.options.selfConsume ||\n\t\t\t\tsession.state === 'stopping' ||\n\t\t\t\titem.scribble.state === 'stopping'\n\n\t\t\tif (shouldSelfConsume) {\n\t\t\t\tthis.tickSelfConsumingItem(item, elapsed)\n\t\t\t} else {\n\t\t\t\tthis.tickPersistentItem(item)\n\t\t\t}\n\t\t}\n\n\t\t// Remove completed items in individual fade mode\n\t\tif (session.options.fadeMode === 'individual') {\n\t\t\tfor (let i = session.items.length - 1; i >= 0; i--) {\n\t\t\t\tif (session.items[i].scribble.points.length === 0) {\n\t\t\t\t\tsession.items.splice(i, 1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate tickPersistentItem(item: ScribbleItem): void {\n\t\tconst { scribble } = item\n\n\t\tif (scribble.state === 'starting') {\n\t\t\tconst { next, prev } = item\n\t\t\tif (next && next !== prev) {\n\t\t\t\titem.prev = next\n\t\t\t\tscribble.points.push(next)\n\t\t\t}\n\t\t\tif (scribble.points.length > 8) {\n\t\t\t\tscribble.state = 'active'\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (scribble.state === 'active') {\n\t\t\tconst { next, prev } = item\n\t\t\tif (next && next !== prev) {\n\t\t\t\titem.prev = next\n\t\t\t\tscribble.points.push(next)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate tickSelfConsumingItem(item: ScribbleItem, elapsed: number): void {\n\t\tconst { scribble } = item\n\n\t\tif (scribble.state === 'starting') {\n\t\t\tconst { next, prev } = item\n\t\t\tif (next && next !== prev) {\n\t\t\t\titem.prev = next\n\t\t\t\tscribble.points.push(next)\n\t\t\t}\n\t\t\tif (scribble.points.length > 8) {\n\t\t\t\tscribble.state = 'active'\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (item.delayRemaining > 0) {\n\t\t\titem.delayRemaining = Math.max(0, item.delayRemaining - elapsed)\n\t\t}\n\n\t\titem.timeoutMs += elapsed\n\t\tif (item.timeoutMs >= 16) {\n\t\t\titem.timeoutMs = 0\n\t\t}\n\n\t\tconst { delayRemaining, timeoutMs, prev, next } = item\n\n\t\tswitch (scribble.state) {\n\t\t\tcase 'active': {\n\t\t\t\tif (next && next !== prev) {\n\t\t\t\t\titem.prev = next\n\t\t\t\t\tscribble.points.push(next)\n\t\t\t\t\tif (delayRemaining === 0 && scribble.points.length > 8) {\n\t\t\t\t\t\tscribble.points.shift()\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (timeoutMs === 0) {\n\t\t\t\t\t\tif (scribble.points.length > 1) {\n\t\t\t\t\t\t\tscribble.points.shift()\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem.delayRemaining = scribble.delay\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'stopping': {\n\t\t\t\tif (delayRemaining === 0 && timeoutMs === 0) {\n\t\t\t\t\tif (scribble.points.length <= 1) {\n\t\t\t\t\t\tscribble.points.length = 0\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (scribble.shrink) {\n\t\t\t\t\t\tscribble.size = Math.max(1, scribble.size * (1 - scribble.shrink))\n\t\t\t\t\t}\n\t\t\t\t\tscribble.points.shift()\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'paused': {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate tickGroupedFade(session: Session, elapsed: number): void {\n\t\tsession.fadeElapsed += elapsed\n\n\t\tlet remainingPoints = 0\n\t\tfor (const item of session.items) {\n\t\t\tremainingPoints += item.scribble.points.length\n\t\t}\n\n\t\tif (remainingPoints === 0) return\n\n\t\tif (session.fadeElapsed >= session.options.fadeDurationMs) {\n\t\t\tfor (const item of session.items) {\n\t\t\t\titem.scribble.points.length = 0\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tconst progress = session.fadeElapsed / session.options.fadeDurationMs\n\t\tconst easedProgress = session.options.fadeEasing === 'ease-in' ? progress * progress : progress\n\n\t\tconst targetRemoved = Math.floor(easedProgress * session.totalPointsAtFadeStart)\n\t\tconst actuallyRemoved = session.totalPointsAtFadeStart - remainingPoints\n\t\tconst pointsToRemove = Math.max(1, targetRemoved - actuallyRemoved)\n\n\t\tlet removed = 0\n\t\tlet itemIndex = 0\n\t\twhile (removed < pointsToRemove && itemIndex < session.items.length) {\n\t\t\tconst item = session.items[itemIndex]\n\t\t\tif (item.scribble.points.length > 0) {\n\t\t\t\titem.scribble.points.shift()\n\t\t\t\tremoved++\n\t\t\t} else {\n\t\t\t\titemIndex++\n\t\t\t}\n\t\t}\n\t}\n}\n"],
4
+ "sourcesContent": ["import { TLScribble, VecModel } from '@tldraw/tlschema'\nimport { uniqueId } from '@tldraw/utils'\nimport { Vec } from '../../../primitives/Vec'\nimport type { Editor } from '../../Editor'\n\n/** @public */\nexport interface ScribbleItem {\n\tid: string\n\tscribble: TLScribble\n\ttimeoutMs: number\n\tdelayRemaining: number\n\tprev: null | VecModel\n\tnext: null | VecModel\n}\n\n/** @public */\nexport interface ScribbleSessionOptions {\n\t/** Session id. Auto-generated if not provided. */\n\tid?: string\n\t/**\n\t * Whether scribbles self-consume (shrink from start) while drawing.\n\t * - true: scribbles eat their own tail as you draw (default, used for eraser/select)\n\t * - false: scribbles persist until session stops (used for laser)\n\t */\n\tselfConsume?: boolean\n\t/**\n\t * How long to wait after last activity before auto-stopping the session.\n\t * Only applies when selfConsume is false.\n\t */\n\tidleTimeoutMs?: number\n\t/**\n\t * How scribbles fade when stopping.\n\t * - 'individual': each scribble fades on its own (default)\n\t * - 'grouped': all scribbles fade together as one sequence\n\t */\n\tfadeMode?: 'individual' | 'grouped'\n\t/**\n\t * Easing for grouped fade.\n\t */\n\tfadeEasing?: 'linear' | 'ease-in'\n\t/**\n\t * Duration of the fade in milliseconds.\n\t */\n\tfadeDurationMs?: number\n}\n\n// Internal session state (not exported)\ninterface Session {\n\tid: string\n\titems: ScribbleItem[]\n\tstate: 'active' | 'stopping' | 'complete'\n\toptions: Required<Omit<ScribbleSessionOptions, 'id'>>\n\tidleTimeoutHandle?: number\n\tfadeElapsed: number\n\ttotalPointsAtFadeStart: number\n}\n\n/** @public */\nexport class ScribbleManager {\n\tprivate sessions = new Map<string, Session>()\n\n\tconstructor(private editor: Editor) {}\n\n\t// ==================== SESSION API ====================\n\n\t/**\n\t * Start a new session for grouping scribbles.\n\t * Returns a session ID that can be used with other session methods.\n\t *\n\t * @param options - Session configuration\n\t * @returns Session ID\n\t * @public\n\t */\n\tstartSession(options: ScribbleSessionOptions = {}): string {\n\t\tconst id = options.id ?? uniqueId()\n\t\tconst session: Session = {\n\t\t\tid,\n\t\t\titems: [],\n\t\t\tstate: 'active',\n\t\t\toptions: {\n\t\t\t\tselfConsume: options.selfConsume ?? true,\n\t\t\t\tidleTimeoutMs: options.idleTimeoutMs ?? 0,\n\t\t\t\tfadeMode: options.fadeMode ?? 'individual',\n\t\t\t\tfadeEasing: options.fadeEasing ?? (options.fadeMode === 'grouped' ? 'ease-in' : 'linear'),\n\t\t\t\tfadeDurationMs: options.fadeDurationMs ?? this.editor.options.laserFadeoutMs,\n\t\t\t},\n\t\t\tfadeElapsed: 0,\n\t\t\ttotalPointsAtFadeStart: 0,\n\t\t}\n\n\t\tthis.sessions.set(id, session)\n\n\t\t// Set up idle timeout if configured\n\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\tthis.resetIdleTimeout(session)\n\t\t}\n\n\t\treturn id\n\t}\n\n\t/**\n\t * Add a scribble to a session.\n\t *\n\t * @param sessionId - The session ID\n\t * @param scribble - Partial scribble properties\n\t * @param scribbleId - Optional scribble ID\n\t * @public\n\t */\n\taddScribbleToSession(\n\t\tsessionId: string,\n\t\tscribble: Partial<TLScribble>,\n\t\tscribbleId = uniqueId()\n\t): ScribbleItem {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session) throw Error(`Session ${sessionId} not found`)\n\n\t\tconst item: ScribbleItem = {\n\t\t\tid: scribbleId,\n\t\t\tscribble: {\n\t\t\t\tid: scribbleId,\n\t\t\t\tsize: 20,\n\t\t\t\tcolor: 'accent',\n\t\t\t\topacity: 0.8,\n\t\t\t\tdelay: 0,\n\t\t\t\tpoints: [],\n\t\t\t\tshrink: 0.1,\n\t\t\t\ttaper: true,\n\t\t\t\t...scribble,\n\t\t\t\tstate: 'starting',\n\t\t\t},\n\t\t\ttimeoutMs: 0,\n\t\t\tdelayRemaining: scribble.delay ?? 0,\n\t\t\tprev: null,\n\t\t\tnext: null,\n\t\t}\n\n\t\tsession.items.push(item)\n\n\t\t// Reset idle timeout on activity\n\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\tthis.resetIdleTimeout(session)\n\t\t}\n\n\t\treturn item\n\t}\n\n\t/**\n\t * Add a point to a scribble in a session.\n\t *\n\t * @param sessionId - The session ID\n\t * @param scribbleId - The scribble ID\n\t * @param x - X coordinate\n\t * @param y - Y coordinate\n\t * @param z - Z coordinate (pressure)\n\t * @public\n\t */\n\taddPointToSession(\n\t\tsessionId: string,\n\t\tscribbleId: string,\n\t\tx: number,\n\t\ty: number,\n\t\tz = 0.5\n\t): ScribbleItem {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session) throw Error(`Session ${sessionId} not found`)\n\n\t\tconst item = session.items.find((i) => i.id === scribbleId)\n\t\tif (!item) throw Error(`Scribble ${scribbleId} not found in session ${sessionId}`)\n\n\t\tconst point = { x, y, z }\n\t\tif (!item.prev || Vec.Dist(item.prev, point) >= 1) {\n\t\t\titem.next = point\n\t\t}\n\n\t\t// Reset idle timeout on activity\n\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\tthis.resetIdleTimeout(session)\n\t\t}\n\n\t\treturn item\n\t}\n\n\t/**\n\t * Extend a session, resetting its idle timeout.\n\t *\n\t * @param sessionId - The session ID\n\t * @public\n\t */\n\textendSession(sessionId: string): void {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session) return\n\n\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\tthis.resetIdleTimeout(session)\n\t\t}\n\t}\n\n\t/**\n\t * Stop a session, triggering fade-out.\n\t *\n\t * @param sessionId - The session ID\n\t * @public\n\t */\n\tstopSession(sessionId: string): void {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session || session.state !== 'active') return\n\n\t\tthis.clearIdleTimeout(session)\n\t\tsession.state = 'stopping'\n\n\t\tif (session.options.fadeMode === 'grouped') {\n\t\t\tsession.totalPointsAtFadeStart = session.items.reduce(\n\t\t\t\t(sum, item) => sum + item.scribble.points.length,\n\t\t\t\t0\n\t\t\t)\n\t\t\tsession.fadeElapsed = 0\n\t\t\tfor (const item of session.items) {\n\t\t\t\titem.scribble.state = 'stopping'\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const item of session.items) {\n\t\t\t\titem.delayRemaining = Math.min(item.delayRemaining, 200)\n\t\t\t\titem.scribble.state = 'stopping'\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clear all scribbles in a session immediately.\n\t *\n\t * @param sessionId - The session ID\n\t * @public\n\t */\n\tclearSession(sessionId: string): void {\n\t\tconst session = this.sessions.get(sessionId)\n\t\tif (!session) return\n\n\t\tthis.clearIdleTimeout(session)\n\t\tfor (const item of session.items) {\n\t\t\titem.scribble.points.length = 0\n\t\t}\n\t\tsession.state = 'complete'\n\t}\n\n\t/**\n\t * Check if a session is active.\n\t *\n\t * @param sessionId - The session ID\n\t * @public\n\t */\n\tisSessionActive(sessionId: string): boolean {\n\t\tconst session = this.sessions.get(sessionId)\n\t\treturn session?.state === 'active'\n\t}\n\n\t// ==================== SIMPLE API (for eraser, select, etc.) ====================\n\n\t/**\n\t * Add a scribble using the default self-consuming behavior.\n\t * Creates an implicit session for the scribble.\n\t *\n\t * @param scribble - Partial scribble properties\n\t * @param id - Optional scribble id\n\t * @returns The created scribble item\n\t * @public\n\t */\n\taddScribble(scribble: Partial<TLScribble>, id = uniqueId()): ScribbleItem {\n\t\tconst sessionId = this.startSession()\n\t\treturn this.addScribbleToSession(sessionId, scribble, id)\n\t}\n\n\t/**\n\t * Add a point to a scribble. Searches all sessions.\n\t *\n\t * @param id - The scribble id\n\t * @param x - X coordinate\n\t * @param y - Y coordinate\n\t * @param z - Z coordinate (pressure)\n\t * @public\n\t */\n\taddPoint(id: string, x: number, y: number, z = 0.5): ScribbleItem {\n\t\tfor (const session of this.sessions.values()) {\n\t\t\tconst item = session.items.find((i) => i.id === id)\n\t\t\tif (item) {\n\t\t\t\tconst point = { x, y, z }\n\t\t\t\tif (!item.prev || Vec.Dist(item.prev, point) >= 1) {\n\t\t\t\t\titem.next = point\n\t\t\t\t}\n\t\t\t\tif (session.options.idleTimeoutMs > 0) {\n\t\t\t\t\tthis.resetIdleTimeout(session)\n\t\t\t\t}\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t\tthrow Error(`Scribble with id ${id} not found`)\n\t}\n\n\t/**\n\t * Mark a scribble as complete (done being drawn but not yet fading).\n\t * Searches all sessions.\n\t *\n\t * @param id - The scribble id\n\t * @public\n\t */\n\tcomplete(id: string): ScribbleItem {\n\t\tfor (const session of this.sessions.values()) {\n\t\t\tconst item = session.items.find((i) => i.id === id)\n\t\t\tif (item) {\n\t\t\t\tif (item.scribble.state === 'starting' || item.scribble.state === 'active') {\n\t\t\t\t\titem.scribble.state = 'complete'\n\t\t\t\t}\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t\tthrow Error(`Scribble with id ${id} not found`)\n\t}\n\n\t/**\n\t * Stop a scribble. Searches all sessions.\n\t *\n\t * @param id - The scribble id\n\t * @public\n\t */\n\tstop(id: string): ScribbleItem {\n\t\tfor (const session of this.sessions.values()) {\n\t\t\tconst item = session.items.find((i) => i.id === id)\n\t\t\tif (item) {\n\t\t\t\titem.delayRemaining = Math.min(item.delayRemaining, 200)\n\t\t\t\titem.scribble.state = 'stopping'\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t\tthrow Error(`Scribble with id ${id} not found`)\n\t}\n\n\t/**\n\t * Stop and remove all sessions.\n\t *\n\t * @public\n\t */\n\treset(): void {\n\t\tfor (const session of this.sessions.values()) {\n\t\t\tthis.clearIdleTimeout(session)\n\t\t}\n\t\tthis.sessions.clear()\n\t\tthis.editor.updateInstanceState({ scribbles: [] })\n\t}\n\n\t/**\n\t * Update on each animation frame.\n\t *\n\t * @param elapsed - The number of milliseconds since the last tick.\n\t * @public\n\t */\n\ttick(elapsed: number): void {\n\t\tconst currentScribbles = this.editor.getInstanceState().scribbles\n\t\tif (this.sessions.size === 0 && currentScribbles.length === 0) return\n\n\t\tthis.editor.run(() => {\n\t\t\t// Tick all sessions\n\t\t\tfor (const session of this.sessions.values()) {\n\t\t\t\tthis.tickSession(session, elapsed)\n\t\t\t}\n\n\t\t\t// Remove completed sessions\n\t\t\tfor (const [id, session] of this.sessions) {\n\t\t\t\tif (session.state === 'complete') {\n\t\t\t\t\tthis.clearIdleTimeout(session)\n\t\t\t\t\tthis.sessions.delete(id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Collect scribbles from all sessions\n\t\t\tconst scribbles: TLScribble[] = []\n\t\t\tfor (const session of this.sessions.values()) {\n\t\t\t\tfor (const item of session.items) {\n\t\t\t\t\tif (item.scribble.points.length > 0) {\n\t\t\t\t\t\tscribbles.push({\n\t\t\t\t\t\t\t...item.scribble,\n\t\t\t\t\t\t\tpoints: [...item.scribble.points],\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.editor.updateInstanceState({ scribbles })\n\t\t})\n\t}\n\n\t// ==================== PRIVATE HELPERS ====================\n\n\tprivate resetIdleTimeout(session: Session): void {\n\t\tthis.clearIdleTimeout(session)\n\t\tsession.idleTimeoutHandle = this.editor.timers.setTimeout(() => {\n\t\t\tthis.stopSession(session.id)\n\t\t}, session.options.idleTimeoutMs)\n\t}\n\n\tprivate clearIdleTimeout(session: Session): void {\n\t\tif (session.idleTimeoutHandle !== undefined) {\n\t\t\tclearTimeout(session.idleTimeoutHandle)\n\t\t\tsession.idleTimeoutHandle = undefined\n\t\t}\n\t}\n\n\tprivate tickSession(session: Session, elapsed: number): void {\n\t\tif (session.state === 'complete') return\n\n\t\tif (session.state === 'stopping' && session.options.fadeMode === 'grouped') {\n\t\t\tthis.tickGroupedFade(session, elapsed)\n\t\t} else {\n\t\t\tthis.tickSessionItems(session, elapsed)\n\t\t}\n\n\t\t// Check if session is complete\n\t\tconst hasContent = session.items.some((item) => item.scribble.points.length > 0)\n\t\tif (!hasContent && (session.state === 'stopping' || session.items.length === 0)) {\n\t\t\tsession.state = 'complete'\n\t\t}\n\t}\n\n\tprivate tickSessionItems(session: Session, elapsed: number): void {\n\t\tfor (const item of session.items) {\n\t\t\tconst shouldSelfConsume =\n\t\t\t\tsession.options.selfConsume ||\n\t\t\t\tsession.state === 'stopping' ||\n\t\t\t\titem.scribble.state === 'stopping'\n\n\t\t\tif (shouldSelfConsume) {\n\t\t\t\tthis.tickSelfConsumingItem(item, elapsed)\n\t\t\t} else {\n\t\t\t\tthis.tickPersistentItem(item)\n\t\t\t}\n\t\t}\n\n\t\t// Remove completed items in individual fade mode\n\t\tif (session.options.fadeMode === 'individual') {\n\t\t\tfor (let i = session.items.length - 1; i >= 0; i--) {\n\t\t\t\tif (session.items[i].scribble.points.length === 0) {\n\t\t\t\t\tsession.items.splice(i, 1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate tickPersistentItem(item: ScribbleItem): void {\n\t\tconst { scribble } = item\n\n\t\tif (scribble.state === 'starting') {\n\t\t\tconst { next, prev } = item\n\t\t\tif (next && next !== prev) {\n\t\t\t\titem.prev = next\n\t\t\t\tscribble.points.push(next)\n\t\t\t}\n\t\t\tif (scribble.points.length > 8) {\n\t\t\t\tscribble.state = 'active'\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (scribble.state === 'active') {\n\t\t\tconst { next, prev } = item\n\t\t\tif (next && next !== prev) {\n\t\t\t\titem.prev = next\n\t\t\t\tscribble.points.push(next)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate tickSelfConsumingItem(item: ScribbleItem, elapsed: number): void {\n\t\tconst { scribble } = item\n\n\t\tif (scribble.state === 'starting') {\n\t\t\tconst { next, prev } = item\n\t\t\tif (next && next !== prev) {\n\t\t\t\titem.prev = next\n\t\t\t\tscribble.points.push(next)\n\t\t\t}\n\t\t\tif (scribble.points.length > 8) {\n\t\t\t\tscribble.state = 'active'\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (item.delayRemaining > 0) {\n\t\t\titem.delayRemaining = Math.max(0, item.delayRemaining - elapsed)\n\t\t}\n\n\t\titem.timeoutMs += elapsed\n\t\tif (item.timeoutMs >= 16) {\n\t\t\titem.timeoutMs = 0\n\t\t}\n\n\t\tconst { delayRemaining, timeoutMs, prev, next } = item\n\n\t\tswitch (scribble.state) {\n\t\t\tcase 'active': {\n\t\t\t\tif (next && next !== prev) {\n\t\t\t\t\titem.prev = next\n\t\t\t\t\tscribble.points.push(next)\n\t\t\t\t\tif (delayRemaining === 0 && scribble.points.length > 8) {\n\t\t\t\t\t\tscribble.points.shift()\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (timeoutMs === 0) {\n\t\t\t\t\t\tif (scribble.points.length > 1) {\n\t\t\t\t\t\t\tscribble.points.shift()\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem.delayRemaining = scribble.delay\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'stopping': {\n\t\t\t\tif (delayRemaining === 0 && timeoutMs === 0) {\n\t\t\t\t\tif (scribble.points.length <= 1) {\n\t\t\t\t\t\tscribble.points.length = 0\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (scribble.shrink) {\n\t\t\t\t\t\tscribble.size = Math.max(1, scribble.size * (1 - scribble.shrink))\n\t\t\t\t\t}\n\t\t\t\t\tscribble.points.shift()\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'paused': {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate tickGroupedFade(session: Session, elapsed: number): void {\n\t\tsession.fadeElapsed += elapsed\n\n\t\tlet remainingPoints = 0\n\t\tfor (const item of session.items) {\n\t\t\tremainingPoints += item.scribble.points.length\n\t\t}\n\n\t\tif (remainingPoints === 0) return\n\n\t\tif (session.fadeElapsed >= session.options.fadeDurationMs) {\n\t\t\tfor (const item of session.items) {\n\t\t\t\titem.scribble.points.length = 0\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tconst progress = session.fadeElapsed / session.options.fadeDurationMs\n\t\tconst easedProgress = session.options.fadeEasing === 'ease-in' ? progress * progress : progress\n\n\t\tconst targetRemoved = Math.floor(easedProgress * session.totalPointsAtFadeStart)\n\t\tconst actuallyRemoved = session.totalPointsAtFadeStart - remainingPoints\n\t\tconst pointsToRemove = Math.max(1, targetRemoved - actuallyRemoved)\n\n\t\tlet removed = 0\n\t\tlet itemIndex = 0\n\t\twhile (removed < pointsToRemove && itemIndex < session.items.length) {\n\t\t\tconst item = session.items[itemIndex]\n\t\t\tif (item.scribble.points.length > 0) {\n\t\t\t\titem.scribble.points.shift()\n\t\t\t\tremoved++\n\t\t\t} else {\n\t\t\t\titemIndex++\n\t\t\t}\n\t\t}\n\t}\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAyB;AACzB,iBAAoB;AAwDb,MAAM,gBAAgB;AAAA,EAG5B,YAAoB,QAAgB;AAAhB;AAAA,EAAiB;AAAA,EAF7B,WAAW,oBAAI,IAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc5C,aAAa,UAAkC,CAAC,GAAW;AAC1D,UAAM,KAAK,QAAQ,UAAM,uBAAS;AAClC,UAAM,UAAmB;AAAA,MACxB;AAAA,MACA,OAAO,CAAC;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACR,aAAa,QAAQ,eAAe;AAAA,QACpC,eAAe,QAAQ,iBAAiB;AAAA,QACxC,UAAU,QAAQ,YAAY;AAAA,QAC9B,YAAY,QAAQ,eAAe,QAAQ,aAAa,YAAY,YAAY;AAAA,QAChF,gBAAgB,QAAQ,kBAAkB,KAAK,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