@peers-app/peers-ui 0.33.24 → 0.34.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 (106) hide show
  1. package/dist/command-palette/command-palette.js +4 -2
  2. package/dist/components/router.d.ts +1 -0
  3. package/dist/components/router.js +4 -1
  4. package/dist/host-shell/host-shell-consumer.js +8 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +7 -1
  7. package/dist/isolated-screens/config.d.ts +51 -0
  8. package/dist/isolated-screens/config.js +73 -0
  9. package/dist/isolated-screens/frame-autostart.d.ts +1 -0
  10. package/dist/isolated-screens/frame-autostart.js +18 -0
  11. package/dist/isolated-screens/frame-bridge.d.ts +30 -0
  12. package/dist/isolated-screens/frame-bridge.js +113 -0
  13. package/dist/isolated-screens/frame-component.d.ts +6 -0
  14. package/dist/isolated-screens/frame-component.js +20 -0
  15. package/dist/isolated-screens/frame-document.d.ts +26 -0
  16. package/dist/isolated-screens/frame-document.js +69 -0
  17. package/dist/isolated-screens/frame-policy.d.ts +17 -0
  18. package/dist/isolated-screens/frame-policy.js +230 -0
  19. package/dist/isolated-screens/frame-protocol.d.ts +185 -0
  20. package/dist/isolated-screens/frame-protocol.js +139 -0
  21. package/dist/isolated-screens/frame-pvars.d.ts +33 -0
  22. package/dist/isolated-screens/frame-pvars.js +152 -0
  23. package/dist/isolated-screens/frame-realm.d.ts +12 -0
  24. package/dist/isolated-screens/frame-realm.js +31 -0
  25. package/dist/isolated-screens/frame-runtime.d.ts +5 -0
  26. package/dist/isolated-screens/frame-runtime.js +416 -0
  27. package/dist/isolated-screens/frame-storage.d.ts +43 -0
  28. package/dist/isolated-screens/frame-storage.js +85 -0
  29. package/dist/isolated-screens/index.d.ts +3 -0
  30. package/dist/isolated-screens/index.js +13 -0
  31. package/dist/isolated-screens/isolated-screen.d.ts +191 -0
  32. package/dist/isolated-screens/isolated-screen.js +684 -0
  33. package/dist/isolated-screens/piece-frames.d.ts +27 -0
  34. package/dist/isolated-screens/piece-frames.js +311 -0
  35. package/dist/isolated-screens/piece-reach.d.ts +11 -0
  36. package/dist/isolated-screens/piece-reach.js +56 -0
  37. package/dist/isolated-screens/port-channel.d.ts +47 -0
  38. package/dist/isolated-screens/port-channel.js +153 -0
  39. package/dist/isolated-screens/routes-sandbox.d.ts +8 -0
  40. package/dist/isolated-screens/routes-sandbox.js +130 -0
  41. package/dist/isolated-screens/screen-tab-context.d.ts +4 -0
  42. package/dist/isolated-screens/screen-tab-context.js +6 -0
  43. package/dist/isolated-screens/test-ports.d.ts +3 -0
  44. package/dist/isolated-screens/test-ports.js +21 -0
  45. package/dist/mentions/mentions-client.js +9 -0
  46. package/dist/notifications/index.js +9 -5
  47. package/dist/operator-console/console-copy.d.ts +15 -0
  48. package/dist/operator-console/console-copy.js +97 -0
  49. package/dist/operator-console/console-header.d.ts +33 -0
  50. package/dist/operator-console/console-header.js +67 -0
  51. package/dist/operator-console/console-input.d.ts +20 -0
  52. package/dist/operator-console/console-input.js +313 -0
  53. package/dist/operator-console/console-repl.d.ts +7 -0
  54. package/dist/operator-console/console-repl.js +108 -0
  55. package/dist/operator-console/console-scope.d.ts +45 -0
  56. package/dist/operator-console/console-scope.js +174 -0
  57. package/dist/operator-console/console-screen.d.ts +8 -0
  58. package/dist/operator-console/console-screen.js +32 -0
  59. package/dist/operator-console/console-session.d.ts +106 -0
  60. package/dist/operator-console/console-session.js +567 -0
  61. package/dist/operator-console/console-test-host.d.ts +21 -0
  62. package/dist/operator-console/console-test-host.js +114 -0
  63. package/dist/operator-console/console-theme.d.ts +41 -0
  64. package/dist/operator-console/console-theme.js +55 -0
  65. package/dist/operator-console/console-value.d.ts +27 -0
  66. package/dist/operator-console/console-value.js +291 -0
  67. package/dist/operator-console/operator-console-state.js +3 -1
  68. package/dist/operator-console/operator-console.d.ts +8 -21
  69. package/dist/operator-console/operator-console.js +8 -61
  70. package/dist/root-layout/app-shell-height.d.ts +16 -3
  71. package/dist/root-layout/app-shell-height.js +17 -4
  72. package/dist/root-layout/host-app-menu.d.ts +17 -0
  73. package/dist/root-layout/host-app-menu.js +22 -0
  74. package/dist/root-layout/layouts/full-screen-layout.js +4 -2
  75. package/dist/system-apps/console.app.d.ts +15 -0
  76. package/dist/system-apps/console.app.js +25 -0
  77. package/dist/system-apps/index.d.ts +1 -0
  78. package/dist/system-apps/index.js +6 -1
  79. package/dist/tabs-layout/tabs-layout.js +12 -20
  80. package/dist/tabs-layout/tabs-state.js +39 -16
  81. package/dist/theme.css +32 -5
  82. package/dist/ui-contracts/piece-height.d.ts +18 -0
  83. package/dist/ui-contracts/piece-height.js +15 -0
  84. package/dist/ui-contracts/piece-host.d.ts +24 -1
  85. package/dist/ui-contracts/piece-host.js +53 -2
  86. package/dist/ui-contracts/piece-props.d.ts +16 -0
  87. package/dist/ui-contracts/piece-props.js +39 -0
  88. package/dist/ui-contracts/piece-resolution.d.ts +5 -0
  89. package/dist/ui-contracts/piece-resolution.js +38 -2
  90. package/dist/ui-contracts/piece.d.ts +2 -7
  91. package/dist/ui-contracts/piece.js +22 -37
  92. package/dist/ui-contracts/popover-surface.d.ts +14 -0
  93. package/dist/ui-contracts/popover-surface.js +32 -3
  94. package/dist/ui-inspection/dom-actions.d.ts +23 -0
  95. package/dist/ui-inspection/dom-actions.js +169 -0
  96. package/dist/ui-inspection/dom-inspector.d.ts +20 -0
  97. package/dist/ui-inspection/dom-inspector.js +184 -0
  98. package/dist/ui-inspection/index.d.ts +73 -0
  99. package/dist/ui-inspection/index.js +147 -0
  100. package/dist/ui-router/find-route.d.ts +6 -0
  101. package/dist/ui-router/find-route.js +22 -0
  102. package/dist/ui-router/routes-loader.js +23 -4
  103. package/dist/ui-router/runnable-version.js +3 -0
  104. package/dist/ui-router/ui-loader.d.ts +6 -1
  105. package/dist/ui-router/ui-loader.js +102 -26
  106. package/package.json +3 -3
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The Console's colors, for the active color mode: the panel's chrome and the colors its output
3
+ * shows values in.
4
+ */
5
+ import type React from "react";
6
+ /** Resolved color palette for the console. */
7
+ export interface ConsoleTheme {
8
+ bg: string;
9
+ headerBg: string;
10
+ border: string;
11
+ text: string;
12
+ muted: string;
13
+ hover: string;
14
+ accent: string;
15
+ /** A string value in a tree or a table. */
16
+ string: string;
17
+ /** A number or bigint. */
18
+ number: string;
19
+ /** `true`, `false`, `null`. */
20
+ keyword: string;
21
+ /** An object's key. */
22
+ key: string;
23
+ /** An error's message. */
24
+ error: string;
25
+ /** A warning, and a hint after an error. */
26
+ warn: string;
27
+ }
28
+ /**
29
+ * Resolve the console color palette for the active color mode. Shared by the panel and by
30
+ * the host layout (so its collapsed strip and resize divider match the panel chrome).
31
+ */
32
+ export declare function getConsoleTheme(isDark: boolean): ConsoleTheme;
33
+ /** The console's palette for the color mode now, kept current as it changes. */
34
+ export declare function useConsoleTheme(): ConsoleTheme;
35
+ /** The monospace font the console's input and output use. */
36
+ export declare const CONSOLE_FONT = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", monospace";
37
+ /**
38
+ * Text in the console's output, as written: monospace, wrapped, and without the box the app's
39
+ * own `pre` style draws.
40
+ */
41
+ export declare const CONSOLE_PRE_STYLE: React.CSSProperties;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * The Console's colors, for the active color mode: the panel's chrome and the colors its output
4
+ * shows values in.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.CONSOLE_PRE_STYLE = exports.CONSOLE_FONT = void 0;
8
+ exports.getConsoleTheme = getConsoleTheme;
9
+ exports.useConsoleTheme = useConsoleTheme;
10
+ const hooks_1 = require("../hooks");
11
+ const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
12
+ /**
13
+ * Resolve the console color palette for the active color mode. Shared by the panel and by
14
+ * the host layout (so its collapsed strip and resize divider match the panel chrome).
15
+ */
16
+ function getConsoleTheme(isDark) {
17
+ return {
18
+ bg: isDark ? "#1e1e1e" : "var(--peers-surface-bg)",
19
+ headerBg: isDark ? "#252526" : "var(--bs-body-bg)",
20
+ border: isDark ? "#3c3c3c" : "var(--peers-surface-border)",
21
+ text: isDark ? "#cccccc" : "var(--bs-body-color)",
22
+ muted: isDark ? "#8c8c8c" : "var(--bs-secondary-color)",
23
+ hover: isDark ? "#2a2d2e" : "var(--peers-tab-hover-bg)",
24
+ accent: isDark ? "#0d6efd" : "var(--bs-link-color)",
25
+ string: isDark ? "#ce9178" : "#a31515",
26
+ number: isDark ? "#b5cea8" : "#098658",
27
+ keyword: isDark ? "#569cd6" : "#0000ff",
28
+ key: isDark ? "#9cdcfe" : "#001080",
29
+ error: isDark ? "#f48771" : "var(--bs-danger-text-emphasis)",
30
+ warn: isDark ? "#cca700" : "var(--bs-warning-text-emphasis)",
31
+ };
32
+ }
33
+ /** The console's palette for the color mode now, kept current as it changes. */
34
+ function useConsoleTheme() {
35
+ const [mode] = (0, hooks_1.useObservable)(color_mode_dropdown_1.colorMode);
36
+ return getConsoleTheme(mode === "dark");
37
+ }
38
+ /** The monospace font the console's input and output use. */
39
+ exports.CONSOLE_FONT = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace';
40
+ /**
41
+ * Text in the console's output, as written: monospace, wrapped, and without the box the app's
42
+ * own `pre` style draws.
43
+ */
44
+ exports.CONSOLE_PRE_STYLE = {
45
+ margin: 0,
46
+ padding: 0,
47
+ border: "none",
48
+ borderRadius: 0,
49
+ background: "none",
50
+ fontFamily: exports.CONSOLE_FONT,
51
+ fontSize: "inherit",
52
+ whiteSpace: "pre-wrap",
53
+ wordBreak: "break-word",
54
+ color: "inherit",
55
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * How the Console shows a value: rows as a table, other objects and arrays as a tree you open
3
+ * level by level, a contract, table or tool as what it has (its printout), and a string as its
4
+ * text.
5
+ */
6
+ import React from "react";
7
+ /**
8
+ * A value's own printout, when the REPL gave it one: a contract shows its tables, tools, vars and
9
+ * events; a tool shows how it's called.
10
+ *
11
+ * @param value Any value.
12
+ * @returns The printout, or undefined.
13
+ */
14
+ export declare function printout(value: unknown): string | undefined;
15
+ /** Whether a value is rows: a nonempty array of plain objects. */
16
+ export declare function isRows(value: unknown): value is Record<string, unknown>[];
17
+ /** The value as text for the clipboard: a string as itself, anything else as JSON. */
18
+ export declare function copyText(value: unknown): string;
19
+ /**
20
+ * A value in the Console's output. One that throws while it's shown (a getter, an object with no
21
+ * text form) shows why instead, so the rest of the output stays.
22
+ *
23
+ * @param props.value The value.
24
+ */
25
+ export declare const ConsoleValue: React.FC<{
26
+ value: unknown;
27
+ }>;
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ConsoleValue = void 0;
37
+ exports.printout = printout;
38
+ exports.isRows = isRows;
39
+ exports.copyText = copyText;
40
+ const jsx_runtime_1 = require("react/jsx-runtime");
41
+ /**
42
+ * How the Console shows a value: rows as a table, other objects and arrays as a tree you open
43
+ * level by level, a contract, table or tool as what it has (its printout), and a string as its
44
+ * text.
45
+ */
46
+ const repl_1 = require("@peers-app/peers-sdk/repl");
47
+ const react_1 = __importStar(require("react"));
48
+ const console_theme_1 = require("./console-theme");
49
+ /** A table shows this many rows until "Show all". */
50
+ const ROWS_SHOWN = 50;
51
+ /** A tree level shows this many entries until "Show all". */
52
+ const ENTRIES_SHOWN = 100;
53
+ /** A cell or preview is cut at this many characters. */
54
+ const CELL_CHARS = 60;
55
+ /**
56
+ * A value's own printout, when the REPL gave it one: a contract shows its tables, tools, vars and
57
+ * events; a tool shows how it's called.
58
+ *
59
+ * @param value Any value.
60
+ * @returns The printout, or undefined.
61
+ */
62
+ function printout(value) {
63
+ if (value === null || (typeof value !== "object" && typeof value !== "function"))
64
+ return undefined;
65
+ try {
66
+ const custom = value[repl_1.INSPECT_KEY];
67
+ if (typeof custom !== "function")
68
+ return undefined;
69
+ const text = custom.call(value);
70
+ return typeof text === "string" ? text : undefined;
71
+ }
72
+ catch {
73
+ return undefined;
74
+ }
75
+ }
76
+ /** Whether a value is a plain object: a row, or an object typed at the prompt. */
77
+ function isPlainObject(value) {
78
+ return (Object.prototype.toString.call(value) === "[object Object]" && printout(value) === undefined);
79
+ }
80
+ /** Whether a value is rows: a nonempty array of plain objects. */
81
+ function isRows(value) {
82
+ if (!Array.isArray(value) || value.length === 0)
83
+ return false;
84
+ for (let index = 0, length = value.length; index < length; index++) {
85
+ if (!isPlainObject(value[index]))
86
+ return false;
87
+ }
88
+ return true;
89
+ }
90
+ /** A value's text, or its kind when it has none (`[object Object]` with no prototype). */
91
+ function stringOf(value) {
92
+ try {
93
+ return String(value);
94
+ }
95
+ catch {
96
+ return Object.prototype.toString.call(value);
97
+ }
98
+ }
99
+ /** A value as text in a cell or a preview: JSON for objects, cut to a length. */
100
+ function shortText(value, chars = CELL_CHARS) {
101
+ let text;
102
+ if (value === undefined)
103
+ text = "";
104
+ else if (typeof value === "string")
105
+ text = value;
106
+ else if (typeof value === "bigint")
107
+ text = `${value}n`;
108
+ else if (typeof value === "function")
109
+ text = `ƒ ${value.name || "anonymous"}()`;
110
+ else if (typeof value === "object" && value !== null) {
111
+ try {
112
+ text = JSON.stringify(value) ?? stringOf(value);
113
+ }
114
+ catch {
115
+ text = stringOf(value);
116
+ }
117
+ }
118
+ else
119
+ text = String(value);
120
+ return text.length > chars ? `${text.slice(0, chars - 1)}…` : text;
121
+ }
122
+ /** The value as text for the clipboard: a string as itself, anything else as JSON. */
123
+ function copyText(value) {
124
+ if (typeof value === "string")
125
+ return value;
126
+ const text = printout(value);
127
+ if (text !== undefined)
128
+ return text;
129
+ try {
130
+ return JSON.stringify(value, null, 2) ?? stringOf(value);
131
+ }
132
+ catch {
133
+ return stringOf(value);
134
+ }
135
+ }
136
+ /** A primitive in its color: `undefined`, `null`, `true`, `42`, `"text"`. */
137
+ const Primitive = ({ value, quoted }) => {
138
+ const theme = (0, console_theme_1.useConsoleTheme)();
139
+ if (value === undefined)
140
+ return (0, jsx_runtime_1.jsx)("span", { style: { color: theme.muted }, children: "undefined" });
141
+ if (value === null || typeof value === "boolean")
142
+ return (0, jsx_runtime_1.jsx)("span", { style: { color: theme.keyword }, children: String(value) });
143
+ if (typeof value === "number" || typeof value === "bigint")
144
+ return ((0, jsx_runtime_1.jsx)("span", { style: { color: theme.number }, children: typeof value === "bigint" ? `${value}n` : String(value) }));
145
+ if (typeof value === "string")
146
+ return (0, jsx_runtime_1.jsx)("span", { style: { color: theme.string }, children: quoted ? JSON.stringify(value) : value });
147
+ if (typeof value === "function")
148
+ return (0, jsx_runtime_1.jsx)("span", { style: { color: theme.muted }, children: shortText(value) });
149
+ if (value instanceof Date)
150
+ return ((0, jsx_runtime_1.jsx)("span", { style: { color: theme.string }, children: Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString() }));
151
+ return (0, jsx_runtime_1.jsx)("span", { children: String(value) });
152
+ };
153
+ /** An object's entries, as a tree shows them: an array's items, a Map's or Set's, or own fields. */
154
+ function entriesOf(value) {
155
+ if (Array.isArray(value))
156
+ return value.map((item, index) => [String(index), item]);
157
+ if (value instanceof Map)
158
+ return [...value.entries()].map(([key, item]) => [shortText(key, 40), item]);
159
+ if (value instanceof Set)
160
+ return [...value.values()].map((item, index) => [String(index), item]);
161
+ if (value instanceof Error)
162
+ return [["message", value.message], ...Object.entries(value)];
163
+ return Object.entries(value);
164
+ }
165
+ /** Whether the tree opens a value: an object or array without its own printout, not a Date. */
166
+ function opens(value) {
167
+ return (value !== null &&
168
+ typeof value === "object" &&
169
+ !(value instanceof Date) &&
170
+ printout(value) === undefined);
171
+ }
172
+ /** What a closed object shows: `Array(3)`, `{ taskId: "…", title: "…", … }`. */
173
+ function summary(value, entries) {
174
+ if (Array.isArray(value))
175
+ return `Array(${value.length})`;
176
+ if (value instanceof Map)
177
+ return `Map(${value.size})`;
178
+ if (value instanceof Set)
179
+ return `Set(${value.size})`;
180
+ const shown = entries
181
+ .slice(0, 4)
182
+ .map(([key, item]) => `${key}: ${opens(item) ? "…" : shortText(typeof item === "string" ? JSON.stringify(item) : item, 24)}`);
183
+ const name = value.constructor && value.constructor !== Object ? `${value.constructor.name} ` : "";
184
+ return `${name}{ ${shown.join(", ")}${entries.length > 4 ? ", …" : ""} }`;
185
+ }
186
+ /** One level of a tree: a toggle for an object, a line for anything else. */
187
+ const TreeNode = ({ label, value, depth, theme }) => {
188
+ const [open, setOpen] = (0, react_1.useState)(depth === 0);
189
+ const [all, setAll] = (0, react_1.useState)(false);
190
+ const name = label === undefined ? null : (0, jsx_runtime_1.jsxs)("span", { style: { color: theme.key }, children: [label, ": "] });
191
+ // Text with line breaks (a tool's Markdown) reads as text under its key, not one escaped line.
192
+ if (typeof value === "string" && /[\r\n]/.test(value)) {
193
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [name, (0, jsx_runtime_1.jsx)("pre", { style: { ...console_theme_1.CONSOLE_PRE_STYLE, color: theme.string, paddingLeft: "1.25em" }, children: value })] }));
194
+ }
195
+ if (!opens(value)) {
196
+ const text = printout(value);
197
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [name, text === undefined ? ((0, jsx_runtime_1.jsx)(Primitive, { value: value, quoted: true })) : ((0, jsx_runtime_1.jsx)("span", { style: { color: theme.muted }, children: text.split("\n")[0] }))] }));
198
+ }
199
+ const entries = entriesOf(value);
200
+ const shown = all ? entries : entries.slice(0, ENTRIES_SHOWN);
201
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => setOpen(!open), "aria-expanded": open, style: {
202
+ border: "none",
203
+ background: "none",
204
+ padding: 0,
205
+ color: "inherit",
206
+ font: "inherit",
207
+ cursor: "pointer",
208
+ textAlign: "left",
209
+ }, children: [(0, jsx_runtime_1.jsx)("span", { style: { color: theme.muted, display: "inline-block", width: "1em" }, children: open ? "▾" : "▸" }), name, (0, jsx_runtime_1.jsx)("span", { style: { color: open ? theme.muted : "inherit" }, children: summary(value, entries) })] }), open && ((0, jsx_runtime_1.jsxs)("div", { style: { paddingLeft: "1.25em" }, children: [shown.map(([key, item]) => ((0, jsx_runtime_1.jsx)(TreeNode, { label: key, value: item, depth: depth + 1, theme: theme }, key))), !entries.length && (0, jsx_runtime_1.jsx)("div", { style: { color: theme.muted }, children: "(empty)" }), shown.length < entries.length && ((0, jsx_runtime_1.jsx)(ShowAll, { count: entries.length, onClick: () => setAll(true), theme: theme }))] }))] }));
210
+ };
211
+ const ShowAll = ({ count, onClick, theme, }) => ((0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: onClick, style: {
212
+ border: "none",
213
+ background: "none",
214
+ padding: 0,
215
+ color: theme.accent,
216
+ font: "inherit",
217
+ cursor: "pointer",
218
+ }, children: ["Show all ", count] }));
219
+ /** Rows as a table, with a switch to the tree. */
220
+ const RowsView = ({ rows, theme, }) => {
221
+ const [asTree, setAsTree] = (0, react_1.useState)(false);
222
+ const [all, setAll] = (0, react_1.useState)(false);
223
+ const columns = [...new Set(rows.slice(0, 200).flatMap((row) => Object.keys(row)))];
224
+ const shown = all ? rows : rows.slice(0, ROWS_SHOWN);
225
+ const switchStyle = (active) => ({
226
+ border: "none",
227
+ background: "none",
228
+ padding: "0 6px 0 0",
229
+ font: "inherit",
230
+ cursor: "pointer",
231
+ color: active ? theme.text : theme.accent,
232
+ fontWeight: active ? 600 : 400,
233
+ });
234
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: { color: theme.muted, marginBottom: "2px" }, children: [rows.length, " row", rows.length === 1 ? "" : "s", " \u00B7", " ", (0, jsx_runtime_1.jsx)("button", { type: "button", style: switchStyle(!asTree), onClick: () => setAsTree(false), children: "table" }), (0, jsx_runtime_1.jsx)("button", { type: "button", style: switchStyle(asTree), onClick: () => setAsTree(true), children: "tree" })] }), asTree ? ((0, jsx_runtime_1.jsx)(TreeNode, { value: rows, depth: 0, theme: theme })) : ((0, jsx_runtime_1.jsxs)("div", { style: { overflowX: "auto", maxWidth: "100%" }, children: [(0, jsx_runtime_1.jsxs)("table", { style: { borderCollapse: "collapse", whiteSpace: "nowrap" }, children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsx)("tr", { children: columns.map((column) => ((0, jsx_runtime_1.jsx)("th", { style: {
235
+ textAlign: "left",
236
+ fontWeight: 600,
237
+ padding: "1px 12px 1px 0",
238
+ color: theme.key,
239
+ borderBottom: `1px solid ${theme.border}`,
240
+ }, children: column }, column))) }) }), (0, jsx_runtime_1.jsx)("tbody", { children: shown.map((row, index) => (
241
+ // biome-ignore lint/suspicious/noArrayIndexKey: rows have no key of their own here
242
+ (0, jsx_runtime_1.jsx)("tr", { children: columns.map((column) => {
243
+ const cell = row[column];
244
+ const full = shortText(cell, 2000);
245
+ return ((0, jsx_runtime_1.jsx)("td", { title: full.length > CELL_CHARS ? full : undefined, style: { padding: "1px 12px 1px 0", verticalAlign: "top" }, children: cell === undefined ? null : opens(cell) ? ((0, jsx_runtime_1.jsx)("span", { style: { color: theme.muted }, children: shortText(cell) })) : typeof cell === "string" ? (shortText(cell)) : ((0, jsx_runtime_1.jsx)(Primitive, { value: cell })) }, column));
246
+ }) }, index))) })] }), shown.length < rows.length && ((0, jsx_runtime_1.jsx)(ShowAll, { count: rows.length, onClick: () => setAll(true), theme: theme }))] }))] }));
247
+ };
248
+ /** What shows instead of a value that threw while it was shown, such as from a getter. */
249
+ const Unshowable = ({ error }) => {
250
+ const theme = (0, console_theme_1.useConsoleTheme)();
251
+ let message;
252
+ try {
253
+ message = String(error instanceof Error ? error.message : error);
254
+ }
255
+ catch {
256
+ message = "it threw";
257
+ }
258
+ return (0, jsx_runtime_1.jsxs)("span", { style: { color: theme.error }, children: ["(This value couldn't be shown: ", message, ")"] });
259
+ };
260
+ /** Keeps a value that throws while it renders inside its own entry. */
261
+ class ValueBoundary extends react_1.default.Component {
262
+ state = { failed: false };
263
+ static getDerivedStateFromError(error) {
264
+ return { failed: true, error };
265
+ }
266
+ render() {
267
+ return this.state.failed ? (0, jsx_runtime_1.jsx)(Unshowable, { error: this.state.error }) : this.props.children;
268
+ }
269
+ }
270
+ /**
271
+ * A value in the Console's output. One that throws while it's shown (a getter, an object with no
272
+ * text form) shows why instead, so the rest of the output stays.
273
+ *
274
+ * @param props.value The value.
275
+ */
276
+ const ConsoleValue = ({ value }) => ((0, jsx_runtime_1.jsx)(ValueBoundary, { children: (0, jsx_runtime_1.jsx)(ValueView, { value: value }) }));
277
+ exports.ConsoleValue = ConsoleValue;
278
+ /** A value, by what it is: text, a printout, rows, a tree, or a primitive. */
279
+ const ValueView = ({ value }) => {
280
+ const theme = (0, console_theme_1.useConsoleTheme)();
281
+ if (typeof value === "string")
282
+ return (0, jsx_runtime_1.jsx)("pre", { style: console_theme_1.CONSOLE_PRE_STYLE, children: value === "" ? '""' : value });
283
+ const text = printout(value);
284
+ if (text !== undefined)
285
+ return (0, jsx_runtime_1.jsx)("pre", { style: console_theme_1.CONSOLE_PRE_STYLE, children: text });
286
+ if (isRows(value))
287
+ return (0, jsx_runtime_1.jsx)(RowsView, { rows: value, theme: theme });
288
+ if (opens(value))
289
+ return (0, jsx_runtime_1.jsx)(TreeNode, { value: value, depth: 0, theme: theme });
290
+ return (0, jsx_runtime_1.jsx)(Primitive, { value: value });
291
+ };
@@ -17,6 +17,7 @@ exports.setConsoleSize = setConsoleSize;
17
17
  exports.initializeOperatorConsole = initializeOperatorConsole;
18
18
  const peers_sdk_1 = require("@peers-app/peers-sdk");
19
19
  const command_palette_1 = require("../command-palette/command-palette");
20
+ const frame_realm_1 = require("../isolated-screens/frame-realm");
20
21
  /** Default panel state: collapsed, docked to the bottom. */
21
22
  exports.DEFAULT_CONSOLE_PANEL_STATE = {
22
23
  expanded: false,
@@ -77,7 +78,8 @@ function handleKeyDown(event) {
77
78
  let initialized = false;
78
79
  /** Install the global Ctrl+` listener and register the palette command (idempotent). */
79
80
  function initializeOperatorConsole() {
80
- if (initialized || typeof window === "undefined")
81
+ // Not in an isolated screen's frame: the frame forwards Ctrl+` to the host's console.
82
+ if (initialized || typeof window === "undefined" || (0, frame_realm_1.isInFrame)())
81
83
  return;
82
84
  initialized = true;
83
85
  document.addEventListener("keydown", handleKeyDown);
@@ -1,28 +1,15 @@
1
1
  /**
2
- * Operator Console — presentational panel
2
+ * Operator Console — the panel
3
3
  *
4
- * The console's visual chrome only: a header toolbar (dock buttons, maximize/restore,
5
- * collapse) plus the body region. It fills its container (`height/width: 100%`) and has
6
- * no positioning of its own — the host layout (e.g. the `tabs-with-console` root layout)
7
- * owns the split sizing, the resize handle, the collapsed edge strip, and where the panel
8
- * is placed. Command input, output blocks, and the engine arrive later.
4
+ * The Console's header ({@link ConsoleHeader}: the group it runs in and clear) with the panel's
5
+ * dock, maximize/restore and collapse buttons, over the Console's REPL ({@link ConsoleRepl}), where contracts are globals as at
6
+ * `peers repl`. The panel fills its container (`height/width: 100%`) and has no positioning of
7
+ * its own: the host layout (e.g. the `tabs-with-console` root layout) owns the split sizing, the
8
+ * resize handle, the collapsed edge strip, and where the panel is placed.
9
9
  */
10
10
  import type React from "react";
11
- /** Resolved color palette for the console chrome. */
12
- export interface ConsoleTheme {
13
- bg: string;
14
- headerBg: string;
15
- border: string;
16
- text: string;
17
- muted: string;
18
- hover: string;
19
- accent: string;
20
- }
21
- /**
22
- * Resolve the console color palette for the active color mode. Shared by the panel and by
23
- * the host layout (so its collapsed strip and resize divider match the panel chrome).
24
- */
25
- export declare function getConsoleTheme(isDark: boolean): ConsoleTheme;
11
+ import { type ConsoleTheme, getConsoleTheme } from "./console-theme";
12
+ export { type ConsoleTheme, getConsoleTheme };
26
13
  /**
27
14
  * The Operator Console panel chrome. Renders as an in-flow flex column that fills its
28
15
  * container; the parent layout decides the panel's size and placement. Reads dock and
@@ -1,26 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OperatorConsolePanel = void 0;
4
- exports.getConsoleTheme = getConsoleTheme;
3
+ exports.OperatorConsolePanel = exports.getConsoleTheme = void 0;
5
4
  const jsx_runtime_1 = require("react/jsx-runtime");
6
5
  const hooks_1 = require("../hooks");
7
- const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
6
+ const console_header_1 = require("./console-header");
7
+ const console_repl_1 = require("./console-repl");
8
+ const console_theme_1 = require("./console-theme");
9
+ Object.defineProperty(exports, "getConsoleTheme", { enumerable: true, get: function () { return console_theme_1.getConsoleTheme; } });
8
10
  const operator_console_state_1 = require("./operator-console-state");
9
- /**
10
- * Resolve the console color palette for the active color mode. Shared by the panel and by
11
- * the host layout (so its collapsed strip and resize divider match the panel chrome).
12
- */
13
- function getConsoleTheme(isDark) {
14
- return {
15
- bg: isDark ? "#1e1e1e" : "var(--peers-surface-bg)",
16
- headerBg: isDark ? "#252526" : "var(--bs-body-bg)",
17
- border: isDark ? "#3c3c3c" : "var(--peers-surface-border)",
18
- text: isDark ? "#cccccc" : "var(--bs-body-color)",
19
- muted: isDark ? "#8c8c8c" : "var(--bs-secondary-color)",
20
- hover: isDark ? "#2a2d2e" : "var(--peers-tab-hover-bg)",
21
- accent: isDark ? "#0d6efd" : "var(--bs-link-color)",
22
- };
23
- }
24
11
  /**
25
12
  * The Operator Console panel chrome. Renders as an in-flow flex column that fills its
26
13
  * container; the parent layout decides the panel's size and placement. Reads dock and
@@ -28,9 +15,8 @@ function getConsoleTheme(isDark) {
28
15
  */
29
16
  const OperatorConsolePanel = () => {
30
17
  const [state] = (0, hooks_1.useObservable)(operator_console_state_1.operatorConsolePanel);
31
- const [mode] = (0, hooks_1.useObservable)(color_mode_dropdown_1.colorMode);
18
+ const theme = (0, console_theme_1.useConsoleTheme)();
32
19
  const { dock, maximized } = state;
33
- const theme = getConsoleTheme(mode === "dark");
34
20
  return ((0, jsx_runtime_1.jsxs)("div", { style: {
35
21
  width: "100%",
36
22
  height: "100%",
@@ -39,50 +25,11 @@ const OperatorConsolePanel = () => {
39
25
  display: "flex",
40
26
  flexDirection: "column",
41
27
  overflow: "hidden",
42
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
43
- display: "flex",
44
- alignItems: "center",
45
- justifyContent: "space-between",
46
- height: "34px",
47
- flex: "0 0 auto",
48
- padding: "0 8px",
49
- backgroundColor: theme.headerBg,
50
- borderBottom: `1px solid ${theme.border}`,
51
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "6px", fontSize: "12px" }, children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-terminal" }), (0, jsx_runtime_1.jsx)("span", { style: { fontWeight: 500 }, children: "Console" })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "2px" }, children: [(0, jsx_runtime_1.jsx)(DockButton, { dock: "left", active: dock === "left", disabled: maximized, theme: theme, icon: "bi-arrow-bar-left", label: "Dock left" }), (0, jsx_runtime_1.jsx)(DockButton, { dock: "bottom", active: dock === "bottom", disabled: maximized, theme: theme, icon: "bi-arrow-bar-down", label: "Dock bottom" }), (0, jsx_runtime_1.jsx)(DockButton, { dock: "right", active: dock === "right", disabled: maximized, theme: theme, icon: "bi-arrow-bar-right", label: "Dock right" }), (0, jsx_runtime_1.jsx)("span", { style: { width: "1px", height: "18px", backgroundColor: theme.border, margin: "0 4px" } }), (0, jsx_runtime_1.jsx)(ToolbarButton, { theme: theme, icon: maximized ? "bi-fullscreen-exit" : "bi-arrows-fullscreen", label: maximized ? "Restore" : "Maximize", onClick: () => (0, operator_console_state_1.setConsoleMaximized)(!maximized) }), (0, jsx_runtime_1.jsx)(ToolbarButton, { theme: theme, icon: "bi-chevron-down", label: "Collapse (Ctrl+`)", onClick: operator_console_state_1.toggleConsole })] })] }), (0, jsx_runtime_1.jsx)("div", { style: {
52
- flex: "1 1 auto",
53
- overflow: "auto",
54
- display: "flex",
55
- alignItems: "center",
56
- justifyContent: "center",
57
- color: theme.muted,
58
- fontSize: "13px",
59
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: { textAlign: "center" }, children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-terminal", style: { fontSize: "24px", display: "block", marginBottom: "6px" } }), "Operator Console"] }) })] }));
28
+ }, children: [(0, jsx_runtime_1.jsxs)(console_header_1.ConsoleHeader, { children: [(0, jsx_runtime_1.jsx)("span", { style: { width: "1px", height: "18px", backgroundColor: theme.border, margin: "0 4px" } }), (0, jsx_runtime_1.jsx)(DockButton, { dock: "left", active: dock === "left", disabled: maximized, theme: theme, icon: "bi-arrow-bar-left", label: "Dock left" }), (0, jsx_runtime_1.jsx)(DockButton, { dock: "bottom", active: dock === "bottom", disabled: maximized, theme: theme, icon: "bi-arrow-bar-down", label: "Dock bottom" }), (0, jsx_runtime_1.jsx)(DockButton, { dock: "right", active: dock === "right", disabled: maximized, theme: theme, icon: "bi-arrow-bar-right", label: "Dock right" }), (0, jsx_runtime_1.jsx)("span", { style: { width: "1px", height: "18px", backgroundColor: theme.border, margin: "0 4px" } }), (0, jsx_runtime_1.jsx)(console_header_1.ToolbarButton, { theme: theme, icon: maximized ? "bi-fullscreen-exit" : "bi-arrows-fullscreen", label: maximized ? "Restore" : "Maximize", onClick: () => (0, operator_console_state_1.setConsoleMaximized)(!maximized) }), (0, jsx_runtime_1.jsx)(console_header_1.ToolbarButton, { theme: theme, icon: "bi-chevron-down", label: "Collapse (Ctrl+`)", onClick: operator_console_state_1.toggleConsole })] }), (0, jsx_runtime_1.jsx)("div", { style: { flex: "1 1 auto", minHeight: 0 }, children: (0, jsx_runtime_1.jsx)(console_repl_1.ConsoleRepl, {}) })] }));
60
29
  };
61
30
  exports.OperatorConsolePanel = OperatorConsolePanel;
62
- /** A small, icon-only button used in the console header toolbar. */
63
- function ToolbarButton({ theme, icon, label, onClick, active, disabled }) {
64
- return ((0, jsx_runtime_1.jsx)("button", { type: "button", title: label, "aria-label": label, disabled: disabled, onClick: onClick, style: {
65
- display: "flex",
66
- alignItems: "center",
67
- justifyContent: "center",
68
- width: "28px",
69
- height: "26px",
70
- border: "none",
71
- borderRadius: "4px",
72
- background: active ? theme.hover : "transparent",
73
- color: active ? theme.text : theme.muted,
74
- cursor: disabled ? "not-allowed" : "pointer",
75
- opacity: disabled ? 0.4 : 1,
76
- fontSize: "14px",
77
- }, onMouseEnter: (e) => {
78
- if (!disabled)
79
- e.currentTarget.style.backgroundColor = theme.hover;
80
- }, onMouseLeave: (e) => {
81
- e.currentTarget.style.backgroundColor = active ? theme.hover : "transparent";
82
- }, children: (0, jsx_runtime_1.jsx)("i", { className: icon }) }));
83
- }
84
31
  /** Header button that docks the console to a given edge. */
85
32
  function DockButton({ dock, active, disabled, theme, icon, label }) {
86
- return ((0, jsx_runtime_1.jsx)(ToolbarButton, { theme: theme, icon: icon, label: label, active: active, disabled: disabled, onClick: () => (0, operator_console_state_1.setConsoleDock)(dock) }));
33
+ return ((0, jsx_runtime_1.jsx)(console_header_1.ToolbarButton, { theme: theme, icon: icon, label: label, active: active, disabled: disabled, onClick: () => (0, operator_console_state_1.setConsoleDock)(dock) }));
87
34
  }
88
35
  exports.default = exports.OperatorConsolePanel;
@@ -6,13 +6,26 @@
6
6
  * header and all. The host sets `--peers-shell-top` and `--peers-shell-bottom`: the PWA uses the
7
7
  * device's safe areas (the status bar and home indicator of an installed iOS app). Both default
8
8
  * to none: Electron draws no title bar of its own in the page.
9
+ *
10
+ * The host can also set `--peers-viewport-height`, the screen's height when `100dvh` reports it
11
+ * wrong. An app installed from an iPhone's Home Screen draws the page on the whole screen, but iOS
12
+ * reports `100dvh` short by the status bar's inset (873 of 932 points on iOS 18.6), so the shell
13
+ * stopped that far above the home indicator. There the PWA uses `100lvh`, the whole screen, since
14
+ * an installed app has no browser toolbars.
9
15
  */
10
- export declare const APP_SHELL_HEIGHT = "calc(100dvh - var(--peers-shell-top, 0px) - var(--peers-shell-bottom, 0px))";
16
+ export declare const APP_SHELL_HEIGHT = "calc(var(--peers-viewport-height, 100dvh) - var(--peers-shell-top, 0px) - var(--peers-shell-bottom, 0px))";
11
17
  /**
12
18
  * Room the shell's top strip leaves at its left end for the window's own buttons, which the host
13
- * draws over the page: macOS's red, yellow and green buttons in Electron, which has no title bar
14
- * there. The host sets `--peers-window-controls-left` (none in full screen, where the buttons
19
+ * draws over the page: macOS's red, yellow and green buttons in the desktop app, which has no
20
+ * title bar. The host sets `--peers-window-controls-left` (none in full screen, where the buttons
15
21
  * hide), and adds the `peers-window-draggable` class to `<html>` so the strip's empty space moves
16
22
  * the window (theme.css). Elsewhere it's none.
17
23
  */
18
24
  export declare const WINDOW_CONTROLS_LEFT = "var(--peers-window-controls-left, 0px)";
25
+ /**
26
+ * Room the shell's top strip leaves at its right end for the window's own buttons: minimize,
27
+ * maximize and close in the desktop app on Windows and Linux, which has no title bar either. The
28
+ * host sets `--peers-window-controls-right` (none in full screen) and `peers-window-draggable`,
29
+ * as for {@link WINDOW_CONTROLS_LEFT}. Elsewhere it's none.
30
+ */
31
+ export declare const WINDOW_CONTROLS_RIGHT = "var(--peers-window-controls-right, 0px)";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WINDOW_CONTROLS_LEFT = exports.APP_SHELL_HEIGHT = void 0;
3
+ exports.WINDOW_CONTROLS_RIGHT = exports.WINDOW_CONTROLS_LEFT = exports.APP_SHELL_HEIGHT = void 0;
4
4
  /**
5
5
  * Height of the app shell: the visible viewport less the room the host keeps outside it.
6
6
  *
@@ -9,13 +9,26 @@ exports.WINDOW_CONTROLS_LEFT = exports.APP_SHELL_HEIGHT = void 0;
9
9
  * header and all. The host sets `--peers-shell-top` and `--peers-shell-bottom`: the PWA uses the
10
10
  * device's safe areas (the status bar and home indicator of an installed iOS app). Both default
11
11
  * to none: Electron draws no title bar of its own in the page.
12
+ *
13
+ * The host can also set `--peers-viewport-height`, the screen's height when `100dvh` reports it
14
+ * wrong. An app installed from an iPhone's Home Screen draws the page on the whole screen, but iOS
15
+ * reports `100dvh` short by the status bar's inset (873 of 932 points on iOS 18.6), so the shell
16
+ * stopped that far above the home indicator. There the PWA uses `100lvh`, the whole screen, since
17
+ * an installed app has no browser toolbars.
12
18
  */
13
- exports.APP_SHELL_HEIGHT = "calc(100dvh - var(--peers-shell-top, 0px) - var(--peers-shell-bottom, 0px))";
19
+ exports.APP_SHELL_HEIGHT = "calc(var(--peers-viewport-height, 100dvh) - var(--peers-shell-top, 0px) - var(--peers-shell-bottom, 0px))";
14
20
  /**
15
21
  * Room the shell's top strip leaves at its left end for the window's own buttons, which the host
16
- * draws over the page: macOS's red, yellow and green buttons in Electron, which has no title bar
17
- * there. The host sets `--peers-window-controls-left` (none in full screen, where the buttons
22
+ * draws over the page: macOS's red, yellow and green buttons in the desktop app, which has no
23
+ * title bar. The host sets `--peers-window-controls-left` (none in full screen, where the buttons
18
24
  * hide), and adds the `peers-window-draggable` class to `<html>` so the strip's empty space moves
19
25
  * the window (theme.css). Elsewhere it's none.
20
26
  */
21
27
  exports.WINDOW_CONTROLS_LEFT = "var(--peers-window-controls-left, 0px)";
28
+ /**
29
+ * Room the shell's top strip leaves at its right end for the window's own buttons: minimize,
30
+ * maximize and close in the desktop app on Windows and Linux, which has no title bar either. The
31
+ * host sets `--peers-window-controls-right` (none in full screen) and `peers-window-draggable`,
32
+ * as for {@link WINDOW_CONTROLS_LEFT}. Elsewhere it's none.
33
+ */
34
+ exports.WINDOW_CONTROLS_RIGHT = "var(--peers-window-controls-right, 0px)";