@playcanvas/inspector 0.2.0 → 0.4.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.
Files changed (49) hide show
  1. package/README.md +147 -5
  2. package/package.json +1 -1
  3. package/src/asset-view.js +24 -17
  4. package/src/camera-view.js +5 -3
  5. package/src/context-menu.js +231 -0
  6. package/src/copy-json.js +692 -0
  7. package/src/describe.js +20 -1
  8. package/src/entity-inspector-script.js +10 -0
  9. package/src/frame-graph-view.js +41 -9
  10. package/src/hierarchy-view.js +29 -3
  11. package/src/inspector.js +958 -80
  12. package/src/list-view.js +118 -12
  13. package/src/material-view.js +7 -6
  14. package/src/memory-view.js +224 -66
  15. package/src/mesh-view.js +6 -5
  16. package/src/model.js +24 -2
  17. package/src/node-model.js +81 -11
  18. package/src/perf-capture.js +2034 -0
  19. package/src/perf-chart.js +3989 -0
  20. package/src/perf-copy.js +367 -0
  21. package/src/perf-view.js +1224 -0
  22. package/src/property-view.js +162 -5
  23. package/src/render-target-view.js +3 -3
  24. package/src/script-view.js +21 -12
  25. package/src/styles.js +374 -2
  26. package/src/texture-view.js +4 -4
  27. package/src/transform-tool.js +185 -0
  28. package/types/asset-view.d.ts +3 -1
  29. package/types/camera-view.d.ts +4 -0
  30. package/types/context-menu.d.ts +90 -0
  31. package/types/copy-json.d.ts +69 -0
  32. package/types/describe.d.ts +1 -1
  33. package/types/entity-inspector-script.d.ts +8 -0
  34. package/types/frame-graph-view.d.ts +7 -0
  35. package/types/hierarchy-view.d.ts +13 -0
  36. package/types/inspector.d.ts +339 -25
  37. package/types/list-view.d.ts +44 -3
  38. package/types/material-view.d.ts +3 -1
  39. package/types/memory-view.d.ts +24 -25
  40. package/types/mesh-view.d.ts +3 -1
  41. package/types/model.d.ts +16 -1
  42. package/types/node-model.d.ts +17 -1
  43. package/types/perf-capture.d.ts +871 -0
  44. package/types/perf-chart.d.ts +1407 -0
  45. package/types/perf-copy.d.ts +61 -0
  46. package/types/perf-view.d.ts +231 -0
  47. package/types/property-view.d.ts +41 -0
  48. package/types/script-view.d.ts +3 -1
  49. package/types/transform-tool.d.ts +92 -0
@@ -0,0 +1,1407 @@
1
+ export type PerfChartDef = object;
2
+ export type PerfLine = object;
3
+ export type PerfLineChart = object;
4
+ export type PerfScriptLine = object;
5
+ export type PerfLevels = object;
6
+ export type PerfShape = object;
7
+ export type PerfRow = object;
8
+ export type PerfHoverLine = object;
9
+ export type PerfTimeBar = object;
10
+ export type PerfPassLink = object;
11
+ export type PerfScriptType = object;
12
+ export type PerfBar = object;
13
+ /** @import { PerfCapture, PerfLoad } from './perf-capture.js' */
14
+ /** @import { PerfPart, PerfScriptLegend } from './perf-view.js' */
15
+ /**
16
+ * @typedef {object} PerfChartDef
17
+ * @ignore
18
+ * @property {string} key - A key unique among the charts.
19
+ * @property {string} title - The title drawn beside it.
20
+ * @property {string} tip - What it shows, while the pointer is over its title.
21
+ * @property {string} total - The channel holding the sum of its parts, which sets its scale and
22
+ * picks the frame a column of many frames shows.
23
+ * @property {PerfPart[]} parts - What it stacks, bottom up.
24
+ * @property {PerfPart[]} [lines] - Parts of the stack drawn as lines across it, as they are
25
+ * counted within the parts already.
26
+ * @property {PerfPart[]} [plain] - What it stacks with an engine that does not break its total
27
+ * down: the release engine.
28
+ * @property {(value: number) => string} format - Formats its figures.
29
+ * @property {boolean} [timing] - Whether it is a duration, scaled to show the display interval
30
+ * as a watermark.
31
+ * @property {number} [unit] - The unit its scale is rounded in, such as a megabyte for memory.
32
+ * @property {string} [empty] - What it says while it has nothing to draw.
33
+ */
34
+ /**
35
+ * @typedef {object} PerfLine
36
+ * @ignore
37
+ * @property {string} key - The channel it draws.
38
+ * @property {string} name - The display name.
39
+ * @property {string} color - The color it is drawn in.
40
+ * @property {string} [unsupported] - Why it cannot show, where it cannot.
41
+ * @property {Float64Array} [values] - The ring it draws, where it is not a channel of the capture.
42
+ */
43
+ /**
44
+ * @typedef {object} PerfLineChart
45
+ * @ignore
46
+ * @property {PerfLine[]} lines - Its lines.
47
+ * @property {(value: number) => string} format - Formats their values.
48
+ * @property {Int32Array} pick - The frame each column showed.
49
+ * @property {number} min - The value at its bottom.
50
+ * @property {number} max - The value at its top.
51
+ * @property {PerfLevels|null} levels - How a height in it reads as a value, null while it has none.
52
+ * @property {Float64Array[]} [values] - The ring each line was drawn from, where it is not a
53
+ * channel of the capture.
54
+ * @property {boolean} [stacked] - Whether its lines are stacked, as the times of the scripts are.
55
+ * @property {PerfScriptLegend} [legend] - The script types it gives a band of their own.
56
+ */
57
+ /**
58
+ * @typedef {object} PerfScriptLine
59
+ * @ignore
60
+ * @property {string} key - The key it is hidden under.
61
+ * @property {string} name - The display name.
62
+ * @property {string} color - The color it is drawn in.
63
+ * @property {number} id - The script type, by its index into the names of the capture, or -1 for
64
+ * the other types together.
65
+ * @property {boolean} pinned - Whether it has its band because it is pinned.
66
+ */
67
+ /**
68
+ * @typedef {object} PerfLevels
69
+ * @ignore
70
+ * @property {number} top - The top of the area its values are drawn in.
71
+ * @property {number} bottom - Its bottom.
72
+ * @property {number} min - The value at the bottom.
73
+ * @property {number} max - The value at the top.
74
+ * @property {(value: number) => string} format - Formats a value.
75
+ */
76
+ /**
77
+ * @typedef {object} PerfShape
78
+ * @ignore
79
+ * @property {string} total - The channel a chart is scaled to.
80
+ * @property {PerfPart[]} parts - What it stacks.
81
+ * @property {PerfPart[]} lines - Its lines across the stack.
82
+ * @property {Float64Array[]} partData - The ring of each part.
83
+ * @property {Float64Array[]} lineData - The ring of each line.
84
+ * @property {boolean} reduced - Whether the inspector's time is left out.
85
+ */
86
+ /**
87
+ * @typedef {object} PerfRow
88
+ * @ignore
89
+ * @property {number} top - Its top edge in CSS pixels.
90
+ * @property {number} height - Its height.
91
+ * @property {number} [chart] - The index of the chart it holds, into {@link CHARTS}.
92
+ * @property {PerfLevels} [levels] - How a height in it reads as a value, for a chart.
93
+ * @property {string} [lines] - The section of the line chart it is a line of the list of:
94
+ * 'scripts', 'counters', 'memory' or 'resources'.
95
+ * @property {number} [index] - Which line of that list it is, -1 for a row that is not one.
96
+ * @property {'more'|'fewer'} [control] - The row of the Scripts list it is that shows more script
97
+ * types, or fewer.
98
+ * @property {string} [loading] - The row of the Loading section it is.
99
+ * @property {number} [kind] - The index of the kind of event it marks, into {@link EVENT_KINDS}.
100
+ * @property {string} [section] - The section it is the title of: 'memory', 'resources', 'events'
101
+ * or the key of a collapsed chart.
102
+ */
103
+ /**
104
+ * @typedef {object} PerfHoverLine
105
+ * @ignore
106
+ * @property {string} text - The line.
107
+ * @property {string} [color] - The color of what it names, shown as a chip in front of it.
108
+ * @property {boolean} [indent] - Whether it is a part of the line above.
109
+ * @property {boolean} [wrap] - Whether it is prose, wrapped to the width of the box.
110
+ * @property {boolean} [strong] - Whether it is what the pointer is over, among the lines.
111
+ * @property {boolean} [nested] - Whether it is a part of the indented line above, as a script type
112
+ * among the other scripts.
113
+ * @property {boolean} [muted] - Whether it says about the lines rather than being one of them.
114
+ */
115
+ /**
116
+ * @typedef {object} PerfTimeBar
117
+ * @ignore
118
+ * @property {string} lane - The key of the row of the frame timeline it goes on.
119
+ * @property {number} start - When it began, in milliseconds from the start of the frame, NaN
120
+ * where the engine did not time it.
121
+ * @property {number} duration - How long it took in milliseconds.
122
+ * @property {string} color - The color it is drawn in.
123
+ * @property {string} name - What it is.
124
+ * @property {boolean} positioned - Whether its start is known, rather than placed after the bar
125
+ * before, as a GPU pass is.
126
+ * @property {boolean} [instant] - Whether it has no duration, as an asset finishing loading.
127
+ * @property {number} [calls] - How many calls it took, as a script type does; the mean per frame
128
+ * for an average frame.
129
+ * @property {string} [label] - What its hover box calls it, where its name alone is not enough.
130
+ * @property {number} [script] - The script type it is, by its index into the names of the capture.
131
+ * @property {PerfPassLink} [pass] - The pass of the frame graph it is, which a click shows on the
132
+ * Frame graph tab.
133
+ * @property {number} [asset] - The id of the asset it is the loading of, which a click shows on the
134
+ * Assets tab.
135
+ * @property {boolean} [phase] - Whether it is a phase of the render, placed after the one before
136
+ * it rather than where it ran.
137
+ * @property {number} [labelEnd] - Where its label stops, in milliseconds into the frame: where the
138
+ * next bar of its lane begins.
139
+ * @property {number} [run] - How many passes of its name follow on in a row from it, it among
140
+ * them, which share one label; 0 for one inside such a run.
141
+ * @property {number} [runDuration] - Their time together.
142
+ * @property {PerfScriptType[]} [children] - What it is made of, which its hover box lists, as the
143
+ * script types of the scripts.
144
+ */
145
+ /**
146
+ * @typedef {object} PerfPassLink
147
+ * @ignore
148
+ * @property {string} name - The profiler name of the pass.
149
+ * @property {number} occurrence - Which of the passes of the frame graph with that name it is.
150
+ */
151
+ /**
152
+ * @typedef {object} PerfScriptType
153
+ * @ignore
154
+ * @property {number} id - The script type, by its index into the names of the capture.
155
+ * @property {string} name - Its name.
156
+ * @property {number} duration - Its own time in an update or a post-update, in milliseconds.
157
+ * @property {number} [calls] - How many calls that took.
158
+ * @property {number} [order] - Where its first call came among the types', 1 for the first.
159
+ * @property {string} color - The color it is drawn in.
160
+ */
161
+ /**
162
+ * @typedef {object} PerfBar
163
+ * @ignore
164
+ * @property {number} x0 - Its left edge in CSS pixels.
165
+ * @property {number} x1 - Its right edge.
166
+ * @property {string} lane - The key of the row of the frame timeline it is on.
167
+ * @property {string} name - What it is.
168
+ * @property {string} color - The color it is drawn in.
169
+ * @property {number} duration - How long it took in milliseconds, zero for an instant.
170
+ * @property {number} start - When it began, in milliseconds into the frame, NaN where unknown.
171
+ * @property {number} [calls] - How many calls it took.
172
+ * @property {string} [label] - What its hover box calls it.
173
+ * @property {number} [script] - The script type it is, which a click shows on the Scripts tab.
174
+ * @property {PerfPassLink} [pass] - The pass of the frame graph it is, which a click shows on the
175
+ * Frame graph tab.
176
+ * @property {number} [asset] - The id of the asset it is the loading of.
177
+ * @property {PerfScriptType[]} [children] - What it is made of.
178
+ */
179
+ /**
180
+ * The charts, top to bottom, above the rows of events.
181
+ *
182
+ * @type {PerfChartDef[]}
183
+ */
184
+ export const CHARTS: PerfChartDef[];
185
+ /**
186
+ * The charts of a capture, a column per frame or per group of frames, with the frame they show
187
+ * picked by a cursor that every chart shares, the events of the frames in a row per kind below
188
+ * them, and below that the timeline of the frame shown. A column of many frames shows the one
189
+ * with the largest figure in that chart, so a spike never hides between pixels, and clicking the
190
+ * column picks that frame. Hovering a column says what it shows.
191
+ *
192
+ * Click a frame to show it, drag to select frames together, scroll to zoom, scroll with Shift to
193
+ * pan and double-click to see the whole capture again.
194
+ *
195
+ * @ignore
196
+ */
197
+ export class PerfCharts {
198
+ /**
199
+ * Picks the frame each column shows: the one with the largest value.
200
+ *
201
+ * @param {Float64Array} values - The ring of the channel.
202
+ * @param {number} slots - The length of the ring.
203
+ * @param {Int32Array} lo - The first frame of each column.
204
+ * @param {Int32Array} hi - One past the last frame of each column.
205
+ * @param {Int32Array} pick - Receives the frame of each column, left as it was for a column
206
+ * without a value.
207
+ * @param {Float64Array} peaks - Receives the values picked, packed.
208
+ * @returns {number} How many columns had a value.
209
+ * @private
210
+ */
211
+ private static _pickLargest;
212
+ /**
213
+ * Draws the parts of a chart stacked, a bar each, each part at least a pixel high so none of
214
+ * them goes missing, with the lines across the stack, the spikes cut off by the scale marked
215
+ * along the top and the hitches above them.
216
+ *
217
+ * @param {CanvasRenderingContext2D} ctx - The context.
218
+ * @param {PerfShape} shape - What the chart draws.
219
+ * @param {Float64Array} totals - The ring of its total.
220
+ * @param {number} slots - The length of the rings.
221
+ * @param {Int32Array|null} pick - The frame of each column, or null when each bar is a frame
222
+ * of its own, from the first in view.
223
+ * @param {number} visibleFrom - The first frame in view.
224
+ * @param {number} bars - How many bars there are.
225
+ * @param {Int32Array} barX - The left edge of each bar.
226
+ * @param {Int32Array} barW - The width of each bar.
227
+ * @param {number} top - The top of the chart, a whole pixel.
228
+ * @param {number} height - Its height, a whole number of pixels.
229
+ * @param {number} scale - The value at its top.
230
+ * @param {number} hitchAbove - The total a hitch takes over, Infinity for none.
231
+ * @param {Int32Array} base - Room for where the stack of each bar has got to.
232
+ * @param {Float64Array} sums - Room for the sum of each bar so far.
233
+ * @private
234
+ */
235
+ private static _drawStack;
236
+ /**
237
+ * Draws a line through the values of the bars, scaled from the smallest to the largest. A
238
+ * frame without a value breaks it.
239
+ *
240
+ * @param {CanvasRenderingContext2D} ctx - The context, with its stroke set.
241
+ * @param {Float64Array} values - The ring of the channel.
242
+ * @param {number} slots - The length of the ring.
243
+ * @param {Int32Array|null} pick - The frame of each column, or null when each bar is a frame
244
+ * of its own, from the first in view.
245
+ * @param {number} visibleFrom - The first frame in view.
246
+ * @param {number} bars - How many bars there are.
247
+ * @param {Int32Array} barX - The left edge of each bar.
248
+ * @param {Int32Array} barW - The width of each bar.
249
+ * @param {number} bottom - Where the smallest value goes down the canvas.
250
+ * @param {number} reach - How far up the largest goes from there.
251
+ * @param {number} min - The smallest value.
252
+ * @param {number} max - The largest.
253
+ * @private
254
+ */
255
+ private static _drawLine;
256
+ /**
257
+ * Marks the bars whose mask has a bit.
258
+ *
259
+ * @param {CanvasRenderingContext2D} ctx - The context, with its fill set.
260
+ * @param {Int32Array} masks - The kinds of event of each bar.
261
+ * @param {number} bit - The kind to mark.
262
+ * @param {number} bars - How many bars there are.
263
+ * @param {Int32Array} barX - The left edge of each bar.
264
+ * @param {Int32Array} barW - The width of each bar.
265
+ * @param {number} top - The top of the marks.
266
+ * @param {number} height - Their height.
267
+ * @private
268
+ */
269
+ private static _drawMarks;
270
+ /**
271
+ * Draws the box beside a line or a row of events, ticked while it shows.
272
+ *
273
+ * @param {CanvasRenderingContext2D} ctx - The context.
274
+ * @param {number} x - Its left edge, on a half pixel so its outline is sharp.
275
+ * @param {number} y - Its top edge, likewise.
276
+ * @param {string} color - The color of what it shows.
277
+ * @param {boolean} on - Whether it is ticked.
278
+ * @private
279
+ */
280
+ private static _checkbox;
281
+ /**
282
+ * Finds the smallest and largest value of a span of frames.
283
+ *
284
+ * @param {Float64Array} values - The ring of the channel.
285
+ * @param {number} slots - The length of the ring.
286
+ * @param {number} from - The first frame.
287
+ * @param {number} to - One past the last frame.
288
+ * @param {Float64Array} range - Receives the smallest and the largest value, Infinity and
289
+ * -Infinity when there are none.
290
+ * @private
291
+ */
292
+ private static _rangeOf;
293
+ /**
294
+ * Draws a label over a dark backing, to read over the bars.
295
+ *
296
+ * @param {CanvasRenderingContext2D} ctx - The context.
297
+ * @param {string} text - The text.
298
+ * @param {number} x - Where it is anchored across.
299
+ * @param {number} y - Its top.
300
+ * @param {'left'|'right'} align - Which side the anchor is on.
301
+ * @private
302
+ */
303
+ private static _label;
304
+ /**
305
+ * As much of a label as fits: the name and its time, the name alone, or the start of the name
306
+ * cut short with an ellipsis.
307
+ *
308
+ * @param {CanvasRenderingContext2D} ctx - The context, with the font set.
309
+ * @param {string} name - The name.
310
+ * @param {string} time - Its time, empty for none.
311
+ * @param {number} room - The width there is.
312
+ * @returns {string} What fits, empty when not even a letter does.
313
+ * @private
314
+ */
315
+ private static _fit;
316
+ /**
317
+ * @param {number} x - A position across the charts or the timeline right of the names.
318
+ * @returns {boolean} Whether it is on the divider beside the names.
319
+ * @private
320
+ */
321
+ private static _onDivider;
322
+ /**
323
+ * @param {HTMLElement} container - The element to fill.
324
+ * @param {PerfCapture} capture - The capture to chart.
325
+ */
326
+ constructor(container: HTMLElement, capture: PerfCapture);
327
+ /**
328
+ * Called when the frame shown or the selected frames change.
329
+ *
330
+ * @type {() => void}
331
+ */
332
+ onChange: () => void;
333
+ /**
334
+ * The frame picked, or -1 to follow the newest.
335
+ *
336
+ * @type {number}
337
+ */
338
+ picked: number;
339
+ /**
340
+ * The frames selected together, inclusive, or null.
341
+ *
342
+ * @type {{ from: number, to: number }|null}
343
+ */
344
+ range: {
345
+ from: number;
346
+ to: number;
347
+ } | null;
348
+ /**
349
+ * The charts and the sections under them that are collapsed to their titles: the keys of
350
+ * {@link CHARTS}, 'resources' and 'events'.
351
+ *
352
+ * @type {Set<string>}
353
+ */
354
+ collapsed: Set<string>;
355
+ /**
356
+ * The lines of the Memory and Resources charts, and the rows of events, that are hidden: each
357
+ * by its section and key, such as 'memory:vramTex' or 'events:resource'.
358
+ *
359
+ * @type {Set<string>}
360
+ */
361
+ hidden: Set<string>;
362
+ /**
363
+ * Called when a section is collapsed or expanded, or a line hidden or shown: what is kept
364
+ * between sessions.
365
+ *
366
+ * @type {() => void}
367
+ */
368
+ onCollapse: () => void;
369
+ /**
370
+ * How many of the longest script types the Scripts chart gives a band of their own, besides
371
+ * those pinned: a multiple of {@link SCRIPT_ROWS}, more with each Show more.
372
+ *
373
+ * @type {number}
374
+ */
375
+ scriptRows: number;
376
+ /**
377
+ * The names of the script types pinned, which the Scripts chart gives a band of their own
378
+ * whatever their time.
379
+ *
380
+ * @type {Set<string>}
381
+ */
382
+ pinned: Set<string>;
383
+ /**
384
+ * Called with a script type clicked on the timeline, by its index into the names of the
385
+ * capture, to show it on the Scripts tab.
386
+ *
387
+ * @type {(id: number) => void}
388
+ */
389
+ onSelectScript: (id: number) => void;
390
+ /**
391
+ * Called with the id of an asset clicked in the Loading section, to show it on the Assets tab.
392
+ *
393
+ * @type {(id: number) => void}
394
+ */
395
+ onSelectAsset: (id: number) => void;
396
+ /**
397
+ * Called with a GPU pass or effect clicked on the timeline, to show it on the Frame graph tab.
398
+ *
399
+ * @type {(pass: PerfPassLink) => void}
400
+ */
401
+ onSelectPass: (pass: PerfPassLink) => void;
402
+ /**
403
+ * Whether the CPU chart includes the inspector's own time. It runs inside the app's update and
404
+ * can dwarf a light app, so leaving it out scales the chart to the app's own time.
405
+ *
406
+ * @type {boolean}
407
+ */
408
+ showInspector: boolean;
409
+ /**
410
+ * @type {PerfCapture}
411
+ * @private
412
+ */
413
+ private _capture;
414
+ /**
415
+ * The frames in view while zoomed in, null to view the whole capture. A view reaching the
416
+ * newest frame follows it as frames are recorded.
417
+ *
418
+ * @type {{ from: number, span: number, follow: boolean }|null}
419
+ * @private
420
+ */
421
+ private _view;
422
+ /** @private */
423
+ private _hover;
424
+ /**
425
+ * The level under the pointer in a chart: a line across it there, labelled with its value, to
426
+ * hold samples against. Null while the pointer is not over a chart.
427
+ *
428
+ * @type {{ y: number, value: number, format: (value: number) => string }|null}
429
+ * @private
430
+ */
431
+ private _level;
432
+ /**
433
+ * The bars of the frame timeline last drawn, and the one under the pointer.
434
+ *
435
+ * @type {PerfBar[]}
436
+ * @private
437
+ */
438
+ private _bars;
439
+ /**
440
+ * The rows of the frame timeline last drawn.
441
+ *
442
+ * @type {{ key: string, name: string, title: string, y: number, h: number }[]}
443
+ * @private
444
+ */
445
+ private _lanes;
446
+ /**
447
+ * The frame each column of each chart showed when last drawn, to pick it on a click.
448
+ *
449
+ * @type {Int32Array[]}
450
+ * @private
451
+ */
452
+ private _columns;
453
+ /**
454
+ * Arrays kept between redraws, by what they are for.
455
+ *
456
+ * @type {Map<string, Int32Array|Float64Array>}
457
+ * @private
458
+ */
459
+ private _scratch;
460
+ /**
461
+ * The ways each chart can be drawn, made once, see {@link _shape}.
462
+ *
463
+ * @type {Map<string, PerfShape>}
464
+ * @private
465
+ */
466
+ private _shapes;
467
+ /**
468
+ * What the Loading section last drew, by row, for the pointer: each item across the canvas, in
469
+ * CSS pixels, with its lane among the assets.
470
+ *
471
+ * @type {Record<string, { x0: number, x1: number, lane: number, load: any }[]>}
472
+ * @private
473
+ */
474
+ private _loadingDrawn;
475
+ /**
476
+ * The script types the Scripts chart last drew, telling when a new selection changes them.
477
+ *
478
+ * @private
479
+ */
480
+ private _legendSignature;
481
+ /**
482
+ * The line charts, and the stacked chart of the scripts, as last drawn, by section, null while
483
+ * collapsed or empty.
484
+ *
485
+ * @type {{ scripts: PerfLineChart|null, memory: PerfLineChart|null, resources: PerfLineChart|null }}
486
+ * @private
487
+ */
488
+ private _lineCharts;
489
+ /**
490
+ * The first and one past the last frame of each column when last drawn.
491
+ *
492
+ * @type {{ lo: Int32Array, hi: Int32Array }}
493
+ * @private
494
+ */
495
+ private _spans;
496
+ /**
497
+ * The charts and rows of events when last drawn.
498
+ *
499
+ * @type {PerfRow[]}
500
+ * @private
501
+ */
502
+ private _rows;
503
+ /**
504
+ * What needs drawing on the next {@link update}: the charts, the frame timeline, and the
505
+ * overlay marking the frame shown, the frame hovered and the frames selected together. The
506
+ * overlay is a canvas of its own, so moving the pointer redraws only it.
507
+ *
508
+ * @private
509
+ */
510
+ private _drawn;
511
+ /**
512
+ * Where the charts last drew their frames, which the overlay and the pointer go by, so they
513
+ * match what is on screen between redraws while frames are being recorded.
514
+ *
515
+ * @private
516
+ */
517
+ private _layout;
518
+ /**
519
+ * The height the charts and their sections were last laid out in, which is taller than their
520
+ * box when they do not fit it, so the box scrolls.
521
+ *
522
+ * @private
523
+ */
524
+ private _contentHeight;
525
+ /**
526
+ * The press on the charts being held: where it went down, the frame there, whether it drags
527
+ * out a range, and the pointer it took. A press with Shift while zoomed in pans instead, from
528
+ * where the view began, once it has moved, and one on the divider beside the names drags it.
529
+ *
530
+ * @type {{ x: number, seq: number, ranging: boolean, pointerId: number, pan?: boolean, from?: number, moved?: boolean, resize?: boolean, clientX?: number, gutter?: number }|null}
531
+ * @private
532
+ */
533
+ private _press;
534
+ /**
535
+ * Where the pointer is across the charts right of the names, NaN while it is not over them.
536
+ *
537
+ * @type {number}
538
+ * @private
539
+ */
540
+ private _pointerX;
541
+ /**
542
+ * Whether the divider beside the names is under the pointer or being dragged.
543
+ *
544
+ * @type {boolean}
545
+ * @private
546
+ */
547
+ private _dividerHot;
548
+ /**
549
+ * The width of the names left of the charts and the timeline.
550
+ *
551
+ * @type {number}
552
+ * @private
553
+ */
554
+ private _gutter;
555
+ /**
556
+ * The press on the frame timeline being held, which drags the divider beside the names or,
557
+ * with Shift while zoomed in, pans.
558
+ *
559
+ * @type {{ x: number, pointerId: number, resize?: boolean, clientX?: number, gutter?: number, pan?: boolean, from?: number, moved?: boolean }|null}
560
+ * @private
561
+ */
562
+ private _timePress;
563
+ /**
564
+ * Where the pointer is across the timeline right of the names, NaN while it is not over it.
565
+ *
566
+ * @type {number}
567
+ * @private
568
+ */
569
+ private _timePointerX;
570
+ /**
571
+ * The cursor of the timeline for what is under the pointer: a hand over a bar a click shows.
572
+ *
573
+ * @type {string}
574
+ * @private
575
+ */
576
+ private _timeCursor;
577
+ /**
578
+ * Whether a press on the timeline dragged, so the click it ends in does nothing.
579
+ *
580
+ * @type {boolean}
581
+ * @private
582
+ */
583
+ private _timeDragged;
584
+ /**
585
+ * Where the title of the timeline ends across it, which a click collapses or expands it up to.
586
+ *
587
+ * @type {number}
588
+ * @private
589
+ */
590
+ private _timelineTitleEnd;
591
+ /**
592
+ * The window whose Shift key the cursor follows while the pointer is over the charts.
593
+ *
594
+ * @type {Window|null}
595
+ * @private
596
+ */
597
+ private _keyView;
598
+ /**
599
+ * What each hover box shows, to rebuild its lines only when that changes.
600
+ *
601
+ * @type {WeakMap<HTMLElement, string>}
602
+ * @private
603
+ */
604
+ private _hoverSignatures;
605
+ /**
606
+ * Redraws the charts and the timeline as soon as their boxes change size, before the browser
607
+ * paints them stretched.
608
+ *
609
+ * @type {ResizeObserver|null}
610
+ * @private
611
+ */
612
+ private _resizeObserver;
613
+ /**
614
+ * The part of the frame the timeline shows while zoomed in, in milliseconds from its start, or
615
+ * null for all of it.
616
+ *
617
+ * @type {{ from: number, span: number }|null}
618
+ * @private
619
+ */
620
+ private _timeView;
621
+ /**
622
+ * Where the timeline last drew: the part of the frame in view, the length of the frame and the
623
+ * width it was drawn across.
624
+ *
625
+ * @private
626
+ */
627
+ private _timeLayout;
628
+ /**
629
+ * The height of the timeline, taller while it has a line of script types.
630
+ *
631
+ * @private
632
+ */
633
+ private _timelineHeight;
634
+ /**
635
+ * The size of the charts and of the timeline, as the resize observer last reported them. A
636
+ * draw goes by these rather than asking the page, which would lay out the whole panel there
637
+ * and then after the property view changed it, inside the app's frame.
638
+ *
639
+ * @type {Map<Element, { width: number, height: number }>}
640
+ * @private
641
+ */
642
+ private _sizes;
643
+ /**
644
+ * The window the resize observer belongs to. The panel can move into a window of its own,
645
+ * whose observer it then needs.
646
+ *
647
+ * @type {Window|null}
648
+ * @private
649
+ */
650
+ private _resizeView;
651
+ _chartsEl: HTMLDivElement;
652
+ _canvas: HTMLCanvasElement;
653
+ _overlay: HTMLCanvasElement;
654
+ _panelEl: HTMLElement;
655
+ _hoverEl: HTMLDivElement;
656
+ _timelineEl: HTMLDivElement;
657
+ _timeline: HTMLCanvasElement;
658
+ _timelineHoverEl: HTMLDivElement;
659
+ _scrollbar: PerfScrollbar;
660
+ _timeScrollbar: PerfScrollbar;
661
+ /**
662
+ * Stops watching the size of the charts.
663
+ */
664
+ destroy(): void;
665
+ /**
666
+ * Watches the size of the charts and the timeline with an observer of the window they are in,
667
+ * making a new one when they have moved to another window.
668
+ *
669
+ * @private
670
+ */
671
+ private _observeSize;
672
+ /**
673
+ * The charts or the timeline changed size, such as while the splitter above the property view
674
+ * is dragged: draws them at their new size now, rather than leaving the browser to stretch the
675
+ * last drawing until the next redraw.
676
+ *
677
+ * @private
678
+ */
679
+ private _onResize;
680
+ /**
681
+ * The width of the names left of the charts and the timeline, in CSS pixels, which dragging
682
+ * the divider beside them changes. It keeps the plot at least a little wide.
683
+ *
684
+ * @type {number}
685
+ */
686
+ set gutter(value: number);
687
+ get gutter(): number;
688
+ /**
689
+ * The element holding the charts, which scrolls when they do not fit it.
690
+ *
691
+ * @type {HTMLElement}
692
+ */
693
+ get chartsElement(): HTMLElement;
694
+ /**
695
+ * The element holding the frame timeline, for a tooltip.
696
+ *
697
+ * @type {HTMLElement}
698
+ */
699
+ get timelineElement(): HTMLElement;
700
+ /**
701
+ * The frame shown below the charts: the one picked, or the newest when none is.
702
+ *
703
+ * @type {number}
704
+ */
705
+ get shown(): number;
706
+ /**
707
+ * Whether the frame shown follows the newest one.
708
+ *
709
+ * @type {boolean}
710
+ */
711
+ get following(): boolean;
712
+ /**
713
+ * Shows a frame, which stops following the newest one.
714
+ *
715
+ * @param {number} seq - The frame, clamped to the frames kept.
716
+ */
717
+ pick(seq: number): void;
718
+ /**
719
+ * Follows the newest frame again.
720
+ */
721
+ follow(): void;
722
+ /**
723
+ * Moves the frame shown.
724
+ *
725
+ * @param {number} delta - How many frames to move by, back when negative.
726
+ */
727
+ step(delta: number): void;
728
+ /**
729
+ * Forgets the frames selected together, the zoom and the frame picked, as after a clear.
730
+ */
731
+ reset(): void;
732
+ /**
733
+ * Unselects the frames selected together.
734
+ */
735
+ clearRange(): void;
736
+ /**
737
+ * Pins a script type to the Scripts chart, giving it a band of its own whatever its time, or
738
+ * unpins it.
739
+ *
740
+ * @param {string} name - The name of the script type.
741
+ */
742
+ togglePin(name: string): void;
743
+ /**
744
+ * Asks for everything to be redrawn on the next {@link update}.
745
+ */
746
+ invalidate(): void;
747
+ /**
748
+ * Redraws what changed: the charts and the frame timeline at most every
749
+ * {@link REDRAW_INTERVAL} while frames are being recorded, and right away for a change of
750
+ * view; the overlay alone as the pointer moves.
751
+ *
752
+ * @param {number} now - The current `performance.now()` time.
753
+ * @returns {boolean} Whether it drew the charts or the timeline, the costly part, so other work
754
+ * of the panel can wait for another frame.
755
+ */
756
+ update(now: number): boolean;
757
+ /**
758
+ * Draws the charts, the frame timeline and the overlay now.
759
+ */
760
+ draw(): void;
761
+ /**
762
+ * @param {HTMLCanvasElement} canvas - A canvas.
763
+ * @param {HTMLElement} box - The element it fills.
764
+ * @param {number} [height] - Its height, when it is taller than the element. Defaults to the
765
+ * height of the element.
766
+ * @returns {{ ctx: CanvasRenderingContext2D, width: number, height: number }|null} Its context,
767
+ * scaled to CSS pixels, and its size in them, or null where it cannot be drawn.
768
+ * @private
769
+ */
770
+ private _prepare;
771
+ /**
772
+ * @param {HTMLElement} box - The charts or the timeline.
773
+ * @returns {{ width: number, height: number }} Its size, as the resize observer reported it, or
774
+ * from the page where there is no observer.
775
+ * @private
776
+ */
777
+ private _sizeOf;
778
+ /**
779
+ * @returns {{ from: number, span: number }} The time in view on the time axis, in
780
+ * milliseconds: where it starts and how long it is.
781
+ * @private
782
+ */
783
+ private _span;
784
+ /**
785
+ * @param {number} x - A position across the charts right of the names, in CSS pixels.
786
+ * @returns {number} The entry drawn there, the one before it in a gap, which may not be kept.
787
+ * @private
788
+ */
789
+ private _seqAt;
790
+ /**
791
+ * @param {number} seq - A kept entry.
792
+ * @returns {number} Where it was drawn across the canvas, in CSS pixels.
793
+ * @private
794
+ */
795
+ private _xOf;
796
+ /**
797
+ * @param {number} seq - A kept entry.
798
+ * @returns {number} How wide it was drawn, in CSS pixels.
799
+ * @private
800
+ */
801
+ private _wOf;
802
+ /**
803
+ * Scrolls a zoomed-in view to an entry, if it is out of view.
804
+ *
805
+ * @param {number} seq - The entry.
806
+ * @private
807
+ */
808
+ private _reveal;
809
+ /**
810
+ * @param {string} key - What the array is for.
811
+ * @param {number} length - Its length.
812
+ * @returns {Int32Array} An array kept for that, reused while its length stays the same, so a
813
+ * redraw makes no garbage. Its content is left from the last use.
814
+ * @private
815
+ */
816
+ private _ints;
817
+ /**
818
+ * @param {string} key - What the array is for.
819
+ * @param {number} length - Its length.
820
+ * @returns {Float64Array} An array kept for that, as {@link _ints} keeps one.
821
+ * @private
822
+ */
823
+ private _floats;
824
+ /**
825
+ * @param {PerfChartDef} chart - A chart.
826
+ * @returns {PerfShape} The
827
+ * channel it is scaled to, the parts it stacks and the lines across them: without the
828
+ * inspector's time in the CPU chart while that is left out, and the total alone where the
829
+ * engine does not break it down. Reduced when the inspector's time is left out.
830
+ * @private
831
+ */
832
+ private _shape;
833
+ /** @private */
834
+ private _drawCharts;
835
+ /**
836
+ * What loaded over a time of the axis: the milestones, the assets and the requests of the kept
837
+ * entries, and the assets loading now, each with where it starts and ends on the axis.
838
+ *
839
+ * @param {number} from - Where the time starts on the axis.
840
+ * @param {number} to - Where it ends.
841
+ * @returns {Record<string, { p0: number, p1: number, load: PerfLoad }[]>} The items by row.
842
+ * @private
843
+ */
844
+ private _loadingItems;
845
+ /**
846
+ * Draws the Loading section: a row each of milestones, assets packed into lanes and the
847
+ * requests in flight, on the time axis of the charts.
848
+ *
849
+ * @param {CanvasRenderingContext2D} ctx - The context.
850
+ * @param {number} top - The top of the section's rows.
851
+ * @param {number} plot - The width of the plot.
852
+ * @param {number} from - Where the time in view starts on the axis.
853
+ * @param {number} span - How long it is.
854
+ * @private
855
+ */
856
+ private _drawLoading;
857
+ /**
858
+ * @param {string} key - A row of the Loading section.
859
+ * @param {number} x - Where the pointer is across the plot, negative over the names.
860
+ * @returns {PerfHoverLine[]} What the row has under the pointer, the longest first, or what the
861
+ * row shows over its name.
862
+ * @private
863
+ */
864
+ private _loadingLines;
865
+ /**
866
+ * Marks the start of the app over the charts, which have no figures for it, and the long
867
+ * times between entries folded away, with how long each was.
868
+ *
869
+ * @param {CanvasRenderingContext2D} ctx - The context.
870
+ * @param {number} chartsBottom - The bottom of the charts.
871
+ * @param {number} plot - The width of the plot.
872
+ * @private
873
+ */
874
+ private _drawStartupAndGaps;
875
+ /**
876
+ * Sizes the thumb of the scrollbar to the time in view, out of all that is kept. It fills the
877
+ * bar, dimmed, while the whole capture is in view.
878
+ *
879
+ * @private
880
+ */
881
+ private _updateScrollbar;
882
+ /**
883
+ * Moves a zoomed-in view so it starts at a time, following the newest frames when it reaches
884
+ * them.
885
+ *
886
+ * @param {number} from - Where on the time axis the view starts.
887
+ * @private
888
+ */
889
+ private _scrollTo;
890
+ /**
891
+ * @returns {PerfScriptLegend} The script types the Scripts chart gives a band of their own,
892
+ * ranked over the frames selected together, or the whole capture.
893
+ * @private
894
+ */
895
+ private _scriptLegend;
896
+ /**
897
+ * The Scripts chart ranks its types over the frames selected together, so a new selection can
898
+ * change its bands: redraws it when it does.
899
+ *
900
+ * @private
901
+ */
902
+ private _checkScriptLegend;
903
+ /**
904
+ * @returns {{ legend: PerfScriptLegend, lines: PerfScriptLine[], controls: ('more'|'fewer')[] }}
905
+ * What the Scripts chart stacks: the script types with a band of their own and the others
906
+ * together; and the rows of its list that show more types or fewer.
907
+ * @private
908
+ */
909
+ private _scriptList;
910
+ /**
911
+ * @returns {string} Why the Scripts chart has nothing to draw.
912
+ * @private
913
+ */
914
+ private _scriptsEmpty;
915
+ /**
916
+ * Draws the time of each script type stacked, beside the list of them, each with a box ticked
917
+ * while it shows, so hiding the large ones lets the small ones fill the chart.
918
+ *
919
+ * @param {CanvasRenderingContext2D} ctx - The context.
920
+ * @param {{ legend: PerfScriptLegend, lines: PerfScriptLine[], controls: ('more'|'fewer')[] }} list - What
921
+ * it stacks, and the rows of its list that show more types or fewer.
922
+ * @param {number} top - The top of the chart.
923
+ * @param {number} width - The width of the canvas.
924
+ * @param {number} plot - The width of the plot.
925
+ * @param {Int32Array} lo - The first frame of each column.
926
+ * @param {Int32Array} hi - One past the last frame of each column.
927
+ * @param {boolean} wide - Whether each bar is a frame of its own.
928
+ * @param {number} visibleFrom - The first frame in view.
929
+ * @param {number} visibleTo - One past the last frame in view.
930
+ * @param {number} bars - How many bars there are.
931
+ * @param {Int32Array} barX - The left edge of each bar.
932
+ * @param {Int32Array} barW - The width of each bar.
933
+ * @returns {PerfLineChart|null} What it drew, for the pointer, or null for nothing.
934
+ * @private
935
+ */
936
+ private _drawScriptChart;
937
+ /**
938
+ * @returns {PerfLine[]} The lines of the Memory chart, the JavaScript heap where the browser
939
+ * reports it.
940
+ * @private
941
+ */
942
+ private _memoryList;
943
+ /**
944
+ * Draws a chart of lines sharing a scale, beside the list of them, each with a box ticked
945
+ * while its line shows. The scale runs from the smallest to the largest value of the lines
946
+ * shown in view, spread to a least range so a level that barely changes is flat.
947
+ *
948
+ * @param {CanvasRenderingContext2D} ctx - The context.
949
+ * @param {string} section - The section the chart is in, which the hidden lines are kept
950
+ * under.
951
+ * @param {PerfLine[]} lines - Its lines.
952
+ * @param {(value: number) => string} format - Formats their values.
953
+ * @param {(max: number) => number} least - The least range for a largest value.
954
+ * @param {number} top - The top of the chart.
955
+ * @param {number} rowHeight - The height of a line of the list; the chart is as tall as the
956
+ * list.
957
+ * @param {number} width - The width of the canvas.
958
+ * @param {number} plot - The width of the plot.
959
+ * @param {Int32Array} lo - The first frame of each column.
960
+ * @param {Int32Array} hi - One past the last frame of each column.
961
+ * @param {boolean} wide - Whether each bar is a frame of its own.
962
+ * @param {number} visibleFrom - The first frame in view.
963
+ * @param {number} visibleTo - One past the last frame in view.
964
+ * @param {number} bars - How many bars there are.
965
+ * @param {Int32Array} barX - The left edge of each bar.
966
+ * @param {Int32Array} barW - The width of each bar.
967
+ * @param {boolean} [own] - Whether each line has a scale of its own, from its smallest to its
968
+ * largest value in view, as lines of different units do. The chart then reads no levels.
969
+ * @returns {PerfLineChart} What it drew, for the pointer.
970
+ * @private
971
+ */
972
+ private _drawLineChart;
973
+ /**
974
+ * @returns {{ key: string, name: string, color: string }[]} The resources the device has.
975
+ * @private
976
+ */
977
+ private _resourceList;
978
+ /**
979
+ * @returns {number[]} The kinds of event the Events section has a row for, by their index into
980
+ * {@link EVENT_KINDS}: the bakes of lightmaps only for an app with a lightmapper.
981
+ * @private
982
+ */
983
+ private _eventKinds;
984
+ /**
985
+ * @returns {PerfLine[]} The lines of the Counters chart, one for each counter of
986
+ * `app.stats.user` the app has set, in the order it first set them.
987
+ * @private
988
+ */
989
+ private _counterList;
990
+ /**
991
+ * Draws the title of a section under the charts, which collapses or expands it when clicked.
992
+ *
993
+ * @param {CanvasRenderingContext2D} ctx - The context.
994
+ * @param {string} key - The section.
995
+ * @param {string} title - Its title.
996
+ * @param {number} top - Where it goes down the canvas.
997
+ * @param {boolean} open - Whether the section is expanded.
998
+ * @private
999
+ */
1000
+ private _sectionTitle;
1001
+ /**
1002
+ * Draws the marks over the charts: the frames selected together, the frame hovered and the
1003
+ * frame shown, where the charts last drew them.
1004
+ *
1005
+ * @private
1006
+ */
1007
+ private _drawOverlay;
1008
+ /**
1009
+ * Draws the divider between the names and the plot, brighter while under the pointer.
1010
+ *
1011
+ * @param {CanvasRenderingContext2D} ctx - The context.
1012
+ * @param {number} height - How far down it goes.
1013
+ * @private
1014
+ */
1015
+ private _drawDivider;
1016
+ /**
1017
+ * Draws a line of text centered across the plot, cut short with an ellipsis where the plot is
1018
+ * too narrow for it.
1019
+ *
1020
+ * @param {CanvasRenderingContext2D} ctx - The context.
1021
+ * @param {string} text - The text.
1022
+ * @param {string} color - Its color.
1023
+ * @param {number} plot - The width of the plot.
1024
+ * @param {number} y - Its top.
1025
+ * @private
1026
+ */
1027
+ private _message;
1028
+ /**
1029
+ * Draws a name in the gutter left of the plot, cut to what fits before the plot, as the width
1030
+ * of the font differs between systems.
1031
+ *
1032
+ * @param {CanvasRenderingContext2D} ctx - The context, with the font set.
1033
+ * @param {string} text - The name.
1034
+ * @param {number} x - Where it starts.
1035
+ * @param {number} y - Its top.
1036
+ * @private
1037
+ */
1038
+ private _gutterText;
1039
+ /**
1040
+ * What the timeline shows: the frame shown, or with frames selected together their average
1041
+ * frame, each phase at its average start for its average time per frame, and each GPU pass for
1042
+ * its average time.
1043
+ *
1044
+ * @returns {{ title: string, interval: number, frames: number, bars: PerfTimeBar[] }|null} The
1045
+ * title, the frame interval, how many frames it covers and the bars, in milliseconds from the
1046
+ * start of the frame. Null when there is nothing to show.
1047
+ * @private
1048
+ */
1049
+ private _timelineModel;
1050
+ /**
1051
+ * Adds what loaded during an entry to the bars of its timeline: the moments in it, and the
1052
+ * assets and the requests going on in it, each packed into the first lane free at its start,
1053
+ * cut to the entry.
1054
+ *
1055
+ * @param {number} seq - The entry.
1056
+ * @param {PerfTimeBar[]} bars - Receives the bars.
1057
+ * @private
1058
+ */
1059
+ private _loadBars;
1060
+ /**
1061
+ * Adds the GPU passes of the frames to the bars of the timeline. The GPU does not say when each
1062
+ * pass ran, only for how long, so they are back to back, each apart, its mean over the frames
1063
+ * that timed the GPU, in the order the passes first ran. The passes an effect runs go on a line
1064
+ * of their own under a bar of the effect, as in a flame chart; a pass of its own, or every pass
1065
+ * where the frame graph did not match, goes on the GPU line.
1066
+ *
1067
+ * @param {number} from - The first frame.
1068
+ * @param {number} to - The last frame, inclusive.
1069
+ * @param {PerfTimeBar[]} bars - Receives the bars.
1070
+ * @private
1071
+ */
1072
+ private _gpuBars;
1073
+ /**
1074
+ * @param {number} from - The first frame.
1075
+ * @param {number} to - The last frame, inclusive.
1076
+ * @param {number} column - Which method of the script types: 0 their update, 1 their
1077
+ * post-update.
1078
+ * @returns {PerfScriptType[]} Each script type with that method, with its time and its calls,
1079
+ * the mean over the frames that timed scripts, and where its first call came, the mean over
1080
+ * the frames it ran in.
1081
+ * @private
1082
+ */
1083
+ private _scriptTypes;
1084
+ /**
1085
+ * What the timeline shows, to copy: its title, how many frames it covers, the frame interval
1086
+ * and its bars by row. A GPU pass has no start, as the GPU does not say when it ran.
1087
+ *
1088
+ * @returns {object|null} The timeline, or null when there is nothing to show.
1089
+ */
1090
+ timelineJson(): object | null;
1091
+ /**
1092
+ * What a right click copies, by where it is: the name of a chart, the title of a section or a
1093
+ * line of a list copies that series; the plot copies the frame under the pointer, or the
1094
+ * frames selected together when it is among them; the timeline copies what it shows.
1095
+ *
1096
+ * @param {Node} target - What was right-clicked.
1097
+ * @param {MouseEvent} e - The click, for where it was.
1098
+ * @returns {{ kind: 'series'|'frame'|'range'|'timeline', key?: string, seq?: number }|null} What
1099
+ * to copy, or null for nothing.
1100
+ */
1101
+ copyAt(target: Node, e: MouseEvent): {
1102
+ kind: "series" | "frame" | "range" | "timeline";
1103
+ key?: string;
1104
+ seq?: number;
1105
+ } | null;
1106
+ /**
1107
+ * The frames a copy covers: those selected together, or every frame kept.
1108
+ *
1109
+ * @type {{ from: number, to: number }}
1110
+ */
1111
+ get copyRange(): {
1112
+ from: number;
1113
+ to: number;
1114
+ };
1115
+ /**
1116
+ * Moves a zoomed-in timeline so it starts at a time of the frame.
1117
+ *
1118
+ * @param {number} from - The first millisecond of the frame to view.
1119
+ * @private
1120
+ */
1121
+ private _scrollTimeTo;
1122
+ /**
1123
+ * Draws the frame shown, or the average frame of the frames selected together, along its own
1124
+ * time: the update and the render with their parts where the engine timed them, the GPU passes
1125
+ * back to back, and what happened meanwhile, each on a row named beside it. Zoomed in, only
1126
+ * part of the frame is drawn, across the whole width.
1127
+ *
1128
+ * @private
1129
+ */
1130
+ private _drawTimeline;
1131
+ /**
1132
+ * Draws the title of the timeline, which a click collapses or expands, with the length of the
1133
+ * frame.
1134
+ *
1135
+ * @param {CanvasRenderingContext2D} ctx - The context.
1136
+ * @param {{ title: string, interval: number }} model - What the timeline shows.
1137
+ * @param {boolean} open - Whether the timeline is expanded.
1138
+ * @private
1139
+ */
1140
+ private _drawTimelineTitle;
1141
+ /**
1142
+ * Zooms the timeline around the pointer, or pans it with Shift or a sideways scroll.
1143
+ *
1144
+ * @param {WheelEvent} e - The event.
1145
+ * @private
1146
+ */
1147
+ private _onTimelineWheel;
1148
+ /** @private */
1149
+ private _onTimelineDoubleClick;
1150
+ /**
1151
+ * @param {PointerEvent|MouseEvent} e - A pointer event on the charts.
1152
+ * @returns {{ x: number, y: number, row: PerfRow|null, column: number }} Where it is: across
1153
+ * the charts right of the names, down the canvas, the chart or row of events, and the column.
1154
+ * @private
1155
+ */
1156
+ private _locate;
1157
+ /**
1158
+ * @param {PointerEvent|MouseEvent} e - A pointer event on the charts.
1159
+ * @returns {number} The frame under it: the one its column shows in the chart it is over, or
1160
+ * the first of its frames with an event of the kind of the row it is over.
1161
+ * @private
1162
+ */
1163
+ private _pickAt;
1164
+ /**
1165
+ * @param {number} column - A column.
1166
+ * @param {number} kind - The index of a kind of event.
1167
+ * @returns {number[]} The frames of the column with an event of that kind.
1168
+ * @private
1169
+ */
1170
+ private _eventFrames;
1171
+ /**
1172
+ * @param {PointerEvent} e - A pointer event on the charts.
1173
+ * @returns {PerfHoverLine[]} What is under it: the figures of the frame a chart shows there,
1174
+ * each part with the color it is drawn in, the events of a row, or what a name beside the
1175
+ * charts stands for. Empty for nothing.
1176
+ * @private
1177
+ */
1178
+ private _hoverLines;
1179
+ /**
1180
+ * Shows one line of a line chart alone, hiding the others, or shows them all again when it
1181
+ * already is.
1182
+ *
1183
+ * @param {string} section - The section of the chart.
1184
+ * @param {number} index - The line.
1185
+ * @private
1186
+ */
1187
+ private _solo;
1188
+ /**
1189
+ * @param {string} section - The section of a line chart.
1190
+ * @param {number} index - One of its lines.
1191
+ * @returns {string|null} The key the line is hidden under, or null for one that cannot show.
1192
+ * @private
1193
+ */
1194
+ private _lineToggle;
1195
+ /**
1196
+ * @param {string} section - The section of the line chart under the pointer.
1197
+ * @param {number} index - The line the pointer is beside.
1198
+ * @param {number} x - Where the pointer is across the plot, negative over the list.
1199
+ * @param {number} column - The column under it.
1200
+ * @param {'more'|'fewer'} [control] - The row of the Scripts list showing more types or fewer
1201
+ * the pointer is beside.
1202
+ * @returns {PerfHoverLine[]} Over the list, what clicking does; over the chart, every line of
1203
+ * the frame there, largest first, with its change since the frame before, and for the other
1204
+ * scripts the types among them.
1205
+ * @private
1206
+ */
1207
+ private _lineChartLines;
1208
+ /**
1209
+ * @param {number} seq - A kept frame.
1210
+ * @param {PerfScriptLegend} legend - The script types with a band of their own.
1211
+ * @returns {PerfHoverLine[]} What the other scripts are made of in the frame: the longest of
1212
+ * their types, how many more there were, and the calls of those that took too little to time.
1213
+ * @private
1214
+ */
1215
+ private _otherScriptLines;
1216
+ /**
1217
+ * Shows what is under the pointer in a box beside it, or hides the box. The lines are rebuilt
1218
+ * only when they change, as the pointer moves within a column.
1219
+ *
1220
+ * @param {PointerEvent|null} e - A pointer event on the charts, or null to hide the box.
1221
+ * @private
1222
+ */
1223
+ private _showHover;
1224
+ /**
1225
+ * Fills a hover box with lines and places it beside the pointer, or hides it when there are
1226
+ * none. The lines are rebuilt only when they change.
1227
+ *
1228
+ * @param {HTMLElement} box - The hover box.
1229
+ * @param {HTMLElement} container - The element it is placed in.
1230
+ * @param {PerfHoverLine[]} lines - What it says.
1231
+ * @param {PointerEvent|null} e - The pointer event it follows.
1232
+ * @param {boolean} above - Whether it goes above the pointer rather than below. It goes above
1233
+ * anyway when there is no room below.
1234
+ * @private
1235
+ */
1236
+ private _renderHover;
1237
+ /**
1238
+ * @param {PointerEvent} e - A pointer event on the frame timeline.
1239
+ * @returns {PerfHoverLine[]} Everything on the row under it, largest first, with the bar under
1240
+ * it marked: the small bars of a row are hard to point at one by one.
1241
+ * @private
1242
+ */
1243
+ private _timelineLines;
1244
+ /**
1245
+ * @param {PointerEvent} e - The event.
1246
+ * @private
1247
+ */
1248
+ private _onPointerDown;
1249
+ /**
1250
+ * @param {PointerEvent} e - The event.
1251
+ * @private
1252
+ */
1253
+ private _onPointerMove;
1254
+ /**
1255
+ * @param {PointerEvent} e - A pointer event on the charts.
1256
+ * @returns {{ y: number, value: number, format: (value: number) => string }|null} The level
1257
+ * under it in the chart it is over, a whole pixel down the canvas, or null outside one.
1258
+ * @private
1259
+ */
1260
+ private _levelAt;
1261
+ /**
1262
+ * @param {PointerEvent} e - The event.
1263
+ * @private
1264
+ */
1265
+ private _onPointerUp;
1266
+ /**
1267
+ * A menu opens over the charts: ends any press, letting go of the pointer, so the menu gets it,
1268
+ * and hides the hover box, which the menu takes the place of.
1269
+ *
1270
+ * @private
1271
+ */
1272
+ private _onContextMenu;
1273
+ /** @private */
1274
+ private _onPointerLeave;
1275
+ /**
1276
+ * Shows that a drag pans: a hand over the plot while Shift is held and the charts are zoomed
1277
+ * in, closed while it pans.
1278
+ *
1279
+ * @param {boolean} shift - Whether Shift is held.
1280
+ * @private
1281
+ */
1282
+ private _updateCursor;
1283
+ /**
1284
+ * Marks the divider beside the names as under the pointer or being dragged, or not.
1285
+ *
1286
+ * @param {boolean} hot - Whether it is.
1287
+ * @private
1288
+ */
1289
+ private _setDividerHot;
1290
+ /**
1291
+ * Follows the Shift key of the window the charts are in while the pointer is over them, so the
1292
+ * cursor changes as Shift is pressed or let go without the pointer moving.
1293
+ *
1294
+ * @param {boolean} on - Whether to follow it.
1295
+ * @private
1296
+ */
1297
+ private _watchKeys;
1298
+ /**
1299
+ * @param {KeyboardEvent} e - The event.
1300
+ * @private
1301
+ */
1302
+ private _onKey;
1303
+ /**
1304
+ * Zooms around the pointer, or pans with Shift or a sideways scroll.
1305
+ *
1306
+ * @param {WheelEvent} e - The event.
1307
+ * @private
1308
+ */
1309
+ private _onWheel;
1310
+ /** @private */
1311
+ private _onDoubleClick;
1312
+ /**
1313
+ * @param {PointerEvent} e - The event.
1314
+ * @private
1315
+ */
1316
+ private _onTimelineMove;
1317
+ /**
1318
+ * @param {MouseEvent} e - A pointer event on the timeline.
1319
+ * @returns {boolean} Whether it is on the title of the timeline.
1320
+ * @private
1321
+ */
1322
+ private _onTimelineTitle;
1323
+ /**
1324
+ * A press on the divider beside the names drags it, and one with Shift while zoomed in pans.
1325
+ *
1326
+ * @param {PointerEvent} e - The event.
1327
+ * @private
1328
+ */
1329
+ private _onTimelineDown;
1330
+ /**
1331
+ * @param {PointerEvent} e - The event.
1332
+ * @private
1333
+ */
1334
+ private _onTimelineUp;
1335
+ /**
1336
+ * A script type clicked on the timeline shows on the Scripts tab.
1337
+ *
1338
+ * @param {MouseEvent} e - The event.
1339
+ * @private
1340
+ */
1341
+ private _onTimelineClick;
1342
+ /**
1343
+ * @param {MouseEvent} e - A pointer event on the frame timeline.
1344
+ * @returns {{ lane: { key: string, title: string }, bars: PerfBar[], x: number, hovered: PerfBar|null }|null}
1345
+ * The row under it, its bars, where across the timeline it is and the bar under it, or null
1346
+ * where there is no row with bars.
1347
+ * @private
1348
+ */
1349
+ private _timelineHit;
1350
+ /** @private */
1351
+ private _onTimelineLeave;
1352
+ }
1353
+ /**
1354
+ * A horizontal scrollbar: a track with a thumb sized to the part of something in view. The thumb
1355
+ * is dragged to pan, the track beside it clicked to page and the bar scrolled over to pan. It only
1356
+ * says how the user moves it: its owner moves the view, and sets the thumb.
1357
+ *
1358
+ * @ignore
1359
+ */
1360
+ declare class PerfScrollbar {
1361
+ /**
1362
+ * @param {Document} doc - The document to make it in.
1363
+ * @param {object} handlers - What the user does with it.
1364
+ * @param {(start: number) => void} handlers.onDrag - The thumb was dragged to start at this
1365
+ * fraction of the bar.
1366
+ * @param {(direction: number) => void} handlers.onPage - The track was clicked: -1 left of the
1367
+ * thumb, 1 right of it.
1368
+ * @param {(delta: number) => void} handlers.onWheel - The bar was scrolled over, by this many
1369
+ * pixels, sideways or down.
1370
+ */
1371
+ constructor(doc: Document, { onDrag, onPage, onWheel }: {
1372
+ onDrag: (start: number) => void;
1373
+ onPage: (direction: number) => void;
1374
+ onWheel: (delta: number) => void;
1375
+ });
1376
+ /**
1377
+ * The bar, to place.
1378
+ *
1379
+ * @type {HTMLElement}
1380
+ */
1381
+ el: HTMLElement;
1382
+ /**
1383
+ * @type {HTMLElement}
1384
+ * @private
1385
+ */
1386
+ private _thumb;
1387
+ /** @private */
1388
+ private _active;
1389
+ /** @private */
1390
+ private _start;
1391
+ /**
1392
+ * The thumb being dragged: where the pointer went down and where the thumb started then.
1393
+ *
1394
+ * @type {{ x: number, start: number }|null}
1395
+ * @private
1396
+ */
1397
+ private _drag;
1398
+ /**
1399
+ * Sizes the thumb. It fills the bar, dimmed, while everything is in view.
1400
+ *
1401
+ * @param {number} start - Where the view starts, as a fraction of the whole.
1402
+ * @param {number} size - How much of the whole is in view.
1403
+ */
1404
+ set(start: number, size: number): void;
1405
+ }
1406
+ import type { PerfCapture } from './perf-capture.js';
1407
+ export {};