@tldraw/editor 5.1.0-next.d7c83ba698ae → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +19 -2
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +3 -5
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +23 -21
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +2 -2
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +27 -8
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +4 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js +8 -0
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +7 -1
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/RBushIndex.js +13 -15
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/RBushIndex.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +43 -24
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
- package/dist-cjs/lib/editor/overlays/OverlayManager.js +5 -0
- package/dist-cjs/lib/editor/overlays/OverlayManager.js.map +2 -2
- package/dist-cjs/lib/editor/overlays/OverlayUtil.js +5 -0
- package/dist-cjs/lib/editor/overlays/OverlayUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +1 -1
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/hooks/usePeerIds.js.map +2 -2
- package/dist-cjs/lib/options.js +1 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/utils/dom.js +1 -0
- package/dist-cjs/lib/utils/dom.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +19 -2
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +3 -5
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +23 -21
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +27 -11
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +4 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +2 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs +8 -0
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +7 -1
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SpatialIndexManager/RBushIndex.mjs +13 -15
- package/dist-esm/lib/editor/managers/SpatialIndexManager/RBushIndex.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +43 -24
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
- package/dist-esm/lib/editor/overlays/OverlayManager.mjs +5 -0
- package/dist-esm/lib/editor/overlays/OverlayManager.mjs.map +2 -2
- package/dist-esm/lib/editor/overlays/OverlayUtil.mjs +5 -0
- package/dist-esm/lib/editor/overlays/OverlayUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +1 -1
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePeerIds.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +1 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/utils/dom.mjs +1 -0
- package/dist-esm/lib/utils/dom.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +3 -5
- package/src/lib/editor/derivations/notVisibleShapes.ts +34 -26
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.test.ts +132 -0
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +40 -12
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +12 -2
- package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +7 -0
- package/src/lib/editor/managers/FocusManager/FocusManager.ts +2 -2
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +33 -2
- package/src/lib/editor/managers/FontManager/FontManager.ts +20 -2
- package/src/lib/editor/managers/InputsManager/InputsManager.ts +11 -2
- package/src/lib/editor/managers/SpatialIndexManager/RBushIndex.ts +13 -14
- package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +67 -40
- package/src/lib/editor/overlays/OverlayManager.ts +6 -0
- package/src/lib/editor/overlays/OverlayUtil.ts +5 -0
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -1
- package/src/lib/hooks/usePeerIds.ts +1 -0
- package/src/lib/options.ts +8 -0
- package/src/lib/utils/dom.ts +1 -0
- package/src/version.ts +3 -3
- package/dist-cjs/lib/utils/collaboratorState.js +0 -42
- package/dist-cjs/lib/utils/collaboratorState.js.map +0 -7
- package/dist-esm/lib/utils/collaboratorState.mjs +0 -22
- package/dist-esm/lib/utils/collaboratorState.mjs.map +0 -7
- package/src/lib/utils/collaboratorState.ts +0 -54
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/editor/managers/SpatialIndexManager/RBushIndex.ts"],
|
|
4
|
-
"sourcesContent": ["import type { TLShapeId } from '@tldraw/tlschema'\nimport RBush from 'rbush'\nimport { Box } from '../../../primitives/Box'\n\n/**\n * Element stored in the R-tree spatial index.\n * Contains bounds (minX, minY, maxX, maxY) and shape ID.\n */\nexport interface SpatialElement {\n\tminX: number\n\tminY: number\n\tmaxX: number\n\tmaxY: number\n\tid: TLShapeId\n}\n\n/**\n * Custom RBush class for tldraw shapes.\n */\nclass TldrawRBush extends RBush<SpatialElement> {}\n\n/**\n * Wrapper around RBush R-tree for efficient spatial queries.\n * Maintains a map of elements currently in the tree for efficient updates.\n */\nexport class RBushIndex {\n\tprivate rBush: TldrawRBush\n\tprivate elementsInTree: Map<TLShapeId, SpatialElement>\n\n\tconstructor() {\n\t\tthis.rBush = new TldrawRBush()\n\t\tthis.elementsInTree = new Map()\n\t}\n\n\t/**\n\t * Search for shapes within the given bounds.\n\t * Returns set of shape IDs that intersect with the bounds.\n\t */\n\tsearch(bounds: Box): Set<TLShapeId> {\n\t\tconst results = this.rBush.search({\n\t\t\tminX: bounds.minX,\n\t\t\tminY: bounds.minY,\n\t\t\tmaxX: bounds.maxX,\n\t\t\tmaxY: bounds.maxY,\n\t\t})\n\t\treturn new Set(results.map((e: SpatialElement) => e.id))\n\t}\n\n\t/**\n\t * Insert or update a shape in the spatial index.\n\t * If the shape already exists, it will be removed first to prevent duplicates.\n\t */\n\tupsert(id: TLShapeId, bounds: Box): void {\n\t\t// Remove existing entry to prevent map-tree desync\n\t\tconst existing = this.elementsInTree.get(id)\n\t\tif (existing) {\n\t\t\tthis.rBush.remove(existing)\n\t\t}\n\n\t\tconst element: SpatialElement = {\n\t\t\tminX: bounds.minX,\n\t\t\tminY: bounds.minY,\n\t\t\tmaxX: bounds.maxX,\n\t\t\tmaxY: bounds.maxY,\n\t\t\tid,\n\t\t}\n\t\tthis.rBush.insert(element)\n\t\tthis.elementsInTree.set(id, element)\n\t}\n\n\t/**\n\t * Remove a shape from the spatial index.\n\t */\n\tremove(id: TLShapeId): void {\n\t\tconst element = this.elementsInTree.get(id)\n\t\tif (element) {\n\t\t\tthis.rBush.remove(element)\n\t\t\tthis.elementsInTree.delete(id)\n\t\t}\n\t}\n\n\t/**\n\t * Bulk load elements into the spatial index.\n\t * More efficient than individual inserts for initial loading.\n\t */\n\tbulkLoad(elements: SpatialElement[]): void {\n\t\tthis.rBush.load(elements)\n\t\tfor (const element of elements) {\n\t\t\tthis.elementsInTree.set(element.id, element)\n\t\t}\n\t}\n\n\t/**\n\t * Clear all elements from the spatial index.\n\t */\n\tclear(): void {\n\t\tthis.rBush.clear()\n\t\tthis.elementsInTree.clear()\n\t}\n\n\t/**\n\t * Check if a shape is in the spatial index.\n\t */\n\thas(id: TLShapeId): boolean {\n\t\treturn this.elementsInTree.has(id)\n\t}\n\n\t/**\n\t * Get the number of elements in the spatial index.\n\t */\n\tgetSize(): number {\n\t\treturn this.elementsInTree.size\n\t}\n\n\t/**\n\t * Get
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;
|
|
4
|
+
"sourcesContent": ["import type { TLShapeId } from '@tldraw/tlschema'\nimport RBush from 'rbush'\nimport { Box } from '../../../primitives/Box'\n\n/**\n * Element stored in the R-tree spatial index.\n * Contains bounds (minX, minY, maxX, maxY) and shape ID.\n */\nexport interface SpatialElement {\n\tminX: number\n\tminY: number\n\tmaxX: number\n\tmaxY: number\n\tid: TLShapeId\n}\n\n/**\n * Custom RBush class for tldraw shapes.\n */\nclass TldrawRBush extends RBush<SpatialElement> {}\n\n/**\n * Wrapper around RBush R-tree for efficient spatial queries.\n * Maintains a map of elements currently in the tree for efficient updates.\n */\nexport class RBushIndex {\n\tprivate rBush: TldrawRBush\n\tprivate elementsInTree: Map<TLShapeId, SpatialElement>\n\n\tconstructor() {\n\t\tthis.rBush = new TldrawRBush()\n\t\tthis.elementsInTree = new Map()\n\t}\n\n\t/**\n\t * Search for shapes within the given bounds.\n\t * Returns set of shape IDs that intersect with the bounds.\n\t */\n\tsearch(bounds: Box): Set<TLShapeId> {\n\t\tconst results = this.rBush.search({\n\t\t\tminX: bounds.minX,\n\t\t\tminY: bounds.minY,\n\t\t\tmaxX: bounds.maxX,\n\t\t\tmaxY: bounds.maxY,\n\t\t})\n\t\treturn new Set(results.map((e: SpatialElement) => e.id))\n\t}\n\n\t/**\n\t * Insert or update a shape in the spatial index.\n\t * If the shape already exists, it will be removed first to prevent duplicates.\n\t */\n\tupsert(id: TLShapeId, bounds: Box): void {\n\t\t// Remove existing entry to prevent map-tree desync\n\t\tconst existing = this.elementsInTree.get(id)\n\t\tif (existing) {\n\t\t\tthis.rBush.remove(existing)\n\t\t}\n\n\t\tconst element: SpatialElement = {\n\t\t\tminX: bounds.minX,\n\t\t\tminY: bounds.minY,\n\t\t\tmaxX: bounds.maxX,\n\t\t\tmaxY: bounds.maxY,\n\t\t\tid,\n\t\t}\n\t\tthis.rBush.insert(element)\n\t\tthis.elementsInTree.set(id, element)\n\t}\n\n\t/**\n\t * Remove a shape from the spatial index.\n\t */\n\tremove(id: TLShapeId): void {\n\t\tconst element = this.elementsInTree.get(id)\n\t\tif (element) {\n\t\t\tthis.rBush.remove(element)\n\t\t\tthis.elementsInTree.delete(id)\n\t\t}\n\t}\n\n\t/**\n\t * Bulk load elements into the spatial index.\n\t * More efficient than individual inserts for initial loading.\n\t */\n\tbulkLoad(elements: SpatialElement[]): void {\n\t\tthis.rBush.load(elements)\n\t\tfor (const element of elements) {\n\t\t\tthis.elementsInTree.set(element.id, element)\n\t\t}\n\t}\n\n\t/**\n\t * Clear all elements from the spatial index.\n\t */\n\tclear(): void {\n\t\tthis.rBush.clear()\n\t\tthis.elementsInTree.clear()\n\t}\n\n\t/**\n\t * Check if a shape is in the spatial index.\n\t */\n\thas(id: TLShapeId): boolean {\n\t\treturn this.elementsInTree.has(id)\n\t}\n\n\t/**\n\t * Get the number of elements in the spatial index.\n\t */\n\tgetSize(): number {\n\t\treturn this.elementsInTree.size\n\t}\n\n\t/**\n\t * Get the raw stored element for a shape, without allocating a Box.\n\t * Use when you only need to read the indexed bounds for comparison.\n\t *\n\t * @internal\n\t */\n\tgetElement(id: TLShapeId): SpatialElement | undefined {\n\t\treturn this.elementsInTree.get(id)\n\t}\n\n\t/**\n\t * Iterate the entries currently in the index. Callers may upsert existing\n\t * keys or remove keys during iteration; current callers do not insert new\n\t * keys.\n\t *\n\t * @internal\n\t */\n\tentries(): IterableIterator<[TLShapeId, SpatialElement]> {\n\t\treturn this.elementsInTree.entries()\n\t}\n\n\t/**\n\t * Dispose of the spatial index.\n\t * Clears all data structures to prevent memory leaks.\n\t */\n\tdispose(): void {\n\t\tthis.clear()\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAkBlB,MAAM,oBAAoB,aAAAA,QAAsB;AAAC;AAM1C,MAAM,WAAW;AAAA,EACf;AAAA,EACA;AAAA,EAER,cAAc;AACb,SAAK,QAAQ,IAAI,YAAY;AAC7B,SAAK,iBAAiB,oBAAI,IAAI;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,QAA6B;AACnC,UAAM,UAAU,KAAK,MAAM,OAAO;AAAA,MACjC,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,UAAyD;AACxD,WAAO,KAAK,eAAe,QAAQ;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAgB;AACf,SAAK,MAAM;AAAA,EACZ;AACD;",
|
|
6
6
|
"names": ["RBush"]
|
|
7
7
|
}
|
|
@@ -36,33 +36,41 @@ class SpatialIndexManager {
|
|
|
36
36
|
rbush;
|
|
37
37
|
spatialIndexComputed;
|
|
38
38
|
lastPageId = null;
|
|
39
|
+
// Bumps only when the rbush content may have changed. Consumers subscribe
|
|
40
|
+
// via the computed; a stable epoch lets prop-only diffs skip downstream
|
|
41
|
+
// invalidations.
|
|
42
|
+
_boundsEpoch = 0;
|
|
43
|
+
rebuildAndBumpEpoch() {
|
|
44
|
+
this.buildFromScratch();
|
|
45
|
+
this._boundsEpoch++;
|
|
46
|
+
return this._boundsEpoch;
|
|
47
|
+
}
|
|
39
48
|
createSpatialIndexComputed() {
|
|
40
49
|
const shapeHistory = this.editor.store.query.filterHistory("shape");
|
|
41
50
|
return (0, import_state.computed)("spatialIndex", (_prevValue, lastComputedEpoch) => {
|
|
42
51
|
if ((0, import_state.isUninitialized)(_prevValue)) {
|
|
43
|
-
return this.
|
|
52
|
+
return this.rebuildAndBumpEpoch();
|
|
44
53
|
}
|
|
45
54
|
const shapeDiff = shapeHistory.getDiffSince(lastComputedEpoch);
|
|
46
55
|
if (shapeDiff === import_state.RESET_VALUE) {
|
|
47
|
-
return this.
|
|
56
|
+
return this.rebuildAndBumpEpoch();
|
|
48
57
|
}
|
|
49
58
|
const currentPageId = this.editor.getCurrentPageId();
|
|
50
59
|
if (this.lastPageId !== currentPageId) {
|
|
51
|
-
return this.
|
|
60
|
+
return this.rebuildAndBumpEpoch();
|
|
52
61
|
}
|
|
53
|
-
if (shapeDiff.length === 0)
|
|
54
|
-
|
|
62
|
+
if (shapeDiff.length === 0) return this._boundsEpoch;
|
|
63
|
+
if (this.processIncrementalUpdate(shapeDiff)) {
|
|
64
|
+
this._boundsEpoch++;
|
|
55
65
|
}
|
|
56
|
-
this.
|
|
57
|
-
return lastComputedEpoch;
|
|
66
|
+
return this._boundsEpoch;
|
|
58
67
|
});
|
|
59
68
|
}
|
|
60
|
-
buildFromScratch(
|
|
69
|
+
buildFromScratch() {
|
|
61
70
|
this.rbush.clear();
|
|
62
71
|
this.lastPageId = this.editor.getCurrentPageId();
|
|
63
|
-
const shapes = this.editor.getCurrentPageShapes();
|
|
64
72
|
const elements = [];
|
|
65
|
-
for (const shape of
|
|
73
|
+
for (const shape of this.editor.getCurrentPageShapes()) {
|
|
66
74
|
const bounds = this.editor.getShapePageBounds(shape.id);
|
|
67
75
|
if (bounds && bounds.isValid()) {
|
|
68
76
|
elements.push({
|
|
@@ -75,23 +83,27 @@ class SpatialIndexManager {
|
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
85
|
this.rbush.bulkLoad(elements);
|
|
78
|
-
return epoch;
|
|
79
86
|
}
|
|
80
87
|
processIncrementalUpdate(shapeDiff) {
|
|
81
88
|
const processedShapeIds = /* @__PURE__ */ new Set();
|
|
89
|
+
let changed = false;
|
|
82
90
|
for (const changes of shapeDiff) {
|
|
83
91
|
for (const shape of (0, import_utils.objectMapValues)(changes.added)) {
|
|
84
92
|
if ((0, import_tlschema.isShape)(shape) && this.editor.getAncestorPageId(shape) === this.lastPageId) {
|
|
85
93
|
const bounds = this.editor.getShapePageBounds(shape.id);
|
|
86
94
|
if (bounds && bounds.isValid()) {
|
|
87
95
|
this.rbush.upsert(shape.id, bounds);
|
|
96
|
+
changed = true;
|
|
88
97
|
}
|
|
89
98
|
processedShapeIds.add(shape.id);
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
for (const shape of (0, import_utils.objectMapValues)(changes.removed)) {
|
|
93
102
|
if ((0, import_tlschema.isShape)(shape)) {
|
|
94
|
-
this.rbush.
|
|
103
|
+
if (this.rbush.has(shape.id)) {
|
|
104
|
+
this.rbush.remove(shape.id);
|
|
105
|
+
changed = true;
|
|
106
|
+
}
|
|
95
107
|
processedShapeIds.add(shape.id);
|
|
96
108
|
}
|
|
97
109
|
}
|
|
@@ -102,28 +114,35 @@ class SpatialIndexManager {
|
|
|
102
114
|
if (isOnPage) {
|
|
103
115
|
const bounds = this.editor.getShapePageBounds(to.id);
|
|
104
116
|
if (bounds && bounds.isValid()) {
|
|
105
|
-
this.rbush.
|
|
117
|
+
const indexedElement = this.rbush.getElement(to.id);
|
|
118
|
+
if (!this.areBoundsEqualToSpatialElement(bounds, indexedElement)) {
|
|
119
|
+
this.rbush.upsert(to.id, bounds);
|
|
120
|
+
changed = true;
|
|
121
|
+
}
|
|
122
|
+
} else if (this.rbush.has(to.id)) {
|
|
123
|
+
this.rbush.remove(to.id);
|
|
124
|
+
changed = true;
|
|
106
125
|
}
|
|
107
|
-
} else {
|
|
126
|
+
} else if (this.rbush.has(to.id)) {
|
|
108
127
|
this.rbush.remove(to.id);
|
|
128
|
+
changed = true;
|
|
109
129
|
}
|
|
110
130
|
}
|
|
111
131
|
}
|
|
112
|
-
const
|
|
113
|
-
for (const shapeId of allShapeIds) {
|
|
132
|
+
for (const [shapeId, indexedElement] of this.rbush.entries()) {
|
|
114
133
|
if (processedShapeIds.has(shapeId)) continue;
|
|
115
134
|
const currentBounds = this.editor.getShapePageBounds(shapeId);
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.rbush.remove(shapeId);
|
|
122
|
-
}
|
|
135
|
+
if (this.areBoundsEqualToSpatialElement(currentBounds, indexedElement)) continue;
|
|
136
|
+
if (currentBounds && currentBounds.isValid()) {
|
|
137
|
+
this.rbush.upsert(shapeId, currentBounds);
|
|
138
|
+
} else {
|
|
139
|
+
this.rbush.remove(shapeId);
|
|
123
140
|
}
|
|
141
|
+
changed = true;
|
|
124
142
|
}
|
|
143
|
+
return changed;
|
|
125
144
|
}
|
|
126
|
-
|
|
145
|
+
areBoundsEqualToSpatialElement(a, b) {
|
|
127
146
|
if (!a && !b) return true;
|
|
128
147
|
if (!a || !b) return false;
|
|
129
148
|
return a.minX === b.minX && a.minY === b.minY && a.maxX === b.maxX && a.maxY === b.maxY;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts"],
|
|
4
|
-
"sourcesContent": ["import { Computed, RESET_VALUE, computed, isUninitialized } from '@tldraw/state'\nimport type { RecordsDiff } from '@tldraw/store'\nimport { TLPageId, TLShape, TLShapeId, isShape } from '@tldraw/tlschema'\nimport type { TLRecord } from '@tldraw/tlschema'\nimport { objectMapValues } from '@tldraw/utils'\nimport { Box } from '../../../primitives/Box'\nimport type { Editor } from '../../Editor'\nimport { RBushIndex, type SpatialElement } from './RBushIndex'\n\n/**\n * Manages spatial indexing for efficient shape location queries.\n *\n * Uses an R-tree (via RBush) to enable O(log n) spatial queries instead of O(n) iteration.\n * Handles shapes with computed bounds (arrows, groups, custom shapes) by checking all shapes'\n * bounds on each update using the reactive bounds cache.\n *\n * Key features:\n * - Incremental updates using filterHistory pattern\n * - Leverages existing bounds cache reactivity for dependency tracking\n * - Works with any custom shape type with computed bounds\n * - Per-page index (rebuilds on page change)\n * - Optimized for viewport culling queries\n *\n * @internal\n */\nexport class SpatialIndexManager {\n\tprivate rbush: RBushIndex\n\tprivate spatialIndexComputed: Computed<number>\n\tprivate lastPageId: TLPageId | null = null\n\n\tconstructor(public readonly editor: Editor) {\n\t\tthis.rbush = new RBushIndex()\n\t\tthis.spatialIndexComputed = this.createSpatialIndexComputed()\n\t}\n\n\tprivate createSpatialIndexComputed() {\n\t\tconst shapeHistory = this.editor.store.query.filterHistory('shape')\n\n\t\treturn computed<number>('spatialIndex', (_prevValue, lastComputedEpoch) => {\n\t\t\tif (isUninitialized(_prevValue)) {\n\t\t\t\treturn this.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiE;AAEjE,sBAAsD;AAEtD,mBAAgC;AAChC,iBAAoB;AAEpB,wBAAgD;AAkBzC,MAAM,oBAAoB;AAAA,
|
|
4
|
+
"sourcesContent": ["import { Computed, RESET_VALUE, computed, isUninitialized } from '@tldraw/state'\nimport type { RecordsDiff } from '@tldraw/store'\nimport { TLPageId, TLShape, TLShapeId, isShape } from '@tldraw/tlschema'\nimport type { TLRecord } from '@tldraw/tlschema'\nimport { objectMapValues } from '@tldraw/utils'\nimport { Box } from '../../../primitives/Box'\nimport type { Editor } from '../../Editor'\nimport { RBushIndex, type SpatialElement } from './RBushIndex'\n\n/**\n * Manages spatial indexing for efficient shape location queries.\n *\n * Uses an R-tree (via RBush) to enable O(log n) spatial queries instead of O(n) iteration.\n * Handles shapes with computed bounds (arrows, groups, custom shapes) by checking all shapes'\n * bounds on each update using the reactive bounds cache.\n *\n * Key features:\n * - Incremental updates using filterHistory pattern\n * - Leverages existing bounds cache reactivity for dependency tracking\n * - Works with any custom shape type with computed bounds\n * - Per-page index (rebuilds on page change)\n * - Optimized for viewport culling queries\n *\n * @internal\n */\nexport class SpatialIndexManager {\n\tprivate rbush: RBushIndex\n\tprivate spatialIndexComputed: Computed<number>\n\tprivate lastPageId: TLPageId | null = null\n\n\t// Bumps only when the rbush content may have changed. Consumers subscribe\n\t// via the computed; a stable epoch lets prop-only diffs skip downstream\n\t// invalidations.\n\tprivate _boundsEpoch = 0\n\n\tconstructor(public readonly editor: Editor) {\n\t\tthis.rbush = new RBushIndex()\n\t\tthis.spatialIndexComputed = this.createSpatialIndexComputed()\n\t}\n\n\tprivate rebuildAndBumpEpoch(): number {\n\t\tthis.buildFromScratch()\n\t\tthis._boundsEpoch++\n\t\treturn this._boundsEpoch\n\t}\n\n\tprivate createSpatialIndexComputed() {\n\t\tconst shapeHistory = this.editor.store.query.filterHistory('shape')\n\n\t\treturn computed<number>('spatialIndex', (_prevValue, lastComputedEpoch) => {\n\t\t\tif (isUninitialized(_prevValue)) {\n\t\t\t\treturn this.rebuildAndBumpEpoch()\n\t\t\t}\n\n\t\t\tconst shapeDiff = shapeHistory.getDiffSince(lastComputedEpoch)\n\n\t\t\tif (shapeDiff === RESET_VALUE) {\n\t\t\t\treturn this.rebuildAndBumpEpoch()\n\t\t\t}\n\n\t\t\tconst currentPageId = this.editor.getCurrentPageId()\n\t\t\tif (this.lastPageId !== currentPageId) {\n\t\t\t\treturn this.rebuildAndBumpEpoch()\n\t\t\t}\n\n\t\t\tif (shapeDiff.length === 0) return this._boundsEpoch\n\n\t\t\tif (this.processIncrementalUpdate(shapeDiff)) {\n\t\t\t\tthis._boundsEpoch++\n\t\t\t}\n\t\t\treturn this._boundsEpoch\n\t\t})\n\t}\n\n\tprivate buildFromScratch(): void {\n\t\tthis.rbush.clear()\n\t\tthis.lastPageId = this.editor.getCurrentPageId()\n\n\t\tconst elements: SpatialElement[] = []\n\t\tfor (const shape of this.editor.getCurrentPageShapes()) {\n\t\t\tconst bounds = this.editor.getShapePageBounds(shape.id)\n\t\t\tif (bounds && bounds.isValid()) {\n\t\t\t\telements.push({\n\t\t\t\t\tminX: bounds.minX,\n\t\t\t\t\tminY: bounds.minY,\n\t\t\t\t\tmaxX: bounds.maxX,\n\t\t\t\t\tmaxY: bounds.maxY,\n\t\t\t\t\tid: shape.id,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// Bulk load for efficiency\n\t\tthis.rbush.bulkLoad(elements)\n\t}\n\n\tprivate processIncrementalUpdate(shapeDiff: RecordsDiff<TLRecord>[]): boolean {\n\t\tconst processedShapeIds = new Set<TLShapeId>()\n\t\tlet changed = false\n\n\t\t// Step 1: apply diff entries directly. `changed` flips only on real\n\t\t// rbush mutations, so prop-only updates and no-op removes (e.g. shapes\n\t\t// from other pages, or never-indexed shapes with invalid bounds) don't\n\t\t// bump the epoch.\n\t\tfor (const changes of shapeDiff) {\n\t\t\tfor (const shape of objectMapValues(changes.added) as TLShape[]) {\n\t\t\t\tif (isShape(shape) && this.editor.getAncestorPageId(shape) === this.lastPageId) {\n\t\t\t\t\tconst bounds = this.editor.getShapePageBounds(shape.id)\n\t\t\t\t\tif (bounds && bounds.isValid()) {\n\t\t\t\t\t\tthis.rbush.upsert(shape.id, bounds)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\t}\n\t\t\t\t\tprocessedShapeIds.add(shape.id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const shape of objectMapValues(changes.removed) as TLShape[]) {\n\t\t\t\tif (isShape(shape)) {\n\t\t\t\t\tif (this.rbush.has(shape.id)) {\n\t\t\t\t\t\tthis.rbush.remove(shape.id)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\t}\n\t\t\t\t\tprocessedShapeIds.add(shape.id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const [, to] of objectMapValues(changes.updated) as [TLShape, TLShape][]) {\n\t\t\t\tif (!isShape(to)) continue\n\t\t\t\tprocessedShapeIds.add(to.id)\n\n\t\t\t\tconst isOnPage = this.editor.getAncestorPageId(to) === this.lastPageId\n\n\t\t\t\tif (isOnPage) {\n\t\t\t\t\tconst bounds = this.editor.getShapePageBounds(to.id)\n\t\t\t\t\tif (bounds && bounds.isValid()) {\n\t\t\t\t\t\tconst indexedElement = this.rbush.getElement(to.id)\n\t\t\t\t\t\tif (!this.areBoundsEqualToSpatialElement(bounds, indexedElement)) {\n\t\t\t\t\t\t\tthis.rbush.upsert(to.id, bounds)\n\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this.rbush.has(to.id)) {\n\t\t\t\t\t\tthis.rbush.remove(to.id)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\t}\n\t\t\t\t} else if (this.rbush.has(to.id)) {\n\t\t\t\t\tthis.rbush.remove(to.id)\n\t\t\t\t\tchanged = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Step 2: must always run. Diff entries can dirty derived bounds \u2014\n\t\t// arrows bound to moved shapes, groups with moved children \u2014 without\n\t\t// touching any record visited in step 1. Also catches outline-only\n\t\t// changes (e.g. geo rectangle\u2192ellipse at the same w/h) that shift a\n\t\t// bound arrow's intersection points: step 1 sees the geo's\n\t\t// axis-aligned bounds unchanged and skips, but the dependent arrow's\n\t\t// bounds have moved.\n\t\t//\n\t\t// Iterating the rbush's element map directly avoids allocating a\n\t\t// shape-id array per pointer move. Mutation here is limited to\n\t\t// upserts of existing keys and deletions, both safe during Map\n\t\t// iteration.\n\t\tfor (const [shapeId, indexedElement] of this.rbush.entries()) {\n\t\t\tif (processedShapeIds.has(shapeId)) continue\n\n\t\t\tconst currentBounds = this.editor.getShapePageBounds(shapeId)\n\t\t\tif (this.areBoundsEqualToSpatialElement(currentBounds, indexedElement)) continue\n\n\t\t\tif (currentBounds && currentBounds.isValid()) {\n\t\t\t\tthis.rbush.upsert(shapeId, currentBounds)\n\t\t\t} else {\n\t\t\t\tthis.rbush.remove(shapeId)\n\t\t\t}\n\t\t\tchanged = true\n\t\t}\n\n\t\treturn changed\n\t}\n\n\tprivate areBoundsEqualToSpatialElement(\n\t\ta: Box | undefined,\n\t\tb: SpatialElement | undefined\n\t): boolean {\n\t\tif (!a && !b) return true\n\t\tif (!a || !b) return false\n\t\treturn a.minX === b.minX && a.minY === b.minY && a.maxX === b.maxX && a.maxY === b.maxY\n\t}\n\n\t/**\n\t * Get shape IDs within the given bounds.\n\t * Optimized for viewport culling queries.\n\t *\n\t * Note: Results are unordered. If you need z-order, combine with sorted shapes:\n\t * ```ts\n\t * const candidates = editor.spatialIndex.getShapeIdsInsideBounds(bounds)\n\t * const sorted = editor.getCurrentPageShapesSorted().filter(s => candidates.has(s.id))\n\t * ```\n\t *\n\t * @param bounds - The bounds to search within\n\t * @returns Unordered set of shape IDs within the bounds\n\t *\n\t * @public\n\t */\n\tgetShapeIdsInsideBounds(bounds: Box): Set<TLShapeId> {\n\t\tthis.spatialIndexComputed.get()\n\t\treturn this.rbush.search(bounds)\n\t}\n\n\t/**\n\t * Get shape IDs at a point (with optional margin).\n\t * Creates a small bounding box around the point and searches the spatial index.\n\t *\n\t * Note: Results are unordered. If you need z-order, combine with sorted shapes:\n\t * ```ts\n\t * const candidates = editor.spatialIndex.getShapeIdsAtPoint(point, margin)\n\t * const sorted = editor.getCurrentPageShapesSorted().filter(s => candidates.has(s.id))\n\t * ```\n\t *\n\t * @param point - The point to search at\n\t * @param margin - The margin around the point to search (default: 0)\n\t * @returns Unordered set of shape IDs that could potentially contain the point\n\t *\n\t * @public\n\t */\n\tgetShapeIdsAtPoint(point: { x: number; y: number }, margin = 0): Set<TLShapeId> {\n\t\tthis.spatialIndexComputed.get()\n\t\treturn this.rbush.search(new Box(point.x - margin, point.y - margin, margin * 2, margin * 2))\n\t}\n\n\t/**\n\t * Dispose of the spatial index manager.\n\t * Clears the R-tree to prevent memory leaks.\n\t *\n\t * @public\n\t */\n\tdispose(): void {\n\t\tthis.rbush.dispose()\n\t\tthis.lastPageId = null\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiE;AAEjE,sBAAsD;AAEtD,mBAAgC;AAChC,iBAAoB;AAEpB,wBAAgD;AAkBzC,MAAM,oBAAoB;AAAA,EAUhC,YAA4B,QAAgB;AAAhB;AAC3B,SAAK,QAAQ,IAAI,6BAAW;AAC5B,SAAK,uBAAuB,KAAK,2BAA2B;AAAA,EAC7D;AAAA,EAH4B;AAAA,EATpB;AAAA,EACA;AAAA,EACA,aAA8B;AAAA;AAAA;AAAA;AAAA,EAK9B,eAAe;AAAA,EAOf,sBAA8B;AACrC,SAAK,iBAAiB;AACtB,SAAK;AACL,WAAO,KAAK;AAAA,EACb;AAAA,EAEQ,6BAA6B;AACpC,UAAM,eAAe,KAAK,OAAO,MAAM,MAAM,cAAc,OAAO;AAElE,eAAO,uBAAiB,gBAAgB,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() {
|
|
55
|
+
for (const util of this._overlayUtils.values()) {
|
|
56
|
+
util.dispose();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
54
59
|
getOverlayUtil(arg) {
|
|
55
60
|
const type = typeof arg === "string" ? arg : arg.type;
|
|
56
61
|
const util = this._overlayUtils.get(type);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/editor/overlays/OverlayManager.ts"],
|
|
4
|
-
"sourcesContent": ["import { atom, computed } from '@tldraw/state'\nimport { Geometry2d } from '../../primitives/geometry/Geometry2d'\nimport { VecLike } from '../../primitives/Vec'\nimport type { Editor } from '../Editor'\nimport { OverlayUtil, TLOverlay } from './OverlayUtil'\n\n/**\n * An active overlay util paired with the overlays it produced for the current\n * editor state. Returned by {@link OverlayManager.getActiveOverlayEntries} so\n * hit-test, render, and debug paths share a single scan per reactive tick.\n *\n * @public\n */\nexport interface TLOverlayEntry {\n\tutil: OverlayUtil\n\toverlays: TLOverlay[]\n}\n\n/** @public */\nexport class OverlayManager {\n\tconstructor(public readonly editor: Editor) {}\n\n\t/** @internal */\n\treadonly _overlayUtils = new Map<string, OverlayUtil>()\n\n\t/**\n\t * Register an overlay util instance. Called during editor construction.\n\t * @internal\n\t */\n\tregisterUtil(util: OverlayUtil) {\n\t\tconst type = (util.constructor as typeof OverlayUtil).type\n\t\tif (!type) {\n\t\t\tthrow new Error(`Overlay util ${util.constructor.name} is missing a static 'type' property.`)\n\t\t}\n\t\tif (this._overlayUtils.has(type)) {\n\t\t\tthrow new Error(`Duplicate overlay util type: \"${type}\"`)\n\t\t}\n\t\tthis._overlayUtils.set(type, util)\n\t}\n\n\t/**\n\t * Get an overlay util by type string, overlay instance, or by passing\n\t * a util class as a generic parameter for type-safe lookup.\n\t *\n\t * @example\n\t * ```ts\n\t * const util = editor.overlays.getOverlayUtil('brush')\n\t * const util = editor.overlays.getOverlayUtil<BrushOverlayUtil>('brush')\n\t * const util = editor.overlays.getOverlayUtil(myOverlay)\n\t * ```\n\t *\n\t * @public\n\t */\n\tgetOverlayUtil<T extends OverlayUtil>(\n\t\ttype: T extends OverlayUtil<infer O> ? O['type'] : string\n\t): T\n\tgetOverlayUtil<O extends TLOverlay>(overlay: O): OverlayUtil<O>\n\tgetOverlayUtil(arg: string | TLOverlay): OverlayUtil {\n\t\tconst type = typeof arg === 'string' ? arg : arg.type\n\t\tconst util = this._overlayUtils.get(type)\n\t\tif (!util) throw new Error(`No overlay util found for type: \"${type}\"`)\n\t\treturn util\n\t}\n\n\t/**\n\t * Returns all registered overlay utils in paint order (ascending zIndex).\n\t * Utils with the same zIndex preserve their registration order.\n\t *\n\t * @public\n\t */\n\t@computed getOverlayUtilsInZOrder(): OverlayUtil[] {\n\t\tconst utils = Array.from(this._overlayUtils.values())\n\t\t// Stable sort by zIndex (registration order breaks ties).\n\t\treturn utils\n\t\t\t.map((util, i) => ({ util, i, z: util.options.zIndex ?? 0 }))\n\t\t\t.sort((a, b) => a.z - b.z || a.i - b.i)\n\t\t\t.map((entry) => entry.util)\n\t}\n\n\t/**\n\t * Reactive list of active overlay utils paired with the overlays they\n\t * produced for the current editor state, in paint order (ascending\n\t * zIndex). Both the hit-test and render paths read from this single\n\t * cached scan instead of each re-deriving the active set. Active utils\n\t * are included even when their `getOverlays()` returns an empty array,\n\t * since `render()` may still draw non-interactive UI (e.g. the selection\n\t * bounding box during brushing).\n\t *\n\t * @public\n\t */\n\t@computed getActiveOverlayEntries(): TLOverlayEntry[] {\n\t\tconst entries: TLOverlayEntry[] = []\n\t\tfor (const util of this.getOverlayUtilsInZOrder()) {\n\t\t\tif (!util.isActive()) continue\n\t\t\tentries.push({ util, overlays: util.getOverlays() })\n\t\t}\n\t\treturn entries\n\t}\n\n\t/**\n\t * Reactively computed list of all currently active overlays, in paint order.\n\t * @public\n\t */\n\t@computed getCurrentOverlays(): TLOverlay[] {\n\t\tconst all: TLOverlay[] = []\n\t\tfor (const { overlays } of this.getActiveOverlayEntries()) {\n\t\t\tall.push(...overlays)\n\t\t}\n\t\treturn all\n\t}\n\n\t// Hit-test geometry cache keyed by overlay identity. Entries remain valid\n\t// while getActiveOverlayEntries() keeps returning the same overlay\n\t// instances; when its reactive deps change, getOverlays() emits fresh\n\t// objects and stale entries fall out by GC.\n\tprivate _geometryCache = new WeakMap<TLOverlay, Geometry2d | null>()\n\n\t/**\n\t * Get hit-test geometry for an overlay, cached by overlay identity. Lets\n\t * hit-testing on a pointermove storm skip the per-overlay geometry\n\t * allocation that {@link OverlayUtil.getGeometry} would otherwise do on\n\t * every call.\n\t *\n\t * @public\n\t */\n\tgetOverlayGeometry(overlay: TLOverlay): Geometry2d | null {\n\t\tconst cached = this._geometryCache.get(overlay)\n\t\tif (cached !== undefined) return cached\n\t\tconst util = this.getOverlayUtil(overlay)\n\t\tconst geometry = util.getGeometry(overlay)\n\t\tthis._geometryCache.set(overlay, geometry)\n\t\treturn geometry\n\t}\n\n\t/**\n\t * The currently hovered overlay id.\n\t * @public\n\t */\n\tprivate _hoveredOverlayId = atom<string | null>('hoveredOverlayId', null)\n\n\tgetHoveredOverlayId(): string | null {\n\t\treturn this._hoveredOverlayId.get()\n\t}\n\n\tgetHoveredOverlay(): TLOverlay | null {\n\t\tconst id = this._hoveredOverlayId.get()\n\t\tif (!id) return null\n\t\treturn this.getCurrentOverlays().find((o) => o.id === id) ?? null\n\t}\n\n\tsetHoveredOverlay(id: string | null) {\n\t\tif (id === this._hoveredOverlayId.get()) return\n\t\tthis._hoveredOverlayId.set(id)\n\t}\n\n\t/**\n\t * Hit test all active overlays at a given page point.\n\t * Returns the topmost overlay whose geometry contains the point, or null.\n\t * Utils are walked from highest zIndex to lowest so the overlay painted on\n\t * top also wins the hit test. Within a util, overlays are walked in\n\t * array order: the first overlay whose geometry contains the point wins,\n\t * so utils should place highest-priority overlays first in `getOverlays`.\n\t * Interactive overlays (those with geometry) are checked; non-interactive are skipped.\n\t *\n\t * @param point - Point in page coordinates\n\t * @param margin - Hit test margin\n\t * @public\n\t */\n\tgetOverlayAtPoint(point: VecLike, margin = 0): TLOverlay | null {\n\t\tconst entries = this.getActiveOverlayEntries()\n\t\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\t\tconst { overlays } = entries[i]\n\t\t\tfor (const overlay of overlays) {\n\t\t\t\tconst geometry = this.getOverlayGeometry(overlay)\n\t\t\t\tif (!geometry) continue\n\t\t\t\tif (geometry.hitTestPoint(point, geometry.isFilled ? 0 : margin, true)) {\n\t\t\t\t\treturn overlay\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAmBxB,MAAM,eAAe;AAAA,EAC3B,YAA4B,QAAgB;AAAhB;AAAA,EAAiB;AAAA,EAAjB;AAAA;AAAA,EAGnB,gBAAgB,oBAAI,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtD,aAAa,MAAmB;AAC/B,UAAM,OAAQ,KAAK,YAAmC;AACtD,QAAI,CAAC,MAAM;AACV,YAAM,IAAI,MAAM,gBAAgB,KAAK,YAAY,IAAI,uCAAuC;AAAA,IAC7F;AACA,QAAI,KAAK,cAAc,IAAI,IAAI,GAAG;AACjC,YAAM,IAAI,MAAM,iCAAiC,IAAI,GAAG;AAAA,IACzD;AACA,SAAK,cAAc,IAAI,MAAM,IAAI;AAAA,EAClC;AAAA,EAmBA,eAAe,KAAsC;AACpD,UAAM,OAAO,OAAO,QAAQ,WAAW,MAAM,IAAI;AACjD,UAAM,OAAO,KAAK,cAAc,IAAI,IAAI;AACxC,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,oCAAoC,IAAI,GAAG;AACtE,WAAO;AAAA,EACR;AAAA,EAQU,0BAAyC;AAClD,UAAM,QAAQ,MAAM,KAAK,KAAK,cAAc,OAAO,CAAC;AAEpD,WAAO,MACL,I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A,EAC9D;AAAA,EAEA,kBAAkB,IAAmB;AACpC,QAAI,OAAO,KAAK,kBAAkB,IAAI,EAAG;AACzC,SAAK,kBAAkB,IAAI,EAAE;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,kBAAkB,OAAgB,SAAS,GAAqB;AAC/D,UAAM,UAAU,KAAK,wBAAwB;AAC7C,aAAS,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;AAC7C,YAAM,EAAE,SAAS,IAAI,QAAQ,CAAC;AAC9B,iBAAW,WAAW,UAAU;AAC/B,cAAM,WAAW,KAAK,mBAAmB,OAAO;AAChD,YAAI,CAAC,SAAU;AACf,YAAI,SAAS,aAAa,OAAO,SAAS,WAAW,IAAI,QAAQ,IAAI,GAAG;AACvE,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;AAhHW;AAAA,EAAT;AAAA,
|
|
4
|
+
"sourcesContent": ["import { atom, computed } from '@tldraw/state'\nimport { Geometry2d } from '../../primitives/geometry/Geometry2d'\nimport { VecLike } from '../../primitives/Vec'\nimport type { Editor } from '../Editor'\nimport { OverlayUtil, TLOverlay } from './OverlayUtil'\n\n/**\n * An active overlay util paired with the overlays it produced for the current\n * editor state. Returned by {@link OverlayManager.getActiveOverlayEntries} so\n * hit-test, render, and debug paths share a single scan per reactive tick.\n *\n * @public\n */\nexport interface TLOverlayEntry {\n\tutil: OverlayUtil\n\toverlays: TLOverlay[]\n}\n\n/** @public */\nexport class OverlayManager {\n\tconstructor(public readonly editor: Editor) {}\n\n\t/** @internal */\n\treadonly _overlayUtils = new Map<string, OverlayUtil>()\n\n\t/**\n\t * Register an overlay util instance. Called during editor construction.\n\t * @internal\n\t */\n\tregisterUtil(util: OverlayUtil) {\n\t\tconst type = (util.constructor as typeof OverlayUtil).type\n\t\tif (!type) {\n\t\t\tthrow new Error(`Overlay util ${util.constructor.name} is missing a static 'type' property.`)\n\t\t}\n\t\tif (this._overlayUtils.has(type)) {\n\t\t\tthrow new Error(`Duplicate overlay util type: \"${type}\"`)\n\t\t}\n\t\tthis._overlayUtils.set(type, util)\n\t}\n\n\tdispose() {\n\t\tfor (const util of this._overlayUtils.values()) {\n\t\t\tutil.dispose()\n\t\t}\n\t}\n\n\t/**\n\t * Get an overlay util by type string, overlay instance, or by passing\n\t * a util class as a generic parameter for type-safe lookup.\n\t *\n\t * @example\n\t * ```ts\n\t * const util = editor.overlays.getOverlayUtil('brush')\n\t * const util = editor.overlays.getOverlayUtil<BrushOverlayUtil>('brush')\n\t * const util = editor.overlays.getOverlayUtil(myOverlay)\n\t * ```\n\t *\n\t * @public\n\t */\n\tgetOverlayUtil<T extends OverlayUtil>(\n\t\ttype: T extends OverlayUtil<infer O> ? O['type'] : string\n\t): T\n\tgetOverlayUtil<O extends TLOverlay>(overlay: O): OverlayUtil<O>\n\tgetOverlayUtil(arg: string | TLOverlay): OverlayUtil {\n\t\tconst type = typeof arg === 'string' ? arg : arg.type\n\t\tconst util = this._overlayUtils.get(type)\n\t\tif (!util) throw new Error(`No overlay util found for type: \"${type}\"`)\n\t\treturn util\n\t}\n\n\t/**\n\t * Returns all registered overlay utils in paint order (ascending zIndex).\n\t * Utils with the same zIndex preserve their registration order.\n\t *\n\t * @public\n\t */\n\t@computed getOverlayUtilsInZOrder(): OverlayUtil[] {\n\t\tconst utils = Array.from(this._overlayUtils.values())\n\t\t// Stable sort by zIndex (registration order breaks ties).\n\t\treturn utils\n\t\t\t.map((util, i) => ({ util, i, z: util.options.zIndex ?? 0 }))\n\t\t\t.sort((a, b) => a.z - b.z || a.i - b.i)\n\t\t\t.map((entry) => entry.util)\n\t}\n\n\t/**\n\t * Reactive list of active overlay utils paired with the overlays they\n\t * produced for the current editor state, in paint order (ascending\n\t * zIndex). Both the hit-test and render paths read from this single\n\t * cached scan instead of each re-deriving the active set. Active utils\n\t * are included even when their `getOverlays()` returns an empty array,\n\t * since `render()` may still draw non-interactive UI (e.g. the selection\n\t * bounding box during brushing).\n\t *\n\t * @public\n\t */\n\t@computed getActiveOverlayEntries(): TLOverlayEntry[] {\n\t\tconst entries: TLOverlayEntry[] = []\n\t\tfor (const util of this.getOverlayUtilsInZOrder()) {\n\t\t\tif (!util.isActive()) continue\n\t\t\tentries.push({ util, overlays: util.getOverlays() })\n\t\t}\n\t\treturn entries\n\t}\n\n\t/**\n\t * Reactively computed list of all currently active overlays, in paint order.\n\t * @public\n\t */\n\t@computed getCurrentOverlays(): TLOverlay[] {\n\t\tconst all: TLOverlay[] = []\n\t\tfor (const { overlays } of this.getActiveOverlayEntries()) {\n\t\t\tall.push(...overlays)\n\t\t}\n\t\treturn all\n\t}\n\n\t// Hit-test geometry cache keyed by overlay identity. Entries remain valid\n\t// while getActiveOverlayEntries() keeps returning the same overlay\n\t// instances; when its reactive deps change, getOverlays() emits fresh\n\t// objects and stale entries fall out by GC.\n\tprivate _geometryCache = new WeakMap<TLOverlay, Geometry2d | null>()\n\n\t/**\n\t * Get hit-test geometry for an overlay, cached by overlay identity. Lets\n\t * hit-testing on a pointermove storm skip the per-overlay geometry\n\t * allocation that {@link OverlayUtil.getGeometry} would otherwise do on\n\t * every call.\n\t *\n\t * @public\n\t */\n\tgetOverlayGeometry(overlay: TLOverlay): Geometry2d | null {\n\t\tconst cached = this._geometryCache.get(overlay)\n\t\tif (cached !== undefined) return cached\n\t\tconst util = this.getOverlayUtil(overlay)\n\t\tconst geometry = util.getGeometry(overlay)\n\t\tthis._geometryCache.set(overlay, geometry)\n\t\treturn geometry\n\t}\n\n\t/**\n\t * The currently hovered overlay id.\n\t * @public\n\t */\n\tprivate _hoveredOverlayId = atom<string | null>('hoveredOverlayId', null)\n\n\tgetHoveredOverlayId(): string | null {\n\t\treturn this._hoveredOverlayId.get()\n\t}\n\n\tgetHoveredOverlay(): TLOverlay | null {\n\t\tconst id = this._hoveredOverlayId.get()\n\t\tif (!id) return null\n\t\treturn this.getCurrentOverlays().find((o) => o.id === id) ?? null\n\t}\n\n\tsetHoveredOverlay(id: string | null) {\n\t\tif (id === this._hoveredOverlayId.get()) return\n\t\tthis._hoveredOverlayId.set(id)\n\t}\n\n\t/**\n\t * Hit test all active overlays at a given page point.\n\t * Returns the topmost overlay whose geometry contains the point, or null.\n\t * Utils are walked from highest zIndex to lowest so the overlay painted on\n\t * top also wins the hit test. Within a util, overlays are walked in\n\t * array order: the first overlay whose geometry contains the point wins,\n\t * so utils should place highest-priority overlays first in `getOverlays`.\n\t * Interactive overlays (those with geometry) are checked; non-interactive are skipped.\n\t *\n\t * @param point - Point in page coordinates\n\t * @param margin - Hit test margin\n\t * @public\n\t */\n\tgetOverlayAtPoint(point: VecLike, margin = 0): TLOverlay | null {\n\t\tconst entries = this.getActiveOverlayEntries()\n\t\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\t\tconst { overlays } = entries[i]\n\t\t\tfor (const overlay of overlays) {\n\t\t\t\tconst geometry = this.getOverlayGeometry(overlay)\n\t\t\t\tif (!geometry) continue\n\t\t\t\tif (geometry.hitTestPoint(point, geometry.isFilled ? 0 : margin, true)) {\n\t\t\t\t\treturn overlay\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAmBxB,MAAM,eAAe;AAAA,EAC3B,YAA4B,QAAgB;AAAhB;AAAA,EAAiB;AAAA,EAAjB;AAAA;AAAA,EAGnB,gBAAgB,oBAAI,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtD,aAAa,MAAmB;AAC/B,UAAM,OAAQ,KAAK,YAAmC;AACtD,QAAI,CAAC,MAAM;AACV,YAAM,IAAI,MAAM,gBAAgB,KAAK,YAAY,IAAI,uCAAuC;AAAA,IAC7F;AACA,QAAI,KAAK,cAAc,IAAI,IAAI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eA0FF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/editor/overlays/OverlayUtil.ts"],
|
|
4
|
-
"sourcesContent": ["import { TLCursorType } from '@tldraw/tlschema'\nimport { Geometry2d } from '../../primitives/geometry/Geometry2d'\nimport type { Editor } from '../Editor'\nimport { TLPointerEventInfo } from '../types/event-types'\n\n/** @public */\nexport interface TLOverlay<Props = Record<string, unknown>> {\n\t/**\n\t * Globally unique id for this overlay instance across all overlay utils.\n\t * Hit-test and hover lookup key on `id` alone, so utils must namespace their\n\t * ids (e.g. `'selection_fg:top_left'`, `'handle:<shapeId>:<handleId>'`) to\n\t * avoid colliding with overlays from other utils.\n\t */\n\tid: string\n\t/** The overlay util type that owns this instance */\n\ttype: string\n\t/** Arbitrary props for the overlay (handle id, corner name, etc.) */\n\tprops: Props\n}\n\n/** @public */\nexport interface TLOverlayUtilConstructor<U extends OverlayUtil = OverlayUtil> {\n\tnew (editor: Editor): U\n\ttype: string\n\tconfigure<T extends TLOverlayUtilConstructor<any>>(\n\t\tthis: T,\n\t\toptions: T extends new (...args: any[]) => { options: infer Options } ? Partial<Options> : never\n\t): T\n}\n\n/** @public */\nexport type TLAnyOverlayUtilConstructor = TLOverlayUtilConstructor<any>\n\n/**\n * Base class for overlay utilities. Overlays are ephemeral UI elements rendered\n * on top of the canvas (selection handles, rotation corners, shape handles, etc.).\n *\n * Each OverlayUtil defines a type of overlay and knows how to:\n * - Determine when its overlays should be active (predicate)\n * - Produce overlay instances from current editor state\n * - Provide hit-test geometry for interactive overlays\n * - Provide cursor style on hover\n * - Render into a canvas 2D context\n *\n * @public\n */\nexport abstract class OverlayUtil<T extends TLOverlay = TLOverlay> {\n\tconstructor(public editor: Editor) {}\n\tstatic type: string\n\n\t/**\n\t * Options for this overlay util. Override this to provide customization options.\n\t * Use {@link OverlayUtil.configure} to customize existing overlay utils.\n\t *\n\t * `zIndex` controls paint and hit-test order across utils \u2014 higher numbers\n\t * paint on top and are hit-tested first. Ties resolve by registration order.\n\t * Defaults to `0`; built-in utils use larger integers (100, 200, \u2026) with\n\t * gaps so custom utils can slot between.\n\t *\n\t * @public\n\t */\n\toptions: { zIndex?: number } = {}\n\n\t/**\n\t * Create a new overlay util class with the given options merged in.\n\t *\n\t * @example\n\t * ```ts\n\t * const MyBrush = BrushOverlayUtil.configure({ fill: 'rgba(0,0,255,0.1)' })\n\t * ```\n\t *\n\t * @public\n\t */\n\tstatic configure<T extends TLOverlayUtilConstructor<any>>(\n\t\tthis: T,\n\t\toptions: T extends new (...args: any[]) => { options: infer Options } ? Partial<Options> : never\n\t): T {\n\t\t// @ts-expect-error -- typescript has no idea what's going on here but it's fine\n\t\treturn class extends this {\n\t\t\t// @ts-expect-error\n\t\t\toptions = { ...this.options, ...options }\n\t\t}\n\t}\n\n\t/**\n\t * Whether this overlay util's overlays should currently be active.\n\t * Checked reactively to determine which overlays exist at any given time.\n\t */\n\tabstract isActive(): boolean\n\n\t/**\n\t * Returns the overlay instances that currently exist.\n\t * Called only when `isActive()` returns true.\n\t */\n\tabstract getOverlays(): T[]\n\n\t/**\n\t * Returns hit-test geometry for an overlay instance, in page coordinates.\n\t * Return null for non-interactive overlays (e.g. snap indicators, scribbles).\n\t */\n\tgetGeometry(_overlay: T): Geometry2d | null {\n\t\treturn null\n\t}\n\n\t/**\n\t * Returns the cursor type to show when hovering this overlay.\n\t */\n\tgetCursor(_overlay: T): TLCursorType | undefined {\n\t\treturn undefined\n\t}\n\n\t/**\n\t * Called when the user points down on this overlay, before the default\n\t * routing runs. Acts as an interrupt: define it to take over the event.\n\t *\n\t * Return `false` to continue with the default behavior (e.g. the\n\t * built-in rotate/resize handle transitions or shape-handle dispatch).\n\t * Return `true` \u2014 or nothing at all \u2014 to skip the default. In other\n\t * words, once you override this method you own the event unless you\n\t * explicitly opt back in by returning `false`.\n\t */\n\tonPointerDown?(overlay: T, info: TLPointerEventInfo): boolean | void\n\n\t/**\n\t * Render all active overlays into the canvas context.\n\t * The context is already transformed to page space (camera transform applied).\n\t * Called reactively when overlays or editor state changes.\n\t */\n\trender(_ctx: CanvasRenderingContext2D, _overlays: T[]): void {}\n\n\t/**\n\t * Optional: render all active overlays into the minimap canvas.\n\t * The context is already transformed to page space (minimap camera applied),\n\t * so overlays can use the same page-space coordinates as in {@link OverlayUtil.render}.\n\t *\n\t * `zoom` is the minimap's screen-pixels-per-page-unit, analogous to\n\t * `editor.getCamera().z`; use `1 / zoom` for one-minimap-pixel line widths.\n\t *\n\t * Most overlays should leave this blank \u2014 only overlays that are meaningful\n\t * at minimap scale (e.g. brushes, collaborator cursors) should opt in.\n\t */\n\trenderMinimap(_ctx: CanvasRenderingContext2D, _overlays: T[], _zoom: number): void {}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CO,MAAe,YAA6C;AAAA,EAClE,YAAmB,QAAgB;AAAhB;AAAA,EAAiB;AAAA,EAAjB;AAAA,EACnB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaP,UAA+B,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYhC,OAAO,UAEN,SACI;AAEJ,WAAO,cAAc,KAAK;AAAA;AAAA,MAEzB,UAAU,EAAE,GAAG,KAAK,SAAS,GAAG,QAAQ;AAAA,IACzC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,YAAY,UAAgC;AAC3C,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,UAAuC;AAChD,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,OAAO,MAAgC,WAAsB;AAAA,EAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAa9D,cAAc,MAAgC,WAAgB,OAAqB;AAAA,EAAC;
|
|
4
|
+
"sourcesContent": ["import { TLCursorType } from '@tldraw/tlschema'\nimport { Geometry2d } from '../../primitives/geometry/Geometry2d'\nimport type { Editor } from '../Editor'\nimport { TLPointerEventInfo } from '../types/event-types'\n\n/** @public */\nexport interface TLOverlay<Props = Record<string, unknown>> {\n\t/**\n\t * Globally unique id for this overlay instance across all overlay utils.\n\t * Hit-test and hover lookup key on `id` alone, so utils must namespace their\n\t * ids (e.g. `'selection_fg:top_left'`, `'handle:<shapeId>:<handleId>'`) to\n\t * avoid colliding with overlays from other utils.\n\t */\n\tid: string\n\t/** The overlay util type that owns this instance */\n\ttype: string\n\t/** Arbitrary props for the overlay (handle id, corner name, etc.) */\n\tprops: Props\n}\n\n/** @public */\nexport interface TLOverlayUtilConstructor<U extends OverlayUtil = OverlayUtil> {\n\tnew (editor: Editor): U\n\ttype: string\n\tconfigure<T extends TLOverlayUtilConstructor<any>>(\n\t\tthis: T,\n\t\toptions: T extends new (...args: any[]) => { options: infer Options } ? Partial<Options> : never\n\t): T\n}\n\n/** @public */\nexport type TLAnyOverlayUtilConstructor = TLOverlayUtilConstructor<any>\n\n/**\n * Base class for overlay utilities. Overlays are ephemeral UI elements rendered\n * on top of the canvas (selection handles, rotation corners, shape handles, etc.).\n *\n * Each OverlayUtil defines a type of overlay and knows how to:\n * - Determine when its overlays should be active (predicate)\n * - Produce overlay instances from current editor state\n * - Provide hit-test geometry for interactive overlays\n * - Provide cursor style on hover\n * - Render into a canvas 2D context\n *\n * @public\n */\nexport abstract class OverlayUtil<T extends TLOverlay = TLOverlay> {\n\tconstructor(public editor: Editor) {}\n\tstatic type: string\n\n\t/**\n\t * Options for this overlay util. Override this to provide customization options.\n\t * Use {@link OverlayUtil.configure} to customize existing overlay utils.\n\t *\n\t * `zIndex` controls paint and hit-test order across utils \u2014 higher numbers\n\t * paint on top and are hit-tested first. Ties resolve by registration order.\n\t * Defaults to `0`; built-in utils use larger integers (100, 200, \u2026) with\n\t * gaps so custom utils can slot between.\n\t *\n\t * @public\n\t */\n\toptions: { zIndex?: number } = {}\n\n\t/**\n\t * Create a new overlay util class with the given options merged in.\n\t *\n\t * @example\n\t * ```ts\n\t * const MyBrush = BrushOverlayUtil.configure({ fill: 'rgba(0,0,255,0.1)' })\n\t * ```\n\t *\n\t * @public\n\t */\n\tstatic configure<T extends TLOverlayUtilConstructor<any>>(\n\t\tthis: T,\n\t\toptions: T extends new (...args: any[]) => { options: infer Options } ? Partial<Options> : never\n\t): T {\n\t\t// @ts-expect-error -- typescript has no idea what's going on here but it's fine\n\t\treturn class extends this {\n\t\t\t// @ts-expect-error\n\t\t\toptions = { ...this.options, ...options }\n\t\t}\n\t}\n\n\t/**\n\t * Whether this overlay util's overlays should currently be active.\n\t * Checked reactively to determine which overlays exist at any given time.\n\t */\n\tabstract isActive(): boolean\n\n\t/**\n\t * Returns the overlay instances that currently exist.\n\t * Called only when `isActive()` returns true.\n\t */\n\tabstract getOverlays(): T[]\n\n\t/**\n\t * Returns hit-test geometry for an overlay instance, in page coordinates.\n\t * Return null for non-interactive overlays (e.g. snap indicators, scribbles).\n\t */\n\tgetGeometry(_overlay: T): Geometry2d | null {\n\t\treturn null\n\t}\n\n\t/**\n\t * Returns the cursor type to show when hovering this overlay.\n\t */\n\tgetCursor(_overlay: T): TLCursorType | undefined {\n\t\treturn undefined\n\t}\n\n\t/**\n\t * Called when the user points down on this overlay, before the default\n\t * routing runs. Acts as an interrupt: define it to take over the event.\n\t *\n\t * Return `false` to continue with the default behavior (e.g. the\n\t * built-in rotate/resize handle transitions or shape-handle dispatch).\n\t * Return `true` \u2014 or nothing at all \u2014 to skip the default. In other\n\t * words, once you override this method you own the event unless you\n\t * explicitly opt back in by returning `false`.\n\t */\n\tonPointerDown?(overlay: T, info: TLPointerEventInfo): boolean | void\n\n\t/**\n\t * Render all active overlays into the canvas context.\n\t * The context is already transformed to page space (camera transform applied).\n\t * Called reactively when overlays or editor state changes.\n\t */\n\trender(_ctx: CanvasRenderingContext2D, _overlays: T[]): void {}\n\n\t/**\n\t * Optional: render all active overlays into the minimap canvas.\n\t * The context is already transformed to page space (minimap camera applied),\n\t * so overlays can use the same page-space coordinates as in {@link OverlayUtil.render}.\n\t *\n\t * `zoom` is the minimap's screen-pixels-per-page-unit, analogous to\n\t * `editor.getCamera().z`; use `1 / zoom` for one-minimap-pixel line widths.\n\t *\n\t * Most overlays should leave this blank \u2014 only overlays that are meaningful\n\t * at minimap scale (e.g. brushes, collaborator cursors) should opt in.\n\t */\n\trenderMinimap(_ctx: CanvasRenderingContext2D, _overlays: T[], _zoom: number): void {}\n\n\t/**\n\t * Clean up any resources held by this overlay util.\n\t */\n\tdispose(): void {}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CO,MAAe,YAA6C;AAAA,EAClE,YAAmB,QAAgB;AAAhB;AAAA,EAAiB;AAAA,EAAjB;AAAA,EACnB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaP,UAA+B,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYhC,OAAO,UAEN,SACI;AAEJ,WAAO,cAAc,KAAK;AAAA;AAAA,MAEzB,UAAU,EAAE,GAAG,KAAK,SAAS,GAAG,QAAQ;AAAA,IACzC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,YAAY,UAAgC;AAC3C,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,UAAuC;AAChD,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,OAAO,MAAgC,WAAsB;AAAA,EAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAa9D,cAAc,MAAgC,WAAgB,OAAqB;AAAA,EAAC;AAAA;AAAA;AAAA;AAAA,EAKpF,UAAgB;AAAA,EAAC;AAClB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -121,7 +121,7 @@ class GroupShapeUtil extends import_ShapeUtil.ShapeUtil {
|
|
|
121
121
|
if (this.editor.getCurrentPageState().focusedGroupId === group.id) {
|
|
122
122
|
this.editor.popFocusedGroupId();
|
|
123
123
|
}
|
|
124
|
-
this.editor.reparentShapes(children, group.parentId);
|
|
124
|
+
this.editor.reparentShapes(children, group.parentId, group.index);
|
|
125
125
|
this.editor.deleteShapes([group.id]);
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/editor/shapes/group/GroupShapeUtil.tsx"],
|
|
4
|
-
"sourcesContent": ["import { TLGroupShape, groupShapeMigrations, groupShapeProps } from '@tldraw/tlschema'\nimport { SVGContainer } from '../../../components/SVGContainer'\nimport { Geometry2d } from '../../../primitives/geometry/Geometry2d'\nimport { Group2d } from '../../../primitives/geometry/Group2d'\nimport { Rectangle2d } from '../../../primitives/geometry/Rectangle2d'\nimport { ShapeUtil } from '../ShapeUtil'\nimport { getPerfectDashProps } from '../shared/getPerfectDashProps'\nimport { DashedOutlineBox } from './DashedOutlineBox'\n\n/** @public */\nexport class GroupShapeUtil extends ShapeUtil<TLGroupShape> {\n\tstatic override type = 'group' as const\n\tstatic override props = groupShapeProps\n\tstatic override migrations = groupShapeMigrations\n\n\toverride hideSelectionBoundsFg(shape: TLGroupShape) {\n\t\treturn true\n\t}\n\n\toverride canBind() {\n\t\treturn false\n\t}\n\n\tcanResize() {\n\t\treturn true\n\t}\n\n\tcanResizeChildren() {\n\t\treturn true\n\t}\n\n\tgetDefaultProps(): TLGroupShape['props'] {\n\t\treturn {}\n\t}\n\n\tgetGeometry(shape: TLGroupShape): Geometry2d {\n\t\tconst children = this.editor.getSortedChildIdsForParent(shape.id)\n\t\tif (children.length === 0) {\n\t\t\treturn new Rectangle2d({ width: 1, height: 1, isFilled: false })\n\t\t}\n\n\t\treturn new Group2d({\n\t\t\tchildren: children.map((childId) => {\n\t\t\t\tconst shape = this.editor.getShape(childId)!\n\t\t\t\treturn this.editor\n\t\t\t\t\t.getShapeGeometry(childId)\n\t\t\t\t\t.transform(this.editor.getShapeLocalTransform(shape)!, { isLabel: false })\n\t\t\t}),\n\t\t})\n\t}\n\n\tcomponent(shape: TLGroupShape) {\n\t\tconst isErasing = this.editor.getErasingShapeIds().includes(shape.id)\n\n\t\tconst { hintingShapeIds } = this.editor.getCurrentPageState()\n\t\tconst isHintingOtherGroup =\n\t\t\thintingShapeIds.length > 0 &&\n\t\t\thintingShapeIds.some(\n\t\t\t\t(id) => id !== shape.id && this.editor.isShapeOfType(this.editor.getShape(id)!, 'group')\n\t\t\t)\n\n\t\tconst isFocused = this.editor.getCurrentPageState().focusedGroupId !== shape.id\n\n\t\tif (\n\t\t\t!isErasing && // always show the outline while we're erasing the group\n\t\t\t// show the outline while the group is focused unless something outside of the group is being hinted\n\t\t\t// this happens dropping shapes from a group onto some outside group\n\t\t\t(isFocused || isHintingOtherGroup)\n\t\t) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst bounds = this.editor.getShapeGeometry(shape).bounds\n\n\t\treturn (\n\t\t\t<SVGContainer>\n\t\t\t\t<DashedOutlineBox className=\"tl-group\" bounds={bounds} />\n\t\t\t</SVGContainer>\n\t\t)\n\t}\n\n\toverride getIndicatorPath(shape: TLGroupShape): Path2D {\n\t\tconst bounds = this.editor.getShapeGeometry(shape).bounds\n\t\tconst zoomLevel = this.editor.getEfficientZoomLevel()\n\t\tconst path = new Path2D()\n\n\t\tfor (const side of bounds.sides) {\n\t\t\tconst [start, end] = side\n\t\t\tconst length = start.dist(end)\n\t\t\tif (length <= 0) continue\n\n\t\t\tconst { strokeDasharray, strokeDashoffset } = getPerfectDashProps(length, 1 / zoomLevel, {\n\t\t\t\tstyle: 'dashed',\n\t\t\t\tlengthRatio: 4,\n\t\t\t})\n\n\t\t\tif (strokeDasharray === 'none') {\n\t\t\t\tpath.moveTo(start.x, start.y)\n\t\t\t\tpath.lineTo(end.x, end.y)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst [dashLength, gapLength] = strokeDasharray.split(' ').map(Number)\n\t\t\tconst dashOffset = Number(strokeDashoffset)\n\t\t\tconst period = dashLength + gapLength\n\t\t\tif (!Number.isFinite(period) || period <= 0) continue\n\n\t\t\tconst dx = (end.x - start.x) / length\n\t\t\tconst dy = (end.y - start.y) / length\n\n\t\t\tfor (let dashStart = -dashOffset; dashStart < length; dashStart += period) {\n\t\t\t\tconst dashEnd = Math.min(length, dashStart + dashLength)\n\t\t\t\tconst clippedDashStart = Math.max(0, dashStart)\n\t\t\t\tif (dashEnd <= clippedDashStart) continue\n\n\t\t\t\tpath.moveTo(start.x + dx * clippedDashStart, start.y + dy * clippedDashStart)\n\t\t\t\tpath.lineTo(start.x + dx * dashEnd, start.y + dy * dashEnd)\n\t\t\t}\n\t\t}\n\n\t\treturn path\n\t}\n\n\toverride onChildrenChange(group: TLGroupShape) {\n\t\tconst children = this.editor.getSortedChildIdsForParent(group.id)\n\t\tif (children.length === 0) {\n\t\t\tif (this.editor.getCurrentPageState().focusedGroupId === group.id) {\n\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t}\n\t\t\tthis.editor.deleteShapes([group.id])\n\t\t\treturn\n\t\t} else if (children.length === 1) {\n\t\t\tif (this.editor.getCurrentPageState().focusedGroupId === group.id) {\n\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t}\n\t\t\tthis.editor.reparentShapes(children, group.parentId)\n\t\t\tthis.editor.deleteShapes([group.id])\n\t\t\treturn\n\t\t}\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AA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WAAW,iBAAkB;AAEjC,aAAK,OAAO,MAAM,IAAI,KAAK,kBAAkB,MAAM,IAAI,KAAK,gBAAgB;AAC5E,aAAK,OAAO,MAAM,IAAI,KAAK,SAAS,MAAM,IAAI,KAAK,OAAO;AAAA,MAC3D;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAAA,EAES,iBAAiB,OAAqB;AAC9C,UAAM,WAAW,KAAK,OAAO,2BAA2B,MAAM,EAAE;AAChE,QAAI,SAAS,WAAW,GAAG;AAC1B,UAAI,KAAK,OAAO,oBAAoB,EAAE,mBAAmB,MAAM,IAAI;AAClE,aAAK,OAAO,kBAAkB;AAAA,MAC/B;AACA,WAAK,OAAO,aAAa,CAAC,MAAM,EAAE,CAAC;AACnC;AAAA,IACD,WAAW,SAAS,WAAW,GAAG;AACjC,UAAI,KAAK,OAAO,oBAAoB,EAAE,mBAAmB,MAAM,IAAI;AAClE,aAAK,OAAO,kBAAkB;AAAA,MAC/B;AACA,WAAK,OAAO,eAAe,UAAU,MAAM,
|
|
4
|
+
"sourcesContent": ["import { TLGroupShape, groupShapeMigrations, groupShapeProps } from '@tldraw/tlschema'\nimport { SVGContainer } from '../../../components/SVGContainer'\nimport { Geometry2d } from '../../../primitives/geometry/Geometry2d'\nimport { Group2d } from '../../../primitives/geometry/Group2d'\nimport { Rectangle2d } from '../../../primitives/geometry/Rectangle2d'\nimport { ShapeUtil } from '../ShapeUtil'\nimport { getPerfectDashProps } from '../shared/getPerfectDashProps'\nimport { DashedOutlineBox } from './DashedOutlineBox'\n\n/** @public */\nexport class GroupShapeUtil extends ShapeUtil<TLGroupShape> {\n\tstatic override type = 'group' as const\n\tstatic override props = groupShapeProps\n\tstatic override migrations = groupShapeMigrations\n\n\toverride hideSelectionBoundsFg(shape: TLGroupShape) {\n\t\treturn true\n\t}\n\n\toverride canBind() {\n\t\treturn false\n\t}\n\n\tcanResize() {\n\t\treturn true\n\t}\n\n\tcanResizeChildren() {\n\t\treturn true\n\t}\n\n\tgetDefaultProps(): TLGroupShape['props'] {\n\t\treturn {}\n\t}\n\n\tgetGeometry(shape: TLGroupShape): Geometry2d {\n\t\tconst children = this.editor.getSortedChildIdsForParent(shape.id)\n\t\tif (children.length === 0) {\n\t\t\treturn new Rectangle2d({ width: 1, height: 1, isFilled: false })\n\t\t}\n\n\t\treturn new Group2d({\n\t\t\tchildren: children.map((childId) => {\n\t\t\t\tconst shape = this.editor.getShape(childId)!\n\t\t\t\treturn this.editor\n\t\t\t\t\t.getShapeGeometry(childId)\n\t\t\t\t\t.transform(this.editor.getShapeLocalTransform(shape)!, { isLabel: false })\n\t\t\t}),\n\t\t})\n\t}\n\n\tcomponent(shape: TLGroupShape) {\n\t\tconst isErasing = this.editor.getErasingShapeIds().includes(shape.id)\n\n\t\tconst { hintingShapeIds } = this.editor.getCurrentPageState()\n\t\tconst isHintingOtherGroup =\n\t\t\thintingShapeIds.length > 0 &&\n\t\t\thintingShapeIds.some(\n\t\t\t\t(id) => id !== shape.id && this.editor.isShapeOfType(this.editor.getShape(id)!, 'group')\n\t\t\t)\n\n\t\tconst isFocused = this.editor.getCurrentPageState().focusedGroupId !== shape.id\n\n\t\tif (\n\t\t\t!isErasing && // always show the outline while we're erasing the group\n\t\t\t// show the outline while the group is focused unless something outside of the group is being hinted\n\t\t\t// this happens dropping shapes from a group onto some outside group\n\t\t\t(isFocused || isHintingOtherGroup)\n\t\t) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst bounds = this.editor.getShapeGeometry(shape).bounds\n\n\t\treturn (\n\t\t\t<SVGContainer>\n\t\t\t\t<DashedOutlineBox className=\"tl-group\" bounds={bounds} />\n\t\t\t</SVGContainer>\n\t\t)\n\t}\n\n\toverride getIndicatorPath(shape: TLGroupShape): Path2D {\n\t\tconst bounds = this.editor.getShapeGeometry(shape).bounds\n\t\tconst zoomLevel = this.editor.getEfficientZoomLevel()\n\t\tconst path = new Path2D()\n\n\t\tfor (const side of bounds.sides) {\n\t\t\tconst [start, end] = side\n\t\t\tconst length = start.dist(end)\n\t\t\tif (length <= 0) continue\n\n\t\t\tconst { strokeDasharray, strokeDashoffset } = getPerfectDashProps(length, 1 / zoomLevel, {\n\t\t\t\tstyle: 'dashed',\n\t\t\t\tlengthRatio: 4,\n\t\t\t})\n\n\t\t\tif (strokeDasharray === 'none') {\n\t\t\t\tpath.moveTo(start.x, start.y)\n\t\t\t\tpath.lineTo(end.x, end.y)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst [dashLength, gapLength] = strokeDasharray.split(' ').map(Number)\n\t\t\tconst dashOffset = Number(strokeDashoffset)\n\t\t\tconst period = dashLength + gapLength\n\t\t\tif (!Number.isFinite(period) || period <= 0) continue\n\n\t\t\tconst dx = (end.x - start.x) / length\n\t\t\tconst dy = (end.y - start.y) / length\n\n\t\t\tfor (let dashStart = -dashOffset; dashStart < length; dashStart += period) {\n\t\t\t\tconst dashEnd = Math.min(length, dashStart + dashLength)\n\t\t\t\tconst clippedDashStart = Math.max(0, dashStart)\n\t\t\t\tif (dashEnd <= clippedDashStart) continue\n\n\t\t\t\tpath.moveTo(start.x + dx * clippedDashStart, start.y + dy * clippedDashStart)\n\t\t\t\tpath.lineTo(start.x + dx * dashEnd, start.y + dy * dashEnd)\n\t\t\t}\n\t\t}\n\n\t\treturn path\n\t}\n\n\toverride onChildrenChange(group: TLGroupShape) {\n\t\tconst children = this.editor.getSortedChildIdsForParent(group.id)\n\t\tif (children.length === 0) {\n\t\t\tif (this.editor.getCurrentPageState().focusedGroupId === group.id) {\n\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t}\n\t\t\tthis.editor.deleteShapes([group.id])\n\t\t\treturn\n\t\t} else if (children.length === 1) {\n\t\t\tif (this.editor.getCurrentPageState().focusedGroupId === group.id) {\n\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t}\n\t\t\tthis.editor.reparentShapes(children, group.parentId, group.index)\n\t\t\tthis.editor.deleteShapes([group.id])\n\t\t\treturn\n\t\t}\n\t}\n}\n"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mBAAmB,KAAK,IAAI,GAAG,SAAS;AAC9C,YAAI,WAAW,iBAAkB;AAEjC,aAAK,OAAO,MAAM,IAAI,KAAK,kBAAkB,MAAM,IAAI,KAAK,gBAAgB;AAC5E,aAAK,OAAO,MAAM,IAAI,KAAK,SAAS,MAAM,IAAI,KAAK,OAAO;AAAA,MAC3D;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAAA,EAES,iBAAiB,OAAqB;AAC9C,UAAM,WAAW,KAAK,OAAO,2BAA2B,MAAM,EAAE;AAChE,QAAI,SAAS,WAAW,GAAG;AAC1B,UAAI,KAAK,OAAO,oBAAoB,EAAE,mBAAmB,MAAM,IAAI;AAClE,aAAK,OAAO,kBAAkB;AAAA,MAC/B;AACA,WAAK,OAAO,aAAa,CAAC,MAAM,EAAE,CAAC;AACnC;AAAA,IACD,WAAW,SAAS,WAAW,GAAG;AACjC,UAAI,KAAK,OAAO,oBAAoB,EAAE,mBAAmB,MAAM,IAAI;AAClE,aAAK,OAAO,kBAAkB;AAAA,MAC/B;AACA,WAAK,OAAO,eAAe,UAAU,MAAM,UAAU,MAAM,KAAK;AAChE,WAAK,OAAO,aAAa,CAAC,MAAM,EAAE,CAAC;AACnC;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["shape"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/hooks/usePeerIds.ts"],
|
|
4
|
-
"sourcesContent": ["import { useComputed, useValue } from '@tldraw/state-react'\nimport { uniq } from '../utils/uniq'\nimport { useEditor } from './useEditor'\n\n/**\n * Reactive list of peer user IDs for collaborators currently shown in the UI.\n * Mirrors {@link Editor.getVisibleCollaborators} \u2014 peers fade out as they\n * transition to idle/inactive, without requiring a manual re-render.\n *\n * @returns The list of peer UserIDs\n * @public\n */\nexport function usePeerIds() {\n\tconst editor = useEditor()\n\n\tconst $userIds = useComputed(\n\t\t'userIds',\n\t\t() => uniq(editor.getVisibleCollaborators().map((p) => p.userId)).sort(),\n\t\t{ isEqual: (a, b) => a.join(',') === b.join?.(',') },\n\t\t[editor]\n\t)\n\n\treturn useValue($userIds)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAsC;AACtC,kBAAqB;AACrB,uBAA0B;
|
|
4
|
+
"sourcesContent": ["import { useComputed, useValue } from '@tldraw/state-react'\nimport { uniq } from '../utils/uniq'\nimport { useEditor } from './useEditor'\n\n/**\n * Reactive list of peer user IDs for collaborators currently shown in the UI.\n * This list includes user ids who are not on the user's current page.\n * Mirrors {@link Editor.getVisibleCollaborators} \u2014 peers fade out as they\n * transition to idle/inactive, without requiring a manual re-render.\n *\n * @returns The list of peer UserIDs\n * @public\n */\nexport function usePeerIds() {\n\tconst editor = useEditor()\n\n\tconst $userIds = useComputed(\n\t\t'userIds',\n\t\t() => uniq(editor.getVisibleCollaborators().map((p) => p.userId)).sort(),\n\t\t{ isEqual: (a, b) => a.join(',') === b.join?.(',') },\n\t\t[editor]\n\t)\n\n\treturn useValue($userIds)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAsC;AACtC,kBAAqB;AACrB,uBAA0B;AAWnB,SAAS,aAAa;AAC5B,QAAM,aAAS,4BAAU;AAEzB,QAAM,eAAW;AAAA,IAChB;AAAA,IACA,UAAM,kBAAK,OAAO,wBAAwB,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK;AAAA,IACvE,EAAE,SAAS,CAAC,GAAG,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,OAAO,GAAG,EAAE;AAAA,IACnD,CAAC,MAAM;AAAA,EACR;AAEA,aAAO,6BAAS,QAAQ;AACzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-cjs/lib/options.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/options.ts"],
|
|
4
|
-
"sourcesContent": ["import { Awaitable } from '@tldraw/utils'\nimport { ComponentType, Fragment } from 'react'\nimport { DEFAULT_CAMERA_OPTIONS } from './constants'\nimport type { Editor } from './editor/Editor'\nimport { TLContent } from './editor/types/clipboard-types'\nimport { TLExternalContent } from './editor/types/external-content'\nimport { TLCameraOptions } from './editor/types/misc-types'\nimport { VecLike } from './primitives/Vec'\nimport { TLDeepLinkOptions } from './utils/deepLinks'\nimport { TLTextOptions } from './utils/richText'\n\n/**\n * Identifies how a clipboard write was triggered (copy vs cut, keyboard vs menu).\n *\n * @public\n */\nexport interface TLClipboardWriteInfo {\n\treadonly operation: 'copy' | 'cut'\n\treadonly source: 'native' | 'menu'\n}\n\n/**\n * Raw clipboard paste payload, before tldraw parses clipboard contents into {@link TLExternalContent}.\n *\n * - `native-event`: from the `paste` event \u2014 `clipboardData` is available synchronously (unlike async\n * `navigator.clipboard.read()`).\n * - `clipboard-read`: from an explicit `navigator.clipboard.read()` call \u2014 only `ClipboardItem[]`\n * exists\n * (no `DataTransfer`).\n *\n * @public\n */\nexport type TLClipboardPasteRawInfo =\n\t| {\n\t\t\treadonly editor: Editor\n\t\t\treadonly source: 'native-event'\n\t\t\treadonly event: ClipboardEvent\n\t\t\treadonly clipboardData: DataTransfer | null\n\t\t\treadonly point: VecLike | undefined\n\t }\n\t| {\n\t\t\treadonly editor: Editor\n\t\t\treadonly source: 'clipboard-read'\n\t\t\treadonly clipboardItems: readonly ClipboardItem[]\n\t\t\treadonly point: VecLike | undefined\n\t }\n\n/**\n * Options for configuring tldraw. For defaults, see {@link defaultTldrawOptions}.\n *\n * @example\n * ```tsx\n * const options: Partial<TldrawOptions> = {\n * maxPages: 3,\n * maxShapesPerPage: 1000,\n * }\n *\n * function MyTldrawComponent() {\n * return <Tldraw options={options} />\n * }\n * ```\n *\n * @public\n */\nexport interface TldrawOptions {\n\treadonly maxShapesPerPage: number\n\treadonly maxFilesAtOnce: number\n\treadonly maxPages: number\n\treadonly animationMediumMs: number\n\treadonly followChaseViewportSnap: number\n\treadonly doubleClickDurationMs: number\n\treadonly multiClickDurationMs: number\n\treadonly coarseDragDistanceSquared: number\n\treadonly dragDistanceSquared: number\n\treadonly uiDragDistanceSquared: number\n\treadonly uiCoarseDragDistanceSquared: number\n\treadonly defaultSvgPadding: number\n\treadonly cameraSlideFriction: number\n\treadonly gridSteps: readonly {\n\t\treadonly min: number\n\t\treadonly mid: number\n\t\treadonly step: number\n\t}[]\n\treadonly collaboratorInactiveTimeoutMs: number\n\treadonly collaboratorIdleTimeoutMs: number\n\treadonly collaboratorCheckIntervalMs: number\n\treadonly cameraMovingTimeoutMs: number\n\treadonly hitTestMargin: number\n\treadonly edgeScrollDelay: number\n\treadonly edgeScrollEaseDuration: number\n\treadonly edgeScrollSpeed: number\n\treadonly edgeScrollDistance: number\n\treadonly coarsePointerWidth: number\n\treadonly coarseHandleRadius: number\n\treadonly handleRadius: number\n\treadonly longPressDurationMs: number\n\treadonly textShadowLod: number\n\treadonly adjacentShapeMargin: number\n\treadonly flattenImageBoundsExpand: number\n\treadonly flattenImageBoundsPadding: number\n\treadonly laserDelayMs: number\n\t/**\n\t * How long (in milliseconds) to fade all laser scribbles after the session ends.\n\t * The total points across all scribbles will be removed proportionally over this duration.\n\t * Defaults to 500ms (0.5 seconds).\n\t */\n\treadonly laserFadeoutMs: number\n\treadonly maxExportDelayMs: number\n\treadonly tooltipDelayMs: number\n\t/**\n\t * How long should previews created by {@link Editor.createTemporaryAssetPreview} last before\n\t * they expire? Defaults to 3 minutes.\n\t */\n\treadonly temporaryAssetPreviewLifetimeMs: number\n\treadonly actionShortcutsLocation: 'menu' | 'toolbar' | 'swap'\n\treadonly createTextOnCanvasDoubleClick: boolean\n\t/**\n\t * The react provider to use when exporting an image. This is useful if your shapes depend on\n\t * external context providers. By default, this is `React.Fragment`.\n\t */\n\treadonly exportProvider: ComponentType<{ children: React.ReactNode }>\n\t/**\n\t * By default, the toolbar items are accessible via number shortcuts according to their order. To disable this, set this option to false.\n\t */\n\treadonly enableToolbarKeyboardShortcuts: boolean\n\t/**\n\t * The maximum number of fonts that will be loaded while blocking the main rendering of the\n\t * canvas. If there are more than this number of fonts needed, we'll just show the canvas right\n\t * away and let the fonts load in in the background.\n\t */\n\treadonly maxFontsToLoadBeforeRender: number\n\t/**\n\t * If you have a CSP policy that blocks inline styles, you can use this prop to provide a\n\t * nonce to use in the editor's styles.\n\t */\n\treadonly nonce: string | undefined\n\t/**\n\t * Branding name of the app, currently only used for adding aria-label for the application.\n\t */\n\treadonly branding?: string\n\t/**\n\t * Whether to use debounced zoom level for certain rendering optimizations. When true,\n\t * `editor.getEfficientZoomLevel()` returns a cached zoom value while the camera is moving,\n\t * reducing re-renders. When false, it always returns the current zoom level.\n\t */\n\treadonly debouncedZoom: boolean\n\t/**\n\t * The number of shapes that must be on the page for the debounced zoom level to be used.\n\t * Defaults to 500 shapes.\n\t */\n\treadonly debouncedZoomThreshold: number\n\t/**\n\t * Whether to allow spacebar panning. When true, the spacebar will pan the camera when held down.\n\t * When false, the spacebar will not pan the camera.\n\t */\n\treadonly spacebarPanning: boolean\n\t/**\n\t * Whether to allow right-click + drag to pan the camera. When true, right-click + drag pans the\n\t * camera and a static right-click opens the context menu at the release position. When false,\n\t * right-click opens the context menu on press (no drag-to-pan).\n\t */\n\treadonly rightClickPanning: boolean\n\t/**\n\t * The default padding (in pixels) used when zooming to fit content in the viewport.\n\t * This affects methods like `zoomToFit()`, `zoomToSelection()`, and `zoomToBounds()`.\n\t * The actual padding used is the minimum of this value and 28% of the viewport width.\n\t * Defaults to 128 pixels.\n\t */\n\treadonly zoomToFitPadding: number\n\t/**\n\t * The distance (in screen pixels) at which shapes snap to guides and other shapes.\n\t */\n\treadonly snapThreshold: number\n\t/**\n\t * Options for the editor's camera. These are the initial camera options.\n\t * Use {@link Editor.setCameraOptions} to update camera options at runtime.\n\t */\n\treadonly camera: Partial<TLCameraOptions>\n\t/**\n\t * Options for the editor's text rendering. These include TipTap configuration and\n\t * font handling. These are the initial text options and cannot be changed at runtime.\n\t */\n\treadonly text: TLTextOptions\n\t/**\n\t * Options for syncing the editor's camera state with the URL. Set to `true` to enable\n\t * with default options, or pass an options object to customize behavior.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Enable with defaults\n\t * <Tldraw options={{ deepLinks: true }} />\n\t *\n\t * // Enable with custom options\n\t * <Tldraw options={{ deepLinks: { param: 'd', debounceMs: 500 } }} />\n\t * ```\n\t */\n\treadonly deepLinks: true | TLDeepLinkOptions | undefined\n\t/**\n\t * Whether the quick-zoom brush preserves its screen-pixel size when the user\n\t * zooms the overview. When true, zooming in shrinks the target viewport (higher\n\t * return zoom); zooming out expands it. When false, the brush keeps the original\n\t * viewport's page dimensions regardless of overview zoom changes.\n\t */\n\treadonly quickZoomPreservesScreenBounds: boolean\n\t/**\n\t * Called before content is written to the clipboard during a copy or cut operation.\n\t * Receives the serialized content (shapes, bindings, assets) and can filter or transform\n\t * it before it reaches the clipboard.\n\t *\n\t * Return a modified `TLContent` object to change what is copied or cut. Return `false` to\n\t * cancel the clipboard write (for cut, the selected shapes are not removed). Return `void`\n\t * (or `undefined`) to pass through unchanged. You may return a `Promise` of those values if\n\t * the hook is async.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Filter out \"locked\" shapes from copy\n\t * onBeforeCopyToClipboard({ content, operation }) {\n\t * return {\n\t * ...content,\n\t * shapes: content.shapes.filter(s => !s.meta.locked),\n\t * rootShapeIds: content.rootShapeIds.filter(id =>\n\t * content.shapes.find(s => s.id === id && !s.meta.locked)\n\t * ),\n\t * }\n\t * }\n\t * ```\n\t */\n\tonBeforeCopyToClipboard?(\n\t\tinfo: { editor: Editor; content: TLContent } & TLClipboardWriteInfo\n\t): Awaitable<TLContent | false | void>\n\t/**\n\t * Called before pasted content is processed and shapes are created. Receives the parsed\n\t * external content from the clipboard and can filter, transform, or cancel it.\n\t *\n\t * Return `false` to cancel the paste. Return a modified content object to transform it.\n\t * Return `void` (or `undefined`) to pass through unchanged. You may return a `Promise` of\n\t * those values if the hook is async.\n\t *\n\t * This only fires for clipboard paste operations (keyboard shortcuts and menu actions),\n\t * not for file drops or programmatic `putExternalContent` calls.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Block pasting of image files\n\t * onBeforePasteFromClipboard({ content }) {\n\t * if (content.type === 'files') {\n\t * const nonImages = content.files.filter(f => !f.type.startsWith('image/'))\n\t * if (nonImages.length === 0) return false\n\t * return { ...content, files: nonImages }\n\t * }\n\t * }\n\t * ```\n\t */\n\tonBeforePasteFromClipboard?(info: {\n\t\teditor: Editor\n\t\tcontent: TLExternalContent<unknown>\n\t\tsource: 'native-event' | 'clipboard-read'\n\t\tpoint?: VecLike\n\t}): Awaitable<TLExternalContent<unknown> | false | void>\n\t/**\n\t * Called first for keyboard and menu paste, **before** tldraw handles or parses clipboard data\n\t * (and before {@link TldrawOptions.onBeforePasteFromClipboard}).\n\t *\n\t * Return `false` to cancel tldraw's default paste handling for this gesture (same convention as\n\t * {@link TldrawOptions.onBeforePasteFromClipboard}). Use this when you handle paste yourself from\n\t * raw clipboard data, or to block the gesture entirely. Return `void` (or `undefined`) to continue.\n\t */\n\tonClipboardPasteRaw?(info: TLClipboardPasteRawInfo): false | void\n\t/**\n\t * Called when content is dropped on the canvas. Provides the page position\n\t * where the drop occurred and the underlying drag event object.\n\t * Return true to prevent default drop handling (files, URLs, etc.)\n\t */\n\texperimental__onDropOnCanvas?(options: {\n\t\tpoint: VecLike\n\t\tevent: React.DragEvent<Element>\n\t}): boolean\n}\n\n/** @public */\nexport const defaultTldrawOptions = {\n\tmaxShapesPerPage: 4000,\n\tmaxFilesAtOnce: 100,\n\tmaxPages: 40,\n\tanimationMediumMs: 320,\n\tfollowChaseViewportSnap: 2,\n\tdoubleClickDurationMs: 450,\n\tmultiClickDurationMs: 200,\n\tcoarseDragDistanceSquared: 36, // 6 squared\n\tdragDistanceSquared: 16, // 4 squared\n\tuiDragDistanceSquared: 16, // 4 squared\n\t// it's really easy to accidentally drag from the toolbar on mobile, so we use a much larger\n\t// threshold than usual here to try and prevent accidental drags.\n\tuiCoarseDragDistanceSquared: 625, // 25 squared\n\tdefaultSvgPadding: 32,\n\tcameraSlideFriction: 0.09,\n\tgridSteps: [\n\t\t{ min: -1, mid: 0.15, step: 64 },\n\t\t{ min: 0.05, mid: 0.375, step: 16 },\n\t\t{ min: 0.15, mid: 1, step: 4 },\n\t\t{ min: 0.7, mid: 2.5, step: 1 },\n\t],\n\tcollaboratorInactiveTimeoutMs: 60000,\n\tcollaboratorIdleTimeoutMs: 3000,\n\tcollaboratorCheckIntervalMs: 1200,\n\tcameraMovingTimeoutMs: 64,\n\thitTestMargin: 8,\n\tedgeScrollDelay: 200,\n\tedgeScrollEaseDuration: 200,\n\tedgeScrollSpeed: 25,\n\tedgeScrollDistance: 8,\n\tcoarsePointerWidth: 12,\n\tcoarseHandleRadius: 20,\n\thandleRadius: 12,\n\tlongPressDurationMs: 500,\n\ttextShadowLod: 0.35,\n\tadjacentShapeMargin: 10,\n\tflattenImageBoundsExpand: 64,\n\tflattenImageBoundsPadding: 16,\n\tlaserDelayMs: 1200,\n\tlaserFadeoutMs: 500,\n\tmaxExportDelayMs: 5000,\n\ttooltipDelayMs: 700,\n\ttemporaryAssetPreviewLifetimeMs: 180000,\n\tactionShortcutsLocation: 'swap',\n\tcreateTextOnCanvasDoubleClick: true,\n\texportProvider: Fragment,\n\tenableToolbarKeyboardShortcuts: true,\n\tmaxFontsToLoadBeforeRender: Infinity,\n\tnonce: undefined,\n\tdebouncedZoom: true,\n\tdebouncedZoomThreshold: 500,\n\tspacebarPanning: true,\n\trightClickPanning: true,\n\tzoomToFitPadding: 128,\n\tsnapThreshold: 8,\n\tcamera: DEFAULT_CAMERA_OPTIONS,\n\ttext: {},\n\tdeepLinks: undefined,\n\tquickZoomPreservesScreenBounds: true,\n\tonBeforeCopyToClipboard: undefined,\n\tonBeforePasteFromClipboard: undefined,\n\tonClipboardPasteRaw: undefined,\n\texperimental__onDropOnCanvas: undefined,\n} as const satisfies TldrawOptions\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAwC;AACxC,uBAAuC;
|
|
4
|
+
"sourcesContent": ["import { Awaitable } from '@tldraw/utils'\nimport { ComponentType, Fragment } from 'react'\nimport { DEFAULT_CAMERA_OPTIONS } from './constants'\nimport type { Editor } from './editor/Editor'\nimport { TLContent } from './editor/types/clipboard-types'\nimport { TLExternalContent } from './editor/types/external-content'\nimport { TLCameraOptions } from './editor/types/misc-types'\nimport { VecLike } from './primitives/Vec'\nimport { TLDeepLinkOptions } from './utils/deepLinks'\nimport { TLTextOptions } from './utils/richText'\n\n/**\n * Identifies how a clipboard write was triggered (copy vs cut, keyboard vs menu).\n *\n * @public\n */\nexport interface TLClipboardWriteInfo {\n\treadonly operation: 'copy' | 'cut'\n\treadonly source: 'native' | 'menu'\n}\n\n/**\n * Raw clipboard paste payload, before tldraw parses clipboard contents into {@link TLExternalContent}.\n *\n * - `native-event`: from the `paste` event \u2014 `clipboardData` is available synchronously (unlike async\n * `navigator.clipboard.read()`).\n * - `clipboard-read`: from an explicit `navigator.clipboard.read()` call \u2014 only `ClipboardItem[]`\n * exists\n * (no `DataTransfer`).\n *\n * @public\n */\nexport type TLClipboardPasteRawInfo =\n\t| {\n\t\t\treadonly editor: Editor\n\t\t\treadonly source: 'native-event'\n\t\t\treadonly event: ClipboardEvent\n\t\t\treadonly clipboardData: DataTransfer | null\n\t\t\treadonly point: VecLike | undefined\n\t }\n\t| {\n\t\t\treadonly editor: Editor\n\t\t\treadonly source: 'clipboard-read'\n\t\t\treadonly clipboardItems: readonly ClipboardItem[]\n\t\t\treadonly point: VecLike | undefined\n\t }\n\n/**\n * Options for configuring tldraw. For defaults, see {@link defaultTldrawOptions}.\n *\n * @example\n * ```tsx\n * const options: Partial<TldrawOptions> = {\n * maxPages: 3,\n * maxShapesPerPage: 1000,\n * }\n *\n * function MyTldrawComponent() {\n * return <Tldraw options={options} />\n * }\n * ```\n *\n * @public\n */\nexport interface TldrawOptions {\n\treadonly maxShapesPerPage: number\n\treadonly maxFilesAtOnce: number\n\treadonly maxPages: number\n\treadonly animationMediumMs: number\n\treadonly followChaseViewportSnap: number\n\treadonly doubleClickDurationMs: number\n\treadonly multiClickDurationMs: number\n\treadonly coarseDragDistanceSquared: number\n\treadonly dragDistanceSquared: number\n\treadonly uiDragDistanceSquared: number\n\treadonly uiCoarseDragDistanceSquared: number\n\treadonly defaultSvgPadding: number\n\treadonly cameraSlideFriction: number\n\treadonly gridSteps: readonly {\n\t\treadonly min: number\n\t\treadonly mid: number\n\t\treadonly step: number\n\t}[]\n\treadonly collaboratorInactiveTimeoutMs: number\n\treadonly collaboratorIdleTimeoutMs: number\n\treadonly collaboratorCheckIntervalMs: number\n\treadonly cameraMovingTimeoutMs: number\n\treadonly hitTestMargin: number\n\treadonly edgeScrollDelay: number\n\treadonly edgeScrollEaseDuration: number\n\treadonly edgeScrollSpeed: number\n\treadonly edgeScrollDistance: number\n\treadonly coarsePointerWidth: number\n\treadonly coarseHandleRadius: number\n\treadonly handleRadius: number\n\treadonly longPressDurationMs: number\n\treadonly textShadowLod: number\n\treadonly adjacentShapeMargin: number\n\treadonly flattenImageBoundsExpand: number\n\treadonly flattenImageBoundsPadding: number\n\treadonly laserDelayMs: number\n\t/**\n\t * How long (in milliseconds) to fade all laser scribbles after the session ends.\n\t * The total points across all scribbles will be removed proportionally over this duration.\n\t * Defaults to 500ms (0.5 seconds).\n\t */\n\treadonly laserFadeoutMs: number\n\treadonly maxExportDelayMs: number\n\treadonly tooltipDelayMs: number\n\t/**\n\t * How long should previews created by {@link Editor.createTemporaryAssetPreview} last before\n\t * they expire? Defaults to 3 minutes.\n\t */\n\treadonly temporaryAssetPreviewLifetimeMs: number\n\treadonly actionShortcutsLocation: 'menu' | 'toolbar' | 'swap'\n\treadonly createTextOnCanvasDoubleClick: boolean\n\t/**\n\t * The react provider to use when exporting an image. This is useful if your shapes depend on\n\t * external context providers. By default, this is `React.Fragment`.\n\t */\n\treadonly exportProvider: ComponentType<{ children: React.ReactNode }>\n\t/**\n\t * By default, the toolbar items are accessible via number shortcuts according to their order. To disable this, set this option to false.\n\t */\n\treadonly enableToolbarKeyboardShortcuts: boolean\n\t/**\n\t * The maximum number of fonts that will be loaded while blocking the main rendering of the\n\t * canvas. If there are more than this number of fonts needed, we'll just show the canvas right\n\t * away and let the fonts load in in the background.\n\t */\n\treadonly maxFontsToLoadBeforeRender: number\n\t/**\n\t * If you have a CSP policy that blocks inline styles, you can use this prop to provide a\n\t * nonce to use in the editor's styles.\n\t */\n\treadonly nonce: string | undefined\n\t/**\n\t * Branding name of the app, currently only used for adding aria-label for the application.\n\t */\n\treadonly branding?: string\n\t/**\n\t * Whether to use debounced zoom level for certain rendering optimizations. When true,\n\t * `editor.getEfficientZoomLevel()` returns a cached zoom value while the camera is moving,\n\t * reducing re-renders. When false, it always returns the current zoom level.\n\t */\n\treadonly debouncedZoom: boolean\n\t/**\n\t * The number of shapes that must be on the page for the debounced zoom level to be used.\n\t * Defaults to 500 shapes.\n\t */\n\treadonly debouncedZoomThreshold: number\n\t/**\n\t * Whether to allow spacebar panning. When true, the spacebar will pan the camera when held down.\n\t * When false, the spacebar will not pan the camera.\n\t */\n\treadonly spacebarPanning: boolean\n\t/**\n\t * Whether to allow right-click + drag to pan the camera. When true, right-click + drag pans the\n\t * camera and a static right-click opens the context menu at the release position. When false,\n\t * right-click opens the context menu on press (no drag-to-pan).\n\t */\n\treadonly rightClickPanning: boolean\n\t/**\n\t * The default padding (in pixels) used when zooming to fit content in the viewport.\n\t * This affects methods like `zoomToFit()`, `zoomToSelection()`, and `zoomToBounds()`.\n\t * The actual padding used is the minimum of this value and 28% of the viewport width.\n\t * Defaults to 128 pixels.\n\t */\n\treadonly zoomToFitPadding: number\n\t/**\n\t * The distance (in screen pixels) at which shapes snap to guides and other shapes.\n\t */\n\treadonly snapThreshold: number\n\t/**\n\t * Whether locked shapes can be selected with a left click. When false (default), left-clicking\n\t * a locked shape is treated as a click on the canvas \u2014 only right-click selects it. When true,\n\t * locked shapes can be selected via left click and included in brush and scribble selections,\n\t * but the editor's lock guards still prevent moving, resizing, editing, or deleting them.\n\t */\n\treadonly selectLockedShapes: boolean\n\t/**\n\t * Options for the editor's camera. These are the initial camera options.\n\t * Use {@link Editor.setCameraOptions} to update camera options at runtime.\n\t */\n\treadonly camera: Partial<TLCameraOptions>\n\t/**\n\t * Options for the editor's text rendering. These include TipTap configuration and\n\t * font handling. These are the initial text options and cannot be changed at runtime.\n\t */\n\treadonly text: TLTextOptions\n\t/**\n\t * Options for syncing the editor's camera state with the URL. Set to `true` to enable\n\t * with default options, or pass an options object to customize behavior.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Enable with defaults\n\t * <Tldraw options={{ deepLinks: true }} />\n\t *\n\t * // Enable with custom options\n\t * <Tldraw options={{ deepLinks: { param: 'd', debounceMs: 500 } }} />\n\t * ```\n\t */\n\treadonly deepLinks: true | TLDeepLinkOptions | undefined\n\t/**\n\t * Whether the quick-zoom brush preserves its screen-pixel size when the user\n\t * zooms the overview. When true, zooming in shrinks the target viewport (higher\n\t * return zoom); zooming out expands it. When false, the brush keeps the original\n\t * viewport's page dimensions regardless of overview zoom changes.\n\t */\n\treadonly quickZoomPreservesScreenBounds: boolean\n\t/**\n\t * Called before content is written to the clipboard during a copy or cut operation.\n\t * Receives the serialized content (shapes, bindings, assets) and can filter or transform\n\t * it before it reaches the clipboard.\n\t *\n\t * Return a modified `TLContent` object to change what is copied or cut. Return `false` to\n\t * cancel the clipboard write (for cut, the selected shapes are not removed). Return `void`\n\t * (or `undefined`) to pass through unchanged. You may return a `Promise` of those values if\n\t * the hook is async.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Filter out \"locked\" shapes from copy\n\t * onBeforeCopyToClipboard({ content, operation }) {\n\t * return {\n\t * ...content,\n\t * shapes: content.shapes.filter(s => !s.meta.locked),\n\t * rootShapeIds: content.rootShapeIds.filter(id =>\n\t * content.shapes.find(s => s.id === id && !s.meta.locked)\n\t * ),\n\t * }\n\t * }\n\t * ```\n\t */\n\tonBeforeCopyToClipboard?(\n\t\tinfo: { editor: Editor; content: TLContent } & TLClipboardWriteInfo\n\t): Awaitable<TLContent | false | void>\n\t/**\n\t * Called before pasted content is processed and shapes are created. Receives the parsed\n\t * external content from the clipboard and can filter, transform, or cancel it.\n\t *\n\t * Return `false` to cancel the paste. Return a modified content object to transform it.\n\t * Return `void` (or `undefined`) to pass through unchanged. You may return a `Promise` of\n\t * those values if the hook is async.\n\t *\n\t * This only fires for clipboard paste operations (keyboard shortcuts and menu actions),\n\t * not for file drops or programmatic `putExternalContent` calls.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Block pasting of image files\n\t * onBeforePasteFromClipboard({ content }) {\n\t * if (content.type === 'files') {\n\t * const nonImages = content.files.filter(f => !f.type.startsWith('image/'))\n\t * if (nonImages.length === 0) return false\n\t * return { ...content, files: nonImages }\n\t * }\n\t * }\n\t * ```\n\t */\n\tonBeforePasteFromClipboard?(info: {\n\t\teditor: Editor\n\t\tcontent: TLExternalContent<unknown>\n\t\tsource: 'native-event' | 'clipboard-read'\n\t\tpoint?: VecLike\n\t}): Awaitable<TLExternalContent<unknown> | false | void>\n\t/**\n\t * Called first for keyboard and menu paste, **before** tldraw handles or parses clipboard data\n\t * (and before {@link TldrawOptions.onBeforePasteFromClipboard}).\n\t *\n\t * Return `false` to cancel tldraw's default paste handling for this gesture (same convention as\n\t * {@link TldrawOptions.onBeforePasteFromClipboard}). Use this when you handle paste yourself from\n\t * raw clipboard data, or to block the gesture entirely. Return `void` (or `undefined`) to continue.\n\t */\n\tonClipboardPasteRaw?(info: TLClipboardPasteRawInfo): false | void\n\t/**\n\t * Called when content is dropped on the canvas. Provides the page position\n\t * where the drop occurred and the underlying drag event object.\n\t * Return true to prevent default drop handling (files, URLs, etc.)\n\t */\n\texperimental__onDropOnCanvas?(options: {\n\t\tpoint: VecLike\n\t\tevent: React.DragEvent<Element>\n\t}): boolean\n}\n\n/** @public */\nexport const defaultTldrawOptions = {\n\tmaxShapesPerPage: 4000,\n\tmaxFilesAtOnce: 100,\n\tmaxPages: 40,\n\tanimationMediumMs: 320,\n\tfollowChaseViewportSnap: 2,\n\tdoubleClickDurationMs: 450,\n\tmultiClickDurationMs: 200,\n\tcoarseDragDistanceSquared: 36, // 6 squared\n\tdragDistanceSquared: 16, // 4 squared\n\tuiDragDistanceSquared: 16, // 4 squared\n\t// it's really easy to accidentally drag from the toolbar on mobile, so we use a much larger\n\t// threshold than usual here to try and prevent accidental drags.\n\tuiCoarseDragDistanceSquared: 625, // 25 squared\n\tdefaultSvgPadding: 32,\n\tcameraSlideFriction: 0.09,\n\tgridSteps: [\n\t\t{ min: -1, mid: 0.15, step: 64 },\n\t\t{ min: 0.05, mid: 0.375, step: 16 },\n\t\t{ min: 0.15, mid: 1, step: 4 },\n\t\t{ min: 0.7, mid: 2.5, step: 1 },\n\t],\n\tcollaboratorInactiveTimeoutMs: 60000,\n\tcollaboratorIdleTimeoutMs: 3000,\n\tcollaboratorCheckIntervalMs: 1200,\n\tcameraMovingTimeoutMs: 64,\n\thitTestMargin: 8,\n\tedgeScrollDelay: 200,\n\tedgeScrollEaseDuration: 200,\n\tedgeScrollSpeed: 25,\n\tedgeScrollDistance: 8,\n\tcoarsePointerWidth: 12,\n\tcoarseHandleRadius: 20,\n\thandleRadius: 12,\n\tlongPressDurationMs: 500,\n\ttextShadowLod: 0.35,\n\tadjacentShapeMargin: 10,\n\tflattenImageBoundsExpand: 64,\n\tflattenImageBoundsPadding: 16,\n\tlaserDelayMs: 1200,\n\tlaserFadeoutMs: 500,\n\tmaxExportDelayMs: 5000,\n\ttooltipDelayMs: 700,\n\ttemporaryAssetPreviewLifetimeMs: 180000,\n\tactionShortcutsLocation: 'swap',\n\tcreateTextOnCanvasDoubleClick: true,\n\texportProvider: Fragment,\n\tenableToolbarKeyboardShortcuts: true,\n\tmaxFontsToLoadBeforeRender: Infinity,\n\tnonce: undefined,\n\tdebouncedZoom: true,\n\tdebouncedZoomThreshold: 500,\n\tspacebarPanning: true,\n\trightClickPanning: true,\n\tzoomToFitPadding: 128,\n\tsnapThreshold: 8,\n\tselectLockedShapes: false,\n\tcamera: DEFAULT_CAMERA_OPTIONS,\n\ttext: {},\n\tdeepLinks: undefined,\n\tquickZoomPreservesScreenBounds: true,\n\tonBeforeCopyToClipboard: undefined,\n\tonBeforePasteFromClipboard: undefined,\n\tonClipboardPasteRaw: undefined,\n\texperimental__onDropOnCanvas: undefined,\n} as const satisfies TldrawOptions\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAwC;AACxC,uBAAuC;AA8RhC,MAAM,uBAAuB;AAAA,EACnC,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA;AAAA,EAC3B,qBAAqB;AAAA;AAAA,EACrB,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAGvB,6BAA6B;AAAA;AAAA,EAC7B,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,WAAW;AAAA,IACV,EAAE,KAAK,IAAI,KAAK,MAAM,MAAM,GAAG;AAAA,IAC/B,EAAE,KAAK,MAAM,KAAK,OAAO,MAAM,GAAG;AAAA,IAClC,EAAE,KAAK,MAAM,KAAK,GAAG,MAAM,EAAE;AAAA,IAC7B,EAAE,KAAK,KAAK,KAAK,KAAK,MAAM,EAAE;AAAA,EAC/B;AAAA,EACA,+BAA+B;AAAA,EAC/B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,2BAA2B;AAAA,EAC3B,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,iCAAiC;AAAA,EACjC,yBAAyB;AAAA,EACzB,+BAA+B;AAAA,EAC/B,gBAAgB;AAAA,EAChB,gCAAgC;AAAA,EAChC,4BAA4B;AAAA,EAC5B,OAAO;AAAA,EACP,eAAe;AAAA,EACf,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,QAAQ;AAAA,EACR,MAAM,CAAC;AAAA,EACP,WAAW;AAAA,EACX,gCAAgC;AAAA,EAChC,yBAAyB;AAAA,EACzB,4BAA4B;AAAA,EAC5B,qBAAqB;AAAA,EACrB,8BAA8B;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,6 +37,7 @@ function loopToHtmlElement(elm) {
|
|
|
37
37
|
else throw Error("Could not find a parent element of an HTML type!");
|
|
38
38
|
}
|
|
39
39
|
function preventDefault(event) {
|
|
40
|
+
if ("cancelable" in event && !event.cancelable) return;
|
|
40
41
|
event.preventDefault();
|
|
41
42
|
if (import_debug_flags.debugFlags.logPreventDefaults.get()) {
|
|
42
43
|
console.warn("preventDefault called on event:", event);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/utils/dom.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nThis is used to facilitate double clicking and pointer capture on elements.\n\nThe events in this file are possibly set on individual SVG elements, \nsuch as handles or corner handles, rather than on HTML elements or \nSVGSVGElements. Raw SVG elements do not support pointerCapture in\nmost cases, meaning that in order for pointer capture to work, we \nneed to crawl up the DOM tree to find the nearest HTML element. Then,\nin order for that element to also call the `onPointerUp` event from\nthis file, we need to manually set that event on that element and\nlater remove it when the pointerup occurs. This is a potential leak\nif the user clicks on a handle but the pointerup does not fire for\nwhatever reason.\n*/\n\nimport { debugFlags, pointerCaptureTrackingObject } from './debug-flags'\n\n/** @public */\nexport function loopToHtmlElement(elm: Element): HTMLElement {\n\tif (elm.nodeType === Node.ELEMENT_NODE) return elm as HTMLElement\n\tif (elm.parentElement) return loopToHtmlElement(elm.parentElement)\n\telse throw Error('Could not find a parent element of an HTML type!')\n}\n\n/**\n * This function calls `event.preventDefault()` for you. Why is that useful?\n *\n * Because if you enable `window.preventDefaultLogging = true` it'll log out a message when it\n * happens. Because we use console.warn rather than (log) you'll get a stack trace in the inspector\n * telling you exactly where it happened. This is important because `e.preventDefault()` is the\n * source of many bugs, but unfortunately it can't be avoided because it also stops a lot of default\n * behaviour which doesn't make sense in our UI\n *\n * @param event - To prevent default on\n * @public\n */\nexport function preventDefault(event: React.BaseSyntheticEvent | Event) {\n\tevent.preventDefault()\n\tif (debugFlags.logPreventDefaults.get()) {\n\t\tconsole.warn('preventDefault called on event:', event)\n\t}\n}\n\n/** @public */\nexport function setPointerCapture(\n\telement: Element,\n\tevent: React.PointerEvent<Element> | PointerEvent\n) {\n\telement.setPointerCapture(event.pointerId)\n\tif (debugFlags.logPointerCaptures.get()) {\n\t\tconst trackingObj = pointerCaptureTrackingObject.get()\n\t\ttrackingObj.set(element, (trackingObj.get(element) ?? 0) + 1)\n\t\tconsole.warn('setPointerCapture called on element:', element, event)\n\t}\n}\n\n/** @public */\nexport function releasePointerCapture(\n\telement: Element,\n\tevent: React.PointerEvent<Element> | PointerEvent\n) {\n\tif (!element.hasPointerCapture(event.pointerId)) {\n\t\treturn\n\t}\n\n\telement.releasePointerCapture(event.pointerId)\n\tif (debugFlags.logPointerCaptures.get()) {\n\t\tconst trackingObj = pointerCaptureTrackingObject.get()\n\t\tif (trackingObj.get(element) === 1) {\n\t\t\ttrackingObj.delete(element)\n\t\t} else if (trackingObj.has(element)) {\n\t\t\ttrackingObj.set(element, trackingObj.get(element)! - 1)\n\t\t} else {\n\t\t\tconsole.warn('Release without capture')\n\t\t}\n\t\tconsole.warn('releasePointerCapture called on element:', element, event)\n\t}\n}\n\n/**\n * Calls `event.stopPropagation()`.\n *\n * @deprecated Use {@link Editor.markEventAsHandled} instead, or manually call `event.stopPropagation()` if\n * that's what you really want.\n *\n * @public\n */\nexport const stopEventPropagation = (e: any) => e.stopPropagation()\n\n/** @internal */\nexport const setStyleProperty = (\n\telm: HTMLElement | null,\n\tproperty: string,\n\tvalue: string | number\n) => {\n\tif (!elm) return\n\telm.style.setProperty(property, String(value))\n}\n\n/** @internal */\nexport function elementShouldCaptureKeys(el: Element | null, includeButtonsAndMenus = true) {\n\tif (!el) return false\n\n\tconst tagName = el.tagName.toLowerCase()\n\treturn (\n\t\t(el as HTMLElement).isContentEditable ||\n\t\ttagName === 'input' ||\n\t\ttagName === 'textarea' ||\n\t\t(includeButtonsAndMenus && tagName === 'select') ||\n\t\t(includeButtonsAndMenus && tagName === 'button') ||\n\t\tel.classList.contains('tlui-slider__thumb')\n\t)\n}\n\n/**\n * Returns the global `document`. Use this instead of bare `document` to satisfy lint rules.\n *\n * When you have a DOM node or editor instance, prefer the scoped versions instead:\n * - `getOwnerDocument(node)` \u2013 the document that owns a specific DOM node\n * - `editor.getContainerDocument()` \u2013 the document where the editor is mounted\n *\n * @internal\n */\nexport function getGlobalDocument(): Document {\n\t// eslint-disable-next-line no-restricted-globals\n\tif (typeof document !== 'undefined') return document\n\treturn globalThis.document\n}\n\n/**\n * Returns the global `window`. Use this instead of bare `window` to satisfy lint rules.\n *\n * When you have a DOM node or editor instance, prefer the scoped versions instead:\n * - `getOwnerWindow(node)` \u2013 the window that owns a specific DOM node\n * - `editor.getContainerWindow()` \u2013 the window where the editor is mounted\n *\n * @internal\n */\nexport function getGlobalWindow(): Window & typeof globalThis {\n\tif (typeof window !== 'undefined') return window as Window & typeof globalThis\n\treturn globalThis as Window & typeof globalThis\n}\n\n/** @internal */\nexport function activeElementShouldCaptureKeys(includeButtonsAndMenus = true, doc?: Document) {\n\treturn elementShouldCaptureKeys(\n\t\t(doc ?? getGlobalDocument()).activeElement,\n\t\tincludeButtonsAndMenus\n\t)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,yBAAyD;AAGlD,SAAS,kBAAkB,KAA2B;AAC5D,MAAI,IAAI,aAAa,KAAK,aAAc,QAAO;AAC/C,MAAI,IAAI,cAAe,QAAO,kBAAkB,IAAI,aAAa;AAAA,MAC5D,OAAM,MAAM,kDAAkD;AACpE;AAcO,SAAS,eAAe,OAAyC;AACvE,QAAM,eAAe;AACrB,MAAI,8BAAW,mBAAmB,IAAI,GAAG;AACxC,YAAQ,KAAK,mCAAmC,KAAK;AAAA,EACtD;AACD;AAGO,SAAS,kBACf,SACA,OACC;AACD,UAAQ,kBAAkB,MAAM,SAAS;AACzC,MAAI,8BAAW,mBAAmB,IAAI,GAAG;AACxC,UAAM,cAAc,gDAA6B,IAAI;AACrD,gBAAY,IAAI,UAAU,YAAY,IAAI,OAAO,KAAK,KAAK,CAAC;AAC5D,YAAQ,KAAK,wCAAwC,SAAS,KAAK;AAAA,EACpE;AACD;AAGO,SAAS,sBACf,SACA,OACC;AACD,MAAI,CAAC,QAAQ,kBAAkB,MAAM,SAAS,GAAG;AAChD;AAAA,EACD;AAEA,UAAQ,sBAAsB,MAAM,SAAS;AAC7C,MAAI,8BAAW,mBAAmB,IAAI,GAAG;AACxC,UAAM,cAAc,gDAA6B,IAAI;AACrD,QAAI,YAAY,IAAI,OAAO,MAAM,GAAG;AACnC,kBAAY,OAAO,OAAO;AAAA,IAC3B,WAAW,YAAY,IAAI,OAAO,GAAG;AACpC,kBAAY,IAAI,SAAS,YAAY,IAAI,OAAO,IAAK,CAAC;AAAA,IACvD,OAAO;AACN,cAAQ,KAAK,yBAAyB;AAAA,IACvC;AACA,YAAQ,KAAK,4CAA4C,SAAS,KAAK;AAAA,EACxE;AACD;AAUO,MAAM,uBAAuB,CAAC,MAAW,EAAE,gBAAgB;AAG3D,MAAM,mBAAmB,CAC/B,KACA,UACA,UACI;AACJ,MAAI,CAAC,IAAK;AACV,MAAI,MAAM,YAAY,UAAU,OAAO,KAAK,CAAC;AAC9C;AAGO,SAAS,yBAAyB,IAAoB,yBAAyB,MAAM;AAC3F,MAAI,CAAC,GAAI,QAAO;AAEhB,QAAM,UAAU,GAAG,QAAQ,YAAY;AACvC,SACE,GAAmB,qBACpB,YAAY,WACZ,YAAY,cACX,0BAA0B,YAAY,YACtC,0BAA0B,YAAY,YACvC,GAAG,UAAU,SAAS,oBAAoB;AAE5C;AAWO,SAAS,oBAA8B;AAE7C,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,SAAO,WAAW;AACnB;AAWO,SAAS,kBAA8C;AAC7D,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,SAAO;AACR;AAGO,SAAS,+BAA+B,yBAAyB,MAAM,KAAgB;AAC7F,SAAO;AAAA,KACL,OAAO,kBAAkB,GAAG;AAAA,IAC7B;AAAA,EACD;AACD;",
|
|
4
|
+
"sourcesContent": ["/*\nThis is used to facilitate double clicking and pointer capture on elements.\n\nThe events in this file are possibly set on individual SVG elements, \nsuch as handles or corner handles, rather than on HTML elements or \nSVGSVGElements. Raw SVG elements do not support pointerCapture in\nmost cases, meaning that in order for pointer capture to work, we \nneed to crawl up the DOM tree to find the nearest HTML element. Then,\nin order for that element to also call the `onPointerUp` event from\nthis file, we need to manually set that event on that element and\nlater remove it when the pointerup occurs. This is a potential leak\nif the user clicks on a handle but the pointerup does not fire for\nwhatever reason.\n*/\n\nimport { debugFlags, pointerCaptureTrackingObject } from './debug-flags'\n\n/** @public */\nexport function loopToHtmlElement(elm: Element): HTMLElement {\n\tif (elm.nodeType === Node.ELEMENT_NODE) return elm as HTMLElement\n\tif (elm.parentElement) return loopToHtmlElement(elm.parentElement)\n\telse throw Error('Could not find a parent element of an HTML type!')\n}\n\n/**\n * This function calls `event.preventDefault()` for you. Why is that useful?\n *\n * Because if you enable `window.preventDefaultLogging = true` it'll log out a message when it\n * happens. Because we use console.warn rather than (log) you'll get a stack trace in the inspector\n * telling you exactly where it happened. This is important because `e.preventDefault()` is the\n * source of many bugs, but unfortunately it can't be avoided because it also stops a lot of default\n * behaviour which doesn't make sense in our UI\n *\n * @param event - To prevent default on\n * @public\n */\nexport function preventDefault(event: React.BaseSyntheticEvent | Event) {\n\tif ('cancelable' in event && !event.cancelable) return\n\tevent.preventDefault()\n\tif (debugFlags.logPreventDefaults.get()) {\n\t\tconsole.warn('preventDefault called on event:', event)\n\t}\n}\n\n/** @public */\nexport function setPointerCapture(\n\telement: Element,\n\tevent: React.PointerEvent<Element> | PointerEvent\n) {\n\telement.setPointerCapture(event.pointerId)\n\tif (debugFlags.logPointerCaptures.get()) {\n\t\tconst trackingObj = pointerCaptureTrackingObject.get()\n\t\ttrackingObj.set(element, (trackingObj.get(element) ?? 0) + 1)\n\t\tconsole.warn('setPointerCapture called on element:', element, event)\n\t}\n}\n\n/** @public */\nexport function releasePointerCapture(\n\telement: Element,\n\tevent: React.PointerEvent<Element> | PointerEvent\n) {\n\tif (!element.hasPointerCapture(event.pointerId)) {\n\t\treturn\n\t}\n\n\telement.releasePointerCapture(event.pointerId)\n\tif (debugFlags.logPointerCaptures.get()) {\n\t\tconst trackingObj = pointerCaptureTrackingObject.get()\n\t\tif (trackingObj.get(element) === 1) {\n\t\t\ttrackingObj.delete(element)\n\t\t} else if (trackingObj.has(element)) {\n\t\t\ttrackingObj.set(element, trackingObj.get(element)! - 1)\n\t\t} else {\n\t\t\tconsole.warn('Release without capture')\n\t\t}\n\t\tconsole.warn('releasePointerCapture called on element:', element, event)\n\t}\n}\n\n/**\n * Calls `event.stopPropagation()`.\n *\n * @deprecated Use {@link Editor.markEventAsHandled} instead, or manually call `event.stopPropagation()` if\n * that's what you really want.\n *\n * @public\n */\nexport const stopEventPropagation = (e: any) => e.stopPropagation()\n\n/** @internal */\nexport const setStyleProperty = (\n\telm: HTMLElement | null,\n\tproperty: string,\n\tvalue: string | number\n) => {\n\tif (!elm) return\n\telm.style.setProperty(property, String(value))\n}\n\n/** @internal */\nexport function elementShouldCaptureKeys(el: Element | null, includeButtonsAndMenus = true) {\n\tif (!el) return false\n\n\tconst tagName = el.tagName.toLowerCase()\n\treturn (\n\t\t(el as HTMLElement).isContentEditable ||\n\t\ttagName === 'input' ||\n\t\ttagName === 'textarea' ||\n\t\t(includeButtonsAndMenus && tagName === 'select') ||\n\t\t(includeButtonsAndMenus && tagName === 'button') ||\n\t\tel.classList.contains('tlui-slider__thumb')\n\t)\n}\n\n/**\n * Returns the global `document`. Use this instead of bare `document` to satisfy lint rules.\n *\n * When you have a DOM node or editor instance, prefer the scoped versions instead:\n * - `getOwnerDocument(node)` \u2013 the document that owns a specific DOM node\n * - `editor.getContainerDocument()` \u2013 the document where the editor is mounted\n *\n * @internal\n */\nexport function getGlobalDocument(): Document {\n\t// eslint-disable-next-line no-restricted-globals\n\tif (typeof document !== 'undefined') return document\n\treturn globalThis.document\n}\n\n/**\n * Returns the global `window`. Use this instead of bare `window` to satisfy lint rules.\n *\n * When you have a DOM node or editor instance, prefer the scoped versions instead:\n * - `getOwnerWindow(node)` \u2013 the window that owns a specific DOM node\n * - `editor.getContainerWindow()` \u2013 the window where the editor is mounted\n *\n * @internal\n */\nexport function getGlobalWindow(): Window & typeof globalThis {\n\tif (typeof window !== 'undefined') return window as Window & typeof globalThis\n\treturn globalThis as Window & typeof globalThis\n}\n\n/** @internal */\nexport function activeElementShouldCaptureKeys(includeButtonsAndMenus = true, doc?: Document) {\n\treturn elementShouldCaptureKeys(\n\t\t(doc ?? getGlobalDocument()).activeElement,\n\t\tincludeButtonsAndMenus\n\t)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,yBAAyD;AAGlD,SAAS,kBAAkB,KAA2B;AAC5D,MAAI,IAAI,aAAa,KAAK,aAAc,QAAO;AAC/C,MAAI,IAAI,cAAe,QAAO,kBAAkB,IAAI,aAAa;AAAA,MAC5D,OAAM,MAAM,kDAAkD;AACpE;AAcO,SAAS,eAAe,OAAyC;AACvE,MAAI,gBAAgB,SAAS,CAAC,MAAM,WAAY;AAChD,QAAM,eAAe;AACrB,MAAI,8BAAW,mBAAmB,IAAI,GAAG;AACxC,YAAQ,KAAK,mCAAmC,KAAK;AAAA,EACtD;AACD;AAGO,SAAS,kBACf,SACA,OACC;AACD,UAAQ,kBAAkB,MAAM,SAAS;AACzC,MAAI,8BAAW,mBAAmB,IAAI,GAAG;AACxC,UAAM,cAAc,gDAA6B,IAAI;AACrD,gBAAY,IAAI,UAAU,YAAY,IAAI,OAAO,KAAK,KAAK,CAAC;AAC5D,YAAQ,KAAK,wCAAwC,SAAS,KAAK;AAAA,EACpE;AACD;AAGO,SAAS,sBACf,SACA,OACC;AACD,MAAI,CAAC,QAAQ,kBAAkB,MAAM,SAAS,GAAG;AAChD;AAAA,EACD;AAEA,UAAQ,sBAAsB,MAAM,SAAS;AAC7C,MAAI,8BAAW,mBAAmB,IAAI,GAAG;AACxC,UAAM,cAAc,gDAA6B,IAAI;AACrD,QAAI,YAAY,IAAI,OAAO,MAAM,GAAG;AACnC,kBAAY,OAAO,OAAO;AAAA,IAC3B,WAAW,YAAY,IAAI,OAAO,GAAG;AACpC,kBAAY,IAAI,SAAS,YAAY,IAAI,OAAO,IAAK,CAAC;AAAA,IACvD,OAAO;AACN,cAAQ,KAAK,yBAAyB;AAAA,IACvC;AACA,YAAQ,KAAK,4CAA4C,SAAS,KAAK;AAAA,EACxE;AACD;AAUO,MAAM,uBAAuB,CAAC,MAAW,EAAE,gBAAgB;AAG3D,MAAM,mBAAmB,CAC/B,KACA,UACA,UACI;AACJ,MAAI,CAAC,IAAK;AACV,MAAI,MAAM,YAAY,UAAU,OAAO,KAAK,CAAC;AAC9C;AAGO,SAAS,yBAAyB,IAAoB,yBAAyB,MAAM;AAC3F,MAAI,CAAC,GAAI,QAAO;AAEhB,QAAM,UAAU,GAAG,QAAQ,YAAY;AACvC,SACE,GAAmB,qBACpB,YAAY,WACZ,YAAY,cACX,0BAA0B,YAAY,YACtC,0BAA0B,YAAY,YACvC,GAAG,UAAU,SAAS,oBAAoB;AAE5C;AAWO,SAAS,oBAA8B;AAE7C,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,SAAO,WAAW;AACnB;AAWO,SAAS,kBAA8C;AAC7D,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,SAAO;AACR;AAGO,SAAS,+BAA+B,yBAAyB,MAAM,KAAgB;AAC7F,SAAO;AAAA,KACL,OAAO,kBAAkB,GAAG;AAAA,IAC7B;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-cjs/version.js
CHANGED
|
@@ -22,10 +22,10 @@ __export(version_exports, {
|
|
|
22
22
|
version: () => version
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(version_exports);
|
|
25
|
-
const version = "5.1.0
|
|
25
|
+
const version = "5.1.0";
|
|
26
26
|
const publishDates = {
|
|
27
27
|
major: "2026-05-06T16:28:18.473Z",
|
|
28
|
-
minor: "2026-
|
|
29
|
-
patch: "2026-
|
|
28
|
+
minor: "2026-06-03T10:26:13.606Z",
|
|
29
|
+
patch: "2026-06-03T10:26:13.606Z"
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=version.js.map
|
package/dist-cjs/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '5.1.0
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '5.1.0'\nexport const publishDates = {\n\tmajor: '2026-05-06T16:28:18.473Z',\n\tminor: '2026-06-03T10:26:13.606Z',\n\tpatch: '2026-06-03T10:26:13.606Z',\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|