@peers-app/peers-ui 0.33.24 → 0.34.1
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 +28 -0
- package/dist/isolated-screens/frame-document.js +77 -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 +196 -0
- package/dist/isolated-screens/frame-protocol.js +150 -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 +494 -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 +193 -0
- package/dist/isolated-screens/isolated-screen.js +695 -0
- package/dist/isolated-screens/piece-frames.d.ts +27 -0
- package/dist/isolated-screens/piece-frames.js +351 -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/isolated-screens/wheel-relay.d.ts +48 -0
- package/dist/isolated-screens/wheel-relay.js +186 -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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wheel across a piece's frame. The host draws a piece that a framed screen embeds over the
|
|
3
|
+
* screen's slot, in a frame of its own beside the screen's frame, not inside it. A wheel the piece
|
|
4
|
+
* doesn't scroll with would chain to the host's window, never to the screen under it, so the
|
|
5
|
+
* piece's frame sends it to the host, the host hands it to the screen, and the screen scrolls the
|
|
6
|
+
* boxes around the slot as the browser would have.
|
|
7
|
+
*/
|
|
8
|
+
/** One axis of a wheel. */
|
|
9
|
+
export type WheelAxis = "x" | "y";
|
|
10
|
+
/**
|
|
11
|
+
* A relayed wheel's movement along one axis, as a finite number of pixels within bounds, or 0.
|
|
12
|
+
*
|
|
13
|
+
* @param value - What the sender gave.
|
|
14
|
+
*/
|
|
15
|
+
export declare function wheelDelta(value: unknown): number;
|
|
16
|
+
/**
|
|
17
|
+
* A wheel event's movement, in pixels, along the axes the browser scrolls with it. Off Apple's
|
|
18
|
+
* systems, Chromium scrolls sideways for a vertical wheel turned with Shift held, though the event
|
|
19
|
+
* still says vertical; on Apple's systems a mouse's wheel with Shift held already arrives sideways,
|
|
20
|
+
* and a trackpad scrolls the way it moves.
|
|
21
|
+
*
|
|
22
|
+
* @param event - The wheel.
|
|
23
|
+
*/
|
|
24
|
+
export declare function wheelPixels(event: WheelEvent): {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* What a wheel along one axis scrolls, from `start` outward, as the browser chains it: the first
|
|
30
|
+
* box the user can scroll that can still move that way, or `"contained"` when a scrolling box on
|
|
31
|
+
* the way is at its edge and stops the wheel there (`overscroll-behavior: contain` or `none`), or
|
|
32
|
+
* nothing when no box takes it.
|
|
33
|
+
*
|
|
34
|
+
* @param start - The element under the pointer.
|
|
35
|
+
* @param axis - The axis.
|
|
36
|
+
* @param delta - Which way, and how far: down or right when positive.
|
|
37
|
+
*/
|
|
38
|
+
export declare function wheelScroller(start: Element | null, axis: WheelAxis, delta: number): Element | "contained" | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* In a framed screen: scroll as a wheel over the piece drawn on `slot` would have, had the piece
|
|
41
|
+
* been in the screen's document. Each axis moves the first box around the slot that can still
|
|
42
|
+
* move that way.
|
|
43
|
+
*
|
|
44
|
+
* @param slot - The slot the piece is drawn over.
|
|
45
|
+
* @param deltaX - Pixels to the right (negative: to the left).
|
|
46
|
+
* @param deltaY - Pixels down (negative: up).
|
|
47
|
+
*/
|
|
48
|
+
export declare function scrollAroundSlot(slot: Element, deltaX: number, deltaY: number): void;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The wheel across a piece's frame. The host draws a piece that a framed screen embeds over the
|
|
4
|
+
* screen's slot, in a frame of its own beside the screen's frame, not inside it. A wheel the piece
|
|
5
|
+
* doesn't scroll with would chain to the host's window, never to the screen under it, so the
|
|
6
|
+
* piece's frame sends it to the host, the host hands it to the screen, and the screen scrolls the
|
|
7
|
+
* boxes around the slot as the browser would have.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.wheelDelta = wheelDelta;
|
|
11
|
+
exports.wheelPixels = wheelPixels;
|
|
12
|
+
exports.wheelScroller = wheelScroller;
|
|
13
|
+
exports.scrollAroundSlot = scrollAroundSlot;
|
|
14
|
+
/** Pixels per line, for a wheel that counts lines (`deltaMode` 1), as browsers scroll them. */
|
|
15
|
+
const LINE_PIXELS = 16;
|
|
16
|
+
/** The most one relayed wheel moves along an axis, either way, in pixels. */
|
|
17
|
+
const MAX_WHEEL_PIXELS = 10_000;
|
|
18
|
+
/**
|
|
19
|
+
* A relayed wheel's movement along one axis, as a finite number of pixels within bounds, or 0.
|
|
20
|
+
*
|
|
21
|
+
* @param value - What the sender gave.
|
|
22
|
+
*/
|
|
23
|
+
function wheelDelta(value) {
|
|
24
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
25
|
+
return 0;
|
|
26
|
+
return Math.max(-MAX_WHEEL_PIXELS, Math.min(MAX_WHEEL_PIXELS, value));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A wheel event's movement, in pixels, along the axes the browser scrolls with it. Off Apple's
|
|
30
|
+
* systems, Chromium scrolls sideways for a vertical wheel turned with Shift held, though the event
|
|
31
|
+
* still says vertical; on Apple's systems a mouse's wheel with Shift held already arrives sideways,
|
|
32
|
+
* and a trackpad scrolls the way it moves.
|
|
33
|
+
*
|
|
34
|
+
* @param event - The wheel.
|
|
35
|
+
*/
|
|
36
|
+
function wheelPixels(event) {
|
|
37
|
+
let x = event.deltaX;
|
|
38
|
+
let y = event.deltaY;
|
|
39
|
+
if (event.shiftKey && x === 0 && y !== 0 && !/Mac|iPod|iPhone|iPad/.test(navigator.userAgent)) {
|
|
40
|
+
x = y;
|
|
41
|
+
y = 0;
|
|
42
|
+
}
|
|
43
|
+
if (event.deltaMode === 1)
|
|
44
|
+
return { x: x * LINE_PIXELS, y: y * LINE_PIXELS };
|
|
45
|
+
if (event.deltaMode === 2)
|
|
46
|
+
return { x: x * window.innerWidth, y: y * window.innerHeight };
|
|
47
|
+
return { x, y };
|
|
48
|
+
}
|
|
49
|
+
/** The document's scrolling box: the viewport's scroller. */
|
|
50
|
+
function rootScroller() {
|
|
51
|
+
return document.scrollingElement ?? document.documentElement;
|
|
52
|
+
}
|
|
53
|
+
/** A box's overflow along an axis. */
|
|
54
|
+
function overflowAlong(style, axis) {
|
|
55
|
+
return axis === "y" ? style.overflowY : style.overflowX;
|
|
56
|
+
}
|
|
57
|
+
/** Whether containment is set explicitly or implied by the container type or content visibility. */
|
|
58
|
+
function appliesContainment(style) {
|
|
59
|
+
const contain = style.getPropertyValue("contain");
|
|
60
|
+
const visibility = style.getPropertyValue("content-visibility");
|
|
61
|
+
return ((contain !== "" && contain !== "none") ||
|
|
62
|
+
/size|anchored/.test(style.getPropertyValue("container-type")) ||
|
|
63
|
+
(visibility !== "" && visibility !== "visible"));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether the body's overflow is the viewport's, so the body itself doesn't scroll: the root's own
|
|
67
|
+
* is `visible` both ways, and neither applies containment, which would keep the body's to itself.
|
|
68
|
+
*/
|
|
69
|
+
function bodyOverflowIsViewports(body) {
|
|
70
|
+
const html = getComputedStyle(document.documentElement);
|
|
71
|
+
return (html.overflowX === "visible" &&
|
|
72
|
+
html.overflowY === "visible" &&
|
|
73
|
+
!appliesContainment(html) &&
|
|
74
|
+
!appliesContainment(body));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* How a box lets the user scroll along an axis: `auto` and `scroll` do, `visible`, `hidden` and
|
|
78
|
+
* `clip` don't, nor does a body whose overflow is the viewport's. The viewport scrolls unless the
|
|
79
|
+
* root, or a body whose overflow is the viewport's, is `hidden` or `clip`.
|
|
80
|
+
*/
|
|
81
|
+
function userScrolls(element, style, axis, isRoot) {
|
|
82
|
+
if (!isRoot) {
|
|
83
|
+
const overflow = overflowAlong(style, axis);
|
|
84
|
+
if (overflow !== "auto" && overflow !== "scroll" && overflow !== "overlay")
|
|
85
|
+
return false;
|
|
86
|
+
// The root, further out, scrolls for such a body.
|
|
87
|
+
return element !== document.body || !bodyOverflowIsViewports(style);
|
|
88
|
+
}
|
|
89
|
+
const html = document.documentElement;
|
|
90
|
+
let overflow = overflowAlong(element === html ? style : getComputedStyle(html), axis);
|
|
91
|
+
if (overflow === "visible" && document.body) {
|
|
92
|
+
// A body that keeps its overflow to itself (the root isn't `visible` both ways, or either
|
|
93
|
+
// applies containment) leaves the viewport's to the root.
|
|
94
|
+
const body = getComputedStyle(document.body);
|
|
95
|
+
if (bodyOverflowIsViewports(body))
|
|
96
|
+
overflow = overflowAlong(body, axis);
|
|
97
|
+
}
|
|
98
|
+
return overflow !== "hidden" && overflow !== "clip";
|
|
99
|
+
}
|
|
100
|
+
/** Whether a scrolling box stops a wheel at its edge from going on to the boxes around it. */
|
|
101
|
+
function containsOverscroll(style, axis) {
|
|
102
|
+
const value = style.getPropertyValue(`overscroll-behavior-${axis}`);
|
|
103
|
+
return value === "contain" || value === "none";
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Whether a box's scroll position along an axis starts at its far end and runs from 0 down to
|
|
107
|
+
* minus its room. Outside a flex box, only right to left does, along x. In a flex box, the writing
|
|
108
|
+
* mode and direction set where each axis starts, a reversed flex direction turns the main axis
|
|
109
|
+
* around, and `wrap-reverse` the cross axis. The viewport isn't a flex box, even when the root
|
|
110
|
+
* element lays out its children with flex.
|
|
111
|
+
*/
|
|
112
|
+
function countsBack(style, axis, isViewport) {
|
|
113
|
+
if (isViewport || (style.display !== "flex" && style.display !== "inline-flex")) {
|
|
114
|
+
return axis === "x" && style.direction === "rtl";
|
|
115
|
+
}
|
|
116
|
+
const mode = style.writingMode;
|
|
117
|
+
const vertical = mode.startsWith("vertical-") || mode.startsWith("sideways-");
|
|
118
|
+
const inline = axis === (vertical ? "y" : "x");
|
|
119
|
+
const backwards = inline
|
|
120
|
+
? (style.direction === "rtl") !== (mode === "sideways-lr")
|
|
121
|
+
: mode.endsWith("-rl");
|
|
122
|
+
const direction = style.flexDirection;
|
|
123
|
+
const row = !direction.startsWith("column");
|
|
124
|
+
const reversed = inline === row ? direction.endsWith("-reverse") : style.flexWrap === "wrap-reverse";
|
|
125
|
+
return backwards !== reversed;
|
|
126
|
+
}
|
|
127
|
+
/** Whether a scrolling box can still move along an axis in a direction. */
|
|
128
|
+
function hasRoom(element, style, axis, delta, isViewport) {
|
|
129
|
+
const room = axis === "y"
|
|
130
|
+
? element.scrollHeight - element.clientHeight
|
|
131
|
+
: element.scrollWidth - element.clientWidth;
|
|
132
|
+
const at = axis === "y" ? element.scrollTop : element.scrollLeft;
|
|
133
|
+
const start = countsBack(style, axis, isViewport) ? -room : 0;
|
|
134
|
+
return delta > 0 ? at < start + room - 0.5 : at > start + 0.5;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* What a wheel along one axis scrolls, from `start` outward, as the browser chains it: the first
|
|
138
|
+
* box the user can scroll that can still move that way, or `"contained"` when a scrolling box on
|
|
139
|
+
* the way is at its edge and stops the wheel there (`overscroll-behavior: contain` or `none`), or
|
|
140
|
+
* nothing when no box takes it.
|
|
141
|
+
*
|
|
142
|
+
* @param start - The element under the pointer.
|
|
143
|
+
* @param axis - The axis.
|
|
144
|
+
* @param delta - Which way, and how far: down or right when positive.
|
|
145
|
+
*/
|
|
146
|
+
function wheelScroller(start, axis, delta) {
|
|
147
|
+
if (delta === 0)
|
|
148
|
+
return undefined;
|
|
149
|
+
const root = rootScroller();
|
|
150
|
+
for (let element = start; element; element = element.parentElement) {
|
|
151
|
+
const isRoot = element === root;
|
|
152
|
+
const style = getComputedStyle(element);
|
|
153
|
+
if (userScrolls(element, style, axis, isRoot)) {
|
|
154
|
+
if (hasRoom(element, style, axis, delta, isRoot))
|
|
155
|
+
return element;
|
|
156
|
+
if (containsOverscroll(style, axis))
|
|
157
|
+
return "contained";
|
|
158
|
+
}
|
|
159
|
+
if (isRoot)
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* In a framed screen: scroll as a wheel over the piece drawn on `slot` would have, had the piece
|
|
166
|
+
* been in the screen's document. Each axis moves the first box around the slot that can still
|
|
167
|
+
* move that way.
|
|
168
|
+
*
|
|
169
|
+
* @param slot - The slot the piece is drawn over.
|
|
170
|
+
* @param deltaX - Pixels to the right (negative: to the left).
|
|
171
|
+
* @param deltaY - Pixels down (negative: up).
|
|
172
|
+
*/
|
|
173
|
+
function scrollAroundSlot(slot, deltaX, deltaY) {
|
|
174
|
+
for (const [axis, delta] of [
|
|
175
|
+
["x", deltaX],
|
|
176
|
+
["y", deltaY],
|
|
177
|
+
]) {
|
|
178
|
+
const scroller = wheelScroller(slot.parentElement, axis, delta);
|
|
179
|
+
if (!scroller || scroller === "contained")
|
|
180
|
+
continue;
|
|
181
|
+
if (axis === "y")
|
|
182
|
+
scroller.scrollTop += delta;
|
|
183
|
+
else
|
|
184
|
+
scroller.scrollLeft += delta;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -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
|
+
}>;
|