@peers-app/peers-ui 0.34.13 → 0.34.15

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 (126) hide show
  1. package/dist/apps-home/app-menu.d.ts +1 -2
  2. package/dist/apps-home/app-menu.js +29 -25
  3. package/dist/command-palette/command-palette-ui.js +13 -12
  4. package/dist/components/autocomplete-chips.d.ts +18 -0
  5. package/dist/components/autocomplete-chips.js +49 -0
  6. package/dist/components/autocomplete.d.ts +88 -0
  7. package/dist/components/autocomplete.js +346 -0
  8. package/dist/components/confirm-button.d.ts +26 -0
  9. package/dist/components/confirm-button.js +55 -0
  10. package/dist/components/data-grid/autocomplete.d.ts +1 -31
  11. package/dist/components/data-grid/autocomplete.js +5 -197
  12. package/dist/components/empty-state.d.ts +16 -0
  13. package/dist/components/empty-state.js +16 -0
  14. package/dist/components/group-switcher.d.ts +3 -3
  15. package/dist/components/group-switcher.js +22 -17
  16. package/dist/components/inline-create-form.d.ts +22 -0
  17. package/dist/components/inline-create-form.js +56 -0
  18. package/dist/components/list-row.d.ts +33 -0
  19. package/dist/components/list-row.js +30 -0
  20. package/dist/components/list-screen.d.ts +31 -3
  21. package/dist/components/list-screen.js +61 -28
  22. package/dist/components/markdown-editor/format-bar.js +15 -40
  23. package/dist/components/markdown-editor/link-plugin.js +38 -9
  24. package/dist/components/markdown-editor/selection-bar-place.d.ts +37 -0
  25. package/dist/components/markdown-editor/selection-bar-place.js +107 -0
  26. package/dist/components/menu-button.d.ts +34 -0
  27. package/dist/components/menu-button.js +66 -0
  28. package/dist/components/screen-header.d.ts +35 -0
  29. package/dist/components/screen-header.js +30 -0
  30. package/dist/components/search-field.d.ts +22 -0
  31. package/dist/components/search-field.js +22 -0
  32. package/dist/components/segmented-control.d.ts +25 -0
  33. package/dist/components/segmented-control.js +18 -0
  34. package/dist/components/typeahead.d.ts +9 -0
  35. package/dist/components/typeahead.js +7 -0
  36. package/dist/delegates/acts-for-you-panel.d.ts +2 -1
  37. package/dist/delegates/acts-for-you-panel.js +46 -17
  38. package/dist/delegates/delegate-request-dialog.d.ts +3 -1
  39. package/dist/delegates/delegate-request-dialog.js +6 -3
  40. package/dist/groups/groups-client.d.ts +23 -1
  41. package/dist/groups/groups-client.js +31 -0
  42. package/dist/index.d.ts +10 -0
  43. package/dist/index.js +14 -1
  44. package/dist/isolated-screens/config.js +1 -9
  45. package/dist/isolated-screens/folder-picker-control.d.ts +57 -0
  46. package/dist/isolated-screens/folder-picker-control.js +217 -0
  47. package/dist/isolated-screens/folder-picker-host.d.ts +57 -0
  48. package/dist/isolated-screens/folder-picker-host.js +178 -0
  49. package/dist/isolated-screens/folder-picker-protocol.d.ts +75 -0
  50. package/dist/isolated-screens/folder-picker-protocol.js +104 -0
  51. package/dist/isolated-screens/frame-bridge.js +8 -0
  52. package/dist/isolated-screens/frame-document.js +2 -1
  53. package/dist/isolated-screens/frame-microphone.d.ts +55 -0
  54. package/dist/isolated-screens/frame-microphone.js +265 -0
  55. package/dist/isolated-screens/frame-permissions.d.ts +19 -0
  56. package/dist/isolated-screens/frame-permissions.js +32 -0
  57. package/dist/isolated-screens/frame-protocol.d.ts +26 -0
  58. package/dist/isolated-screens/frame-protocol.js +9 -0
  59. package/dist/isolated-screens/frame-pvars.d.ts +27 -0
  60. package/dist/isolated-screens/frame-pvars.js +101 -14
  61. package/dist/isolated-screens/global-widgets.d.ts +1 -2
  62. package/dist/isolated-screens/index.d.ts +2 -0
  63. package/dist/isolated-screens/index.js +3 -1
  64. package/dist/isolated-screens/isolated-screen.d.ts +21 -0
  65. package/dist/isolated-screens/isolated-screen.js +88 -5
  66. package/dist/isolated-screens/local-folder-picker.d.ts +55 -0
  67. package/dist/isolated-screens/local-folder-picker.js +143 -0
  68. package/dist/isolated-screens/microphone-host.d.ts +110 -0
  69. package/dist/isolated-screens/microphone-host.js +397 -0
  70. package/dist/isolated-screens/microphone-prompt.d.ts +20 -0
  71. package/dist/isolated-screens/microphone-prompt.js +60 -0
  72. package/dist/isolated-screens/piece-frames.js +5 -94
  73. package/dist/isolated-screens/piece-reach.d.ts +1 -0
  74. package/dist/isolated-screens/port-channel.d.ts +21 -11
  75. package/dist/isolated-screens/port-channel.js +15 -5
  76. package/dist/isolated-screens/slot-rect.d.ts +38 -0
  77. package/dist/isolated-screens/slot-rect.js +121 -0
  78. package/dist/isolated-screens/test-ports.d.ts +17 -0
  79. package/dist/isolated-screens/test-ports.js +25 -3
  80. package/dist/mentions/mention-chooser.js +1 -1
  81. package/dist/notifications/notifications-screen.js +1 -1
  82. package/dist/screens/data-explorer/data-explorer.d.ts +1 -0
  83. package/dist/screens/data-explorer/data-explorer.js +28 -10
  84. package/dist/screens/data-explorer/query-executor.d.ts +1 -0
  85. package/dist/screens/data-explorer/query-executor.js +3 -1
  86. package/dist/screens/groups/group-list.d.ts +13 -3
  87. package/dist/screens/groups/group-list.js +88 -11
  88. package/dist/screens/identity/identity-routes.d.ts +16 -0
  89. package/dist/screens/identity/identity-routes.js +27 -10
  90. package/dist/screens/identity/identity-screen.js +4 -1
  91. package/dist/screens/invites/activity-view.d.ts +3 -1
  92. package/dist/screens/invites/activity-view.js +7 -3
  93. package/dist/screens/invites/pending-invites-list.d.ts +8 -4
  94. package/dist/screens/invites/pending-invites-list.js +44 -45
  95. package/dist/screens/network-viewer/graph/network-graph-controls.js +3 -3
  96. package/dist/screens/packages/local-folder-grants-panel.d.ts +2 -0
  97. package/dist/screens/packages/local-folder-grants-panel.js +1 -1
  98. package/dist/screens/packages/package-info.js +2 -1
  99. package/dist/screens/packages/package-list.d.ts +2 -2
  100. package/dist/screens/packages/package-list.js +89 -105
  101. package/dist/screens/packages/package-microphone-panel.d.ts +14 -0
  102. package/dist/screens/packages/package-microphone-panel.js +62 -0
  103. package/dist/screens/packages/package-runtime-status.d.ts +10 -2
  104. package/dist/screens/packages/package-runtime-status.js +17 -4
  105. package/dist/screens/peer-types/peer-type-details.js +3 -2
  106. package/dist/screens/peer-types/peer-type-list.d.ts +1 -1
  107. package/dist/screens/peer-types/peer-type-list.js +4 -4
  108. package/dist/screens/settings/settings-page.js +1 -4
  109. package/dist/screens/tools/tool-details.js +2 -1
  110. package/dist/screens/tools/tool-list.d.ts +1 -1
  111. package/dist/screens/tools/tool-list.js +22 -60
  112. package/dist/screens/variables/variable-details.js +5 -4
  113. package/dist/screens/variables/variable-list.d.ts +17 -0
  114. package/dist/screens/variables/variable-list.js +72 -28
  115. package/dist/tabs-layout/network-status-details.d.ts +4 -4
  116. package/dist/tabs-layout/network-status-details.js +6 -5
  117. package/dist/tabs-layout/network-status-indicator.d.ts +1 -0
  118. package/dist/tabs-layout/network-status-indicator.js +1 -0
  119. package/dist/tabs-layout/tab-bar-shortcuts.d.ts +46 -0
  120. package/dist/tabs-layout/tab-bar-shortcuts.js +140 -0
  121. package/dist/tabs-layout/tabs-layout.js +11 -9
  122. package/dist/theme.css +326 -6
  123. package/dist/ui-contracts/popover-surface.d.ts +3 -0
  124. package/dist/ui-contracts/popover-surface.js +6 -3
  125. package/dist/ui-defaults/list-screen.js +10 -4
  126. package/package.json +3 -3
@@ -15,6 +15,7 @@ const focus_relay_1 = require("./focus-relay");
15
15
  const frame_component_1 = require("./frame-component");
16
16
  const frame_protocol_1 = require("./frame-protocol");
17
17
  const frame_realm_1 = require("./frame-realm");
18
+ const slot_rect_1 = require("./slot-rect");
18
19
  const wheel_relay_1 = require("./wheel-relay");
19
20
  /**
20
21
  * Inside a framed screen: ask the host who draws a piece.
@@ -150,43 +151,6 @@ function inlinePieceComponent(available, name) {
150
151
  inlineComponents.set(key, component);
151
152
  return component;
152
153
  }
153
- /** The part of a slot that shows: its rectangle cut by every scrolling box around it. */
154
- function visibleClip(element, rect) {
155
- let top = rect.top;
156
- let left = rect.left;
157
- let bottom = rect.bottom;
158
- let right = rect.right;
159
- for (let parent = element.parentElement; parent; parent = parent.parentElement) {
160
- const style = getComputedStyle(parent);
161
- if (style.overflowX === "visible" && style.overflowY === "visible")
162
- continue;
163
- const box = parent.getBoundingClientRect();
164
- if (style.overflowY !== "visible") {
165
- top = Math.max(top, box.top);
166
- bottom = Math.min(bottom, box.bottom);
167
- }
168
- if (style.overflowX !== "visible") {
169
- left = Math.max(left, box.left);
170
- right = Math.min(right, box.right);
171
- }
172
- }
173
- top = Math.max(top, 0);
174
- left = Math.max(left, 0);
175
- bottom = Math.min(bottom, window.innerHeight);
176
- right = Math.min(right, window.innerWidth);
177
- return {
178
- top: Math.max(0, top - rect.top),
179
- left: Math.max(0, left - rect.left),
180
- bottom: Math.max(0, rect.bottom - bottom),
181
- right: Math.max(0, rect.right - right),
182
- };
183
- }
184
- /**
185
- * Events, heard on the way down to their target, after which a slot may have moved without the
186
- * screen's DOM changing: an image (or other element) that loaded, a CSS transition or animation
187
- * that ended.
188
- */
189
- const LAYOUT_EVENTS = ["load", "transitionend", "animationend"];
190
154
  const slotComponents = new Map();
191
155
  /** The embedder's loading view, over a piece's frame until the frame has drawn the piece. */
192
156
  const LOADING_OVER_FRAME = { position: "absolute", inset: 0 };
@@ -225,6 +189,8 @@ function slotPieceComponent(available, name) {
225
189
  // Each mount is a slot of its own, so a late answer to an earlier one never touches it.
226
190
  const slotId = (0, peers_sdk_1.newid)();
227
191
  let active = true;
192
+ // Where the slot is, sent to the host once it holds the slot.
193
+ let stopWatching;
228
194
  setDrawn(false);
229
195
  const mine = (payload) => payload?.slotId === slotId;
230
196
  const stops = [
@@ -293,59 +259,11 @@ function slotPieceComponent(available, name) {
293
259
  if (!active)
294
260
  return host.notify(frame_protocol_1.FrameNotice.pieceUnmount, { slotId });
295
261
  mounted.current = slotId;
296
- schedule();
297
- if (slotRef.current)
298
- resize.observe(slotRef.current);
299
- resize.observe(document.body);
300
- window.addEventListener("resize", schedule);
301
- document.addEventListener("scroll", schedule, true);
302
- // The whole document: a class on <html> or a style in <head> can move it too.
303
- changes.observe(document.documentElement, {
304
- subtree: true,
305
- childList: true,
306
- attributes: true,
307
- characterData: true,
308
- });
309
- for (const type of LAYOUT_EVENTS)
310
- document.addEventListener(type, check, true);
262
+ stopWatching = (0, slot_rect_1.watchSlotRect)(() => slotRef.current, (rect, clip) => host.notify(frame_protocol_1.FrameNotice.pieceRect, { slotId, rect, clip }));
311
263
  if (JSON.stringify(latest.current.props) !== propsKey) {
312
264
  host.notify(frame_protocol_1.FrameNotice.pieceProps, { slotId, props: latest.current.props });
313
265
  }
314
266
  }, (error) => active && setFailed(errorText(error)));
315
- // Where the slot is, sent once per animation frame while anything moves it. A resize or a
316
- // scroll always sends it. Content above the slot that grows or shrinks moves the slot
317
- // without resizing it, so any other change in the screen (its document, an image that
318
- // loaded, a transition that ended) measures the slot again, and sends only if it moved.
319
- let scheduled = 0;
320
- let always = false;
321
- let sent = "";
322
- const report = () => {
323
- scheduled = 0;
324
- const send = always;
325
- always = false;
326
- const element = slotRef.current;
327
- if (!element)
328
- return;
329
- const rect = element.getBoundingClientRect();
330
- const box = { x: rect.left, y: rect.top, width: rect.width, height: rect.height };
331
- const clip = visibleClip(element, rect);
332
- const key = JSON.stringify([box, clip]);
333
- if (!send && key === sent)
334
- return;
335
- sent = key;
336
- host.notify(frame_protocol_1.FrameNotice.pieceRect, { slotId, rect: box, clip });
337
- };
338
- const schedule = () => {
339
- always = true;
340
- if (!scheduled)
341
- scheduled = requestAnimationFrame(report);
342
- };
343
- const check = () => {
344
- if (!scheduled)
345
- scheduled = requestAnimationFrame(report);
346
- };
347
- const resize = new ResizeObserver(schedule);
348
- const changes = new MutationObserver(check);
349
267
  return () => {
350
268
  active = false;
351
269
  if (mounted.current === slotId) {
@@ -354,14 +272,7 @@ function slotPieceComponent(available, name) {
354
272
  }
355
273
  for (const stop of stops)
356
274
  stop();
357
- if (scheduled)
358
- cancelAnimationFrame(scheduled);
359
- resize.disconnect();
360
- changes.disconnect();
361
- window.removeEventListener("resize", schedule);
362
- document.removeEventListener("scroll", schedule, true);
363
- for (const type of LAYOUT_EVENTS)
364
- document.removeEventListener(type, check, true);
275
+ stopWatching?.();
365
276
  };
366
277
  }, [host, mode, inPopover, maxWidth]);
367
278
  // Until the host holds the slot, its mount sends the props that are current when it does.
@@ -12,6 +12,7 @@ export interface IStoredManifest {
12
12
  alsoImplements?: never[];
13
13
  }[];
14
14
  globalWidgets?: unknown;
15
+ microphone?: unknown;
15
16
  }
16
17
  /**
17
18
  * The manifest this device stored for a package version, when it has one that matches the
@@ -6,24 +6,34 @@
6
6
  */
7
7
  /** The smallest port the channel needs: a `MessagePort`, or one end of a test pair. */
8
8
  export interface IPortLike {
9
- postMessage(message: unknown): void;
10
- addEventListener(type: "message", listener: (event: {
11
- data: unknown;
12
- }) => void): void;
13
- removeEventListener(type: "message", listener: (event: {
14
- data: unknown;
15
- }) => void): void;
9
+ postMessage(message: unknown, transfer?: Transferable[]): void;
10
+ addEventListener(type: "message", listener: (event: IPortMessageEvent) => void): void;
11
+ removeEventListener(type: "message", listener: (event: IPortMessageEvent) => void): void;
16
12
  start?(): void;
17
13
  close?(): void;
18
14
  }
19
- /** A request handler: its result, or what it throws, goes back to the asker. */
20
- export type PortRequestHandler = (payload: any) => unknown | Promise<unknown>;
15
+ /** What a port's listener gets: the message, and the ports it carried. */
16
+ export interface IPortMessageEvent {
17
+ data: unknown;
18
+ /** Ports the sender transferred with the message. */
19
+ ports?: readonly MessagePort[];
20
+ }
21
+ /**
22
+ * A request handler: its result, or what it throws, goes back to the asker. `ports` are the ports
23
+ * the asker transferred with the request (`request`'s `transfer`), given only when there are some.
24
+ */
25
+ export type PortRequestHandler = (payload: any, ports?: readonly MessagePort[]) => unknown | Promise<unknown>;
21
26
  /** A notification handler. */
22
27
  export type PortNotifyHandler = (payload: any) => void;
23
28
  /** Requests and notifications over one port. */
24
29
  export interface IPortChannel {
25
- /** Ask the other side, and wait for its answer. Rejects with the error it threw. */
26
- request<T = unknown>(type: string, payload?: unknown): Promise<T>;
30
+ /**
31
+ * Ask the other side, and wait for its answer. Rejects with the error it threw.
32
+ *
33
+ * @param transfer - Ports to hand over with the request, which its handler gets as `ports`
34
+ * (a `MessageChannel` end for a stream that shouldn't pass through the main threads).
35
+ */
36
+ request<T = unknown>(type: string, payload?: unknown, transfer?: MessagePort[]): Promise<T>;
27
37
  /** Tell the other side something, without waiting. */
28
38
  notify(type: string, payload?: unknown): void;
29
39
  /** Answer one type of request. Returns a function that stops answering. */
@@ -27,10 +27,13 @@ function openPortChannel(port, opts = {}) {
27
27
  const pending = new Map();
28
28
  const requestHandlers = new Map();
29
29
  const notifyHandlers = new Map();
30
- const post = (message) => {
30
+ const post = (message, transfer) => {
31
31
  if (closed)
32
32
  return;
33
- port.postMessage(message);
33
+ if (transfer?.length)
34
+ port.postMessage(message, transfer);
35
+ else
36
+ port.postMessage(message);
34
37
  };
35
38
  const listener = (event) => {
36
39
  if (closed)
@@ -74,7 +77,11 @@ function openPortChannel(port, opts = {}) {
74
77
  if (message.kind === "request") {
75
78
  const { id, type } = message;
76
79
  const handler = requestHandlers.get(type);
80
+ const ports = event.ports ?? [];
77
81
  if (!handler) {
82
+ // Nothing takes the ports, so they're closed rather than left open.
83
+ for (const transferred of ports)
84
+ transferred.close();
78
85
  post({ kind: "response", id, ok: false, error: `Unknown request: ${type}` });
79
86
  try {
80
87
  opts.onUnknownRequest?.(type);
@@ -86,10 +93,13 @@ function openPortChannel(port, opts = {}) {
86
93
  }
87
94
  void (async () => {
88
95
  try {
89
- const value = await handler((0, peers_sdk_1.fromJSON)(message.payload));
96
+ const payload = (0, peers_sdk_1.fromJSON)(message.payload);
97
+ const value = await (ports.length ? handler(payload, ports) : handler(payload));
90
98
  post({ kind: "response", id, ok: true, value: (0, peers_sdk_1.toJSONKeepingBytes)(value) });
91
99
  }
92
100
  catch (error) {
101
+ for (const transferred of ports)
102
+ transferred.close();
93
103
  post({ kind: "response", id, ok: false, error: errorMessage(error) });
94
104
  }
95
105
  })();
@@ -98,14 +108,14 @@ function openPortChannel(port, opts = {}) {
98
108
  port.addEventListener("message", listener);
99
109
  port.start?.();
100
110
  return {
101
- request(type, payload) {
111
+ request(type, payload, transfer) {
102
112
  if (closed)
103
113
  return Promise.reject(new Error("The frame's channel is closed"));
104
114
  const id = nextId++;
105
115
  return new Promise((resolve, reject) => {
106
116
  pending.set(id, { resolve, reject });
107
117
  try {
108
- post({ kind: "request", id, type, payload: (0, peers_sdk_1.toJSONKeepingBytes)(payload) });
118
+ post({ kind: "request", id, type, payload: (0, peers_sdk_1.toJSONKeepingBytes)(payload) }, transfer);
109
119
  }
110
120
  catch (error) {
111
121
  pending.delete(id);
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Where a slot in a framed screen is, for the host that draws over it: a piece's frame
3
+ * (`piece-frames.tsx`) or a control Peers draws itself (`local-folder-picker.tsx`).
4
+ */
5
+ /** A slot's box, in the frame's coordinates. */
6
+ export interface ISlotRect {
7
+ x: number;
8
+ y: number;
9
+ width: number;
10
+ height: number;
11
+ }
12
+ /** How much of each side of a slot is hidden, by scrolling boxes around it or the window's edge. */
13
+ export interface ISlotClip {
14
+ top: number;
15
+ right: number;
16
+ bottom: number;
17
+ left: number;
18
+ }
19
+ /**
20
+ * The part of a slot that shows: its rectangle cut by every scrolling box around it.
21
+ *
22
+ * @param element - The slot.
23
+ * @param rect - Its bounding rectangle.
24
+ * @returns How much of each side is cut off.
25
+ */
26
+ export declare function visibleClip(element: HTMLElement, rect: DOMRect): ISlotClip;
27
+ /**
28
+ * Report where a slot is, once per animation frame while anything moves it, until stopped. A
29
+ * resize or a scroll always reports it. Content above the slot that grows or shrinks moves the
30
+ * slot without resizing it, so any other change in the screen (its document, an image that loaded,
31
+ * a transition that ended) measures the slot again, and reports only if it moved. The first report
32
+ * comes on the next animation frame.
33
+ *
34
+ * @param slot - The slot, read at each report; nothing is reported while it's gone.
35
+ * @param send - Called with the slot's box and the part of it that's hidden.
36
+ * @returns Stops watching.
37
+ */
38
+ export declare function watchSlotRect(slot: () => HTMLElement | null, send: (rect: ISlotRect, clip: ISlotClip) => void): () => void;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ /**
3
+ * Where a slot in a framed screen is, for the host that draws over it: a piece's frame
4
+ * (`piece-frames.tsx`) or a control Peers draws itself (`local-folder-picker.tsx`).
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.visibleClip = visibleClip;
8
+ exports.watchSlotRect = watchSlotRect;
9
+ /**
10
+ * The part of a slot that shows: its rectangle cut by every scrolling box around it.
11
+ *
12
+ * @param element - The slot.
13
+ * @param rect - Its bounding rectangle.
14
+ * @returns How much of each side is cut off.
15
+ */
16
+ function visibleClip(element, rect) {
17
+ let top = rect.top;
18
+ let left = rect.left;
19
+ let bottom = rect.bottom;
20
+ let right = rect.right;
21
+ for (let parent = element.parentElement; parent; parent = parent.parentElement) {
22
+ const style = getComputedStyle(parent);
23
+ if (style.overflowX === "visible" && style.overflowY === "visible")
24
+ continue;
25
+ const box = parent.getBoundingClientRect();
26
+ if (style.overflowY !== "visible") {
27
+ top = Math.max(top, box.top);
28
+ bottom = Math.min(bottom, box.bottom);
29
+ }
30
+ if (style.overflowX !== "visible") {
31
+ left = Math.max(left, box.left);
32
+ right = Math.min(right, box.right);
33
+ }
34
+ }
35
+ top = Math.max(top, 0);
36
+ left = Math.max(left, 0);
37
+ bottom = Math.min(bottom, window.innerHeight);
38
+ right = Math.min(right, window.innerWidth);
39
+ return {
40
+ top: Math.max(0, top - rect.top),
41
+ left: Math.max(0, left - rect.left),
42
+ bottom: Math.max(0, rect.bottom - bottom),
43
+ right: Math.max(0, rect.right - right),
44
+ };
45
+ }
46
+ /**
47
+ * Events, heard on the way down to their target, after which a slot may have moved without the
48
+ * screen's DOM changing: an image (or other element) that loaded, a CSS transition or animation
49
+ * that ended.
50
+ */
51
+ const LAYOUT_EVENTS = ["load", "transitionend", "animationend"];
52
+ /**
53
+ * Report where a slot is, once per animation frame while anything moves it, until stopped. A
54
+ * resize or a scroll always reports it. Content above the slot that grows or shrinks moves the
55
+ * slot without resizing it, so any other change in the screen (its document, an image that loaded,
56
+ * a transition that ended) measures the slot again, and reports only if it moved. The first report
57
+ * comes on the next animation frame.
58
+ *
59
+ * @param slot - The slot, read at each report; nothing is reported while it's gone.
60
+ * @param send - Called with the slot's box and the part of it that's hidden.
61
+ * @returns Stops watching.
62
+ */
63
+ function watchSlotRect(slot, send) {
64
+ let scheduled = 0;
65
+ let always = false;
66
+ let sent = "";
67
+ const report = () => {
68
+ scheduled = 0;
69
+ const force = always;
70
+ always = false;
71
+ const element = slot();
72
+ if (!element)
73
+ return;
74
+ const rect = element.getBoundingClientRect();
75
+ const box = { x: rect.left, y: rect.top, width: rect.width, height: rect.height };
76
+ const clip = visibleClip(element, rect);
77
+ const key = JSON.stringify([box, clip]);
78
+ if (!force && key === sent)
79
+ return;
80
+ sent = key;
81
+ send(box, clip);
82
+ };
83
+ const schedule = () => {
84
+ always = true;
85
+ if (!scheduled)
86
+ scheduled = requestAnimationFrame(report);
87
+ };
88
+ const check = () => {
89
+ if (!scheduled)
90
+ scheduled = requestAnimationFrame(report);
91
+ };
92
+ const resize = new ResizeObserver(schedule);
93
+ const changes = new MutationObserver(check);
94
+ schedule();
95
+ const element = slot();
96
+ if (element)
97
+ resize.observe(element);
98
+ resize.observe(document.body);
99
+ window.addEventListener("resize", schedule);
100
+ document.addEventListener("scroll", schedule, true);
101
+ // The whole document: a class on <html> or a style in <head> can move it too.
102
+ changes.observe(document.documentElement, {
103
+ subtree: true,
104
+ childList: true,
105
+ attributes: true,
106
+ characterData: true,
107
+ });
108
+ for (const type of LAYOUT_EVENTS)
109
+ document.addEventListener(type, check, true);
110
+ return () => {
111
+ if (scheduled)
112
+ cancelAnimationFrame(scheduled);
113
+ scheduled = 0;
114
+ resize.disconnect();
115
+ changes.disconnect();
116
+ window.removeEventListener("resize", schedule);
117
+ document.removeEventListener("scroll", schedule, true);
118
+ for (const type of LAYOUT_EVENTS)
119
+ document.removeEventListener(type, check, true);
120
+ };
121
+ }
@@ -1,3 +1,20 @@
1
1
  import type { IPortLike } from "./port-channel";
2
2
  /** Two connected ports for tests: what one posts, the other's listeners get, a tick later. */
3
3
  export declare function portPair(): [IPortLike, IPortLike];
4
+ /** A worklet processor as a test drives it: its port, and `process`. */
5
+ export interface ITestWorkletProcessor {
6
+ port: {
7
+ onmessage: ((event: {
8
+ data: unknown;
9
+ }) => void) | null;
10
+ };
11
+ process(inputs: Float32Array[][], outputs?: Float32Array[][]): boolean;
12
+ }
13
+ /**
14
+ * Run an AudioWorklet module's source here, off any audio thread, and make one of the processors
15
+ * it registers, as the engine would.
16
+ *
17
+ * @param source - The module's source.
18
+ * @param sampleRate - The worklet scope's `sampleRate`.
19
+ */
20
+ export declare function loadWorkletProcessor(source: string, sampleRate: number): ITestWorkletProcessor;
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.portPair = portPair;
4
+ exports.loadWorkletProcessor = loadWorkletProcessor;
4
5
  const node_v8_1 = require("node:v8");
5
6
  /** Two connected ports for tests: what one posts, the other's listeners get, a tick later. */
6
7
  function portPair() {
7
8
  const listeners = [new Set(), new Set()];
8
9
  const make = (mine, theirs) => ({
9
- postMessage: (message) => {
10
- // A structured clone, as a real port makes.
10
+ postMessage: (message, transfer) => {
11
+ // A structured clone, as a real port makes. Transferred ports arrive as they are.
11
12
  const data = (0, node_v8_1.deserialize)((0, node_v8_1.serialize)(message));
13
+ const ports = (transfer ?? []);
12
14
  setTimeout(() => {
13
15
  for (const listener of theirs)
14
- listener({ data });
16
+ listener({ data, ports });
15
17
  }, 0);
16
18
  },
17
19
  addEventListener: (_type, listener) => mine.add(listener),
@@ -19,3 +21,23 @@ function portPair() {
19
21
  });
20
22
  return [make(listeners[0], listeners[1]), make(listeners[1], listeners[0])];
21
23
  }
24
+ /**
25
+ * Run an AudioWorklet module's source here, off any audio thread, and make one of the processors
26
+ * it registers, as the engine would.
27
+ *
28
+ * @param source - The module's source.
29
+ * @param sampleRate - The worklet scope's `sampleRate`.
30
+ */
31
+ function loadWorkletProcessor(source, sampleRate) {
32
+ class AudioWorkletProcessor {
33
+ port = { onmessage: null };
34
+ }
35
+ let registered;
36
+ const registerProcessor = (_name, processor) => {
37
+ registered = processor;
38
+ };
39
+ new Function("AudioWorkletProcessor", "registerProcessor", "sampleRate", source)(AudioWorkletProcessor, registerProcessor, sampleRate);
40
+ if (!registered)
41
+ throw new Error("The module registered no processor");
42
+ return new registered();
43
+ }
@@ -55,7 +55,7 @@ function handleFrontDialogKeys(inside, onEscape) {
55
55
  onEscape();
56
56
  return;
57
57
  }
58
- const controls = Array.from(front.querySelectorAll("button, input"));
58
+ const controls = Array.from(front.querySelectorAll("button:enabled, input:enabled"));
59
59
  const active = document.activeElement;
60
60
  const index = active instanceof HTMLElement ? controls.indexOf(active) : -1;
61
61
  const next = e.shiftKey
@@ -166,7 +166,7 @@ function NotificationSettings() {
166
166
  const key = `${source.match.groupId ?? ""}:${source.match.packageId ?? ""}:${source.match.fromUserId ?? ""}:${source.match.kind ?? ""}`;
167
167
  return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap align-items-center gap-2 px-2 py-2 border-bottom", children: [(0, jsx_runtime_1.jsx)("span", { className: "flex-grow-1 small", children: source.label }), (0, jsx_runtime_1.jsxs)("select", { className: "form-select form-select-sm", style: { width: "auto" }, "aria-label": `Level for ${source.label}`, value: rule?.level ?? "", onChange: (event) => setRule(source.match, {
168
168
  level: (event.target.value || undefined),
169
- }), children: [(0, jsx_runtime_1.jsx)("option", { value: "", children: "As the app asks" }), ["priority", "loud", "quiet", "background", "off"].map((level) => ((0, jsx_runtime_1.jsx)("option", { value: level, children: levelLabels[level] }, level)))] }), source.match.fromUserId && ((0, jsx_runtime_1.jsxs)("label", { className: "form-check-label small d-flex align-items-center gap-1", children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", className: "form-check-input m-0", checked: rule?.allowPriority === true, onChange: (event) => setRule(source.match, {
169
+ }), children: [(0, jsx_runtime_1.jsx)("option", { value: "", children: "As the app asks" }), ["priority", "loud", "quiet", "background", "off"].map((level) => ((0, jsx_runtime_1.jsx)("option", { value: level, children: levelLabels[level] }, level)))] }), source.match.fromUserId && ((0, jsx_runtime_1.jsxs)("label", { className: "form-check form-switch form-check-label small d-flex align-items-center gap-2 m-0 ps-0", children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", role: "switch", className: "form-check-input m-0", checked: rule?.allowPriority === true, "aria-checked": rule?.allowPriority === true, onChange: (event) => setRule(source.match, {
170
170
  allowPriority: event.target.checked ? true : undefined,
171
171
  }) }), "Allow priority"] }))] }, key));
172
172
  })] })] })] }));
@@ -1 +1,2 @@
1
+ /** Browses tables, storage use and change-history commands for the current desktop context. */
1
2
  export declare function DataExplorerList(): import("react/jsx-runtime").JSX.Element;
@@ -4,6 +4,8 @@ exports.DataExplorerList = DataExplorerList;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const loading_indicator_1 = require("../../components/loading-indicator");
7
+ const menu_button_1 = require("../../components/menu-button");
8
+ const screen_header_1 = require("../../components/screen-header");
7
9
  const globals_1 = require("../../globals");
8
10
  const ui_loader_1 = require("../../ui-router/ui-loader");
9
11
  function getDataExplorerApi() {
@@ -42,6 +44,7 @@ function DeleteConfirmModal({ tableName, onConfirm, onCancel, }) {
42
44
  // biome-ignore lint/a11y/noAutofocus: confirmation input needs immediate focus
43
45
  autoFocus: true })] }), (0, jsx_runtime_1.jsxs)("div", { className: "card-footer d-flex justify-content-end gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-secondary", onClick: onCancel, disabled: deleting, children: "Cancel" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-danger", disabled: confirmText !== tableName || deleting, onClick: handleConfirm, children: deleting ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1" }), "Deleting..."] })) : ("Delete Table") })] })] }) }));
44
46
  }
47
+ /** Browses tables, storage use and change-history commands for the current desktop context. */
45
48
  function DataExplorerList() {
46
49
  const [tables, setTables] = (0, react_1.useState)([]);
47
50
  const [deletedTables, setDeletedTables] = (0, react_1.useState)([]);
@@ -188,16 +191,31 @@ function DataExplorerList() {
188
191
  }
189
192
  const registeredTables = tables.filter((t) => t.isRegistered);
190
193
  const unregisteredTables = tables.filter((t) => !t.isRegistered);
191
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid p-4", children: [deleteTarget && ((0, jsx_runtime_1.jsx)(DeleteConfirmModal, { tableName: deleteTarget, onConfirm: handleDeleteTable, onCancel: () => setDeleteTarget(null) })), (0, jsx_runtime_1.jsxs)("ul", { className: "nav nav-tabs mb-4", children: [(0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("a", { className: "nav-link active", href: "#/data-explorer", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-table" }), " Tables"] }) }), (0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("a", { className: "nav-link", href: "#/data-explorer/query", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-terminal" }), " Query"] }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-between align-items-center mb-4", children: [(0, jsx_runtime_1.jsx)("h2", { children: "Data Explorer" }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "btn-group", role: "group", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-warning", onClick: () => compactDatabase(), disabled: compacting || loading, title: "Compact database (cleanup changes older than 2 weeks)", children: compacting ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1", role: "status", "aria-hidden": "true" }), "Compacting..."] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-disc" }), " Compact Database"] })) }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-warning dropdown-toggle dropdown-toggle-split", "data-bs-toggle": "dropdown", "aria-expanded": "false", disabled: compacting || loading, title: "More compaction options", children: (0, jsx_runtime_1.jsx)("span", { className: "visually-hidden", children: "Toggle Dropdown" }) }), (0, jsx_runtime_1.jsxs)("ul", { className: "dropdown-menu", children: [(0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsxs)("a", { className: "dropdown-item", href: "#", onClick: (e) => {
192
- e.preventDefault();
193
- compactDatabase(Date.now());
194
- }, children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-exclamation-triangle text-danger me-2" }), "Extreme Compaction", (0, jsx_runtime_1.jsx)("div", { className: "small text-muted", children: "Remove ALL change history" })] }) }), (0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)("hr", { className: "dropdown-divider" }) }), (0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsxs)("a", { className: "dropdown-item", href: "#", onClick: (e) => {
195
- e.preventDefault();
196
- resetChangeTracking();
197
- }, children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-arrow-clockwise text-warning me-2" }), "Reset Change Tracking", (0, jsx_runtime_1.jsx)("div", { className: "small text-muted", children: "Clear and rebuild all change history" })] }) })] })] }), (0, jsx_runtime_1.jsxs)("button", { className: "btn btn-sm btn-primary", onClick: () => {
198
- setLoading(true);
199
- loadTables();
200
- }, disabled: compacting, children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-arrow-clockwise" }), " Refresh"] })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "card mb-4", children: (0, jsx_runtime_1.jsx)("div", { className: "card-body", children: (0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-between align-items-center", children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h5", { className: "card-title mb-2", children: "Current Data Context" }), (0, jsx_runtime_1.jsx)("p", { className: "mb-0", children: currentContext })] }), (0, jsx_runtime_1.jsxs)("div", { className: "text-end", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-muted small", children: "Total DB Size" }), (0, jsx_runtime_1.jsx)("div", { className: "fs-4 fw-bold", children: formatBytes(tables.reduce((sum, t) => sum + (t.bytes || 0), 0)) })] })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "card mb-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsxs)("h5", { className: "card-title", children: ["Registered Tables (", registeredTables.length, ")", (0, jsx_runtime_1.jsx)("span", { className: "badge bg-success ms-2", children: "Active" })] }), (0, jsx_runtime_1.jsx)("p", { className: "text-muted small", children: "These tables are registered with the TableContainer and actively used by the application." }), registeredTables.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: "text-muted", children: "No registered tables found" })) : ((0, jsx_runtime_1.jsx)("div", { className: "table-responsive", children: (0, jsx_runtime_1.jsxs)("table", { className: "table table-hover table-sm", children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "Table Name" }), (0, jsx_runtime_1.jsx)("th", { children: "Table ID" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Row Count" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Bytes" }), (0, jsx_runtime_1.jsx)("th", { style: { width: "1%" } })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: registeredTables.map((table) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("strong", { children: table.tableName }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("code", { className: "text-muted small", children: table.tableId || "system" }) }), (0, jsx_runtime_1.jsx)("td", { className: "text-end", children: table.rowCount !== undefined ? table.rowCount.toLocaleString() : "-" }), (0, jsx_runtime_1.jsx)("td", { className: `text-end fw-bold ${getBytesColorClass(table.bytes)}`, children: formatBytes(table.bytes) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-danger border-0", title: `Delete ${table.tableName}`, onClick: () => setDeleteTarget(table.tableName), children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-trash" }) }) })] }, table.tableName))) })] }) }))] }) }), unregisteredTables.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "card mb-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsxs)("h5", { className: "card-title", children: ["Unregistered Tables (", unregisteredTables.length, ")", (0, jsx_runtime_1.jsx)("span", { className: "badge bg-warning text-dark ms-2", children: "Raw SQLite" })] }), (0, jsx_runtime_1.jsx)("p", { className: "text-muted small", children: "These tables exist in the SQLite database but are not registered with the TableContainer. They may be system tables, change tracking tables, or legacy tables." }), (0, jsx_runtime_1.jsx)("div", { className: "table-responsive", children: (0, jsx_runtime_1.jsxs)("table", { className: "table table-hover table-sm", children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "Table Name" }), (0, jsx_runtime_1.jsx)("th", { children: "Type" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Row Count" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Bytes" }), (0, jsx_runtime_1.jsx)("th", { children: "SQL Definition" }), (0, jsx_runtime_1.jsx)("th", { style: { width: "1%" } })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: unregisteredTables.map((table) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("strong", { children: table.tableName }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("span", { className: "badge bg-secondary", children: table.type || "table" }) }), (0, jsx_runtime_1.jsx)("td", { className: "text-end", children: table.rowCount !== undefined ? table.rowCount.toLocaleString() : "-" }), (0, jsx_runtime_1.jsx)("td", { className: `text-end fw-bold ${getBytesColorClass(table.bytes)}`, children: formatBytes(table.bytes) }), (0, jsx_runtime_1.jsx)("td", { children: table.sql ? ((0, jsx_runtime_1.jsxs)("details", { children: [(0, jsx_runtime_1.jsx)("summary", { className: "cursor-pointer text-primary", style: { cursor: "pointer" }, children: (0, jsx_runtime_1.jsx)("small", { children: "View SQL" }) }), (0, jsx_runtime_1.jsx)("pre", { className: "mt-2 p-2 bg-body-secondary border rounded", style: {
194
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "container-xxl p-3", children: [deleteTarget && ((0, jsx_runtime_1.jsx)(DeleteConfirmModal, { tableName: deleteTarget, onConfirm: handleDeleteTable, onCancel: () => setDeleteTarget(null) })), (0, jsx_runtime_1.jsx)(screen_header_1.ScreenHeader, { icon: "bi-database", title: "Data Explorer", subtitle: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [currentContext, " \u00B7 ", formatBytes(tables.reduce((sum, t) => sum + (t.bytes || 0), 0)), " in all"] }), actions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-primary text-nowrap", onClick: () => {
195
+ setLoading(true);
196
+ loadTables();
197
+ }, disabled: compacting, children: compacting ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1", "aria-hidden": "true" }), "Compacting\u2026"] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-arrow-clockwise me-1", "aria-hidden": "true" }), "Refresh"] })) }), (0, jsx_runtime_1.jsx)(menu_button_1.MenuButton, { items: [
198
+ {
199
+ label: "Compact database (history over 2 weeks old)",
200
+ icon: "bi-disc",
201
+ disabled: compacting || loading,
202
+ onSelect: () => void compactDatabase(),
203
+ },
204
+ {
205
+ label: "Remove all change history",
206
+ icon: "bi-exclamation-triangle",
207
+ danger: true,
208
+ disabled: compacting || loading,
209
+ onSelect: () => void compactDatabase(Date.now()),
210
+ },
211
+ "divider",
212
+ {
213
+ label: "Reset change tracking",
214
+ icon: "bi-arrow-clockwise",
215
+ disabled: compacting || loading,
216
+ onSelect: () => void resetChangeTracking(),
217
+ },
218
+ ] })] }) }), (0, jsx_runtime_1.jsxs)("ul", { className: "nav nav-tabs mb-4", children: [(0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("a", { className: "nav-link active", href: "#/data-explorer", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-table" }), " Tables"] }) }), (0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("a", { className: "nav-link", href: "#/data-explorer/query", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-terminal" }), " Query"] }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "card mb-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsxs)("h5", { className: "card-title", children: ["Registered Tables (", registeredTables.length, ")", (0, jsx_runtime_1.jsx)("span", { className: "badge bg-success ms-2", children: "Active" })] }), (0, jsx_runtime_1.jsx)("p", { className: "text-muted small", children: "These tables are registered with the TableContainer and actively used by the application." }), registeredTables.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: "text-muted", children: "No registered tables found" })) : ((0, jsx_runtime_1.jsx)("div", { className: "table-responsive", children: (0, jsx_runtime_1.jsxs)("table", { className: "table table-hover table-sm", children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "Table Name" }), (0, jsx_runtime_1.jsx)("th", { children: "Table ID" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Row Count" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Bytes" }), (0, jsx_runtime_1.jsx)("th", { style: { width: "1%" } })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: registeredTables.map((table) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("strong", { children: table.tableName }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("code", { className: "text-muted small", children: table.tableId || "system" }) }), (0, jsx_runtime_1.jsx)("td", { className: "text-end", children: table.rowCount !== undefined ? table.rowCount.toLocaleString() : "-" }), (0, jsx_runtime_1.jsx)("td", { className: `text-end fw-bold ${getBytesColorClass(table.bytes)}`, children: formatBytes(table.bytes) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-danger border-0", title: `Delete ${table.tableName}`, onClick: () => setDeleteTarget(table.tableName), children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-trash" }) }) })] }, table.tableName))) })] }) }))] }) }), unregisteredTables.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "card mb-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsxs)("h5", { className: "card-title", children: ["Unregistered Tables (", unregisteredTables.length, ")", (0, jsx_runtime_1.jsx)("span", { className: "badge bg-warning text-dark ms-2", children: "Raw SQLite" })] }), (0, jsx_runtime_1.jsx)("p", { className: "text-muted small", children: "These tables exist in the SQLite database but are not registered with the TableContainer. They may be system tables, change tracking tables, or legacy tables." }), (0, jsx_runtime_1.jsx)("div", { className: "table-responsive", children: (0, jsx_runtime_1.jsxs)("table", { className: "table table-hover table-sm", children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "Table Name" }), (0, jsx_runtime_1.jsx)("th", { children: "Type" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Row Count" }), (0, jsx_runtime_1.jsx)("th", { className: "text-end", children: "Bytes" }), (0, jsx_runtime_1.jsx)("th", { children: "SQL Definition" }), (0, jsx_runtime_1.jsx)("th", { style: { width: "1%" } })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: unregisteredTables.map((table) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("strong", { children: table.tableName }) }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("span", { className: "badge bg-secondary", children: table.type || "table" }) }), (0, jsx_runtime_1.jsx)("td", { className: "text-end", children: table.rowCount !== undefined ? table.rowCount.toLocaleString() : "-" }), (0, jsx_runtime_1.jsx)("td", { className: `text-end fw-bold ${getBytesColorClass(table.bytes)}`, children: formatBytes(table.bytes) }), (0, jsx_runtime_1.jsx)("td", { children: table.sql ? ((0, jsx_runtime_1.jsxs)("details", { children: [(0, jsx_runtime_1.jsx)("summary", { className: "cursor-pointer text-primary", style: { cursor: "pointer" }, children: (0, jsx_runtime_1.jsx)("small", { children: "View SQL" }) }), (0, jsx_runtime_1.jsx)("pre", { className: "mt-2 p-2 bg-body-secondary border rounded", style: {
201
219
  fontSize: "0.75rem",
202
220
  maxHeight: "300px",
203
221
  overflow: "auto",
@@ -1 +1,2 @@
1
+ /** Runs SQL against the current desktop context and displays the results in query tabs. */
1
2
  export declare function QueryExecutor(): import("react/jsx-runtime").JSX.Element;
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const peers_sdk_1 = require("@peers-app/peers-sdk");
6
6
  const react_1 = require("react");
7
7
  const loading_indicator_1 = require("../../components/loading-indicator");
8
+ const screen_header_1 = require("../../components/screen-header");
8
9
  const globals_1 = require("../../globals");
9
10
  const hooks_1 = require("../../hooks");
10
11
  const ui_loader_1 = require("../../ui-router/ui-loader");
@@ -25,6 +26,7 @@ const queryTabs = (0, peers_sdk_1.groupDeviceVar)("dataExplorerQueryTabs", {
25
26
  const activeQueryTabId = (0, peers_sdk_1.groupDeviceVar)("dataExplorerActiveQueryTab", {
26
27
  defaultValue: "",
27
28
  });
29
+ /** Runs SQL against the current desktop context and displays the results in query tabs. */
28
30
  function QueryExecutor() {
29
31
  (0, hooks_1.useObservable)(queryTabs);
30
32
  (0, hooks_1.useObservable)(activeQueryTabId);
@@ -205,7 +207,7 @@ function QueryExecutor() {
205
207
  if (!(0, globals_1.isDesktop)()) {
206
208
  return ((0, jsx_runtime_1.jsx)("div", { className: "container-fluid p-4", children: (0, jsx_runtime_1.jsx)("div", { className: "alert alert-info", children: "Query Executor is only available in the desktop application." }) }));
207
209
  }
208
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid p-4", children: [(0, jsx_runtime_1.jsxs)("ul", { className: "nav nav-tabs mb-4", children: [(0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("a", { className: "nav-link", href: "#/data-explorer", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-table" }), " Tables"] }) }), (0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("a", { className: "nav-link active", href: "#/data-explorer/query", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-terminal" }), " Query"] }) })] }), (0, jsx_runtime_1.jsx)("h2", { className: "mb-3", children: "SQL Query Executor" }), (0, jsx_runtime_1.jsx)("div", { className: "mb-3", children: (0, jsx_runtime_1.jsxs)("ul", { className: "nav nav-tabs", children: [tabs.map((tab) => ((0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("div", { className: `nav-link ${tab.id === activeTabId ? "active" : ""}`, style: { cursor: "pointer", display: "flex", alignItems: "center", gap: "8px" }, children: [(0, jsx_runtime_1.jsx)("span", { onClick: () => activeQueryTabId(tab.id), style: { flex: 1 }, children: tab.name }), tabs.length > 1 && ((0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm p-0", onClick: (e) => {
210
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "container-xxl p-3", children: [(0, jsx_runtime_1.jsx)(screen_header_1.ScreenHeader, { icon: "bi-database", title: "Data Explorer", subtitle: "Run SQL against this device's copy of the group's data" }), (0, jsx_runtime_1.jsxs)("ul", { className: "nav nav-tabs mb-4", children: [(0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("a", { className: "nav-link", href: "#/data-explorer", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-table" }), " Tables"] }) }), (0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("a", { className: "nav-link active", href: "#/data-explorer/query", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-terminal" }), " Query"] }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "mb-3", children: (0, jsx_runtime_1.jsxs)("ul", { className: "nav nav-tabs", children: [tabs.map((tab) => ((0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: (0, jsx_runtime_1.jsxs)("div", { className: `nav-link ${tab.id === activeTabId ? "active" : ""}`, style: { cursor: "pointer", display: "flex", alignItems: "center", gap: "8px" }, children: [(0, jsx_runtime_1.jsx)("span", { onClick: () => activeQueryTabId(tab.id), style: { flex: 1 }, children: tab.name }), tabs.length > 1 && ((0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm p-0", onClick: (e) => {
209
211
  e.stopPropagation();
210
212
  closeTab(tab.id);
211
213
  }, style: {