@peers-app/peers-ui 0.34.7 → 0.34.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/command-palette/command-palette-ui.js +14 -14
  2. package/dist/command-palette/command-palette.d.ts +10 -3
  3. package/dist/command-palette/command-palette.js +60 -6
  4. package/dist/command-palette/frame-commands.d.ts +37 -0
  5. package/dist/command-palette/frame-commands.js +43 -0
  6. package/dist/globals.d.ts +13 -2
  7. package/dist/globals.js +24 -2
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.js +9 -1
  10. package/dist/isolated-screens/config.js +1 -5
  11. package/dist/isolated-screens/frame-permissions.d.ts +11 -0
  12. package/dist/isolated-screens/frame-permissions.js +33 -0
  13. package/dist/isolated-screens/frame-protocol.d.ts +64 -0
  14. package/dist/isolated-screens/frame-protocol.js +28 -0
  15. package/dist/isolated-screens/frame-runtime.js +68 -2
  16. package/dist/isolated-screens/frame-viewport.d.ts +9 -0
  17. package/dist/isolated-screens/frame-viewport.js +36 -0
  18. package/dist/isolated-screens/global-widgets.d.ts +74 -0
  19. package/dist/isolated-screens/global-widgets.js +270 -0
  20. package/dist/isolated-screens/isolated-screen.d.ts +51 -1
  21. package/dist/isolated-screens/isolated-screen.js +228 -14
  22. package/dist/isolated-screens/piece-reach.d.ts +24 -0
  23. package/dist/isolated-screens/piece-reach.js +24 -8
  24. package/dist/isolated-screens/widget-box.d.ts +48 -0
  25. package/dist/isolated-screens/widget-box.js +193 -0
  26. package/dist/operator-console/operator-console-state.js +5 -1
  27. package/dist/root-layout/root-layout-host.js +3 -1
  28. package/dist/screens/devices/devices-list.d.ts +5 -1
  29. package/dist/screens/devices/devices-list.js +12 -4
  30. package/dist/screens/packages/package-info.js +2 -1
  31. package/dist/screens/packages/package-widgets-panel.d.ts +15 -0
  32. package/dist/screens/packages/package-widgets-panel.js +64 -0
  33. package/dist/tabs-layout/tabs-state.d.ts +5 -2
  34. package/dist/tabs-layout/tabs-state.js +41 -17
  35. package/package.json +3 -3
@@ -70,7 +70,11 @@ function setConsoleSize(size) {
70
70
  * platforms (matching VS Code / Cursor). Intentionally not Cmd on macOS.
71
71
  */
72
72
  function handleKeyDown(event) {
73
- if (event.ctrlKey && !event.metaKey && !event.altKey && event.code === "Backquote") {
73
+ if (event.ctrlKey &&
74
+ !event.metaKey &&
75
+ !event.altKey &&
76
+ event.code === "Backquote" &&
77
+ !event.defaultPrevented) {
74
78
  event.preventDefault();
75
79
  toggleConsole();
76
80
  }
@@ -20,6 +20,8 @@ const react_1 = require("react");
20
20
  const command_palette_ui_1 = require("../command-palette/command-palette-ui");
21
21
  const globals_1 = require("../globals");
22
22
  const hooks_1 = require("../hooks");
23
+ const config_1 = require("../isolated-screens/config");
24
+ const global_widgets_1 = require("../isolated-screens/global-widgets");
23
25
  const identity_ipc_1 = require("../screens/device-pairing/identity-ipc");
24
26
  const identity_routes_1 = require("../screens/identity/identity-routes");
25
27
  const invite_capture_1 = require("../screens/invites/invite-capture");
@@ -116,5 +118,5 @@ function RootLayoutBootstrap(props) {
116
118
  document.getElementById("appLoadingDiv")?.remove();
117
119
  const layout = (0, root_layout_registry_1.getRootLayout)(layoutId ?? root_layout_registry_1.DEFAULT_ROOT_LAYOUT_ID) ?? (0, root_layout_registry_1.getRootLayout)(root_layout_registry_1.DEFAULT_ROOT_LAYOUT_ID);
118
120
  const Body = layout?.Component;
119
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [Body && (0, jsx_runtime_1.jsx)(Body, {}), (0, jsx_runtime_1.jsx)(command_palette_ui_1.CommandPaletteOverlay, {}), overlays.map(({ id, Component }) => ((0, jsx_runtime_1.jsx)(Component, {}, id))), showWelcomeModal && ((0, jsx_runtime_1.jsx)(welcome_modal_1.WelcomeModal, { colorMode: _colorMode, onClose: () => setShowWelcomeModal(false) }))] }));
121
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [Body && (0, jsx_runtime_1.jsx)(Body, {}), (0, jsx_runtime_1.jsx)(command_palette_ui_1.CommandPaletteOverlay, {}), overlays.map(({ id, Component }) => ((0, jsx_runtime_1.jsx)(Component, {}, id))), (0, config_1.isolatedScreensHost)() ? (0, jsx_runtime_1.jsx)(global_widgets_1.GlobalWidgetsLayer, {}) : null, showWelcomeModal && ((0, jsx_runtime_1.jsx)(welcome_modal_1.WelcomeModal, { colorMode: _colorMode, onClose: () => setShowWelcomeModal(false) }))] }));
120
122
  }
@@ -1,5 +1,9 @@
1
1
  import { type IDevice, type INetworkConnectionInfo } from "@peers-app/peers-sdk";
2
- /** Compact, fully clickable row for one of the signed-in user's devices. */
2
+ /**
3
+ * Compact, fully clickable row for one of the signed-in user's devices. This device's row
4
+ * shows a "This device" badge where the others show their connection, since a device has
5
+ * no connection to itself.
6
+ */
3
7
  export declare function DeviceRow(props: {
4
8
  device: IDevice;
5
9
  connection?: INetworkConnectionInfo;
@@ -29,10 +29,18 @@ function connectionLabel(connection) {
29
29
  : "unknown path";
30
30
  return `${connection.connectionState} · ${path}`;
31
31
  }
32
- /** Compact, fully clickable row for one of the signed-in user's devices. */
33
- function DeviceRow(props) {
32
+ /** Online or Offline, and the path when connected, for another device's row. */
33
+ function ConnectionBadges(props) {
34
34
  const connected = props.connection !== undefined;
35
- return ((0, jsx_runtime_1.jsxs)("a", { href: `#${identity_routes_1.IDENTITY_DEVICES_PATH}/${props.device.deviceId}`, className: "list-group-item list-group-item-action d-flex align-items-center gap-3 py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "rounded-3 bg-body-secondary d-inline-flex align-items-center justify-content-center flex-shrink-0", style: { width: 44, height: 44 }, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("i", { className: `bi ${props.isThisDevice ? "bi-laptop-fill" : "bi-laptop"}` }) }), (0, jsx_runtime_1.jsxs)("span", { className: "flex-grow-1 overflow-hidden", children: [(0, jsx_runtime_1.jsxs)("span", { className: "d-flex align-items-center gap-2 flex-wrap", children: [(0, jsx_runtime_1.jsx)("span", { className: "fw-semibold text-truncate", children: props.device.name || props.device.reportedName || "Unnamed device" }), props.isThisDevice ? (0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-primary", children: "This device" }) : null] }), (0, jsx_runtime_1.jsx)("span", { className: "small text-muted d-block", children: props.device.lastSeen ? `Seen ${relativeTime(props.device.lastSeen)}` : "Never seen" })] }), (0, jsx_runtime_1.jsx)("span", { className: `badge ${connected ? "text-bg-success" : "text-bg-secondary"}`, children: connected ? "Online" : "Offline" }), connected && props.connection?.pathType ? ((0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-light border text-capitalize", children: props.connection.pathType })) : null, (0, jsx_runtime_1.jsx)("i", { className: "bi bi-chevron-right text-muted", "aria-hidden": "true" })] }));
35
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: `badge ${connected ? "text-bg-success" : "text-bg-secondary"}`, children: connected ? "Online" : "Offline" }), props.connection?.pathType ? ((0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-light border text-capitalize", children: props.connection.pathType })) : null] }));
36
+ }
37
+ /**
38
+ * Compact, fully clickable row for one of the signed-in user's devices. This device's row
39
+ * shows a "This device" badge where the others show their connection, since a device has
40
+ * no connection to itself.
41
+ */
42
+ function DeviceRow(props) {
43
+ return ((0, jsx_runtime_1.jsxs)("a", { href: `#${identity_routes_1.IDENTITY_DEVICES_PATH}/${props.device.deviceId}`, className: "list-group-item list-group-item-action d-flex align-items-center gap-3 py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "rounded-3 bg-body-secondary d-inline-flex align-items-center justify-content-center flex-shrink-0", style: { width: 44, height: 44 }, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("i", { className: `bi ${props.isThisDevice ? "bi-laptop-fill" : "bi-laptop"}` }) }), (0, jsx_runtime_1.jsxs)("span", { className: "flex-grow-1 overflow-hidden", children: [(0, jsx_runtime_1.jsx)("span", { className: "fw-semibold text-truncate d-block", children: props.device.name || props.device.reportedName || "Unnamed device" }), (0, jsx_runtime_1.jsx)("span", { className: "small text-muted d-block", children: props.device.lastSeen ? `Seen ${relativeTime(props.device.lastSeen)}` : "Never seen" })] }), props.isThisDevice ? ((0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-primary", children: "This device" })) : ((0, jsx_runtime_1.jsx)(ConnectionBadges, { connection: props.connection })), (0, jsx_runtime_1.jsx)("i", { className: "bi bi-chevron-right text-muted", "aria-hidden": "true" })] }));
36
44
  }
37
45
  function ThisDeviceCard(props) {
38
46
  const name = (0, hooks_1.useObservableState)(props.device.name ?? "");
@@ -134,7 +142,7 @@ function DevicesSection(props) {
134
142
  return ((0, jsx_runtime_1.jsxs)("div", { className: "container-xxl p-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-3", children: [(0, jsx_runtime_1.jsxs)("h4", { className: "mb-1", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-laptop me-2" }), "My devices"] }), (0, jsx_runtime_1.jsxs)("div", { className: "small text-muted", children: ["Installations signed in to this account. Connection diagnostics stay in", " ", (0, jsx_runtime_1.jsx)("a", { href: "#network-viewer", children: "Network Viewer" }), "."] })] }), (0, jsx_runtime_1.jsx)(activity_view_1.PendingWorkLink, { type: "device" }), (0, jsx_runtime_1.jsxs)("div", { className: "list-group", children: [mine ? ((0, jsx_runtime_1.jsx)(DeviceRow, { device: mine, connection: byId.get(mine.deviceId), isThisDevice: true })) : null, others.map((device) => ((0, jsx_runtime_1.jsx)(DeviceRow, { device: device, connection: byId.get(device.deviceId), isThisDevice: false }, device.deviceId)))] }), !mine && others.length === 0 ? ((0, jsx_runtime_1.jsxs)("div", { className: "border rounded p-4 text-center", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-laptop fs-2 text-muted" }), (0, jsx_runtime_1.jsx)("h6", { className: "mt-2", children: "No devices are registered yet" }), (0, jsx_runtime_1.jsx)("a", { href: `#${identity_routes_1.IDENTITY_PAIR_PATH}`, className: "btn btn-primary btn-sm", children: "Add a device" })] })) : null, mine && others.length === 0 ? ((0, jsx_runtime_1.jsxs)("p", { className: "small text-muted mt-3", children: ["This is your only device. Use ", (0, jsx_runtime_1.jsx)("a", { href: `#${identity_routes_1.IDENTITY_PAIR_PATH}`, children: "Add device" }), " to sign in somewhere else."] })) : null] }));
135
143
  }
136
144
  function DeviceDetail(props) {
137
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-xxl p-3", children: [(0, jsx_runtime_1.jsx)("a", { href: `#${identity_routes_1.IDENTITY_DEVICES_PATH}`, className: "btn btn-link btn-sm px-0 mb-2", children: "Back to devices" }), (0, jsx_runtime_1.jsx)("h4", { className: "mb-3", children: props.device.name || "Unnamed device" }), props.isThisDevice ? (0, jsx_runtime_1.jsx)(ThisDeviceCard, { device: props.device }) : null, (0, jsx_runtime_1.jsxs)("dl", { className: "row small mb-3", children: [(0, jsx_runtime_1.jsx)("dt", { className: "col-sm-4", children: "Trust" }), (0, jsx_runtime_1.jsx)("dd", { className: "col-sm-8", children: trustLabel(props.device.trustLevel) }), (0, jsx_runtime_1.jsx)("dt", { className: "col-sm-4", children: "Connection" }), (0, jsx_runtime_1.jsx)("dd", { className: "col-sm-8", children: connectionLabel(props.connection) }), (0, jsx_runtime_1.jsx)("dt", { className: "col-sm-4", children: "Last seen" }), (0, jsx_runtime_1.jsx)("dd", { className: "col-sm-8", children: props.device.lastSeen ? new Date(props.device.lastSeen).toLocaleString() : "Unknown" }), (0, jsx_runtime_1.jsx)("dt", { className: "col-sm-4", children: "Device ID" }), (0, jsx_runtime_1.jsx)("dd", { className: "col-sm-8 text-break", children: props.device.deviceId })] }), (0, jsx_runtime_1.jsx)("a", { href: "#network-viewer", className: "btn btn-outline-secondary btn-sm me-2", children: "Open Network Viewer" }), props.isThisDevice ? null : ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-danger btn-sm", onClick: () => void forgetDevice(props.device), children: "Forget" })), props.isThisDevice ? null : ((0, jsx_runtime_1.jsx)(remote_app_update_panel_1.RemoteAppUpdatePanel, { deviceId: props.device.deviceId, deviceName: props.device.name }))] }));
145
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "container-xxl p-3", children: [(0, jsx_runtime_1.jsx)("a", { href: `#${identity_routes_1.IDENTITY_DEVICES_PATH}`, className: "btn btn-link btn-sm px-0 mb-2", children: "Back to devices" }), (0, jsx_runtime_1.jsx)("h4", { className: "mb-3", children: props.device.name || "Unnamed device" }), props.isThisDevice ? (0, jsx_runtime_1.jsx)(ThisDeviceCard, { device: props.device }) : null, (0, jsx_runtime_1.jsxs)("dl", { className: "row small mb-3", children: [(0, jsx_runtime_1.jsx)("dt", { className: "col-sm-4", children: "Trust" }), (0, jsx_runtime_1.jsx)("dd", { className: "col-sm-8", children: trustLabel(props.device.trustLevel) }), (0, jsx_runtime_1.jsx)("dt", { className: "col-sm-4", children: "Connection" }), (0, jsx_runtime_1.jsx)("dd", { className: "col-sm-8", children: props.isThisDevice ? "This device" : connectionLabel(props.connection) }), (0, jsx_runtime_1.jsx)("dt", { className: "col-sm-4", children: "Last seen" }), (0, jsx_runtime_1.jsx)("dd", { className: "col-sm-8", children: props.device.lastSeen ? new Date(props.device.lastSeen).toLocaleString() : "Unknown" }), (0, jsx_runtime_1.jsx)("dt", { className: "col-sm-4", children: "Device ID" }), (0, jsx_runtime_1.jsx)("dd", { className: "col-sm-8 text-break", children: props.device.deviceId })] }), (0, jsx_runtime_1.jsx)("a", { href: "#network-viewer", className: "btn btn-outline-secondary btn-sm me-2", children: "Open Network Viewer" }), props.isThisDevice ? null : ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-danger btn-sm", onClick: () => void forgetDevice(props.device), children: "Forget" })), props.isThisDevice ? null : ((0, jsx_runtime_1.jsx)(remote_app_update_panel_1.RemoteAppUpdatePanel, { deviceId: props.device.deviceId, deviceName: props.device.name }))] }));
138
146
  }
139
147
  async function forgetDevice(device) {
140
148
  const confirmed = confirm(`Forget ${device.name || device.deviceId}?`);
@@ -10,6 +10,7 @@ const acts_for_you_panel_1 = require("../../delegates/acts-for-you-panel");
10
10
  const hooks_1 = require("../../hooks");
11
11
  const host_shell_consumer_1 = require("../../host-shell/host-shell-consumer");
12
12
  const package_network_panel_1 = require("./package-network-panel");
13
+ const package_widgets_panel_1 = require("./package-widgets-panel");
13
14
  /** Info tab for the package details screen. */
14
15
  const PackageInfo = (props) => {
15
16
  const { pkg } = props;
@@ -121,6 +122,6 @@ const PackageInfo = (props) => {
121
122
  await (0, peers_sdk_1.updatePackagePrefs)(pkg.packageId, {
122
123
  followTags: val === "stable" ? "stable" : val,
123
124
  });
124
- }, children: [(0, jsx_runtime_1.jsx)("option", { value: "stable", children: "Stable" }), (0, jsx_runtime_1.jsx)("option", { value: "stable,beta", children: "Stable + Beta" })] })] })] }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2", children: [(0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsxs)("small", { children: ["Description:", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: `This should be edited in the package's README.md. It will automatically update when you restart Peers or reload the package.` })] }), (0, jsx_runtime_1.jsx)(markdown_with_mentions_1.MarkdownWithMentions, { content: pkg.description || "" })] }), (0, jsx_runtime_1.jsx)(package_network_panel_1.PackageNetworkPanel, { packageId: pkg.packageId }), (0, jsx_runtime_1.jsx)(acts_for_you_panel_1.ActsForYouPanel, { packageId: pkg.packageId, packageName: pkg.name || pkg.packageId })] }));
125
+ }, children: [(0, jsx_runtime_1.jsx)("option", { value: "stable", children: "Stable" }), (0, jsx_runtime_1.jsx)("option", { value: "stable,beta", children: "Stable + Beta" })] })] })] }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2", children: [(0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsxs)("small", { children: ["Description:", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: `This should be edited in the package's README.md. It will automatically update when you restart Peers or reload the package.` })] }), (0, jsx_runtime_1.jsx)(markdown_with_mentions_1.MarkdownWithMentions, { content: pkg.description || "" })] }), (0, jsx_runtime_1.jsx)(package_network_panel_1.PackageNetworkPanel, { packageId: pkg.packageId }), (0, jsx_runtime_1.jsx)(package_widgets_panel_1.PackageWidgetsPanel, { packageId: pkg.packageId, packageName: pkg.name || pkg.packageId, packageVersionId: activeVersionId }), (0, jsx_runtime_1.jsx)(acts_for_you_panel_1.ActsForYouPanel, { packageId: pkg.packageId, packageName: pkg.name || pkg.packageId })] }));
125
126
  };
126
127
  exports.PackageInfo = PackageInfo;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A package's widgets over every app, each with an on/off switch for this device: the ones the
3
+ * manifest this device stored for the selected version declares, and the ones Peers draws now
4
+ * (from the version running in Personal, which may be an older one while an update waits). Shows
5
+ * nothing for a package with neither.
6
+ *
7
+ * @param props.packageId - The package.
8
+ * @param props.packageName - Its name.
9
+ * @param props.packageVersionId - The selected version in the group the screen shows.
10
+ */
11
+ export declare function PackageWidgetsPanel(props: {
12
+ packageId: string;
13
+ packageName: string;
14
+ packageVersionId?: string;
15
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageWidgetsPanel = PackageWidgetsPanel;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
6
+ const react_1 = require("react");
7
+ const hooks_1 = require("../../hooks");
8
+ const frame_permissions_1 = require("../../isolated-screens/frame-permissions");
9
+ const global_widgets_1 = require("../../isolated-screens/global-widgets");
10
+ const piece_reach_1 = require("../../isolated-screens/piece-reach");
11
+ /**
12
+ * A package's widgets over every app, each with an on/off switch for this device: the ones the
13
+ * manifest this device stored for the selected version declares, and the ones Peers draws now
14
+ * (from the version running in Personal, which may be an older one while an update waits). Shows
15
+ * nothing for a package with neither.
16
+ *
17
+ * @param props.packageId - The package.
18
+ * @param props.packageName - Its name.
19
+ * @param props.packageVersionId - The selected version in the group the screen shows.
20
+ */
21
+ function PackageWidgetsPanel(props) {
22
+ const { packageId, packageVersionId } = props;
23
+ const [declared, setDeclared] = (0, react_1.useState)([]);
24
+ const [off] = (0, hooks_1.useObservable)(frame_permissions_1.globalWidgetsOff);
25
+ const [listed] = (0, hooks_1.useObservable)(global_widgets_1.listedGlobalWidgets);
26
+ (0, react_1.useEffect)(() => {
27
+ let cancelled = false;
28
+ setDeclared([]);
29
+ if (!packageVersionId)
30
+ return;
31
+ void (async () => {
32
+ try {
33
+ const { dataContextId } = await (0, peers_sdk_1.getDefaultDataContext)();
34
+ const manifest = await (0, piece_reach_1.readStoredManifest)(dataContextId, packageVersionId);
35
+ // A stale selection can name another package's version.
36
+ if (!cancelled && manifest?.packageId === packageId) {
37
+ setDeclared((0, global_widgets_1.widgetsDeclaredIn)(manifest));
38
+ }
39
+ }
40
+ catch {
41
+ if (!cancelled)
42
+ setDeclared([]);
43
+ }
44
+ })();
45
+ return () => {
46
+ cancelled = true;
47
+ };
48
+ }, [packageId, packageVersionId]);
49
+ const widgets = new Map();
50
+ for (const entry of listed ?? []) {
51
+ if (entry.packageId === packageId)
52
+ widgets.set(entry.widget.id, entry.widget);
53
+ }
54
+ for (const widget of declared)
55
+ if (!widgets.has(widget.id))
56
+ widgets.set(widget.id, widget);
57
+ if (!widgets.size)
58
+ return null;
59
+ const hidden = new Set(Array.isArray(off) ? off : []);
60
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "mt-2", "data-package-widgets": packageId, children: [(0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsx)("small", { children: "Over every app (this device):" }), [...widgets.values()].map((widget) => {
61
+ const id = `widget-${packageId}-${widget.id}`;
62
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "form-check form-switch", children: [(0, jsx_runtime_1.jsx)("input", { id: id, className: "form-check-input", type: "checkbox", checked: !hidden.has(`${packageId}:${widget.id}`), onChange: (event) => (0, frame_permissions_1.setGlobalWidgetOn)(packageId, widget.id, event.target.checked) }), (0, jsx_runtime_1.jsx)("label", { className: "form-check-label", htmlFor: id, children: widget.title })] }, widget.id));
63
+ }), (0, jsx_runtime_1.jsxs)("div", { className: "form-text", children: ["Drawn from the copy of ", props.packageName, " in your Personal group."] })] }));
64
+ }
@@ -2,11 +2,14 @@ import { type IAppNav, type Observable } from "@peers-app/peers-sdk";
2
2
  import { type IPackageWithNavs } from "../ui-router/routes-loader";
3
3
  import { type TabState } from "./tab-order";
4
4
  export { launcherApp, normalizeTabHistory, previousAppTabId, type TabState, tabsByRecentUse, } from "./tab-order";
5
- /** Open tabs. Writes through to device storage after the initial restore. */
5
+ /**
6
+ * Open tabs. Writes through to device storage after the initial restore. In a package's frame
7
+ * they're the host's, read only, and follow it.
8
+ */
6
9
  export declare const activeTabs: Observable<TabState[]> & {
7
10
  loadingPromise: Promise<void>;
8
11
  };
9
- /** Id of the tab whose path is showing. */
12
+ /** Id of the tab whose path is showing. In a package's frame, the host's, kept current. */
10
13
  export declare const activeTabId: Observable<string> & {
11
14
  loadingPromise: Promise<void>;
12
15
  };
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "launcherApp", { enumerable: true, get: function
19
19
  Object.defineProperty(exports, "normalizeTabHistory", { enumerable: true, get: function () { return tab_order_2.normalizeTabHistory; } });
20
20
  Object.defineProperty(exports, "previousAppTabId", { enumerable: true, get: function () { return tab_order_2.previousAppTabId; } });
21
21
  Object.defineProperty(exports, "tabsByRecentUse", { enumerable: true, get: function () { return tab_order_2.tabsByRecentUse; } });
22
- // Persistent vars for storage (write-only, no subscription to avoid oscillation)
22
+ // The window restores its tabs from storage. In a frame these are live bindings to the host.
23
23
  const _persistentActiveTabs = (0, peers_sdk_1.groupDeviceVar)("activeTabs", {
24
24
  defaultValue: [tab_order_1.launcherApp],
25
25
  });
@@ -33,9 +33,23 @@ let finishNavigationRestore = () => { };
33
33
  const navigationReady = new Promise((resolve) => {
34
34
  finishNavigationRestore = resolve;
35
35
  });
36
- // In-memory observables for UI state (loaded once, then write-through to persistent vars)
37
- /** Open tabs. Writes through to device storage after the initial restore. */
36
+ // Expose the existing binding's reads and subscriptions with the same readiness promise as the
37
+ // window. The host owns the tabs. A frame has no second copy to synchronize or write back.
38
+ function frameNavigationValue(source) {
39
+ return Object.assign(() => source(), {
40
+ subscribe: source.subscribe,
41
+ notifySubscribers: source.notifySubscribers,
42
+ subscriberCount: source.subscriberCount,
43
+ loadingPromise: navigationReady,
44
+ });
45
+ }
46
+ /**
47
+ * Open tabs. Writes through to device storage after the initial restore. In a package's frame
48
+ * they're the host's, read only, and follow it.
49
+ */
38
50
  exports.activeTabs = (() => {
51
+ if ((0, frame_realm_1.frameHost)())
52
+ return frameNavigationValue(_persistentActiveTabs);
39
53
  const obs = (0, peers_sdk_1.observable)([tab_order_1.launcherApp]);
40
54
  // Write-through to persistent var on change
41
55
  obs.subscribe((value) => {
@@ -43,8 +57,10 @@ exports.activeTabs = (() => {
43
57
  });
44
58
  return Object.assign(obs, { loadingPromise: navigationReady });
45
59
  })();
46
- /** Id of the tab whose path is showing. */
60
+ /** Id of the tab whose path is showing. In a package's frame, the host's, kept current. */
47
61
  exports.activeTabId = (() => {
62
+ if ((0, frame_realm_1.frameHost)())
63
+ return frameNavigationValue(_persistentActiveTabId);
48
64
  const obs = (0, peers_sdk_1.observable)("launcher");
49
65
  // Write-through to persistent var on change
50
66
  obs.subscribe((value) => {
@@ -61,6 +77,8 @@ let tabHistoryRestored = false;
61
77
  * Ctrl+Tab), never the tab strip. Kept per device.
62
78
  */
63
79
  exports.tabHistory = (() => {
80
+ if ((0, frame_realm_1.frameHost)())
81
+ return frameNavigationValue(_persistentTabHistory);
64
82
  const obs = (0, peers_sdk_1.observable)([]);
65
83
  obs.subscribe((value) => {
66
84
  if (tabHistoryRestored) {
@@ -69,20 +87,11 @@ exports.tabHistory = (() => {
69
87
  });
70
88
  return Object.assign(obs, { loadingPromise: navigationReady });
71
89
  })();
72
- void Promise.all([
90
+ const navigationLoaded = Promise.all([
73
91
  _persistentActiveTabs.loadingPromise,
74
92
  _persistentActiveTabId.loadingPromise,
75
93
  _persistentTabHistory.loadingPromise,
76
- ]).then(() => {
77
- const restored = restoreNavigationState(_persistentActiveTabs(), _persistentActiveTabId());
78
- (0, exports.activeTabs)(restored.tabs);
79
- if ((0, exports.activeTabId)() !== restored.activeId) {
80
- (0, exports.activeTabId)(restored.activeId);
81
- }
82
- tabHistoryRestored = true;
83
- (0, exports.tabHistory)((0, tab_order_1.normalizeTabHistory)(_persistentTabHistory() ?? [], (0, exports.activeTabs)(), (0, exports.activeTabId)()));
84
- finishNavigationRestore();
85
- });
94
+ ]);
86
95
  function sameIds(left, right) {
87
96
  return left.length === right.length && left.every((id, index) => id === right[index]);
88
97
  }
@@ -92,8 +101,23 @@ function refreshTabHistory() {
92
101
  (0, exports.tabHistory)(next);
93
102
  }
94
103
  }
95
- exports.activeTabs.subscribe(refreshTabHistory);
96
- exports.activeTabId.subscribe(refreshTabHistory);
104
+ if ((0, frame_realm_1.frameHost)()) {
105
+ void navigationLoaded.then(finishNavigationRestore);
106
+ }
107
+ else {
108
+ void navigationLoaded.then(() => {
109
+ const restored = restoreNavigationState(_persistentActiveTabs(), _persistentActiveTabId());
110
+ (0, exports.activeTabs)(restored.tabs);
111
+ if ((0, exports.activeTabId)() !== restored.activeId) {
112
+ (0, exports.activeTabId)(restored.activeId);
113
+ }
114
+ tabHistoryRestored = true;
115
+ (0, exports.tabHistory)((0, tab_order_1.normalizeTabHistory)(_persistentTabHistory() ?? [], (0, exports.activeTabs)(), (0, exports.activeTabId)()));
116
+ finishNavigationRestore();
117
+ });
118
+ exports.activeTabs.subscribe(refreshTabHistory);
119
+ exports.activeTabId.subscribe(refreshTabHistory);
120
+ }
97
121
  /** Tab ids whose bodies have been mounted at least once. */
98
122
  exports.initializedTabs = new Set();
99
123
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-ui",
3
- "version": "0.34.7",
3
+ "version": "0.34.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-ui.git"
@@ -36,7 +36,7 @@
36
36
  "lint:fix": "biome check --write ."
37
37
  },
38
38
  "peerDependencies": {
39
- "@peers-app/peers-sdk": "^0.34.7",
39
+ "@peers-app/peers-sdk": "^0.34.9",
40
40
  "bootstrap": "^5.3.3",
41
41
  "react": "^18.0.0",
42
42
  "react-dom": "^18.0.0"
@@ -47,7 +47,7 @@
47
47
  "@babel/preset-react": "^7.24.1",
48
48
  "@babel/preset-typescript": "^7.27.1",
49
49
  "@biomejs/biome": "2.3.11",
50
- "@peers-app/peers-sdk": "0.34.7",
50
+ "@peers-app/peers-sdk": "0.34.9",
51
51
  "@testing-library/dom": "^10.4.0",
52
52
  "@testing-library/jest-dom": "^6.6.3",
53
53
  "@testing-library/react": "^16.3.0",