@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.
- package/dist/command-palette/command-palette-ui.js +14 -14
- package/dist/command-palette/command-palette.d.ts +10 -3
- package/dist/command-palette/command-palette.js +60 -6
- package/dist/command-palette/frame-commands.d.ts +37 -0
- package/dist/command-palette/frame-commands.js +43 -0
- package/dist/globals.d.ts +13 -2
- package/dist/globals.js +24 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +9 -1
- package/dist/isolated-screens/config.js +1 -5
- package/dist/isolated-screens/frame-permissions.d.ts +11 -0
- package/dist/isolated-screens/frame-permissions.js +33 -0
- package/dist/isolated-screens/frame-protocol.d.ts +64 -0
- package/dist/isolated-screens/frame-protocol.js +28 -0
- package/dist/isolated-screens/frame-runtime.js +68 -2
- package/dist/isolated-screens/frame-viewport.d.ts +9 -0
- package/dist/isolated-screens/frame-viewport.js +36 -0
- package/dist/isolated-screens/global-widgets.d.ts +74 -0
- package/dist/isolated-screens/global-widgets.js +270 -0
- package/dist/isolated-screens/isolated-screen.d.ts +51 -1
- package/dist/isolated-screens/isolated-screen.js +228 -14
- package/dist/isolated-screens/piece-reach.d.ts +24 -0
- package/dist/isolated-screens/piece-reach.js +24 -8
- package/dist/isolated-screens/widget-box.d.ts +48 -0
- package/dist/isolated-screens/widget-box.js +193 -0
- package/dist/operator-console/operator-console-state.js +5 -1
- package/dist/root-layout/root-layout-host.js +3 -1
- package/dist/screens/devices/devices-list.d.ts +5 -1
- package/dist/screens/devices/devices-list.js +12 -4
- package/dist/screens/packages/package-info.js +2 -1
- package/dist/screens/packages/package-widgets-panel.d.ts +15 -0
- package/dist/screens/packages/package-widgets-panel.js +64 -0
- package/dist/tabs-layout/tabs-state.d.ts +5 -2
- package/dist/tabs-layout/tabs-state.js +41 -17
- package/package.json +3 -3
|
@@ -11,6 +11,10 @@ const tabs_state_1 = require("../tabs-layout/tabs-state");
|
|
|
11
11
|
const app_catalog_1 = require("../ui-router/app-catalog");
|
|
12
12
|
const routes_loader_1 = require("../ui-router/routes-loader");
|
|
13
13
|
const command_palette_1 = require("./command-palette");
|
|
14
|
+
function chooseCommand(id) {
|
|
15
|
+
(0, command_palette_1.closeCommandPalette)();
|
|
16
|
+
(0, command_palette_1.executeCommand)(id);
|
|
17
|
+
}
|
|
14
18
|
/** Searchable overlay for launching apps and running commands. */
|
|
15
19
|
function CommandPaletteOverlay() {
|
|
16
20
|
const [isOpen] = (0, hooks_1.useObservable)(command_palette_1.isCommandPaletteOpen);
|
|
@@ -71,16 +75,18 @@ function CommandPaletteOverlay() {
|
|
|
71
75
|
allItems.push({ type: "app", app, id: `app-${app.packageId}-${app.path}` });
|
|
72
76
|
});
|
|
73
77
|
// Then add commands
|
|
74
|
-
const
|
|
78
|
+
const groupedCommands = Object.entries(filteredCommands.reduce((acc, cmd) => {
|
|
75
79
|
const category = cmd.category || "Other";
|
|
76
80
|
if (!acc[category])
|
|
77
81
|
acc[category] = [];
|
|
78
82
|
acc[category].push(cmd);
|
|
79
83
|
return acc;
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
}, Object.create(null)));
|
|
85
|
+
for (const [, commands] of groupedCommands) {
|
|
86
|
+
for (const cmd of commands) {
|
|
87
|
+
allItems.push({ type: "command", command: cmd, id: `command-${cmd.id}` });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
84
90
|
// Focus input when opened
|
|
85
91
|
(0, react_1.useEffect)(() => {
|
|
86
92
|
if (isOpen && inputRef.current) {
|
|
@@ -112,7 +118,7 @@ function CommandPaletteOverlay() {
|
|
|
112
118
|
(0, tabs_state_1.goToTabPath)(selectedItem.app.path);
|
|
113
119
|
}
|
|
114
120
|
else if (selectedItem?.type === "command" && selectedItem.command) {
|
|
115
|
-
(
|
|
121
|
+
chooseCommand(selectedItem.command.id);
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
};
|
|
@@ -189,13 +195,7 @@ function CommandPaletteOverlay() {
|
|
|
189
195
|
minWidth: "16px",
|
|
190
196
|
} }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "fw-medium", children: app.displayName }), (0, jsx_runtime_1.jsx)("div", { className: "small text-muted", style: { fontSize: "12px" }, children: app.packageId === "system-apps" ? "System App" : app.packageName })] })] }) }, `${app.packageId}-${app.path}`));
|
|
191
197
|
})] })), filteredCommands.length > 0 &&
|
|
192
|
-
|
|
193
|
-
const category = cmd.category || "Other";
|
|
194
|
-
if (!acc[category])
|
|
195
|
-
acc[category] = [];
|
|
196
|
-
acc[category].push(cmd);
|
|
197
|
-
return acc;
|
|
198
|
-
}, {})).map(([category, commands]) => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "px-3 py-1 small text-muted fw-bold text-uppercase", style: { fontSize: "11px", letterSpacing: "0.5px" }, children: category }), commands.map((command) => {
|
|
198
|
+
groupedCommands.map(([category, commands]) => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "px-3 py-1 small text-muted fw-bold text-uppercase", style: { fontSize: "11px", letterSpacing: "0.5px" }, children: category }), commands.map((command) => {
|
|
199
199
|
const commandId = `command-${command.id}`;
|
|
200
200
|
const globalIndex = allItems.findIndex((item) => item.id === commandId);
|
|
201
201
|
const isSelected = globalIndex === selectedIndex;
|
|
@@ -206,7 +206,7 @@ function CommandPaletteOverlay() {
|
|
|
206
206
|
: ""}`, style: {
|
|
207
207
|
cursor: "pointer",
|
|
208
208
|
transition: "background-color 0.1s ease",
|
|
209
|
-
}, onClick: () => (
|
|
209
|
+
}, onClick: () => chooseCommand(command.id), onMouseEnter: () => setSelectedIndex(globalIndex), children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center", children: [command.iconClassName && ((0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: command.iconClassName, className: "me-3", style: {
|
|
210
210
|
fontSize: "16px",
|
|
211
211
|
color: isSelected ? (isDark ? "#ffffff" : "#0d6efd") : "#6c757d",
|
|
212
212
|
minWidth: "16px",
|
|
@@ -8,8 +8,7 @@ export interface Command {
|
|
|
8
8
|
description?: string;
|
|
9
9
|
/**
|
|
10
10
|
* Keyboard shortcut, as `Mod+Key` with modifiers in the order Cmd, Ctrl, Alt, Shift and the
|
|
11
|
-
* key as `KeyboardEvent.key` names it (for example `Cmd+Alt+ArrowRight`).
|
|
12
|
-
* is built when the palette initializes.
|
|
11
|
+
* key as `KeyboardEvent.key` names it (for example `Cmd+Alt+ArrowRight`).
|
|
13
12
|
*/
|
|
14
13
|
shortcut?: string;
|
|
15
14
|
/** Group heading; searched too. */
|
|
@@ -26,7 +25,9 @@ export declare const isCommandPaletteOpen: import("@peers-app/peers-sdk").Observ
|
|
|
26
25
|
/** The palette's search text. Cleared when it opens or closes. */
|
|
27
26
|
export declare const commandSearchQuery: import("@peers-app/peers-sdk").Observable<string>;
|
|
28
27
|
/**
|
|
29
|
-
* Add a command, or replace the one with its id.
|
|
28
|
+
* Add a command, or replace the one with its id. A package's command shows in the palette under
|
|
29
|
+
* its package's name, and its shortcut, which needs ⌘ or Ctrl, works from any app; a shortcut
|
|
30
|
+
* another command already has is refused.
|
|
30
31
|
*
|
|
31
32
|
* @param command - The command.
|
|
32
33
|
*/
|
|
@@ -37,6 +38,12 @@ export declare function registerCommand(command: Command): void;
|
|
|
37
38
|
* @param commandId - The command's id.
|
|
38
39
|
*/
|
|
39
40
|
export declare function unregisterCommand(commandId: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* The command a shortcut runs, if any.
|
|
43
|
+
*
|
|
44
|
+
* @param shortcut - As `Command.shortcut`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function commandForShortcut(shortcut: string): Command | undefined;
|
|
40
47
|
/**
|
|
41
48
|
* Look up a command.
|
|
42
49
|
*
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.commandSearchQuery = exports.isCommandPaletteOpen = void 0;
|
|
4
4
|
exports.registerCommand = registerCommand;
|
|
5
5
|
exports.unregisterCommand = unregisterCommand;
|
|
6
|
+
exports.commandForShortcut = commandForShortcut;
|
|
6
7
|
exports.getCommand = getCommand;
|
|
7
8
|
exports.getAllCommands = getAllCommands;
|
|
8
9
|
exports.searchCommands = searchCommands;
|
|
@@ -15,12 +16,15 @@ exports.destroyCommandPalette = destroyCommandPalette;
|
|
|
15
16
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
16
17
|
const frame_realm_1 = require("../isolated-screens/frame-realm");
|
|
17
18
|
const tabs_state_1 = require("../tabs-layout/tabs-state");
|
|
19
|
+
const frame_commands_1 = require("./frame-commands");
|
|
18
20
|
/** Whether the command palette is open. In memory only. */
|
|
19
21
|
exports.isCommandPaletteOpen = (0, peers_sdk_1.observable)(false);
|
|
20
22
|
/** The palette's search text. Cleared when it opens or closes. */
|
|
21
23
|
exports.commandSearchQuery = (0, peers_sdk_1.observable)("");
|
|
22
24
|
// Command registry
|
|
23
25
|
const registeredCommands = new Map();
|
|
26
|
+
// Normalized shortcut → command id.
|
|
27
|
+
const shortcutToCommandMap = new Map();
|
|
24
28
|
// Detect platform for keyboard shortcuts
|
|
25
29
|
const isMac = typeof navigator !== "undefined" ? /Mac|iPod|iPhone|iPad/.test(navigator.userAgent) : false;
|
|
26
30
|
const modKey = isMac ? "Cmd" : "Ctrl";
|
|
@@ -96,11 +100,37 @@ for (const cmd of coreCommands) {
|
|
|
96
100
|
registeredCommands.set(cmd.id, cmd);
|
|
97
101
|
}
|
|
98
102
|
/**
|
|
99
|
-
* Add a command, or replace the one with its id.
|
|
103
|
+
* Add a command, or replace the one with its id. A package's command shows in the palette under
|
|
104
|
+
* its package's name, and its shortcut, which needs ⌘ or Ctrl, works from any app; a shortcut
|
|
105
|
+
* another command already has is refused.
|
|
100
106
|
*
|
|
101
107
|
* @param command - The command.
|
|
102
108
|
*/
|
|
103
109
|
function registerCommand(command) {
|
|
110
|
+
const hostBridge = (0, frame_commands_1.commandHostBridge)();
|
|
111
|
+
if (hostBridge) {
|
|
112
|
+
(0, frame_commands_1.setFrameCommandAction)(command.id, command.action);
|
|
113
|
+
hostBridge.register({
|
|
114
|
+
id: command.id,
|
|
115
|
+
label: command.label,
|
|
116
|
+
...(command.description === undefined ? {} : { description: command.description }),
|
|
117
|
+
...(command.shortcut === undefined ? {} : { shortcut: command.shortcut }),
|
|
118
|
+
...(command.iconClassName === undefined ? {} : { iconClassName: command.iconClassName }),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else if (command.shortcut) {
|
|
122
|
+
const key = normalizeShortcut(command.shortcut);
|
|
123
|
+
const owner = shortcutToCommandMap.get(key);
|
|
124
|
+
if (owner && owner !== command.id) {
|
|
125
|
+
console.warn(`${command.shortcut} is already the shortcut for ${registeredCommands.get(owner)?.label ?? owner}`);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
releaseShortcut(registeredCommands.get(command.id));
|
|
129
|
+
shortcutToCommandMap.set(key, command.id);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
releaseShortcut(registeredCommands.get(command.id));
|
|
133
|
+
}
|
|
104
134
|
registeredCommands.set(command.id, command);
|
|
105
135
|
}
|
|
106
136
|
/**
|
|
@@ -109,7 +139,31 @@ function registerCommand(command) {
|
|
|
109
139
|
* @param commandId - The command's id.
|
|
110
140
|
*/
|
|
111
141
|
function unregisterCommand(commandId) {
|
|
142
|
+
const command = registeredCommands.get(commandId);
|
|
112
143
|
registeredCommands.delete(commandId);
|
|
144
|
+
const hostBridge = (0, frame_commands_1.commandHostBridge)();
|
|
145
|
+
if (hostBridge) {
|
|
146
|
+
(0, frame_commands_1.setFrameCommandAction)(commandId, undefined);
|
|
147
|
+
hostBridge.unregister(commandId);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
releaseShortcut(command);
|
|
151
|
+
}
|
|
152
|
+
function releaseShortcut(command) {
|
|
153
|
+
if (command?.shortcut) {
|
|
154
|
+
const key = normalizeShortcut(command.shortcut);
|
|
155
|
+
if (shortcutToCommandMap.get(key) === command.id)
|
|
156
|
+
shortcutToCommandMap.delete(key);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The command a shortcut runs, if any.
|
|
161
|
+
*
|
|
162
|
+
* @param shortcut - As `Command.shortcut`.
|
|
163
|
+
*/
|
|
164
|
+
function commandForShortcut(shortcut) {
|
|
165
|
+
const commandId = shortcutToCommandMap.get(normalizeShortcut(shortcut));
|
|
166
|
+
return commandId ? registeredCommands.get(commandId) : undefined;
|
|
113
167
|
}
|
|
114
168
|
/**
|
|
115
169
|
* Look up a command.
|
|
@@ -162,13 +216,13 @@ function toggleCommandPalette() {
|
|
|
162
216
|
* @param commandId - The command's id.
|
|
163
217
|
*/
|
|
164
218
|
function executeCommand(commandId) {
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
219
|
+
const host = (0, frame_commands_1.commandHostBridge)();
|
|
220
|
+
if (host)
|
|
221
|
+
host.run(commandId);
|
|
222
|
+
else
|
|
223
|
+
getCommand(commandId)?.action();
|
|
169
224
|
}
|
|
170
225
|
// Keyboard shortcut handling
|
|
171
|
-
const shortcutToCommandMap = new Map();
|
|
172
226
|
// Build shortcut map from registered commands
|
|
173
227
|
function buildShortcutMap() {
|
|
174
228
|
shortcutToCommandMap.clear();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IFrameCommand } from "../isolated-screens/frame-protocol";
|
|
2
|
+
/**
|
|
3
|
+
* A package frame's commands: in a frame, `registerCommand` sends a command to the host's palette
|
|
4
|
+
* and keeps its action here, for when the host runs it. Kept apart from the palette, which imports
|
|
5
|
+
* the tabs, so the frame runtime can load it alone.
|
|
6
|
+
*/
|
|
7
|
+
/** The host's palette, as a package's frame reaches it. */
|
|
8
|
+
export interface ICommandHostBridge {
|
|
9
|
+
/** Add one of the frame's commands to the host's palette. */
|
|
10
|
+
register(command: IFrameCommand): void;
|
|
11
|
+
/** Take one of them out. */
|
|
12
|
+
unregister(commandId: string): void;
|
|
13
|
+
/** Run one of the package's commands that another of its frames added. */
|
|
14
|
+
run(commandId: string): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Send this frame's commands to the host's palette. Only the frame runtime calls it.
|
|
18
|
+
*
|
|
19
|
+
* @param bridge - The host's side, or `undefined` to stop (tests).
|
|
20
|
+
*/
|
|
21
|
+
export declare function bridgeCommandsToHost(bridge: ICommandHostBridge | undefined): void;
|
|
22
|
+
/** The host's palette, in a frame; `undefined` in the host's window. */
|
|
23
|
+
export declare function commandHostBridge(): ICommandHostBridge | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Keep a frame command's action, or drop it.
|
|
26
|
+
*
|
|
27
|
+
* @param commandId - The id the frame registered it under.
|
|
28
|
+
* @param action - What it runs; `undefined` to drop it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function setFrameCommandAction(commandId: string, action: (() => void) | undefined): void;
|
|
31
|
+
/**
|
|
32
|
+
* Run a command this frame registered, when the host's palette or a shortcut runs it. Only the
|
|
33
|
+
* frame runtime calls it.
|
|
34
|
+
*
|
|
35
|
+
* @param commandId - The id the frame registered it under.
|
|
36
|
+
*/
|
|
37
|
+
export declare function runFrameCommand(commandId: string): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bridgeCommandsToHost = bridgeCommandsToHost;
|
|
4
|
+
exports.commandHostBridge = commandHostBridge;
|
|
5
|
+
exports.setFrameCommandAction = setFrameCommandAction;
|
|
6
|
+
exports.runFrameCommand = runFrameCommand;
|
|
7
|
+
let hostBridge;
|
|
8
|
+
const actions = new Map();
|
|
9
|
+
/**
|
|
10
|
+
* Send this frame's commands to the host's palette. Only the frame runtime calls it.
|
|
11
|
+
*
|
|
12
|
+
* @param bridge - The host's side, or `undefined` to stop (tests).
|
|
13
|
+
*/
|
|
14
|
+
function bridgeCommandsToHost(bridge) {
|
|
15
|
+
hostBridge = bridge;
|
|
16
|
+
if (!bridge)
|
|
17
|
+
actions.clear();
|
|
18
|
+
}
|
|
19
|
+
/** The host's palette, in a frame; `undefined` in the host's window. */
|
|
20
|
+
function commandHostBridge() {
|
|
21
|
+
return hostBridge;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Keep a frame command's action, or drop it.
|
|
25
|
+
*
|
|
26
|
+
* @param commandId - The id the frame registered it under.
|
|
27
|
+
* @param action - What it runs; `undefined` to drop it.
|
|
28
|
+
*/
|
|
29
|
+
function setFrameCommandAction(commandId, action) {
|
|
30
|
+
if (action)
|
|
31
|
+
actions.set(commandId, action);
|
|
32
|
+
else
|
|
33
|
+
actions.delete(commandId);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Run a command this frame registered, when the host's palette or a shortcut runs it. Only the
|
|
37
|
+
* frame runtime calls it.
|
|
38
|
+
*
|
|
39
|
+
* @param commandId - The id the frame registered it under.
|
|
40
|
+
*/
|
|
41
|
+
function runFrameCommand(commandId) {
|
|
42
|
+
actions.get(commandId)?.();
|
|
43
|
+
}
|
package/dist/globals.d.ts
CHANGED
|
@@ -9,10 +9,21 @@ export declare const mainContentPath: import("@peers-app/peers-sdk").Observable<
|
|
|
9
9
|
export declare function queryParam(name: string, value?: string): string;
|
|
10
10
|
/** Signed profile for the active user after {@link loadGlobals}. */
|
|
11
11
|
export declare let me: IUser;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* The Peers window's width. In a global widget's frame, which is only as big as what the widget
|
|
14
|
+
* draws, it's still the window's, so a widget lays itself out and clamps a drag to the window.
|
|
15
|
+
*/
|
|
13
16
|
export declare const windowWidth: import("@peers-app/peers-sdk").Observable<number>;
|
|
14
|
-
/**
|
|
17
|
+
/** The Peers window's height; in a global widget's frame, the window's too. */
|
|
15
18
|
export declare const windowHeight: import("@peers-app/peers-sdk").Observable<number>;
|
|
19
|
+
/**
|
|
20
|
+
* In a global widget's frame: the Peers window's size, which the host sends, stands for this
|
|
21
|
+
* frame's own from now on. Only the frame runtime calls it.
|
|
22
|
+
*
|
|
23
|
+
* @param width - The window's width.
|
|
24
|
+
* @param height - The window's height.
|
|
25
|
+
*/
|
|
26
|
+
export declare function followHostViewport(width: number, height: number): void;
|
|
16
27
|
/** True when the viewport uses wide-screen navigation. */
|
|
17
28
|
export declare const isDesktop: import("@peers-app/peers-sdk").Observable<boolean>;
|
|
18
29
|
/** Enabled groups available to the active user. */
|
package/dist/globals.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.groups = exports.isDesktop = exports.windowHeight = exports.windowWidth = exports.me = exports.mainContentPath = exports._mainContentPath = exports.packageReloaded = void 0;
|
|
4
4
|
exports.queryParam = queryParam;
|
|
5
|
+
exports.followHostViewport = followHostViewport;
|
|
5
6
|
exports.initializeHashNavigation = initializeHashNavigation;
|
|
6
7
|
exports.loadGlobals = loadGlobals;
|
|
7
8
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
@@ -63,14 +64,35 @@ function queryParam(name, value) {
|
|
|
63
64
|
}
|
|
64
65
|
/** Signed profile for the active user after {@link loadGlobals}. */
|
|
65
66
|
exports.me = null;
|
|
66
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* The Peers window's width. In a global widget's frame, which is only as big as what the widget
|
|
69
|
+
* draws, it's still the window's, so a widget lays itself out and clamps a drag to the window.
|
|
70
|
+
*/
|
|
67
71
|
exports.windowWidth = (0, peers_sdk_1.observable)(window.innerWidth); //.extend({ rateLimit: 500 });
|
|
68
|
-
/**
|
|
72
|
+
/** The Peers window's height; in a global widget's frame, the window's too. */
|
|
69
73
|
exports.windowHeight = (0, peers_sdk_1.observable)(window.innerHeight); //.extend({ rateLimit: 500 });
|
|
74
|
+
/** Set in a global widget's frame: the window's size comes from the host, not this frame's. */
|
|
75
|
+
let viewportFromHost = false;
|
|
70
76
|
window.addEventListener("resize", (_ev) => {
|
|
77
|
+
if (viewportFromHost)
|
|
78
|
+
return;
|
|
71
79
|
(0, exports.windowWidth)(window.innerWidth);
|
|
72
80
|
(0, exports.windowHeight)(window.innerHeight);
|
|
73
81
|
});
|
|
82
|
+
/**
|
|
83
|
+
* In a global widget's frame: the Peers window's size, which the host sends, stands for this
|
|
84
|
+
* frame's own from now on. Only the frame runtime calls it.
|
|
85
|
+
*
|
|
86
|
+
* @param width - The window's width.
|
|
87
|
+
* @param height - The window's height.
|
|
88
|
+
*/
|
|
89
|
+
function followHostViewport(width, height) {
|
|
90
|
+
viewportFromHost = true;
|
|
91
|
+
if ((0, exports.windowWidth)() !== width)
|
|
92
|
+
(0, exports.windowWidth)(width);
|
|
93
|
+
if ((0, exports.windowHeight)() !== height)
|
|
94
|
+
(0, exports.windowHeight)(height);
|
|
95
|
+
}
|
|
74
96
|
/** True when the viewport uses wide-screen navigation. */
|
|
75
97
|
exports.isDesktop = (0, peers_sdk_1.computed)(() => {
|
|
76
98
|
// return windowWidth() > 1200;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { type Command, executeCommand, registerCommand, unregisterCommand, } from "./command-palette/command-palette";
|
|
1
2
|
export * from "./components/color-picker";
|
|
2
3
|
export * from "./components/data-grid";
|
|
3
4
|
export * from "./components/icon";
|
|
@@ -12,7 +13,7 @@ export * from "./components/responsive-section-nav";
|
|
|
12
13
|
export * from "./components/sortable-list";
|
|
13
14
|
export * from "./components/tabs";
|
|
14
15
|
export { Typeahead, type TypeaheadItem } from "./components/typeahead";
|
|
15
|
-
export { isDesktop, mainContentPath } from "./globals";
|
|
16
|
+
export { isDesktop, mainContentPath, windowHeight, windowWidth } from "./globals";
|
|
16
17
|
export * from "./graph/ring-layout";
|
|
17
18
|
export * from "./groups";
|
|
18
19
|
export * from "./hooks";
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.inspectUI = exports.FRAME_SELECTOR_PREFIX = exports.actOnUI = exports.updateActiveTabTitle = exports.goToTabPath = exports.closeCurrentTab = exports.activeTabs = exports.activeTabId = exports.setRootLayout = exports.selectedRootLayoutId = exports.getRootLayouts = exports.getRootLayout = exports.DEFAULT_ROOT_LAYOUT_ID = exports.TabsLayoutApp = exports.RootLayoutHost = exports.LayoutPicker = exports.unregisterGlobalOverlay = exports.registerGlobalOverlay = exports.globalOverlays = exports.notificationHostControls = exports.openMention = exports.useMentionPlace = exports.MentionGroupContext = exports.MentionChip = exports.openLink = exports.mainContentPath = exports.isDesktop = exports.Typeahead = exports.MarkdownEditor = exports.configureIconSearchIndexes = void 0;
|
|
17
|
+
exports.inspectUI = exports.FRAME_SELECTOR_PREFIX = exports.actOnUI = exports.updateActiveTabTitle = exports.goToTabPath = exports.closeCurrentTab = exports.activeTabs = exports.activeTabId = exports.setRootLayout = exports.selectedRootLayoutId = exports.getRootLayouts = exports.getRootLayout = exports.DEFAULT_ROOT_LAYOUT_ID = exports.TabsLayoutApp = exports.RootLayoutHost = exports.LayoutPicker = exports.unregisterGlobalOverlay = exports.registerGlobalOverlay = exports.globalOverlays = exports.notificationHostControls = exports.openMention = exports.useMentionPlace = exports.MentionGroupContext = exports.MentionChip = exports.openLink = exports.windowWidth = exports.windowHeight = exports.mainContentPath = exports.isDesktop = exports.Typeahead = exports.MarkdownEditor = exports.configureIconSearchIndexes = exports.unregisterCommand = exports.registerCommand = exports.executeCommand = void 0;
|
|
18
|
+
// Commands in the command palette, with optional shortcuts. From a package's frame they go to the
|
|
19
|
+
// host's palette, under the package's name.
|
|
20
|
+
var command_palette_1 = require("./command-palette/command-palette");
|
|
21
|
+
Object.defineProperty(exports, "executeCommand", { enumerable: true, get: function () { return command_palette_1.executeCommand; } });
|
|
22
|
+
Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_palette_1.registerCommand; } });
|
|
23
|
+
Object.defineProperty(exports, "unregisterCommand", { enumerable: true, get: function () { return command_palette_1.unregisterCommand; } });
|
|
18
24
|
__exportStar(require("./components/color-picker"), exports);
|
|
19
25
|
__exportStar(require("./components/data-grid"), exports);
|
|
20
26
|
__exportStar(require("./components/icon"), exports);
|
|
@@ -34,6 +40,8 @@ Object.defineProperty(exports, "Typeahead", { enumerable: true, get: function ()
|
|
|
34
40
|
var globals_1 = require("./globals");
|
|
35
41
|
Object.defineProperty(exports, "isDesktop", { enumerable: true, get: function () { return globals_1.isDesktop; } });
|
|
36
42
|
Object.defineProperty(exports, "mainContentPath", { enumerable: true, get: function () { return globals_1.mainContentPath; } });
|
|
43
|
+
Object.defineProperty(exports, "windowHeight", { enumerable: true, get: function () { return globals_1.windowHeight; } });
|
|
44
|
+
Object.defineProperty(exports, "windowWidth", { enumerable: true, get: function () { return globals_1.windowWidth; } });
|
|
37
45
|
// Groups: names, colors and icons from System Groups, and the dialog that edits a group's look.
|
|
38
46
|
__exportStar(require("./graph/ring-layout"), exports);
|
|
39
47
|
__exportStar(require("./groups"), exports);
|
|
@@ -12,13 +12,9 @@ let runtimeSource;
|
|
|
12
12
|
* can't do for it yet. The list only shrinks: each entry goes when its reason does.
|
|
13
13
|
*/
|
|
14
14
|
exports.SHARED_WINDOW_PACKAGES = new Map([
|
|
15
|
-
[
|
|
16
|
-
"00mh0wlipjixk2gqmurbwee0o",
|
|
17
|
-
"Tasks: its timer overlay shows over every app (global widgets, task 00mwiaq9279nj7u3a8cchwjin)",
|
|
18
|
-
],
|
|
19
15
|
[
|
|
20
16
|
"00mwi9ux5ate4rpcr26wdedph",
|
|
21
|
-
"Operator:
|
|
17
|
+
"Operator: Talk uses the microphone, which a frame's opaque origin can't open (Chromium and WebKit refuse it even with allow=microphone), and its settings write a secret variable (the OpenAI key), which frames can't. Its declared widget draws in the window.",
|
|
22
18
|
],
|
|
23
19
|
[
|
|
24
20
|
"00mp0gayf4f9hotacqsobyv6w",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Observable } from "@peers-app/peers-sdk";
|
|
2
|
+
/** The global widgets turned off on this device, as `<packageId>:<widgetId>`. */
|
|
3
|
+
export declare const globalWidgetsOff: Observable<string[]>;
|
|
4
|
+
/**
|
|
5
|
+
* Turn one of a package's global widgets off on this device, or back on.
|
|
6
|
+
*
|
|
7
|
+
* @param packageId - The package.
|
|
8
|
+
* @param widgetId - The widget's id in it.
|
|
9
|
+
* @param on - Whether it shows.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setGlobalWidgetOn(packageId: string, widgetId: string, on: boolean): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.globalWidgetsOff = void 0;
|
|
4
|
+
exports.setGlobalWidgetOn = setGlobalWidgetOn;
|
|
5
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
|
+
const frame_realm_1 = require("./frame-realm");
|
|
7
|
+
// What the person chose for packages' global widgets on this device. Peers' own variables: a
|
|
8
|
+
// package's frame can't read or write them, since its variables are stored under its own id.
|
|
9
|
+
/**
|
|
10
|
+
* One of Peers' own device lists, in the window. Every package's frame loads this module too
|
|
11
|
+
* (it's part of peers-ui) but never reads these, so there it's a plain list, and the frame's
|
|
12
|
+
* start doesn't ask the host for variables it has no use for.
|
|
13
|
+
*
|
|
14
|
+
* @param name - The variable's name.
|
|
15
|
+
*/
|
|
16
|
+
function hostDeviceList(name) {
|
|
17
|
+
return (0, frame_realm_1.isInFrame)() ? (0, peers_sdk_1.observable)([]) : (0, peers_sdk_1.deviceVar)(name, { defaultValue: [] });
|
|
18
|
+
}
|
|
19
|
+
/** The global widgets turned off on this device, as `<packageId>:<widgetId>`. */
|
|
20
|
+
exports.globalWidgetsOff = hostDeviceList("globalWidgetsOff");
|
|
21
|
+
/**
|
|
22
|
+
* Turn one of a package's global widgets off on this device, or back on.
|
|
23
|
+
*
|
|
24
|
+
* @param packageId - The package.
|
|
25
|
+
* @param widgetId - The widget's id in it.
|
|
26
|
+
* @param on - Whether it shows.
|
|
27
|
+
*/
|
|
28
|
+
function setGlobalWidgetOn(packageId, widgetId, on) {
|
|
29
|
+
const key = `${packageId}:${widgetId}`;
|
|
30
|
+
const current = Array.isArray((0, exports.globalWidgetsOff)()) ? (0, exports.globalWidgetsOff)() : [];
|
|
31
|
+
const without = current.filter((entry) => entry !== key);
|
|
32
|
+
(0, exports.globalWidgetsOff)(on ? without : [...without, key]);
|
|
33
|
+
}
|
|
@@ -49,6 +49,14 @@ export interface IFrameInit {
|
|
|
49
49
|
*/
|
|
50
50
|
overSlot?: boolean;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* For a global widget's frame instead of a screen's: the widget's id in its package, and where
|
|
54
|
+
* the host put the frame (see {@link IWidgetPlacement}). The UI to draw is `peersUIId`.
|
|
55
|
+
*/
|
|
56
|
+
widget?: {
|
|
57
|
+
id: string;
|
|
58
|
+
placement: IWidgetPlacement;
|
|
59
|
+
};
|
|
52
60
|
/** The tab's path. */
|
|
53
61
|
path: string;
|
|
54
62
|
/** The host's theme. */
|
|
@@ -61,6 +69,34 @@ export interface IFrameInit {
|
|
|
61
69
|
*/
|
|
62
70
|
legacyStorage: Record<string, string>;
|
|
63
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Where the host put a global widget's frame, in the window's coordinates, and the window's size.
|
|
74
|
+
* The widget's frame lays its content out as if it were the whole window, shifted by `x` and `y`,
|
|
75
|
+
* so `position: fixed` in the widget means the window.
|
|
76
|
+
*/
|
|
77
|
+
export interface IWidgetPlacement {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
/** The window's width. */
|
|
83
|
+
viewportWidth: number;
|
|
84
|
+
/** The window's height. */
|
|
85
|
+
viewportHeight: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A command a package's frame adds to the command palette: everything but its action. It's listed
|
|
89
|
+
* under its package's name, whatever category the frame gives it.
|
|
90
|
+
*/
|
|
91
|
+
export interface IFrameCommand {
|
|
92
|
+
/** Its id within the package. */
|
|
93
|
+
id: string;
|
|
94
|
+
label: string;
|
|
95
|
+
description?: string;
|
|
96
|
+
/** As `Command.shortcut`: `Cmd+J` and the like, with ⌘ or Ctrl. */
|
|
97
|
+
shortcut?: string;
|
|
98
|
+
iconClassName?: string;
|
|
99
|
+
}
|
|
64
100
|
/** A request the frame makes of the host, by name. */
|
|
65
101
|
export declare const FrameRequest: {
|
|
66
102
|
/** A legacy RPC call (`rpcServerCalls`), checked by the host's policy. */
|
|
@@ -98,6 +134,18 @@ export declare const FrameRequest: {
|
|
|
98
134
|
* keeps, as Retry does in its own window, and every screen resolves its pieces again.
|
|
99
135
|
*/
|
|
100
136
|
readonly pieceRetry: "piece.retry";
|
|
137
|
+
/**
|
|
138
|
+
* Add a command to the host's command palette, as the frame's package: an
|
|
139
|
+
* {@link IFrameCommand}. The host runs it by telling this frame (`command.run`).
|
|
140
|
+
*/
|
|
141
|
+
readonly commandRegister: "command.register";
|
|
142
|
+
/** Remove one of the frame's commands: `{ id }`. */
|
|
143
|
+
readonly commandUnregister: "command.unregister";
|
|
144
|
+
/**
|
|
145
|
+
* Run one of the frame's package's commands, which another of the package's frames registered
|
|
146
|
+
* (a screen asking its global widget to open): `{ id }`.
|
|
147
|
+
*/
|
|
148
|
+
readonly commandRun: "command.run";
|
|
101
149
|
};
|
|
102
150
|
/** A notification the frame sends the host, by name. */
|
|
103
151
|
export declare const FrameNotice: {
|
|
@@ -159,6 +207,18 @@ export declare const FrameNotice: {
|
|
|
159
207
|
readonly wheel: "frame.wheel";
|
|
160
208
|
/** The user asked to start a screen that failed to load again: the host makes a new frame. */
|
|
161
209
|
readonly restart: "frame.restart";
|
|
210
|
+
/**
|
|
211
|
+
* From a global widget's frame: the box its content covers, in the window's coordinates,
|
|
212
|
+
* `{ box: { x, y, width, height } }`, or `{ box: null }` when it draws nothing. The host puts the
|
|
213
|
+
* frame over that box.
|
|
214
|
+
*/
|
|
215
|
+
readonly widgetBox: "widget.box";
|
|
216
|
+
/**
|
|
217
|
+
* From a global widget's frame: an element in it captured the pointer (`{ active: true }`, a drag
|
|
218
|
+
* started) or let it go (`{ active: false }`). While it holds it, the frame covers the window,
|
|
219
|
+
* so the drag doesn't lose the pointer at the frame's edge.
|
|
220
|
+
*/
|
|
221
|
+
readonly widgetCapture: "widget.capture";
|
|
162
222
|
};
|
|
163
223
|
/** A request the host makes of the frame, by name. */
|
|
164
224
|
export declare const HostRequest: {
|
|
@@ -219,4 +279,8 @@ export declare const HostNotice: {
|
|
|
219
279
|
readonly pieceWheel: "piece.wheel";
|
|
220
280
|
/** Something a piece resolution depends on changed: the screen resolves its pieces again. */
|
|
221
281
|
readonly pieceRevision: "piece.revision";
|
|
282
|
+
/** A global widget's frame moved: an {@link IWidgetPlacement}. */
|
|
283
|
+
readonly widgetPlacement: "widget.placement";
|
|
284
|
+
/** Run one of the frame's commands: `{ id }`. */
|
|
285
|
+
readonly commandRun: "command.run";
|
|
222
286
|
};
|
|
@@ -47,6 +47,18 @@ exports.FrameRequest = {
|
|
|
47
47
|
* keeps, as Retry does in its own window, and every screen resolves its pieces again.
|
|
48
48
|
*/
|
|
49
49
|
pieceRetry: "piece.retry",
|
|
50
|
+
/**
|
|
51
|
+
* Add a command to the host's command palette, as the frame's package: an
|
|
52
|
+
* {@link IFrameCommand}. The host runs it by telling this frame (`command.run`).
|
|
53
|
+
*/
|
|
54
|
+
commandRegister: "command.register",
|
|
55
|
+
/** Remove one of the frame's commands: `{ id }`. */
|
|
56
|
+
commandUnregister: "command.unregister",
|
|
57
|
+
/**
|
|
58
|
+
* Run one of the frame's package's commands, which another of the package's frames registered
|
|
59
|
+
* (a screen asking its global widget to open): `{ id }`.
|
|
60
|
+
*/
|
|
61
|
+
commandRun: "command.run",
|
|
50
62
|
};
|
|
51
63
|
/** A notification the frame sends the host, by name. */
|
|
52
64
|
exports.FrameNotice = {
|
|
@@ -108,6 +120,18 @@ exports.FrameNotice = {
|
|
|
108
120
|
wheel: "frame.wheel",
|
|
109
121
|
/** The user asked to start a screen that failed to load again: the host makes a new frame. */
|
|
110
122
|
restart: "frame.restart",
|
|
123
|
+
/**
|
|
124
|
+
* From a global widget's frame: the box its content covers, in the window's coordinates,
|
|
125
|
+
* `{ box: { x, y, width, height } }`, or `{ box: null }` when it draws nothing. The host puts the
|
|
126
|
+
* frame over that box.
|
|
127
|
+
*/
|
|
128
|
+
widgetBox: "widget.box",
|
|
129
|
+
/**
|
|
130
|
+
* From a global widget's frame: an element in it captured the pointer (`{ active: true }`, a drag
|
|
131
|
+
* started) or let it go (`{ active: false }`). While it holds it, the frame covers the window,
|
|
132
|
+
* so the drag doesn't lose the pointer at the frame's edge.
|
|
133
|
+
*/
|
|
134
|
+
widgetCapture: "widget.capture",
|
|
111
135
|
};
|
|
112
136
|
/** A request the host makes of the frame, by name. */
|
|
113
137
|
exports.HostRequest = {
|
|
@@ -168,4 +192,8 @@ exports.HostNotice = {
|
|
|
168
192
|
pieceWheel: "piece.wheel",
|
|
169
193
|
/** Something a piece resolution depends on changed: the screen resolves its pieces again. */
|
|
170
194
|
pieceRevision: "piece.revision",
|
|
195
|
+
/** A global widget's frame moved: an {@link IWidgetPlacement}. */
|
|
196
|
+
widgetPlacement: "widget.placement",
|
|
197
|
+
/** Run one of the frame's commands: `{ id }`. */
|
|
198
|
+
commandRun: "command.run",
|
|
171
199
|
};
|