@powerhousedao/connect 6.2.3-dev.10 → 6.2.3-dev.11
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/{AddDriveModal-xAw48kdl.js → AddDriveModal-CW-ZSWkf.js} +5 -5
- package/dist/{AddDriveModal-xAw48kdl.js.map → AddDriveModal-CW-ZSWkf.js.map} +1 -1
- package/dist/{ClearStorageModal-BHLFpni1.js → ClearStorageModal-DmcvyYIt.js} +5 -5
- package/dist/{ClearStorageModal-BHLFpni1.js.map → ClearStorageModal-DmcvyYIt.js.map} +1 -1
- package/dist/{ConfirmDocumentUpgradeModal-FUOhZsk7.js → ConfirmDocumentUpgradeModal-BBrFlHp_.js} +6 -6
- package/dist/{ConfirmDocumentUpgradeModal-FUOhZsk7.js.map → ConfirmDocumentUpgradeModal-BBrFlHp_.js.map} +1 -1
- package/dist/{CookiesPolicyModal-BpyPPyxS.js → CookiesPolicyModal-lKdOuTNm.js} +4 -4
- package/dist/{CookiesPolicyModal-BpyPPyxS.js.map → CookiesPolicyModal-lKdOuTNm.js.map} +1 -1
- package/dist/{CreateDocumentModal-C45W8J0V.js → CreateDocumentModal-HmK-78sB.js} +4 -4
- package/dist/{CreateDocumentModal-C45W8J0V.js.map → CreateDocumentModal-HmK-78sB.js.map} +1 -1
- package/dist/{DebugSettingsModal-cFjT1zO6.js → DebugSettingsModal-DCHY1gxr.js} +7 -7
- package/dist/{DebugSettingsModal-cFjT1zO6.js.map → DebugSettingsModal-DCHY1gxr.js.map} +1 -1
- package/dist/{DeleteDriveModal-Dug84t1j.js → DeleteDriveModal-Cyw6hwc2.js} +5 -5
- package/dist/{DeleteDriveModal-Dug84t1j.js.map → DeleteDriveModal-Cyw6hwc2.js.map} +1 -1
- package/dist/{DeleteItemModal-mMzy3V8o.js → DeleteItemModal-CiFwstZx.js} +5 -5
- package/dist/{DeleteItemModal-mMzy3V8o.js.map → DeleteItemModal-CiFwstZx.js.map} +1 -1
- package/dist/{DisclaimerModal-DvpD5dPM.js → DisclaimerModal-DIRsjUvu.js} +4 -4
- package/dist/{DisclaimerModal-DvpD5dPM.js.map → DisclaimerModal-DIRsjUvu.js.map} +1 -1
- package/dist/{DocumentVersionUnsupportedModal-C3Q0V75l.js → DocumentVersionUnsupportedModal-KftC3-jr.js} +4 -4
- package/dist/{DocumentVersionUnsupportedModal-C3Q0V75l.js.map → DocumentVersionUnsupportedModal-KftC3-jr.js.map} +1 -1
- package/dist/{DownloadDocumentWithErrorsModal-IKl0ljQb.js → DownloadDocumentWithErrorsModal-CxsR74d-.js} +4 -4
- package/dist/{DownloadDocumentWithErrorsModal-IKl0ljQb.js.map → DownloadDocumentWithErrorsModal-CxsR74d-.js.map} +1 -1
- package/dist/{DriveAuthRequiredModal-DVK7ZQzO.js → DriveAuthRequiredModal-BoqnnNKT.js} +5 -5
- package/dist/{DriveAuthRequiredModal-DVK7ZQzO.js.map → DriveAuthRequiredModal-BoqnnNKT.js.map} +1 -1
- package/dist/{DriveSettingsModal-C6-mRQiv.js → DriveSettingsModal-DRarHRIb.js} +4 -4
- package/dist/{DriveSettingsModal-C6-mRQiv.js.map → DriveSettingsModal-DRarHRIb.js.map} +1 -1
- package/dist/{InspectorModal-Z7YMEHRm.js → InspectorModal-C-stEvbU.js} +8 -8
- package/dist/{InspectorModal-Z7YMEHRm.js.map → InspectorModal-C-stEvbU.js.map} +1 -1
- package/dist/{LoginModal-CybbOm3N.js → LoginModal-DhQTxsoG.js} +5 -5
- package/dist/{LoginModal-CybbOm3N.js.map → LoginModal-DhQTxsoG.js.map} +1 -1
- package/dist/{MissingPackageModal-nBnExqO0.js → MissingPackageModal-aotCq824.js} +5 -5
- package/dist/{MissingPackageModal-nBnExqO0.js.map → MissingPackageModal-aotCq824.js.map} +1 -1
- package/dist/{OpenFileDocumentsModal-JcGCx1ta.js → OpenFileDocumentsModal-D6KDgv7k.js} +6 -6
- package/dist/{OpenFileDocumentsModal-JcGCx1ta.js.map → OpenFileDocumentsModal-D6KDgv7k.js.map} +1 -1
- package/dist/{SettingsModal-CgqnSXs5.js → SettingsModal-BUZo2YyO.js} +9 -9
- package/dist/{SettingsModal-CgqnSXs5.js.map → SettingsModal-BUZo2YyO.js.map} +1 -1
- package/dist/{UpgradeDriveModal-_8t9slxQ.js → UpgradeDriveModal-C8scFkuq.js} +4 -4
- package/dist/{UpgradeDriveModal-_8t9slxQ.js.map → UpgradeDriveModal-C8scFkuq.js.map} +1 -1
- package/dist/app-loader-8h_8WWHM.js +4 -0
- package/dist/{app-loader-GDy45Yza.js → app-loader-DmGPm7Sl.js} +1102 -1105
- package/dist/app-loader-DmGPm7Sl.js.map +1 -0
- package/dist/app-skeleton-BQts0IHn.js +4 -0
- package/dist/app-skeleton-C6RjKQuy.js +111 -0
- package/dist/app-skeleton-C6RjKQuy.js.map +1 -0
- package/dist/boot-uobbAyWT.js +210 -0
- package/dist/boot-uobbAyWT.js.map +1 -0
- package/dist/buffer-Bu1eWySI.js +66 -0
- package/dist/buffer-Bu1eWySI.js.map +1 -0
- package/dist/{build-info-BPvkFr0E.js → build-info-BaGdg_ws.js} +5 -5
- package/dist/{build-info-BPvkFr0E.js.map → build-info-BaGdg_ws.js.map} +1 -1
- package/dist/components-BCqRZRGY.js +5 -0
- package/dist/{connect.config-DaHDEUrw.js → connect.config-CzrL0fQ8.js} +3 -3
- package/dist/{connect.config-DaHDEUrw.js.map → connect.config-CzrL0fQ8.js.map} +1 -1
- package/dist/{connection-state-3w4liC1X.js → connection-state-B-ZALWjg.js} +5 -5
- package/dist/{connection-state-3w4liC1X.js.map → connection-state-B-ZALWjg.js.map} +1 -1
- package/dist/{cookie-banner-BH6bIq24.js → cookie-banner-DNkY7wrk.js} +6 -6
- package/dist/{cookie-banner-BH6bIq24.js.map → cookie-banner-DNkY7wrk.js.map} +1 -1
- package/dist/{i18n-CWO0vYVd.js → i18n-90Q8hAPL.js} +3 -3
- package/dist/{i18n-CWO0vYVd.js.map → i18n-90Q8hAPL.js.map} +1 -1
- package/dist/{load-BJ8uRKR9.js → load-ChkCrcus.js} +8 -8
- package/dist/{load-BJ8uRKR9.js.map → load-ChkCrcus.js.map} +1 -1
- package/dist/main.js +8 -8
- package/dist/main.js.map +1 -1
- package/dist/package-manager-ncb8SFdW.js +470 -0
- package/dist/package-manager-ncb8SFdW.js.map +1 -0
- package/dist/{pglite-major-B39aOEiE.js → pglite-major-D3sdYMs2.js} +3 -3
- package/dist/{pglite-major-B39aOEiE.js.map → pglite-major-D3sdYMs2.js.map} +1 -1
- package/dist/{pglite-migrate-core-Boxqqx-c.js → pglite-migrate-core-BIWwtl5e.js} +4 -4
- package/dist/{pglite-migrate-core-Boxqqx-c.js.map → pglite-migrate-core-BIWwtl5e.js.map} +1 -1
- package/dist/{pglite-seed-BqAUvNFw.js → pglite-seed-CMX1lzzo.js} +4 -4
- package/dist/{pglite-seed-BqAUvNFw.js.map → pglite-seed-CMX1lzzo.js.map} +1 -1
- package/dist/{preferences-store-_5Cw4_YV.js → preferences-store-D6w85eGd.js} +6 -25
- package/dist/preferences-store-D6w85eGd.js.map +1 -0
- package/dist/{pwa-manifest-link-DIgOSo2Q.js → pwa-manifest-link-B38lBmEu.js} +3 -3
- package/dist/{pwa-manifest-link-DIgOSo2Q.js.map → pwa-manifest-link-B38lBmEu.js.map} +1 -1
- package/dist/{reactor-CbgxQyev.js → reactor-CskVEvz2.js} +23 -420
- package/dist/reactor-CskVEvz2.js.map +1 -0
- package/dist/reactor.worker.js +9 -4
- package/dist/reactor.worker.js.map +1 -1
- package/dist/{registerServiceWorker-BSzbNfvz.js → registerServiceWorker-B3cnPnPC.js} +5 -5
- package/dist/{registerServiceWorker-BSzbNfvz.js.map → registerServiceWorker-B3cnPnPC.js.map} +1 -1
- package/dist/start-connect.d.ts.map +1 -1
- package/dist/start-connect.js +6 -8
- package/dist/start-connect.js.map +1 -1
- package/dist/style.css +19 -0
- package/dist/{toast-BXIGd4Eb.js → toast-CO6ChlzE.js} +3 -3
- package/dist/{toast-BXIGd4Eb.js.map → toast-CO6ChlzE.js.map} +1 -1
- package/dist/{use-renown-login-Cf3va6u_.js → use-renown-login-rS9wfcuG.js} +3 -3
- package/dist/{use-renown-login-Cf3va6u_.js.map → use-renown-login-rS9wfcuG.js.map} +1 -1
- package/dist/useIsEmbedded-B_AIFqBu.js +26 -0
- package/dist/useIsEmbedded-B_AIFqBu.js.map +1 -0
- package/dist/{useRegistryPackages-BnUcL_nZ.js → useRegistryPackages-B4jnu65n.js} +60 -3
- package/dist/useRegistryPackages-B4jnu65n.js.map +1 -0
- package/package.json +12 -12
- package/dist/app-loader-GDy45Yza.js.map +0 -1
- package/dist/app-loader-WZecUfE8.js +0 -4
- package/dist/components-Df4NlQZz.js +0 -4
- package/dist/preferences-store-_5Cw4_YV.js.map +0 -1
- package/dist/reactor-CbgxQyev.js.map +0 -1
- package/dist/useRegistryPackages-BnUcL_nZ.js.map +0 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5c60f239-1c35-57a1-83fc-fb51532676b8")}catch(e){}}();
|
|
3
3
|
import { n as getRuntimeConfig } from "./runtime-config-DL3QjcfM.js";
|
|
4
|
-
import { a as resolvePgMajorForRuntime, r as loadPGliteModule } from "./pglite-major-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { PWA_IDB_KEY, PWA_IDB_NAME, PWA_IDB_STORE, PWA_IDB_VERSION, mergePwaConfig, withInferredCategory } from "@powerhousedao/shared/connect";
|
|
4
|
+
import { a as resolvePgMajorForRuntime, r as loadPGliteModule } from "./pglite-major-D3sdYMs2.js";
|
|
5
|
+
import { n as buildPHGlobalConfig, o as phGlobalConfig } from "./connect.config-CzrL0fQ8.js";
|
|
6
|
+
import { r as toast } from "./toast-CO6ChlzE.js";
|
|
7
|
+
import { r as getSharedDeps, t as BrowserPackageManager } from "./package-manager-ncb8SFdW.js";
|
|
8
|
+
import { i as getVersion, n as getGitSha } from "./build-info-BaGdg_ws.js";
|
|
9
|
+
import { a as detectReactorPgMajor, h as RELATIONAL_PGLITE_NAME, m as REACTOR_PGLITE_NAME, n as setWorkerConnectionStatus, o as detectRelationalPgMajor, p as REACTOR_INSTANCE_NAMESPACE } from "./connection-state-B-ZALWjg.js";
|
|
11
10
|
import { createRelationalDb } from "@powerhousedao/shared/processors";
|
|
12
11
|
import { DocumentModelRegistry, DocumentModelResolver, ReactorEventTypes, createReactorHostModuleBase } from "@powerhousedao/reactor";
|
|
13
12
|
import { MessageRouter, RPC_PROTOCOL_VERSION, SyncManagerProxy, connectReactorClient, createInspectorProxy, createPortTransport, createReactorEventBusProxy, createRelationalPgliteProxy, createWorkerAdminClient, postReactorIdentity } from "@powerhousedao/reactor-browser/rpc";
|
|
@@ -16,89 +15,8 @@ import { PGliteDialect } from "kysely-pglite-dialect";
|
|
|
16
15
|
import { BrowserLocalStorage, ChannelScheme as ChannelScheme$1, DRIVE_DOCUMENT_TYPES, DocumentCache, DocumentChangeType, ReactorBuilder as ReactorBuilder$1, ReactorClientBuilder as ReactorClientBuilder$1, RegistryClient, addDrive, addPHEventHandlers, addRemoteDrive, createAnalyticsStore, extractDriveSlugFromPath, extractNodeSlugFromPath, getDrives, isDriveAuthError, login, refreshReactorDataClient, setAttachmentService, setDefaultPHGlobalConfig, setDocumentCache, setDriveMetadata, setDrives, setFeatures, setPGliteDB, setPHToast, setPackageDiscoveryService, setReactorClient, setReactorClientModule, setRenown, setSelectedDrive, setSelectedNode, setVetraPackageManager, waitForDocumentReady } from "@powerhousedao/reactor-browser";
|
|
17
16
|
import { ConsoleLogger, logger, setLogLevel as setLogLevel$1 } from "document-model";
|
|
18
17
|
import { BrowserKeyStorage, RenownBuilder, RenownCryptoBuilder, createSignatureVerifier } from "@renown/sdk";
|
|
19
|
-
import { PwaConfigSchema } from "@powerhousedao/shared/document-model";
|
|
20
18
|
import { createAttachmentClient, createRemoteAttachmentService, createXhrUploadTransport } from "@powerhousedao/reactor-attachments/client";
|
|
21
19
|
import { OpenFeature } from "@openfeature/web-sdk";
|
|
22
|
-
import * as common from "@powerhousedao/powerhouse-vetra-packages";
|
|
23
|
-
import commonPkg from "@powerhousedao/powerhouse-vetra-packages/package.json" with { type: "json" };
|
|
24
|
-
import { toCdnUrl } from "@powerhousedao/shared/registry/urls";
|
|
25
|
-
import vetraPkg from "@powerhousedao/vetra/package.json" with { type: "json" };
|
|
26
|
-
//#region src/utils/pwa-idb.ts
|
|
27
|
-
function openPwaIdb() {
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
const req = indexedDB.open(PWA_IDB_NAME, PWA_IDB_VERSION);
|
|
30
|
-
req.onupgradeneeded = () => {
|
|
31
|
-
if (!req.result.objectStoreNames.contains(PWA_IDB_STORE)) req.result.createObjectStore(PWA_IDB_STORE);
|
|
32
|
-
};
|
|
33
|
-
req.onerror = () => reject(req.error ?? /* @__PURE__ */ new Error("ph-pwa open failed"));
|
|
34
|
-
req.onblocked = () => reject(/* @__PURE__ */ new Error("ph-pwa open blocked"));
|
|
35
|
-
req.onsuccess = () => resolve(req.result);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/** Write (replace) the single merged fragment record. Best-effort: a failure to
|
|
39
|
-
* mirror the manifest must never break package installation, so callers ignore
|
|
40
|
-
* rejections. No-op when IndexedDB is unavailable (SSR/tests). */
|
|
41
|
-
async function writeMergedPwaFragment(fragment) {
|
|
42
|
-
if (typeof indexedDB === "undefined") return;
|
|
43
|
-
const db = await openPwaIdb();
|
|
44
|
-
try {
|
|
45
|
-
await new Promise((resolve, reject) => {
|
|
46
|
-
const tx = db.transaction(PWA_IDB_STORE, "readwrite");
|
|
47
|
-
tx.oncomplete = () => resolve();
|
|
48
|
-
tx.onerror = () => reject(tx.error ?? /* @__PURE__ */ new Error("PWA fragment write failed"));
|
|
49
|
-
tx.objectStore(PWA_IDB_STORE).put({
|
|
50
|
-
version: 1,
|
|
51
|
-
fragment,
|
|
52
|
-
updatedAt: Date.now()
|
|
53
|
-
}, PWA_IDB_KEY);
|
|
54
|
-
});
|
|
55
|
-
} finally {
|
|
56
|
-
db.close();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/** Resolve `src` against the package `baseUrl`, absolute srcs passing through.
|
|
60
|
-
* `baseUrl` may itself be relative (e.g. a same-origin-proxied registry, or the
|
|
61
|
-
* dev `/node_modules/…` path), so it is first made absolute against the app
|
|
62
|
-
* origin — `new URL(src, relativeBase)` would otherwise throw and silently
|
|
63
|
-
* leave the src unresolved. A malformed src is left untouched. */
|
|
64
|
-
function toAbsoluteAssetUrl(src, baseUrl) {
|
|
65
|
-
try {
|
|
66
|
-
const origin = typeof location !== "undefined" ? location.href : "http://localhost/";
|
|
67
|
-
return new URL(src, new URL(baseUrl, origin)).toString();
|
|
68
|
-
} catch {
|
|
69
|
-
return src;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function resolveIconSrc(icon, baseUrl) {
|
|
73
|
-
return {
|
|
74
|
-
...icon,
|
|
75
|
-
src: toAbsoluteAssetUrl(icon.src, baseUrl)
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Rewrite a package fragment's relative asset srcs (manifest icons and
|
|
80
|
-
* file-handler icons) to absolute URLs against the package's base — a runtime
|
|
81
|
-
* package's assets live on the registry CDN, not the app origin, so the served
|
|
82
|
-
* manifest must point there. `baseUrl` null (a local/bundled package whose
|
|
83
|
-
* assets are app-origin-relative) leaves srcs untouched.
|
|
84
|
-
*/
|
|
85
|
-
function resolveFragmentAssetUrls(config, baseUrl) {
|
|
86
|
-
if (!baseUrl || !config.manifest) return config;
|
|
87
|
-
const m = config.manifest;
|
|
88
|
-
const resolveIcons = (icons) => icons?.map((icon) => resolveIconSrc(icon, baseUrl));
|
|
89
|
-
return {
|
|
90
|
-
...config,
|
|
91
|
-
manifest: {
|
|
92
|
-
...m,
|
|
93
|
-
icons: resolveIcons(m.icons),
|
|
94
|
-
file_handlers: m.file_handlers?.map((handler) => ({
|
|
95
|
-
...handler,
|
|
96
|
-
icons: resolveIcons(handler.icons)
|
|
97
|
-
}))
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
20
|
//#region src/pglite.db.ts
|
|
103
21
|
async function createMainThreadPGlite(major, dbName) {
|
|
104
22
|
const { PGlite } = await loadPGliteModule(major);
|
|
@@ -683,325 +601,6 @@ var PackageDiscoveryService = class {
|
|
|
683
601
|
}
|
|
684
602
|
};
|
|
685
603
|
//#endregion
|
|
686
|
-
//#region src/package-manager.ts
|
|
687
|
-
/**
|
|
688
|
-
* Strip any `@tag` / `@version` suffix from a package spec, returning the bare
|
|
689
|
-
* package name. Mirrors `parsePackageSpec` on the UI side.
|
|
690
|
-
*/
|
|
691
|
-
function parseBareName(spec) {
|
|
692
|
-
const trimmed = spec.trim();
|
|
693
|
-
const at = trimmed.startsWith("@") ? trimmed.lastIndexOf("@") : trimmed.indexOf("@");
|
|
694
|
-
return at > 0 ? trimmed.slice(0, at) : trimmed;
|
|
695
|
-
}
|
|
696
|
-
async function fetchPackageJsonVersion(baseUrl) {
|
|
697
|
-
try {
|
|
698
|
-
const res = await fetch(baseUrl);
|
|
699
|
-
if (!res.ok) return void 0;
|
|
700
|
-
const pkg = await res.json();
|
|
701
|
-
return typeof pkg.version === "string" ? pkg.version : void 0;
|
|
702
|
-
} catch {
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
const LOCAL_PACKAGE_NAME = "Local";
|
|
707
|
-
var BrowserPackageManager = class {
|
|
708
|
-
registryUrl;
|
|
709
|
-
#storage;
|
|
710
|
-
#packages = /* @__PURE__ */ new Map();
|
|
711
|
-
#subscribers = /* @__PURE__ */ new Set();
|
|
712
|
-
#packagesMemo = [];
|
|
713
|
-
#stylesheets = /* @__PURE__ */ new Map();
|
|
714
|
-
#localPackage;
|
|
715
|
-
#cdnUrl;
|
|
716
|
-
#localPackageVersion;
|
|
717
|
-
#localPackageNames = new Set([LOCAL_PACKAGE_NAME]);
|
|
718
|
-
#pwaSyncTimer;
|
|
719
|
-
/** Serialized last-mirrored PWA fragment; lets a sync skip the IndexedDB
|
|
720
|
-
* write + manifest re-attach when nothing PWA-relevant changed. */
|
|
721
|
-
#lastSyncedFragmentJson;
|
|
722
|
-
constructor(namespace, registryUrl) {
|
|
723
|
-
this.#storage = new BrowserLocalStorage(namespace + ":PH_PACKAGES");
|
|
724
|
-
this.registryUrl = registryUrl;
|
|
725
|
-
this.#cdnUrl = registryUrl !== null ? toCdnUrl(registryUrl) : null;
|
|
726
|
-
}
|
|
727
|
-
async init(localPackage, localPackageVersion, studioMode) {
|
|
728
|
-
this.addLocalPackage(common.manifest.name, common, commonPkg.version);
|
|
729
|
-
if (studioMode) {
|
|
730
|
-
const vetra = await import("@powerhousedao/vetra");
|
|
731
|
-
this.addLocalPackage(vetra.manifest.name, vetra, vetraPkg.version);
|
|
732
|
-
}
|
|
733
|
-
if (localPackage) this.updateLocalPackage(localPackage, localPackageVersion);
|
|
734
|
-
for (const packageName of this.#storage.keys()) {
|
|
735
|
-
const specForReload = this.#storage.get(packageName)?.spec ?? packageName;
|
|
736
|
-
console.debug(`[Connect][PackageManager] Rehydrating "${packageName}" via spec "${specForReload}"`);
|
|
737
|
-
if ((await this.addPackage(specForReload)).type === "error") this.#storage.delete(packageName);
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
addLocalPackage(name, loadedPackage, version) {
|
|
741
|
-
this.#localPackageNames.add(name);
|
|
742
|
-
this.#registerPackage({
|
|
743
|
-
name,
|
|
744
|
-
importUrl: null,
|
|
745
|
-
stylesheetUrl: null,
|
|
746
|
-
loadedPackage,
|
|
747
|
-
version
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
updateLocalPackage(pkg, version) {
|
|
751
|
-
console.debug("Updating local package:", pkg);
|
|
752
|
-
this.#localPackage = pkg;
|
|
753
|
-
this.#registerPackage({
|
|
754
|
-
name: LOCAL_PACKAGE_NAME,
|
|
755
|
-
stylesheetUrl: null,
|
|
756
|
-
importUrl: null,
|
|
757
|
-
loadedPackage: pkg
|
|
758
|
-
});
|
|
759
|
-
if (version) {
|
|
760
|
-
this.#localPackageVersion = version;
|
|
761
|
-
this.#notifyPackagesChanged();
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
fetchPackageJsonVersion("/package.json").then((fetchedVersion) => {
|
|
765
|
-
this.#localPackageVersion = fetchedVersion;
|
|
766
|
-
if (fetchedVersion) this.#notifyPackagesChanged();
|
|
767
|
-
}).catch(() => {});
|
|
768
|
-
}
|
|
769
|
-
get packages() {
|
|
770
|
-
return this.#packagesMemo;
|
|
771
|
-
}
|
|
772
|
-
get cdnUrl() {
|
|
773
|
-
return this.#cdnUrl;
|
|
774
|
-
}
|
|
775
|
-
getPackageSource(packageName) {
|
|
776
|
-
if (this.#localPackageNames.has(packageName)) return "common";
|
|
777
|
-
if (packageName === this.#localPackage?.manifest.name) return "project";
|
|
778
|
-
const packageMeta = this.#storage.get(packageName);
|
|
779
|
-
if (!packageMeta) return null;
|
|
780
|
-
if (packageMeta.importUrl === `/node_modules/${packageName}`) return "local-install";
|
|
781
|
-
return "registry-install";
|
|
782
|
-
}
|
|
783
|
-
/**
|
|
784
|
-
* Return the registry-installed packages keyed by their storage name (which
|
|
785
|
-
* is the registry spec, e.g. "@powerhousedao/clint-common"), with the
|
|
786
|
-
* installed version when known. Excludes bundled (common) packages, the
|
|
787
|
-
* local project package, and packages resolved out of `/node_modules/`.
|
|
788
|
-
*/
|
|
789
|
-
getRegistryPackages() {
|
|
790
|
-
const out = [];
|
|
791
|
-
for (const [name, meta] of this.#storage) {
|
|
792
|
-
if (this.#localPackageNames.has(name)) continue;
|
|
793
|
-
if (name === LOCAL_PACKAGE_NAME) continue;
|
|
794
|
-
if (meta.importUrl === `/node_modules/${name}`) continue;
|
|
795
|
-
out.push({
|
|
796
|
-
name,
|
|
797
|
-
version: meta.version
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
return out;
|
|
801
|
-
}
|
|
802
|
-
getPackageVersion(packageName) {
|
|
803
|
-
if (packageName === this.#localPackage?.manifest.name) return this.#localPackageVersion;
|
|
804
|
-
return this.#storage.get(packageName)?.version;
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* The spec the user requested when this package was installed (e.g.
|
|
808
|
-
* `name@dev` or `name@6.2.1`). Undefined for bare-name installs, legacy
|
|
809
|
-
* entries, and local packages — the Package Manager treats that as the
|
|
810
|
-
* `latest` stream when picking update targets.
|
|
811
|
-
*/
|
|
812
|
-
getPackageSpec(packageName) {
|
|
813
|
-
return this.#storage.get(packageName)?.spec;
|
|
814
|
-
}
|
|
815
|
-
async addPackage(packageSpec) {
|
|
816
|
-
const bareName = parseBareName(packageSpec);
|
|
817
|
-
const hasTagOrVersion = bareName !== packageSpec;
|
|
818
|
-
console.debug(`[Connect][PackageManager] addPackage spec="${packageSpec}" bareName="${bareName}"`);
|
|
819
|
-
const existingPackage = this.#packages.get(bareName);
|
|
820
|
-
if (existingPackage) {
|
|
821
|
-
const requestedVersion = hasTagOrVersion ? packageSpec.slice(bareName.length + 1) : void 0;
|
|
822
|
-
const currentVersion = this.#storage.get(bareName)?.version;
|
|
823
|
-
if (this.#localPackageNames.has(bareName) || !requestedVersion || !currentVersion || requestedVersion === currentVersion) {
|
|
824
|
-
console.debug(`[Connect][PackageManager] "${bareName}" already loaded; skipping re-fetch`);
|
|
825
|
-
return {
|
|
826
|
-
type: "success",
|
|
827
|
-
package: existingPackage
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
console.debug(`[Connect][PackageManager] "${bareName}" version bump ${currentVersion} → ${requestedVersion}; refetching`);
|
|
831
|
-
}
|
|
832
|
-
try {
|
|
833
|
-
const packageWithMeta = await this.#loadPackage(packageSpec);
|
|
834
|
-
packageWithMeta.name = bareName;
|
|
835
|
-
if (hasTagOrVersion) packageWithMeta.spec = packageSpec;
|
|
836
|
-
if (existingPackage) this.#unmountStylesheet(bareName);
|
|
837
|
-
this.#registerPackage(packageWithMeta);
|
|
838
|
-
return {
|
|
839
|
-
type: "success",
|
|
840
|
-
package: packageWithMeta.loadedPackage
|
|
841
|
-
};
|
|
842
|
-
} catch (error) {
|
|
843
|
-
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
844
|
-
console.error(`[Connect][PackageManager] Failed to install package "${packageSpec}": ${normalized.message}`, normalized);
|
|
845
|
-
return {
|
|
846
|
-
type: "error",
|
|
847
|
-
error: normalized
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
async addPackages(packageNames) {
|
|
852
|
-
const results = [];
|
|
853
|
-
for (const packageName of packageNames) {
|
|
854
|
-
const result = await this.addPackage(packageName);
|
|
855
|
-
results.push(result);
|
|
856
|
-
}
|
|
857
|
-
return results;
|
|
858
|
-
}
|
|
859
|
-
removePackage(name) {
|
|
860
|
-
this.#packages.delete(name);
|
|
861
|
-
this.#storage.delete(name);
|
|
862
|
-
this.#unmountStylesheet(name);
|
|
863
|
-
this.#notifyPackagesChanged();
|
|
864
|
-
}
|
|
865
|
-
subscribe(handler) {
|
|
866
|
-
this.#subscribers.add(handler);
|
|
867
|
-
return () => {
|
|
868
|
-
this.#subscribers.delete(handler);
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
load(documentType) {
|
|
872
|
-
const documentModelModule = Array.from(this.#packages.values().flatMap((p) => p.documentModels)).find((m) => m.documentModel.global.id === documentType);
|
|
873
|
-
if (documentModelModule) return Promise.resolve(documentModelModule);
|
|
874
|
-
return Promise.reject(/* @__PURE__ */ new Error("Model not available"));
|
|
875
|
-
}
|
|
876
|
-
async #loadPackageFromNodeModules(name) {
|
|
877
|
-
const importUrl = `/node_modules/${name}/browser/index.js`;
|
|
878
|
-
const stylesheetUrl = `/node_modules/${name}/style.css`;
|
|
879
|
-
const packageWithMeta = await this.#importPackage({
|
|
880
|
-
name,
|
|
881
|
-
importUrl,
|
|
882
|
-
stylesheetUrl
|
|
883
|
-
});
|
|
884
|
-
packageWithMeta.version = await fetchPackageJsonVersion(`/node_modules/${name}/package.json`);
|
|
885
|
-
return packageWithMeta;
|
|
886
|
-
}
|
|
887
|
-
async #loadPackageFromRegistry(name) {
|
|
888
|
-
const importUrl = `${this.#cdnUrl}/${name}/browser/index.js`;
|
|
889
|
-
const stylesheetUrl = `${this.#cdnUrl}/${name}/style.css`;
|
|
890
|
-
const packageWithMeta = await this.#importPackage({
|
|
891
|
-
name,
|
|
892
|
-
importUrl,
|
|
893
|
-
stylesheetUrl
|
|
894
|
-
});
|
|
895
|
-
packageWithMeta.version = await fetchPackageJsonVersion(`${this.#cdnUrl}/${name}/package.json`);
|
|
896
|
-
return packageWithMeta;
|
|
897
|
-
}
|
|
898
|
-
async #importPackage(packageMeta) {
|
|
899
|
-
const { name, importUrl, stylesheetUrl } = packageMeta;
|
|
900
|
-
if (!importUrl) throw new Error(`Import url not defined for package "${name}".`);
|
|
901
|
-
return {
|
|
902
|
-
name,
|
|
903
|
-
loadedPackage: await import(
|
|
904
|
-
/* @vite-ignore */
|
|
905
|
-
importUrl
|
|
906
|
-
),
|
|
907
|
-
importUrl,
|
|
908
|
-
stylesheetUrl
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
async #loadPackage(packageName) {
|
|
912
|
-
if (this.#localPackageNames.has(packageName)) throw new Error(`Package "${packageName}" is a local package and cannot be loaded dynamically.`);
|
|
913
|
-
if (!import.meta.env.PROD) try {
|
|
914
|
-
return await this.#loadPackageFromNodeModules(packageName);
|
|
915
|
-
} catch (error) {
|
|
916
|
-
console.warn(`Failed to load package "${packageName}" from node_modules:`, error);
|
|
917
|
-
}
|
|
918
|
-
if (!this.registryUrl) throw new Error("Registry url not defined.");
|
|
919
|
-
return await this.#loadPackageFromRegistry(packageName);
|
|
920
|
-
}
|
|
921
|
-
#registerPackage(packageWithMeta) {
|
|
922
|
-
const { name, loadedPackage, importUrl, stylesheetUrl, version, spec } = packageWithMeta;
|
|
923
|
-
if (stylesheetUrl !== null) this.#mountStylesheet(name, stylesheetUrl);
|
|
924
|
-
this.#packages.set(name, loadedPackage);
|
|
925
|
-
this.#storage.set(name, {
|
|
926
|
-
name,
|
|
927
|
-
importUrl,
|
|
928
|
-
stylesheetUrl,
|
|
929
|
-
version,
|
|
930
|
-
...spec ? { spec } : {}
|
|
931
|
-
});
|
|
932
|
-
console.debug(`[Connect][PackageManager] Registered "${name}" (version=${version ?? "?"}, spec=${spec ?? "—"})`);
|
|
933
|
-
this.#notifyPackagesChanged();
|
|
934
|
-
}
|
|
935
|
-
#mountStylesheet(name, href) {
|
|
936
|
-
const existing = this.#stylesheets.get(name);
|
|
937
|
-
if (existing) return existing;
|
|
938
|
-
const style = document.createElement("style");
|
|
939
|
-
style.textContent = `@import url("${href}") layer(external-packages);`;
|
|
940
|
-
document.head.appendChild(style);
|
|
941
|
-
this.#stylesheets.set(name, style);
|
|
942
|
-
}
|
|
943
|
-
#unmountStylesheet(name) {
|
|
944
|
-
const style = this.#stylesheets.get(name);
|
|
945
|
-
if (!style) return;
|
|
946
|
-
style.remove();
|
|
947
|
-
this.#stylesheets.delete(name);
|
|
948
|
-
}
|
|
949
|
-
#notifyPackagesChanged() {
|
|
950
|
-
this.#packagesMemo = Array.from(this.#packages.values());
|
|
951
|
-
const packages = this.packages;
|
|
952
|
-
this.#subscribers.forEach((handler) => {
|
|
953
|
-
handler({ packages });
|
|
954
|
-
});
|
|
955
|
-
this.#schedulePwaSync();
|
|
956
|
-
}
|
|
957
|
-
/**
|
|
958
|
-
* Debounced mirror of every loaded package's PWA fragment into IndexedDB, so
|
|
959
|
-
* the service worker can serve a web-app manifest that reflects packages
|
|
960
|
-
* installed AT RUNTIME (a SW can't read localStorage, where the package list
|
|
961
|
-
* lives). Debounced because `init()` rehydrates many packages in a burst;
|
|
962
|
-
* coalescing collapses that into a single write.
|
|
963
|
-
*/
|
|
964
|
-
#schedulePwaSync() {
|
|
965
|
-
if (typeof indexedDB === "undefined") return;
|
|
966
|
-
clearTimeout(this.#pwaSyncTimer);
|
|
967
|
-
this.#pwaSyncTimer = setTimeout(() => {
|
|
968
|
-
this.#syncPwaFragments();
|
|
969
|
-
}, 50);
|
|
970
|
-
}
|
|
971
|
-
async #syncPwaFragments() {
|
|
972
|
-
const contributions = [];
|
|
973
|
-
for (const [name, loadedPackage] of this.#packages) {
|
|
974
|
-
const manifest = loadedPackage.manifest;
|
|
975
|
-
let config = {};
|
|
976
|
-
if (manifest.pwa) {
|
|
977
|
-
const parsed = PwaConfigSchema.safeParse(manifest.pwa);
|
|
978
|
-
if (parsed.success) {
|
|
979
|
-
const importUrl = this.#storage.get(name)?.importUrl ?? null;
|
|
980
|
-
const baseUrl = importUrl ? importUrl.replace(/browser\/index\.js$/, "") : null;
|
|
981
|
-
config = resolveFragmentAssetUrls(parsed.data, baseUrl);
|
|
982
|
-
} else console.warn(`[Connect][PWA] "${name}" ships an invalid pwa fragment; skipped.`, parsed.error);
|
|
983
|
-
}
|
|
984
|
-
config = withInferredCategory(config, manifest.category);
|
|
985
|
-
if (Object.keys(config).length === 0) continue;
|
|
986
|
-
contributions.push({
|
|
987
|
-
source: name,
|
|
988
|
-
config
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
const merged = mergePwaConfig(contributions);
|
|
992
|
-
const mergedJson = JSON.stringify(merged);
|
|
993
|
-
if (mergedJson === this.#lastSyncedFragmentJson) return;
|
|
994
|
-
try {
|
|
995
|
-
await writeMergedPwaFragment(merged);
|
|
996
|
-
} catch (error) {
|
|
997
|
-
console.debug("[Connect][PWA] fragment mirror to IndexedDB failed:", error);
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
this.#lastSyncedFragmentJson = mergedJson;
|
|
1001
|
-
refreshPwaManifestLink();
|
|
1002
|
-
}
|
|
1003
|
-
};
|
|
1004
|
-
//#endregion
|
|
1005
604
|
//#region src/reactor-worker-name.ts
|
|
1006
605
|
const GEN_KEY_PREFIX = "ph-reactor-gen:";
|
|
1007
606
|
function reactorWorkerName(namespace) {
|
|
@@ -1072,6 +671,7 @@ function createWorkerReactorClientModule(args) {
|
|
|
1072
671
|
relationalNamespace: args.relationalNamespace,
|
|
1073
672
|
cdnUrl: args.cdnUrl,
|
|
1074
673
|
packageSpecs: args.packageSpecs,
|
|
674
|
+
sharedImports: args.sharedImports,
|
|
1075
675
|
studioMode: args.studioMode,
|
|
1076
676
|
renownChainId: args.renownChainId,
|
|
1077
677
|
featureFlags: args.featureFlags
|
|
@@ -1329,26 +929,29 @@ async function createReactor(localPackage) {
|
|
|
1329
929
|
if (isReactorWorkerEnabled()) {
|
|
1330
930
|
const packageSpecs = packageManager.getRegistryPackages().map((p) => p.version ? `${p.name}@${p.version}` : p.name);
|
|
1331
931
|
const registryClient = new RegistryClient(packageManager.cdnUrl ?? "");
|
|
932
|
+
const documentModelLoader = { async load(documentType) {
|
|
933
|
+
const names = packageManager.cdnUrl ? await registryClient.getPackagesByDocumentType(documentType) : [];
|
|
934
|
+
for (const name of names) {
|
|
935
|
+
const result = await packageManager.addPackage(name);
|
|
936
|
+
if (result.type === "error") throw new Error(`Failed to install package "${name}" for document model: ${documentType}`, { cause: result.error });
|
|
937
|
+
}
|
|
938
|
+
const module = packageManager.packages.flatMap((p) => p.documentModels).find((m) => m.documentModel.global.id === documentType);
|
|
939
|
+
if (!module) throw new Error(names.length > 0 ? `Installed [${names.join(", ")}] but document model not available: ${documentType}` : `No package found for document model: ${documentType} (cdnUrl: ${packageManager.cdnUrl ?? "none"})`);
|
|
940
|
+
return module;
|
|
941
|
+
} };
|
|
942
|
+
const sharedImports = (await getSharedDeps())?.imports;
|
|
1332
943
|
const workerClient = createWorkerReactorClientModule({
|
|
1333
944
|
namespace: REACTOR_INSTANCE_NAMESPACE,
|
|
1334
945
|
relationalNamespace: RELATIONAL_PGLITE_NAME,
|
|
1335
946
|
cdnUrl: packageManager.cdnUrl ?? "",
|
|
1336
947
|
packageSpecs,
|
|
948
|
+
sharedImports,
|
|
1337
949
|
studioMode: phGlobalConfig.studioMode,
|
|
1338
950
|
renownChainId,
|
|
1339
951
|
featureFlags: reactorFeatureFlags,
|
|
1340
952
|
documentModelModules,
|
|
1341
953
|
upgradeManifests,
|
|
1342
|
-
documentModelLoader
|
|
1343
|
-
const names = packageManager.cdnUrl ? await registryClient.getPackagesByDocumentType(documentType) : [];
|
|
1344
|
-
for (const name of names) {
|
|
1345
|
-
const result = await packageManager.addPackage(name);
|
|
1346
|
-
if (result.type === "error") throw new Error(`Failed to install package "${name}" for document model: ${documentType}`, { cause: result.error });
|
|
1347
|
-
}
|
|
1348
|
-
const module = packageManager.packages.flatMap((p) => p.documentModels).find((m) => m.documentModel.global.id === documentType);
|
|
1349
|
-
if (!module) throw new Error(names.length > 0 ? `Installed [${names.join(", ")}] but document model not available: ${documentType}` : `No package found for document model: ${documentType} (cdnUrl: ${packageManager.cdnUrl ?? "none"})`);
|
|
1350
|
-
return module;
|
|
1351
|
-
} },
|
|
954
|
+
documentModelLoader,
|
|
1352
955
|
renown,
|
|
1353
956
|
onReload: (reason, workerGen) => {
|
|
1354
957
|
logger.warn("Reactor worker requested reload: @reason", reason);
|
|
@@ -1460,5 +1063,5 @@ function getDriveUrl() {
|
|
|
1460
1063
|
//#endregion
|
|
1461
1064
|
export { createReactor as n, clearReactorStorage as t };
|
|
1462
1065
|
|
|
1463
|
-
//# sourceMappingURL=reactor-
|
|
1464
|
-
//# debugId=
|
|
1066
|
+
//# sourceMappingURL=reactor-CskVEvz2.js.map
|
|
1067
|
+
//# debugId=5c60f239-1c35-57a1-83fc-fb51532676b8
|