@playcanvas/inspector 0.2.0 → 0.3.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.
@@ -102,7 +102,7 @@ export type InspectorPhysicsDrawOptions = {
102
102
  range?: number;
103
103
  };
104
104
  /**
105
- * An in-page inspector for a running application. It docks a panel over the canvas with four
105
+ * An in-page inspector for a running application. It docks a panel over the canvas with twelve
106
106
  * tabs above a live property view of whatever is selected:
107
107
  *
108
108
  * - Hierarchy: the entity tree. The property view shows the node's transform, every component it
@@ -111,9 +111,12 @@ export type InspectorPhysicsDrawOptions = {
111
111
  * - Cameras: every camera in render order, with its target, viewport, layers and render mode. The
112
112
  * render mode of a camera can be switched to a debug view of the material inputs, the whole scene
113
113
  * drawn in wireframe, and any camera flown.
114
+ * - Assets: every asset in the registry with its file, load state and the components using it.
115
+ * Asset references on a component link here, and a texture names the asset it came from.
114
116
  * - Frame graph: the render passes of the last frame in execution order, as the render pass trace
115
117
  * prints them, with the layer steps of forward passes, the light of shadow passes and optional
116
- * GPU timings. Render target cells link to the next tab.
118
+ * GPU timings. Render target cells link to the next tab. With the debug engine, the debug frame
119
+ * draws a forward pass only up to a chosen draw, stepped one draw at a time with the arrow keys.
117
120
  * - Render targets: every render target on the device including the backbuffer, with its
118
121
  * attachments and the passes that rendered into it this frame, linking back to the frame graph.
119
122
  * The selected target's attachment can be previewed live in a corner of the viewport.
@@ -128,20 +131,21 @@ export type InspectorPhysicsDrawOptions = {
128
131
  * - Scripts: every script class the script registry holds or an entity uses, with the entities using
129
132
  * it, its declared attributes and its source as the browser keeps it. The script sections of an
130
133
  * entity link here.
131
- * - Memory: video memory by kind of resource, and every buffer on the device, largest first, named
132
- * after the mesh, material or asset it was found to belong to. Buffer values elsewhere link here.
134
+ * - Memory: video memory by kind of resource, each kind a group headed by its count and size that
135
+ * opens to list its buffers largest first, named after the mesh, material or asset each was found
136
+ * to belong to. Buffer values elsewhere link here.
133
137
  * - Shaders: every shader on the device with its language, state and vertex attributes. The
134
138
  * compiled variants listed on a material link here.
135
- * - Assets: every asset in the registry with its file, load state and the components using it.
136
- * Asset references on a component link here, and a texture names the asset it came from.
137
139
  * - Physics: the rigid bodies and joints of the scene, with the physics world drawn over the scene
138
140
  * through the engine's debug drawer when Ammo is loaded.
139
141
  *
140
142
  * The app can be paused and stepped a frame at a time, and the panel can be popped out into its own
141
- * window to leave the canvas unobscured.
143
+ * window to leave the canvas unobscured. In the view, an entity can be picked to select it, and the
144
+ * camera flown, or orbited around the selected entity, without moving the app's own camera.
142
145
  *
143
- * The view is read-only, with one exception: the checkbox on each hierarchy row flips the node's
144
- * enabled flag.
146
+ * The inspector is read-only, apart from the checkbox on each hierarchy row, which flips the node's
147
+ * enabled flag, pausing and stepping the app, and view-only overrides: render modes, wireframe and
148
+ * a flown or orbited camera, which it removes when it closes.
145
149
  *
146
150
  * ```javascript
147
151
  * const inspector = new Inspector(app, { dock: 'left' });
@@ -375,6 +379,34 @@ export class Inspector {
375
379
  * @private
376
380
  */
377
381
  private _bodyList;
382
+ /**
383
+ * The gizmo that moves, rotates or scales the selected entity, while one of its buttons is on.
384
+ *
385
+ * @type {TransformTool|null}
386
+ * @private
387
+ */
388
+ private _transformTool;
389
+ /**
390
+ * The buttons of the gizmos, by what each does.
391
+ *
392
+ * @type {Record<TransformMode, HTMLButtonElement>}
393
+ * @private
394
+ */
395
+ private _transformBtns;
396
+ /**
397
+ * The menu opened with a right click, which copies what it was opened on.
398
+ *
399
+ * @type {ContextMenu|null}
400
+ * @private
401
+ */
402
+ private _menu;
403
+ /**
404
+ * How many links the menu's deep copy follows.
405
+ *
406
+ * @type {number}
407
+ * @private
408
+ */
409
+ private _copyDepth;
378
410
  /**
379
411
  * Draws the selected render target's texture over the canvas, straight from the GPU.
380
412
  *
@@ -604,16 +636,6 @@ export class Inspector {
604
636
  * @private
605
637
  */
606
638
  private _instancePages;
607
- /**
608
- * @type {HTMLSelectElement}
609
- * @private
610
- */
611
- private _bufferKind;
612
- /**
613
- * @type {HTMLElement}
614
- * @private
615
- */
616
- private _memoryNote;
617
639
  /**
618
640
  * Model builder for the property view when a buffer is selected.
619
641
  *
@@ -1122,6 +1144,81 @@ export class Inspector {
1122
1144
  * @private
1123
1145
  */
1124
1146
  private _applyFilter;
1147
+ /**
1148
+ * @returns {Record<string, ListView>} The list of each tab, all but the hierarchy, by tab.
1149
+ * @private
1150
+ */
1151
+ private _tabLists;
1152
+ /**
1153
+ * @returns {ListView[]} The lists of the tabs, all but the hierarchy.
1154
+ * @private
1155
+ */
1156
+ private _lists;
1157
+ /**
1158
+ * Opens the copy menu on what was right-clicked. Text fields keep the browser's own menu, to
1159
+ * paste into them.
1160
+ *
1161
+ * @param {MouseEvent} e - The event.
1162
+ * @private
1163
+ */
1164
+ private _onContextMenu;
1165
+ /**
1166
+ * What a right click copies: a row or section of the property view, or anywhere else in it
1167
+ * the subject. A row of a list or of the hierarchy is selected first, the way a click selects
1168
+ * it, and the subject it shows is copied; the header of a group copies the group, and a row
1169
+ * that selects nothing its figures. A tab is opened first, the way a click opens it, and
1170
+ * everything it lists is copied.
1171
+ *
1172
+ * @param {Node} target - What was right-clicked.
1173
+ * @returns {CopyTarget|null} What to copy, or null for a part of the panel nothing is copied
1174
+ * from, such as the toolbar.
1175
+ * @private
1176
+ */
1177
+ private _copyTargetAt;
1178
+ /**
1179
+ * @param {string} tab - A tab.
1180
+ * @returns {CopyTarget|null} A copy of everything the tab lists: the hierarchy from its root,
1181
+ * or every row of the tab's list, whatever its filter shows.
1182
+ * @private
1183
+ */
1184
+ private _tabCopyTarget;
1185
+ /**
1186
+ * @param {CopyTarget} copy - What the menu copies.
1187
+ * @returns {MenuItem[]} The entries of the menu: on its own, a
1188
+ * number of links deep, and every link there is.
1189
+ * @private
1190
+ */
1191
+ private _copyItems;
1192
+ /**
1193
+ * @param {number} depth - How many links the deep copy follows.
1194
+ * @private
1195
+ */
1196
+ private _setCopyDepth;
1197
+ /**
1198
+ * Copies to the clipboard as JSON, and notes how much was copied.
1199
+ *
1200
+ * @param {CopyTarget} copy - What to copy.
1201
+ * @param {number} depth - How many links to follow, see {@link CopyOptions#depth}.
1202
+ * @private
1203
+ */
1204
+ private _copy;
1205
+ /**
1206
+ * @returns {Set<object>} The app's own objects, which a copy never follows, as through them it
1207
+ * would reach everything else.
1208
+ * @private
1209
+ */
1210
+ private _opaqueObjects;
1211
+ /**
1212
+ * The model a copy follows a link into: what the tab the link opens on shows, see
1213
+ * {@link Inspector#_selectAny}, without the lists of what uses the object.
1214
+ *
1215
+ * @param {object} obj - An object reached through a link.
1216
+ * @param {PassModelContext & { app: AppBase, backlinks: boolean }} ctx - What the model
1217
+ * builders need besides their subject.
1218
+ * @returns {PropertySection[]|PropertyRow[]|null} The model, or null for an object no tab shows.
1219
+ * @private
1220
+ */
1221
+ private _copyModel;
1125
1222
  /**
1126
1223
  * Reveals a linked object in the tab that lists it: nodes in the hierarchy, passes in the frame
1127
1224
  * graph, render targets in their list.
@@ -1218,11 +1315,13 @@ export class Inspector {
1218
1315
  /** @private */
1219
1316
  private _stopFly;
1220
1317
  /**
1221
- * Orbit needs a node to orbit around, so its button is off until one is selected.
1318
+ * Pick, Fly and Orbit take the view from the app, which a gizmo needs to be used in, so their
1319
+ * buttons are off while one is on. Orbit also needs a node to orbit around, so its button is off
1320
+ * until one is selected.
1222
1321
  *
1223
1322
  * @private
1224
1323
  */
1225
- private _applyOrbitState;
1324
+ private _applyViewToolState;
1226
1325
  /**
1227
1326
  * Takes the pointer on the canvas for a mode, and Esc to end it.
1228
1327
  *
@@ -1278,6 +1377,27 @@ export class Inspector {
1278
1377
  * @private
1279
1378
  */
1280
1379
  private _updateModeStatus;
1380
+ /**
1381
+ * Turns a gizmo on, in place of the one that is on, or turns it off. The gizmo is drawn and
1382
+ * used in the view of the first camera drawing to the screen, which Pick, Fly and Orbit would
1383
+ * take from the app, so they stop and stay off while it is on.
1384
+ *
1385
+ * @param {TransformMode|null} mode - What the gizmo does, or null to turn it off.
1386
+ * @private
1387
+ */
1388
+ private _setTransformMode;
1389
+ /**
1390
+ * @param {KeyboardEvent} e - A key pressed while a gizmo is on.
1391
+ * @private
1392
+ */
1393
+ private _onTransformKey;
1394
+ /**
1395
+ * Hands the pointer to the gizmo first, and keeps from everything else what it keeps.
1396
+ *
1397
+ * @param {Event} e - A pointer event anywhere in the window.
1398
+ * @private
1399
+ */
1400
+ private _onTransformPointer;
1281
1401
  /**
1282
1402
  * Outlines a node in the viewport for the current frame.
1283
1403
  *
@@ -7,9 +7,10 @@ export type ListRow = object;
7
7
  export type ListGuides = object;
8
8
  export type ListEntry = object;
9
9
  /**
10
- * A flat, selectable list of rows with cells. Rows are keyed and reconciled in place, so a list
11
- * rebuilt from scratch a couple of times a second keeps its selection and scroll position and only
12
- * touches the text that changed.
10
+ * A flat, selectable list of rows with cells, optionally in groups under headers that open and
11
+ * close them. Rows are keyed and reconciled in place, so a list rebuilt from scratch a couple of
12
+ * times a second keeps its selection, open groups and scroll position and only touches the text
13
+ * that changed.
13
14
  *
14
15
  * @ignore
15
16
  */
@@ -80,18 +81,37 @@ export class ListView {
80
81
  * @private
81
82
  */
82
83
  private _entries;
84
+ /**
85
+ * Whether each header the user opened or closed is open, by row key.
86
+ *
87
+ * @type {Map<string, boolean>}
88
+ * @private
89
+ */
90
+ private _open;
83
91
  /**
84
92
  * The number of rows before filtering.
85
93
  *
86
94
  * @type {number}
87
95
  */
88
96
  get rowCount(): number;
97
+ /**
98
+ * The rows, all of them, whatever the filter shows and whichever groups are open.
99
+ *
100
+ * @type {ListRow[]}
101
+ */
102
+ get rows(): ListRow[];
89
103
  /**
90
104
  * The item of the selected row, or null when nothing is selected or the row is gone.
91
105
  *
92
106
  * @type {*}
93
107
  */
94
108
  get selected(): any;
109
+ /**
110
+ * The selected row, or null when nothing is selected or the row is gone.
111
+ *
112
+ * @type {ListRow|null}
113
+ */
114
+ get selectedRow(): ListRow | null;
95
115
  /**
96
116
  * Replaces the rows and re-renders.
97
117
  *
@@ -111,10 +131,31 @@ export class ListView {
111
131
  * @returns {boolean} Whether a row was found.
112
132
  */
113
133
  selectItem(item: any): boolean;
134
+ /**
135
+ * @param {Node} node - An element, such as the target of a context menu event.
136
+ * @returns {ListRow|null} The row it is in, a header included, or null when it is in none.
137
+ */
138
+ rowAt(node: Node): ListRow | null;
139
+ /**
140
+ * @param {ListRow} row - A header row.
141
+ * @returns {boolean} Whether its group is open.
142
+ * @private
143
+ */
144
+ private _isOpen;
114
145
  /**
115
146
  * Synchronizes the DOM with the rows.
116
147
  */
117
148
  render(): void;
149
+ /**
150
+ * Decides which rows are shown. Without a filter, the rows of a closed group are hidden. With
151
+ * one, every matching row is shown whether its group is open or not, and a header is shown when
152
+ * any row of its group matches.
153
+ *
154
+ * @param {string} filter - The lower-cased filter, or an empty string for none.
155
+ * @returns {boolean[]} Whether each row is shown.
156
+ * @private
157
+ */
158
+ private _shownRows;
118
159
  /**
119
160
  * @param {ListEntry} entry - The row entry.
120
161
  * @param {ListCell[]} cells - The cells to show.
@@ -16,11 +16,13 @@ export type MaterialSources = {
16
16
  * properties, and what uses it, with each mesh instance opening in place.
17
17
  *
18
18
  * @param {Material} material - The material.
19
- * @param {{ app: AppBase }} ctx - The app, to find the assets and debug lines using the material.
19
+ * @param {{ app: AppBase, backlinks?: boolean }} ctx - The app, to find the assets and debug lines
20
+ * using the material, and whether to find them at all, which a copy has no use for.
20
21
  * @returns {PropertySection[]} The sections.
21
22
  */
22
23
  export function buildMaterialModel(material: Material, ctx: {
23
24
  app: AppBase;
25
+ backlinks?: boolean;
24
26
  }): PropertySection[];
25
27
  /**
26
28
  * One row per material found, the most used first, dimmed when no mesh instance uses it.
@@ -17,13 +17,6 @@ export type BufferOwner = {
17
17
  */
18
18
  target: GraphNode | Asset | Material | null;
19
19
  };
20
- /** What the list can be narrowed to, as selector options. */
21
- export const BUFFER_KINDS: string[][];
22
- /**
23
- * @param {Buffer} buffer - A buffer.
24
- * @returns {number} Its size in bytes.
25
- */
26
- export function bufferBytes(buffer: Buffer): number;
27
20
  /**
28
21
  * @param {*} buffer - A buffer.
29
22
  * @returns {'vertex'|'index'|'uniform'|'storage'|null} Its kind, or null for anything else.
@@ -42,55 +35,61 @@ export function bufferKind(buffer: any): "vertex" | "index" | "uniform" | "stora
42
35
  * @returns {Map<Buffer, BufferOwner[]>} The owners of each attributed buffer.
43
36
  */
44
37
  export function bufferOwners(app: AppBase): Map<Buffer, BufferOwner[]>;
45
- /**
46
- * One row per buffer, largest first, named after what uses it and dimmed when nothing was found.
47
- *
48
- * @param {GraphicsDevice} device - The device.
49
- * @param {Map<Buffer, BufferOwner[]>} owners - The owners of each buffer.
50
- * @param {string} kind - The kind to list, or 'all'.
51
- * @returns {ListRow[]} The rows.
52
- */
53
- export function bufferRows(device: GraphicsDevice, owners: Map<Buffer, BufferOwner[]>, kind: string): ListRow[];
54
38
  /**
55
39
  * Everything the property view shows for a buffer: its size and layout, what it was found to
56
40
  * belong to (linked), and every other public property.
57
41
  *
58
42
  * @param {Buffer} buffer - The buffer.
59
- * @param {{ app: AppBase }} ctx - The app, to find the buffer's owners.
43
+ * @param {{ app: AppBase, backlinks?: boolean }} ctx - The app, to find the buffer's owners, and
44
+ * whether to find them at all, which a copy has no use for.
60
45
  * @returns {PropertySection[]} The sections.
61
46
  */
62
47
  export function buildBufferModel(buffer: Buffer, ctx: {
63
48
  app: AppBase;
49
+ backlinks?: boolean;
64
50
  }): PropertySection[];
65
51
  /**
66
52
  * Every buffer the device tracks, largest first. Uniform buffers appear only when persistent, as
67
- * the rest are slices of the per-frame pool.
53
+ * the rest are slices of the per-draw pool.
68
54
  *
69
55
  * @param {GraphicsDevice} device - The device.
70
- * @param {string} [kind] - One of {@link BUFFER_KINDS}.
56
+ * @param {'all'|'vertex'|'index'|'uniform'|'storage'} [kind] - The kind to collect.
71
57
  * @returns {Buffer[]} The buffers.
72
58
  */
73
- export function collectBuffers(device: GraphicsDevice, kind?: string): Buffer[];
59
+ export function collectBuffers(device: GraphicsDevice, kind?: "all" | "vertex" | "index" | "uniform" | "storage"): Buffer[];
74
60
  /**
75
61
  * @param {Buffer} buffer - A buffer.
76
62
  * @returns {number} An id that stays the same for the lifetime of the buffer, since buffers carry
77
63
  * no name of their own.
78
64
  */
79
65
  export function idOf(buffer: Buffer): number;
66
+ export namespace KIND_NAMES {
67
+ let vertex: string;
68
+ let index: string;
69
+ let uniform: string;
70
+ let storage: string;
71
+ }
80
72
  /**
81
- * The totals shown above the list: video memory by kind of resource, the per-frame uniform pool,
82
- * and the counts of the device caches that grow with the variety of what is drawn.
73
+ * The rows of the memory list: one group per kind of resource, headed by its count and total size
74
+ * and closed until opened, holding its buffers largest first, named after what uses each. The
75
+ * device caches come last. Kinds with nothing on the device are left out.
83
76
  *
84
77
  * @param {GraphicsDevice} device - The device.
85
- * @returns {string} The totals, one line per group.
78
+ * @param {Map<Buffer, BufferOwner[]>} owners - The owners of each buffer.
79
+ * @returns {ListRow[]} The rows.
86
80
  */
87
- export function memorySummary(device: GraphicsDevice): string;
81
+ export function memoryRows(device: GraphicsDevice, owners: Map<Buffer, BufferOwner[]>): ListRow[];
88
82
  /**
89
83
  * @param {GraphNode|null} node - The node a mesh instance draws at.
90
84
  * @returns {string} Its name, after its parent's when it has one below the root: imported models
91
85
  * often give every mesh node the same name, and the parent tells them apart.
92
86
  */
93
87
  export function nodeLabel(node: GraphNode | null): string;
88
+ /**
89
+ * @param {GraphicsDevice} device - The device.
90
+ * @returns {number} The video memory the device counts for its textures and buffers.
91
+ */
92
+ export function videoMemory(device: GraphicsDevice): number;
94
93
  import { VertexBuffer } from 'playcanvas';
95
94
  import { IndexBuffer } from 'playcanvas';
96
95
  import { StorageBuffer } from 'playcanvas';
@@ -98,6 +97,6 @@ import type { GraphNode } from 'playcanvas';
98
97
  import type { Asset } from 'playcanvas';
99
98
  import type { Material } from 'playcanvas';
100
99
  import type { AppBase } from 'playcanvas';
100
+ import type { PropertySection } from './model.js';
101
101
  import type { GraphicsDevice } from 'playcanvas';
102
102
  import type { ListRow } from './list-view.js';
103
- import type { PropertySection } from './model.js';
@@ -47,11 +47,13 @@ export type MeshSurvey = {
47
47
  * format, and what uses it, with each mesh instance opening in place.
48
48
  *
49
49
  * @param {Mesh} mesh - The mesh.
50
- * @param {{ app: AppBase }} ctx - The app, to find the mesh's users.
50
+ * @param {{ app: AppBase, backlinks?: boolean }} ctx - The app, to find the mesh's users, and
51
+ * whether to find them at all, which a copy has no use for.
51
52
  * @returns {PropertySection[]} The sections.
52
53
  */
53
54
  export function buildMeshModel(mesh: Mesh, ctx: {
54
55
  app: AppBase;
56
+ backlinks?: boolean;
55
57
  }): PropertySection[];
56
58
  /**
57
59
  * @param {Mesh} mesh - A mesh.
package/types/model.d.ts CHANGED
@@ -6,6 +6,13 @@ export type PropertySection = object;
6
6
  * @returns {string} The attachments in the trace's notation, e.g. `[C×2][D][S]`.
7
7
  */
8
8
  export function attachmentsText(rt: RenderTarget, device: GraphicsDevice): string;
9
+ /**
10
+ * Marks a value as referring back to what holds or uses the subject, which copies leave out.
11
+ *
12
+ * @param {Described} value - The value.
13
+ * @returns {Described} The same value.
14
+ */
15
+ export function backlink(value: Described): Described;
9
16
  /**
10
17
  * @param {number} bytes - A byte count.
11
18
  * @returns {string} The count in the largest unit that keeps it above one, with two decimals.
@@ -37,6 +44,8 @@ export function formatName(format: number | undefined): string;
37
44
  * @property {string} title - The title.
38
45
  * @property {PropertyRow[]} rows - The rows.
39
46
  * @property {boolean} [collapsed] - Whether the section starts out collapsed.
47
+ * @property {boolean} [backlink] - Whether the section lists what uses the subject, which copies
48
+ * leave out, see {@link Described#backlink}.
40
49
  */
41
50
  /**
42
51
  * @param {string} key - The section key.
@@ -45,6 +54,12 @@ export function formatName(format: number | undefined): string;
45
54
  * @returns {PropertySection} An empty section.
46
55
  */
47
56
  export function makeSection(key: string, title: string, collapsed?: boolean): PropertySection;
57
+ /**
58
+ * @param {string} key - The section key.
59
+ * @param {string} title - The section title.
60
+ * @returns {PropertySection} An empty section listing what uses the subject, which copies leave out.
61
+ */
62
+ export function makeUsageSection(key: string, title: string): PropertySection;
48
63
  /**
49
64
  * Passes are named after their class unless given a name, so the class-family prefix carries no
50
65
  * information in a list of passes.
@@ -103,5 +118,5 @@ export function reflectRows(section: PropertySection, obj: object, stopPrototype
103
118
  export function renderTargetSummary(rt: RenderTarget | null, device: GraphicsDevice): string;
104
119
  import type { RenderTarget } from 'playcanvas';
105
120
  import type { GraphicsDevice } from 'playcanvas';
106
- import type { FramePass } from 'playcanvas';
107
121
  import type { Described } from './describe.js';
122
+ import type { FramePass } from 'playcanvas';
@@ -1,3 +1,11 @@
1
+ /**
2
+ * The sections a component shows under its entity, for a component reached on its own, such as
3
+ * through a link.
4
+ *
5
+ * @param {Component} component - The component.
6
+ * @returns {PropertySection[]} Its section, followed by one per script instance of a script component.
7
+ */
8
+ export function buildComponentModel(component: Component): PropertySection[];
1
9
  /**
2
10
  * Everything the property view shows for a node: identity, transform, one section per component
3
11
  * and one per script instance. A component's mesh instances open in place, each into its own
@@ -44,13 +52,21 @@ export function meshRows(mesh: Mesh): PropertyRow[];
44
52
  * @returns {PropertyRow[]} Its rows: whether it is enabled, then its attributes.
45
53
  */
46
54
  export function scriptInstanceRows(script: ScriptType | Script): PropertyRow[];
55
+ /**
56
+ * Moves the physics body of a node to where the node now is. A dynamic or kinematic body would
57
+ * otherwise put the node back where the body is on the next step of the simulation.
58
+ *
59
+ * @param {GraphNode} node - A node whose transform was changed.
60
+ */
61
+ export function syncBody(node: GraphNode): void;
47
62
  /**
48
63
  * @param {import('playcanvas').VertexFormat} format - A vertex format.
49
64
  * @returns {Described} The format, expanding into one row per element.
50
65
  */
51
66
  export function vertexFormatValue(format: import("playcanvas").VertexFormat): Described;
52
- import type { GraphNode } from 'playcanvas';
67
+ import { Component } from 'playcanvas';
53
68
  import type { PropertySection } from './model.js';
69
+ import type { GraphNode } from 'playcanvas';
54
70
  import type { LayerComposition } from 'playcanvas';
55
71
  import type { Described } from './describe.js';
56
72
  import type { Material } from 'playcanvas';
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Something a context menu of the panel can copy.
3
+ */
4
+ export type CopyTarget = object;
1
5
  export type RowElements = object;
2
6
  export type SectionElements = object;
3
7
  /**
@@ -98,6 +102,13 @@ export class PropertyView {
98
102
  * @private
99
103
  */
100
104
  private _emptyEl;
105
+ /**
106
+ * The rows and sections by the elements showing them, to find what a menu was opened on.
107
+ *
108
+ * @type {WeakMap<Element, RowElements|SectionElements>}
109
+ * @private
110
+ */
111
+ private _byElement;
101
112
  /**
102
113
  * The subject being shown.
103
114
  *
@@ -124,6 +135,20 @@ export class PropertyView {
124
135
  * @private
125
136
  */
126
137
  private _loadScroll;
138
+ /**
139
+ * What a copy made from an element of the panel copies: the row or the section title the
140
+ * element is in, and anywhere else the subject itself.
141
+ *
142
+ * @param {Node} node - The element, such as the target of a context menu event.
143
+ * @returns {CopyTarget|null} What to copy, or null when the element is not in the panel or
144
+ * nothing is shown.
145
+ */
146
+ copyTargetAt(node: Node): CopyTarget | null;
147
+ /**
148
+ * @returns {CopyTarget|null} A copy of the subject, rebuilt when it is made so it reads the
149
+ * live object, or null when nothing is shown.
150
+ */
151
+ subjectCopyTarget(): CopyTarget | null;
127
152
  /**
128
153
  * Re-reads every shown property and updates the text that changed.
129
154
  */
@@ -185,5 +210,21 @@ export class PropertyView {
185
210
  * @private
186
211
  */
187
212
  private _createRow;
213
+ /**
214
+ * Opens the text field of an editable value. Enter hands the text to the edit and closes the
215
+ * field once the edit takes it, or marks the text as not taken; leaving the field does the
216
+ * same, and gives up on text that is not taken; Escape closes it without a change.
217
+ *
218
+ * @param {RowElements} elements - The row.
219
+ * @private
220
+ */
221
+ private _startEdit;
222
+ /**
223
+ * Closes the text field of a value, which shows its text again on the next refresh.
224
+ *
225
+ * @param {RowElements} elements - The row.
226
+ * @private
227
+ */
228
+ private _endEdit;
188
229
  }
189
230
  import type { PropertySection } from './model.js';
@@ -24,11 +24,13 @@ export type ScriptEntry = {
24
24
  * using it, each instance opening in place into its attributes, and its source.
25
25
  *
26
26
  * @param {Function} cls - The script class.
27
- * @param {{ app: AppBase }} ctx - The app.
27
+ * @param {{ app: AppBase, backlinks?: boolean }} ctx - The app, and whether to list the entities
28
+ * using the class, which a copy has no use for.
28
29
  * @returns {PropertySection[]} The sections.
29
30
  */
30
31
  export function buildScriptModel(cls: Function, ctx: {
31
32
  app: AppBase;
33
+ backlinks?: boolean;
32
34
  }): PropertySection[];
33
35
  /**
34
36
  * @param {Function} cls - A class.