@tldraw/editor 4.6.0-next.e0f85e824397 → 4.6.0-next.e390fde97eab
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 +297 -3
- package/dist-cjs/index.js +5 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +16 -1
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +15 -0
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js +80 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js.map +7 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +466 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js +17 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js.map +7 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.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/editor/shapes/shared/getPerfectDashProps.js +6 -0
- package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +14 -17
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/utils/runtime.js +2 -1
- package/dist-cjs/lib/utils/runtime.js.map +2 -2
- package/dist-cjs/lib/utils/sync/hardReset.js +0 -8
- package/dist-cjs/lib/utils/sync/hardReset.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 +297 -3
- package/dist-esm/index.mjs +5 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +16 -1
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +15 -0
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs +60 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +438 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs +1 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs.map +7 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.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/editor/shapes/shared/getPerfectDashProps.mjs +6 -0
- package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +14 -17
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/utils/runtime.mjs +2 -1
- package/dist-esm/lib/utils/runtime.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/hardReset.mjs +0 -8
- package/dist-esm/lib/utils/sync/hardReset.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/index.ts +15 -0
- package/src/lib/components/MenuClickCapture.tsx +20 -0
- package/src/lib/editor/Editor.ts +16 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.ts +82 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +522 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +583 -0
- package/src/lib/editor/managers/PerformanceManager/perf-types.ts +196 -0
- package/src/lib/editor/shapes/ShapeUtil.ts +2 -2
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -1
- package/src/lib/editor/shapes/shared/getPerfectDashProps.ts +7 -0
- package/src/lib/editor/tools/StateNode.ts +16 -18
- package/src/lib/utils/runtime.ts +3 -1
- package/src/lib/utils/sync/hardReset.ts +0 -8
- package/src/version.ts +3 -3
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function safeMark(name, detail) {
|
|
2
|
+
try {
|
|
3
|
+
performance.mark(name, detail ? { detail } : void 0);
|
|
4
|
+
} catch {
|
|
5
|
+
performance.mark(name);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
class PerformanceApiAdapter {
|
|
9
|
+
cleanups = [];
|
|
10
|
+
constructor(perfManager) {
|
|
11
|
+
this.cleanups.push(
|
|
12
|
+
perfManager.on("interaction-start", (event) => {
|
|
13
|
+
safeMark(`tldraw:interaction:${event.name}:start`, { path: event.path });
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
this.cleanups.push(
|
|
17
|
+
perfManager.on("interaction-end", (event) => {
|
|
18
|
+
const startMark = `tldraw:interaction:${event.name}:start`;
|
|
19
|
+
const endMark = `tldraw:interaction:${event.name}:end`;
|
|
20
|
+
safeMark(endMark, {
|
|
21
|
+
path: event.path,
|
|
22
|
+
fps: event.fps,
|
|
23
|
+
frameCount: event.frameCount,
|
|
24
|
+
shapeCount: event.shapeCount
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
performance.measure(`tldraw:interaction:${event.name}`, startMark, endMark);
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
this.cleanups.push(
|
|
33
|
+
perfManager.on("camera-start", (event) => {
|
|
34
|
+
safeMark(`tldraw:camera:${event.type}:start`);
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
this.cleanups.push(
|
|
38
|
+
perfManager.on("camera-end", (event) => {
|
|
39
|
+
const startMark = `tldraw:camera:${event.type}:start`;
|
|
40
|
+
const endMark = `tldraw:camera:${event.type}:end`;
|
|
41
|
+
safeMark(endMark, { fps: event.fps, shapeCount: event.shapeCount });
|
|
42
|
+
try {
|
|
43
|
+
performance.measure(`tldraw:camera:${event.type}`, startMark, endMark);
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
/** Remove all listeners and stop piping events. @public */
|
|
50
|
+
dispose() {
|
|
51
|
+
for (const cleanup of this.cleanups) {
|
|
52
|
+
cleanup();
|
|
53
|
+
}
|
|
54
|
+
this.cleanups.length = 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
PerformanceApiAdapter
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=PerformanceApiAdapter.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.ts"],
|
|
4
|
+
"sourcesContent": ["import type { PerformanceManager } from './PerformanceManager'\n\n/** Wrap performance.mark with try/catch \u2014 `detail` option may throw in Safari/Firefox. */\nfunction safeMark(name: string, detail?: Record<string, unknown>) {\n\ttry {\n\t\tperformance.mark(name, detail ? { detail } : undefined)\n\t} catch {\n\t\tperformance.mark(name)\n\t}\n}\n\n/**\n * Optional adapter that pipes PerformanceManager events into browser\n * `performance.mark()` / `performance.measure()` for DevTools integration.\n *\n * Tree-shakeable \u2014 only included if imported.\n *\n * @example\n * ```ts\n * const adapter = new PerformanceApiAdapter(editor.performance)\n * // ... later\n * adapter.dispose()\n * ```\n *\n * @public\n */\nexport class PerformanceApiAdapter {\n\tprivate cleanups: (() => void)[] = []\n\n\tconstructor(perfManager: PerformanceManager) {\n\t\tthis.cleanups.push(\n\t\t\tperfManager.on('interaction-start', (event) => {\n\t\t\t\tsafeMark(`tldraw:interaction:${event.name}:start`, { path: event.path })\n\t\t\t})\n\t\t)\n\n\t\tthis.cleanups.push(\n\t\t\tperfManager.on('interaction-end', (event) => {\n\t\t\t\tconst startMark = `tldraw:interaction:${event.name}:start`\n\t\t\t\tconst endMark = `tldraw:interaction:${event.name}:end`\n\t\t\t\tsafeMark(endMark, {\n\t\t\t\t\tpath: event.path,\n\t\t\t\t\tfps: event.fps,\n\t\t\t\t\tframeCount: event.frameCount,\n\t\t\t\t\tshapeCount: event.shapeCount,\n\t\t\t\t})\n\t\t\t\ttry {\n\t\t\t\t\tperformance.measure(`tldraw:interaction:${event.name}`, startMark, endMark)\n\t\t\t\t} catch {\n\t\t\t\t\t// start mark may not exist if adapter attached mid-interaction\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\n\t\tthis.cleanups.push(\n\t\t\tperfManager.on('camera-start', (event) => {\n\t\t\t\tsafeMark(`tldraw:camera:${event.type}:start`)\n\t\t\t})\n\t\t)\n\n\t\tthis.cleanups.push(\n\t\t\tperfManager.on('camera-end', (event) => {\n\t\t\t\tconst startMark = `tldraw:camera:${event.type}:start`\n\t\t\t\tconst endMark = `tldraw:camera:${event.type}:end`\n\t\t\t\tsafeMark(endMark, { fps: event.fps, shapeCount: event.shapeCount })\n\t\t\t\ttry {\n\t\t\t\t\tperformance.measure(`tldraw:camera:${event.type}`, startMark, endMark)\n\t\t\t\t} catch {\n\t\t\t\t\t// start mark may not exist\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\n\t/** Remove all listeners and stop piping events. @public */\n\tdispose() {\n\t\tfor (const cleanup of this.cleanups) {\n\t\t\tcleanup()\n\t\t}\n\t\tthis.cleanups.length = 0\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,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AAC;AAAA,IACF;AAAA,EACD;AAAA;AAAA,EAGA,UAAU;AACT,eAAW,WAAW,KAAK,UAAU;AACpC,cAAQ;AAAA,IACT;AACA,SAAK,SAAS,SAAS;AAAA,EACxB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
import { bind } from "@tldraw/utils";
|
|
12
|
+
import EventEmitter from "eventemitter3";
|
|
13
|
+
function percentile(sorted, p) {
|
|
14
|
+
const idx = Math.ceil(p * sorted.length) - 1;
|
|
15
|
+
return sorted[Math.max(0, idx)];
|
|
16
|
+
}
|
|
17
|
+
function computeFrameTimeStats(frameTimes) {
|
|
18
|
+
if (frameTimes.length === 0) return { avg: 0, median: 0, p95: 0, p99: 0, min: 0, max: 0 };
|
|
19
|
+
const sorted = [...frameTimes].sort((a, b) => a - b);
|
|
20
|
+
const sum = sorted.reduce((a, b) => a + b, 0);
|
|
21
|
+
return {
|
|
22
|
+
avg: sum / sorted.length,
|
|
23
|
+
median: percentile(sorted, 0.5),
|
|
24
|
+
p95: percentile(sorted, 0.95),
|
|
25
|
+
p99: percentile(sorted, 0.99),
|
|
26
|
+
min: sorted[0],
|
|
27
|
+
max: sorted[sorted.length - 1]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function toLoafEntry(entry) {
|
|
31
|
+
const e = entry;
|
|
32
|
+
if (typeof e.duration !== "number") return null;
|
|
33
|
+
return {
|
|
34
|
+
startTime: e.startTime,
|
|
35
|
+
duration: e.duration,
|
|
36
|
+
blockingDuration: e.blockingDuration ?? 0,
|
|
37
|
+
scripts: (e.scripts ?? []).map((s) => ({
|
|
38
|
+
sourceURL: s.sourceURL ?? "",
|
|
39
|
+
invoker: s.invoker ?? "",
|
|
40
|
+
duration: s.duration ?? 0
|
|
41
|
+
}))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
class PerformanceManager {
|
|
45
|
+
/** @internal */
|
|
46
|
+
emitter = new EventEmitter();
|
|
47
|
+
editor;
|
|
48
|
+
// Active interaction tracking
|
|
49
|
+
activeInteraction = null;
|
|
50
|
+
// Active camera tracking
|
|
51
|
+
activeCamera = null;
|
|
52
|
+
// Lazy listener cleanup functions
|
|
53
|
+
frameCleanup = null;
|
|
54
|
+
shapeCreatedCleanup = null;
|
|
55
|
+
shapeEditedCleanup = null;
|
|
56
|
+
shapeDeletedCleanup = null;
|
|
57
|
+
// LoAF observer
|
|
58
|
+
loafObserver = null;
|
|
59
|
+
constructor(editor) {
|
|
60
|
+
this.editor = editor;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Subscribe to a performance event. Returns an unsubscribe function.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const unsub = editor.performance.on('interaction-end', (event) => {
|
|
68
|
+
* sendToAnalytics({ name: event.name, fps: event.fps, p95: event.p95FrameTime })
|
|
69
|
+
* })
|
|
70
|
+
* // later: unsub()
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
on(event, fn) {
|
|
76
|
+
this.emitter.on(event, fn);
|
|
77
|
+
this._maybeAttachLazyListeners(event);
|
|
78
|
+
return () => {
|
|
79
|
+
this.emitter.off(event, fn);
|
|
80
|
+
this._maybeDetachLazyListeners(event);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Subscribe to a performance event once. The listener is removed after the first invocation.
|
|
85
|
+
* Returns an unsubscribe function for early removal.
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
once(event, fn) {
|
|
90
|
+
const wrapped = (...args) => {
|
|
91
|
+
;
|
|
92
|
+
fn(...args);
|
|
93
|
+
this._maybeDetachLazyListeners(event);
|
|
94
|
+
};
|
|
95
|
+
this.emitter.once(event, wrapped);
|
|
96
|
+
this._maybeAttachLazyListeners(event);
|
|
97
|
+
return () => {
|
|
98
|
+
this.emitter.off(event, wrapped);
|
|
99
|
+
this._maybeDetachLazyListeners(event);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** @internal */
|
|
103
|
+
dispose() {
|
|
104
|
+
if (this.activeCamera?.timeout) clearTimeout(this.activeCamera.timeout);
|
|
105
|
+
this.activeInteraction = null;
|
|
106
|
+
this.activeCamera = null;
|
|
107
|
+
this.frameCleanup?.();
|
|
108
|
+
this.frameCleanup = null;
|
|
109
|
+
this.shapeCreatedCleanup?.();
|
|
110
|
+
this.shapeCreatedCleanup = null;
|
|
111
|
+
this.shapeEditedCleanup?.();
|
|
112
|
+
this.shapeEditedCleanup = null;
|
|
113
|
+
this.shapeDeletedCleanup?.();
|
|
114
|
+
this.shapeDeletedCleanup = null;
|
|
115
|
+
this._stopLoafObserver();
|
|
116
|
+
this.emitter.removeAllListeners();
|
|
117
|
+
}
|
|
118
|
+
// --- Internal notification methods ---
|
|
119
|
+
/** @internal */
|
|
120
|
+
_notifyInteractionStart(name, path) {
|
|
121
|
+
if (this.emitter.listenerCount("interaction-start") === 0 && this.emitter.listenerCount("interaction-end") === 0) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (this.activeInteraction) {
|
|
125
|
+
console.warn(
|
|
126
|
+
`[tldraw] New interaction '${name}' started while '${this.activeInteraction.name}' was still active`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const selectedShapeTypes = {};
|
|
130
|
+
for (const shape of this.editor.getSelectedShapes()) {
|
|
131
|
+
selectedShapeTypes[shape.type] = (selectedShapeTypes[shape.type] || 0) + 1;
|
|
132
|
+
}
|
|
133
|
+
this.activeInteraction = {
|
|
134
|
+
name,
|
|
135
|
+
path,
|
|
136
|
+
startTime: performance.now(),
|
|
137
|
+
frameTimes: [],
|
|
138
|
+
selectedShapeTypes,
|
|
139
|
+
loafEntries: []
|
|
140
|
+
};
|
|
141
|
+
const event = {
|
|
142
|
+
name,
|
|
143
|
+
path,
|
|
144
|
+
timestamp: performance.now()
|
|
145
|
+
};
|
|
146
|
+
this.emitter.emit("interaction-start", event);
|
|
147
|
+
}
|
|
148
|
+
/** @internal */
|
|
149
|
+
_notifyInteractionEnd() {
|
|
150
|
+
const interaction = this.activeInteraction;
|
|
151
|
+
if (!interaction) return;
|
|
152
|
+
this.activeInteraction = null;
|
|
153
|
+
if (this.emitter.listenerCount("interaction-end") === 0) return;
|
|
154
|
+
const duration = performance.now() - interaction.startTime;
|
|
155
|
+
const stats = computeFrameTimeStats(interaction.frameTimes);
|
|
156
|
+
const event = {
|
|
157
|
+
name: interaction.name,
|
|
158
|
+
path: interaction.path,
|
|
159
|
+
duration,
|
|
160
|
+
fps: interaction.frameTimes.length > 0 ? interaction.frameTimes.length / duration * 1e3 : 0,
|
|
161
|
+
frameCount: interaction.frameTimes.length,
|
|
162
|
+
avgFrameTime: stats.avg,
|
|
163
|
+
medianFrameTime: stats.median,
|
|
164
|
+
p95FrameTime: stats.p95,
|
|
165
|
+
p99FrameTime: stats.p99,
|
|
166
|
+
minFrameTime: stats.min,
|
|
167
|
+
maxFrameTime: stats.max,
|
|
168
|
+
frameTimes: interaction.frameTimes,
|
|
169
|
+
shapeCount: this.editor.getCurrentPageShapeIds().size,
|
|
170
|
+
selectedShapeTypes: interaction.selectedShapeTypes,
|
|
171
|
+
longAnimationFrames: interaction.loafEntries.length > 0 ? interaction.loafEntries : void 0,
|
|
172
|
+
zoomLevel: this.editor.getCamera().z,
|
|
173
|
+
timestamp: performance.now()
|
|
174
|
+
};
|
|
175
|
+
this.emitter.emit("interaction-end", event);
|
|
176
|
+
}
|
|
177
|
+
/** @internal */
|
|
178
|
+
_notifyCameraOperation(type) {
|
|
179
|
+
if (this.emitter.listenerCount("camera-start") === 0 && this.emitter.listenerCount("camera-end") === 0) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (this.activeCamera) {
|
|
183
|
+
if (this.activeCamera.timeout) {
|
|
184
|
+
clearTimeout(this.activeCamera.timeout);
|
|
185
|
+
}
|
|
186
|
+
if (this.activeCamera.type !== type) {
|
|
187
|
+
this._endCameraSession();
|
|
188
|
+
this._startCameraSession(type);
|
|
189
|
+
} else {
|
|
190
|
+
this.activeCamera.timeout = this.editor.timers.setTimeout(
|
|
191
|
+
() => this._endCameraSession(),
|
|
192
|
+
50
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
this._startCameraSession(type);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** @internal */
|
|
200
|
+
_notifyUndoRedo(type, undoDepth, redoDepth) {
|
|
201
|
+
if (this.emitter.listenerCount(type) === 0) return;
|
|
202
|
+
const event = {
|
|
203
|
+
type,
|
|
204
|
+
undoDepth,
|
|
205
|
+
redoDepth
|
|
206
|
+
};
|
|
207
|
+
this.emitter.emit(type, event);
|
|
208
|
+
}
|
|
209
|
+
// --- Private helpers ---
|
|
210
|
+
_startCameraSession(type) {
|
|
211
|
+
this.activeCamera = {
|
|
212
|
+
type,
|
|
213
|
+
startTime: performance.now(),
|
|
214
|
+
frameTimes: [],
|
|
215
|
+
timeout: this.editor.timers.setTimeout(() => this._endCameraSession(), 50),
|
|
216
|
+
loafEntries: []
|
|
217
|
+
};
|
|
218
|
+
if (this.emitter.listenerCount("camera-start") > 0) {
|
|
219
|
+
const event = {
|
|
220
|
+
type,
|
|
221
|
+
timestamp: performance.now()
|
|
222
|
+
};
|
|
223
|
+
this.emitter.emit("camera-start", event);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
_endCameraSession() {
|
|
227
|
+
const camera = this.activeCamera;
|
|
228
|
+
if (!camera) return;
|
|
229
|
+
this.activeCamera = null;
|
|
230
|
+
if (camera.timeout) clearTimeout(camera.timeout);
|
|
231
|
+
if (this.emitter.listenerCount("camera-end") === 0) return;
|
|
232
|
+
const duration = performance.now() - camera.startTime;
|
|
233
|
+
const stats = computeFrameTimeStats(camera.frameTimes);
|
|
234
|
+
const viewportBounds = this.editor.getViewportScreenBounds();
|
|
235
|
+
const totalShapes = this.editor.getCurrentPageShapeIds().size;
|
|
236
|
+
const culledShapeCount = this.editor.getCulledShapes().size;
|
|
237
|
+
const event = {
|
|
238
|
+
type: camera.type,
|
|
239
|
+
duration,
|
|
240
|
+
fps: camera.frameTimes.length > 0 ? camera.frameTimes.length / duration * 1e3 : 0,
|
|
241
|
+
frameCount: camera.frameTimes.length,
|
|
242
|
+
avgFrameTime: stats.avg,
|
|
243
|
+
medianFrameTime: stats.median,
|
|
244
|
+
p95FrameTime: stats.p95,
|
|
245
|
+
p99FrameTime: stats.p99,
|
|
246
|
+
minFrameTime: stats.min,
|
|
247
|
+
maxFrameTime: stats.max,
|
|
248
|
+
frameTimes: camera.frameTimes,
|
|
249
|
+
shapeCount: totalShapes,
|
|
250
|
+
viewportWidth: viewportBounds.w,
|
|
251
|
+
viewportHeight: viewportBounds.h,
|
|
252
|
+
longAnimationFrames: camera.loafEntries.length > 0 ? camera.loafEntries : void 0,
|
|
253
|
+
visibleShapeCount: totalShapes - culledShapeCount,
|
|
254
|
+
culledShapeCount,
|
|
255
|
+
zoomLevel: this.editor.getCamera().z,
|
|
256
|
+
timestamp: performance.now()
|
|
257
|
+
};
|
|
258
|
+
this.emitter.emit("camera-end", event);
|
|
259
|
+
}
|
|
260
|
+
_onFrame(elapsed) {
|
|
261
|
+
if (this.activeInteraction) {
|
|
262
|
+
this.activeInteraction.frameTimes.push(elapsed);
|
|
263
|
+
}
|
|
264
|
+
if (this.activeCamera) {
|
|
265
|
+
this.activeCamera.frameTimes.push(elapsed);
|
|
266
|
+
}
|
|
267
|
+
if (this.emitter.listenerCount("frame") > 0) {
|
|
268
|
+
const totalShapes = this.editor.getCurrentPageShapeIds().size;
|
|
269
|
+
const culledShapes = this.editor.getCulledShapes();
|
|
270
|
+
const culledCount = culledShapes.size;
|
|
271
|
+
const event = {
|
|
272
|
+
elapsed,
|
|
273
|
+
shapeCount: totalShapes,
|
|
274
|
+
culledShapeCount: culledCount,
|
|
275
|
+
visibleShapeCount: totalShapes - culledCount
|
|
276
|
+
};
|
|
277
|
+
this.emitter.emit("frame", event);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
_onShapesCreated(records) {
|
|
281
|
+
if (this.emitter.listenerCount("shapes-created") === 0) return;
|
|
282
|
+
const shapeTypes = {};
|
|
283
|
+
for (const record of records) {
|
|
284
|
+
if (record.typeName === "shape") {
|
|
285
|
+
shapeTypes[record.type] = (shapeTypes[record.type] || 0) + 1;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const count = Object.values(shapeTypes).reduce((a, b) => a + b, 0);
|
|
289
|
+
if (count === 0) return;
|
|
290
|
+
const event = {
|
|
291
|
+
operation: "create",
|
|
292
|
+
count,
|
|
293
|
+
shapeTypes,
|
|
294
|
+
timestamp: performance.now()
|
|
295
|
+
};
|
|
296
|
+
this.emitter.emit("shapes-created", event);
|
|
297
|
+
}
|
|
298
|
+
_onShapesEdited(records) {
|
|
299
|
+
if (this.emitter.listenerCount("shapes-updated") === 0) return;
|
|
300
|
+
const shapeTypes = {};
|
|
301
|
+
for (const record of records) {
|
|
302
|
+
if (record.typeName === "shape") {
|
|
303
|
+
shapeTypes[record.type] = (shapeTypes[record.type] || 0) + 1;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const count = Object.values(shapeTypes).reduce((a, b) => a + b, 0);
|
|
307
|
+
if (count === 0) return;
|
|
308
|
+
const event = {
|
|
309
|
+
operation: "update",
|
|
310
|
+
count,
|
|
311
|
+
shapeTypes,
|
|
312
|
+
timestamp: performance.now()
|
|
313
|
+
};
|
|
314
|
+
this.emitter.emit("shapes-updated", event);
|
|
315
|
+
}
|
|
316
|
+
_onShapesDeleted(ids) {
|
|
317
|
+
if (this.emitter.listenerCount("shapes-deleted") === 0) return;
|
|
318
|
+
const shapeTypes = {};
|
|
319
|
+
for (const id of ids) {
|
|
320
|
+
const shape = this.editor.getShape(id);
|
|
321
|
+
if (shape) {
|
|
322
|
+
shapeTypes[shape.type] = (shapeTypes[shape.type] || 0) + 1;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const event = {
|
|
326
|
+
operation: "delete",
|
|
327
|
+
count: ids.length,
|
|
328
|
+
shapeTypes,
|
|
329
|
+
timestamp: performance.now()
|
|
330
|
+
};
|
|
331
|
+
this.emitter.emit("shapes-deleted", event);
|
|
332
|
+
}
|
|
333
|
+
// --- LoAF observer ---
|
|
334
|
+
_startLoafObserver() {
|
|
335
|
+
if (typeof PerformanceObserver === "undefined") return;
|
|
336
|
+
try {
|
|
337
|
+
const supported = PerformanceObserver.supportedEntryTypes;
|
|
338
|
+
if (!supported?.includes("long-animation-frame")) return;
|
|
339
|
+
} catch {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
this.loafObserver = new PerformanceObserver((list) => {
|
|
343
|
+
const isInteractionActive = this.activeInteraction !== null;
|
|
344
|
+
const isCameraActive = this.activeCamera !== null;
|
|
345
|
+
if (!isInteractionActive && !isCameraActive) return;
|
|
346
|
+
for (const entry of list.getEntries()) {
|
|
347
|
+
const loaf = toLoafEntry(entry);
|
|
348
|
+
if (!loaf) continue;
|
|
349
|
+
if (isInteractionActive) {
|
|
350
|
+
this.activeInteraction.loafEntries.push(loaf);
|
|
351
|
+
}
|
|
352
|
+
if (isCameraActive) {
|
|
353
|
+
this.activeCamera.loafEntries.push(loaf);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
this.loafObserver.observe({ type: "long-animation-frame", buffered: false });
|
|
358
|
+
}
|
|
359
|
+
_stopLoafObserver() {
|
|
360
|
+
if (this.loafObserver) {
|
|
361
|
+
this.loafObserver.disconnect();
|
|
362
|
+
this.loafObserver = null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// --- Lazy listener management ---
|
|
366
|
+
_needsFrameListener() {
|
|
367
|
+
return this.emitter.listenerCount("frame") > 0 || this.emitter.listenerCount("interaction-start") > 0 || this.emitter.listenerCount("interaction-end") > 0 || this.emitter.listenerCount("camera-start") > 0 || this.emitter.listenerCount("camera-end") > 0;
|
|
368
|
+
}
|
|
369
|
+
_needsLoafObserver() {
|
|
370
|
+
return this.emitter.listenerCount("interaction-end") > 0 || this.emitter.listenerCount("camera-end") > 0;
|
|
371
|
+
}
|
|
372
|
+
_maybeAttachLazyListeners(event) {
|
|
373
|
+
if (!this.frameCleanup && (event === "frame" || event === "interaction-start" || event === "interaction-end" || event === "camera-start" || event === "camera-end")) {
|
|
374
|
+
if (this._needsFrameListener()) {
|
|
375
|
+
this.editor.on("frame", this._onFrame);
|
|
376
|
+
this.frameCleanup = () => this.editor.off("frame", this._onFrame);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (!this.loafObserver && (event === "interaction-end" || event === "camera-end")) {
|
|
380
|
+
if (this._needsLoafObserver()) {
|
|
381
|
+
this._startLoafObserver();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (!this.shapeCreatedCleanup && event === "shapes-created") {
|
|
385
|
+
this.editor.on("created-shapes", this._onShapesCreated);
|
|
386
|
+
this.shapeCreatedCleanup = () => this.editor.off("created-shapes", this._onShapesCreated);
|
|
387
|
+
}
|
|
388
|
+
if (!this.shapeEditedCleanup && event === "shapes-updated") {
|
|
389
|
+
this.editor.on("edited-shapes", this._onShapesEdited);
|
|
390
|
+
this.shapeEditedCleanup = () => this.editor.off("edited-shapes", this._onShapesEdited);
|
|
391
|
+
}
|
|
392
|
+
if (!this.shapeDeletedCleanup && event === "shapes-deleted") {
|
|
393
|
+
this.editor.on("deleted-shapes", this._onShapesDeleted);
|
|
394
|
+
this.shapeDeletedCleanup = () => this.editor.off("deleted-shapes", this._onShapesDeleted);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
_maybeDetachLazyListeners(event) {
|
|
398
|
+
if (this.frameCleanup && (event === "frame" || event === "interaction-start" || event === "interaction-end" || event === "camera-start" || event === "camera-end")) {
|
|
399
|
+
if (!this._needsFrameListener()) {
|
|
400
|
+
this.frameCleanup();
|
|
401
|
+
this.frameCleanup = null;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (this.loafObserver && (event === "interaction-end" || event === "camera-end")) {
|
|
405
|
+
if (!this._needsLoafObserver()) {
|
|
406
|
+
this._stopLoafObserver();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (this.shapeCreatedCleanup && event === "shapes-created" && this.emitter.listenerCount("shapes-created") === 0) {
|
|
410
|
+
this.shapeCreatedCleanup();
|
|
411
|
+
this.shapeCreatedCleanup = null;
|
|
412
|
+
}
|
|
413
|
+
if (this.shapeEditedCleanup && event === "shapes-updated" && this.emitter.listenerCount("shapes-updated") === 0) {
|
|
414
|
+
this.shapeEditedCleanup();
|
|
415
|
+
this.shapeEditedCleanup = null;
|
|
416
|
+
}
|
|
417
|
+
if (this.shapeDeletedCleanup && event === "shapes-deleted" && this.emitter.listenerCount("shapes-deleted") === 0) {
|
|
418
|
+
this.shapeDeletedCleanup();
|
|
419
|
+
this.shapeDeletedCleanup = null;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
__decorateClass([
|
|
424
|
+
bind
|
|
425
|
+
], PerformanceManager.prototype, "_onFrame", 1);
|
|
426
|
+
__decorateClass([
|
|
427
|
+
bind
|
|
428
|
+
], PerformanceManager.prototype, "_onShapesCreated", 1);
|
|
429
|
+
__decorateClass([
|
|
430
|
+
bind
|
|
431
|
+
], PerformanceManager.prototype, "_onShapesEdited", 1);
|
|
432
|
+
__decorateClass([
|
|
433
|
+
bind
|
|
434
|
+
], PerformanceManager.prototype, "_onShapesDeleted", 1);
|
|
435
|
+
export {
|
|
436
|
+
PerformanceManager
|
|
437
|
+
};
|
|
438
|
+
//# sourceMappingURL=PerformanceManager.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/lib/editor/managers/PerformanceManager/PerformanceManager.ts"],
|
|
4
|
+
"sourcesContent": ["import type { TLRecord, TLShapeId } from '@tldraw/tlschema'\nimport { bind } from '@tldraw/utils'\nimport EventEmitter from 'eventemitter3'\nimport type { Editor } from '../../Editor'\nimport type {\n\tTLCameraEndPerfEvent,\n\tTLCameraStartPerfEvent,\n\tTLFramePerfEvent,\n\tTLInteractionEndPerfEvent,\n\tTLInteractionStartPerfEvent,\n\tTLPerfEventMap,\n\tTLPerfLongAnimationFrame,\n\tTLShapeOperationPerfEvent,\n\tTLUndoRedoPerfEvent,\n} from './perf-types'\n\nfunction percentile(sorted: number[], p: number): number {\n\tconst idx = Math.ceil(p * sorted.length) - 1\n\treturn sorted[Math.max(0, idx)]\n}\n\nfunction computeFrameTimeStats(frameTimes: number[]) {\n\tif (frameTimes.length === 0) return { avg: 0, median: 0, p95: 0, p99: 0, min: 0, max: 0 }\n\tconst sorted = [...frameTimes].sort((a, b) => a - b)\n\tconst sum = sorted.reduce((a, b) => a + b, 0)\n\treturn {\n\t\tavg: sum / sorted.length,\n\t\tmedian: percentile(sorted, 0.5),\n\t\tp95: percentile(sorted, 0.95),\n\t\tp99: percentile(sorted, 0.99),\n\t\tmin: sorted[0],\n\t\tmax: sorted[sorted.length - 1],\n\t}\n}\n\nfunction toLoafEntry(entry: PerformanceEntry): TLPerfLongAnimationFrame | null {\n\t// LoAF entries have these properties but TypeScript doesn't know about them yet\n\tconst e = entry as PerformanceEntry & {\n\t\tblockingDuration?: number\n\t\tscripts?: ReadonlyArray<{\n\t\t\tsourceURL?: string\n\t\t\tinvoker?: string\n\t\t\tduration?: number\n\t\t}>\n\t}\n\tif (typeof e.duration !== 'number') return null\n\treturn {\n\t\tstartTime: e.startTime,\n\t\tduration: e.duration,\n\t\tblockingDuration: e.blockingDuration ?? 0,\n\t\tscripts: (e.scripts ?? []).map((s) => ({\n\t\t\tsourceURL: s.sourceURL ?? '',\n\t\t\tinvoker: s.invoker ?? '',\n\t\t\tduration: s.duration ?? 0,\n\t\t})),\n\t}\n}\n\n/**\n * Manages performance event subscriptions for the editor. Available as `editor.performance`.\n *\n * Listeners are lazy \u2014 internal editor hooks (frame, shape events) are only attached while\n * at least one subscriber exists, so there is zero overhead when unused.\n *\n * @example\n * ```ts\n * const unsub = editor.performance.on('interaction-end', (event) => {\n * console.log(`${event.name}: ${event.fps.toFixed(1)} fps, p95=${event.p95FrameTime.toFixed(1)}ms`)\n * })\n * ```\n *\n * @public\n */\nexport class PerformanceManager {\n\t/** @internal */\n\treadonly emitter = new EventEmitter<TLPerfEventMap>()\n\n\tprivate editor: Editor\n\n\t// Active interaction tracking\n\tprivate activeInteraction: {\n\t\tname: string\n\t\tpath: string\n\t\tstartTime: number\n\t\tframeTimes: number[]\n\t\tselectedShapeTypes: Record<string, number>\n\t\tloafEntries: TLPerfLongAnimationFrame[]\n\t} | null = null\n\n\t// Active camera tracking\n\tprivate activeCamera: {\n\t\ttype: 'panning' | 'zooming'\n\t\tstartTime: number\n\t\tframeTimes: number[]\n\t\ttimeout: number | null\n\t\tloafEntries: TLPerfLongAnimationFrame[]\n\t} | null = null\n\n\t// Lazy listener cleanup functions\n\tprivate frameCleanup: (() => void) | null = null\n\tprivate shapeCreatedCleanup: (() => void) | null = null\n\tprivate shapeEditedCleanup: (() => void) | null = null\n\tprivate shapeDeletedCleanup: (() => void) | null = null\n\n\t// LoAF observer\n\tprivate loafObserver: PerformanceObserver | null = null\n\n\tconstructor(editor: Editor) {\n\t\tthis.editor = editor\n\t}\n\n\t/**\n\t * Subscribe to a performance event. Returns an unsubscribe function.\n\t *\n\t * @example\n\t * ```ts\n\t * const unsub = editor.performance.on('interaction-end', (event) => {\n\t * sendToAnalytics({ name: event.name, fps: event.fps, p95: event.p95FrameTime })\n\t * })\n\t * // later: unsub()\n\t * ```\n\t *\n\t * @public\n\t */\n\ton<K extends keyof TLPerfEventMap>(\n\t\tevent: K,\n\t\tfn: (...args: TLPerfEventMap[K]) => void\n\t): () => void {\n\t\tthis.emitter.on(event, fn as any)\n\t\tthis._maybeAttachLazyListeners(event)\n\t\treturn () => {\n\t\t\tthis.emitter.off(event, fn as any)\n\t\t\tthis._maybeDetachLazyListeners(event)\n\t\t}\n\t}\n\n\t/**\n\t * Subscribe to a performance event once. The listener is removed after the first invocation.\n\t * Returns an unsubscribe function for early removal.\n\t *\n\t * @public\n\t */\n\tonce<K extends keyof TLPerfEventMap>(\n\t\tevent: K,\n\t\tfn: (...args: TLPerfEventMap[K]) => void\n\t): () => void {\n\t\tconst wrapped = (...args: TLPerfEventMap[K]) => {\n\t\t\t;(fn as any)(...args)\n\t\t\tthis._maybeDetachLazyListeners(event)\n\t\t}\n\t\tthis.emitter.once(event, wrapped as any)\n\t\tthis._maybeAttachLazyListeners(event)\n\t\treturn () => {\n\t\t\tthis.emitter.off(event, wrapped as any)\n\t\t\tthis._maybeDetachLazyListeners(event)\n\t\t}\n\t}\n\n\t/** @internal */\n\tdispose() {\n\t\tif (this.activeCamera?.timeout) clearTimeout(this.activeCamera.timeout)\n\t\tthis.activeInteraction = null\n\t\tthis.activeCamera = null\n\t\tthis.frameCleanup?.()\n\t\tthis.frameCleanup = null\n\t\tthis.shapeCreatedCleanup?.()\n\t\tthis.shapeCreatedCleanup = null\n\t\tthis.shapeEditedCleanup?.()\n\t\tthis.shapeEditedCleanup = null\n\t\tthis.shapeDeletedCleanup?.()\n\t\tthis.shapeDeletedCleanup = null\n\t\tthis._stopLoafObserver()\n\t\tthis.emitter.removeAllListeners()\n\t}\n\n\t// --- Internal notification methods ---\n\n\t/** @internal */\n\t_notifyInteractionStart(name: string, path: string) {\n\t\tif (\n\t\t\tthis.emitter.listenerCount('interaction-start') === 0 &&\n\t\t\tthis.emitter.listenerCount('interaction-end') === 0\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.activeInteraction) {\n\t\t\tconsole.warn(\n\t\t\t\t`[tldraw] New interaction '${name}' started while '${this.activeInteraction.name}' was still active`\n\t\t\t)\n\t\t}\n\n\t\t// Capture selected shape types at start\n\t\tconst selectedShapeTypes: Record<string, number> = {}\n\t\tfor (const shape of this.editor.getSelectedShapes()) {\n\t\t\tselectedShapeTypes[shape.type] = (selectedShapeTypes[shape.type] || 0) + 1\n\t\t}\n\n\t\tthis.activeInteraction = {\n\t\t\tname,\n\t\t\tpath,\n\t\t\tstartTime: performance.now(),\n\t\t\tframeTimes: [],\n\t\t\tselectedShapeTypes,\n\t\t\tloafEntries: [],\n\t\t}\n\n\t\tconst event: TLInteractionStartPerfEvent = {\n\t\t\tname,\n\t\t\tpath,\n\t\t\ttimestamp: performance.now(),\n\t\t}\n\t\tthis.emitter.emit('interaction-start', event)\n\t}\n\n\t/** @internal */\n\t_notifyInteractionEnd() {\n\t\tconst interaction = this.activeInteraction\n\t\tif (!interaction) return\n\t\tthis.activeInteraction = null\n\n\t\tif (this.emitter.listenerCount('interaction-end') === 0) return\n\n\t\tconst duration = performance.now() - interaction.startTime\n\t\tconst stats = computeFrameTimeStats(interaction.frameTimes)\n\n\t\tconst event: TLInteractionEndPerfEvent = {\n\t\t\tname: interaction.name,\n\t\t\tpath: interaction.path,\n\t\t\tduration,\n\t\t\tfps:\n\t\t\t\tinteraction.frameTimes.length > 0 ? (interaction.frameTimes.length / duration) * 1000 : 0,\n\t\t\tframeCount: interaction.frameTimes.length,\n\t\t\tavgFrameTime: stats.avg,\n\t\t\tmedianFrameTime: stats.median,\n\t\t\tp95FrameTime: stats.p95,\n\t\t\tp99FrameTime: stats.p99,\n\t\t\tminFrameTime: stats.min,\n\t\t\tmaxFrameTime: stats.max,\n\t\t\tframeTimes: interaction.frameTimes,\n\t\t\tshapeCount: this.editor.getCurrentPageShapeIds().size,\n\t\t\tselectedShapeTypes: interaction.selectedShapeTypes,\n\t\t\tlongAnimationFrames: interaction.loafEntries.length > 0 ? interaction.loafEntries : undefined,\n\t\t\tzoomLevel: this.editor.getCamera().z,\n\t\t\ttimestamp: performance.now(),\n\t\t}\n\t\tthis.emitter.emit('interaction-end', event)\n\t}\n\n\t/** @internal */\n\t_notifyCameraOperation(type: 'panning' | 'zooming') {\n\t\tif (\n\t\t\tthis.emitter.listenerCount('camera-start') === 0 &&\n\t\t\tthis.emitter.listenerCount('camera-end') === 0\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.activeCamera) {\n\t\t\t// Extend existing camera session\n\t\t\tif (this.activeCamera.timeout) {\n\t\t\t\tclearTimeout(this.activeCamera.timeout)\n\t\t\t}\n\t\t\t// If type changed, end old and start new\n\t\t\tif (this.activeCamera.type !== type) {\n\t\t\t\tthis._endCameraSession()\n\t\t\t\tthis._startCameraSession(type)\n\t\t\t} else {\n\t\t\t\t// Reset timeout\n\t\t\t\tthis.activeCamera.timeout = this.editor.timers.setTimeout(\n\t\t\t\t\t() => this._endCameraSession(),\n\t\t\t\t\t50\n\t\t\t\t)\n\t\t\t}\n\t\t} else {\n\t\t\tthis._startCameraSession(type)\n\t\t}\n\t}\n\n\t/** @internal */\n\t_notifyUndoRedo(type: 'undo' | 'redo', undoDepth: number, redoDepth: number) {\n\t\tif (this.emitter.listenerCount(type) === 0) return\n\n\t\tconst event: TLUndoRedoPerfEvent = {\n\t\t\ttype,\n\t\t\tundoDepth,\n\t\t\tredoDepth,\n\t\t}\n\t\tthis.emitter.emit(type, event)\n\t}\n\n\t// --- Private helpers ---\n\n\tprivate _startCameraSession(type: 'panning' | 'zooming') {\n\t\tthis.activeCamera = {\n\t\t\ttype,\n\t\t\tstartTime: performance.now(),\n\t\t\tframeTimes: [],\n\t\t\ttimeout: this.editor.timers.setTimeout(() => this._endCameraSession(), 50),\n\t\t\tloafEntries: [],\n\t\t}\n\n\t\tif (this.emitter.listenerCount('camera-start') > 0) {\n\t\t\tconst event: TLCameraStartPerfEvent = {\n\t\t\t\ttype,\n\t\t\t\ttimestamp: performance.now(),\n\t\t\t}\n\t\t\tthis.emitter.emit('camera-start', event)\n\t\t}\n\t}\n\n\tprivate _endCameraSession() {\n\t\tconst camera = this.activeCamera\n\t\tif (!camera) return\n\t\tthis.activeCamera = null\n\t\tif (camera.timeout) clearTimeout(camera.timeout)\n\n\t\tif (this.emitter.listenerCount('camera-end') === 0) return\n\n\t\tconst duration = performance.now() - camera.startTime\n\t\tconst stats = computeFrameTimeStats(camera.frameTimes)\n\t\tconst viewportBounds = this.editor.getViewportScreenBounds()\n\t\tconst totalShapes = this.editor.getCurrentPageShapeIds().size\n\t\tconst culledShapeCount = this.editor.getCulledShapes().size\n\n\t\tconst event: TLCameraEndPerfEvent = {\n\t\t\ttype: camera.type,\n\t\t\tduration,\n\t\t\tfps: camera.frameTimes.length > 0 ? (camera.frameTimes.length / duration) * 1000 : 0,\n\t\t\tframeCount: camera.frameTimes.length,\n\t\t\tavgFrameTime: stats.avg,\n\t\t\tmedianFrameTime: stats.median,\n\t\t\tp95FrameTime: stats.p95,\n\t\t\tp99FrameTime: stats.p99,\n\t\t\tminFrameTime: stats.min,\n\t\t\tmaxFrameTime: stats.max,\n\t\t\tframeTimes: camera.frameTimes,\n\t\t\tshapeCount: totalShapes,\n\t\t\tviewportWidth: viewportBounds.w,\n\t\t\tviewportHeight: viewportBounds.h,\n\t\t\tlongAnimationFrames: camera.loafEntries.length > 0 ? camera.loafEntries : undefined,\n\t\t\tvisibleShapeCount: totalShapes - culledShapeCount,\n\t\t\tculledShapeCount,\n\t\t\tzoomLevel: this.editor.getCamera().z,\n\t\t\ttimestamp: performance.now(),\n\t\t}\n\t\tthis.emitter.emit('camera-end', event)\n\t}\n\n\t@bind\n\tprivate _onFrame(elapsed: number) {\n\t\t// Record frame time for active interaction/camera\n\t\tif (this.activeInteraction) {\n\t\t\tthis.activeInteraction.frameTimes.push(elapsed)\n\t\t}\n\t\tif (this.activeCamera) {\n\t\t\tthis.activeCamera.frameTimes.push(elapsed)\n\t\t}\n\n\t\t// Emit standalone frame event if listeners exist\n\t\tif (this.emitter.listenerCount('frame') > 0) {\n\t\t\tconst totalShapes = this.editor.getCurrentPageShapeIds().size\n\t\t\tconst culledShapes = this.editor.getCulledShapes()\n\t\t\tconst culledCount = culledShapes.size\n\t\t\tconst event: TLFramePerfEvent = {\n\t\t\t\telapsed,\n\t\t\t\tshapeCount: totalShapes,\n\t\t\t\tculledShapeCount: culledCount,\n\t\t\t\tvisibleShapeCount: totalShapes - culledCount,\n\t\t\t}\n\t\t\tthis.emitter.emit('frame', event)\n\t\t}\n\t}\n\n\t@bind\n\tprivate _onShapesCreated(records: TLRecord[]) {\n\t\tif (this.emitter.listenerCount('shapes-created') === 0) return\n\t\tconst shapeTypes: Record<string, number> = {}\n\t\tfor (const record of records) {\n\t\t\tif (record.typeName === 'shape') {\n\t\t\t\tshapeTypes[record.type] = (shapeTypes[record.type] || 0) + 1\n\t\t\t}\n\t\t}\n\t\tconst count = Object.values(shapeTypes).reduce((a, b) => a + b, 0)\n\t\tif (count === 0) return\n\t\tconst event: TLShapeOperationPerfEvent = {\n\t\t\toperation: 'create',\n\t\t\tcount,\n\t\t\tshapeTypes,\n\t\t\ttimestamp: performance.now(),\n\t\t}\n\t\tthis.emitter.emit('shapes-created', event)\n\t}\n\n\t@bind\n\tprivate _onShapesEdited(records: TLRecord[]) {\n\t\tif (this.emitter.listenerCount('shapes-updated') === 0) return\n\t\tconst shapeTypes: Record<string, number> = {}\n\t\tfor (const record of records) {\n\t\t\tif (record.typeName === 'shape') {\n\t\t\t\tshapeTypes[record.type] = (shapeTypes[record.type] || 0) + 1\n\t\t\t}\n\t\t}\n\t\tconst count = Object.values(shapeTypes).reduce((a, b) => a + b, 0)\n\t\tif (count === 0) return\n\t\tconst event: TLShapeOperationPerfEvent = {\n\t\t\toperation: 'update',\n\t\t\tcount,\n\t\t\tshapeTypes,\n\t\t\ttimestamp: performance.now(),\n\t\t}\n\t\tthis.emitter.emit('shapes-updated', event)\n\t}\n\n\t@bind\n\tprivate _onShapesDeleted(ids: TLShapeId[]) {\n\t\tif (this.emitter.listenerCount('shapes-deleted') === 0) return\n\t\tconst shapeTypes: Record<string, number> = {}\n\t\tfor (const id of ids) {\n\t\t\t// Works because 'deleted-shapes' fires before store.remove() in Editor.deleteShapes\n\t\t\tconst shape = this.editor.getShape(id)\n\t\t\tif (shape) {\n\t\t\t\tshapeTypes[shape.type] = (shapeTypes[shape.type] || 0) + 1\n\t\t\t}\n\t\t}\n\t\tconst event: TLShapeOperationPerfEvent = {\n\t\t\toperation: 'delete',\n\t\t\tcount: ids.length,\n\t\t\tshapeTypes,\n\t\t\ttimestamp: performance.now(),\n\t\t}\n\t\tthis.emitter.emit('shapes-deleted', event)\n\t}\n\n\t// --- LoAF observer ---\n\n\tprivate _startLoafObserver() {\n\t\tif (typeof PerformanceObserver === 'undefined') return\n\n\t\ttry {\n\t\t\tconst supported = PerformanceObserver.supportedEntryTypes\n\t\t\tif (!supported?.includes('long-animation-frame')) return\n\t\t} catch {\n\t\t\treturn\n\t\t}\n\n\t\tthis.loafObserver = new PerformanceObserver((list) => {\n\t\t\tconst isInteractionActive = this.activeInteraction !== null\n\t\t\tconst isCameraActive = this.activeCamera !== null\n\n\t\t\tif (!isInteractionActive && !isCameraActive) return\n\n\t\t\tfor (const entry of list.getEntries()) {\n\t\t\t\tconst loaf = toLoafEntry(entry)\n\t\t\t\tif (!loaf) continue\n\n\t\t\t\tif (isInteractionActive) {\n\t\t\t\t\tthis.activeInteraction!.loafEntries.push(loaf)\n\t\t\t\t}\n\t\t\t\tif (isCameraActive) {\n\t\t\t\t\tthis.activeCamera!.loafEntries.push(loaf)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\tthis.loafObserver.observe({ type: 'long-animation-frame', buffered: false })\n\t}\n\n\tprivate _stopLoafObserver() {\n\t\tif (this.loafObserver) {\n\t\t\tthis.loafObserver.disconnect()\n\t\t\tthis.loafObserver = null\n\t\t}\n\t}\n\n\t// --- Lazy listener management ---\n\n\tprivate _needsFrameListener(): boolean {\n\t\treturn (\n\t\t\tthis.emitter.listenerCount('frame') > 0 ||\n\t\t\tthis.emitter.listenerCount('interaction-start') > 0 ||\n\t\t\tthis.emitter.listenerCount('interaction-end') > 0 ||\n\t\t\tthis.emitter.listenerCount('camera-start') > 0 ||\n\t\t\tthis.emitter.listenerCount('camera-end') > 0\n\t\t)\n\t}\n\n\tprivate _needsLoafObserver(): boolean {\n\t\treturn (\n\t\t\tthis.emitter.listenerCount('interaction-end') > 0 ||\n\t\t\tthis.emitter.listenerCount('camera-end') > 0\n\t\t)\n\t}\n\n\tprivate _maybeAttachLazyListeners(event: keyof TLPerfEventMap) {\n\t\t// Frame listener needed for frame event + interaction/camera frame time tracking\n\t\tif (\n\t\t\t!this.frameCleanup &&\n\t\t\t(event === 'frame' ||\n\t\t\t\tevent === 'interaction-start' ||\n\t\t\t\tevent === 'interaction-end' ||\n\t\t\t\tevent === 'camera-start' ||\n\t\t\t\tevent === 'camera-end')\n\t\t) {\n\t\t\tif (this._needsFrameListener()) {\n\t\t\t\tthis.editor.on('frame', this._onFrame)\n\t\t\t\tthis.frameCleanup = () => this.editor.off('frame', this._onFrame)\n\t\t\t}\n\t\t}\n\n\t\t// LoAF observer needed when interaction-end or camera-end listeners exist\n\t\tif (!this.loafObserver && (event === 'interaction-end' || event === 'camera-end')) {\n\t\t\tif (this._needsLoafObserver()) {\n\t\t\t\tthis._startLoafObserver()\n\t\t\t}\n\t\t}\n\n\t\tif (!this.shapeCreatedCleanup && event === 'shapes-created') {\n\t\t\tthis.editor.on('created-shapes', this._onShapesCreated)\n\t\t\tthis.shapeCreatedCleanup = () => this.editor.off('created-shapes', this._onShapesCreated)\n\t\t}\n\n\t\tif (!this.shapeEditedCleanup && event === 'shapes-updated') {\n\t\t\tthis.editor.on('edited-shapes', this._onShapesEdited)\n\t\t\tthis.shapeEditedCleanup = () => this.editor.off('edited-shapes', this._onShapesEdited)\n\t\t}\n\n\t\tif (!this.shapeDeletedCleanup && event === 'shapes-deleted') {\n\t\t\tthis.editor.on('deleted-shapes', this._onShapesDeleted)\n\t\t\tthis.shapeDeletedCleanup = () => this.editor.off('deleted-shapes', this._onShapesDeleted)\n\t\t}\n\t}\n\n\tprivate _maybeDetachLazyListeners(event: keyof TLPerfEventMap) {\n\t\tif (\n\t\t\tthis.frameCleanup &&\n\t\t\t(event === 'frame' ||\n\t\t\t\tevent === 'interaction-start' ||\n\t\t\t\tevent === 'interaction-end' ||\n\t\t\t\tevent === 'camera-start' ||\n\t\t\t\tevent === 'camera-end')\n\t\t) {\n\t\t\tif (!this._needsFrameListener()) {\n\t\t\t\tthis.frameCleanup()\n\t\t\t\tthis.frameCleanup = null\n\t\t\t}\n\t\t}\n\n\t\t// Stop LoAF observer when no longer needed\n\t\tif (this.loafObserver && (event === 'interaction-end' || event === 'camera-end')) {\n\t\t\tif (!this._needsLoafObserver()) {\n\t\t\t\tthis._stopLoafObserver()\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tthis.shapeCreatedCleanup &&\n\t\t\tevent === 'shapes-created' &&\n\t\t\tthis.emitter.listenerCount('shapes-created') === 0\n\t\t) {\n\t\t\tthis.shapeCreatedCleanup()\n\t\t\tthis.shapeCreatedCleanup = null\n\t\t}\n\n\t\tif (\n\t\t\tthis.shapeEditedCleanup &&\n\t\t\tevent === 'shapes-updated' &&\n\t\t\tthis.emitter.listenerCount('shapes-updated') === 0\n\t\t) {\n\t\t\tthis.shapeEditedCleanup()\n\t\t\tthis.shapeEditedCleanup = null\n\t\t}\n\n\t\tif (\n\t\t\tth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P;AAAA,GA7SW,mBA8SJ;AAoBA;AAAA,EADP;AAAA,GAjUW,mBAkUJ;AAoBA;AAAA,EADP;AAAA,GArVW,mBAsVJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=perf-types.mjs.map
|
|
@@ -135,7 +135,7 @@ class ShapeUtil {
|
|
|
135
135
|
*
|
|
136
136
|
* @public
|
|
137
137
|
*/
|
|
138
|
-
canBind(
|
|
138
|
+
canBind(opts) {
|
|
139
139
|
return true;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
@@ -280,7 +280,7 @@ class ShapeUtil {
|
|
|
280
280
|
* @param type - The shape type.
|
|
281
281
|
* @public
|
|
282
282
|
*/
|
|
283
|
-
canReceiveNewChildrenOfType(shape,
|
|
283
|
+
canReceiveNewChildrenOfType(shape, type) {
|
|
284
284
|
return false;
|
|
285
285
|
}
|
|
286
286
|
/** @internal */
|