@playcanvas/inspector 0.4.0 → 0.6.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/README.md +176 -3
- package/package.json +8 -6
- package/src/asset-view.js +66 -3
- package/src/camera-view.js +1 -1
- package/src/copy-json.js +48 -9
- package/src/describe.js +1 -1
- package/src/frame-graph-view.js +4 -4
- package/src/image-capture.js +387 -0
- package/src/inspector.js +700 -57
- package/src/layer-view.js +235 -0
- package/src/list-view.js +2 -0
- package/src/log-capture.js +225 -0
- package/src/material-view.js +1 -1
- package/src/mcp-tools.js +1149 -0
- package/src/memory-view.js +60 -4
- package/src/mesh-view.js +51 -2
- package/src/perf-copy.js +1 -1
- package/src/physics-view.js +2 -2
- package/src/ref-registry.js +136 -0
- package/src/render-target-view.js +86 -9
- package/src/shader-view.js +33 -2
- package/src/snapshot-view.js +268 -0
- package/src/styles.js +283 -0
- package/src/texture-view.js +2 -2
- package/src/treemap-view.js +837 -0
- package/types/asset-view.d.ts +10 -0
- package/types/image-capture.d.ts +136 -0
- package/types/inspector.d.ts +291 -11
- package/types/layer-view.d.ts +80 -0
- package/types/log-capture.d.ts +104 -0
- package/types/mcp-tools.d.ts +855 -0
- package/types/memory-view.d.ts +11 -0
- package/types/mesh-view.d.ts +13 -0
- package/types/perf-copy.d.ts +22 -0
- package/types/ref-registry.d.ts +75 -0
- package/types/render-target-view.d.ts +17 -4
- package/types/shader-view.d.ts +12 -0
- package/types/snapshot-view.d.ts +166 -0
- package/types/texture-view.d.ts +12 -1
- package/types/treemap-view.d.ts +379 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One thing a snapshot measured, such as a buffer or an asset's file.
|
|
3
|
+
*/
|
|
4
|
+
export type SnapshotItem = {
|
|
5
|
+
/**
|
|
6
|
+
* - Who the item is, unique within the snapshot and kept from one snapshot
|
|
7
|
+
* of a tab to the next, such as the id of a buffer, so that a comparison pairs it with itself.
|
|
8
|
+
*/
|
|
9
|
+
key: string;
|
|
10
|
+
/**
|
|
11
|
+
* - The groups the item is drawn in, outermost first.
|
|
12
|
+
*/
|
|
13
|
+
group: string[];
|
|
14
|
+
/**
|
|
15
|
+
* - Its name.
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* - Its size, in bytes.
|
|
20
|
+
*/
|
|
21
|
+
size: number;
|
|
22
|
+
/**
|
|
23
|
+
* - A line about it, shown while it is hovered.
|
|
24
|
+
*/
|
|
25
|
+
info?: string;
|
|
26
|
+
/**
|
|
27
|
+
* - What it measured, to show in the tab that lists it.
|
|
28
|
+
* Held weakly, so a snapshot keeps nothing of the app alive.
|
|
29
|
+
*/
|
|
30
|
+
target?: WeakRef<object>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* How a treemap's boxes link to the tabs listing what they measured.
|
|
34
|
+
*/
|
|
35
|
+
export type TreemapLinks = {
|
|
36
|
+
/**
|
|
37
|
+
* - The name of the tab listing an object, or
|
|
38
|
+
* null when none does.
|
|
39
|
+
*/
|
|
40
|
+
label: (target: object) => string | null;
|
|
41
|
+
/**
|
|
42
|
+
* - Shows an object in the tab listing it, and says
|
|
43
|
+
* whether it was found there.
|
|
44
|
+
*/
|
|
45
|
+
open: (target: object) => boolean;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A snapshot as the treemap draws it.
|
|
49
|
+
*/
|
|
50
|
+
export type TreemapSnapshot = {
|
|
51
|
+
/**
|
|
52
|
+
* - Its number among the snapshots of its tab.
|
|
53
|
+
*/
|
|
54
|
+
number: number;
|
|
55
|
+
/**
|
|
56
|
+
* - When it was captured, in milliseconds since the epoch.
|
|
57
|
+
*/
|
|
58
|
+
time: number;
|
|
59
|
+
/**
|
|
60
|
+
* - The sum of the sizes of its items.
|
|
61
|
+
*/
|
|
62
|
+
total: number;
|
|
63
|
+
/**
|
|
64
|
+
* - What it measured.
|
|
65
|
+
*/
|
|
66
|
+
items: SnapshotItem[];
|
|
67
|
+
/**
|
|
68
|
+
* - What it leaves out, or an empty string.
|
|
69
|
+
*/
|
|
70
|
+
note: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* What a treemap tab shows: one snapshot, or two compared.
|
|
74
|
+
*/
|
|
75
|
+
export type TreemapData = {
|
|
76
|
+
/**
|
|
77
|
+
* - The name of the tab the snapshots were captured on, such as 'Memory'.
|
|
78
|
+
*/
|
|
79
|
+
tab: string;
|
|
80
|
+
/**
|
|
81
|
+
* - What the sizes are, in a few words.
|
|
82
|
+
*/
|
|
83
|
+
measure: string;
|
|
84
|
+
/**
|
|
85
|
+
* - The snapshot shown, or the later of the two compared.
|
|
86
|
+
*/
|
|
87
|
+
to: TreemapSnapshot;
|
|
88
|
+
/**
|
|
89
|
+
* - The earlier of the two compared, or null.
|
|
90
|
+
*/
|
|
91
|
+
from: TreemapSnapshot | null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A box of the treemap: a group, or an item.
|
|
95
|
+
*/
|
|
96
|
+
export type TreemapNode = {
|
|
97
|
+
/**
|
|
98
|
+
* - Whether it is an item.
|
|
99
|
+
*/
|
|
100
|
+
leaf: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* - Its name, as drawn.
|
|
103
|
+
*/
|
|
104
|
+
name: string;
|
|
105
|
+
/**
|
|
106
|
+
* - Who it is in the tree, for opening a group.
|
|
107
|
+
*/
|
|
108
|
+
id: string;
|
|
109
|
+
/**
|
|
110
|
+
* - The item, for an item.
|
|
111
|
+
*/
|
|
112
|
+
item: SnapshotItem | null;
|
|
113
|
+
/**
|
|
114
|
+
* - The groups inside a group, while it is built.
|
|
115
|
+
*/
|
|
116
|
+
folders: Map<string, TreemapNode>;
|
|
117
|
+
/**
|
|
118
|
+
* - The items directly inside a group, while it is built.
|
|
119
|
+
*/
|
|
120
|
+
leaves: TreemapNode[];
|
|
121
|
+
/**
|
|
122
|
+
* - What a group holds, largest first.
|
|
123
|
+
*/
|
|
124
|
+
kids: TreemapNode[];
|
|
125
|
+
/**
|
|
126
|
+
* - Its bytes in the snapshot shown.
|
|
127
|
+
*/
|
|
128
|
+
value: number;
|
|
129
|
+
/**
|
|
130
|
+
* - Its bytes in the snapshot compared against, or 0.
|
|
131
|
+
*/
|
|
132
|
+
was: number;
|
|
133
|
+
/**
|
|
134
|
+
* - The bytes its box stands for.
|
|
135
|
+
*/
|
|
136
|
+
size: number;
|
|
137
|
+
/**
|
|
138
|
+
* - The group it is drawn in.
|
|
139
|
+
*/
|
|
140
|
+
parent: TreemapNode | null;
|
|
141
|
+
/**
|
|
142
|
+
* - Its fill, the colour of the group at the top it is in.
|
|
143
|
+
*/
|
|
144
|
+
color: string;
|
|
145
|
+
};
|
|
146
|
+
export type TreemapRect = {
|
|
147
|
+
/**
|
|
148
|
+
* - The box.
|
|
149
|
+
*/
|
|
150
|
+
item: TreemapNode;
|
|
151
|
+
/**
|
|
152
|
+
* - Its left.
|
|
153
|
+
*/
|
|
154
|
+
x: number;
|
|
155
|
+
/**
|
|
156
|
+
* - Its top.
|
|
157
|
+
*/
|
|
158
|
+
y: number;
|
|
159
|
+
/**
|
|
160
|
+
* - Its width.
|
|
161
|
+
*/
|
|
162
|
+
w: number;
|
|
163
|
+
/**
|
|
164
|
+
* - Its height.
|
|
165
|
+
*/
|
|
166
|
+
h: number;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* The contents of a treemap tab: a snapshot of a tab, or two compared, drawn as a box per item
|
|
170
|
+
* sized by its bytes, nested in boxes for its groups. Clicking a group's name opens it.
|
|
171
|
+
*
|
|
172
|
+
* Compared, every box takes the larger of the item's two sizes, and the share of it that changed
|
|
173
|
+
* is marked, red for bytes added and striped green for bytes removed. An item in only one of the
|
|
174
|
+
* snapshots is marked whole. Sized by change instead, a box is as large as its change, and items
|
|
175
|
+
* that did not change are left out.
|
|
176
|
+
*
|
|
177
|
+
* Ctrl + wheel or a pinch magnifies at the pointer, drawing the treemap larger than the tab to
|
|
178
|
+
* give more boxes room for their names, and dragging moves around it.
|
|
179
|
+
*
|
|
180
|
+
* @ignore
|
|
181
|
+
*/
|
|
182
|
+
export class TreemapView {
|
|
183
|
+
/**
|
|
184
|
+
* @param {TreemapData} data - What to draw.
|
|
185
|
+
* @param {TreemapLinks|null} [links] - How boxes link to the tabs listing what they measured.
|
|
186
|
+
*/
|
|
187
|
+
constructor(data: TreemapData, links?: TreemapLinks | null);
|
|
188
|
+
/**
|
|
189
|
+
* The tab's panel.
|
|
190
|
+
*
|
|
191
|
+
* @type {HTMLElement}
|
|
192
|
+
*/
|
|
193
|
+
el: HTMLElement;
|
|
194
|
+
/**
|
|
195
|
+
* @type {TreemapData}
|
|
196
|
+
* @private
|
|
197
|
+
*/
|
|
198
|
+
private _data;
|
|
199
|
+
/**
|
|
200
|
+
* How boxes link to the tabs listing what they measured, or null for no links.
|
|
201
|
+
*
|
|
202
|
+
* @type {TreemapLinks|null}
|
|
203
|
+
* @private
|
|
204
|
+
*/
|
|
205
|
+
private _links;
|
|
206
|
+
/**
|
|
207
|
+
* Whether boxes are sized by how much they changed, when comparing.
|
|
208
|
+
*
|
|
209
|
+
* @type {boolean}
|
|
210
|
+
* @private
|
|
211
|
+
*/
|
|
212
|
+
private _byChange;
|
|
213
|
+
/**
|
|
214
|
+
* The id of the group open, or an empty string for everything.
|
|
215
|
+
*
|
|
216
|
+
* @type {string}
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
private _zoom;
|
|
220
|
+
/**
|
|
221
|
+
* The magnification, one of {@link SCALES}.
|
|
222
|
+
*
|
|
223
|
+
* @type {number}
|
|
224
|
+
* @private
|
|
225
|
+
*/
|
|
226
|
+
private _scale;
|
|
227
|
+
/**
|
|
228
|
+
* The tree last drawn.
|
|
229
|
+
*
|
|
230
|
+
* @type {TreemapNode|null}
|
|
231
|
+
* @private
|
|
232
|
+
*/
|
|
233
|
+
private _root;
|
|
234
|
+
/**
|
|
235
|
+
* The size of the view last drawn at, so a refresh redraws only when it changed.
|
|
236
|
+
*
|
|
237
|
+
* @type {string}
|
|
238
|
+
* @private
|
|
239
|
+
*/
|
|
240
|
+
private _drawnSize;
|
|
241
|
+
/**
|
|
242
|
+
* A drag moving around the magnified treemap.
|
|
243
|
+
*
|
|
244
|
+
* @type {{ x: number, y: number, left: number, top: number, moved: boolean }|null}
|
|
245
|
+
* @private
|
|
246
|
+
*/
|
|
247
|
+
private _drag;
|
|
248
|
+
/**
|
|
249
|
+
* The wheel's movement not yet turned into a step of magnification.
|
|
250
|
+
*
|
|
251
|
+
* @type {number}
|
|
252
|
+
* @private
|
|
253
|
+
*/
|
|
254
|
+
private _wheel;
|
|
255
|
+
/** @type {HTMLElement} @private */
|
|
256
|
+
private _crumbs;
|
|
257
|
+
/** @type {HTMLElement} @private */
|
|
258
|
+
private _view;
|
|
259
|
+
/** @type {HTMLElement} @private */
|
|
260
|
+
private _box;
|
|
261
|
+
/** @type {HTMLElement} @private */
|
|
262
|
+
private _legend;
|
|
263
|
+
/** @type {HTMLElement} @private */
|
|
264
|
+
private _tip;
|
|
265
|
+
/** @type {HTMLElement} @private */
|
|
266
|
+
private _scaleText;
|
|
267
|
+
/** @type {HTMLButtonElement} @private */
|
|
268
|
+
private _scaleDown;
|
|
269
|
+
/** @type {HTMLButtonElement} @private */
|
|
270
|
+
private _scaleUp;
|
|
271
|
+
/**
|
|
272
|
+
* The name of the tab, such as 'Memory #2' or 'Memory #1→#2'.
|
|
273
|
+
*
|
|
274
|
+
* @type {string}
|
|
275
|
+
*/
|
|
276
|
+
get title(): string;
|
|
277
|
+
/**
|
|
278
|
+
* When the snapshots were captured and what they add up to.
|
|
279
|
+
*
|
|
280
|
+
* @type {string}
|
|
281
|
+
*/
|
|
282
|
+
get summary(): string;
|
|
283
|
+
/**
|
|
284
|
+
* The tree last drawn, for tests.
|
|
285
|
+
*
|
|
286
|
+
* @type {TreemapNode|null}
|
|
287
|
+
*/
|
|
288
|
+
get tree(): TreemapNode | null;
|
|
289
|
+
/**
|
|
290
|
+
* Opens a group.
|
|
291
|
+
*
|
|
292
|
+
* @param {string} id - The group's id, or an empty string for everything.
|
|
293
|
+
*/
|
|
294
|
+
zoomTo(id: string): void;
|
|
295
|
+
/**
|
|
296
|
+
* Draws again when the tab changed size since it was drawn, as when the panel was resized.
|
|
297
|
+
* Called on the panel's refreshes, rather than on every frame.
|
|
298
|
+
*/
|
|
299
|
+
fit(): void;
|
|
300
|
+
/**
|
|
301
|
+
* Draws the treemap from the top of the group open, with its trail and legend.
|
|
302
|
+
*/
|
|
303
|
+
render(): void;
|
|
304
|
+
/**
|
|
305
|
+
* Draws a box, and inside a group, the boxes it holds.
|
|
306
|
+
*
|
|
307
|
+
* @param {TreemapNode} node - The box.
|
|
308
|
+
* @param {HTMLElement} parent - The element it goes in.
|
|
309
|
+
* @param {{ x: number, y: number, w: number, h: number }} rect - Where it goes in it.
|
|
310
|
+
* @param {TreemapNode} top - The group open, for the share of it a box is.
|
|
311
|
+
* @private
|
|
312
|
+
*/
|
|
313
|
+
private _place;
|
|
314
|
+
/**
|
|
315
|
+
* @param {TreemapNode} node - An item's box.
|
|
316
|
+
* @returns {string|null} The name of the tab listing what it measured, as it was when the
|
|
317
|
+
* snapshot was taken, or null when no tab lists it.
|
|
318
|
+
* @private
|
|
319
|
+
*/
|
|
320
|
+
private _linkOf;
|
|
321
|
+
/**
|
|
322
|
+
* Shows what the box under the pointer holds, by the pointer.
|
|
323
|
+
*
|
|
324
|
+
* @param {MouseEvent} e - The pointer's move.
|
|
325
|
+
* @param {TreemapNode} node - The box.
|
|
326
|
+
* @param {TreemapNode} top - The group open.
|
|
327
|
+
* @param {string} [note] - A line to end on instead of where a click goes.
|
|
328
|
+
* @private
|
|
329
|
+
*/
|
|
330
|
+
private _showTip;
|
|
331
|
+
/**
|
|
332
|
+
* Sizes the treemap for the magnification, to the room the tab has.
|
|
333
|
+
*
|
|
334
|
+
* @private
|
|
335
|
+
*/
|
|
336
|
+
private _fitBox;
|
|
337
|
+
/**
|
|
338
|
+
* Steps the magnification, keeping one point of the treemap where it is: the pointer when
|
|
339
|
+
* magnifying with the wheel, otherwise the middle.
|
|
340
|
+
*
|
|
341
|
+
* @param {number} step - Steps to take, up or down.
|
|
342
|
+
* @param {number} [anchorX] - The point to keep, from the left of the tab.
|
|
343
|
+
* @param {number} [anchorY] - The point to keep, from the top of the tab.
|
|
344
|
+
* @private
|
|
345
|
+
*/
|
|
346
|
+
private _magnify;
|
|
347
|
+
/**
|
|
348
|
+
* Ctrl + wheel magnifies towards the pointer, as in maps and design tools; a trackpad pinch
|
|
349
|
+
* arrives the same way. A plain wheel scrolls, and Shift + wheel scrolls sideways, as usual.
|
|
350
|
+
*
|
|
351
|
+
* @param {WheelEvent} e - The event.
|
|
352
|
+
* @private
|
|
353
|
+
*/
|
|
354
|
+
private _onWheel;
|
|
355
|
+
/**
|
|
356
|
+
* @param {PointerEvent} e - The event.
|
|
357
|
+
* @private
|
|
358
|
+
*/
|
|
359
|
+
private _onPointerDown;
|
|
360
|
+
/**
|
|
361
|
+
* Dragging moves around a magnified treemap.
|
|
362
|
+
*
|
|
363
|
+
* @param {PointerEvent} e - The event.
|
|
364
|
+
* @private
|
|
365
|
+
*/
|
|
366
|
+
private _onPointerMove;
|
|
367
|
+
/**
|
|
368
|
+
* @param {PointerEvent} e - The event.
|
|
369
|
+
* @private
|
|
370
|
+
*/
|
|
371
|
+
private _onPointerUp;
|
|
372
|
+
/**
|
|
373
|
+
* + and - magnify, 0 fits and Backspace goes back up a group, while the treemap has focus.
|
|
374
|
+
*
|
|
375
|
+
* @param {KeyboardEvent} e - The event.
|
|
376
|
+
* @private
|
|
377
|
+
*/
|
|
378
|
+
private _onKeyDown;
|
|
379
|
+
}
|