@tldraw/editor 4.3.0-canary.2362fd2ebe56 → 4.3.0-canary.2643056dfc8d

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 (177) hide show
  1. package/dist-cjs/index.d.ts +537 -120
  2. package/dist-cjs/index.js +8 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/components/ErrorBoundary.js.map +1 -1
  5. package/dist-cjs/lib/components/GeometryDebuggingView.js +1 -17
  6. package/dist-cjs/lib/components/GeometryDebuggingView.js.map +2 -2
  7. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +4 -5
  8. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  9. package/dist-cjs/lib/constants.js +1 -3
  10. package/dist-cjs/lib/constants.js.map +2 -2
  11. package/dist-cjs/lib/editor/Editor.js +349 -280
  12. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  13. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +16 -23
  14. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +3 -3
  15. package/dist-cjs/lib/editor/derivations/parentsToChildren.js +12 -3
  16. package/dist-cjs/lib/editor/derivations/parentsToChildren.js.map +2 -2
  17. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +1 -1
  18. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
  19. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +5 -6
  20. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
  21. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +591 -0
  22. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +7 -0
  23. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +1 -1
  24. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
  25. package/dist-cjs/lib/editor/managers/SpatialIndexManager/RBushIndex.js +144 -0
  26. package/dist-cjs/lib/editor/managers/SpatialIndexManager/RBushIndex.js.map +7 -0
  27. package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +181 -0
  28. package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +7 -0
  29. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +1 -22
  30. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +2 -2
  31. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +31 -23
  32. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  33. package/dist-cjs/lib/editor/shapes/group/DashedOutlineBox.js +1 -1
  34. package/dist-cjs/lib/editor/shapes/group/DashedOutlineBox.js.map +2 -2
  35. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +3 -3
  36. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +2 -2
  37. package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
  38. package/dist-cjs/lib/exports/parseCss.js +1 -1
  39. package/dist-cjs/lib/exports/parseCss.js.map +2 -2
  40. package/dist-cjs/lib/globals/environment.js +45 -9
  41. package/dist-cjs/lib/globals/environment.js.map +2 -2
  42. package/dist-cjs/lib/hooks/useCoarsePointer.js +14 -29
  43. package/dist-cjs/lib/hooks/useCoarsePointer.js.map +2 -2
  44. package/dist-cjs/lib/hooks/useEvent.js +1 -1
  45. package/dist-cjs/lib/hooks/useEvent.js.map +2 -2
  46. package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
  47. package/dist-cjs/lib/hooks/useGestureEvents.js +1 -1
  48. package/dist-cjs/lib/hooks/useGestureEvents.js.map +2 -2
  49. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
  50. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
  51. package/dist-cjs/lib/hooks/useScreenBounds.js.map +2 -2
  52. package/dist-cjs/lib/hooks/useStateAttribute.js +4 -1
  53. package/dist-cjs/lib/hooks/useStateAttribute.js.map +2 -2
  54. package/dist-cjs/lib/hooks/useTransform.js.map +1 -1
  55. package/dist-cjs/lib/hooks/useZoomCss.js +4 -8
  56. package/dist-cjs/lib/hooks/useZoomCss.js.map +2 -2
  57. package/dist-cjs/lib/options.js +6 -1
  58. package/dist-cjs/lib/options.js.map +2 -2
  59. package/dist-cjs/lib/primitives/Box.js +3 -0
  60. package/dist-cjs/lib/primitives/Box.js.map +2 -2
  61. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +1 -0
  62. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  63. package/dist-cjs/lib/utils/rotation.js +1 -1
  64. package/dist-cjs/lib/utils/rotation.js.map +2 -2
  65. package/dist-cjs/version.js +3 -3
  66. package/dist-cjs/version.js.map +1 -1
  67. package/dist-esm/index.d.mts +537 -120
  68. package/dist-esm/index.mjs +9 -2
  69. package/dist-esm/index.mjs.map +2 -2
  70. package/dist-esm/lib/components/ErrorBoundary.mjs.map +1 -1
  71. package/dist-esm/lib/components/GeometryDebuggingView.mjs +1 -17
  72. package/dist-esm/lib/components/GeometryDebuggingView.mjs.map +2 -2
  73. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +4 -5
  74. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  75. package/dist-esm/lib/constants.mjs +1 -3
  76. package/dist-esm/lib/constants.mjs.map +2 -2
  77. package/dist-esm/lib/editor/Editor.mjs +350 -283
  78. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  79. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +16 -23
  80. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +3 -3
  81. package/dist-esm/lib/editor/derivations/parentsToChildren.mjs +13 -4
  82. package/dist-esm/lib/editor/derivations/parentsToChildren.mjs.map +2 -2
  83. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +1 -1
  84. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
  85. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +5 -6
  86. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
  87. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +573 -0
  88. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +7 -0
  89. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +1 -1
  90. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
  91. package/dist-esm/lib/editor/managers/SpatialIndexManager/RBushIndex.mjs +114 -0
  92. package/dist-esm/lib/editor/managers/SpatialIndexManager/RBushIndex.mjs.map +7 -0
  93. package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +161 -0
  94. package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +7 -0
  95. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +1 -22
  96. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +2 -2
  97. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +31 -23
  98. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  99. package/dist-esm/lib/editor/shapes/group/DashedOutlineBox.mjs +1 -1
  100. package/dist-esm/lib/editor/shapes/group/DashedOutlineBox.mjs.map +2 -2
  101. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +3 -3
  102. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +2 -2
  103. package/dist-esm/lib/exports/parseCss.mjs +1 -1
  104. package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
  105. package/dist-esm/lib/globals/environment.mjs +45 -9
  106. package/dist-esm/lib/globals/environment.mjs.map +2 -2
  107. package/dist-esm/lib/hooks/useCoarsePointer.mjs +15 -30
  108. package/dist-esm/lib/hooks/useCoarsePointer.mjs.map +2 -2
  109. package/dist-esm/lib/hooks/useEvent.mjs +1 -1
  110. package/dist-esm/lib/hooks/useEvent.mjs.map +2 -2
  111. package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
  112. package/dist-esm/lib/hooks/useGestureEvents.mjs +1 -1
  113. package/dist-esm/lib/hooks/useGestureEvents.mjs.map +2 -2
  114. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
  115. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
  116. package/dist-esm/lib/hooks/useScreenBounds.mjs.map +2 -2
  117. package/dist-esm/lib/hooks/useStateAttribute.mjs +4 -1
  118. package/dist-esm/lib/hooks/useStateAttribute.mjs.map +2 -2
  119. package/dist-esm/lib/hooks/useTransform.mjs.map +1 -1
  120. package/dist-esm/lib/hooks/useZoomCss.mjs +4 -8
  121. package/dist-esm/lib/hooks/useZoomCss.mjs.map +2 -2
  122. package/dist-esm/lib/options.mjs +6 -1
  123. package/dist-esm/lib/options.mjs.map +2 -2
  124. package/dist-esm/lib/primitives/Box.mjs +3 -0
  125. package/dist-esm/lib/primitives/Box.mjs.map +2 -2
  126. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +1 -0
  127. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  128. package/dist-esm/lib/utils/rotation.mjs +1 -1
  129. package/dist-esm/lib/utils/rotation.mjs.map +2 -2
  130. package/dist-esm/version.mjs +3 -3
  131. package/dist-esm/version.mjs.map +1 -1
  132. package/editor.css +14 -12
  133. package/package.json +21 -17
  134. package/src/index.ts +5 -1
  135. package/src/lib/components/ErrorBoundary.tsx +1 -1
  136. package/src/lib/components/GeometryDebuggingView.tsx +1 -19
  137. package/src/lib/components/default-components/DefaultCanvas.tsx +5 -8
  138. package/src/lib/config/TLUserPreferences.test.ts +40 -0
  139. package/src/lib/constants.ts +0 -2
  140. package/src/lib/editor/Editor.test.ts +140 -0
  141. package/src/lib/editor/Editor.ts +455 -326
  142. package/src/lib/editor/derivations/notVisibleShapes.ts +21 -33
  143. package/src/lib/editor/derivations/parentsToChildren.ts +18 -7
  144. package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +17 -31
  145. package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
  146. package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +129 -79
  147. package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +10 -6
  148. package/src/lib/editor/managers/InputsManager/InputsManager.ts +566 -0
  149. package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +0 -4
  150. package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +12 -0
  151. package/src/lib/editor/managers/SnapManager/SnapManager.ts +1 -1
  152. package/src/lib/editor/managers/SpatialIndexManager/RBushIndex.ts +144 -0
  153. package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +215 -0
  154. package/src/lib/editor/managers/TickManager/TickManager.test.ts +40 -107
  155. package/src/lib/editor/managers/TickManager/TickManager.ts +2 -32
  156. package/src/lib/editor/shapes/ShapeUtil.ts +67 -24
  157. package/src/lib/editor/shapes/group/DashedOutlineBox.tsx +1 -1
  158. package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +3 -3
  159. package/src/lib/editor/types/emit-types.ts +3 -1
  160. package/src/lib/exports/parseCss.test.ts +1 -0
  161. package/src/lib/exports/parseCss.ts +1 -1
  162. package/src/lib/globals/environment.ts +65 -10
  163. package/src/lib/hooks/useCoarsePointer.ts +16 -59
  164. package/src/lib/hooks/useEvent.tsx +1 -1
  165. package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +1 -1
  166. package/src/lib/hooks/useGestureEvents.ts +2 -2
  167. package/src/lib/hooks/usePassThroughMouseOverEvents.ts +1 -1
  168. package/src/lib/hooks/usePassThroughWheelEvents.ts +1 -1
  169. package/src/lib/hooks/useScreenBounds.ts +1 -1
  170. package/src/lib/hooks/useStateAttribute.ts +4 -1
  171. package/src/lib/hooks/useTransform.ts +1 -1
  172. package/src/lib/hooks/useZoomCss.ts +3 -8
  173. package/src/lib/options.ts +32 -0
  174. package/src/lib/primitives/Box.ts +9 -0
  175. package/src/lib/primitives/geometry/Geometry2d.ts +1 -0
  176. package/src/lib/utils/rotation.ts +1 -1
  177. package/src/version.ts +3 -3
@@ -1,4 +1,5 @@
1
1
  import { Atom } from '@tldraw/state';
2
+ import { AtomSet } from '@tldraw/store';
2
3
  import { BoxModel } from '@tldraw/tlschema';
3
4
  import { ComponentType } from 'react';
4
5
  import { Computed } from '@tldraw/state';
@@ -9,10 +10,11 @@ import EventEmitter from 'eventemitter3';
9
10
  import { ExoticComponent } from 'react';
10
11
  import { ExtractShapeByProps } from '@tldraw/tlschema';
11
12
  import { ForwardRefExoticComponent } from 'react';
13
+ import { FragmentProps } from 'react';
12
14
  import { HistoryEntry } from '@tldraw/store';
13
15
  import { IndexKey } from '@tldraw/utils';
14
16
  import { JsonObject } from '@tldraw/utils';
15
- import { JSX as JSX_2 } from 'react/jsx-runtime';
17
+ import { JSX } from 'react/jsx-runtime';
16
18
  import { LegacyMigrations } from '@tldraw/store';
17
19
  import { MigrationSequence } from '@tldraw/store';
18
20
  import { NamedExoticComponent } from 'react';
@@ -488,6 +490,7 @@ export declare class Box {
488
490
  get cornersAndCenter(): Vec[];
489
491
  get sides(): Array<[Vec, Vec]>;
490
492
  get size(): Vec;
493
+ isValid(): boolean;
491
494
  toFixed(): this;
492
495
  setTo(B: Box): this;
493
496
  set(x?: number, y?: number, w?: number, h?: number): this;
@@ -655,7 +658,7 @@ export declare function clockwiseAngleDist(a0: number, a1: number): number;
655
658
  * @public
656
659
  * @react
657
660
  */
658
- export declare function ContainerProvider({ container, children }: ContainerProviderProps): JSX_2.Element;
661
+ export declare function ContainerProvider({ container, children }: ContainerProviderProps): JSX.Element;
659
662
 
660
663
  /** @public */
661
664
  export declare interface ContainerProviderProps {
@@ -796,16 +799,16 @@ export declare interface DebugFlagDefaults<T> {
796
799
  /* Excluded from this release type: DEFAULT_CAMERA_OPTIONS */
797
800
 
798
801
  /** @public @react */
799
- export declare function DefaultBackground(): JSX_2.Element;
802
+ export declare function DefaultBackground(): JSX.Element;
800
803
 
801
804
  /** @public @react */
802
- export declare const DefaultBrush: ({ brush, color, opacity, className }: TLBrushProps) => JSX_2.Element;
805
+ export declare const DefaultBrush: ({ brush, color, opacity, className }: TLBrushProps) => JSX.Element;
803
806
 
804
807
  /** @public @react */
805
- export declare function DefaultCanvas({ className }: TLCanvasComponentProps): JSX_2.Element;
808
+ export declare function DefaultCanvas({ className }: TLCanvasComponentProps): JSX.Element;
806
809
 
807
810
  /** @public @react */
808
- export declare function DefaultCollaboratorHint({ className, zoom, point, color, viewport, opacity, }: TLCollaboratorHintProps): JSX_2.Element;
811
+ export declare function DefaultCollaboratorHint({ className, zoom, point, color, viewport, opacity, }: TLCollaboratorHintProps): JSX.Element;
809
812
 
810
813
  /** @public @react */
811
814
  export declare const DefaultCursor: NamedExoticComponent<TLCursorProps>;
@@ -814,22 +817,22 @@ export declare const DefaultCursor: NamedExoticComponent<TLCursorProps>;
814
817
  export declare const DefaultErrorFallback: TLErrorFallbackComponent;
815
818
 
816
819
  /** @public @react */
817
- export declare function DefaultGrid({ x, y, z, size }: TLGridProps): JSX_2.Element;
820
+ export declare function DefaultGrid({ x, y, z, size }: TLGridProps): JSX.Element;
818
821
 
819
822
  /** @public @react */
820
- export declare function DefaultHandle({ handle, isCoarse, className, zoom }: TLHandleProps): JSX_2.Element;
823
+ export declare function DefaultHandle({ handle, isCoarse, className, zoom }: TLHandleProps): JSX.Element;
821
824
 
822
825
  /** @public @react */
823
- export declare const DefaultHandles: ({ children }: TLHandlesProps) => JSX_2.Element;
826
+ export declare const DefaultHandles: ({ children }: TLHandlesProps) => JSX.Element;
824
827
 
825
828
  /** @public @react */
826
- export declare function DefaultScribble({ scribble, zoom, color, opacity, className }: TLScribbleProps): JSX_2.Element | null;
829
+ export declare function DefaultScribble({ scribble, zoom, color, opacity, className }: TLScribbleProps): JSX.Element | null;
827
830
 
828
831
  /** @public @react */
829
- export declare function DefaultSelectionBackground({ bounds, rotation }: TLSelectionBackgroundProps): JSX_2.Element;
832
+ export declare function DefaultSelectionBackground({ bounds, rotation }: TLSelectionBackgroundProps): JSX.Element;
830
833
 
831
834
  /** @public @react */
832
- export declare function DefaultSelectionForeground({ bounds, rotation }: TLSelectionForegroundProps): JSX_2.Element;
835
+ export declare function DefaultSelectionForeground({ bounds, rotation }: TLSelectionForegroundProps): JSX.Element;
833
836
 
834
837
  /** @public @react */
835
838
  export declare const DefaultShapeIndicator: NamedExoticComponent<TLShapeIndicatorProps>;
@@ -841,10 +844,10 @@ export declare const DefaultShapeIndicators: NamedExoticComponent<TLShapeIndicat
841
844
  export declare const DefaultShapeWrapper: ForwardRefExoticComponent<TLShapeWrapperProps & RefAttributes<HTMLDivElement>>;
842
845
 
843
846
  /** @public @react */
844
- export declare function DefaultSnapIndicator({ className, line, zoom }: TLSnapIndicatorProps): JSX_2.Element;
847
+ export declare function DefaultSnapIndicator({ className, line, zoom }: TLSnapIndicatorProps): JSX.Element;
845
848
 
846
849
  /** @public @react */
847
- export declare function DefaultSpinner(props: React.SVGProps<SVGSVGElement>): JSX_2.Element;
850
+ export declare function DefaultSpinner(props: React.SVGProps<SVGSVGElement>): JSX.Element;
848
851
 
849
852
  /** @public @react */
850
853
  export declare const DefaultSvgDefs: () => null;
@@ -863,6 +866,8 @@ export declare const defaultTldrawOptions: {
863
866
  readonly collaboratorIdleTimeoutMs: 3000;
864
867
  readonly collaboratorInactiveTimeoutMs: 60000;
865
868
  readonly createTextOnCanvasDoubleClick: true;
869
+ readonly debouncedZoom: true;
870
+ readonly debouncedZoomThreshold: 500;
866
871
  readonly defaultSvgPadding: 32;
867
872
  readonly doubleClickDurationMs: 450;
868
873
  readonly dragDistanceSquared: 16;
@@ -871,9 +876,7 @@ export declare const defaultTldrawOptions: {
871
876
  readonly edgeScrollEaseDuration: 200;
872
877
  readonly edgeScrollSpeed: 25;
873
878
  readonly enableToolbarKeyboardShortcuts: true;
874
- readonly exportProvider: ExoticComponent< {
875
- children?: ReactNode | undefined;
876
- }>;
879
+ readonly exportProvider: ExoticComponent<FragmentProps>;
877
880
  readonly flattenImageBoundsExpand: 64;
878
881
  readonly flattenImageBoundsPadding: 16;
879
882
  readonly followChaseViewportSnap: 2;
@@ -905,11 +908,14 @@ export declare const defaultTldrawOptions: {
905
908
  readonly maxShapesPerPage: 4000;
906
909
  readonly multiClickDurationMs: 200;
907
910
  readonly nonce: undefined;
911
+ readonly snapThreshold: 8;
912
+ readonly spacebarPanning: true;
908
913
  readonly temporaryAssetPreviewLifetimeMs: 180000;
909
914
  readonly textShadowLod: 0.35;
910
915
  readonly tooltipDelayMs: 700;
911
916
  readonly uiCoarseDragDistanceSquared: 625;
912
917
  readonly uiDragDistanceSquared: 16;
918
+ readonly zoomToFitPadding: 128;
913
919
  };
914
920
 
915
921
  /** @public */
@@ -983,6 +989,7 @@ export declare class EdgeScrollManager {
983
989
  constructor(editor: Editor);
984
990
  private _isEdgeScrolling;
985
991
  private _edgeScrollDuration;
992
+ getIsEdgeScrolling(): boolean;
986
993
  /**
987
994
  * Update the camera position when the mouse is close to the edge of the screen.
988
995
  * Run this on every tick when in a state where edge scrolling is enabled.
@@ -1041,7 +1048,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1041
1048
  */
1042
1049
  removeTool(Tool: TLStateNodeConstructor, parent?: StateNode): void;
1043
1050
  /**
1044
- * A set of functions to call when the app is disposed.
1051
+ * A set of functions to call when the editor is disposed.
1045
1052
  *
1046
1053
  * @public
1047
1054
  */
@@ -1054,11 +1061,23 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1054
1061
  isDisposed: boolean;
1055
1062
  /* Excluded from this release type: _tickManager */
1056
1063
  /**
1057
- * A manager for the app's snapping feature.
1064
+ * A manager for the editor's input state.
1065
+ *
1066
+ * @public
1067
+ */
1068
+ readonly inputs: InputsManager;
1069
+ /**
1070
+ * A manager for the editor's snapping feature.
1058
1071
  *
1059
1072
  * @public
1060
1073
  */
1061
1074
  readonly snaps: SnapManager;
1075
+ /**
1076
+ * A manager for spatial indexing, enabling efficient shape location queries.
1077
+ *
1078
+ * @public
1079
+ */
1080
+ readonly spatialIndex: SpatialIndexManager;
1062
1081
  /**
1063
1082
  * A manager for the any asynchronous events and making sure they're
1064
1083
  * cleaned up upon disposal.
@@ -1195,7 +1214,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1195
1214
  } | S): BindingUtil<S>;
1196
1215
  getBindingUtil<T extends BindingUtil>(type: T extends BindingUtil<infer R> ? R['type'] : string): T;
1197
1216
  /**
1198
- * A manager for the app's history.
1217
+ * A manager for the editor's history.
1199
1218
  *
1200
1219
  * @readonly
1201
1220
  */
@@ -1212,10 +1231,11 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1212
1231
  */
1213
1232
  undo(): this;
1214
1233
  /**
1215
- * Whether the app can undo.
1234
+ * Whether the editor can undo.
1216
1235
  *
1217
1236
  * @public
1218
1237
  */
1238
+ canUndo(): boolean;
1219
1239
  getCanUndo(): boolean;
1220
1240
  /**
1221
1241
  * Redo to the next mark.
@@ -1228,13 +1248,14 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1228
1248
  * @public
1229
1249
  */
1230
1250
  redo(): this;
1231
- clearHistory(): this;
1232
1251
  /**
1233
- * Whether the app can redo.
1252
+ * Whether the editor can redo.
1234
1253
  *
1235
1254
  * @public
1236
1255
  */
1256
+ canRedo(): boolean;
1237
1257
  getCanRedo(): boolean;
1258
+ clearHistory(): this;
1238
1259
  /**
1239
1260
  * Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
1240
1261
  * any redos. You typically want to do this just before a user interaction begins or is handled.
@@ -1593,7 +1614,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1593
1614
  */
1594
1615
  selectNone(): this;
1595
1616
  /**
1596
- * The id of the app's only selected shape.
1617
+ * The id of the editor's only selected shape.
1597
1618
  *
1598
1619
  * @returns Null if there is no shape or more than one selected shape, otherwise the selected shape's id.
1599
1620
  *
@@ -1602,7 +1623,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1602
1623
  */
1603
1624
  getOnlySelectedShapeId(): null | TLShapeId;
1604
1625
  /**
1605
- * The app's only selected shape.
1626
+ * The editor's only selected shape.
1606
1627
  *
1607
1628
  * @returns Null if there is no shape or more than one selected shape, otherwise the selected shape.
1608
1629
  *
@@ -1694,6 +1715,16 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1694
1715
  * @public
1695
1716
  */
1696
1717
  getEditingShape(): TLShape | undefined;
1718
+ /**
1719
+ * Whether the shape can be edited.
1720
+ *
1721
+ * @param shape - The shape (or shape id) to check if it can be edited.
1722
+ * @param info - The info about the edit start.
1723
+ *
1724
+ * @public
1725
+ * @returns true if the shape can be edited, false otherwise.
1726
+ */
1727
+ canEditShape<T extends TLShape | TLShapeId>(shape: null | T, info?: TLEditStartInfo): shape is T;
1697
1728
  /**
1698
1729
  * Set the current editing shape.
1699
1730
  *
@@ -1813,6 +1844,15 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1813
1844
  * @public
1814
1845
  */
1815
1846
  getCroppingShapeId(): null | TLShapeId;
1847
+ /**
1848
+ * Whether the shape can be cropped.
1849
+ *
1850
+ * @param shape - The shape (or shape id) to check if it can be cropped.
1851
+ *
1852
+ * @public
1853
+ * @returns true if the shape can be cropped, false otherwise.
1854
+ */
1855
+ canCropShape<T extends TLShape | TLShapeId>(shape: null | T): shape is T;
1816
1856
  /**
1817
1857
  * Set the current cropping shape.
1818
1858
  *
@@ -1855,6 +1895,32 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1855
1895
  * @public
1856
1896
  */
1857
1897
  getZoomLevel(): number;
1898
+ private _debouncedZoomLevel;
1899
+ /**
1900
+ * Get the debounced zoom level. When the camera is moving, this returns the zoom level
1901
+ * from when the camera started moving rather than the current zoom level. This can be
1902
+ * used to avoid expensive re-renders during camera movements.
1903
+ *
1904
+ * This behavior is controlled by the `useDebouncedZoom` option. When `useDebouncedZoom`
1905
+ * is `false`, this method always returns the current zoom level.
1906
+ *
1907
+ * @public
1908
+ */
1909
+ getDebouncedZoomLevel(): number;
1910
+ private _getAboveDebouncedZoomThreshold;
1911
+ /**
1912
+ * Get the efficient zoom level. This returns the current zoom level if there are less than 300 shapes on the page,
1913
+ * otherwise it returns the debounced zoom level. This can be used to avoid expensive re-renders during camera movements.
1914
+ *
1915
+ * @public
1916
+ * @example
1917
+ * ```ts
1918
+ * editor.getEfficientZoomLevel()
1919
+ * ```
1920
+ *
1921
+ * @public
1922
+ */
1923
+ getEfficientZoomLevel(): number;
1858
1924
  /**
1859
1925
  * Get the camera's initial or reset zoom level.
1860
1926
  *
@@ -1969,7 +2035,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1969
2035
  * ```ts
1970
2036
  * editor.zoomIn()
1971
2037
  * editor.zoomIn(editor.getViewportScreenCenter(), { animation: { duration: 200 } })
1972
- * editor.zoomIn(editor.inputs.currentScreenPoint, { animation: { duration: 200 } })
2038
+ * editor.zoomIn(editor.inputs.getCurrentScreenPoint(), { animation: { duration: 200 } })
1973
2039
  * ```
1974
2040
  *
1975
2041
  * @param point - The screen point to zoom in on. Defaults to the screen center
@@ -1985,7 +2051,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1985
2051
  * ```ts
1986
2052
  * editor.zoomOut()
1987
2053
  * editor.zoomOut(editor.getViewportScreenCenter(), { animation: { duration: 120 } })
1988
- * editor.zoomOut(editor.inputs.currentScreenPoint, { animation: { duration: 120 } })
2054
+ * editor.zoomOut(editor.inputs.getCurrentScreenPoint(), { animation: { duration: 120 } })
1989
2055
  * ```
1990
2056
  *
1991
2057
  * @param point - The point to zoom out on. Defaults to the viewport screen center.
@@ -2198,8 +2264,8 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2198
2264
  /* Excluded from this release type: getUnorderedRenderingShapes */
2199
2265
  private _cameraState;
2200
2266
  private _cameraStateTimeoutRemaining;
2201
- _decayCameraStateTimeout(elapsed: number): void;
2202
- _tickCameraState(): void;
2267
+ private _decayCameraStateTimeout;
2268
+ private _tickCameraState;
2203
2269
  /**
2204
2270
  * Whether the camera is moving or idle.
2205
2271
  *
@@ -2648,6 +2714,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2648
2714
  */
2649
2715
  getNotVisibleShapes(): Set<TLShapeId>;
2650
2716
  private _notVisibleShapes;
2717
+ private _culledShapesCache;
2651
2718
  /**
2652
2719
  * Get culled shapes (those that should not render), taking into account which shapes are selected or editing.
2653
2720
  *
@@ -2697,6 +2764,22 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2697
2764
  hitInside?: boolean;
2698
2765
  margin?: number;
2699
2766
  }): TLShape[];
2767
+ /**
2768
+ * Get shape IDs within the given bounds.
2769
+ *
2770
+ * Note: Results are unordered. If you need z-order, combine with sorted shapes:
2771
+ * ```ts
2772
+ * const candidates = editor.getShapeIdsInsideBounds(bounds)
2773
+ * const sorted = editor.getCurrentPageShapesSorted().filter(s => candidates.has(s.id))
2774
+ * ```
2775
+ *
2776
+ * @param bounds - The bounds to search within.
2777
+ *
2778
+ * @returns Unordered set of shape IDs within the given bounds.
2779
+ *
2780
+ * @public
2781
+ */
2782
+ getShapeIdsInsideBounds(bounds: Box): Set<TLShapeId>;
2700
2783
  /**
2701
2784
  * Test whether a point (in the current page space) will will a shape. This method takes into account masks,
2702
2785
  * such as when a shape is the child of a frame and is partially clipped by the frame.
@@ -3720,59 +3803,6 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3720
3803
  url: string;
3721
3804
  width: number;
3722
3805
  }>;
3723
- /**
3724
- * The app's current input state.
3725
- *
3726
- * @public
3727
- */
3728
- inputs: {
3729
- /** A set containing the currently pressed buttons. */
3730
- buttons: Set<number>;
3731
- /** A set containing the currently pressed keys. */
3732
- keys: Set<string>;
3733
- /** The most recent pointer down's position in screen space. */
3734
- originScreenPoint: Vec;
3735
- /** The most recent pointer down's position in the current page space. */
3736
- originPagePoint: Vec;
3737
- /** The most recent pointer position in screen space. */
3738
- currentScreenPoint: Vec;
3739
- /** The most recent pointer position in the current page space. */
3740
- currentPagePoint: Vec;
3741
- /** The previous pointer position in screen space. */
3742
- previousScreenPoint: Vec;
3743
- /** The previous pointer position in the current page space. */
3744
- previousPagePoint: Vec;
3745
- /** Velocity of mouse pointer, in pixels per millisecond */
3746
- pointerVelocity: Vec;
3747
- /** Whether the alt or option key is currently pressed. */
3748
- altKey: boolean;
3749
- /** Whether the control or command key is currently pressed. */
3750
- ctrlKey: boolean;
3751
- /** Whether the input is from a pe. */
3752
- isPen: boolean;
3753
- /** Whether the meta key is currently pressed. */
3754
- metaKey: boolean;
3755
- /** Whether the shift key is currently pressed. */
3756
- shiftKey: boolean;
3757
- /** Whether the user is dragging. */
3758
- isDragging: boolean;
3759
- /** Whether the user is editing. */
3760
- isEditing: boolean;
3761
- /** Whether the user is panning. */
3762
- isPanning: boolean;
3763
- /** Whether the user is pinching. */
3764
- isPinching: boolean;
3765
- /** Whether the user is pointing. */
3766
- isPointing: boolean;
3767
- /** Whether the user is spacebar panning. */
3768
- isSpacebarPanning: boolean;
3769
- };
3770
- /**
3771
- * Update the input points from a pointer, pinch, or wheel event.
3772
- *
3773
- * @param info - The event info.
3774
- */
3775
- private _updateInputsFromEvent;
3776
3806
  /**
3777
3807
  * Dispatch a cancel event.
3778
3808
  *
@@ -4018,7 +4048,6 @@ export declare class Editor extends EventEmitter<TLEventMap> {
4018
4048
  /* Excluded from this release type: _metaKeyTimeout */
4019
4049
  /* Excluded from this release type: _setMetaKeyTimeout */
4020
4050
  /* Excluded from this release type: _restoreToolId */
4021
- /* Excluded from this release type: _pinchStart */
4022
4051
  /* Excluded from this release type: _didPinch */
4023
4052
  /* Excluded from this release type: _selectedShapeIdsAtPointerDown */
4024
4053
  /* Excluded from this release type: _longPressTimeout */
@@ -4093,7 +4122,7 @@ export declare class EditorAtom<T> {
4093
4122
  export declare const EditorContext: React_3.Context<Editor | null>;
4094
4123
 
4095
4124
  /** @public @react */
4096
- export declare function EditorProvider({ editor, children }: EditorProviderProps): JSX_2.Element;
4125
+ export declare function EditorProvider({ editor, children }: EditorProviderProps): JSX.Element;
4097
4126
 
4098
4127
  /** @public */
4099
4128
  export declare interface EditorProviderProps {
@@ -4124,7 +4153,7 @@ export declare class Ellipse2d extends Geometry2d {
4124
4153
  }
4125
4154
 
4126
4155
  /** @public */
4127
- export declare class ErrorBoundary extends React_2.Component<React_2.PropsWithRef<React_2.PropsWithChildren<TLErrorBoundaryProps>>, {
4156
+ export declare class ErrorBoundary extends React_2.Component<React_2.PropsWithChildren<TLErrorBoundaryProps>, {
4128
4157
  error: Error | null;
4129
4158
  }> {
4130
4159
  static getDerivedStateFromError(error: Error): {
@@ -4134,11 +4163,11 @@ export declare class ErrorBoundary extends React_2.Component<React_2.PropsWithRe
4134
4163
  error: null;
4135
4164
  };
4136
4165
  componentDidCatch(error: unknown): void;
4137
- render(): boolean | JSX_2.Element | Iterable<React_2.ReactNode> | null | number | string | undefined;
4166
+ render(): bigint | boolean | JSX.Element | Iterable<React_2.ReactNode> | null | number | Promise<bigint | boolean | Iterable<React_2.ReactNode> | null | number | React_2.ReactElement<unknown, React_2.JSXElementConstructor<any> | string> | React_2.ReactPortal | string | undefined> | string | undefined;
4138
4167
  }
4139
4168
 
4140
4169
  /** @public @react */
4141
- export declare function ErrorScreen({ children }: LoadingScreenProps): JSX_2.Element;
4170
+ export declare function ErrorScreen({ children }: LoadingScreenProps): JSX.Element;
4142
4171
 
4143
4172
  /** @public */
4144
4173
  export declare const EVENT_NAME_MAP: Record<Exclude<TLEventName, TLPinchEventName>, keyof TLEventHandlers>;
@@ -4438,8 +4467,8 @@ export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
4438
4467
  canResizeChildren(): boolean;
4439
4468
  getDefaultProps(): TLGroupShape['props'];
4440
4469
  getGeometry(shape: TLGroupShape): Geometry2d;
4441
- component(shape: TLGroupShape): JSX_2.Element | null;
4442
- indicator(shape: TLGroupShape): JSX_2.Element;
4470
+ component(shape: TLGroupShape): JSX.Element | null;
4471
+ indicator(shape: TLGroupShape): JSX.Element;
4443
4472
  onChildrenChange(group: TLGroupShape): void;
4444
4473
  }
4445
4474
 
@@ -4543,7 +4572,7 @@ export declare class HistoryManager<R extends UnknownRecord> {
4543
4572
  }
4544
4573
 
4545
4574
  /** @public @react */
4546
- export declare function HTMLContainer({ children, className, ...rest }: HTMLContainerProps): JSX_2.Element;
4575
+ export declare function HTMLContainer({ children, className, ...rest }: HTMLContainerProps): JSX.Element;
4547
4576
 
4548
4577
  /** @public */
4549
4578
  export declare type HTMLContainerProps = React_2.HTMLAttributes<HTMLDivElement>;
@@ -4551,6 +4580,248 @@ export declare type HTMLContainerProps = React_2.HTMLAttributes<HTMLDivElement>;
4551
4580
  /** @public */
4552
4581
  export declare const inlineBase64AssetStore: TLAssetStore;
4553
4582
 
4583
+ /** @public */
4584
+ export declare class InputsManager {
4585
+ private readonly editor;
4586
+ constructor(editor: Editor);
4587
+ private _originPagePoint;
4588
+ /**
4589
+ * The most recent pointer down's position in the current page space.
4590
+ */
4591
+ getOriginPagePoint(): Vec;
4592
+ /**
4593
+ * @deprecated Use `getOriginPagePoint()` instead.
4594
+ */
4595
+ get originPagePoint(): Vec;
4596
+ private _originScreenPoint;
4597
+ /**
4598
+ * The most recent pointer down's position in screen space.
4599
+ */
4600
+ getOriginScreenPoint(): Vec;
4601
+ /**
4602
+ * @deprecated Use `getOriginScreenPoint()` instead.
4603
+ */
4604
+ get originScreenPoint(): Vec;
4605
+ private _previousPagePoint;
4606
+ /**
4607
+ * The previous pointer position in the current page space.
4608
+ */
4609
+ getPreviousPagePoint(): Vec;
4610
+ /**
4611
+ * @deprecated Use `getPreviousPagePoint()` instead.
4612
+ */
4613
+ get previousPagePoint(): Vec;
4614
+ private _previousScreenPoint;
4615
+ /**
4616
+ * The previous pointer position in screen space.
4617
+ */
4618
+ getPreviousScreenPoint(): Vec;
4619
+ /**
4620
+ * @deprecated Use `getPreviousScreenPoint()` instead.
4621
+ */
4622
+ get previousScreenPoint(): Vec;
4623
+ private _currentPagePoint;
4624
+ /**
4625
+ * The most recent pointer position in the current page space.
4626
+ */
4627
+ getCurrentPagePoint(): Vec;
4628
+ /**
4629
+ * @deprecated Use `getCurrentPagePoint()` instead.
4630
+ */
4631
+ get currentPagePoint(): Vec;
4632
+ private _currentScreenPoint;
4633
+ /**
4634
+ * The most recent pointer position in screen space.
4635
+ */
4636
+ getCurrentScreenPoint(): Vec;
4637
+ /**
4638
+ * @deprecated Use `getCurrentScreenPoint()` instead.
4639
+ */
4640
+ get currentScreenPoint(): Vec;
4641
+ private _pointerVelocity;
4642
+ /**
4643
+ * Velocity of mouse pointer, in pixels per millisecond.
4644
+ */
4645
+ getPointerVelocity(): Vec;
4646
+ /**
4647
+ * @deprecated Use `getPointerVelocity()` instead.
4648
+ */
4649
+ get pointerVelocity(): Vec;
4650
+ /* Excluded from this release type: setPointerVelocity */
4651
+ /**
4652
+ * A set containing the currently pressed keys.
4653
+ */
4654
+ readonly keys: AtomSet<string>;
4655
+ /**
4656
+ * A set containing the currently pressed buttons.
4657
+ */
4658
+ readonly buttons: AtomSet<number>;
4659
+ private _isPen;
4660
+ /**
4661
+ * Whether the input is from a pen.
4662
+ */
4663
+ getIsPen(): boolean;
4664
+ /**
4665
+ * @deprecated Use `getIsPen()` instead.
4666
+ */
4667
+ get isPen(): boolean;
4668
+ set isPen(isPen: boolean);
4669
+ /**
4670
+ * @param isPen - Whether the input is from a pen.
4671
+ */
4672
+ setIsPen(isPen: boolean): void;
4673
+ private _shiftKey;
4674
+ /**
4675
+ * Whether the shift key is currently pressed.
4676
+ */
4677
+ getShiftKey(): boolean;
4678
+ /**
4679
+ * @deprecated Use `getShiftKey()` instead.
4680
+ */
4681
+ get shiftKey(): boolean;
4682
+ set shiftKey(shiftKey: boolean);
4683
+ /* Excluded from this release type: setShiftKey */
4684
+ private _metaKey;
4685
+ /**
4686
+ * Whether the meta key is currently pressed.
4687
+ */
4688
+ getMetaKey(): boolean;
4689
+ /**
4690
+ * @deprecated Use `getMetaKey()` instead.
4691
+ */
4692
+ get metaKey(): boolean;
4693
+ set metaKey(metaKey: boolean);
4694
+ /* Excluded from this release type: setMetaKey */
4695
+ private _ctrlKey;
4696
+ /**
4697
+ * Whether the ctrl or command key is currently pressed.
4698
+ */
4699
+ getCtrlKey(): boolean;
4700
+ /**
4701
+ * @deprecated Use `getCtrlKey()` instead.
4702
+ */
4703
+ get ctrlKey(): boolean;
4704
+ set ctrlKey(ctrlKey: boolean);
4705
+ /* Excluded from this release type: setCtrlKey */
4706
+ private _altKey;
4707
+ /**
4708
+ * Whether the alt or option key is currently pressed.
4709
+ */
4710
+ getAltKey(): boolean;
4711
+ /**
4712
+ * @deprecated Use `getAltKey()` instead.
4713
+ */
4714
+ get altKey(): boolean;
4715
+ set altKey(altKey: boolean);
4716
+ /* Excluded from this release type: setAltKey */
4717
+ /**
4718
+ * Is the accelerator key (cmd on mac, ctrl elsewhere) currently pressed.
4719
+ */
4720
+ getAccelKey(): boolean;
4721
+ /**
4722
+ * @deprecated Use `getAccelKey()` instead.
4723
+ */
4724
+ get accelKey(): boolean;
4725
+ private _isDragging;
4726
+ /**
4727
+ * Whether the user is dragging.
4728
+ */
4729
+ getIsDragging(): boolean;
4730
+ /**
4731
+ * Soon to be deprecated, use `getIsDragging()` instead.
4732
+ */
4733
+ get isDragging(): boolean;
4734
+ set isDragging(isDragging: boolean);
4735
+ /**
4736
+ * @param isDragging - Whether the user is dragging.
4737
+ */
4738
+ setIsDragging(isDragging: boolean): void;
4739
+ private _isPointing;
4740
+ /**
4741
+ * Whether the user is pointing.
4742
+ */
4743
+ getIsPointing(): boolean;
4744
+ /**
4745
+ * @deprecated Use `getIsPointing()` instead.
4746
+ */
4747
+ get isPointing(): boolean;
4748
+ set isPointing(isPointing: boolean);
4749
+ /* Excluded from this release type: setIsPointing */
4750
+ private _isPinching;
4751
+ /**
4752
+ * Whether the user is pinching.
4753
+ */
4754
+ getIsPinching(): boolean;
4755
+ /**
4756
+ * @deprecated Use `getIsPinching()` instead.
4757
+ */
4758
+ get isPinching(): boolean;
4759
+ set isPinching(isPinching: boolean);
4760
+ /* Excluded from this release type: setIsPinching */
4761
+ private _isEditing;
4762
+ /**
4763
+ * Whether the user is editing.
4764
+ */
4765
+ getIsEditing(): boolean;
4766
+ /**
4767
+ * @deprecated Use `getIsEditing()` instead.
4768
+ */
4769
+ get isEditing(): boolean;
4770
+ set isEditing(isEditing: boolean);
4771
+ /**
4772
+ * @param isEditing - Whether the user is editing.
4773
+ */
4774
+ setIsEditing(isEditing: boolean): void;
4775
+ private _isPanning;
4776
+ /**
4777
+ * Whether the user is panning.
4778
+ */
4779
+ getIsPanning(): boolean;
4780
+ /**
4781
+ * @deprecated Use `getIsPanning()` instead.
4782
+ */
4783
+ get isPanning(): boolean;
4784
+ set isPanning(isPanning: boolean);
4785
+ /* Excluded from this release type: setIsPanning */
4786
+ private _isSpacebarPanning;
4787
+ /**
4788
+ * Whether the user is spacebar panning.
4789
+ */
4790
+ getIsSpacebarPanning(): boolean;
4791
+ /**
4792
+ * @deprecated Use `getIsSpacebarPanning()` instead.
4793
+ */
4794
+ get isSpacebarPanning(): boolean;
4795
+ set isSpacebarPanning(isSpacebarPanning: boolean);
4796
+ /* Excluded from this release type: setIsSpacebarPanning */
4797
+ private _getHasCollaborators;
4798
+ /* Excluded from this release type: _velocityPrevPoint */
4799
+ /* Excluded from this release type: updatePointerVelocity */
4800
+ /* Excluded from this release type: updateFromEvent */
4801
+ toJson(): {
4802
+ altKey: boolean;
4803
+ buttons: number[];
4804
+ ctrlKey: boolean;
4805
+ currentPagePoint: VecModel;
4806
+ currentScreenPoint: VecModel;
4807
+ isDragging: boolean;
4808
+ isEditing: boolean;
4809
+ isPanning: boolean;
4810
+ isPen: boolean;
4811
+ isPinching: boolean;
4812
+ isPointing: boolean;
4813
+ isSpacebarPanning: boolean;
4814
+ keys: string[];
4815
+ metaKey: boolean;
4816
+ originPagePoint: VecModel;
4817
+ originScreenPoint: VecModel;
4818
+ pointerVelocity: VecModel;
4819
+ previousPagePoint: VecModel;
4820
+ previousScreenPoint: VecModel;
4821
+ shiftKey: boolean;
4822
+ };
4823
+ }
4824
+
4554
4825
  /**
4555
4826
  * Find the intersections between a circle and a circle.
4556
4827
  *
@@ -4680,7 +4951,7 @@ export declare function kickoutOccludedShapes(editor: Editor, shapeIds: TLShapeI
4680
4951
  export declare function linesIntersect(A: VecLike, B: VecLike, C: VecLike, D: VecLike): boolean;
4681
4952
 
4682
4953
  /** @public @react */
4683
- export declare function LoadingScreen({ children }: LoadingScreenProps): JSX_2.Element;
4954
+ export declare function LoadingScreen({ children }: LoadingScreenProps): JSX.Element;
4684
4955
 
4685
4956
  /** @public */
4686
4957
  export declare interface LoadingScreenProps {
@@ -4798,7 +5069,7 @@ export declare function maybeSnapToGrid(point: Vec, editor: Editor): Vec;
4798
5069
  *
4799
5070
  * @public @react
4800
5071
  */
4801
- export declare function MenuClickCapture(): false | JSX_2.Element;
5072
+ export declare function MenuClickCapture(): false | JSX.Element;
4802
5073
 
4803
5074
  /* Excluded from this release type: normalizeWheel */
4804
5075
 
@@ -5231,20 +5502,20 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
5231
5502
  * @param shape - The shape.
5232
5503
  * @public
5233
5504
  */
5234
- canSnap(_shape: Shape): boolean;
5505
+ canSnap(shape: Shape): boolean;
5235
5506
  /**
5236
5507
  * Whether the shape can be tabbed to.
5237
5508
  *
5238
5509
  * @param shape - The shape.
5239
5510
  * @public
5240
5511
  */
5241
- canTabTo(_shape: Shape): boolean;
5512
+ canTabTo(shape: Shape): boolean;
5242
5513
  /**
5243
5514
  * Whether the shape can be scrolled while editing.
5244
5515
  *
5245
5516
  * @public
5246
5517
  */
5247
- canScroll(_shape: Shape): boolean;
5518
+ canScroll(shape: Shape): boolean;
5248
5519
  /**
5249
5520
  * Whether the shape can be bound to. See {@link TLShapeUtilCanBindOpts} for details.
5250
5521
  *
@@ -5256,31 +5527,37 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
5256
5527
  *
5257
5528
  * @public
5258
5529
  */
5259
- canEdit(_shape: Shape): boolean;
5530
+ canEdit(shape: Shape, info: TLEditStartInfo): boolean;
5260
5531
  /**
5261
5532
  * Whether the shape can be resized.
5262
5533
  *
5263
5534
  * @public
5264
5535
  */
5265
- canResize(_shape: Shape): boolean;
5536
+ canResize(shape: Shape): boolean;
5266
5537
  /**
5267
5538
  * When the shape is resized, whether the shape's children should also be resized.
5268
5539
  *
5269
5540
  * @public
5270
5541
  */
5271
- canResizeChildren(_shape: Shape): boolean;
5542
+ canResizeChildren(shape: Shape): boolean;
5272
5543
  /**
5273
5544
  * Whether the shape can be edited in read-only mode.
5274
5545
  *
5275
5546
  * @public
5276
5547
  */
5277
- canEditInReadonly(_shape: Shape): boolean;
5548
+ canEditInReadonly(shape: Shape): boolean;
5549
+ /**
5550
+ * Whether the shape can be edited while locked or while an ancestor is locked.
5551
+ *
5552
+ * @public
5553
+ */
5554
+ canEditWhileLocked(shape: Shape): boolean;
5278
5555
  /**
5279
5556
  * Whether the shape can be cropped.
5280
5557
  *
5281
5558
  * @public
5282
5559
  */
5283
- canCrop(_shape: Shape): boolean;
5560
+ canCrop(shape: Shape): boolean;
5284
5561
  /**
5285
5562
  * Whether the shape can participate in layout functions such as alignment or distribution.
5286
5563
  *
@@ -5290,7 +5567,7 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
5290
5567
  *
5291
5568
  * @public
5292
5569
  */
5293
- canBeLaidOut(_shape: Shape, _info: TLShapeUtilCanBeLaidOutOpts): boolean;
5570
+ canBeLaidOut(shape: Shape, info: TLShapeUtilCanBeLaidOutOpts): boolean;
5294
5571
  /**
5295
5572
  * Whether this shape can be culled. By default, shapes are culled for
5296
5573
  * performance reasons when they are outside of the viewport. Culled shapes are still rendered
@@ -5298,11 +5575,31 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
5298
5575
  *
5299
5576
  * @param shape - The shape.
5300
5577
  */
5301
- canCull(_shape: Shape): boolean;
5578
+ canCull(shape: Shape): boolean;
5302
5579
  /* Excluded from this release type: providesBackgroundForChildren */
5303
5580
  /**
5304
5581
  * Get the clip path to apply to this shape's children.
5305
5582
  *
5583
+ * The returned points should define the **inner** clip boundary - the area where
5584
+ * children will be visible. If your shape has a stroke, you should inset the clip
5585
+ * path by half the stroke width so children are clipped to the inner edge of the
5586
+ * stroke rather than its center line.
5587
+ *
5588
+ * @example
5589
+ * ```ts
5590
+ * override getClipPath(shape: MyShape): Vec[] | undefined {
5591
+ * const strokeWidth = 2
5592
+ * const inset = strokeWidth / 2
5593
+ * // Return points inset by half the stroke width
5594
+ * return [
5595
+ * new Vec(inset, inset),
5596
+ * new Vec(shape.props.w - inset, inset),
5597
+ * new Vec(shape.props.w - inset, shape.props.h - inset),
5598
+ * new Vec(inset, shape.props.h - inset),
5599
+ * ]
5600
+ * }
5601
+ * ```
5602
+ *
5306
5603
  * @param shape - The shape to get the clip path for
5307
5604
  * @returns Array of points defining the clipping polygon in local coordinates, or undefined if no clipping
5308
5605
  * @public
@@ -5327,37 +5624,37 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
5327
5624
  * @returns boolean indicating if this shape should hide in the minimap
5328
5625
  * @public
5329
5626
  */
5330
- hideInMinimap?(_shape: Shape): boolean;
5627
+ hideInMinimap?(shape: Shape): boolean;
5331
5628
  /**
5332
5629
  * Whether the shape should hide its resize handles when selected.
5333
5630
  *
5334
5631
  * @public
5335
5632
  */
5336
- hideResizeHandles(_shape: Shape): boolean;
5633
+ hideResizeHandles(shape: Shape): boolean;
5337
5634
  /**
5338
5635
  * Whether the shape should hide its rotation handles when selected.
5339
5636
  *
5340
5637
  * @public
5341
5638
  */
5342
- hideRotateHandle(_shape: Shape): boolean;
5639
+ hideRotateHandle(shape: Shape): boolean;
5343
5640
  /**
5344
5641
  * Whether the shape should hide its selection bounds background when selected.
5345
5642
  *
5346
5643
  * @public
5347
5644
  */
5348
- hideSelectionBoundsBg(_shape: Shape): boolean;
5645
+ hideSelectionBoundsBg(shape: Shape): boolean;
5349
5646
  /**
5350
5647
  * Whether the shape should hide its selection bounds foreground when selected.
5351
5648
  *
5352
5649
  * @public
5353
5650
  */
5354
- hideSelectionBoundsFg(_shape: Shape): boolean;
5651
+ hideSelectionBoundsFg(shape: Shape): boolean;
5355
5652
  /**
5356
5653
  * Whether the shape's aspect ratio is locked.
5357
5654
  *
5358
5655
  * @public
5359
5656
  */
5360
- isAspectRatioLocked(_shape: Shape): boolean;
5657
+ isAspectRatioLocked(shape: Shape): boolean;
5361
5658
  /**
5362
5659
  * By default, the bounds of an image export are the bounds of all the shapes it contains, plus
5363
5660
  * some padding. If an export includes a shape where `isExportBoundsContainer` is true, then the
@@ -5365,10 +5662,10 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
5365
5662
  * useful in cases like annotating on top of an image, where you usually want to avoid extra
5366
5663
  * padding around the image if you don't need it.
5367
5664
  *
5368
- * @param _shape - The shape to check
5665
+ * @param shape - The shape to check
5369
5666
  * @returns True if this shape should be treated as an export bounds container
5370
5667
  */
5371
- isExportBoundsContainer(_shape: Shape): boolean;
5668
+ isExportBoundsContainer(shape: Shape): boolean;
5372
5669
  /* Excluded from this release type: backgroundComponent */
5373
5670
  /**
5374
5671
  * Get the interpolated props for an animating shape. This is an optional method.
@@ -5405,7 +5702,7 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
5405
5702
  * @param type - The shape type.
5406
5703
  * @public
5407
5704
  */
5408
- canReceiveNewChildrenOfType(_shape: Shape, _type: TLShape['type']): boolean;
5705
+ canReceiveNewChildrenOfType(shape: Shape, _type: TLShape['type']): boolean;
5409
5706
  /**
5410
5707
  * Get the shape as an SVG object.
5411
5708
  *
@@ -5438,14 +5735,14 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
5438
5735
  * Get the geometry to use when snapping to this this shape in translate/resize operations. See
5439
5736
  * {@link BoundsSnapGeometry} for details.
5440
5737
  */
5441
- getBoundsSnapGeometry(_shape: Shape): BoundsSnapGeometry;
5738
+ getBoundsSnapGeometry(shape: Shape): BoundsSnapGeometry;
5442
5739
  /**
5443
5740
  * Get the geometry to use when snapping handles to this shape. See {@link HandleSnapGeometry}
5444
5741
  * for details.
5445
5742
  */
5446
- getHandleSnapGeometry(_shape: Shape): HandleSnapGeometry;
5447
- getText(_shape: Shape): string | undefined;
5448
- getAriaDescriptor(_shape: Shape): string | undefined;
5743
+ getHandleSnapGeometry(shape: Shape): HandleSnapGeometry;
5744
+ getText(shape: Shape): string | undefined;
5745
+ getAriaDescriptor(shape: Shape): string | undefined;
5449
5746
  /**
5450
5747
  * A callback called just before a shape is created. This method provides a last chance to modify
5451
5748
  * the created shape.
@@ -5803,6 +6100,77 @@ export declare class SnapManager {
5803
6100
  getCurrentCommonAncestor(): TLShapeId | undefined;
5804
6101
  }
5805
6102
 
6103
+ /**
6104
+ * Manages spatial indexing for efficient shape location queries.
6105
+ *
6106
+ * Uses an R-tree (via RBush) to enable O(log n) spatial queries instead of O(n) iteration.
6107
+ * Handles shapes with computed bounds (arrows, groups, custom shapes) by checking all shapes'
6108
+ * bounds on each update using the reactive bounds cache.
6109
+ *
6110
+ * Key features:
6111
+ * - Incremental updates using filterHistory pattern
6112
+ * - Leverages existing bounds cache reactivity for dependency tracking
6113
+ * - Works with any custom shape type with computed bounds
6114
+ * - Per-page index (rebuilds on page change)
6115
+ * - Optimized for viewport culling queries
6116
+ *
6117
+ * @public
6118
+ */
6119
+ export declare class SpatialIndexManager {
6120
+ readonly editor: Editor;
6121
+ private rbush;
6122
+ private spatialIndexComputed;
6123
+ private lastPageId;
6124
+ constructor(editor: Editor);
6125
+ private createSpatialIndexComputed;
6126
+ private buildFromScratch;
6127
+ private processIncrementalUpdate;
6128
+ private areBoundsEqual;
6129
+ /**
6130
+ * Get shape IDs within the given bounds.
6131
+ * Optimized for viewport culling queries.
6132
+ *
6133
+ * Note: Results are unordered. If you need z-order, combine with sorted shapes:
6134
+ * ```ts
6135
+ * const candidates = editor.spatialIndex.getShapeIdsInsideBounds(bounds)
6136
+ * const sorted = editor.getCurrentPageShapesSorted().filter(s => candidates.has(s.id))
6137
+ * ```
6138
+ *
6139
+ * @param bounds - The bounds to search within
6140
+ * @returns Unordered set of shape IDs within the bounds
6141
+ *
6142
+ * @public
6143
+ */
6144
+ getShapeIdsInsideBounds(bounds: Box): Set<TLShapeId>;
6145
+ /**
6146
+ * Get shape IDs at a point (with optional margin).
6147
+ * Creates a small bounding box around the point and searches the spatial index.
6148
+ *
6149
+ * Note: Results are unordered. If you need z-order, combine with sorted shapes:
6150
+ * ```ts
6151
+ * const candidates = editor.spatialIndex.getShapeIdsAtPoint(point, margin)
6152
+ * const sorted = editor.getCurrentPageShapesSorted().filter(s => candidates.has(s.id))
6153
+ * ```
6154
+ *
6155
+ * @param point - The point to search at
6156
+ * @param margin - The margin around the point to search (default: 0)
6157
+ * @returns Unordered set of shape IDs that could potentially contain the point
6158
+ *
6159
+ * @public
6160
+ */
6161
+ getShapeIdsAtPoint(point: {
6162
+ x: number;
6163
+ y: number;
6164
+ }, margin?: number): Set<TLShapeId>;
6165
+ /**
6166
+ * Dispose of the spatial index manager.
6167
+ * Clears the R-tree to prevent memory leaks.
6168
+ *
6169
+ * @public
6170
+ */
6171
+ dispose(): void;
6172
+ }
6173
+
5806
6174
  /** @public */
5807
6175
  export declare class Stadium2d extends Geometry2d {
5808
6176
  config: Omit<Geometry2dOptions, 'isClosed'> & {
@@ -5940,7 +6308,7 @@ export declare const stopEventPropagation: (e: any) => any;
5940
6308
  export declare function suffixSafeId(id: SafeId, suffix: string): SafeId;
5941
6309
 
5942
6310
  /** @public @react */
5943
- export declare function SVGContainer({ children, className, ...rest }: SVGContainerProps): JSX_2.Element;
6311
+ export declare function SVGContainer({ children, className, ...rest }: SVGContainerProps): JSX.Element;
5944
6312
 
5945
6313
  /** @public */
5946
6314
  export declare type SVGContainerProps = React_2.ComponentProps<'svg'>;
@@ -6038,6 +6406,8 @@ export declare class TextManager {
6038
6406
  }[];
6039
6407
  }
6040
6408
 
6409
+ /* Excluded from this release type: TickManager */
6410
+
6041
6411
  /**
6042
6412
  * This is the TipTap editor! Docs are {@link https://tiptap.dev/docs}.
6043
6413
  *
@@ -6589,6 +6959,33 @@ export declare interface TldrawOptions {
6589
6959
  * Branding name of the app, currently only used for adding aria-label for the application.
6590
6960
  */
6591
6961
  readonly branding?: string;
6962
+ /**
6963
+ * Whether to use debounced zoom level for certain rendering optimizations. When true,
6964
+ * `editor.getDebouncedZoomLevel()` returns a cached zoom value while the camera is moving,
6965
+ * reducing re-renders. When false, it always returns the current zoom level.
6966
+ */
6967
+ readonly debouncedZoom: boolean;
6968
+ /**
6969
+ * The number of shapes that must be on the page for the debounced zoom level to be used.
6970
+ * Defaults to 300 shapes.
6971
+ */
6972
+ readonly debouncedZoomThreshold: number;
6973
+ /**
6974
+ * Whether to allow spacebar panning. When true, the spacebar will pan the camera when held down.
6975
+ * When false, the spacebar will not pan the camera.
6976
+ */
6977
+ readonly spacebarPanning: boolean;
6978
+ /**
6979
+ * The default padding (in pixels) used when zooming to fit content in the viewport.
6980
+ * This affects methods like `zoomToFit()`, `zoomToSelection()`, and `zoomToBounds()`.
6981
+ * The actual padding used is the minimum of this value and 28% of the viewport width.
6982
+ * Defaults to 128 pixels.
6983
+ */
6984
+ readonly zoomToFitPadding: number;
6985
+ /**
6986
+ * The distance (in screen pixels) at which shapes snap to guides and other shapes.
6987
+ */
6988
+ readonly snapThreshold: number;
6592
6989
  }
6593
6990
 
6594
6991
  /** @public */
@@ -6634,7 +7031,7 @@ export declare interface TLEditorComponents {
6634
7031
  /** @public */
6635
7032
  export declare interface TLEditorOptions {
6636
7033
  /**
6637
- * The Store instance to use for keeping the app's data. This may be prepopulated, e.g. by loading
7034
+ * The Store instance to use for keeping the editor's data. This may be prepopulated, e.g. by loading
6638
7035
  * from a server or database.
6639
7036
  */
6640
7037
  store: TLStore;
@@ -6713,6 +7110,11 @@ export declare interface TLEditorSnapshot {
6713
7110
  session: TLSessionStateSnapshot;
6714
7111
  }
6715
7112
 
7113
+ /** @public */
7114
+ export declare interface TLEditStartInfo {
7115
+ type: 'click-header' | 'click' | 'double-click-corner' | 'double-click-edge' | 'double-click' | 'press_enter' | 'unknown';
7116
+ }
7117
+
6716
7118
  /** @public */
6717
7119
  export declare interface TLEmbedExternalContent<EmbedDefinition> extends TLBaseExternalContent {
6718
7120
  type: 'embed';
@@ -6725,6 +7127,8 @@ export declare type TLEnterEventHandler = (info: any, from: string) => void;
6725
7127
 
6726
7128
  /**
6727
7129
  * An object that contains information about the current device and environment.
7130
+ * This object is not reactive and will not update automatically when the environment changes,
7131
+ * so only include values that are fixed, such as the user's browser and operating system.
6728
7132
  *
6729
7133
  * @public
6730
7134
  */
@@ -6739,6 +7143,17 @@ export declare const tlenv: {
6739
7143
  isWebview: boolean;
6740
7144
  };
6741
7145
 
7146
+ /**
7147
+ * An atom that contains information about the current device and environment.
7148
+ * This object is reactive and will update automatically when the environment changes.
7149
+ * Use it for values that may change over time, such as the pointer type.
7150
+ *
7151
+ * @public
7152
+ */
7153
+ export declare const tlenvReactive: Atom< {
7154
+ isCoarsePointer: boolean;
7155
+ }, unknown>;
7156
+
6742
7157
  /** @public */
6743
7158
  export declare interface TLErrorBoundaryProps {
6744
7159
  children: React_2.ReactNode;
@@ -6802,6 +7217,7 @@ export declare interface TLEventMap {
6802
7217
  event: [TLEventInfo];
6803
7218
  tick: [number];
6804
7219
  frame: [number];
7220
+ resize: [BoxModel];
6805
7221
  'select-all-text': [{
6806
7222
  shapeId: TLShapeId;
6807
7223
  }];
@@ -6816,6 +7232,7 @@ export declare interface TLEventMap {
6816
7232
  'edited-shapes': [TLRecord[]];
6817
7233
  'deleted-shapes': [TLShapeId[]];
6818
7234
  edit: [];
7235
+ dispose: [];
6819
7236
  }
6820
7237
 
6821
7238
  /** @public */
@@ -7913,10 +8330,10 @@ export declare function useMaybeEditor(): Editor | null;
7913
8330
  /* Excluded from this release type: useOnMount */
7914
8331
 
7915
8332
  /** @public */
7916
- export declare function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement>): void;
8333
+ export declare function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement | null>): void;
7917
8334
 
7918
8335
  /** @public */
7919
- export declare function usePassThroughWheelEvents(ref: RefObject<HTMLElement>): void;
8336
+ export declare function usePassThroughWheelEvents(ref: RefObject<HTMLElement | null>): void;
7920
8337
 
7921
8338
  /**
7922
8339
  * @returns The list of peer UserIDs
@@ -8024,7 +8441,7 @@ export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreS
8024
8441
  export declare function useTLStore(opts: TLStoreOptions): TLStore;
8025
8442
 
8026
8443
  /** @public */
8027
- export declare function useTransform(ref: React.RefObject<HTMLElement | SVGElement>, x?: number, y?: number, scale?: number, rotate?: number, additionalOffset?: VecLike): void;
8444
+ export declare function useTransform(ref: React.RefObject<HTMLElement | null | SVGElement>, x?: number, y?: number, scale?: number, rotate?: number, additionalOffset?: VecLike): void;
8028
8445
 
8029
8446
  /**
8030
8447
  * React's useId hook returns a unique id for the component. However, it uses a colon in the id,