@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.
- package/dist/command-palette/command-palette.js +4 -2
- package/dist/components/router.d.ts +1 -0
- package/dist/components/router.js +4 -1
- package/dist/host-shell/host-shell-consumer.js +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -1
- package/dist/isolated-screens/config.d.ts +51 -0
- package/dist/isolated-screens/config.js +73 -0
- package/dist/isolated-screens/frame-autostart.d.ts +1 -0
- package/dist/isolated-screens/frame-autostart.js +18 -0
- package/dist/isolated-screens/frame-bridge.d.ts +30 -0
- package/dist/isolated-screens/frame-bridge.js +113 -0
- package/dist/isolated-screens/frame-component.d.ts +6 -0
- package/dist/isolated-screens/frame-component.js +20 -0
- package/dist/isolated-screens/frame-document.d.ts +26 -0
- package/dist/isolated-screens/frame-document.js +69 -0
- package/dist/isolated-screens/frame-policy.d.ts +17 -0
- package/dist/isolated-screens/frame-policy.js +230 -0
- package/dist/isolated-screens/frame-protocol.d.ts +185 -0
- package/dist/isolated-screens/frame-protocol.js +139 -0
- package/dist/isolated-screens/frame-pvars.d.ts +33 -0
- package/dist/isolated-screens/frame-pvars.js +152 -0
- package/dist/isolated-screens/frame-realm.d.ts +12 -0
- package/dist/isolated-screens/frame-realm.js +31 -0
- package/dist/isolated-screens/frame-runtime.d.ts +5 -0
- package/dist/isolated-screens/frame-runtime.js +416 -0
- package/dist/isolated-screens/frame-storage.d.ts +43 -0
- package/dist/isolated-screens/frame-storage.js +85 -0
- package/dist/isolated-screens/index.d.ts +3 -0
- package/dist/isolated-screens/index.js +13 -0
- package/dist/isolated-screens/isolated-screen.d.ts +191 -0
- package/dist/isolated-screens/isolated-screen.js +684 -0
- package/dist/isolated-screens/piece-frames.d.ts +27 -0
- package/dist/isolated-screens/piece-frames.js +311 -0
- package/dist/isolated-screens/piece-reach.d.ts +11 -0
- package/dist/isolated-screens/piece-reach.js +56 -0
- package/dist/isolated-screens/port-channel.d.ts +47 -0
- package/dist/isolated-screens/port-channel.js +153 -0
- package/dist/isolated-screens/routes-sandbox.d.ts +8 -0
- package/dist/isolated-screens/routes-sandbox.js +130 -0
- package/dist/isolated-screens/screen-tab-context.d.ts +4 -0
- package/dist/isolated-screens/screen-tab-context.js +6 -0
- package/dist/isolated-screens/test-ports.d.ts +3 -0
- package/dist/isolated-screens/test-ports.js +21 -0
- package/dist/mentions/mentions-client.js +9 -0
- package/dist/notifications/index.js +9 -5
- package/dist/operator-console/console-copy.d.ts +15 -0
- package/dist/operator-console/console-copy.js +97 -0
- package/dist/operator-console/console-header.d.ts +33 -0
- package/dist/operator-console/console-header.js +67 -0
- package/dist/operator-console/console-input.d.ts +20 -0
- package/dist/operator-console/console-input.js +313 -0
- package/dist/operator-console/console-repl.d.ts +7 -0
- package/dist/operator-console/console-repl.js +108 -0
- package/dist/operator-console/console-scope.d.ts +45 -0
- package/dist/operator-console/console-scope.js +174 -0
- package/dist/operator-console/console-screen.d.ts +8 -0
- package/dist/operator-console/console-screen.js +32 -0
- package/dist/operator-console/console-session.d.ts +106 -0
- package/dist/operator-console/console-session.js +567 -0
- package/dist/operator-console/console-test-host.d.ts +21 -0
- package/dist/operator-console/console-test-host.js +114 -0
- package/dist/operator-console/console-theme.d.ts +41 -0
- package/dist/operator-console/console-theme.js +55 -0
- package/dist/operator-console/console-value.d.ts +27 -0
- package/dist/operator-console/console-value.js +291 -0
- package/dist/operator-console/operator-console-state.js +3 -1
- package/dist/operator-console/operator-console.d.ts +8 -21
- package/dist/operator-console/operator-console.js +8 -61
- package/dist/root-layout/app-shell-height.d.ts +16 -3
- package/dist/root-layout/app-shell-height.js +17 -4
- package/dist/root-layout/host-app-menu.d.ts +17 -0
- package/dist/root-layout/host-app-menu.js +22 -0
- package/dist/root-layout/layouts/full-screen-layout.js +4 -2
- package/dist/system-apps/console.app.d.ts +15 -0
- package/dist/system-apps/console.app.js +25 -0
- package/dist/system-apps/index.d.ts +1 -0
- package/dist/system-apps/index.js +6 -1
- package/dist/tabs-layout/tabs-layout.js +12 -20
- package/dist/tabs-layout/tabs-state.js +39 -16
- package/dist/theme.css +32 -5
- package/dist/ui-contracts/piece-height.d.ts +18 -0
- package/dist/ui-contracts/piece-height.js +15 -0
- package/dist/ui-contracts/piece-host.d.ts +24 -1
- package/dist/ui-contracts/piece-host.js +53 -2
- package/dist/ui-contracts/piece-props.d.ts +16 -0
- package/dist/ui-contracts/piece-props.js +39 -0
- package/dist/ui-contracts/piece-resolution.d.ts +5 -0
- package/dist/ui-contracts/piece-resolution.js +38 -2
- package/dist/ui-contracts/piece.d.ts +2 -7
- package/dist/ui-contracts/piece.js +22 -37
- package/dist/ui-contracts/popover-surface.d.ts +14 -0
- package/dist/ui-contracts/popover-surface.js +32 -3
- package/dist/ui-inspection/dom-actions.d.ts +23 -0
- package/dist/ui-inspection/dom-actions.js +169 -0
- package/dist/ui-inspection/dom-inspector.d.ts +20 -0
- package/dist/ui-inspection/dom-inspector.js +184 -0
- package/dist/ui-inspection/index.d.ts +73 -0
- package/dist/ui-inspection/index.js +147 -0
- package/dist/ui-router/find-route.d.ts +6 -0
- package/dist/ui-router/find-route.js +22 -0
- package/dist/ui-router/routes-loader.js +23 -4
- package/dist/ui-router/runnable-version.js +3 -0
- package/dist/ui-router/ui-loader.d.ts +6 -1
- package/dist/ui-router/ui-loader.js +102 -26
- package/package.json +3 -3
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateRoutesBundle = evaluateRoutesBundle;
|
|
4
|
+
const frame_document_1 = require("./frame-document");
|
|
5
|
+
const port_channel_1 = require("./port-channel");
|
|
6
|
+
/** The routes frame's script: stand-in globals, and evaluating each bundle it's sent. */
|
|
7
|
+
const ROUTES_SCRIPT = `
|
|
8
|
+
(function () {
|
|
9
|
+
function stub() {
|
|
10
|
+
var fn = function () { return proxy; };
|
|
11
|
+
var proxy = new Proxy(fn, {
|
|
12
|
+
get: function (_t, key) {
|
|
13
|
+
if (key === Symbol.toPrimitive) return function () { return ""; };
|
|
14
|
+
if (key === "then") return undefined;
|
|
15
|
+
return proxy;
|
|
16
|
+
},
|
|
17
|
+
apply: function () { return proxy; },
|
|
18
|
+
construct: function () { return proxy; },
|
|
19
|
+
});
|
|
20
|
+
return proxy;
|
|
21
|
+
}
|
|
22
|
+
["React", "PeersSDK", "PeersUI", "zod"].forEach(function (name) { window[name] = stub(); });
|
|
23
|
+
var FIELDS = ["peersUIId", "path", "uiCategory", "uiSubcategory", "uiEditMode", "priority", "opensAnyGroup"];
|
|
24
|
+
function clean(route) {
|
|
25
|
+
var out = {};
|
|
26
|
+
if (!route || typeof route !== "object") return out;
|
|
27
|
+
FIELDS.forEach(function (field) {
|
|
28
|
+
var value;
|
|
29
|
+
try { value = route[field]; } catch (e) { return; }
|
|
30
|
+
var type = typeof value;
|
|
31
|
+
if (type === "string" || type === "number" || type === "boolean") out[field] = value;
|
|
32
|
+
});
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
function start(port) {
|
|
36
|
+
port.onmessage = function (event) {
|
|
37
|
+
var request = event.data || {};
|
|
38
|
+
if (request.kind !== "request") return;
|
|
39
|
+
var code = request.payload && request.payload.code;
|
|
40
|
+
var routes = [];
|
|
41
|
+
try {
|
|
42
|
+
var exportRoutes = function (exported) {
|
|
43
|
+
var list = exported && exported.routes;
|
|
44
|
+
if (list && typeof list.length === "number") {
|
|
45
|
+
for (var i = 0; i < list.length; i++) routes.push(clean(list[i]));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
new Function("exportRoutes", String(code))(exportRoutes);
|
|
49
|
+
port.postMessage({ kind: "response", id: request.id, ok: true, value: routes });
|
|
50
|
+
} catch (error) {
|
|
51
|
+
port.postMessage({ kind: "response", id: request.id, ok: false, error: String(error && error.message || error) });
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var booted = false;
|
|
56
|
+
addEventListener("message", function (event) {
|
|
57
|
+
var data = event.data;
|
|
58
|
+
if (booted || event.source !== parent || !data || data.type !== "${frame_document_1.FRAME_BOOT}") return;
|
|
59
|
+
booted = true;
|
|
60
|
+
start(event.ports[0]);
|
|
61
|
+
});
|
|
62
|
+
parent.postMessage({ type: "${frame_document_1.FRAME_HELLO}" }, "*");
|
|
63
|
+
})();
|
|
64
|
+
`;
|
|
65
|
+
function routesDocument() {
|
|
66
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${frame_document_1.FRAME_CSP}"></head><body><script>${ROUTES_SCRIPT}</script></body></html>`;
|
|
67
|
+
}
|
|
68
|
+
let sandbox;
|
|
69
|
+
/** Make the routes frame, once, and wait for it to boot. */
|
|
70
|
+
function routesSandbox() {
|
|
71
|
+
sandbox ??= new Promise((resolve, reject) => {
|
|
72
|
+
const frame = document.createElement("iframe");
|
|
73
|
+
frame.setAttribute("sandbox", "allow-scripts");
|
|
74
|
+
frame.setAttribute("aria-hidden", "true");
|
|
75
|
+
frame.setAttribute("data-peers-routes-sandbox", "");
|
|
76
|
+
frame.style.display = "none";
|
|
77
|
+
let channel;
|
|
78
|
+
const onMessage = (event) => {
|
|
79
|
+
if (event.source !== frame.contentWindow)
|
|
80
|
+
return;
|
|
81
|
+
if (event.data?.type !== frame_document_1.FRAME_HELLO)
|
|
82
|
+
return;
|
|
83
|
+
if (channel) {
|
|
84
|
+
// Its document was replaced: start again with a new frame.
|
|
85
|
+
console.warn("[routes] the routes sandbox's document was replaced; making a new one");
|
|
86
|
+
window.removeEventListener("message", onMessage);
|
|
87
|
+
channel.close();
|
|
88
|
+
frame.remove();
|
|
89
|
+
sandbox = undefined;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const { port1, port2 } = new MessageChannel();
|
|
93
|
+
channel = (0, port_channel_1.openPortChannel)(port1);
|
|
94
|
+
frame.contentWindow?.postMessage({ type: frame_document_1.FRAME_BOOT }, "*", [port2]);
|
|
95
|
+
resolve(channel);
|
|
96
|
+
};
|
|
97
|
+
window.addEventListener("message", onMessage);
|
|
98
|
+
frame.srcdoc = routesDocument();
|
|
99
|
+
const attach = () => document.body.appendChild(frame);
|
|
100
|
+
if (document.body)
|
|
101
|
+
attach();
|
|
102
|
+
else
|
|
103
|
+
window.addEventListener("DOMContentLoaded", attach, { once: true });
|
|
104
|
+
setTimeout(() => {
|
|
105
|
+
if (channel)
|
|
106
|
+
return;
|
|
107
|
+
window.removeEventListener("DOMContentLoaded", attach);
|
|
108
|
+
window.removeEventListener("message", onMessage);
|
|
109
|
+
frame.remove();
|
|
110
|
+
reject(new Error("The routes sandbox didn't start"));
|
|
111
|
+
}, 15_000);
|
|
112
|
+
}).catch((error) => {
|
|
113
|
+
sandbox = undefined;
|
|
114
|
+
throw error;
|
|
115
|
+
});
|
|
116
|
+
return sandbox;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Run one package's routes bundle in the sandbox and return its routes, stamped with the package.
|
|
120
|
+
*
|
|
121
|
+
* @param packageId - The package whose bundle it is.
|
|
122
|
+
* @param code - The bundle, checked by the caller.
|
|
123
|
+
*/
|
|
124
|
+
async function evaluateRoutesBundle(packageId, code) {
|
|
125
|
+
const channel = await routesSandbox();
|
|
126
|
+
const routes = (await channel.request("routes", { code })) ?? [];
|
|
127
|
+
return routes
|
|
128
|
+
.filter((route) => typeof route.peersUIId === "string" && route.peersUIId)
|
|
129
|
+
.map((route) => ({ ...route, packageId }));
|
|
130
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScreenTabContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/** The tab a package screen shows in, for its isolated frame to navigate and title. */
|
|
6
|
+
exports.ScreenTabContext = (0, react_1.createContext)(undefined);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.portPair = portPair;
|
|
4
|
+
const node_v8_1 = require("node:v8");
|
|
5
|
+
/** Two connected ports for tests: what one posts, the other's listeners get, a tick later. */
|
|
6
|
+
function portPair() {
|
|
7
|
+
const listeners = [new Set(), new Set()];
|
|
8
|
+
const make = (mine, theirs) => ({
|
|
9
|
+
postMessage: (message) => {
|
|
10
|
+
// A structured clone, as a real port makes.
|
|
11
|
+
const data = (0, node_v8_1.deserialize)((0, node_v8_1.serialize)(message));
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
for (const listener of theirs)
|
|
14
|
+
listener({ data });
|
|
15
|
+
}, 0);
|
|
16
|
+
},
|
|
17
|
+
addEventListener: (_type, listener) => mine.add(listener),
|
|
18
|
+
removeEventListener: (_type, listener) => mine.delete(listener),
|
|
19
|
+
});
|
|
20
|
+
return [make(listeners[0], listeners[1]), make(listeners[1], listeners[0])];
|
|
21
|
+
}
|
|
@@ -9,6 +9,8 @@ exports.resolveMentionPlace = resolveMentionPlace;
|
|
|
9
9
|
exports.openMentionPlace = openMentionPlace;
|
|
10
10
|
exports.openMention = openMention;
|
|
11
11
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
12
|
+
const frame_protocol_1 = require("../isolated-screens/frame-protocol");
|
|
13
|
+
const frame_realm_1 = require("../isolated-screens/frame-realm");
|
|
12
14
|
const tabs_state_1 = require("../tabs-layout/tabs-state");
|
|
13
15
|
const open_in_group_1 = require("../ui-router/open-in-group");
|
|
14
16
|
const mention_chooser_1 = require("./mention-chooser");
|
|
@@ -216,6 +218,13 @@ async function openMentionPlace(place) {
|
|
|
216
218
|
* @param groupId - The document's group.
|
|
217
219
|
*/
|
|
218
220
|
async function openMention(ref, groupId) {
|
|
221
|
+
// An isolated screen asks its host: the host resolves the mention and, when it's in more than
|
|
222
|
+
// one place, asks the user which, above every screen.
|
|
223
|
+
const host = (0, frame_realm_1.frameHost)();
|
|
224
|
+
if (host) {
|
|
225
|
+
await host.request(frame_protocol_1.FrameRequest.openMention, { ref, groupId });
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
219
228
|
const consumer = await exports.mentionsContract.get();
|
|
220
229
|
const { results } = await consumer.tools.resolve({
|
|
221
230
|
refs: [ref],
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useNotificationSummary = exports.openNotificationById = exports.openNotification = exports.notificationsContract = exports.NOTIFICATIONS_PATH = exports.NotificationBell = void 0;
|
|
4
4
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
5
|
+
const frame_realm_1 = require("../isolated-screens/frame-realm");
|
|
5
6
|
const notifications_client_1 = require("./notifications-client");
|
|
6
7
|
require("./notifications-screen");
|
|
7
8
|
require("./priority-alert");
|
|
@@ -13,8 +14,11 @@ Object.defineProperty(exports, "notificationsContract", { enumerable: true, get:
|
|
|
13
14
|
Object.defineProperty(exports, "openNotification", { enumerable: true, get: function () { return notifications_client_2.openNotification; } });
|
|
14
15
|
Object.defineProperty(exports, "openNotificationById", { enumerable: true, get: function () { return notifications_client_2.openNotificationById; } });
|
|
15
16
|
Object.defineProperty(exports, "useNotificationSummary", { enumerable: true, get: function () { return notifications_client_2.useNotificationSummary; } });
|
|
16
|
-
// A notification clicked in the desktop app's main process opens what it's about here
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
// A notification clicked in the desktop app's main process opens what it's about here: in the
|
|
18
|
+
// host's window, not in an isolated screen's frame.
|
|
19
|
+
if (!(0, frame_realm_1.isInFrame)()) {
|
|
20
|
+
(0, peers_sdk_1.subscribe)("ui:openNotification", (event) => {
|
|
21
|
+
if (event.data?.notificationId)
|
|
22
|
+
void (0, notifications_client_1.openNotificationById)(event.data.notificationId);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Console entry keeps for showing a result: a copy, when the result is only data, so the
|
|
3
|
+
* entry shows it as it was when it ran.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The value an entry keeps for showing: a copy of a result that's only data, so the entry keeps
|
|
7
|
+
* showing it as it was when it ran, as a printed line would, after a later line changes it
|
|
8
|
+
* (`t.status = "Canceled"`). The code's own variables and `$` still hold the original. Anything
|
|
9
|
+
* else (a contract, a tool, a function, a class instance, a map, something with a getter, or
|
|
10
|
+
* something too big or too deep to copy) is kept as it is, and shows as it is now.
|
|
11
|
+
*
|
|
12
|
+
* @param value A result, or a printed value.
|
|
13
|
+
* @returns The copy, or the value itself.
|
|
14
|
+
*/
|
|
15
|
+
export declare function asItWas(value: unknown): unknown;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What a Console entry keeps for showing a result: a copy, when the result is only data, so the
|
|
4
|
+
* entry shows it as it was when it ran.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.asItWas = asItWas;
|
|
8
|
+
/** A result with more parts than this isn't copied for its entry, and shows as it is now. */
|
|
9
|
+
const COPIED_PARTS = 2_000_000;
|
|
10
|
+
/** What a part that isn't data copies to: the whole value is then kept as it is. */
|
|
11
|
+
const NOT_DATA = Symbol("not data");
|
|
12
|
+
/** How many prototypes an object has: none, 1 for a plain object, 2 for an array or a date. */
|
|
13
|
+
function prototypeDepth(value) {
|
|
14
|
+
let depth = 0;
|
|
15
|
+
for (let prototype = Object.getPrototypeOf(value); prototype;) {
|
|
16
|
+
depth++;
|
|
17
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
18
|
+
}
|
|
19
|
+
return depth;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A copy of a value that's only data: primitives (not symbols), dates, arrays, and plain objects
|
|
23
|
+
* whose properties are values, not getters. Checked by tag and prototype depth, not `instanceof`,
|
|
24
|
+
* so a value from another realm is still data, and a class instance or an Array subclass isn't.
|
|
25
|
+
*
|
|
26
|
+
* @param value The value, or a part of it.
|
|
27
|
+
* @param copies Each object already copied, by the original, so a cycle copies as a cycle.
|
|
28
|
+
* @param budget The parts left to copy.
|
|
29
|
+
* @returns The copy, or {@link NOT_DATA}.
|
|
30
|
+
*/
|
|
31
|
+
function copyOf(value, copies, budget) {
|
|
32
|
+
if (typeof value === "function" || typeof value === "symbol")
|
|
33
|
+
return NOT_DATA;
|
|
34
|
+
if (typeof value !== "object" || value === null)
|
|
35
|
+
return value;
|
|
36
|
+
if (copies.has(value))
|
|
37
|
+
return copies.get(value);
|
|
38
|
+
if (--budget.parts < 0 || Object.getOwnPropertySymbols(value).length)
|
|
39
|
+
return NOT_DATA;
|
|
40
|
+
const tag = Object.prototype.toString.call(value);
|
|
41
|
+
if (tag === "[object Date]") {
|
|
42
|
+
if (prototypeDepth(value) !== 2)
|
|
43
|
+
return NOT_DATA;
|
|
44
|
+
const date = new Date(Date.prototype.getTime.call(value));
|
|
45
|
+
copies.set(value, date);
|
|
46
|
+
return date;
|
|
47
|
+
}
|
|
48
|
+
let copy;
|
|
49
|
+
if (tag === "[object Array]" && prototypeDepth(value) === 2)
|
|
50
|
+
copy = new Array(value.length);
|
|
51
|
+
else if (tag === "[object Object]" && prototypeDepth(value) <= 1)
|
|
52
|
+
copy = Object.getPrototypeOf(value) === null ? Object.create(null) : {};
|
|
53
|
+
else
|
|
54
|
+
return NOT_DATA;
|
|
55
|
+
copies.set(value, copy);
|
|
56
|
+
for (const key of Object.keys(value)) {
|
|
57
|
+
const property = Object.getOwnPropertyDescriptor(value, key);
|
|
58
|
+
if (!property || !("value" in property))
|
|
59
|
+
return NOT_DATA;
|
|
60
|
+
const part = copyOf(property.value, copies, budget);
|
|
61
|
+
if (part === NOT_DATA)
|
|
62
|
+
return NOT_DATA;
|
|
63
|
+
// Defined, not assigned, so a `__proto__` key stays a key.
|
|
64
|
+
if (key === "__proto__")
|
|
65
|
+
Object.defineProperty(copy, key, {
|
|
66
|
+
value: part,
|
|
67
|
+
writable: true,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
});
|
|
71
|
+
else
|
|
72
|
+
copy[key] = part;
|
|
73
|
+
}
|
|
74
|
+
return copy;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The value an entry keeps for showing: a copy of a result that's only data, so the entry keeps
|
|
78
|
+
* showing it as it was when it ran, as a printed line would, after a later line changes it
|
|
79
|
+
* (`t.status = "Canceled"`). The code's own variables and `$` still hold the original. Anything
|
|
80
|
+
* else (a contract, a tool, a function, a class instance, a map, something with a getter, or
|
|
81
|
+
* something too big or too deep to copy) is kept as it is, and shows as it is now.
|
|
82
|
+
*
|
|
83
|
+
* @param value A result, or a printed value.
|
|
84
|
+
* @returns The copy, or the value itself.
|
|
85
|
+
*/
|
|
86
|
+
function asItWas(value) {
|
|
87
|
+
if (typeof value !== "object" || value === null)
|
|
88
|
+
return value;
|
|
89
|
+
try {
|
|
90
|
+
const copy = copyOf(value, new Map(), { parts: COPIED_PARTS });
|
|
91
|
+
return copy === NOT_DATA ? value : copy;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Too deep to copy without running out of stack.
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Console's header bar, shared by the panel and the Console app: the title, the group the
|
|
3
|
+
* Console runs in, and a clear button, with room for a surface's own buttons after them.
|
|
4
|
+
*/
|
|
5
|
+
import type React from "react";
|
|
6
|
+
/** The colors a header button needs. */
|
|
7
|
+
export interface ButtonTheme {
|
|
8
|
+
text: string;
|
|
9
|
+
muted: string;
|
|
10
|
+
hover: string;
|
|
11
|
+
}
|
|
12
|
+
/** What a header button shows and does. */
|
|
13
|
+
export interface ToolbarButtonProps {
|
|
14
|
+
theme: ButtonTheme;
|
|
15
|
+
/** A Bootstrap icon class: `bi-slash-circle`. */
|
|
16
|
+
icon: string;
|
|
17
|
+
/** Its tooltip and accessible name. */
|
|
18
|
+
label: string;
|
|
19
|
+
onClick: () => void;
|
|
20
|
+
active?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** A small, icon-only button in the Console's header. */
|
|
24
|
+
export declare function ToolbarButton({ theme, icon, label, onClick, active, disabled, }: ToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* The header: "Console", the group its calls run in, and the clear button, then `children` (the
|
|
27
|
+
* panel's dock, maximize and collapse buttons).
|
|
28
|
+
*
|
|
29
|
+
* @param props.children Buttons after the clear button.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ConsoleHeader: React.FC<{
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleHeader = void 0;
|
|
4
|
+
exports.ToolbarButton = ToolbarButton;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const hooks_1 = require("../hooks");
|
|
7
|
+
const console_session_1 = require("./console-session");
|
|
8
|
+
const console_theme_1 = require("./console-theme");
|
|
9
|
+
/** A small, icon-only button in the Console's header. */
|
|
10
|
+
function ToolbarButton({ theme, icon, label, onClick, active, disabled, }) {
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)("button", { type: "button", title: label, "aria-label": label, disabled: disabled, onClick: onClick, style: {
|
|
12
|
+
display: "flex",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
width: "28px",
|
|
16
|
+
height: "26px",
|
|
17
|
+
border: "none",
|
|
18
|
+
borderRadius: "4px",
|
|
19
|
+
background: active ? theme.hover : "transparent",
|
|
20
|
+
color: active ? theme.text : theme.muted,
|
|
21
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
22
|
+
opacity: disabled ? 0.4 : 1,
|
|
23
|
+
fontSize: "14px",
|
|
24
|
+
}, onMouseEnter: (e) => {
|
|
25
|
+
if (!disabled)
|
|
26
|
+
e.currentTarget.style.backgroundColor = theme.hover;
|
|
27
|
+
}, onMouseLeave: (e) => {
|
|
28
|
+
e.currentTarget.style.backgroundColor = active ? theme.hover : "transparent";
|
|
29
|
+
}, children: (0, jsx_runtime_1.jsx)("i", { className: icon }) }));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The header: "Console", the group its calls run in, and the clear button, then `children` (the
|
|
33
|
+
* panel's dock, maximize and collapse buttons).
|
|
34
|
+
*
|
|
35
|
+
* @param props.children Buttons after the clear button.
|
|
36
|
+
*/
|
|
37
|
+
const ConsoleHeader = ({ children }) => {
|
|
38
|
+
const [context] = (0, hooks_1.useObservable)(console_session_1.consoleContext);
|
|
39
|
+
const theme = (0, console_theme_1.useConsoleTheme)();
|
|
40
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
41
|
+
display: "flex",
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
justifyContent: "space-between",
|
|
44
|
+
height: "34px",
|
|
45
|
+
flex: "0 0 auto",
|
|
46
|
+
padding: "0 8px",
|
|
47
|
+
backgroundColor: theme.headerBg,
|
|
48
|
+
borderBottom: `1px solid ${theme.border}`,
|
|
49
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
50
|
+
display: "flex",
|
|
51
|
+
alignItems: "center",
|
|
52
|
+
gap: "6px",
|
|
53
|
+
fontSize: "12px",
|
|
54
|
+
minWidth: 0,
|
|
55
|
+
whiteSpace: "nowrap",
|
|
56
|
+
}, 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.jsx)("span", { title: `${context}: the group the Console's calls run in. use("Home") moves it to Home.`, style: {
|
|
57
|
+
color: theme.muted,
|
|
58
|
+
border: `1px solid ${theme.border}`,
|
|
59
|
+
borderRadius: "8px",
|
|
60
|
+
padding: "0 6px",
|
|
61
|
+
lineHeight: "16px",
|
|
62
|
+
minWidth: 0,
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
textOverflow: "ellipsis",
|
|
65
|
+
}, children: context })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "2px", flex: "0 0 auto" }, children: [(0, jsx_runtime_1.jsx)(ToolbarButton, { theme: theme, icon: "bi-slash-circle", label: "Clear (Ctrl+L)", onClick: () => (0, console_session_1.clearConsole)() }), children] })] }));
|
|
66
|
+
};
|
|
67
|
+
exports.ConsoleHeader = ConsoleHeader;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Console's input: code with completion, a grey line saying which argument the cursor is at
|
|
3
|
+
* (`describeTask(taskId, subtaskDepth?, …)`, with the field a value fills in bold), and history.
|
|
4
|
+
*
|
|
5
|
+
* Keys: Enter runs (and adds a line while a bracket is still open); Shift+Enter adds a line; Tab
|
|
6
|
+
* completes; ↑ and ↓ move through the completions when they're open, and through history on the
|
|
7
|
+
* first and last line; Escape closes the completions; Ctrl+L clears the output; Ctrl+C with
|
|
8
|
+
* nothing selected empties the input.
|
|
9
|
+
*/
|
|
10
|
+
import type React from "react";
|
|
11
|
+
/**
|
|
12
|
+
* The Console's input line.
|
|
13
|
+
*
|
|
14
|
+
* @param props.context The data context's name, shown as the prompt.
|
|
15
|
+
* @param props.ready Whether the contracts are loaded: completion waits for them.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ConsoleInput: React.ForwardRefExoticComponent<{
|
|
18
|
+
context: string;
|
|
19
|
+
ready: boolean;
|
|
20
|
+
} & React.RefAttributes<HTMLTextAreaElement>>;
|