@peers-app/peers-ui 0.33.7 → 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.
Files changed (36) hide show
  1. package/dist/apps-home/app-menu.d.ts +55 -0
  2. package/dist/apps-home/app-menu.js +126 -0
  3. package/dist/apps-home/app-status.d.ts +34 -0
  4. package/dist/apps-home/app-status.js +85 -0
  5. package/dist/apps-home/app-tile.d.ts +33 -0
  6. package/dist/apps-home/app-tile.js +106 -0
  7. package/dist/apps-home/apps-home.d.ts +29 -0
  8. package/dist/apps-home/apps-home.js +311 -0
  9. package/dist/apps-home/get-apps-sheet.d.ts +52 -0
  10. package/dist/apps-home/get-apps-sheet.js +130 -0
  11. package/dist/apps-home/pinned-apps.d.ts +73 -0
  12. package/dist/apps-home/pinned-apps.js +213 -0
  13. package/dist/apps-home/remove-app-dialog.d.ts +20 -0
  14. package/dist/apps-home/remove-app-dialog.js +62 -0
  15. package/dist/command-palette/command-palette-ui.js +2 -33
  16. package/dist/components/markdown-editor/editor.d.ts +22 -8
  17. package/dist/components/markdown-editor/editor.js +5 -4
  18. package/dist/components/markdown-editor/mention-preview-card.d.ts +13 -0
  19. package/dist/components/markdown-editor/mention-preview-card.js +30 -0
  20. package/dist/components/markdown-editor/mentions-plugin.d.ts +36 -2
  21. package/dist/components/markdown-editor/mentions-plugin.js +129 -34
  22. package/dist/components/markdown-editor/selection-effects-plugin.d.ts +18 -0
  23. package/dist/components/markdown-editor/selection-effects-plugin.js +49 -0
  24. package/dist/mentions/mention-chip.d.ts +3 -2
  25. package/dist/mentions/mention-chip.js +5 -4
  26. package/dist/root-layout/root-layout-host.js +0 -1
  27. package/dist/screens/search/global-search.js +2 -33
  28. package/dist/tabs-layout/tabs-layout.js +2 -127
  29. package/dist/tabs-layout/tabs-state.d.ts +7 -10
  30. package/dist/tabs-layout/tabs-state.js +8 -63
  31. package/dist/theme.css +948 -6
  32. package/dist/ui-router/app-catalog.d.ts +55 -0
  33. package/dist/ui-router/app-catalog.js +74 -0
  34. package/dist/ui-router/routes-loader.js +46 -27
  35. package/dist/ui-router/runnable-version.js +2 -1
  36. package/package.json +3 -3
@@ -0,0 +1,55 @@
1
+ import { type AppColor, type IAppNav } from "@peers-app/peers-sdk";
2
+ import { type IPackageWithNavs } from "./routes-loader";
3
+ /** Whether an app is built into Peers or comes from an installed package. */
4
+ export type AppKind = "system" | "package";
5
+ /** One app: a screen that the Apps screen, the command palette and Search can open. */
6
+ export interface IAppEntry {
7
+ /** The app's canonical path, which opens it and identifies it (in pins, for example). */
8
+ path: string;
9
+ /** The package that adds it, `system-apps` for a built-in app. */
10
+ packageId: string;
11
+ /** The package's name. */
12
+ packageName: string;
13
+ /** The package's description, if it has one. */
14
+ packageDescription?: string;
15
+ /** The app nav it was built from. */
16
+ navItem: IAppNav;
17
+ /** The nav's name. */
18
+ name: string;
19
+ /** The name to show: the nav's display name, or its name. */
20
+ displayName: string;
21
+ /** The Bootstrap icon class. */
22
+ iconClassName: string;
23
+ /** The icon's palette color, or `system` for a built-in app, which is drawn in grey. */
24
+ color: AppColor | "system";
25
+ /** Built in, or from a package. */
26
+ kind: AppKind;
27
+ }
28
+ /**
29
+ * The canonical path of an app: a built-in app's own route, or `package-nav/<packageId>/<nav>`
30
+ * for a package's app, with the nav path lowercased and its other characters made dashes.
31
+ *
32
+ * @param packageId - The package that adds the app, `system-apps` for a built-in one.
33
+ * @param navItem - The app nav.
34
+ */
35
+ export declare function appPath(packageId: string, navItem: IAppNav): string;
36
+ /**
37
+ * Every app in the installed packages, then the built-in apps, in that order. A disabled
38
+ * package, or one without app navs, adds nothing.
39
+ *
40
+ * @param packages - Installed packages with the app navs of the version each runs here.
41
+ * @param system - The built-in apps' package.
42
+ */
43
+ export declare function buildAppCatalog(packages: readonly IPackageWithNavs[], system?: IPackageWithNavs): IAppEntry[];
44
+ /**
45
+ * Whether an app matches a search: its display name, nav name, package name or package
46
+ * description contains the query, ignoring case. A built-in app matches on its own names only:
47
+ * they all share one package name and description, so those would match every one of them. An
48
+ * empty query matches everything.
49
+ *
50
+ * @param entry - The app.
51
+ * @param query - What the user typed.
52
+ */
53
+ export declare function appMatchesQuery(entry: IAppEntry, query: string): boolean;
54
+ /** Every app in the current context, rebuilt when its installed packages change. */
55
+ export declare function useAppCatalog(): IAppEntry[];
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appPath = appPath;
4
+ exports.buildAppCatalog = buildAppCatalog;
5
+ exports.appMatchesQuery = appMatchesQuery;
6
+ exports.useAppCatalog = useAppCatalog;
7
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
8
+ const react_1 = require("react");
9
+ const use_observable_1 = require("../hooks/use-observable");
10
+ const system_apps_1 = require("../system-apps");
11
+ const routes_loader_1 = require("./routes-loader");
12
+ /**
13
+ * The canonical path of an app: a built-in app's own route, or `package-nav/<packageId>/<nav>`
14
+ * for a package's app, with the nav path lowercased and its other characters made dashes.
15
+ *
16
+ * @param packageId - The package that adds the app, `system-apps` for a built-in one.
17
+ * @param navItem - The app nav.
18
+ */
19
+ function appPath(packageId, navItem) {
20
+ if (packageId === system_apps_1.systemPackage.packageId) {
21
+ return navItem.navigationPath ?? navItem.name.replace(/\s/g, "-").toLowerCase();
22
+ }
23
+ const nav = (navItem.navigationPath ?? navItem.name).replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
24
+ return `package-nav/${packageId}/${nav}`.replace(/\/{2,}/g, "/");
25
+ }
26
+ /**
27
+ * Every app in the installed packages, then the built-in apps, in that order. A disabled
28
+ * package, or one without app navs, adds nothing.
29
+ *
30
+ * @param packages - Installed packages with the app navs of the version each runs here.
31
+ * @param system - The built-in apps' package.
32
+ */
33
+ function buildAppCatalog(packages, system = system_apps_1.systemPackage) {
34
+ return [...packages, system]
35
+ .filter((pkg) => !pkg.disabled && (pkg.appNavs?.length ?? 0) > 0)
36
+ .flatMap((pkg) => {
37
+ const isSystem = pkg.packageId === system.packageId;
38
+ return (pkg.appNavs ?? []).map((navItem) => ({
39
+ path: appPath(pkg.packageId, navItem),
40
+ packageId: pkg.packageId,
41
+ packageName: pkg.name,
42
+ packageDescription: pkg.description || undefined,
43
+ navItem,
44
+ name: navItem.name,
45
+ displayName: navItem.displayName || navItem.name,
46
+ iconClassName: navItem.iconClassName || "bi-box-seam",
47
+ color: isSystem ? "system" : (0, peers_sdk_1.resolveAppColor)(pkg.packageId, navItem),
48
+ kind: isSystem ? "system" : "package",
49
+ }));
50
+ });
51
+ }
52
+ /**
53
+ * Whether an app matches a search: its display name, nav name, package name or package
54
+ * description contains the query, ignoring case. A built-in app matches on its own names only:
55
+ * they all share one package name and description, so those would match every one of them. An
56
+ * empty query matches everything.
57
+ *
58
+ * @param entry - The app.
59
+ * @param query - What the user typed.
60
+ */
61
+ function appMatchesQuery(entry, query) {
62
+ const needle = query.trim().toLowerCase();
63
+ if (!needle)
64
+ return true;
65
+ const texts = entry.kind === "system"
66
+ ? [entry.displayName, entry.name]
67
+ : [entry.displayName, entry.name, entry.packageName, entry.packageDescription];
68
+ return texts.some((text) => !!text && text.toLowerCase().includes(needle));
69
+ }
70
+ /** Every app in the current context, rebuilt when its installed packages change. */
71
+ function useAppCatalog() {
72
+ const [packages] = (0, use_observable_1.useObservable)(routes_loader_1.allPackages);
73
+ return (0, react_1.useMemo)(() => buildAppCatalog(packages), [packages]);
74
+ }
@@ -40,6 +40,47 @@ async function recheckPackage(packageId) {
40
40
  }
41
41
  reloadPackage(packageId);
42
42
  }
43
+ const refreshing = {};
44
+ /**
45
+ * Bring one package's entry up to date after its Packages row changed. The list keeps what
46
+ * {@link loadAllRoutes} would list now (not disabled, with a selected version), so a package
47
+ * installed while the app is open appears once its version is activated, and its routes load
48
+ * then. Its routes bundle still runs only when `resolveRunnableVersion` allows it. Refreshes of
49
+ * one package run one at a time, each from the stored row, so a slow one can't overwrite a newer.
50
+ */
51
+ function refreshPackage(packageId) {
52
+ const next = (refreshing[packageId] ?? Promise.resolve()).then(async () => {
53
+ try {
54
+ const pkg = await (0, peers_sdk_1.Packages)().get(packageId);
55
+ const listed = !!pkg && !pkg.disabled && !!pkg.activePackageVersionId;
56
+ const entry = pkg && listed ? await enrichWithPvAppNavs(pkg) : undefined;
57
+ const _allPackages = (0, exports.allPackages)();
58
+ const idx = _allPackages.findIndex((p) => p.packageId === packageId);
59
+ if (entry) {
60
+ if (idx >= 0)
61
+ _allPackages[idx] = entry;
62
+ else
63
+ _allPackages.push(entry);
64
+ subscribeToPrefs(packageId);
65
+ }
66
+ else if (idx >= 0) {
67
+ _allPackages.splice(idx, 1);
68
+ }
69
+ (0, exports.allPackages)([..._allPackages]);
70
+ if (!entry)
71
+ return;
72
+ if (packageId in routeLoadingPromises)
73
+ reloadPackage(packageId);
74
+ else
75
+ await loadRoutesBundle(entry);
76
+ }
77
+ catch (error) {
78
+ console.warn(`Couldn't refresh the app links of package ${packageId}`, error);
79
+ }
80
+ });
81
+ refreshing[packageId] = next;
82
+ return next;
83
+ }
43
84
  /**
44
85
  * Enrich an IPackage with appNavs from the device's active PackageVersion record.
45
86
  */
@@ -62,33 +103,10 @@ const loadAllRoutes = async () => {
62
103
  for (const pkg of enriched) {
63
104
  subscribeToPrefs(pkg.packageId);
64
105
  }
65
- (0, peers_sdk_1.Packages)().dataChanged.subscribe(async (evt) => {
66
- const enrichedPkg = await enrichWithPvAppNavs(evt.dataObject);
67
- const _allPackages = (0, exports.allPackages)();
68
- if (evt.op === "insert") {
69
- _allPackages.push(enrichedPkg);
70
- subscribeToPrefs(evt.dataObject.packageId);
71
- }
72
- else if (evt.op === "delete") {
73
- const idx = _allPackages.findIndex((p) => p.packageId === evt.dataObject.packageId);
74
- if (idx >= 0) {
75
- _allPackages.splice(idx, 1);
76
- }
77
- }
78
- else {
79
- const idx = _allPackages.findIndex((p) => p.packageId === evt.dataObject.packageId);
80
- if (idx >= 0) {
81
- _allPackages[idx] = enrichedPkg;
82
- }
83
- }
84
- (0, exports.allPackages)([..._allPackages]);
85
- });
86
106
  (0, peers_sdk_1.Packages)().dataChanged.subscribe((evt) => {
87
- const pkg = evt.dataObject;
88
- const loadingPromise = routeLoadingPromises[pkg.packageId];
89
- if (!loadingPromise)
90
- return;
91
- reloadPackage(pkg.packageId);
107
+ const packageId = evt.dataObject?.packageId;
108
+ if (packageId)
109
+ void refreshPackage(packageId);
92
110
  });
93
111
  // A promotion changes only the selected version's row (dev to beta or stable).
94
112
  (0, runnable_version_1.onSelectedPackageVersionChanged)((packageId) => void recheckPackage(packageId));
@@ -144,7 +162,8 @@ function loadRoutesBundle(pkg, forceRefresh) {
144
162
  }
145
163
  const reloadPackage = (0, peers_sdk_1.debounceByArgs)(async (packageId) => {
146
164
  const pkg = await (0, peers_sdk_1.Packages)().get(packageId);
147
- if (pkg) {
165
+ // A refresh queued before the package was disabled must not run its routes afterwards.
166
+ if (pkg && !pkg.disabled) {
148
167
  await loadRoutesBundle(pkg, true);
149
168
  }
150
169
  }, 200);
@@ -22,7 +22,8 @@ async function resolveRunnableVersion(pkg) {
22
22
  try {
23
23
  const dataContext = await (0, peers_sdk_1.getDefaultDataContext)();
24
24
  const stored = await (0, peers_sdk_1.Packages)(dataContext).get(pkg.packageId);
25
- if (!stored)
25
+ // The package may have been disabled since the caller read its row.
26
+ if (!stored || stored.disabled)
26
27
  return undefined;
27
28
  let devicePvId;
28
29
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-ui",
3
- "version": "0.33.7",
3
+ "version": "0.33.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.33.7",
39
+ "@peers-app/peers-sdk": "^0.33.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.33.7",
50
+ "@peers-app/peers-sdk": "0.33.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",