@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,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host's own menu (File, Edit, View, Window, Help) where its window has no menu bar: the
|
|
3
|
+
* desktop app on Windows and Linux, whose window has neither title bar nor menu bar. The shell's
|
|
4
|
+
* top strip opens it from a ☰ at its left end. Elsewhere there's none: macOS keeps the menu in
|
|
5
|
+
* the screen's menu bar, and a browser has its own.
|
|
6
|
+
*/
|
|
7
|
+
export interface HostAppMenu {
|
|
8
|
+
/** Opens the menu with its top-left corner at a point in the page's pixels. */
|
|
9
|
+
open(x: number, y: number): void;
|
|
10
|
+
}
|
|
11
|
+
/** The host's menu, when the shell has to offer it (see {@link HostAppMenu}). */
|
|
12
|
+
export declare function hostAppMenu(): HostAppMenu | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The ☰ at the left end of the shell's top strip that opens the host's menu below it. Renders
|
|
15
|
+
* nothing where the host has no such menu.
|
|
16
|
+
*/
|
|
17
|
+
export declare function HostAppMenuButton(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hostAppMenu = hostAppMenu;
|
|
4
|
+
exports.HostAppMenuButton = HostAppMenuButton;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
/** The host's menu, when the shell has to offer it (see {@link HostAppMenu}). */
|
|
7
|
+
function hostAppMenu() {
|
|
8
|
+
return window.electronAPI?.appMenu;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The ☰ at the left end of the shell's top strip that opens the host's menu below it. Renders
|
|
12
|
+
* nothing where the host has no such menu.
|
|
13
|
+
*/
|
|
14
|
+
function HostAppMenuButton() {
|
|
15
|
+
const menu = hostAppMenu();
|
|
16
|
+
if (!menu)
|
|
17
|
+
return null;
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm d-flex align-items-center flex-shrink-0 peers-strip-icon-button", onClick: (event) => {
|
|
19
|
+
const button = event.currentTarget.getBoundingClientRect();
|
|
20
|
+
menu.open(button.left, button.bottom);
|
|
21
|
+
}, title: "Menu", "aria-label": "Menu", "aria-haspopup": "menu", "data-testid": "host-app-menu-button", children: (0, jsx_runtime_1.jsx)("i", { className: "bi-list", style: { fontSize: "16px" } }) }));
|
|
22
|
+
}
|
|
@@ -23,6 +23,7 @@ const color_mode_dropdown_1 = require("../../screens/settings/color-mode-dropdow
|
|
|
23
23
|
const tabs_layout_1 = require("../../tabs-layout/tabs-layout");
|
|
24
24
|
const tabs_state_1 = require("../../tabs-layout/tabs-state");
|
|
25
25
|
const app_shell_height_1 = require("../app-shell-height");
|
|
26
|
+
const host_app_menu_1 = require("../host-app-menu");
|
|
26
27
|
const isMac = typeof navigator !== "undefined" ? /Mac|iPod|iPhone|iPad/.test(navigator.userAgent) : false;
|
|
27
28
|
const paletteHint = isMac ? "⌘K" : "Ctrl+K";
|
|
28
29
|
/** The full-screen layout body: minimal header + the single active screen. */
|
|
@@ -41,11 +42,12 @@ function FullScreenLayout() {
|
|
|
41
42
|
const isLauncher = activeTab.packageId === "launcher" || activeTab.tabId === "launcher";
|
|
42
43
|
const isLight = mode === "light";
|
|
43
44
|
const title = isLauncher ? "Apps" : activeTab.title;
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-column", style: { height: app_shell_height_1.APP_SHELL_HEIGHT, overflow: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: `border-bottom peers-tab-strip d-flex align-items-center
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-column", style: { height: app_shell_height_1.APP_SHELL_HEIGHT, overflow: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: `border-bottom peers-tab-strip d-flex align-items-center ${isLight ? "" : "bg-dark"}`, style: {
|
|
45
46
|
height: "36px",
|
|
46
47
|
paddingLeft: `calc(${app_shell_height_1.WINDOW_CONTROLS_LEFT} + 0.25rem)`,
|
|
48
|
+
paddingRight: `calc(${app_shell_height_1.WINDOW_CONTROLS_RIGHT} + 0.25rem)`,
|
|
47
49
|
borderBottomColor: isLight ? "var(--peers-tab-edge)" : "#495057",
|
|
48
|
-
}, children: [(0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: mode, isMobile: isMobile }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, active: isLauncher, icon: "bi-grid-3x3-gap", label: "Apps", onClick: () => (0, tabs_state_1.activeTabId)("launcher") }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center flex-grow-1 overflow-hidden px-2", children: [!isLauncher && activeTab.iconClassName && ((0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: activeTab.iconClassName, className: "me-2" })), (0, jsx_runtime_1.jsx)("span", { className: "text-truncate fw-medium", style: { fontSize: "13px" }, children: title })] }), (0, jsx_runtime_1.jsx)(notification_bell_1.NotificationBell, { compact: true }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, icon: "bi-search", label: `Search and navigate (${paletteHint})`, onClick: command_palette_1.openCommandPalette, children: (0, jsx_runtime_1.jsx)("span", { className: "d-none d-md-inline ms-1", style: { fontSize: "11px" }, children: paletteHint }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1 overflow-hidden", children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabErrorBoundary, { tabTitle: activeTab.title, tabId: activeTab.tabId, children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabContent, { tab: activeTab, isMobile: isMobile, isActive: true }) }, activeTab.tabId) })] }));
|
|
50
|
+
}, children: [(0, jsx_runtime_1.jsx)(host_app_menu_1.HostAppMenuButton, {}), (0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: mode, isMobile: isMobile }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, active: isLauncher, icon: "bi-grid-3x3-gap", label: "Apps", onClick: () => (0, tabs_state_1.activeTabId)("launcher") }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center flex-grow-1 overflow-hidden px-2", children: [!isLauncher && activeTab.iconClassName && ((0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: activeTab.iconClassName, className: "me-2" })), (0, jsx_runtime_1.jsx)("span", { className: "text-truncate fw-medium", style: { fontSize: "13px" }, children: title })] }), (0, jsx_runtime_1.jsx)(notification_bell_1.NotificationBell, { compact: true }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, icon: "bi-search", label: `Search and navigate (${paletteHint})`, onClick: command_palette_1.openCommandPalette, children: (0, jsx_runtime_1.jsx)("span", { className: "d-none d-md-inline ms-1", style: { fontSize: "11px" }, children: paletteHint }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1 overflow-hidden", children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabErrorBoundary, { tabTitle: activeTab.title, tabId: activeTab.tabId, children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabContent, { tab: activeTab, isMobile: isMobile, isActive: true }) }, activeTab.tabId) })] }));
|
|
49
51
|
}
|
|
50
52
|
/** A small, transparent header button matching the tabs layout's toolbar styling. */
|
|
51
53
|
function HeaderButton({ isLight, icon, label, onClick, active, children }) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IAppNav } from "@peers-app/peers-sdk";
|
|
2
|
+
/** The Console app's route. */
|
|
3
|
+
export declare const CONSOLE_APP_PATH = "console";
|
|
4
|
+
/**
|
|
5
|
+
* Console system app: the Console's prompt full screen, in any layout. The same session as the
|
|
6
|
+
* Tabs + Console layout's panel.
|
|
7
|
+
*/
|
|
8
|
+
export declare const consoleApp: IAppNav;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a route is the Console app's.
|
|
11
|
+
*
|
|
12
|
+
* @param path A tab's route: `console`, `/console/`.
|
|
13
|
+
* @returns True for the Console app.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isConsolePath(path: string | null | undefined): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.consoleApp = exports.CONSOLE_APP_PATH = void 0;
|
|
4
|
+
exports.isConsolePath = isConsolePath;
|
|
5
|
+
/** The Console app's route. */
|
|
6
|
+
exports.CONSOLE_APP_PATH = "console";
|
|
7
|
+
/**
|
|
8
|
+
* Console system app: the Console's prompt full screen, in any layout. The same session as the
|
|
9
|
+
* Tabs + Console layout's panel.
|
|
10
|
+
*/
|
|
11
|
+
exports.consoleApp = {
|
|
12
|
+
name: "Console",
|
|
13
|
+
iconClassName: "bi-terminal",
|
|
14
|
+
navigationPath: exports.CONSOLE_APP_PATH,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Whether a route is the Console app's.
|
|
18
|
+
*
|
|
19
|
+
* @param path A tab's route: `console`, `/console/`.
|
|
20
|
+
* @returns True for the Console app.
|
|
21
|
+
*/
|
|
22
|
+
function isConsolePath(path) {
|
|
23
|
+
const route = (path ?? "").split("?")[0].trim().toLowerCase();
|
|
24
|
+
return route.replace(/^\/+|\/+$/g, "") === exports.CONSOLE_APP_PATH;
|
|
25
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IAppNav } from "@peers-app/peers-sdk";
|
|
2
2
|
import type { IPackageWithNavs } from "../ui-router/routes-loader";
|
|
3
|
+
export { consoleApp, isConsolePath } from "./console.app";
|
|
3
4
|
export { consoleLogsApp } from "./console-logs.app";
|
|
4
5
|
export { dataExplorerApp } from "./data-explorer.app";
|
|
5
6
|
export { identityApp } from "./identity.app";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.systemPackage = exports.systemApps = exports.variablesApp = exports.typesApp = exports.toolsApp = exports.settingsApp = exports.searchApp = exports.packagesApp = exports.notificationsApp = exports.networkViewerApp = exports.mobileSettingsApp = exports.identityApp = exports.dataExplorerApp = exports.consoleLogsApp = void 0;
|
|
3
|
+
exports.systemPackage = exports.systemApps = exports.variablesApp = exports.typesApp = exports.toolsApp = exports.settingsApp = exports.searchApp = exports.packagesApp = exports.notificationsApp = exports.networkViewerApp = exports.mobileSettingsApp = exports.identityApp = exports.dataExplorerApp = exports.consoleLogsApp = exports.isConsolePath = exports.consoleApp = void 0;
|
|
4
|
+
var console_app_1 = require("./console.app");
|
|
5
|
+
Object.defineProperty(exports, "consoleApp", { enumerable: true, get: function () { return console_app_1.consoleApp; } });
|
|
6
|
+
Object.defineProperty(exports, "isConsolePath", { enumerable: true, get: function () { return console_app_1.isConsolePath; } });
|
|
4
7
|
var console_logs_app_1 = require("./console-logs.app");
|
|
5
8
|
Object.defineProperty(exports, "consoleLogsApp", { enumerable: true, get: function () { return console_logs_app_1.consoleLogsApp; } });
|
|
6
9
|
var data_explorer_app_1 = require("./data-explorer.app");
|
|
@@ -26,6 +29,7 @@ var types_app_1 = require("./types.app");
|
|
|
26
29
|
Object.defineProperty(exports, "typesApp", { enumerable: true, get: function () { return types_app_1.typesApp; } });
|
|
27
30
|
var variables_app_1 = require("./variables.app");
|
|
28
31
|
Object.defineProperty(exports, "variablesApp", { enumerable: true, get: function () { return variables_app_1.variablesApp; } });
|
|
32
|
+
const console_app_2 = require("./console.app");
|
|
29
33
|
const console_logs_app_2 = require("./console-logs.app");
|
|
30
34
|
const data_explorer_app_2 = require("./data-explorer.app");
|
|
31
35
|
const identity_app_2 = require("./identity.app");
|
|
@@ -49,6 +53,7 @@ exports.systemApps = [
|
|
|
49
53
|
search_app_2.searchApp,
|
|
50
54
|
// System Tools & Debugging
|
|
51
55
|
network_viewer_app_2.networkViewerApp,
|
|
56
|
+
console_app_2.consoleApp,
|
|
52
57
|
console_logs_app_2.consoleLogsApp,
|
|
53
58
|
data_explorer_app_2.dataExplorerApp,
|
|
54
59
|
// Core Management Apps
|
|
@@ -51,11 +51,15 @@ const menu_surface_1 = require("../components/menu-surface");
|
|
|
51
51
|
const router_1 = require("../components/router");
|
|
52
52
|
const globals_1 = require("../globals");
|
|
53
53
|
const hooks_1 = require("../hooks");
|
|
54
|
+
const config_1 = require("../isolated-screens/config");
|
|
55
|
+
const screen_tab_context_1 = require("../isolated-screens/screen-tab-context");
|
|
54
56
|
const notifications_client_1 = require("../notifications/notifications-client");
|
|
55
57
|
const notifications_panel_1 = require("../notifications/notifications-panel");
|
|
56
58
|
const app_shell_height_1 = require("../root-layout/app-shell-height");
|
|
59
|
+
const host_app_menu_1 = require("../root-layout/host-app-menu");
|
|
57
60
|
const identity_routes_1 = require("../screens/identity/identity-routes");
|
|
58
61
|
const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
|
|
62
|
+
const console_app_1 = require("../system-apps/console.app");
|
|
59
63
|
const ui_loader_1 = require("../ui-router/ui-loader");
|
|
60
64
|
const network_status_indicator_1 = require("./network-status-indicator");
|
|
61
65
|
const tab_color_1 = require("./tab-color");
|
|
@@ -141,25 +145,10 @@ function TabsLayoutInternal({ fillContainer = false } = {}) {
|
|
|
141
145
|
backgroundColor: _colorMode === "light" ? "rgba(var(--bs-body-bg-rgb), 0.85)" : "rgba(0,0,0,0.85)",
|
|
142
146
|
}, children: (0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "spinner-border text-secondary mb-3", role: "status" }), (0, jsx_runtime_1.jsx)("div", { className: `small ${_colorMode === "light" ? "text-muted" : "text-secondary"}`, children: "Switching group..." })] }) })), (0, jsx_runtime_1.jsx)("div", { className: `border-bottom peers-tab-strip ${_colorMode === "light" ? "" : "bg-dark"}`, style: {
|
|
143
147
|
paddingLeft: app_shell_height_1.WINDOW_CONTROLS_LEFT,
|
|
148
|
+
paddingRight: app_shell_height_1.WINDOW_CONTROLS_RIGHT,
|
|
144
149
|
borderBottomWidth: "1px",
|
|
145
150
|
borderBottomColor: _colorMode === "light" ? "var(--peers-tab-edge)" : "#495057",
|
|
146
|
-
}, children: isMobile ? ((0, jsx_runtime_1.jsx)(MobileTabsHeader, { tabs: tabs, activeTab: activeTab, onSwitch: switchTab, onClose: tabs_state_1.closeTab, colorMode: _colorMode })) : ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center px-1", style: { height: "36px" }, children: [(0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: _colorMode, isMobile: false }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm
|
|
147
|
-
padding: "4px 8px",
|
|
148
|
-
fontSize: "12px",
|
|
149
|
-
borderRadius: "6px",
|
|
150
|
-
border: "none",
|
|
151
|
-
background: "transparent",
|
|
152
|
-
color: _colorMode === "light" ? "var(--peers-tab-icon-color)" : "#adb5bd",
|
|
153
|
-
}, onMouseEnter: (e) => {
|
|
154
|
-
e.currentTarget.style.backgroundColor =
|
|
155
|
-
_colorMode === "light" ? "var(--peers-tab-hover-bg)" : "#495057";
|
|
156
|
-
e.currentTarget.style.color =
|
|
157
|
-
_colorMode === "light" ? "var(--bs-link-color)" : "#ffffff";
|
|
158
|
-
}, onMouseLeave: (e) => {
|
|
159
|
-
e.currentTarget.style.backgroundColor = "transparent";
|
|
160
|
-
e.currentTarget.style.color =
|
|
161
|
-
_colorMode === "light" ? "var(--peers-tab-icon-color)" : "#adb5bd";
|
|
162
|
-
}, children: (0, jsx_runtime_1.jsx)("i", { className: "bi-search", style: { fontSize: "14px" } }) }), (0, jsx_runtime_1.jsx)(DesktopTabStrip, { tabs: tabs, activeTab: activeTab, onSwitch: switchTab, colorMode: _colorMode }), (0, jsx_runtime_1.jsx)(network_status_indicator_1.TabsStripIndicators, {})] })) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1 overflow-hidden", children: inPaneOrder(tabs).map((tab) => ((0, jsx_runtime_1.jsx)("div", { className: `h-100 ${activeTab === tab.tabId ? "d-block" : "d-none"}`, style: { display: activeTab === tab.tabId ? "block" : "none" }, children: (0, jsx_runtime_1.jsx)(TabErrorBoundary, { tabTitle: tab.title, tabId: tab.tabId, children: (0, jsx_runtime_1.jsx)(TabContent, { tab: tab, isMobile: isMobile, isActive: activeTab === tab.tabId }) }) }, tab.tabId))) }), (0, jsx_runtime_1.jsx)(tab_switcher_overlay_1.TabSwitcherOverlay, {})] }, currentlyActiveGroupId));
|
|
151
|
+
}, children: isMobile ? ((0, jsx_runtime_1.jsx)(MobileTabsHeader, { tabs: tabs, activeTab: activeTab, onSwitch: switchTab, onClose: tabs_state_1.closeTab, colorMode: _colorMode })) : ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center px-1", style: { height: "36px" }, children: [(0, jsx_runtime_1.jsx)(host_app_menu_1.HostAppMenuButton, {}), (0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: _colorMode, isMobile: false }), (0, jsx_runtime_1.jsx)(DesktopTabStrip, { tabs: tabs, activeTab: activeTab, onSwitch: switchTab, colorMode: _colorMode }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm ms-1 d-flex align-items-center flex-shrink-0 peers-strip-icon-button", onClick: command_palette_1.openCommandPalette, title: "Search everything (Cmd+K)", children: (0, jsx_runtime_1.jsx)("i", { className: "bi-search", style: { fontSize: "14px" } }) }), (0, jsx_runtime_1.jsx)(network_status_indicator_1.TabsStripIndicators, {})] })) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1 overflow-hidden", children: inPaneOrder(tabs).map((tab) => ((0, jsx_runtime_1.jsx)("div", { className: `h-100 ${activeTab === tab.tabId ? "d-block" : "d-none"}`, style: { display: activeTab === tab.tabId ? "block" : "none" }, children: (0, jsx_runtime_1.jsx)(TabErrorBoundary, { tabTitle: tab.title, tabId: tab.tabId, children: (0, jsx_runtime_1.jsx)(TabContent, { tab: tab, isMobile: isMobile, isActive: activeTab === tab.tabId }) }) }, tab.tabId))) }), (0, jsx_runtime_1.jsx)(tab_switcher_overlay_1.TabSwitcherOverlay, {})] }, currentlyActiveGroupId));
|
|
163
152
|
}
|
|
164
153
|
/**
|
|
165
154
|
* The tabs in an order that never changes for tabs already open (by id), so a reorder in the
|
|
@@ -260,7 +249,7 @@ function MobileTabsHeader({ tabs, activeTab, onSwitch, onClose, colorMode, }) {
|
|
|
260
249
|
document.addEventListener("keydown", closeOnEscape);
|
|
261
250
|
return () => document.removeEventListener("keydown", closeOnEscape);
|
|
262
251
|
}, [showMenuDropdown, closeMenu]);
|
|
263
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center justify-content-between px-2 position-relative", style: { height: "36px" }, children: [(0, jsx_runtime_1.
|
|
252
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center justify-content-between px-2 position-relative", style: { height: "36px" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center gap-1", children: [(0, jsx_runtime_1.jsx)(host_app_menu_1.HostAppMenuButton, {}), (0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: colorMode, isMobile: true })] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center justify-content-center position-absolute", style: {
|
|
264
253
|
left: "50%",
|
|
265
254
|
transform: "translateX(-50%)",
|
|
266
255
|
pointerEvents: "none",
|
|
@@ -379,8 +368,11 @@ const TabContentRenderer = react_1.default.memo(({ tab, isMobile }) => {
|
|
|
379
368
|
// System apps use the main Router (which reads from mainContentPath)
|
|
380
369
|
// Package apps use UIRouter with explicit path
|
|
381
370
|
const isSystemApp = tab.packageId === "system-apps";
|
|
382
|
-
|
|
383
|
-
|
|
371
|
+
// Identity and the Console fill the tab edge to edge and scroll inside themselves, and so does
|
|
372
|
+
// an isolated package screen's frame, which draws the tab's padding inside itself.
|
|
373
|
+
const fillsTab = (isSystemApp && ((0, identity_routes_1.isIdentityPath)(tab.path) || (0, console_app_1.isConsolePath)(tab.path))) ||
|
|
374
|
+
(!isSystemApp && (0, config_1.runsIsolated)(tab.packageId));
|
|
375
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: `h-100 ${fillsTab ? "overflow-hidden" : "overflow-auto"} ${fillsTab ? "" : isMobile ? "p-2" : "p-3"}`, children: (0, jsx_runtime_1.jsx)(screen_tab_context_1.ScreenTabContext.Provider, { value: { tabId: tab.tabId }, children: isSystemApp ? ((0, jsx_runtime_1.jsx)(router_1.Router, { path: tab.path })) : ((0, jsx_runtime_1.jsx)(ui_loader_1.UIRouter, { path: tab.path, uiCategory: "screen", props: {} })) }) }));
|
|
384
376
|
}, (prevProps, nextProps) => {
|
|
385
377
|
// Only re-render if the tab or isMobile changed
|
|
386
378
|
return (prevProps.tab.tabId === nextProps.tab.tabId &&
|
|
@@ -8,6 +8,8 @@ exports.restoreNavigationState = restoreNavigationState;
|
|
|
8
8
|
exports.determineAppFromPath = determineAppFromPath;
|
|
9
9
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
10
10
|
const globals_1 = require("../globals");
|
|
11
|
+
const frame_protocol_1 = require("../isolated-screens/frame-protocol");
|
|
12
|
+
const frame_realm_1 = require("../isolated-screens/frame-realm");
|
|
11
13
|
const identity_routes_1 = require("../screens/identity/identity-routes");
|
|
12
14
|
const system_apps_1 = require("../system-apps");
|
|
13
15
|
const routes_loader_1 = require("../ui-router/routes-loader");
|
|
@@ -105,6 +107,14 @@ exports.initializedTabs = new Set();
|
|
|
105
107
|
* @param options - App-root behavior. Launcher opens preserve the current section.
|
|
106
108
|
*/
|
|
107
109
|
function navigateTo(rawPath, options) {
|
|
110
|
+
// An isolated screen can't reach the tabs: its host navigates for it.
|
|
111
|
+
const host = (0, frame_realm_1.frameHost)();
|
|
112
|
+
if (host) {
|
|
113
|
+
void host
|
|
114
|
+
.request(frame_protocol_1.FrameRequest.navigate, { path: rawPath, options })
|
|
115
|
+
.catch((error) => console.error(`Couldn't open ${rawPath}`, error));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
108
118
|
const requestedPathname = (0, identity_routes_1.parseRoute)(rawPath).pathname;
|
|
109
119
|
if (!requestedPathname) {
|
|
110
120
|
const launcher = (0, exports.activeTabs)().find((tab) => tab.tabId === "launcher") ?? (0, exports.activeTabs)()[0];
|
|
@@ -356,6 +366,12 @@ function mergeIdentityTabs(tabs, activeId) {
|
|
|
356
366
|
* @param newTitle - Title shown on the tab strip.
|
|
357
367
|
*/
|
|
358
368
|
const updateActiveTabTitle = (newTitle) => {
|
|
369
|
+
// From an isolated screen, the title is its own tab's.
|
|
370
|
+
const host = (0, frame_realm_1.frameHost)();
|
|
371
|
+
if (host) {
|
|
372
|
+
void host.request(frame_protocol_1.FrameRequest.setTitle, { title: newTitle }).catch(() => undefined);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
359
375
|
// TODO Fix this to use a more reliable update mechanism
|
|
360
376
|
// using setTimeout to get around a race condition for setting title on new tabs
|
|
361
377
|
setTimeout(() => {
|
|
@@ -447,6 +463,12 @@ const closeTab = (tabId) => {
|
|
|
447
463
|
exports.closeTab = closeTab;
|
|
448
464
|
/** Close the active tab. The launcher tab stays open. */
|
|
449
465
|
const closeCurrentTab = () => {
|
|
466
|
+
// From an isolated screen, the tab it closes is its own.
|
|
467
|
+
const host = (0, frame_realm_1.frameHost)();
|
|
468
|
+
if (host) {
|
|
469
|
+
void host.request(frame_protocol_1.FrameRequest.closeTab).catch(() => undefined);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
450
472
|
(0, exports.closeTab)((0, exports.activeTabId)());
|
|
451
473
|
};
|
|
452
474
|
exports.closeCurrentTab = closeCurrentTab;
|
|
@@ -509,19 +531,20 @@ const switchToPreviousTab = () => {
|
|
|
509
531
|
(0, exports.activeTabId)(currentTabs[prevIndex].tabId);
|
|
510
532
|
};
|
|
511
533
|
exports.switchToPreviousTab = switchToPreviousTab;
|
|
512
|
-
//
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
});
|
|
534
|
+
// The window follows the active tab. A frame receives its own tab's path from the host.
|
|
535
|
+
if (!(0, frame_realm_1.frameHost)()) {
|
|
536
|
+
exports.activeTabId.subscribe((newActiveTab) => {
|
|
537
|
+
const currentTabs = (0, exports.activeTabs)();
|
|
538
|
+
const activeTab = currentTabs.find((t) => t.tabId === newActiveTab);
|
|
539
|
+
if (!activeTab) {
|
|
540
|
+
console.warn("Active tab not found:", newActiveTab);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (activeTab.packageId !== "launcher") {
|
|
544
|
+
(0, globals_1._mainContentPath)(activeTab.path);
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
(0, globals_1._mainContentPath)(""); // Launcher or fallback
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
package/dist/theme.css
CHANGED
|
@@ -95,11 +95,12 @@
|
|
|
95
95
|
--bs-table-bg: var(--peers-surface-bg);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
/* The host draws the window's own buttons over the strip
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
/* The host has no title bar and draws the window's own buttons over the strip (the desktop app:
|
|
99
|
+
peers-window-draggable on <html>; room at the left end on macOS, --peers-window-controls-left,
|
|
100
|
+
and at the right end on Windows and Linux, --peers-window-controls-right). The strip's empty
|
|
101
|
+
space moves the window, and what takes a click in it stays clickable. So does an overlay that
|
|
102
|
+
can cover the strip (position-fixed, a modal, or peers-window-no-drag on a package's own): the
|
|
103
|
+
region ignores what's drawn on top, so its top edge would move the window. */
|
|
103
104
|
.peers-window-draggable .peers-tab-strip {
|
|
104
105
|
-webkit-app-region: drag;
|
|
105
106
|
app-region: drag;
|
|
@@ -140,6 +141,32 @@
|
|
|
140
141
|
color: var(--peers-tab-strip-color);
|
|
141
142
|
}
|
|
142
143
|
|
|
144
|
+
/* An icon button in the strip: search, and the host's menu (☰). */
|
|
145
|
+
.btn.peers-strip-icon-button {
|
|
146
|
+
padding: 4px 8px;
|
|
147
|
+
font-size: 12px;
|
|
148
|
+
border-radius: 6px;
|
|
149
|
+
border: none;
|
|
150
|
+
background: transparent;
|
|
151
|
+
color: #adb5bd;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.btn.peers-strip-icon-button:hover,
|
|
155
|
+
.btn.peers-strip-icon-button:focus-visible {
|
|
156
|
+
background-color: #495057;
|
|
157
|
+
color: #ffffff;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[data-bs-theme="light"] .btn.peers-strip-icon-button {
|
|
161
|
+
color: var(--peers-tab-icon-color);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
[data-bs-theme="light"] .btn.peers-strip-icon-button:hover,
|
|
165
|
+
[data-bs-theme="light"] .btn.peers-strip-icon-button:focus-visible {
|
|
166
|
+
background-color: var(--peers-tab-hover-bg);
|
|
167
|
+
color: var(--bs-link-color);
|
|
168
|
+
}
|
|
169
|
+
|
|
143
170
|
[data-bs-theme="light"] .peers-tab {
|
|
144
171
|
--peers-tab-bg: transparent;
|
|
145
172
|
background-color: var(--peers-tab-bg);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the box a piece draws in is sized: `fill` for a view that fills its embedder's box,
|
|
3
|
+
* `content` for one that takes its own height, and for a popover. A piece drawn in a frame of its
|
|
4
|
+
* own reads it to know whether to report its height.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PieceHeightContext: import("react").Context<"fill" | "content">;
|
|
7
|
+
/** The size of the box a piece draws in. */
|
|
8
|
+
export interface IPieceSize {
|
|
9
|
+
/** Width in CSS pixels. */
|
|
10
|
+
width: number;
|
|
11
|
+
/** Height in CSS pixels. */
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The measured size of the box a piece draws in, which `usePieceSize` reads. `<Piece>` measures
|
|
16
|
+
* its box; a piece drawn in a frame of its own is measured inside that frame.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PieceSizeContext: import("react").Context<IPieceSize>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PieceSizeContext = exports.PieceHeightContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* How the box a piece draws in is sized: `fill` for a view that fills its embedder's box,
|
|
7
|
+
* `content` for one that takes its own height, and for a popover. A piece drawn in a frame of its
|
|
8
|
+
* own reads it to know whether to report its height.
|
|
9
|
+
*/
|
|
10
|
+
exports.PieceHeightContext = (0, react_1.createContext)("content");
|
|
11
|
+
/**
|
|
12
|
+
* The measured size of the box a piece draws in, which `usePieceSize` reads. `<Piece>` measures
|
|
13
|
+
* its box; a piece drawn in a frame of its own is measured inside that frame.
|
|
14
|
+
*/
|
|
15
|
+
exports.PieceSizeContext = (0, react_1.createContext)({ width: 0, height: 0 });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IContractDefinition, type IContractProviderInfo, type IPeersPackageUIs } from "@peers-app/peers-sdk";
|
|
1
|
+
import { type IContractDefinition, type IContractProviderInfo, type IPackage, type IPeersPackageUIs } from "@peers-app/peers-sdk";
|
|
2
2
|
import type { PieceComponent } from "./types";
|
|
3
3
|
/** The active group's id, or the user's for Personal: where a piece shows when none is named. */
|
|
4
4
|
export declare function defaultDataContextId(): Promise<string>;
|
|
@@ -84,6 +84,29 @@ export declare function piecesFromExport(exported: IPeersPackageUIs | undefined)
|
|
|
84
84
|
* @param exported - What the bundle passed `exportUIs`.
|
|
85
85
|
*/
|
|
86
86
|
export declare function recordLoadedPieces(packageVersionId: string, uiBundleFileId: string, exported: IPeersPackageUIs | undefined): void;
|
|
87
|
+
/** A provider version's UI bundle, read and checked for a piece that runs in a frame of its own. */
|
|
88
|
+
export interface IPieceBundle {
|
|
89
|
+
/** The provider's row in the piece's group. */
|
|
90
|
+
pkg: IPackage;
|
|
91
|
+
/** The bundle's code. */
|
|
92
|
+
code: string;
|
|
93
|
+
/** The version it's from. */
|
|
94
|
+
packageVersionId: string;
|
|
95
|
+
/** Its UI bundle's file. */
|
|
96
|
+
uiBundleFileId: string;
|
|
97
|
+
/** The group it was read in. */
|
|
98
|
+
dataContextId: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Read a provider version's UI bundle without running it, checked as {@link loadVersionPieces}
|
|
102
|
+
* checks it (the version may run, and in a group it matches its hash): for a piece drawn in a
|
|
103
|
+
* frame of its own, which runs the bundle there.
|
|
104
|
+
*
|
|
105
|
+
* @param dataContextId - The group the piece is embedded for.
|
|
106
|
+
* @param packageId - The provider.
|
|
107
|
+
* @param packageVersionId - The version it runs there.
|
|
108
|
+
*/
|
|
109
|
+
export declare function readVersionBundle(dataContextId: string, packageId: string, packageVersionId: string): Promise<IPieceBundle>;
|
|
87
110
|
/**
|
|
88
111
|
* The pieces a package version's UI bundle registers, running the bundle once per version and
|
|
89
112
|
* file when no screen already did. The version's row is read in the piece's group, and in a group
|
|
@@ -8,6 +8,7 @@ exports.watchProviders = watchProviders;
|
|
|
8
8
|
exports.installedProvider = installedProvider;
|
|
9
9
|
exports.piecesFromExport = piecesFromExport;
|
|
10
10
|
exports.recordLoadedPieces = recordLoadedPieces;
|
|
11
|
+
exports.readVersionBundle = readVersionBundle;
|
|
11
12
|
exports.loadVersionPieces = loadVersionPieces;
|
|
12
13
|
exports.resetPieceBundles = resetPieceBundles;
|
|
13
14
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
@@ -18,6 +19,10 @@ const implement_piece_1 = require("./implement-piece");
|
|
|
18
19
|
// contract providers, the version of a provider this device runs there, and that version's UI
|
|
19
20
|
// bundle. Tests replace this module.
|
|
20
21
|
const catalogs = new Map();
|
|
22
|
+
// Membership can change while a piece resolves. Looking up its rows must never create a group.
|
|
23
|
+
function pieceDataContext(user, id) {
|
|
24
|
+
return !id || id === user.userId ? user.userDataContext : user.groupDataContexts.get(id);
|
|
25
|
+
}
|
|
21
26
|
function catalogFor(dataContextId) {
|
|
22
27
|
let catalog = catalogs.get(dataContextId);
|
|
23
28
|
if (!catalog) {
|
|
@@ -137,7 +142,10 @@ async function installedProvider(dataContextId, contractId, version, providerPac
|
|
|
137
142
|
(!providerPackageId || pkg.packageId === providerPackageId));
|
|
138
143
|
if (!idle.length)
|
|
139
144
|
return undefined;
|
|
140
|
-
const
|
|
145
|
+
const dataContext = pieceDataContext(await (0, peers_sdk_1.getUserContext)(), dataContextId);
|
|
146
|
+
if (!dataContext)
|
|
147
|
+
return undefined;
|
|
148
|
+
const manifests = (0, peers_sdk_1.PackageVersionManifests)(dataContext);
|
|
141
149
|
let older;
|
|
142
150
|
for (const pkg of idle) {
|
|
143
151
|
const packageVersionId = pkg.requested.effectivePackageVersionId;
|
|
@@ -205,6 +213,45 @@ function recordLoadedPieces(packageVersionId, uiBundleFileId, exported) {
|
|
|
205
213
|
return;
|
|
206
214
|
bundles.set(key, piecesFromExport(exported));
|
|
207
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Read a provider version's UI bundle without running it, checked as {@link loadVersionPieces}
|
|
218
|
+
* checks it (the version may run, and in a group it matches its hash): for a piece drawn in a
|
|
219
|
+
* frame of its own, which runs the bundle there.
|
|
220
|
+
*
|
|
221
|
+
* @param dataContextId - The group the piece is embedded for.
|
|
222
|
+
* @param packageId - The provider.
|
|
223
|
+
* @param packageVersionId - The version it runs there.
|
|
224
|
+
*/
|
|
225
|
+
async function readVersionBundle(dataContextId, packageId, packageVersionId) {
|
|
226
|
+
const dataContext = pieceDataContext(await (0, peers_sdk_1.getUserContext)(), dataContextId);
|
|
227
|
+
if (!dataContext)
|
|
228
|
+
throw new Error("The piece's group is no longer available");
|
|
229
|
+
const pv = await (0, peers_sdk_1.PackageVersions)(dataContext).get(packageVersionId);
|
|
230
|
+
if (!pv)
|
|
231
|
+
throw new Error(`Version ${packageVersionId} of ${packageId} isn't on this device`);
|
|
232
|
+
if (pv.packageId !== packageId)
|
|
233
|
+
throw new Error(`Version ${packageVersionId} belongs to another package`);
|
|
234
|
+
if (!pv.uiBundleFileId)
|
|
235
|
+
throw new Error(`Version ${pv.version} of ${packageId} has no UI bundle`);
|
|
236
|
+
const stored = await (0, peers_sdk_1.Packages)(dataContext).get(packageId);
|
|
237
|
+
if (!stored)
|
|
238
|
+
throw new Error(`${packageId} isn't installed in this group`);
|
|
239
|
+
if (stored.disabled)
|
|
240
|
+
throw new Error(`${stored.name} is turned off in this group`);
|
|
241
|
+
await (0, peers_sdk_1.assertPackageVersionRunnable)(stored, pv, dataContext);
|
|
242
|
+
const code = await (0, bundle_files_1.readBundleText)(dataContextId, pv.uiBundleFileId);
|
|
243
|
+
if (!code)
|
|
244
|
+
throw new Error(`Version ${pv.version} of ${packageId} has an empty UI bundle`);
|
|
245
|
+
if (dataContext.groupId)
|
|
246
|
+
(0, peers_sdk_1.assertPackageBundleIntegrity)(pv, "ui", code);
|
|
247
|
+
return {
|
|
248
|
+
pkg: stored,
|
|
249
|
+
code,
|
|
250
|
+
packageVersionId,
|
|
251
|
+
uiBundleFileId: pv.uiBundleFileId,
|
|
252
|
+
dataContextId: dataContext.dataContextId,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
208
255
|
/**
|
|
209
256
|
* The pieces a package version's UI bundle registers, running the bundle once per version and
|
|
210
257
|
* file when no screen already did. The version's row is read in the piece's group, and in a group
|
|
@@ -216,10 +263,14 @@ function recordLoadedPieces(packageVersionId, uiBundleFileId, exported) {
|
|
|
216
263
|
* @param packageVersionId - The version it runs there.
|
|
217
264
|
*/
|
|
218
265
|
async function loadVersionPieces(dataContextId, packageId, packageVersionId) {
|
|
219
|
-
const dataContext = (await (0, peers_sdk_1.getUserContext)()
|
|
266
|
+
const dataContext = pieceDataContext(await (0, peers_sdk_1.getUserContext)(), dataContextId);
|
|
267
|
+
if (!dataContext)
|
|
268
|
+
throw new Error("The piece's group is no longer available");
|
|
220
269
|
const pv = await (0, peers_sdk_1.PackageVersions)(dataContext).get(packageVersionId);
|
|
221
270
|
if (!pv)
|
|
222
271
|
throw new Error(`Version ${packageVersionId} of ${packageId} isn't on this device`);
|
|
272
|
+
if (pv.packageId !== packageId)
|
|
273
|
+
throw new Error(`Version ${packageVersionId} belongs to another package`);
|
|
223
274
|
if (!pv.uiBundleFileId)
|
|
224
275
|
throw new Error(`Version ${pv.version} of ${packageId} has no UI bundle`);
|
|
225
276
|
const key = `${packageVersionId}:${pv.uiBundleFileId}`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type IContractPiece } from "@peers-app/peers-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Props as a piece gets them: a plain-data copy, checked against the props its declaration
|
|
4
|
+
* gives, nested fields and allowed values included. `<Piece>` checks them for its embedder, and
|
|
5
|
+
* the host checks them again before they reach a provider's frame from a framed screen, which
|
|
6
|
+
* could send anything.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The embedder's props.
|
|
9
|
+
* @param piece - The piece, as the embedder's version of the contract declares it.
|
|
10
|
+
* @returns The checked copy, or why the props were refused.
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkPieceProps(value: unknown, piece: IContractPiece): {
|
|
13
|
+
value: Record<string, unknown>;
|
|
14
|
+
} | {
|
|
15
|
+
error: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkPieceProps = checkPieceProps;
|
|
4
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
5
|
+
/**
|
|
6
|
+
* Props as a piece gets them: a plain-data copy, checked against the props its declaration
|
|
7
|
+
* gives, nested fields and allowed values included. `<Piece>` checks them for its embedder, and
|
|
8
|
+
* the host checks them again before they reach a provider's frame from a framed screen, which
|
|
9
|
+
* could send anything.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The embedder's props.
|
|
12
|
+
* @param piece - The piece, as the embedder's version of the contract declares it.
|
|
13
|
+
* @returns The checked copy, or why the props were refused.
|
|
14
|
+
*/
|
|
15
|
+
function checkPieceProps(value, piece) {
|
|
16
|
+
let snapshot;
|
|
17
|
+
try {
|
|
18
|
+
snapshot = (0, peers_sdk_1.snapshotPackageValue)(value ?? {});
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return {
|
|
22
|
+
error: `Props must be plain data (ids, options, short text): ${error instanceof Error ? error.message : String(error)}`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (!snapshot || typeof snapshot !== "object" || Array.isArray(snapshot)) {
|
|
26
|
+
return { error: "Props must be an object" };
|
|
27
|
+
}
|
|
28
|
+
// Every shape the declaration gives, nested fields and allowed values included: the embedder
|
|
29
|
+
// was built against this version, so a misfit is its mistake.
|
|
30
|
+
const parsed = (0, peers_sdk_1.fieldsToShapeSchema)(piece.propsFields).passthrough().safeParse(snapshot);
|
|
31
|
+
if (!parsed.success) {
|
|
32
|
+
return {
|
|
33
|
+
error: `Props don't fit piece "${piece.name}": ${parsed.error.issues
|
|
34
|
+
.map((issue) => `${issue.path.join(".") || "props"} ${issue.message}`)
|
|
35
|
+
.join("; ")}`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return { value: parsed.data };
|
|
39
|
+
}
|
|
@@ -29,6 +29,11 @@ export type PieceResolution = ({
|
|
|
29
29
|
* starting, stopping, or changing version on this device.
|
|
30
30
|
*/
|
|
31
31
|
export declare const pieceRevision: import("@peers-app/peers-sdk").Observable<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Drop every resolution kept, and resolve each shown piece again: what Retry on a piece that
|
|
34
|
+
* failed to resolve does. A framed screen's Retry asks the host to do it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function refreshPieceResolutions(): void;
|
|
32
37
|
/** @internal Register a stand-in for a piece; see `mockPiece`. */
|
|
33
38
|
export declare function setPieceMock(contractId: string, version: number, piece: IContractPiece, component: PieceComponent): () => void;
|
|
34
39
|
/** The group a handle's piece shows for: the one it names, else the active group. */
|