@peers-app/peers-ui 0.19.0 → 0.19.6
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/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/screens/packages/package-details.d.ts +1 -0
- package/dist/screens/packages/package-details.js +2 -7
- package/dist/screens/packages/package-helpers.d.ts +33 -0
- package/dist/screens/packages/package-helpers.js +110 -0
- package/dist/screens/packages/package-info.d.ts +1 -2
- package/dist/screens/packages/package-info.js +52 -47
- package/dist/screens/packages/package-list.js +140 -45
- package/dist/screens/packages/package-versions.js +13 -13
- package/dist/system-apps/index.d.ts +3 -2
- package/dist/tabs-layout/tabs-state.d.ts +3 -2
- package/dist/ui-router/routes-loader.d.ts +6 -20
- package/dist/ui-router/routes-loader.js +2 -3
- package/package.json +3 -3
- package/src/index.tsx +1 -0
- package/src/screens/packages/package-details.tsx +2 -4
- package/src/screens/packages/package-helpers.ts +140 -0
- package/src/screens/packages/package-info.tsx +122 -67
- package/src/screens/packages/package-list.tsx +247 -88
- package/src/screens/packages/package-versions.tsx +14 -14
- package/src/system-apps/index.ts +3 -2
- package/src/tabs-layout/tabs-state.ts +3 -4
- package/src/ui-router/routes-loader.ts +9 -6
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
computePackageVersionHash,
|
|
3
3
|
getEffectivePackagePrefs,
|
|
4
4
|
getMe,
|
|
5
|
+
hasDeviceFollowOverride,
|
|
5
6
|
type IDoc,
|
|
6
7
|
type IPackage,
|
|
7
8
|
type IPackageVersion,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
} from "@peers-app/peers-sdk";
|
|
15
16
|
import { useState } from "react";
|
|
16
17
|
import { useObservable, useObservableState, usePromise } from "../../hooks";
|
|
18
|
+
import { activatePackageVersion, isGroupAdmin } from "./package-helpers";
|
|
17
19
|
|
|
18
20
|
function formatDate(iso: string): string {
|
|
19
21
|
try {
|
|
@@ -84,19 +86,7 @@ export const PackageVersionsList = (props: { pkg: IDoc<IPackage> }) => {
|
|
|
84
86
|
async function activateVersion(pv: IPackageVersion) {
|
|
85
87
|
setActivating(pv.packageVersionId);
|
|
86
88
|
try {
|
|
87
|
-
await
|
|
88
|
-
activePackageVersionId: pv.packageVersionId,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// For non-dev versions, also update the group default so other devices
|
|
92
|
-
// can discover this as the recommended version.
|
|
93
|
-
if (pv.versionTag !== "dev") {
|
|
94
|
-
const current = await Packages().get(pkg.packageId);
|
|
95
|
-
if (current) {
|
|
96
|
-
current.activePackageVersionId = pv.packageVersionId;
|
|
97
|
-
await Packages().signAndSave(current);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
89
|
+
await activatePackageVersion(pkg.packageId, pv);
|
|
100
90
|
await pkg.load();
|
|
101
91
|
refreshKey(refreshKey() + 1);
|
|
102
92
|
} catch (err: unknown) {
|
|
@@ -183,7 +173,17 @@ export const PackageVersionsList = (props: { pkg: IDoc<IPackage> }) => {
|
|
|
183
173
|
async function pinVersion() {
|
|
184
174
|
setPinning(true);
|
|
185
175
|
try {
|
|
186
|
-
|
|
176
|
+
const pinsGroup = !hasDeviceFollowOverride(devicePrefs) && (await isGroupAdmin());
|
|
177
|
+
|
|
178
|
+
if (pinsGroup) {
|
|
179
|
+
const current = await Packages().get(pkg.packageId);
|
|
180
|
+
if (current) {
|
|
181
|
+
current.versionFollowRange = "pinned";
|
|
182
|
+
await Packages().signAndSave(current);
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
await updatePackagePrefs(pkg.packageId, { pinned: true });
|
|
186
|
+
}
|
|
187
187
|
await pkg.load();
|
|
188
188
|
} catch (err: unknown) {
|
|
189
189
|
alert(`Failed to pin version: ${err instanceof Error ? err.message : String(err)}`);
|
package/src/system-apps/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { IAppNav
|
|
1
|
+
import type { IAppNav } from "@peers-app/peers-sdk";
|
|
2
|
+
import type { IPackageWithNavs } from "../ui-router/routes-loader";
|
|
2
3
|
|
|
3
4
|
export { accountApp } from "./account.app";
|
|
4
5
|
export { assistantsApp } from "./assistants.app";
|
|
@@ -73,7 +74,7 @@ export const systemApps: IAppNav[] = [
|
|
|
73
74
|
];
|
|
74
75
|
|
|
75
76
|
// Virtual system package for tabs integration
|
|
76
|
-
export const systemPackage:
|
|
77
|
+
export const systemPackage: IPackageWithNavs = {
|
|
77
78
|
packageId: "system-apps",
|
|
78
79
|
name: "System Apps",
|
|
79
80
|
description: "Core system functionality and management tools",
|
|
@@ -2,14 +2,13 @@ import {
|
|
|
2
2
|
groupDeviceVar,
|
|
3
3
|
groupUserVar,
|
|
4
4
|
type IAppNav,
|
|
5
|
-
type IPackage,
|
|
6
5
|
newid,
|
|
7
6
|
type Observable,
|
|
8
7
|
observable,
|
|
9
8
|
} from "@peers-app/peers-sdk";
|
|
10
9
|
import { _mainContentPath } from "../globals";
|
|
11
10
|
import { systemPackage } from "../system-apps";
|
|
12
|
-
import { allPackages } from "../ui-router/routes-loader";
|
|
11
|
+
import { allPackages, type IPackageWithNavs } from "../ui-router/routes-loader";
|
|
13
12
|
|
|
14
13
|
export interface TabState {
|
|
15
14
|
tabId: string;
|
|
@@ -158,7 +157,7 @@ export const handleMainPathChanged = (
|
|
|
158
157
|
}
|
|
159
158
|
};
|
|
160
159
|
|
|
161
|
-
type AppInfo = { navItem: IAppNav; package:
|
|
160
|
+
type AppInfo = { navItem: IAppNav; package: IPackageWithNavs };
|
|
162
161
|
|
|
163
162
|
export function determineAppFromPath(path: string): AppInfo | undefined {
|
|
164
163
|
const launcherInfo = {
|
|
@@ -186,7 +185,7 @@ export function determineAppFromPath(path: string): AppInfo | undefined {
|
|
|
186
185
|
.flatMap((pkg) => {
|
|
187
186
|
const navs = pkg.appNavs;
|
|
188
187
|
if (!navs) return [];
|
|
189
|
-
return navs.map((navItem) => ({ navItem, package: pkg
|
|
188
|
+
return navs.map((navItem) => ({ navItem, package: pkg }));
|
|
190
189
|
});
|
|
191
190
|
|
|
192
191
|
// Find the most relevant app based on path
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
debounceByArgs,
|
|
3
|
+
type IAppNav,
|
|
3
4
|
type IPackage,
|
|
4
5
|
type IPeersPackageRoutes,
|
|
5
6
|
type IPeersUIRoute,
|
|
@@ -11,7 +12,10 @@ import {
|
|
|
11
12
|
} from "@peers-app/peers-sdk";
|
|
12
13
|
import "../ui-defaults";
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
/** IPackage enriched with appNavs from the active PackageVersion. */
|
|
16
|
+
export type IPackageWithNavs = IPackage & { appNavs?: IAppNav[] };
|
|
17
|
+
|
|
18
|
+
export const allPackages = observable<IPackageWithNavs[]>([]);
|
|
15
19
|
let allRoutesLoaded = false;
|
|
16
20
|
|
|
17
21
|
const prefsSubscribed = new Set<string>();
|
|
@@ -41,10 +45,9 @@ function subscribeToPrefs(packageId: string) {
|
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
/**
|
|
44
|
-
* Enrich an IPackage with appNavs from the device's active
|
|
45
|
-
* Falls back to `pkg.appNavs` for backward compat with older data.
|
|
48
|
+
* Enrich an IPackage with appNavs from the device's active PackageVersion record.
|
|
46
49
|
*/
|
|
47
|
-
async function enrichWithPvAppNavs(pkg: IPackage): Promise<
|
|
50
|
+
async function enrichWithPvAppNavs(pkg: IPackage): Promise<IPackageWithNavs> {
|
|
48
51
|
let pvId = pkg.activePackageVersionId;
|
|
49
52
|
try {
|
|
50
53
|
const pvar = packagePrefsVar(pkg.packageId);
|
|
@@ -60,7 +63,7 @@ async function enrichWithPvAppNavs(pkg: IPackage): Promise<IPackage> {
|
|
|
60
63
|
return { ...pkg, appNavs: pv.appNavs };
|
|
61
64
|
}
|
|
62
65
|
} catch {
|
|
63
|
-
/*
|
|
66
|
+
/* PV not found */
|
|
64
67
|
}
|
|
65
68
|
return pkg;
|
|
66
69
|
}
|
|
@@ -115,7 +118,7 @@ type RoutesBundleWindow = Window & {
|
|
|
115
118
|
};
|
|
116
119
|
|
|
117
120
|
const routeLoadingPromises: Record<string, Promise<unknown>> = {};
|
|
118
|
-
function loadRoutesBundle(pkg:
|
|
121
|
+
function loadRoutesBundle(pkg: IPackageWithNavs, forceRefresh?: boolean): Promise<unknown> {
|
|
119
122
|
// Dynamically import the bundle
|
|
120
123
|
let importPromise: Promise<unknown> = routeLoadingPromises[pkg.packageId];
|
|
121
124
|
if (!importPromise || forceRefresh) {
|