@peers-app/peers-ui 0.27.3 → 0.27.5
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/screens/network-viewer/group-details-modal.d.ts +4 -0
- package/dist/screens/network-viewer/group-details-modal.js +6 -46
- package/dist/screens/network-viewer/network-viewer-ipc.d.ts +3 -2
- package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
- package/dist/screens/network-viewer/sync-recovery.js +103 -1
- package/dist/screens/variables/variable-details.js +2 -1
- package/dist/tabs-layout/network-status-indicator.js +26 -12
- package/dist/tabs-layout/use-network-status.d.ts +6 -1
- package/dist/tabs-layout/use-network-status.js +27 -4
- package/package.json +9 -3
- package/.claude/settings.local.json +0 -34
- package/.github/README.md +0 -52
- package/.github/workflows/delete-all-artifacts.yml +0 -49
- package/.github/workflows/publish.yml +0 -51
- package/babel.config.js +0 -7
- package/biome.json +0 -198
- package/dist/app-updates/app-updates-consumer.test.d.ts +0 -1
- package/dist/app-updates/app-updates-consumer.test.js +0 -56
- package/dist/app-updates/app-updates-settings.test.d.ts +0 -1
- package/dist/app-updates/app-updates-settings.test.js +0 -93
- package/dist/app-updates/remote-app-update-panel.test.d.ts +0 -1
- package/dist/app-updates/remote-app-update-panel.test.js +0 -165
- package/dist/components/access-level-field.test.d.ts +0 -1
- package/dist/components/access-level-field.test.js +0 -28
- package/dist/components/message-logs/tool-access-approval-card.test.d.ts +0 -1
- package/dist/components/message-logs/tool-access-approval-card.test.js +0 -102
- package/dist/components/responsive-section-nav.test.d.ts +0 -1
- package/dist/components/responsive-section-nav.test.js +0 -45
- package/dist/globals-hash.test.d.ts +0 -1
- package/dist/globals-hash.test.js +0 -16
- package/dist/hooks/use-observable-state.test.d.ts +0 -1
- package/dist/hooks/use-observable-state.test.js +0 -64
- package/dist/hooks/use-observable.test.d.ts +0 -1
- package/dist/hooks/use-observable.test.js +0 -191
- package/dist/hooks/use-rows.test.d.ts +0 -1
- package/dist/hooks/use-rows.test.js +0 -175
- package/dist/hooks/use-tool.test.d.ts +0 -1
- package/dist/hooks/use-tool.test.js +0 -190
- package/dist/host-shell/host-shell-consumer.test.d.ts +0 -1
- package/dist/host-shell/host-shell-consumer.test.js +0 -28
- package/dist/root-layout/root-layout-host.test.d.ts +0 -1
- package/dist/root-layout/root-layout-host.test.js +0 -86
- package/dist/screens/account/account-screen.test.d.ts +0 -1
- package/dist/screens/account/account-screen.test.js +0 -51
- package/dist/screens/assistants/assistant-config.test.d.ts +0 -1
- package/dist/screens/assistants/assistant-config.test.js +0 -57
- package/dist/screens/contacts/contact-list.test.d.ts +0 -1
- package/dist/screens/contacts/contact-list.test.js +0 -48
- package/dist/screens/device-pairing/device-pairing.test.d.ts +0 -1
- package/dist/screens/device-pairing/device-pairing.test.js +0 -119
- package/dist/screens/devices/devices-list.test.d.ts +0 -1
- package/dist/screens/devices/devices-list.test.js +0 -53
- package/dist/screens/groups/group-list.test.d.ts +0 -1
- package/dist/screens/groups/group-list.test.js +0 -38
- package/dist/screens/identity/identity-routes.test.d.ts +0 -1
- package/dist/screens/identity/identity-routes.test.js +0 -51
- package/dist/screens/identity/identity-screen.test.d.ts +0 -1
- package/dist/screens/identity/identity-screen.test.js +0 -103
- package/dist/screens/invites/accept-invite.test.d.ts +0 -1
- package/dist/screens/invites/accept-invite.test.js +0 -103
- package/dist/screens/invites/activity-view.test.d.ts +0 -1
- package/dist/screens/invites/activity-view.test.js +0 -108
- package/dist/screens/invites/invite-classify.test.d.ts +0 -1
- package/dist/screens/invites/invite-classify.test.js +0 -115
- package/dist/screens/network-viewer/network-viewer-ipc.test.d.ts +0 -1
- package/dist/screens/network-viewer/network-viewer-ipc.test.js +0 -61
- package/dist/screens/network-viewer/network-viewer.section.test.d.ts +0 -1
- package/dist/screens/network-viewer/network-viewer.section.test.js +0 -63
- package/dist/screens/network-viewer/sync-recovery.test.d.ts +0 -1
- package/dist/screens/network-viewer/sync-recovery.test.js +0 -104
- package/dist/screens/packages/package-helpers.test.d.ts +0 -1
- package/dist/screens/packages/package-helpers.test.js +0 -53
- package/dist/screens/packages/package-runtime-status.test.d.ts +0 -1
- package/dist/screens/packages/package-runtime-status.test.js +0 -50
- package/dist/screens/packages/packages-ipc.test.d.ts +0 -1
- package/dist/screens/packages/packages-ipc.test.js +0 -43
- package/dist/screens/settings/settings-page.test.d.ts +0 -1
- package/dist/screens/settings/settings-page.test.js +0 -19
- package/dist/screens/tools/tool-access-ipc.test.d.ts +0 -1
- package/dist/screens/tools/tool-access-ipc.test.js +0 -40
- package/dist/screens/tools/tool-catalog-ipc.test.d.ts +0 -1
- package/dist/screens/tools/tool-catalog-ipc.test.js +0 -52
- package/dist/tabs-layout/network-status-indicator.test.d.ts +0 -1
- package/dist/tabs-layout/network-status-indicator.test.js +0 -665
- package/dist/tabs-layout/tabs-state.test.d.ts +0 -1
- package/dist/tabs-layout/tabs-state.test.js +0 -110
- package/dist/tabs-layout/use-network-status.test.d.ts +0 -1
- package/dist/tabs-layout/use-network-status.test.js +0 -45
- package/dist/ui-router/ui-loader.test.d.ts +0 -1
- package/dist/ui-router/ui-loader.test.js +0 -91
- package/jest.config.js +0 -25
- package/release-guard.js +0 -10
- package/src/app-updates/app-update-controls.tsx +0 -73
- package/src/app-updates/app-updates-consumer.test.ts +0 -83
- package/src/app-updates/app-updates-consumer.ts +0 -121
- package/src/app-updates/app-updates-settings.test.tsx +0 -109
- package/src/app-updates/app-updates-settings.tsx +0 -136
- package/src/app-updates/remote-app-update-panel.test.tsx +0 -205
- package/src/app-updates/remote-app-update-panel.tsx +0 -210
- package/src/app-updates/use-app-update-status.ts +0 -16
- package/src/command-palette/command-palette-ui.tsx +0 -564
- package/src/command-palette/command-palette.ts +0 -242
- package/src/components/access-level-field.test.tsx +0 -32
- package/src/components/access-level-field.tsx +0 -68
- package/src/components/checkbox.tsx +0 -25
- package/src/components/group-switcher.tsx +0 -526
- package/src/components/input-date.tsx +0 -29
- package/src/components/input-number.tsx +0 -83
- package/src/components/input.tsx +0 -25
- package/src/components/inverse-lazy-list.tsx +0 -107
- package/src/components/io-schema-values.tsx +0 -103
- package/src/components/io-schema.tsx +0 -259
- package/src/components/lazy-list.tsx +0 -115
- package/src/components/list-screen.tsx +0 -126
- package/src/components/loading-indicator.tsx +0 -7
- package/src/components/markdown-editor/autolink-plugin.tsx +0 -29
- package/src/components/markdown-editor/editor-inline.tsx +0 -9
- package/src/components/markdown-editor/editor.tsx +0 -158
- package/src/components/markdown-editor/markdown-plugin.tsx +0 -202
- package/src/components/markdown-editor/mention-node.ts +0 -204
- package/src/components/markdown-editor/mentions-plugin.tsx +0 -354
- package/src/components/markdown-editor/move-line-plugin.tsx +0 -186
- package/src/components/markdown-editor/select-line-boundary-plugin.tsx +0 -95
- package/src/components/markdown-editor/theme.ts +0 -46
- package/src/components/markdown-editor/toolbar.tsx +0 -269
- package/src/components/markdown-with-mentions.tsx +0 -198
- package/src/components/message-logs/message-logs.tsx +0 -523
- package/src/components/message-logs/tool-access-approval-card.test.tsx +0 -127
- package/src/components/message-logs/tool-access-approval-card.tsx +0 -178
- package/src/components/messages/avatar.tsx +0 -171
- package/src/components/messages/channel-message-list.tsx +0 -189
- package/src/components/messages/channel-view.tsx +0 -92
- package/src/components/messages/message-compose.tsx +0 -192
- package/src/components/messages/message-display.tsx +0 -231
- package/src/components/messages/thread-message-list.tsx +0 -135
- package/src/components/qr-scanner.tsx +0 -180
- package/src/components/responsive-section-nav.test.tsx +0 -88
- package/src/components/responsive-section-nav.tsx +0 -92
- package/src/components/router.tsx +0 -175
- package/src/components/save-button.tsx +0 -134
- package/src/components/sortable-list.tsx +0 -130
- package/src/components/tabs.tsx +0 -76
- package/src/components/tooltip.tsx +0 -43
- package/src/components/trust-level-badge.tsx +0 -44
- package/src/components/trust-level-dropdown.tsx +0 -136
- package/src/components/typeahead.tsx +0 -357
- package/src/globals-hash.test.ts +0 -19
- package/src/globals.tsx +0 -226
- package/src/hooks/index.ts +0 -8
- package/src/hooks/use-host-contract.ts +0 -75
- package/src/hooks/use-observable-state.test.tsx +0 -101
- package/src/hooks/use-observable-state.ts +0 -29
- package/src/hooks/use-observable.test.tsx +0 -258
- package/src/hooks/use-observable.ts +0 -67
- package/src/hooks/use-on-screen.ts +0 -24
- package/src/hooks/use-promise.ts +0 -34
- package/src/hooks/use-rows.test.tsx +0 -196
- package/src/hooks/use-rows.ts +0 -120
- package/src/hooks/use-subscription.ts +0 -24
- package/src/hooks/use-tool.test.tsx +0 -225
- package/src/hooks/use-tool.ts +0 -116
- package/src/host-shell/host-shell-consumer.test.ts +0 -32
- package/src/host-shell/host-shell-consumer.ts +0 -53
- package/src/index.tsx +0 -42
- package/src/mention-configs.ts +0 -185
- package/src/operator-console/operator-console-state.ts +0 -119
- package/src/operator-console/operator-console.tsx +0 -233
- package/src/peers-services-registration.ts +0 -6
- package/src/root-layout/global-overlays.ts +0 -50
- package/src/root-layout/layout-picker.tsx +0 -47
- package/src/root-layout/layouts/full-screen-layout.tsx +0 -144
- package/src/root-layout/layouts/tabs-with-console-layout.tsx +0 -260
- package/src/root-layout/root-layout-host.test.tsx +0 -108
- package/src/root-layout/root-layout-host.tsx +0 -147
- package/src/root-layout/root-layout-registry.ts +0 -51
- package/src/root-layout/root-layout-state.ts +0 -55
- package/src/root-layout/root-layout.ts +0 -32
- package/src/screens/account/account-screen.test.tsx +0 -65
- package/src/screens/account/account-screen.tsx +0 -942
- package/src/screens/assistants/assistant-config.test.tsx +0 -54
- package/src/screens/assistants/assistant-config.tsx +0 -121
- package/src/screens/assistants/assistant-details.tsx +0 -89
- package/src/screens/assistants/assistant-info.tsx +0 -66
- package/src/screens/assistants/assistant-list.tsx +0 -145
- package/src/screens/assistants/assistant-tools.tsx +0 -82
- package/src/screens/console-logs/console-logs-list.tsx +0 -374
- package/src/screens/console-logs/log-display.tsx +0 -137
- package/src/screens/console-logs/log-filters.tsx +0 -64
- package/src/screens/console-logs/mobile-log-card.tsx +0 -161
- package/src/screens/console-logs/resizable-table-header.tsx +0 -110
- package/src/screens/contacts/contact-details.tsx +0 -123
- package/src/screens/contacts/contact-list.test.tsx +0 -59
- package/src/screens/contacts/contact-list.tsx +0 -286
- package/src/screens/contacts/index.ts +0 -2
- package/src/screens/data-explorer/data-explorer.tsx +0 -633
- package/src/screens/data-explorer/index.ts +0 -6
- package/src/screens/data-explorer/query-executor.tsx +0 -520
- package/src/screens/device-pairing/device-pairing.test.tsx +0 -143
- package/src/screens/device-pairing/device-pairing.tsx +0 -461
- package/src/screens/device-pairing/identity-ipc.ts +0 -25
- package/src/screens/device-pairing/index.ts +0 -2
- package/src/screens/device-pairing/use-device-pairing-state.ts +0 -15
- package/src/screens/devices/devices-list.test.tsx +0 -68
- package/src/screens/devices/devices-list.tsx +0 -365
- package/src/screens/devices/index.ts +0 -1
- package/src/screens/groups/group-details.tsx +0 -160
- package/src/screens/groups/group-invite-panel.tsx +0 -311
- package/src/screens/groups/group-list.test.tsx +0 -44
- package/src/screens/groups/group-list.tsx +0 -317
- package/src/screens/groups/group-members.tsx +0 -343
- package/src/screens/groups/index.ts +0 -3
- package/src/screens/identity/identity-routes.test.ts +0 -70
- package/src/screens/identity/identity-routes.ts +0 -301
- package/src/screens/identity/identity-screen.test.tsx +0 -138
- package/src/screens/identity/identity-screen.tsx +0 -282
- package/src/screens/identity/index.ts +0 -2
- package/src/screens/identity/invite-contact-panel.tsx +0 -45
- package/src/screens/identity/profile-invite.tsx +0 -93
- package/src/screens/invites/accept-invite.test.tsx +0 -115
- package/src/screens/invites/accept-invite.tsx +0 -318
- package/src/screens/invites/activity-view.test.tsx +0 -127
- package/src/screens/invites/activity-view.tsx +0 -162
- package/src/screens/invites/index.ts +0 -6
- package/src/screens/invites/invite-capture.ts +0 -104
- package/src/screens/invites/invite-classify.test.ts +0 -129
- package/src/screens/invites/invite-share.tsx +0 -104
- package/src/screens/invites/invites-ipc.ts +0 -25
- package/src/screens/invites/pending-invites-list.tsx +0 -256
- package/src/screens/network-viewer/connection-troubleshooter.tsx +0 -395
- package/src/screens/network-viewer/cpu-usage-graph.tsx +0 -294
- package/src/screens/network-viewer/device-details-modal.tsx +0 -339
- package/src/screens/network-viewer/group-details-modal.tsx +0 -421
- package/src/screens/network-viewer/index.ts +0 -8
- package/src/screens/network-viewer/network-viewer-ipc.test.ts +0 -72
- package/src/screens/network-viewer/network-viewer-ipc.ts +0 -39
- package/src/screens/network-viewer/network-viewer-section.ts +0 -12
- package/src/screens/network-viewer/network-viewer.section.test.tsx +0 -68
- package/src/screens/network-viewer/network-viewer.tsx +0 -708
- package/src/screens/network-viewer/remote-logs-panel.tsx +0 -190
- package/src/screens/network-viewer/sync-recovery.test.tsx +0 -114
- package/src/screens/network-viewer/sync-recovery.tsx +0 -461
- package/src/screens/network-viewer/usage-graph.tsx +0 -455
- package/src/screens/packages/local-folder-grants-panel.tsx +0 -290
- package/src/screens/packages/local-folders-ipc.ts +0 -28
- package/src/screens/packages/package-details.tsx +0 -166
- package/src/screens/packages/package-helpers.test.ts +0 -57
- package/src/screens/packages/package-helpers.ts +0 -137
- package/src/screens/packages/package-info.tsx +0 -354
- package/src/screens/packages/package-list.tsx +0 -519
- package/src/screens/packages/package-network-panel.tsx +0 -82
- package/src/screens/packages/package-new-local.tsx +0 -100
- package/src/screens/packages/package-runtime-status.test.tsx +0 -58
- package/src/screens/packages/package-runtime-status.tsx +0 -68
- package/src/screens/packages/package-versions.tsx +0 -298
- package/src/screens/packages/packages-ipc.test.ts +0 -47
- package/src/screens/packages/packages-ipc.ts +0 -125
- package/src/screens/peer-types/peer-type-details.tsx +0 -172
- package/src/screens/peer-types/peer-type-list.tsx +0 -64
- package/src/screens/search/global-search.tsx +0 -406
- package/src/screens/settings/color-mode-dropdown.tsx +0 -82
- package/src/screens/settings/settings-page.test.tsx +0 -24
- package/src/screens/settings/settings-page.tsx +0 -426
- package/src/screens/setup-user.tsx +0 -355
- package/src/screens/tools/tool-access-ipc.test.ts +0 -55
- package/src/screens/tools/tool-access-ipc.ts +0 -27
- package/src/screens/tools/tool-catalog-ipc.test.ts +0 -52
- package/src/screens/tools/tool-catalog-ipc.ts +0 -51
- package/src/screens/tools/tool-details.tsx +0 -52
- package/src/screens/tools/tool-info.tsx +0 -45
- package/src/screens/tools/tool-list.tsx +0 -106
- package/src/screens/tools/tool-schema.tsx +0 -44
- package/src/screens/tools/tool-test-details.tsx +0 -89
- package/src/screens/tools/tool-test-list.tsx +0 -73
- package/src/screens/variables/variable-details.tsx +0 -289
- package/src/screens/variables/variable-list.tsx +0 -110
- package/src/screens/welcome-modal.tsx +0 -294
- package/src/screens/workflows/workflow-details.tsx +0 -115
- package/src/screens/workflows/workflow-info.tsx +0 -22
- package/src/screens/workflows/workflow-instructions.tsx +0 -134
- package/src/screens/workflows/workflow-list.tsx +0 -117
- package/src/setupTests.ts +0 -38
- package/src/system-apps/assistants.app.ts +0 -7
- package/src/system-apps/console-logs.app.ts +0 -7
- package/src/system-apps/data-explorer.app.ts +0 -8
- package/src/system-apps/identity.app.ts +0 -9
- package/src/system-apps/index.ts +0 -77
- package/src/system-apps/mobile-settings.app.ts +0 -7
- package/src/system-apps/network-viewer.app.ts +0 -8
- package/src/system-apps/packages.app.ts +0 -7
- package/src/system-apps/search.app.ts +0 -8
- package/src/system-apps/settings.app.ts +0 -7
- package/src/system-apps/threads.app.ts +0 -7
- package/src/system-apps/tools.app.ts +0 -7
- package/src/system-apps/types.app.ts +0 -7
- package/src/system-apps/variables.app.ts +0 -7
- package/src/system-apps/workflows.app.ts +0 -7
- package/src/tabs-layout/network-status-indicator.test.tsx +0 -799
- package/src/tabs-layout/network-status-indicator.tsx +0 -756
- package/src/tabs-layout/tabs-layout.tsx +0 -857
- package/src/tabs-layout/tabs-state.test.ts +0 -152
- package/src/tabs-layout/tabs-state.ts +0 -587
- package/src/tabs-layout/use-network-status.test.tsx +0 -58
- package/src/tabs-layout/use-network-status.ts +0 -68
- package/src/ui-defaults/index.ts +0 -2
- package/src/ui-defaults/list-screen.tsx +0 -94
- package/src/ui-defaults/markdown-field.tsx +0 -87
- package/src/ui-router/routes-loader.ts +0 -193
- package/src/ui-router/ui-loader.test.tsx +0 -108
- package/src/ui-router/ui-loader.tsx +0 -606
- package/src/utils.ts +0 -95
- package/tsconfig.json +0 -18
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getEffectivePackagePrefs,
|
|
3
|
-
type ICursorIterable,
|
|
4
|
-
type IPackage,
|
|
5
|
-
type IPackageVersion,
|
|
6
|
-
isid,
|
|
7
|
-
isPackageRepositoryUrl,
|
|
8
|
-
observable,
|
|
9
|
-
Packages,
|
|
10
|
-
PackageVersions,
|
|
11
|
-
packagePrefsVar,
|
|
12
|
-
packagesRootDir,
|
|
13
|
-
} from "@peers-app/peers-sdk";
|
|
14
|
-
import type React from "react";
|
|
15
|
-
import { useCallback, useEffect, useState } from "react";
|
|
16
|
-
import { Input } from "../../components/input";
|
|
17
|
-
import { LazyList } from "../../components/lazy-list";
|
|
18
|
-
import { LoadingIndicator } from "../../components/loading-indicator";
|
|
19
|
-
import { Tooltip } from "../../components/tooltip";
|
|
20
|
-
import { isDesktop, mainContentPath } from "../../globals";
|
|
21
|
-
import { useObservable, useObservableState, usePromise } from "../../hooks";
|
|
22
|
-
import { openOnHost } from "../../host-shell/host-shell-consumer";
|
|
23
|
-
import { registerInternalPeersUI } from "../../ui-router/ui-loader";
|
|
24
|
-
import { LocalFolderGrantsPanel } from "./local-folder-grants-panel";
|
|
25
|
-
import {
|
|
26
|
-
activatePackageVersion,
|
|
27
|
-
checkVersionStatus,
|
|
28
|
-
type IVersionStatus,
|
|
29
|
-
type UpdateLevel,
|
|
30
|
-
updateLevelRank,
|
|
31
|
-
} from "./package-helpers";
|
|
32
|
-
import { PackageRuntimeBadge } from "./package-runtime-status";
|
|
33
|
-
import { packagesTools } from "./packages-ipc";
|
|
34
|
-
|
|
35
|
-
interface IPackageRowStatus extends IVersionStatus {
|
|
36
|
-
/** When on a dev version, the group's non-dev active PV (if any). */
|
|
37
|
-
groupReleasePv: IPackageVersion | null;
|
|
38
|
-
/** When on a non-dev version, the latest dev PV (if any). */
|
|
39
|
-
latestDevPv: IPackageVersion | null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function tagBadgeClass(tag: string): string {
|
|
43
|
-
if (tag === "dev") return "text-bg-danger";
|
|
44
|
-
if (tag.startsWith("beta")) return "text-bg-warning";
|
|
45
|
-
return "text-bg-success";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function updateBadgeClass(level: UpdateLevel): string {
|
|
49
|
-
if (level === "major") return "text-bg-danger";
|
|
50
|
-
if (level === "minor") return "text-bg-warning";
|
|
51
|
-
return "text-bg-info";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const PackageRow = ({ pkg, onUpdated }: { pkg: IPackage; onUpdated: () => void }) => {
|
|
55
|
-
const [updating, setUpdating] = useState(false);
|
|
56
|
-
const [devicePrefs] = useObservable(packagePrefsVar(pkg.packageId));
|
|
57
|
-
const effective = getEffectivePackagePrefs(pkg, devicePrefs);
|
|
58
|
-
// A dev reload rewrites the selected version row in place (same id, new version), so the
|
|
59
|
-
// ids below do not change; recompute when this package's version rows change.
|
|
60
|
-
const [versionsRevision, setVersionsRevision] = useState(0);
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
const sub = PackageVersions().dataChanged.subscribe((evt) => {
|
|
63
|
-
if (evt.dataObject?.packageId === pkg.packageId) setVersionsRevision((value) => value + 1);
|
|
64
|
-
});
|
|
65
|
-
return () => {
|
|
66
|
-
sub.unsubscribe();
|
|
67
|
-
};
|
|
68
|
-
}, [pkg.packageId]);
|
|
69
|
-
|
|
70
|
-
const status = usePromise(
|
|
71
|
-
async (): Promise<IPackageRowStatus | null> => {
|
|
72
|
-
if (!effective.activePackageVersionId) return null;
|
|
73
|
-
const s = await checkVersionStatus(
|
|
74
|
-
pkg.packageId,
|
|
75
|
-
effective.activePackageVersionId,
|
|
76
|
-
effective.followTags,
|
|
77
|
-
);
|
|
78
|
-
if (!s) return null;
|
|
79
|
-
|
|
80
|
-
let groupReleasePv: IPackageVersion | null = null;
|
|
81
|
-
if (
|
|
82
|
-
s.activePv.versionTag === "dev" &&
|
|
83
|
-
pkg.activePackageVersionId &&
|
|
84
|
-
pkg.activePackageVersionId !== effective.activePackageVersionId
|
|
85
|
-
) {
|
|
86
|
-
try {
|
|
87
|
-
const gpv = await PackageVersions().get(pkg.activePackageVersionId);
|
|
88
|
-
if (gpv && gpv.versionTag !== "dev") groupReleasePv = gpv;
|
|
89
|
-
} catch {}
|
|
90
|
-
}
|
|
91
|
-
let latestDevPv: IPackageVersion | null = null;
|
|
92
|
-
if (s.activePv.versionTag !== "dev") {
|
|
93
|
-
const allVersions = await PackageVersions().list({ packageId: pkg.packageId });
|
|
94
|
-
for (const v of allVersions) {
|
|
95
|
-
if (v.versionTag !== "dev") continue;
|
|
96
|
-
if (!latestDevPv || (v.createdAt || "") > (latestDevPv.createdAt || "")) {
|
|
97
|
-
latestDevPv = v;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return { ...s, groupReleasePv, latestDevPv };
|
|
103
|
-
},
|
|
104
|
-
undefined,
|
|
105
|
-
[
|
|
106
|
-
effective.activePackageVersionId,
|
|
107
|
-
pkg.packageId,
|
|
108
|
-
effective.followTags,
|
|
109
|
-
pkg.activePackageVersionId,
|
|
110
|
-
versionsRevision,
|
|
111
|
-
],
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
const isOnDev = status?.activePv.versionTag === "dev";
|
|
115
|
-
const hasGroupRelease = !!status?.groupReleasePv;
|
|
116
|
-
const hasUpdate = !isOnDev && !!status?.newerLevel && !!status?.newestPv;
|
|
117
|
-
const hasDevVersion = !isOnDev && !!status?.latestDevPv;
|
|
118
|
-
const isDeviceOverridden =
|
|
119
|
-
!!effective.activePackageVersionId &&
|
|
120
|
-
!!pkg.activePackageVersionId &&
|
|
121
|
-
effective.activePackageVersionId !== pkg.activePackageVersionId;
|
|
122
|
-
|
|
123
|
-
async function handleUpdate() {
|
|
124
|
-
if (!status?.newestPv) return;
|
|
125
|
-
setUpdating(true);
|
|
126
|
-
try {
|
|
127
|
-
await activatePackageVersion(pkg.packageId, status.newestPv);
|
|
128
|
-
onUpdated();
|
|
129
|
-
} catch (err: unknown) {
|
|
130
|
-
alert(`Failed to update: ${err instanceof Error ? err.message : String(err)}`);
|
|
131
|
-
} finally {
|
|
132
|
-
setUpdating(false);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async function handleUseRelease() {
|
|
137
|
-
setUpdating(true);
|
|
138
|
-
try {
|
|
139
|
-
await (await packagesTools()).activatePackageVersion({
|
|
140
|
-
packageId: pkg.packageId,
|
|
141
|
-
scope: "device",
|
|
142
|
-
});
|
|
143
|
-
onUpdated();
|
|
144
|
-
} catch (err: unknown) {
|
|
145
|
-
alert(`Failed to switch: ${err instanceof Error ? err.message : String(err)}`);
|
|
146
|
-
} finally {
|
|
147
|
-
setUpdating(false);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
async function handleUseDev() {
|
|
152
|
-
if (!status?.latestDevPv) return;
|
|
153
|
-
setUpdating(true);
|
|
154
|
-
try {
|
|
155
|
-
await (await packagesTools()).activatePackageVersion({
|
|
156
|
-
packageId: pkg.packageId,
|
|
157
|
-
packageVersionId: status.latestDevPv.packageVersionId,
|
|
158
|
-
scope: "device",
|
|
159
|
-
});
|
|
160
|
-
onUpdated();
|
|
161
|
-
} catch (err: unknown) {
|
|
162
|
-
alert(`Failed to switch: ${err instanceof Error ? err.message : String(err)}`);
|
|
163
|
-
} finally {
|
|
164
|
-
setUpdating(false);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
<div className="container-fluid pb-4 d-flex align-items-center">
|
|
170
|
-
<div className="flex-grow-1" style={{ minWidth: 0 }}>
|
|
171
|
-
<i className="bi bi-box-fill"></i>
|
|
172
|
-
<a href={`#packages/${pkg.packageId}`}>{pkg.name}</a>
|
|
173
|
-
<span className="ms-2">
|
|
174
|
-
<PackageRuntimeBadge packageId={pkg.packageId} />
|
|
175
|
-
</span>
|
|
176
|
-
{isDeviceOverridden && (
|
|
177
|
-
<span
|
|
178
|
-
className="text-warning ms-1"
|
|
179
|
-
title="This device is using a different version than the group"
|
|
180
|
-
>
|
|
181
|
-
<i className="bi bi-pc-display" />
|
|
182
|
-
</span>
|
|
183
|
-
)}
|
|
184
|
-
{status && (
|
|
185
|
-
<span className="ms-2">
|
|
186
|
-
<small className="text-muted">v{status.activePv.version}</small>
|
|
187
|
-
{status.activePv.versionTag && (
|
|
188
|
-
<span
|
|
189
|
-
className={`badge ms-1 ${tagBadgeClass(status.activePv.versionTag)}`}
|
|
190
|
-
style={{ fontSize: "0.65em" }}
|
|
191
|
-
>
|
|
192
|
-
{status.activePv.versionTag}
|
|
193
|
-
</span>
|
|
194
|
-
)}
|
|
195
|
-
{hasUpdate ? (
|
|
196
|
-
<span
|
|
197
|
-
className={`badge ms-1 ${updateBadgeClass(status.newerLevel)}`}
|
|
198
|
-
style={{ fontSize: "0.65em" }}
|
|
199
|
-
>
|
|
200
|
-
v{status.newestPv?.version} available
|
|
201
|
-
</span>
|
|
202
|
-
) : isOnDev && hasGroupRelease ? (
|
|
203
|
-
<span className="badge ms-1 text-bg-secondary" style={{ fontSize: "0.65em" }}>
|
|
204
|
-
release: v{status.groupReleasePv?.version}
|
|
205
|
-
</span>
|
|
206
|
-
) : (
|
|
207
|
-
<span className="badge ms-1 text-bg-success" style={{ fontSize: "0.65em" }}>
|
|
208
|
-
up to date
|
|
209
|
-
</span>
|
|
210
|
-
)}
|
|
211
|
-
</span>
|
|
212
|
-
)}
|
|
213
|
-
<Tooltip markdownContent={pkg.description} positions={["bottom", "top", "right", "left"]} />
|
|
214
|
-
</div>
|
|
215
|
-
{hasUpdate && (
|
|
216
|
-
<button
|
|
217
|
-
className="btn btn-sm btn-outline-primary ms-2 text-nowrap"
|
|
218
|
-
disabled={updating}
|
|
219
|
-
onClick={handleUpdate}
|
|
220
|
-
>
|
|
221
|
-
{updating ? (
|
|
222
|
-
<span className="spinner-border spinner-border-sm me-1" />
|
|
223
|
-
) : (
|
|
224
|
-
<i className="bi bi-arrow-up-circle me-1" />
|
|
225
|
-
)}
|
|
226
|
-
Update
|
|
227
|
-
</button>
|
|
228
|
-
)}
|
|
229
|
-
{isOnDev && hasGroupRelease && (
|
|
230
|
-
<button
|
|
231
|
-
className="btn btn-sm btn-outline-secondary ms-2 text-nowrap"
|
|
232
|
-
disabled={updating}
|
|
233
|
-
onClick={handleUseRelease}
|
|
234
|
-
>
|
|
235
|
-
{updating ? (
|
|
236
|
-
<span className="spinner-border spinner-border-sm me-1" />
|
|
237
|
-
) : (
|
|
238
|
-
<i className="bi bi-box-arrow-in-right me-1" />
|
|
239
|
-
)}
|
|
240
|
-
Use Release
|
|
241
|
-
</button>
|
|
242
|
-
)}
|
|
243
|
-
{hasDevVersion && (
|
|
244
|
-
<button
|
|
245
|
-
className="btn btn-sm btn-outline-danger ms-2 text-nowrap"
|
|
246
|
-
disabled={updating}
|
|
247
|
-
onClick={handleUseDev}
|
|
248
|
-
>
|
|
249
|
-
{updating ? (
|
|
250
|
-
<span className="spinner-border spinner-border-sm me-1" />
|
|
251
|
-
) : (
|
|
252
|
-
<i className="bi bi-tools me-1" />
|
|
253
|
-
)}
|
|
254
|
-
Use Dev
|
|
255
|
-
</button>
|
|
256
|
-
)}
|
|
257
|
-
</div>
|
|
258
|
-
);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Packages screen: search, create/import/install from the search box, local folder grants,
|
|
263
|
-
* and the installed package list.
|
|
264
|
-
*/
|
|
265
|
-
export const PackageList = () => {
|
|
266
|
-
const [searchTextObs] = useState(() => observable(""));
|
|
267
|
-
const [searchText] = useObservable(searchTextObs);
|
|
268
|
-
const addingPackage = useObservableState(false);
|
|
269
|
-
const refreshKey = useObservableState(0);
|
|
270
|
-
|
|
271
|
-
const [cursorObs] = useState(() => observable<ICursorIterable<IPackage> | undefined>());
|
|
272
|
-
|
|
273
|
-
const newCursor = useCallback(async () => {
|
|
274
|
-
const cursor = await Packages().cursor(
|
|
275
|
-
{
|
|
276
|
-
$or: [
|
|
277
|
-
{ name: { $matchWords: searchText } },
|
|
278
|
-
{ description: { $matchWords: searchText } },
|
|
279
|
-
{ remoteRepo: { $matchWords: searchText } },
|
|
280
|
-
],
|
|
281
|
-
},
|
|
282
|
-
{ sortBy: ["-packageId"] },
|
|
283
|
-
);
|
|
284
|
-
cursorObs(cursor);
|
|
285
|
-
return cursor;
|
|
286
|
-
}, [searchText, cursorObs]);
|
|
287
|
-
|
|
288
|
-
useEffect(() => {
|
|
289
|
-
void newCursor();
|
|
290
|
-
}, [newCursor]);
|
|
291
|
-
|
|
292
|
-
async function loadMore(existing: IPackage[]): Promise<IPackage[]> {
|
|
293
|
-
const moreMatches: IPackage[] = [];
|
|
294
|
-
const cursor = cursorObs() || (await newCursor());
|
|
295
|
-
for await (const nextRecord of cursor) {
|
|
296
|
-
if (existing.find((e) => e.packageId === nextRecord.packageId)) continue;
|
|
297
|
-
moreMatches.push(nextRecord);
|
|
298
|
-
if (searchText.length && moreMatches.length > 5) break;
|
|
299
|
-
if (moreMatches.length >= 50) break;
|
|
300
|
-
}
|
|
301
|
-
if (moreMatches.length === 0) {
|
|
302
|
-
cursorObs(undefined);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (!searchText.length && existing.length === 0 && moreMatches.length > 0) {
|
|
306
|
-
const DEV_WITH_RELEASE_RANK = 0.5;
|
|
307
|
-
const rankMap = new Map<string, number>();
|
|
308
|
-
await Promise.all(
|
|
309
|
-
moreMatches.map(async (pkg) => {
|
|
310
|
-
try {
|
|
311
|
-
const pVar = packagePrefsVar(pkg.packageId);
|
|
312
|
-
await pVar.loadingPromise;
|
|
313
|
-
const eff = getEffectivePackagePrefs(pkg, pVar());
|
|
314
|
-
if (!eff.activePackageVersionId) return;
|
|
315
|
-
const s = await checkVersionStatus(
|
|
316
|
-
pkg.packageId,
|
|
317
|
-
eff.activePackageVersionId,
|
|
318
|
-
eff.followTags,
|
|
319
|
-
);
|
|
320
|
-
if (!s) return;
|
|
321
|
-
if (s.newerLevel) {
|
|
322
|
-
rankMap.set(pkg.packageId, updateLevelRank[s.newerLevel]);
|
|
323
|
-
} else if (s.activePv.versionTag === "dev" && pkg.activePackageVersionId) {
|
|
324
|
-
try {
|
|
325
|
-
const gpv = await PackageVersions().get(pkg.activePackageVersionId);
|
|
326
|
-
if (gpv && gpv.versionTag !== "dev") {
|
|
327
|
-
rankMap.set(pkg.packageId, DEV_WITH_RELEASE_RANK);
|
|
328
|
-
}
|
|
329
|
-
} catch {}
|
|
330
|
-
}
|
|
331
|
-
} catch {}
|
|
332
|
-
}),
|
|
333
|
-
);
|
|
334
|
-
moreMatches.sort((a, b) => {
|
|
335
|
-
const aRank = rankMap.get(a.packageId) ?? 0;
|
|
336
|
-
const bRank = rankMap.get(b.packageId) ?? 0;
|
|
337
|
-
if (bRank !== aRank) return bRank - aRank;
|
|
338
|
-
return (a.name || "").localeCompare(b.name || "");
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return moreMatches;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
async function searchSubmit(evt: React.KeyboardEvent<HTMLInputElement>) {
|
|
346
|
-
if (evt.key !== "Enter") return;
|
|
347
|
-
const name = searchText.trim();
|
|
348
|
-
if (!name) return;
|
|
349
|
-
|
|
350
|
-
if (isPackageRepositoryUrl(name)) {
|
|
351
|
-
if (!confirm(`Add remote package: ${name}`)) return;
|
|
352
|
-
try {
|
|
353
|
-
addingPackage(true);
|
|
354
|
-
const { packageId } = await (await packagesTools()).clonePackage({ url: name });
|
|
355
|
-
const pkg = await Packages().get(packageId);
|
|
356
|
-
if (pkg) {
|
|
357
|
-
mainContentPath(`packages/${packageId}`);
|
|
358
|
-
}
|
|
359
|
-
} catch (err: unknown) {
|
|
360
|
-
let errMessage = err instanceof Error ? err.message : String(err);
|
|
361
|
-
errMessage = errMessage.replace(/\s+/g, " ");
|
|
362
|
-
confirm(`Error adding remote package: ${errMessage}`);
|
|
363
|
-
} finally {
|
|
364
|
-
addingPackage(false);
|
|
365
|
-
}
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// A package id re-enables that package, or copies it here from another of your contexts.
|
|
370
|
-
if (isid(name)) {
|
|
371
|
-
if (!confirm(`Install package ${name} into this context`)) return;
|
|
372
|
-
try {
|
|
373
|
-
addingPackage(true);
|
|
374
|
-
const { packageId } = await (await packagesTools()).installPackage({ packageId: name });
|
|
375
|
-
mainContentPath(`packages/${packageId}`);
|
|
376
|
-
} catch (err: unknown) {
|
|
377
|
-
confirm(`Error installing package: ${err instanceof Error ? err.message : String(err)}`);
|
|
378
|
-
} finally {
|
|
379
|
-
addingPackage(false);
|
|
380
|
-
}
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (!confirm(`Create or import local package: ${searchText}`)) return;
|
|
385
|
-
|
|
386
|
-
try {
|
|
387
|
-
addingPackage(true);
|
|
388
|
-
const { packageId, warning } = await (await packagesTools()).createPackage({ name });
|
|
389
|
-
const pkg = await Packages().get(packageId);
|
|
390
|
-
if (pkg) {
|
|
391
|
-
if (warning) {
|
|
392
|
-
confirm(warning);
|
|
393
|
-
}
|
|
394
|
-
mainContentPath(`packages/${packageId}`);
|
|
395
|
-
}
|
|
396
|
-
} catch (err: unknown) {
|
|
397
|
-
confirm(`Error creating package: ${err instanceof Error ? err.message : String(err)}`);
|
|
398
|
-
} finally {
|
|
399
|
-
addingPackage(false);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (addingPackage()) {
|
|
404
|
-
return (
|
|
405
|
-
<div>
|
|
406
|
-
<div className="container-fluid d-flex justify-content-center mt-5">
|
|
407
|
-
<i className="bi bi-box-seam"></i> Adding Package
|
|
408
|
-
</div>
|
|
409
|
-
<div className="container-fluid d-flex justify-content-center mt-2">
|
|
410
|
-
<div
|
|
411
|
-
className="progress"
|
|
412
|
-
role="progressbar"
|
|
413
|
-
aria-label="Animated striped example"
|
|
414
|
-
aria-valuenow={100}
|
|
415
|
-
aria-valuemin={0}
|
|
416
|
-
aria-valuemax={100}
|
|
417
|
-
>
|
|
418
|
-
<div
|
|
419
|
-
className="progress-bar progress-bar-striped progress-bar-animated"
|
|
420
|
-
style={{ width: 150 }}
|
|
421
|
-
></div>
|
|
422
|
-
</div>
|
|
423
|
-
</div>
|
|
424
|
-
</div>
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
return (
|
|
429
|
-
<div className="container-fluid">
|
|
430
|
-
<div className="input-group mt-3 mb-3">
|
|
431
|
-
<Input
|
|
432
|
-
value={searchTextObs}
|
|
433
|
-
className="form-control"
|
|
434
|
-
placeholder="Search, add, or create package"
|
|
435
|
-
autoFocus={!!isDesktop()}
|
|
436
|
-
onKeyUp={(evt) => searchSubmit(evt)}
|
|
437
|
-
/>
|
|
438
|
-
<button
|
|
439
|
-
className="btn btn-outline-secondary dropdown-toggle sm"
|
|
440
|
-
type="button"
|
|
441
|
-
data-bs-toggle="dropdown"
|
|
442
|
-
aria-expanded="false"
|
|
443
|
-
>
|
|
444
|
-
<i className="bi bi-plus-lg"></i>
|
|
445
|
-
</button>
|
|
446
|
-
<ul className="dropdown-menu dropdown-menu-end">
|
|
447
|
-
<li>
|
|
448
|
-
<a className="dropdown-item" href="#packages/newlocal">
|
|
449
|
-
New Local Package
|
|
450
|
-
</a>
|
|
451
|
-
</li>
|
|
452
|
-
<li>
|
|
453
|
-
<a className="dropdown-item disabled" href="#">
|
|
454
|
-
Add Local Package
|
|
455
|
-
</a>
|
|
456
|
-
</li>
|
|
457
|
-
<li>
|
|
458
|
-
<a className="dropdown-item disabled" href="#">
|
|
459
|
-
Add Remote Package
|
|
460
|
-
</a>
|
|
461
|
-
</li>
|
|
462
|
-
<li>
|
|
463
|
-
<hr className="dropdown-divider" />
|
|
464
|
-
</li>
|
|
465
|
-
<li>
|
|
466
|
-
<a
|
|
467
|
-
className="dropdown-item"
|
|
468
|
-
onClick={() => void openOnHost(packagesRootDir)}
|
|
469
|
-
style={{ cursor: "pointer" }}
|
|
470
|
-
>
|
|
471
|
-
Open Packages Directory
|
|
472
|
-
</a>
|
|
473
|
-
</li>
|
|
474
|
-
</ul>
|
|
475
|
-
</div>
|
|
476
|
-
|
|
477
|
-
<LocalFolderGrantsPanel />
|
|
478
|
-
|
|
479
|
-
<div className="peers-list-container">
|
|
480
|
-
<LazyList
|
|
481
|
-
resetTrigger={`${searchText}_${refreshKey()}`}
|
|
482
|
-
loadMore={loadMore}
|
|
483
|
-
scrollThreshold={0.6}
|
|
484
|
-
renderItems={(packages) => {
|
|
485
|
-
return packages.map((pkg) => (
|
|
486
|
-
<PackageRow
|
|
487
|
-
key={pkg.packageId}
|
|
488
|
-
pkg={pkg}
|
|
489
|
-
onUpdated={() => refreshKey(refreshKey() + 1)}
|
|
490
|
-
/>
|
|
491
|
-
));
|
|
492
|
-
}}
|
|
493
|
-
loadingIndicator={
|
|
494
|
-
<div className="d-flex justify-content-center" style={{ height: 200 }}>
|
|
495
|
-
<LoadingIndicator />
|
|
496
|
-
</div>
|
|
497
|
-
}
|
|
498
|
-
endOfList={
|
|
499
|
-
<div className="d-flex justify-content-center" style={{ height: 200 }}>
|
|
500
|
-
{/* <span className="h3">End of List</span> */}
|
|
501
|
-
</div>
|
|
502
|
-
}
|
|
503
|
-
/>
|
|
504
|
-
</div>
|
|
505
|
-
</div>
|
|
506
|
-
);
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
registerInternalPeersUI({
|
|
510
|
-
peersUIId: "00m5fre6r5m2p2wd1m4x6nx0b",
|
|
511
|
-
component: PackageList,
|
|
512
|
-
routes: [
|
|
513
|
-
{
|
|
514
|
-
isMatch: (_props, context) => context.path === "packages",
|
|
515
|
-
uiCategory: "screen",
|
|
516
|
-
priority: 1,
|
|
517
|
-
},
|
|
518
|
-
],
|
|
519
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContractConsumer,
|
|
3
|
-
getHostContractTransport,
|
|
4
|
-
getHttpContractDefinition,
|
|
5
|
-
getUserContext,
|
|
6
|
-
type IHttpPolicyInfo,
|
|
7
|
-
waitForHostContractTransport,
|
|
8
|
-
} from "@peers-app/peers-sdk";
|
|
9
|
-
import { useEffect, useState } from "react";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Shows the host allowlist and credential refs declared by an isolated package.
|
|
13
|
-
*
|
|
14
|
-
* Secret values stay on the host. A host that does not provide System HTTP, such
|
|
15
|
-
* as the PWA, renders nothing.
|
|
16
|
-
*/
|
|
17
|
-
export const PackageNetworkPanel = (props: { packageId: string }) => {
|
|
18
|
-
const [policy, setPolicy] = useState<IHttpPolicyInfo | undefined>();
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
let cancelled = false;
|
|
22
|
-
let dispose = () => {};
|
|
23
|
-
(async () => {
|
|
24
|
-
try {
|
|
25
|
-
const userContext = await getUserContext();
|
|
26
|
-
const dataContextId = userContext.currentlyActiveGroupId() || userContext.userId;
|
|
27
|
-
const transport =
|
|
28
|
-
getHostContractTransport() ?? (await waitForHostContractTransport({ timeoutMs: 3_000 }));
|
|
29
|
-
const consumer = createContractConsumer(getHttpContractDefinition(), transport, {
|
|
30
|
-
dataContextId,
|
|
31
|
-
});
|
|
32
|
-
dispose = () => consumer.dispose();
|
|
33
|
-
const next = await consumer.tools.describePolicy({ packageId: props.packageId });
|
|
34
|
-
if (!cancelled) {
|
|
35
|
-
setPolicy(next);
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
if (!cancelled) {
|
|
39
|
-
setPolicy(undefined);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
})();
|
|
43
|
-
return () => {
|
|
44
|
-
cancelled = true;
|
|
45
|
-
dispose();
|
|
46
|
-
};
|
|
47
|
-
}, [props.packageId]);
|
|
48
|
-
|
|
49
|
-
if (!policy || (policy.allowedHosts.length === 0 && policy.credentials.length === 0)) {
|
|
50
|
-
return policy ? (
|
|
51
|
-
<div className="mt-3">
|
|
52
|
-
<small className="text-muted">This package does not declare outbound network access.</small>
|
|
53
|
-
</div>
|
|
54
|
-
) : null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<div className="mt-3">
|
|
59
|
-
<small>Network access</small>
|
|
60
|
-
<ul className="mb-2">
|
|
61
|
-
{policy.allowedHosts.map((host) => (
|
|
62
|
-
<li key={host}>
|
|
63
|
-
<code>{host}</code>
|
|
64
|
-
</li>
|
|
65
|
-
))}
|
|
66
|
-
</ul>
|
|
67
|
-
{policy.credentials.length > 0 && (
|
|
68
|
-
<>
|
|
69
|
-
<small>Credentials injected by the host</small>
|
|
70
|
-
<ul className="mb-0">
|
|
71
|
-
{policy.credentials.map((credential) => (
|
|
72
|
-
<li key={credential.ref}>
|
|
73
|
-
<code>{credential.ref}</code> sets <code>{credential.header}</code> from{" "}
|
|
74
|
-
<code>{credential.secretVar}</code> ({credential.scope})
|
|
75
|
-
</li>
|
|
76
|
-
))}
|
|
77
|
-
</ul>
|
|
78
|
-
</>
|
|
79
|
-
)}
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { camelCaseToHyphens, Packages, packagesRootDir } from "@peers-app/peers-sdk";
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
import { mainContentPath } from "../../globals";
|
|
4
|
-
import { openInEditorOnHost } from "../../host-shell/host-shell-consumer";
|
|
5
|
-
import { packagesTools } from "./packages-ipc";
|
|
6
|
-
|
|
7
|
-
/** Form for scaffolding a new local package from the template into `~/peers/packages`. */
|
|
8
|
-
export const PackageNewLocal = () => {
|
|
9
|
-
const defaultName = "New Package";
|
|
10
|
-
const [packageName, setPackageName] = useState("");
|
|
11
|
-
|
|
12
|
-
const [packageLocation, setPackageLocation] = useState("");
|
|
13
|
-
|
|
14
|
-
let packageFolderName = packageName || defaultName;
|
|
15
|
-
packageFolderName = packageFolderName.replace(/[^a-zA-Z0-9]/g, " ");
|
|
16
|
-
packageFolderName = packageFolderName.replace(/\s+/g, " ").trim();
|
|
17
|
-
packageFolderName = camelCaseToHyphens(packageFolderName);
|
|
18
|
-
|
|
19
|
-
const packageLocationDefault = `${packagesRootDir}/${packageFolderName}`;
|
|
20
|
-
|
|
21
|
-
const hiddenFileInput = React.useRef<HTMLInputElement>(null);
|
|
22
|
-
|
|
23
|
-
const handleFolderSelect = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
24
|
-
// @ts-expect-error
|
|
25
|
-
const path = e.target.files?.[0]?.path;
|
|
26
|
-
const folderPath = path;
|
|
27
|
-
if (folderPath) {
|
|
28
|
-
setPackageLocation(folderPath);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const createLocalPackage = async () => {
|
|
33
|
-
try {
|
|
34
|
-
const { packageId, warning } = await (await packagesTools()).createPackage({
|
|
35
|
-
name: packageName,
|
|
36
|
-
location: packageLocation || packageLocationDefault,
|
|
37
|
-
});
|
|
38
|
-
const pkg = await Packages().get(packageId);
|
|
39
|
-
if (pkg) {
|
|
40
|
-
if (warning) {
|
|
41
|
-
confirm(warning);
|
|
42
|
-
}
|
|
43
|
-
mainContentPath(`packages/${packageId}`);
|
|
44
|
-
void openInEditorOnHost(packageLocation || packageLocationDefault);
|
|
45
|
-
}
|
|
46
|
-
} catch (err) {
|
|
47
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
48
|
-
confirm(`Error creating package:\n\n${message}`);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<div className="container mt-2">
|
|
54
|
-
<h4 className="text-center">New Local Package</h4>
|
|
55
|
-
|
|
56
|
-
<div className="input-group mt-3 mb-3">
|
|
57
|
-
<input
|
|
58
|
-
type="text"
|
|
59
|
-
className="form-control"
|
|
60
|
-
placeholder="Package Name"
|
|
61
|
-
value={packageName}
|
|
62
|
-
onChange={(e) => setPackageName(e.target.value)}
|
|
63
|
-
/>
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
<input
|
|
67
|
-
ref={hiddenFileInput}
|
|
68
|
-
type="file"
|
|
69
|
-
className="visually-hidden"
|
|
70
|
-
onChange={handleFolderSelect}
|
|
71
|
-
// @ts-expect-error
|
|
72
|
-
directory=""
|
|
73
|
-
webkitdirectory=""
|
|
74
|
-
/>
|
|
75
|
-
<div className="input-group mt-3 mb-3">
|
|
76
|
-
<input
|
|
77
|
-
type="text"
|
|
78
|
-
className="form-control"
|
|
79
|
-
placeholder={packageLocationDefault}
|
|
80
|
-
value={packageLocation}
|
|
81
|
-
onChange={(e) => setPackageLocation(e.target.value)}
|
|
82
|
-
disabled
|
|
83
|
-
/>
|
|
84
|
-
{/* <button className="btn btn-outline-secondary" type="button"
|
|
85
|
-
onClick={() => hiddenFileInput.current?.click()}>
|
|
86
|
-
<i className="bi bi-folder-fill"></i>
|
|
87
|
-
</button> */}
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
<button
|
|
91
|
-
className="btn btn-primary float-end"
|
|
92
|
-
type="button"
|
|
93
|
-
onClick={() => createLocalPackage()}
|
|
94
|
-
disabled={!packageName}
|
|
95
|
-
>
|
|
96
|
-
Create Package
|
|
97
|
-
</button>
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
};
|