@peers-app/peers-ui 0.33.8 → 0.33.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.
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appPathOfRecent = appPathOfRecent;
4
+ exports.pinsFromRecents = pinsFromRecents;
5
+ exports.pinnedAppsReady = pinnedAppsReady;
6
+ exports.currentPins = currentPins;
7
+ exports.usePinnedApps = usePinnedApps;
8
+ exports.pinApp = pinApp;
9
+ exports.unpinApp = unpinApp;
10
+ exports.reorderPins = reorderPins;
11
+ exports.withShownReordered = withShownReordered;
12
+ exports.movePin = movePin;
13
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
14
+ const lodash_1 = require("lodash");
15
+ const react_1 = require("react");
16
+ const use_observable_1 = require("../hooks/use-observable");
17
+ const identity_routes_1 = require("../screens/identity/identity-routes");
18
+ const tabs_state_1 = require("../tabs-layout/tabs-state");
19
+ /**
20
+ * The apps pinned to the top of the Apps screen, as canonical app paths in the user's order.
21
+ * One list per group, synced across the user's devices. Unset until the user first changes it.
22
+ */
23
+ const pinnedAppsVar = (0, peers_sdk_1.groupUserVar)("pinnedApps");
24
+ /**
25
+ * The launcher's recently used apps, from before pins. Nothing writes it now; it only gives the
26
+ * pins their first value, until the user changes them.
27
+ */
28
+ const legacyRecentApps = (0, peers_sdk_1.groupUserVar)("recentlyUsedApps");
29
+ /** How many recent apps become pins when a group's pins were never set. */
30
+ const SEEDED_PIN_COUNT = 4;
31
+ /**
32
+ * The app path a stored recent path belongs to: a built-in app's first segment, or a package's
33
+ * `package-nav/<packageId>/<nav>`. Legacy identity routes map onto Identity, and the routes of
34
+ * removed built-in apps name nothing.
35
+ *
36
+ * @param path - A path from the old recents list, possibly a deep link or a legacy alias.
37
+ * @returns The app's path, or `undefined` when the path names no app.
38
+ */
39
+ function appPathOfRecent(path) {
40
+ const canonical = (0, identity_routes_1.canonicalizeRoute)(path);
41
+ if ((0, identity_routes_1.isIdentityPath)(canonical))
42
+ return identity_routes_1.IDENTITY_APP_PATH;
43
+ if ((0, tabs_state_1.isRemovedAppRoute)(canonical))
44
+ return undefined;
45
+ const segments = (0, identity_routes_1.parseRoute)(canonical)
46
+ .pathname.split("/")
47
+ .filter(Boolean)
48
+ .map((segment) => segment.toLowerCase());
49
+ if (segments[0] === "package-nav") {
50
+ return segments.length >= 3 ? segments.slice(0, 3).join("/") : undefined;
51
+ }
52
+ return segments[0];
53
+ }
54
+ /**
55
+ * The pins a group starts with when they were never set: the first four distinct apps of the
56
+ * old recents list.
57
+ *
58
+ * @param recents - The old recents, newest first.
59
+ */
60
+ function pinsFromRecents(recents) {
61
+ const pins = [];
62
+ for (const recent of recents) {
63
+ const path = appPathOfRecent(recent);
64
+ if (path && !pins.includes(path))
65
+ pins.push(path);
66
+ if (pins.length === SEEDED_PIN_COUNT)
67
+ break;
68
+ }
69
+ return pins;
70
+ }
71
+ /**
72
+ * This device's pins, which the screen reads instead of the stored var. When changes come
73
+ * quickly, the stored var can briefly go back to an older list as its own writes echo back, and
74
+ * then drop the newer writes as stale; this copy keeps the newest list and writes it again.
75
+ */
76
+ const localPins = (0, peers_sdk_1.observable)(undefined);
77
+ const pinsLoaded = (0, peers_sdk_1.observable)(false);
78
+ /** Lists written here recently, newest last: the stored var going back to one is an echo. */
79
+ const recentWrites = [];
80
+ /** How long a write here can still echo back. */
81
+ const ECHO_WINDOW_MS = 30_000;
82
+ let pinsReady;
83
+ /**
84
+ * Load the stored pins and follow changes made on the user's other devices. Safe to call more
85
+ * than once.
86
+ */
87
+ function pinnedAppsReady() {
88
+ pinsReady ??= Promise.all([pinnedAppsVar.loadingPromise, legacyRecentApps.loadingPromise]).then(() => {
89
+ localPins(pinnedAppsVar());
90
+ pinsLoaded(true);
91
+ pinnedAppsVar.subscribe(onStoredPins);
92
+ });
93
+ return pinsReady;
94
+ }
95
+ function onStoredPins(stored) {
96
+ if ((0, lodash_1.isEqual)(stored, localPins()))
97
+ return;
98
+ const now = Date.now();
99
+ const echo = recentWrites.some((write) => now - write.at < ECHO_WINDOW_MS && (0, lodash_1.isEqual)(write.pins, stored));
100
+ if (!echo) {
101
+ localPins(stored); // changed on another device
102
+ return;
103
+ }
104
+ // An older write here came back: store the newest pins again, after this change settles.
105
+ setTimeout(() => {
106
+ const latest = localPins();
107
+ if (latest && !(0, lodash_1.isEqual)(pinnedAppsVar(), latest))
108
+ pinnedAppsVar(latest);
109
+ }, 0);
110
+ }
111
+ /**
112
+ * Run a change to the pins now, or once they've loaded: before then the change would start from
113
+ * an empty or seeded list and replace the stored pins.
114
+ */
115
+ function whenPinsLoaded(change) {
116
+ if (pinsLoaded())
117
+ change();
118
+ else
119
+ void pinnedAppsReady().then(change);
120
+ }
121
+ function writePins(pins) {
122
+ localPins(pins);
123
+ recentWrites.push({ pins, at: Date.now() });
124
+ if (recentWrites.length > 20)
125
+ recentWrites.shift();
126
+ pinnedAppsVar(pins);
127
+ }
128
+ /**
129
+ * The pins in effect: the stored list, or, until one is stored, the pins seeded from the old
130
+ * recents. The seed isn't written, so a device that hasn't synced yet can't replace pins set on
131
+ * another device.
132
+ */
133
+ function currentPins() {
134
+ return localPins() ?? pinsFromRecents(legacyRecentApps() ?? []);
135
+ }
136
+ /**
137
+ * The pinned app paths in order, including apps that aren't installed now (the screen hides
138
+ * those, and they come back if the app is installed again). `loaded` is false until the stored
139
+ * pins have loaded; `pins` stays empty until then so an early recents load can't show the seed.
140
+ */
141
+ function usePinnedApps() {
142
+ (0, react_1.useEffect)(() => {
143
+ void pinnedAppsReady();
144
+ }, []);
145
+ const [local] = (0, use_observable_1.useObservable)(localPins);
146
+ const [recents] = (0, use_observable_1.useObservable)(legacyRecentApps);
147
+ const [loaded] = (0, use_observable_1.useObservable)(pinsLoaded);
148
+ return { pins: loaded ? (local ?? pinsFromRecents(recents ?? [])) : [], loaded };
149
+ }
150
+ /**
151
+ * Pin an app at the end of the list. Pinning a pinned app changes nothing. Before the stored
152
+ * pins have loaded, this waits for them.
153
+ *
154
+ * @param path - The app's canonical path.
155
+ */
156
+ function pinApp(path) {
157
+ whenPinsLoaded(() => {
158
+ const pins = currentPins();
159
+ if (!pins.includes(path))
160
+ writePins([...pins, path]);
161
+ });
162
+ }
163
+ /**
164
+ * Unpin an app. Before the stored pins have loaded, this waits for them.
165
+ *
166
+ * @param path - The app's canonical path.
167
+ */
168
+ function unpinApp(path) {
169
+ whenPinsLoaded(() => {
170
+ const pins = currentPins();
171
+ if (pins.includes(path))
172
+ writePins(pins.filter((pin) => pin !== path));
173
+ });
174
+ }
175
+ /**
176
+ * Put the shown pins in a new order. Pins that aren't shown (apps not installed now) keep their
177
+ * places in the stored list. Before the stored pins have loaded, this waits for them.
178
+ *
179
+ * @param shown - The pins on screen, in their current order.
180
+ * @param reordered - The same pins in the new order.
181
+ */
182
+ function reorderPins(shown, reordered) {
183
+ whenPinsLoaded(() => writePins(withShownReordered(currentPins(), shown, reordered)));
184
+ }
185
+ /**
186
+ * Replace the shown pins' slots in `pins` with `reordered`, leaving the other pins in place.
187
+ *
188
+ * @param pins - Every pin, in stored order.
189
+ * @param shown - The pins on screen, in their current order; each one is in `pins`.
190
+ * @param reordered - `shown` in its new order.
191
+ */
192
+ function withShownReordered(pins, shown, reordered) {
193
+ const visible = new Set(shown);
194
+ let next = 0;
195
+ return pins.map((pin) => (visible.has(pin) ? (reordered[next++] ?? pin) : pin));
196
+ }
197
+ /**
198
+ * Move a shown pin one place earlier or later among the shown pins.
199
+ *
200
+ * @param shown - The pins on screen, in order.
201
+ * @param path - The pin to move.
202
+ * @param step - -1 for earlier, 1 for later.
203
+ */
204
+ function movePin(shown, path, step) {
205
+ const from = shown.indexOf(path);
206
+ const to = from + step;
207
+ if (from < 0 || to < 0 || to >= shown.length)
208
+ return;
209
+ const reordered = [...shown];
210
+ reordered.splice(from, 1);
211
+ reordered.splice(to, 0, path);
212
+ reorderPins(shown, reordered);
213
+ }
@@ -0,0 +1,20 @@
1
+ import type React from "react";
2
+ import type { IAppEntry } from "../ui-router/app-catalog";
3
+ interface IRemoveAppDialogProps {
4
+ /** The app whose package is removed. */
5
+ entry: IAppEntry;
6
+ /** The package's other apps, which go with it. */
7
+ otherApps: readonly IAppEntry[];
8
+ /** The group (or "Personal") it's removed from. */
9
+ groupName: string;
10
+ /** Remove the package. A rejection is shown in the dialog. */
11
+ onConfirm: () => Promise<void>;
12
+ /** Close without removing. */
13
+ onCancel: () => void;
14
+ }
15
+ /**
16
+ * Asks before removing an app's package from the group, since that removes it for every device
17
+ * there. A modal dialog: focus starts on Cancel and stays inside, and Escape cancels.
18
+ */
19
+ export declare function RemoveAppDialog({ entry, otherApps, groupName, onConfirm, onCancel, }: IRemoveAppDialogProps): React.ReactPortal;
20
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RemoveAppDialog = RemoveAppDialog;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_dom_1 = require("react-dom");
7
+ /**
8
+ * Asks before removing an app's package from the group, since that removes it for every device
9
+ * there. A modal dialog: focus starts on Cancel and stays inside, and Escape cancels.
10
+ */
11
+ function RemoveAppDialog({ entry, otherApps, groupName, onConfirm, onCancel, }) {
12
+ const dialogRef = (0, react_1.useRef)(null);
13
+ const cancelRef = (0, react_1.useRef)(null);
14
+ const [removing, setRemoving] = (0, react_1.useState)(false);
15
+ const [error, setError] = (0, react_1.useState)();
16
+ const name = otherApps.length ? entry.packageName : entry.displayName;
17
+ (0, react_1.useEffect)(() => {
18
+ cancelRef.current?.focus();
19
+ }, []);
20
+ const onKeyDown = (event) => {
21
+ if (event.key === "Escape" && !removing) {
22
+ event.preventDefault();
23
+ onCancel();
24
+ return;
25
+ }
26
+ if (event.key !== "Tab")
27
+ return;
28
+ const focusable = Array.from(dialogRef.current?.querySelectorAll("button:not(:disabled)") ?? []);
29
+ if (!focusable.length)
30
+ return;
31
+ const first = focusable[0];
32
+ const last = focusable[focusable.length - 1];
33
+ if (event.shiftKey && document.activeElement === first) {
34
+ event.preventDefault();
35
+ last.focus();
36
+ }
37
+ else if (!event.shiftKey && document.activeElement === last) {
38
+ event.preventDefault();
39
+ first.focus();
40
+ }
41
+ };
42
+ const remove = async () => {
43
+ setRemoving(true);
44
+ setError(undefined);
45
+ try {
46
+ await onConfirm();
47
+ }
48
+ catch (err) {
49
+ setError(err instanceof Error ? err.message : String(err));
50
+ setRemoving(false);
51
+ }
52
+ };
53
+ return (0, react_dom_1.createPortal)(
54
+ // biome-ignore lint/a11y/noStaticElementInteractions: a pointer-only backdrop; Escape cancels
55
+ (0, jsx_runtime_1.jsx)("div", { className: "peers-apps-dialog-backdrop", onMouseDown: (event) => {
56
+ if (event.target === event.currentTarget && !removing)
57
+ onCancel();
58
+ }, children: (0, jsx_runtime_1.jsxs)("div", { ref: dialogRef, className: "peers-apps-dialog text-body", role: "dialog", "aria-modal": "true", "aria-labelledby": "peers-remove-app-title", "aria-describedby": "peers-remove-app-text", onKeyDown: onKeyDown, "data-testid": "remove-app-dialog", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-apps-dialog-head", children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${entry.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("i", { className: entry.iconClassName }) }), (0, jsx_runtime_1.jsxs)("h3", { id: "peers-remove-app-title", children: ["Remove ", name, " from ", groupName, "?"] })] }), (0, jsx_runtime_1.jsxs)("p", { id: "peers-remove-app-text", children: [name, " is removed for every device in ", groupName, ".", otherApps.length > 0 &&
59
+ ` Its other ${otherApps.length === 1 ? "app" : "apps"}, ${otherApps
60
+ .map((app) => app.displayName)
61
+ .join(", ")}, ${otherApps.length === 1 ? "goes" : "go"} with it.`, " ", "You can install it again from Get apps."] }), error && ((0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2 px-3 small", role: "alert", children: error })), (0, jsx_runtime_1.jsxs)("div", { className: "peers-apps-dialog-actions", children: [(0, jsx_runtime_1.jsx)("button", { ref: cancelRef, type: "button", className: "btn peers-apps-ghost", onClick: onCancel, disabled: removing, children: "Cancel" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-danger", onClick: remove, disabled: removing, "data-testid": "remove-app-confirm", children: removing ? "Removing…" : "Remove" })] })] }) }), document.body);
62
+ }
@@ -6,8 +6,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_1 = require("react");
7
7
  const hooks_1 = require("../hooks");
8
8
  const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
9
- const system_apps_1 = require("../system-apps");
10
9
  const tabs_state_1 = require("../tabs-layout/tabs-state");
10
+ const app_catalog_1 = require("../ui-router/app-catalog");
11
11
  const routes_loader_1 = require("../ui-router/routes-loader");
12
12
  const command_palette_1 = require("./command-palette");
13
13
  /** Searchable overlay for launching apps and running commands. */
@@ -50,38 +50,7 @@ function CommandPaletteOverlay() {
50
50
  const searchQuery = localQuery;
51
51
  const filteredCommands = (0, command_palette_1.searchCommands)(searchQuery);
52
52
  // Get all apps (system and user)
53
- const getAllApps = () => {
54
- const allPackages_ = [...packages, system_apps_1.systemPackage];
55
- return allPackages_
56
- .filter((p) => !p.disabled && p.appNavs && p.appNavs.length > 0)
57
- .flatMap((pkg) => {
58
- const navs = pkg.appNavs;
59
- if (!navs)
60
- return [];
61
- return navs.map((navItem) => {
62
- // Construct path - use direct path for system apps, package-nav for others
63
- let path;
64
- if (pkg.packageId === "system-apps") {
65
- path = navItem.navigationPath ?? navItem.name.replace(/\s/g, "-").toLowerCase();
66
- }
67
- else {
68
- path = `package-nav/${pkg.packageId}/${(navItem.navigationPath ?? navItem.name).replace(/[^a-zA-Z0-9]/g, "-").toLowerCase()}`;
69
- while (path.includes("//")) {
70
- path = path.replace("//", "/");
71
- }
72
- }
73
- return {
74
- packageId: pkg.packageId,
75
- packageName: pkg.name,
76
- navItem,
77
- path,
78
- name: navItem.name,
79
- displayName: navItem.displayName || navItem.name,
80
- iconClassName: navItem.iconClassName || "bi-box-seam",
81
- };
82
- });
83
- });
84
- };
53
+ const getAllApps = () => (0, app_catalog_1.buildAppCatalog)(packages);
85
54
  // Search apps
86
55
  const searchApps = (query) => {
87
56
  if (!query.trim())
@@ -92,7 +92,6 @@ function RootLayoutBootstrap(props) {
92
92
  await Promise.all([
93
93
  tabs_state_1.activeTabs.loadingPromise,
94
94
  tabs_state_1.activeTabId.loadingPromise,
95
- tabs_state_1.recentlyUsedApps.loadingPromise,
96
95
  peers_sdk_1.hasShownWelcomeModal.loadingPromise,
97
96
  ]);
98
97
  (0, globals_1.initializeHashNavigation)();
@@ -5,8 +5,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const hooks_1 = require("../../hooks");
7
7
  const mention_configs_1 = require("../../mention-configs");
8
- const system_apps_1 = require("../../system-apps");
9
8
  const tabs_state_1 = require("../../tabs-layout/tabs-state");
9
+ const app_catalog_1 = require("../../ui-router/app-catalog");
10
10
  const routes_loader_1 = require("../../ui-router/routes-loader");
11
11
  const color_mode_dropdown_1 = require("../settings/color-mode-dropdown");
12
12
  const searchConfigs = [
@@ -31,38 +31,7 @@ function GlobalSearch() {
31
31
  }
32
32
  }, []);
33
33
  // Get all apps (system and user)
34
- const getAllApps = (0, react_1.useCallback)(() => {
35
- const allPackages_ = [...packages, system_apps_1.systemPackage];
36
- return allPackages_
37
- .filter((p) => !p.disabled && p.appNavs && p.appNavs.length > 0)
38
- .flatMap((pkg) => {
39
- const navs = pkg.appNavs;
40
- if (!navs?.length)
41
- return [];
42
- return navs.map((navItem) => {
43
- // Construct path - use direct path for system apps, package-nav for others
44
- let path;
45
- if (pkg.packageId === "system-apps") {
46
- path = navItem.navigationPath ?? navItem.name.replace(/\s/g, "-").toLowerCase();
47
- }
48
- else {
49
- path = `package-nav/${pkg.packageId}/${(navItem.navigationPath ?? navItem.name).replace(/[^a-zA-Z0-9]/g, "-").toLowerCase()}`;
50
- while (path.includes("//")) {
51
- path = path.replace("//", "/");
52
- }
53
- }
54
- return {
55
- packageId: pkg.packageId,
56
- packageName: pkg.name,
57
- navItem,
58
- path,
59
- name: navItem.name,
60
- displayName: navItem.displayName || navItem.name,
61
- iconClassName: navItem.iconClassName || "bi-box-seam",
62
- };
63
- });
64
- });
65
- }, [packages]);
34
+ const getAllApps = (0, react_1.useCallback)(() => (0, app_catalog_1.buildAppCatalog)(packages), [packages]);
66
35
  // Debounced search effect
67
36
  (0, react_1.useEffect)(() => {
68
37
  if (!searchQuery.trim()) {
@@ -39,20 +39,18 @@ exports.TabContent = TabContent;
39
39
  const jsx_runtime_1 = require("react/jsx-runtime");
40
40
  const peers_sdk_1 = require("@peers-app/peers-sdk");
41
41
  const react_1 = __importStar(require("react"));
42
+ const apps_home_1 = require("../apps-home/apps-home");
42
43
  const command_palette_1 = require("../command-palette/command-palette");
43
44
  const group_switcher_1 = require("../components/group-switcher");
44
45
  const menu_surface_1 = require("../components/menu-surface");
45
46
  const router_1 = require("../components/router");
46
47
  const globals_1 = require("../globals");
47
48
  const hooks_1 = require("../hooks");
48
- const local_network_offer_1 = require("../local-network/local-network-offer");
49
49
  const notifications_client_1 = require("../notifications/notifications-client");
50
50
  const notifications_panel_1 = require("../notifications/notifications-panel");
51
51
  const app_shell_height_1 = require("../root-layout/app-shell-height");
52
52
  const identity_routes_1 = require("../screens/identity/identity-routes");
53
53
  const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
54
- const system_apps_1 = require("../system-apps");
55
- const routes_loader_1 = require("../ui-router/routes-loader");
56
54
  const ui_loader_1 = require("../ui-router/ui-loader");
57
55
  const network_status_indicator_1 = require("./network-status-indicator");
58
56
  const tabs_state_1 = require("./tabs-state");
@@ -313,7 +311,7 @@ function TabContent({ tab, isMobile, isActive }) {
313
311
  // Create individual tab content components that don't re-render
314
312
  const TabContentRenderer = react_1.default.memo(({ tab, isMobile }) => {
315
313
  if (tab.packageId === "launcher") {
316
- return (0, jsx_runtime_1.jsx)(AppLauncherTab, { isMobile: isMobile });
314
+ return (0, jsx_runtime_1.jsx)(apps_home_1.AppsHome, { isMobile: isMobile });
317
315
  }
318
316
  // System apps use the main Router (which reads from mainContentPath)
319
317
  // Package apps use UIRouter with explicit path
@@ -326,126 +324,3 @@ const TabContentRenderer = react_1.default.memo(({ tab, isMobile }) => {
326
324
  prevProps.tab.path === nextProps.tab.path &&
327
325
  prevProps.isMobile === nextProps.isMobile);
328
326
  });
329
- function AppLauncherTab({ isMobile }) {
330
- const [packages] = (0, hooks_1.useObservable)(routes_loader_1.allPackages);
331
- const [recentApps] = (0, hooks_1.useObservable)(tabs_state_1.recentlyUsedApps);
332
- const [searchTerm, setSearchTerm] = react_1.default.useState("");
333
- // Combine regular packages with system apps package
334
- const allPackages_ = [...packages, system_apps_1.systemPackage];
335
- // Create app items from nav items in packages
336
- const allApps = allPackages_
337
- .filter((p) => !p.disabled && p.appNavs && p.appNavs.length > 0)
338
- .flatMap((pkg) => {
339
- const navs = pkg.appNavs;
340
- if (!navs)
341
- return [];
342
- return navs.map((navItem) => {
343
- // Construct path - use direct path for system apps, package-nav for others
344
- let path;
345
- if (pkg.packageId === "system-apps") {
346
- // System apps use direct routing (like the original left bar)
347
- path = navItem.navigationPath ?? navItem.name.replace(/\s/g, "-").toLowerCase();
348
- }
349
- else {
350
- // Regular packages use package-nav format
351
- path = `package-nav/${pkg.packageId}/${(navItem.navigationPath ?? navItem.name).replace(/[^a-zA-Z0-9]/g, "-").toLowerCase()}`;
352
- while (path.includes("//")) {
353
- path = path.replace("//", "/");
354
- }
355
- }
356
- return {
357
- packageId: pkg.packageId,
358
- packageName: pkg.name,
359
- navItem,
360
- path,
361
- name: navItem.name,
362
- displayName: navItem.displayName || navItem.name,
363
- iconClassName: navItem.iconClassName || "bi-box-seam",
364
- };
365
- });
366
- });
367
- // Filter apps based on search term
368
- const filteredApps = searchTerm.trim()
369
- ? allApps.filter((app) => app.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
370
- app.displayName.toLowerCase().includes(searchTerm.toLowerCase()))
371
- : allApps;
372
- // Categorize filtered apps by package ID
373
- const systemApps = filteredApps.filter((app) => app.packageId === "system-apps");
374
- const userApps = filteredApps.filter((app) => app.packageId !== "system-apps");
375
- // Get recently used apps by matching paths (only show if they match search)
376
- const recentAppItems = recentApps
377
- .map((path) => filteredApps.find((app) => app.path === path))
378
- .filter(Boolean);
379
- const openApp = (appItem) => {
380
- // Check if this is the mobile-settings app and we're in React Native
381
- const w = window;
382
- if (appItem.path === "mobile-settings" && typeof w.__NATIVE_THEME !== "undefined") {
383
- if (w.ReactNativeWebView) {
384
- w.ReactNativeWebView.postMessage(JSON.stringify({
385
- type: "navigate",
386
- path: "mobile-settings",
387
- }));
388
- }
389
- else {
390
- window.location.href = "peers://mobile-settings";
391
- }
392
- return;
393
- }
394
- (0, tabs_state_1.goToTabPath)(appItem.path);
395
- };
396
- return ((0, jsx_runtime_1.jsxs)("div", { className: `container-fluid ${isMobile ? "p-2" : "p-4"}`, style: { maxHeight: "100%", overflowY: "auto" }, children: [(0, jsx_runtime_1.jsx)(local_network_offer_1.LocalNetworkHomeCards, {}), (0, jsx_runtime_1.jsx)("div", { className: isMobile ? "mb-3" : "mb-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "position-relative", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-search position-absolute", style: {
397
- left: "12px",
398
- top: "50%",
399
- transform: "translateY(-50%)",
400
- color: "#6c757d",
401
- zIndex: 1,
402
- } }), (0, jsx_runtime_1.jsx)("input", { type: "text", className: "form-control", placeholder: "Search apps...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), style: {
403
- paddingLeft: "40px",
404
- fontSize: isMobile ? "14px" : "15px",
405
- } }), searchTerm && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm position-absolute", style: {
406
- right: "8px",
407
- top: "50%",
408
- transform: "translateY(-50%)",
409
- border: "none",
410
- background: "none",
411
- color: "#6c757d",
412
- }, onClick: () => setSearchTerm(""), children: (0, jsx_runtime_1.jsx)("i", { className: "bi-x" }) }))] }) }), recentAppItems.length > 0 && ((0, jsx_runtime_1.jsx)(AppSection, { title: "Recently Used", iconClassName: "bi-clock", apps: recentAppItems, onOpenApp: openApp, isMobile: isMobile })), userApps.length > 0 && ((0, jsx_runtime_1.jsx)(AppSection, { title: "User Apps", iconClassName: "bi-person", apps: userApps, onOpenApp: openApp, isMobile: isMobile })), systemApps.length > 0 && ((0, jsx_runtime_1.jsx)(AppSection, { title: "System Apps", iconClassName: "bi-gear", apps: systemApps, onOpenApp: openApp, isMobile: isMobile }))] }));
413
- }
414
- function AppSection({ title, iconClassName, apps, onOpenApp, isMobile }) {
415
- return ((0, jsx_runtime_1.jsxs)("div", { className: "mb-5", children: [(0, jsx_runtime_1.jsxs)("h4", { className: `${isMobile ? "mb-3 h5" : "mb-3"}`, children: [(0, jsx_runtime_1.jsx)("i", { className: `${iconClassName} me-2` }), title] }), (0, jsx_runtime_1.jsx)("div", { className: `d-flex flex-wrap ${isMobile ? "gap-3" : "gap-4"}`, style: { gap: isMobile ? "16px" : "20px" }, children: apps.map((app) => ((0, jsx_runtime_1.jsx)(AppCard, { appItem: app, onOpenApp: onOpenApp, isMobile: isMobile }, `${app.packageId}-${app.path}`))) })] }));
416
- }
417
- function AppCard({ appItem, onOpenApp, isMobile }) {
418
- const [_colorMode] = (0, hooks_1.useObservable)(color_mode_dropdown_1.colorMode);
419
- const isDark = _colorMode === "dark";
420
- return ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "d-flex flex-column align-items-center text-center", style: {
421
- cursor: "pointer",
422
- width: isMobile ? "80px" : "90px",
423
- transition: "all 0.15s ease",
424
- background: "none",
425
- border: "none",
426
- padding: 0,
427
- }, title: appItem.name, onMouseEnter: (e) => {
428
- e.currentTarget.style.transform = "scale(1.05)";
429
- }, onMouseLeave: (e) => {
430
- e.currentTarget.style.transform = "scale(1)";
431
- }, onClick: () => onOpenApp(appItem), children: [(0, jsx_runtime_1.jsx)("div", { className: "d-flex align-items-center justify-content-center mb-2", style: {
432
- width: isMobile ? "64px" : "72px",
433
- height: isMobile ? "64px" : "72px",
434
- backgroundColor: isDark ? "#343a40" : "var(--peers-surface-bg)",
435
- borderRadius: "12px",
436
- border: `1px solid ${isDark ? "#495057" : "var(--peers-surface-border)"}`,
437
- boxShadow: isDark ? "0 2px 4px rgba(0,0,0,0.3)" : "0 2px 4px rgba(0,0,0,0.08)",
438
- transition: "all 0.15s ease",
439
- }, children: (0, jsx_runtime_1.jsx)("i", { className: appItem.iconClassName, style: {
440
- fontSize: isMobile ? "28px" : "32px",
441
- color: isDark ? "#0d6efd" : "#0d6efd",
442
- } }) }), (0, jsx_runtime_1.jsx)("span", { className: isDark ? "text-light" : "text-body", style: {
443
- fontSize: isMobile ? "11px" : "12px",
444
- fontWeight: "500",
445
- lineHeight: "1.2",
446
- maxWidth: "100%",
447
- overflow: "hidden",
448
- textOverflow: "ellipsis",
449
- whiteSpace: "nowrap",
450
- }, children: appItem.displayName })] }));
451
- }
@@ -18,10 +18,6 @@ export declare const activeTabs: Observable<TabState[]> & {
18
18
  export declare const activeTabId: Observable<string> & {
19
19
  loadingPromise: Promise<void>;
20
20
  };
21
- /** App roots recently opened from the launcher, newest first. */
22
- export declare const recentlyUsedApps: Observable<string[]> & {
23
- loadingPromise: Promise<void>;
24
- };
25
21
  /** Tab ids whose bodies have been mounted at least once. */
26
22
  export declare const initializedTabs: Set<string>;
27
23
  /** Options for {@link navigateTo}. */
@@ -59,6 +55,13 @@ export declare function goToTabPath(path: string): void;
59
55
  * @param _setNewMainPath - Direct path setter. Navigation updates the path itself.
60
56
  */
61
57
  export declare const handleMainPathChanged: (_oldPath: string, newPath: string, _setNewMainPath: (path: string) => void) => void;
58
+ /**
59
+ * Whether a route belonged to a built-in app Peers no longer has (Threads, Assistants,
60
+ * Workflows).
61
+ *
62
+ * @param path - A route, with or without a query string.
63
+ */
64
+ export declare function isRemovedAppRoute(path: string): boolean;
62
65
  /**
63
66
  * Rewrite stored tabs onto canonical routes.
64
67
  *
@@ -73,12 +76,6 @@ export declare function restoreNavigationState(tabs: TabState[], activeId: strin
73
76
  tabs: TabState[];
74
77
  activeId: string;
75
78
  };
76
- /**
77
- * Map a stored recent-app path onto the current app root.
78
- *
79
- * @param path - Persisted recent path, possibly a legacy alias.
80
- */
81
- export declare function migrateRecentPath(path: string): string;
82
79
  type AppInfo = {
83
80
  navItem: IAppNav;
84
81
  package: IPackageWithNavs;