@powerhousedao/connect 6.2.3-dev.7 → 6.2.3-dev.70
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/CUSTOMIZING.md +80 -0
- package/README.md +28 -0
- package/RUNTIME-CONFIG.md +472 -0
- package/dist/{AddDriveModal-xAw48kdl.js → AddDriveModal-BjgmiHJr.js} +10 -10
- package/dist/AddDriveModal-BjgmiHJr.js.map +1 -0
- package/dist/{ClearStorageModal-Czo-h6OE.js → ClearStorageModal-BwGVIuLX.js} +11 -13
- package/dist/ClearStorageModal-BwGVIuLX.js.map +1 -0
- package/dist/{ConfirmDocumentUpgradeModal-FUOhZsk7.js → ConfirmDocumentUpgradeModal-CoixS60F.js} +9 -8
- package/dist/ConfirmDocumentUpgradeModal-CoixS60F.js.map +1 -0
- package/dist/{CookiesPolicyModal-BpyPPyxS.js → CookiesPolicyModal-BpFjYc7T.js} +5 -5
- package/dist/{CookiesPolicyModal-BpyPPyxS.js.map → CookiesPolicyModal-BpFjYc7T.js.map} +1 -1
- package/dist/{CreateDocumentModal-C45W8J0V.js → CreateDocumentModal-B-cXzeOA.js} +11 -10
- package/dist/CreateDocumentModal-B-cXzeOA.js.map +1 -0
- package/dist/{DebugSettingsModal-BUkre5Ke.js → DebugSettingsModal-DfOnR4iY.js} +9 -9
- package/dist/DebugSettingsModal-DfOnR4iY.js.map +1 -0
- package/dist/{DeleteDriveModal-Dug84t1j.js → DeleteDriveModal-1pAIayG_.js} +7 -7
- package/dist/DeleteDriveModal-1pAIayG_.js.map +1 -0
- package/dist/{DeleteItemModal-mMzy3V8o.js → DeleteItemModal-BUpqmFxS.js} +8 -8
- package/dist/DeleteItemModal-BUpqmFxS.js.map +1 -0
- package/dist/{DisclaimerModal-DvpD5dPM.js → DisclaimerModal-TIJXRYLF.js} +7 -7
- package/dist/DisclaimerModal-TIJXRYLF.js.map +1 -0
- package/dist/{DocumentVersionUnsupportedModal-C3Q0V75l.js → DocumentVersionUnsupportedModal-DH9Zzsyw.js} +6 -6
- package/dist/DocumentVersionUnsupportedModal-DH9Zzsyw.js.map +1 -0
- package/dist/{DownloadDocumentWithErrorsModal-IKl0ljQb.js → DownloadDocumentWithErrorsModal-Beh-xw8B.js} +8 -7
- package/dist/DownloadDocumentWithErrorsModal-Beh-xw8B.js.map +1 -0
- package/dist/{DriveAuthRequiredModal-DVK7ZQzO.js → DriveAuthRequiredModal-XTcoJKvj.js} +7 -7
- package/dist/DriveAuthRequiredModal-XTcoJKvj.js.map +1 -0
- package/dist/{DriveSettingsModal-C6-mRQiv.js → DriveSettingsModal-DZKawN7w.js} +6 -6
- package/dist/DriveSettingsModal-DZKawN7w.js.map +1 -0
- package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js +2565 -0
- package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js.map +1 -0
- package/dist/{InspectorModal-C-dm0iSW.js → InspectorModal-BVqRNFfP.js} +70 -30
- package/dist/InspectorModal-BVqRNFfP.js.map +1 -0
- package/dist/{LoginModal-CybbOm3N.js → LoginModal-O06ZvWFI.js} +8 -8
- package/dist/LoginModal-O06ZvWFI.js.map +1 -0
- package/dist/{OpenFileDocumentsModal-DEcFBZ5I.js → OpenFileDocumentsModal-BNHD0vg9.js} +16 -14
- package/dist/OpenFileDocumentsModal-BNHD0vg9.js.map +1 -0
- package/dist/{UpgradeDriveModal-_8t9slxQ.js → UpgradeDriveModal-CCWKp5yn.js} +7 -7
- package/dist/UpgradeDriveModal-CCWKp5yn.js.map +1 -0
- package/dist/app-loader-BjAXSJQ6.js +4 -0
- package/dist/app-loader-DtH6v5CE.js +1244 -0
- package/dist/app-loader-DtH6v5CE.js.map +1 -0
- package/dist/app-skeleton-BFjvlTWd.js +112 -0
- package/dist/app-skeleton-BFjvlTWd.js.map +1 -0
- package/dist/app-skeleton-DFg65Rxa.js +4 -0
- package/dist/boot-N7f3RrY_.js +233 -0
- package/dist/boot-N7f3RrY_.js.map +1 -0
- package/dist/buffer-DNTcuap_.js +66 -0
- package/dist/buffer-DNTcuap_.js.map +1 -0
- package/dist/{build-info-N6D-34wu.js → build-info-TgBEqTq1.js} +10 -6
- package/dist/build-info-TgBEqTq1.js.map +1 -0
- package/dist/components-B_wpF5Is.js +121 -0
- package/dist/components-B_wpF5Is.js.map +1 -0
- package/dist/{connect.config-DaHDEUrw.js → connect.config-D1pGNmaF.js} +25 -13
- package/dist/connect.config-D1pGNmaF.js.map +1 -0
- package/dist/{connection-state-3w4liC1X.js → connection-state-B6fleM37.js} +20 -9
- package/dist/connection-state-B6fleM37.js.map +1 -0
- package/dist/context-De2EB1AA-Ni0d829Q.js +1759 -0
- package/dist/context-De2EB1AA-Ni0d829Q.js.map +1 -0
- package/dist/{cookie-banner-BH6bIq24.js → cookie-banner-CAvd3PC3.js} +7 -7
- package/dist/{cookie-banner-BH6bIq24.js.map → cookie-banner-CAvd3PC3.js.map} +1 -1
- package/dist/document-editor-container-CGLXOl0t.js +4 -0
- package/dist/document-editor-container-FNIEsf8H.js +310 -0
- package/dist/document-editor-container-FNIEsf8H.js.map +1 -0
- package/dist/drive-icon-BiVP8yJc.js +38 -0
- package/dist/drive-icon-BiVP8yJc.js.map +1 -0
- package/dist/error-boundary-BsUBww61.js +155 -0
- package/dist/error-boundary-BsUBww61.js.map +1 -0
- package/dist/esm-BDACZntJ.js +148 -0
- package/dist/esm-BDACZntJ.js.map +1 -0
- package/dist/generic.d.ts +116 -0
- package/dist/generic.d.ts.map +1 -0
- package/dist/generic.js +31 -0
- package/dist/generic.js.map +1 -0
- package/dist/{i18n-CWO0vYVd.js → i18n-D9WYPgk9.js} +4 -4
- package/dist/{i18n-CWO0vYVd.js.map → i18n-D9WYPgk9.js.map} +1 -1
- package/dist/index-NyJPEHvw.d.ts +4 -0
- package/dist/layout-wfvkfP4J.js +5 -0
- package/dist/layout.d.ts +3 -0
- package/dist/layout.js +4 -0
- package/dist/{load-BxUCaDLH.js → load-CkbGF6wB.js} +48 -46
- package/dist/load-CkbGF6wB.js.map +1 -0
- package/dist/load-runtime-config-DXswYA71.js +14 -0
- package/dist/load-runtime-config-DXswYA71.js.map +1 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +8 -8
- package/dist/main.js.map +1 -1
- package/dist/open-file-uploads-B5pr1sA2.js +183 -0
- package/dist/open-file-uploads-B5pr1sA2.js.map +1 -0
- package/dist/package-manager-CPqbVSd8.js +524 -0
- package/dist/package-manager-CPqbVSd8.js.map +1 -0
- package/dist/{pglite-major-B39aOEiE.js → pglite-major-p4_YefAE.js} +23 -5
- package/dist/pglite-major-p4_YefAE.js.map +1 -0
- package/dist/{pglite-migrate-core-Boxqqx-c.js → pglite-migrate-core-DBlU6HIc.js} +9 -7
- package/dist/pglite-migrate-core-DBlU6HIc.js.map +1 -0
- package/dist/{pglite-seed-BqAUvNFw.js → pglite-seed-eGzXMld2.js} +4 -4
- package/dist/{pglite-seed-BqAUvNFw.js.map → pglite-seed-eGzXMld2.js.map} +1 -1
- package/dist/pglite.worker.d.ts +2 -1
- package/dist/pglite.worker.js +4 -3
- package/dist/pglite.worker.js.map +1 -1
- package/dist/pglite.worker.legacy.d.ts +2 -1
- package/dist/pglite.worker.legacy.js +4 -3
- package/dist/pglite.worker.legacy.js.map +1 -1
- package/dist/plugins-CWbr0n_Q.js +246 -0
- package/dist/plugins-CWbr0n_Q.js.map +1 -0
- package/dist/{preferences-store-_5Cw4_YV.js → preferences-store-CSqauT9V.js} +6 -25
- package/dist/preferences-store-CSqauT9V.js.map +1 -0
- package/dist/prerender.d.ts +38 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +177 -0
- package/dist/prerender.js.map +1 -0
- package/dist/prerendered-shell-peKE7AqI.js +51 -0
- package/dist/prerendered-shell-peKE7AqI.js.map +1 -0
- package/dist/{pwa-manifest-link-DIgOSo2Q.js → pwa-manifest-link-DQRJpF0r.js} +3 -3
- package/dist/{pwa-manifest-link-DIgOSo2Q.js.map → pwa-manifest-link-DQRJpF0r.js.map} +1 -1
- package/dist/{reactor-Bg0Y9sdl.js → reactor-DLCl-WHi.js} +509 -562
- package/dist/reactor-DLCl-WHi.js.map +1 -0
- package/dist/reactor-chat-LAB-9G3G.js +50 -0
- package/dist/reactor-chat-LAB-9G3G.js.map +1 -0
- package/dist/reactor.worker.d.ts +2 -1
- package/dist/reactor.worker.js +478 -156
- package/dist/reactor.worker.js.map +1 -1
- package/dist/{registerServiceWorker-BSzbNfvz.js → registerServiceWorker-APlHkrmH.js} +5 -5
- package/dist/{registerServiceWorker-BSzbNfvz.js.map → registerServiceWorker-APlHkrmH.js.map} +1 -1
- package/dist/root-B1Pq9x6S.js +24 -0
- package/dist/root-B1Pq9x6S.js.map +1 -0
- package/dist/route-tree.d.ts +2220 -0
- package/dist/route-tree.d.ts.map +1 -0
- package/dist/route-tree.js +135 -0
- package/dist/route-tree.js.map +1 -0
- package/dist/route-views-BF0p-4Fi.js +60 -0
- package/dist/route-views-BF0p-4Fi.js.map +1 -0
- package/dist/route-views-CTARvT5N.js +55 -0
- package/dist/route-views-CTARvT5N.js.map +1 -0
- package/dist/route-views-D8I-1PWU.js +4 -0
- package/dist/route-views.d.ts +7 -0
- package/dist/route-views.d.ts.map +1 -0
- package/dist/route-views.js +4 -0
- package/dist/router-BguOMBUh.js +4 -0
- package/dist/router-L9X9U-97.js +46 -0
- package/dist/router-L9X9U-97.js.map +1 -0
- package/dist/router.d.ts +2 -0
- package/dist/router.js +3 -0
- package/dist/sentry-Cuc_Nbba.js +22 -0
- package/dist/sentry-Cuc_Nbba.js.map +1 -0
- package/dist/settings-B-apZN_f.js +1084 -0
- package/dist/settings-B-apZN_f.js.map +1 -0
- package/dist/settings-tabs-CRgiuZcb.js +385 -0
- package/dist/settings-tabs-CRgiuZcb.js.map +1 -0
- package/dist/shell-core-head.html +2 -0
- package/dist/shell-core.html +1 -0
- package/dist/shell-head.html +2 -0
- package/dist/shell-plugins.json +1 -0
- package/dist/shell.html +1 -0
- package/dist/start-connect.d.ts +7 -9
- package/dist/start-connect.d.ts.map +1 -1
- package/dist/start-connect.js +9 -8
- package/dist/start-connect.js.map +1 -1
- package/dist/store-lock-Bi3B9VJD.js +159 -0
- package/dist/store-lock-Bi3B9VJD.js.map +1 -0
- package/dist/style.css +3131 -774
- package/dist/{toast-BXIGd4Eb.js → toast-C6WW-_O-.js} +3 -3
- package/dist/{toast-BXIGd4Eb.js.map → toast-C6WW-_O-.js.map} +1 -1
- package/dist/ui-CwbE23ra.js +66 -0
- package/dist/ui-CwbE23ra.js.map +1 -0
- package/dist/{use-renown-login-Cf3va6u_.js → use-renown-login-dPpDOYq5.js} +4 -4
- package/dist/use-renown-login-dPpDOYq5.js.map +1 -0
- package/docs/customizing/data-and-navigation.md +232 -0
- package/docs/customizing/hosts-and-plugins.md +65 -0
- package/docs/customizing/layout.md +149 -0
- package/docs/customizing/modals.md +78 -0
- package/docs/customizing/overrides.md +113 -0
- package/docs/customizing/packages.md +39 -0
- package/docs/customizing/pages.md +136 -0
- package/docs/customizing/styles-and-branding.md +69 -0
- package/docs/customizing/types-and-troubleshooting.md +63 -0
- package/fonts.css +177 -0
- package/package.json +81 -25
- package/scripts/prerender-shell.ts +51 -0
- package/skills/customize-connect/SKILL.md +74 -0
- package/src/route-tree.ts +3 -0
- package/src/routeTree.gen.ts +235 -0
- package/src/router/index.ts +2 -0
- package/src/router/register.ts +9 -0
- package/src/routes/__root.tsx +12 -0
- package/src/routes/_app/$.tsx +13 -0
- package/src/routes/_app/d/$driveSlug/{-$nodeSlug}.tsx +13 -0
- package/src/routes/_app/d/$driveSlug.tsx +13 -0
- package/src/routes/_app/index.tsx +13 -0
- package/src/routes/_app/settings/appearance.tsx +13 -0
- package/src/routes/_app/settings/packages.tsx +13 -0
- package/src/routes/_app/settings.tsx +13 -0
- package/src/routes/_app.tsx +13 -0
- package/style.css +8 -23
- package/tailwind.css +12 -0
- package/theme.css +5 -0
- package/dist/AddDriveModal-xAw48kdl.js.map +0 -1
- package/dist/ClearStorageModal-Czo-h6OE.js.map +0 -1
- package/dist/ConfirmDocumentUpgradeModal-FUOhZsk7.js.map +0 -1
- package/dist/CreateDocumentModal-C45W8J0V.js.map +0 -1
- package/dist/DebugSettingsModal-BUkre5Ke.js.map +0 -1
- package/dist/DeleteDriveModal-Dug84t1j.js.map +0 -1
- package/dist/DeleteItemModal-mMzy3V8o.js.map +0 -1
- package/dist/DisclaimerModal-DvpD5dPM.js.map +0 -1
- package/dist/DocumentVersionUnsupportedModal-C3Q0V75l.js.map +0 -1
- package/dist/DownloadDocumentWithErrorsModal-IKl0ljQb.js.map +0 -1
- package/dist/DriveAuthRequiredModal-DVK7ZQzO.js.map +0 -1
- package/dist/DriveSettingsModal-C6-mRQiv.js.map +0 -1
- package/dist/InspectorModal-C-dm0iSW.js.map +0 -1
- package/dist/LoginModal-CybbOm3N.js.map +0 -1
- package/dist/MissingPackageModal-nBnExqO0.js +0 -49
- package/dist/MissingPackageModal-nBnExqO0.js.map +0 -1
- package/dist/OpenFileDocumentsModal-DEcFBZ5I.js.map +0 -1
- package/dist/SettingsModal-CRBkw7d0.js +0 -569
- package/dist/SettingsModal-CRBkw7d0.js.map +0 -1
- package/dist/UpgradeDriveModal-_8t9slxQ.js.map +0 -1
- package/dist/app-loader-DkQhle_a.js +0 -4
- package/dist/app-loader-lsCT8EWA.js +0 -2244
- package/dist/app-loader-lsCT8EWA.js.map +0 -1
- package/dist/build-info-N6D-34wu.js.map +0 -1
- package/dist/components-DHzkxxly.js +0 -4
- package/dist/connect.config-DaHDEUrw.js.map +0 -1
- package/dist/connection-state-3w4liC1X.js.map +0 -1
- package/dist/load-BxUCaDLH.js.map +0 -1
- package/dist/pglite-major-B39aOEiE.js.map +0 -1
- package/dist/pglite-migrate-core-Boxqqx-c.js.map +0 -1
- package/dist/preferences-store-_5Cw4_YV.js.map +0 -1
- package/dist/reactor-Bg0Y9sdl.js.map +0 -1
- package/dist/runtime-config-DL3QjcfM.js +0 -24
- package/dist/runtime-config-DL3QjcfM.js.map +0 -1
- package/dist/sentry-QXKgQmr2.js +0 -15
- package/dist/sentry-QXKgQmr2.js.map +0 -1
- package/dist/use-renown-login-Cf3va6u_.js.map +0 -1
- package/dist/useRegistryPackages-BnUcL_nZ.js +0 -390
- package/dist/useRegistryPackages-BnUcL_nZ.js.map +0 -1
|
@@ -1,110 +1,104 @@
|
|
|
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]="
|
|
3
|
-
import { n as
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { a as
|
|
9
|
-
import { r as
|
|
10
|
-
import {
|
|
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]="2c212d19-c60e-51df-85b4-428dfc7292c8")}catch(e){}}();
|
|
3
|
+
import { n as buildPHGlobalConfig, o as phGlobalConfig, r as connectConfig } from "./connect.config-D1pGNmaF.js";
|
|
4
|
+
import { a as isPackagedConnectDist, i as getVersion, n as getGitSha } from "./build-info-TgBEqTq1.js";
|
|
5
|
+
import { r as getSharedDeps, t as BrowserPackageManager } from "./package-manager-CPqbVSd8.js";
|
|
6
|
+
import { r as toast } from "./toast-C6WW-_O-.js";
|
|
7
|
+
import { a as closeWithin, n as watchStoreLockWait, o as configureConnectChannelScheme, s as createConnectSignerConfig } from "./store-lock-Bi3B9VJD.js";
|
|
8
|
+
import { a as resolvePgMajorForRuntime, f as toStoredDocumentsRefused, r as loadPGliteModule } from "./pglite-major-p4_YefAE.js";
|
|
9
|
+
import { g as RELATIONAL_PGLITE_NAME, h as REACTOR_PGLITE_NAME, m as REACTOR_INSTANCE_NAMESPACE, n as getWorkerConnectionStatus, o as detectReactorPgMajor, r as setWorkerConnectionStatus, s as detectRelationalPgMajor, t as clearStorageHeld } from "./connection-state-B6fleM37.js";
|
|
10
|
+
import { holdConnectRoutes } from "@powerhousedao/connect-core/router";
|
|
11
|
+
import { BrowserLocalStorage, DRIVE_DOCUMENT_TYPES, DocumentCache, DocumentChangeType, ReactorBuilder, ReactorClientBuilder, RegistryClient, addDrive, addPHEventHandlers, addRemoteDrive, createAnalyticsStore, getFullReactorClient, getPHStore, isDriveAuthError, login, refreshReactorDataClient, setAttachmentService, setDefaultPHGlobalConfig, setDocumentCache, setDriveMetadata, setDrives, setFeatures, setPGliteDB, setPHToast, setPackageDiscoveryService, setReactorClient, setReactorClientModule, setRenown, setSelectedDrive, setSelectedNode, setVetraPackageManager, trackDriveArrival, untilDriveListed, waitForDocumentReady } from "@powerhousedao/reactor-browser";
|
|
12
|
+
import { ConsoleLogger, logger, setLogLevel as setLogLevel$1 } from "document-model";
|
|
13
|
+
import { getConnectPluginUi } from "@powerhousedao/connect-core/plugins";
|
|
11
14
|
import { createRelationalDb } from "@powerhousedao/shared/processors";
|
|
12
|
-
import { DocumentModelRegistry, DocumentModelResolver, ReactorEventTypes, createReactorHostModuleBase } from "@powerhousedao/reactor";
|
|
13
|
-
import { MessageRouter, RPC_PROTOCOL_VERSION, SyncManagerProxy, connectReactorClient, createInspectorProxy, createPortTransport, createReactorEventBusProxy, createRelationalPgliteProxy, createWorkerAdminClient, postReactorIdentity } from "@powerhousedao/reactor-browser/rpc";
|
|
15
|
+
import { DocumentModelRegistry, DocumentModelResolver, HardenedPGliteDialect, LocalChannelFactory, LocalChannelPortRegistry, PGLITE_IDB_STORAGE_FACTS, ReactorEventTypes, createReactorHostModuleBase } from "@powerhousedao/reactor";
|
|
16
|
+
import { MessageRouter, RPC_PROTOCOL_VERSION, SyncManagerProxy, connectReactorClient, createInspectorProxy, createPortTransport, createReactorEventBusProxy, createRelationalPgliteProxy, createWorkerAdminClient, isFingerprintMismatchReload, postReactorIdentity } from "@powerhousedao/reactor-browser/rpc";
|
|
14
17
|
import { Kysely } from "kysely";
|
|
15
|
-
import {
|
|
16
|
-
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
|
-
import { ConsoleLogger, logger, setLogLevel as setLogLevel$1 } from "document-model";
|
|
18
|
-
import { BrowserKeyStorage, RenownBuilder, RenownCryptoBuilder, createSignatureVerifier } from "@renown/sdk";
|
|
19
|
-
import { PwaConfigSchema } from "@powerhousedao/shared/document-model";
|
|
18
|
+
import { createAppReactorClient, getAppDrives, getRuntimeConfig, planReactorClient, refreshAppDrives } from "@powerhousedao/connect-core/runtime";
|
|
20
19
|
import { createAttachmentClient, createRemoteAttachmentService, createXhrUploadTransport } from "@powerhousedao/reactor-attachments/client";
|
|
20
|
+
import { BrowserKeyStorage, RenownBuilder, RenownCryptoBuilder } from "@renown/sdk";
|
|
21
21
|
import { OpenFeature } from "@openfeature/web-sdk";
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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();
|
|
22
|
+
//#region src/utils/poisoned-store-budget.ts
|
|
23
|
+
const BUDGET_LIMIT = 2;
|
|
24
|
+
const POISONED_STORE = {
|
|
25
|
+
key: "ph-connect:poisoned-store-reloads",
|
|
26
|
+
quietMs: 6e5
|
|
27
|
+
};
|
|
28
|
+
const MISMATCH = {
|
|
29
|
+
key: "ph-connect:mismatch-reloads",
|
|
30
|
+
quietMs: 6e4
|
|
31
|
+
};
|
|
32
|
+
function sessionStore() {
|
|
44
33
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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();
|
|
34
|
+
return globalThis.sessionStorage;
|
|
35
|
+
} catch {
|
|
36
|
+
return;
|
|
57
37
|
}
|
|
58
38
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
function readRecord(raw) {
|
|
40
|
+
const record = raw ? JSON.parse(raw) : null;
|
|
41
|
+
return typeof record?.count === "number" && typeof record.lastAt === "number" ? {
|
|
42
|
+
count: record.count,
|
|
43
|
+
lastAt: record.lastAt
|
|
44
|
+
} : {
|
|
45
|
+
count: 0,
|
|
46
|
+
lastAt: 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function claimReload(budget, storage, now) {
|
|
50
|
+
if (storage === void 0) return false;
|
|
65
51
|
try {
|
|
66
|
-
const
|
|
67
|
-
|
|
52
|
+
const previous = readRecord(storage.getItem(budget.key));
|
|
53
|
+
const count = now - previous.lastAt >= budget.quietMs ? 0 : previous.count;
|
|
54
|
+
const allowed = count < BUDGET_LIMIT;
|
|
55
|
+
storage.setItem(budget.key, JSON.stringify({
|
|
56
|
+
count: allowed ? count + 1 : count,
|
|
57
|
+
lastAt: now
|
|
58
|
+
}));
|
|
59
|
+
return allowed;
|
|
68
60
|
} catch {
|
|
69
|
-
return
|
|
61
|
+
return false;
|
|
70
62
|
}
|
|
71
63
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
/** One page reload answers every budgeted reload the page hears, of either budget. */
|
|
65
|
+
let reloadRequested = false;
|
|
66
|
+
function reloadWithinBudget(budget, reload, pastBudget, storage = sessionStore(), now = Date.now()) {
|
|
67
|
+
if (reloadRequested) return;
|
|
68
|
+
if (claimReload(budget, storage, now)) {
|
|
69
|
+
reloadRequested = true;
|
|
70
|
+
reload();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
setWorkerConnectionStatus(pastBudget);
|
|
77
74
|
}
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}))
|
|
98
|
-
}
|
|
99
|
-
};
|
|
75
|
+
/** Past the budget a poisoned store stops reloading and shows storage-unusable, so clear storage stays reachable. */
|
|
76
|
+
function reloadForPoisonedStore(reload, storage, now) {
|
|
77
|
+
reloadWithinBudget(POISONED_STORE, reload, "storage-unusable", storage, now);
|
|
78
|
+
}
|
|
79
|
+
/** onPoisoned for an in-tab store: the page reload reopens it, within the poisoned-store budget. */
|
|
80
|
+
function reloadPageForPoisonedStore(cause, reload = () => window.location.reload()) {
|
|
81
|
+
console.error("[connect] PGlite session poisoned:", cause);
|
|
82
|
+
reloadForPoisonedStore(reload);
|
|
83
|
+
}
|
|
84
|
+
function reloadForWorker(reason, reload, storage, now) {
|
|
85
|
+
if (reason === "storage session poisoned") {
|
|
86
|
+
reloadForPoisonedStore(reload, storage, now);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (isFingerprintMismatchReload(reason)) {
|
|
90
|
+
reloadWithinBudget(MISMATCH, reload, "version-conflict", storage, now);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
reload();
|
|
100
94
|
}
|
|
101
95
|
//#endregion
|
|
102
96
|
//#region src/pglite.db.ts
|
|
103
|
-
async function createMainThreadPGlite(major, dbName) {
|
|
97
|
+
async function createMainThreadPGlite(major, dbName, relaxedDurability) {
|
|
104
98
|
const { PGlite } = await loadPGliteModule(major);
|
|
105
99
|
const { live } = major === 16 ? await import("pglite-legacy-02/live") : await import("@electric-sql/pglite/live");
|
|
106
100
|
return new PGlite(`idb://${dbName}`, {
|
|
107
|
-
relaxedDurability
|
|
101
|
+
relaxedDurability,
|
|
108
102
|
extensions: { live }
|
|
109
103
|
});
|
|
110
104
|
}
|
|
@@ -114,37 +108,72 @@ function chainedCreate(create) {
|
|
|
114
108
|
bootChain = pending.catch(() => void 0);
|
|
115
109
|
return pending;
|
|
116
110
|
}
|
|
111
|
+
const CLOSE_TIMEOUT_MS = 3e4;
|
|
117
112
|
function pgliteSingleton(opts) {
|
|
118
113
|
let cached;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
114
|
+
let unusable;
|
|
115
|
+
return {
|
|
116
|
+
get() {
|
|
117
|
+
if (cached) return cached;
|
|
118
|
+
const pending = chainedCreate(async () => {
|
|
119
|
+
if (unusable) throw unusable;
|
|
120
|
+
const major = resolvePgMajorForRuntime(await opts.detectMajor());
|
|
121
|
+
if (major !== 17) console.warn(`[${opts.label}] Opening legacy Postgres ${major} data dir. Migrate to PG17 from the banner or the Inspector → Debug tab.`);
|
|
122
|
+
return createMainThreadPGlite(major, opts.dbName, opts.relaxedDurability);
|
|
123
|
+
});
|
|
124
|
+
cached = pending;
|
|
125
|
+
pending.catch(() => {
|
|
126
|
+
if (cached === pending) cached = void 0;
|
|
127
|
+
});
|
|
128
|
+
return pending;
|
|
129
|
+
},
|
|
130
|
+
async discard() {
|
|
131
|
+
const pending = cached;
|
|
132
|
+
if (!pending) return;
|
|
133
|
+
cached = void 0;
|
|
134
|
+
const closing = bootChain.then(async () => {
|
|
135
|
+
const pg = await pending;
|
|
136
|
+
let timer;
|
|
137
|
+
try {
|
|
138
|
+
await Promise.race([pg.close(), new Promise((resolve) => {
|
|
139
|
+
timer = setTimeout(() => {
|
|
140
|
+
unusable = /* @__PURE__ */ new Error(`[${opts.label}] PGlite did not close within ${CLOSE_TIMEOUT_MS}ms; reload the page to reopen its store`);
|
|
141
|
+
console.warn(unusable.message);
|
|
142
|
+
resolve();
|
|
143
|
+
}, CLOSE_TIMEOUT_MS);
|
|
144
|
+
})]);
|
|
145
|
+
} finally {
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
bootChain = closing.catch(() => void 0);
|
|
150
|
+
try {
|
|
151
|
+
await closing;
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error(`[${opts.label}] closing PGlite failed:`, error);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
131
156
|
};
|
|
132
157
|
}
|
|
133
|
-
const
|
|
158
|
+
const reactorPGlite = pgliteSingleton({
|
|
134
159
|
dbName: REACTOR_PGLITE_NAME,
|
|
135
160
|
detectMajor: detectReactorPgMajor,
|
|
136
|
-
label: "reactor"
|
|
161
|
+
label: "reactor",
|
|
162
|
+
relaxedDurability: false
|
|
137
163
|
});
|
|
164
|
+
const getReactorPGlite = reactorPGlite.get;
|
|
165
|
+
const discardReactorPGlite = reactorPGlite.discard;
|
|
138
166
|
const getRelationalPGlite = pgliteSingleton({
|
|
139
167
|
dbName: RELATIONAL_PGLITE_NAME,
|
|
140
168
|
detectMajor: detectRelationalPgMajor,
|
|
141
|
-
label: "relational"
|
|
142
|
-
|
|
169
|
+
label: "relational",
|
|
170
|
+
relaxedDurability: true
|
|
171
|
+
}).get;
|
|
143
172
|
async function getDb() {
|
|
144
173
|
const pgLite = await getRelationalPGlite();
|
|
145
174
|
return {
|
|
146
175
|
pgLite,
|
|
147
|
-
relationalDb: createRelationalDb(new Kysely({ dialect: new
|
|
176
|
+
relationalDb: createRelationalDb(new Kysely({ dialect: new HardenedPGliteDialect(pgLite, { onPoisoned: reloadPageForPoisonedStore }) }))
|
|
148
177
|
};
|
|
149
178
|
}
|
|
150
179
|
//#endregion
|
|
@@ -153,20 +182,34 @@ async function getDb() {
|
|
|
153
182
|
* Creates a Reactor that plugs into legacy storage but syncs through the new
|
|
154
183
|
* Reactor GQL API.
|
|
155
184
|
*/
|
|
156
|
-
async function createBrowserReactor(documentModelModules, upgradeManifests, renown, featureFlags, documentModelLoader) {
|
|
157
|
-
const signerConfig =
|
|
158
|
-
signer: renown.signer,
|
|
159
|
-
verifier: createSignatureVerifier()
|
|
160
|
-
};
|
|
185
|
+
async function createBrowserReactor(documentModelModules, upgradeManifests, renown, featureFlags, documentModelLoader, createSignaturePolicy, renownEndpoints = {}, unsupportedStoredDocuments, multiReactor = false) {
|
|
186
|
+
const signerConfig = await createConnectSignerConfig(renown.signer, featureFlags, renownEndpoints);
|
|
161
187
|
const jwtHandler = async (_url) => {
|
|
162
188
|
if (!renown.user) return;
|
|
163
189
|
return renown.getBearerToken({ expiresIn: 10 });
|
|
164
190
|
};
|
|
165
191
|
const pg = await getReactorPGlite();
|
|
166
192
|
const logger = new ConsoleLogger(["reactor-client"]);
|
|
167
|
-
const
|
|
193
|
+
const reactorBuilder = new ReactorBuilder().withDocumentModelSources(documentModelModules).withUpgradeManifests(upgradeManifests).withExecutorConfig({ featureFlags }).withJwtHandler(jwtHandler).withGroupCommitPGlite({
|
|
194
|
+
pg,
|
|
195
|
+
onUnrecoverable: reloadPageForPoisonedStore,
|
|
196
|
+
onDiagnostic: (message, error) => console.error(`[reactor] pglite: ${message}`, error)
|
|
197
|
+
}).withStorageFacts(PGLITE_IDB_STORAGE_FACTS);
|
|
198
|
+
configureConnectChannelScheme(reactorBuilder, {
|
|
199
|
+
multiReactor,
|
|
200
|
+
createLocalChannelFactory: () => new LocalChannelFactory(logger, new LocalChannelPortRegistry({ logger }).provider)
|
|
201
|
+
});
|
|
202
|
+
const builder = new ReactorClientBuilder().withLogger(logger).withSigner(signerConfig).withReactorBuilder(reactorBuilder);
|
|
168
203
|
if (documentModelLoader) builder.withDocumentModelLoader(documentModelLoader);
|
|
169
|
-
|
|
204
|
+
if (createSignaturePolicy) builder.withCreateSignaturePolicy(createSignaturePolicy);
|
|
205
|
+
if (unsupportedStoredDocuments) reactorBuilder.withUnsupportedStoredDocuments(unsupportedStoredDocuments);
|
|
206
|
+
let module;
|
|
207
|
+
try {
|
|
208
|
+
module = await builder.buildModule();
|
|
209
|
+
} catch (error) {
|
|
210
|
+
await discardReactorPGlite();
|
|
211
|
+
throw toStoredDocumentsRefused(error);
|
|
212
|
+
}
|
|
170
213
|
return {
|
|
171
214
|
...module,
|
|
172
215
|
kind: "browser",
|
|
@@ -212,8 +255,10 @@ async function addRemoteDefaultDrive(drive) {
|
|
|
212
255
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
213
256
|
}
|
|
214
257
|
}
|
|
258
|
+
const store = getPHStore();
|
|
259
|
+
if (driveId && store) await untilDriveListed(store, driveId);
|
|
215
260
|
if (driveId && (drive.name || drive.icon)) try {
|
|
216
|
-
const reactorClient =
|
|
261
|
+
const reactorClient = getFullReactorClient();
|
|
217
262
|
if (reactorClient) await waitForDocumentReady(reactorClient, driveId, { timeoutMs: 15e3 });
|
|
218
263
|
await setDriveMetadata(driveId, {
|
|
219
264
|
name: drive.name,
|
|
@@ -237,7 +282,7 @@ async function addLocalDefaultDrive(drive) {
|
|
|
237
282
|
return;
|
|
238
283
|
}
|
|
239
284
|
try {
|
|
240
|
-
const reactorClient =
|
|
285
|
+
const reactorClient = getFullReactorClient();
|
|
241
286
|
if (reactorClient) {
|
|
242
287
|
if (await reactorClient.isDocumentIdTaken(drive.id)) return;
|
|
243
288
|
}
|
|
@@ -683,341 +728,33 @@ var PackageDiscoveryService = class {
|
|
|
683
728
|
}
|
|
684
729
|
};
|
|
685
730
|
//#endregion
|
|
686
|
-
//#region src/
|
|
687
|
-
|
|
688
|
-
|
|
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) {
|
|
731
|
+
//#region src/reactor-worker-name.ts
|
|
732
|
+
const GEN_KEY_PREFIX = "ph-reactor-gen:";
|
|
733
|
+
function genStore() {
|
|
697
734
|
try {
|
|
698
|
-
|
|
699
|
-
if (!res.ok) return void 0;
|
|
700
|
-
const pkg = await res.json();
|
|
701
|
-
return typeof pkg.version === "string" ? pkg.version : void 0;
|
|
735
|
+
return globalThis.localStorage;
|
|
702
736
|
} catch {
|
|
703
737
|
return;
|
|
704
738
|
}
|
|
705
739
|
}
|
|
706
|
-
|
|
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
|
-
//#region src/reactor-worker-name.ts
|
|
1006
|
-
const GEN_KEY_PREFIX = "ph-reactor-gen:";
|
|
1007
|
-
function reactorWorkerName(namespace) {
|
|
1008
|
-
const gen = readWorkerGen(namespace);
|
|
740
|
+
function workerNameForGen(namespace, gen) {
|
|
1009
741
|
return gen ? `ph-reactor:${namespace}#${gen}` : `ph-reactor:${namespace}`;
|
|
1010
742
|
}
|
|
1011
|
-
function readWorkerGen(namespace) {
|
|
743
|
+
function readWorkerGen(namespace, storage = genStore()) {
|
|
1012
744
|
try {
|
|
1013
|
-
return
|
|
745
|
+
return storage?.getItem(GEN_KEY_PREFIX + namespace) ?? null;
|
|
1014
746
|
} catch {
|
|
1015
747
|
return null;
|
|
1016
748
|
}
|
|
1017
749
|
}
|
|
1018
|
-
|
|
750
|
+
/**
|
|
751
|
+
* Gens are unordered tokens, so a reload moves the gen on only from the one
|
|
752
|
+
* this tab's worker runs as; a stale worker's reload never undoes a newer one.
|
|
753
|
+
*/
|
|
754
|
+
function adoptWorkerGen(namespace, from, to, storage = genStore()) {
|
|
1019
755
|
try {
|
|
1020
|
-
|
|
756
|
+
if (storage?.getItem(GEN_KEY_PREFIX + namespace) !== from) return;
|
|
757
|
+
storage.setItem(GEN_KEY_PREFIX + namespace, to);
|
|
1021
758
|
} catch {}
|
|
1022
759
|
}
|
|
1023
760
|
//#endregion
|
|
@@ -1026,8 +763,44 @@ const PING_INTERVAL_MS = 2e3;
|
|
|
1026
763
|
const PING_DEADLINE_MS = 3e3;
|
|
1027
764
|
const MAX_MISSED_PINGS = 2;
|
|
1028
765
|
/** Sorted so the same set always produces the same fingerprint. */
|
|
1029
|
-
function enabledFlagList(flags) {
|
|
1030
|
-
return Object.entries(
|
|
766
|
+
function enabledFlagList(flags, multiReactor) {
|
|
767
|
+
return Object.entries({
|
|
768
|
+
...flags,
|
|
769
|
+
multiReactor
|
|
770
|
+
}).filter(([, enabled]) => enabled).map(([name]) => name).sort().join(",");
|
|
771
|
+
}
|
|
772
|
+
/** The hello fingerprint; a running worker with a different one retires. */
|
|
773
|
+
function buildWorkerVersion(args) {
|
|
774
|
+
const gitSha = getGitSha();
|
|
775
|
+
const buildId = gitSha !== "unknown" ? gitSha : getVersion();
|
|
776
|
+
return {
|
|
777
|
+
appBuildId: args.workerDigest ? `${buildId}+w.${args.workerDigest}` : buildId,
|
|
778
|
+
rpcProtocolVersion: RPC_PROTOCOL_VERSION,
|
|
779
|
+
models: args.documentModelModules.map((m) => ({
|
|
780
|
+
id: m.documentModel.global.id,
|
|
781
|
+
version: m.version ?? 1
|
|
782
|
+
})),
|
|
783
|
+
featureFlags: enabledFlagList(args.featureFlags, args.multiReactor)
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
/** What the worker's build reads; flags arrive here because it has no config. */
|
|
787
|
+
function buildWorkerConstruct(args) {
|
|
788
|
+
return {
|
|
789
|
+
namespace: args.namespace,
|
|
790
|
+
relationalNamespace: args.relationalNamespace,
|
|
791
|
+
cdnUrl: args.cdnUrl,
|
|
792
|
+
packageSpecs: args.packageSpecs,
|
|
793
|
+
sharedImports: args.sharedImports,
|
|
794
|
+
studioMode: args.studioMode,
|
|
795
|
+
workflowsEnabled: args.workflowsEnabled,
|
|
796
|
+
renownChainId: args.renownChainId,
|
|
797
|
+
featureFlags: args.featureFlags,
|
|
798
|
+
multiReactor: args.multiReactor,
|
|
799
|
+
createSignaturePolicy: args.createSignaturePolicy,
|
|
800
|
+
unsupportedStoredDocuments: args.unsupportedStoredDocuments,
|
|
801
|
+
renownEndpoints: args.renownEndpoints,
|
|
802
|
+
packageSources: args.packageSources
|
|
803
|
+
};
|
|
1031
804
|
}
|
|
1032
805
|
function toReactorIdentity(user) {
|
|
1033
806
|
if (!user) return null;
|
|
@@ -1038,14 +811,17 @@ function toReactorIdentity(user) {
|
|
|
1038
811
|
};
|
|
1039
812
|
}
|
|
1040
813
|
function createWorkerReactorClientModule(args) {
|
|
1041
|
-
const workerUrl = new URL("./reactor.worker.js", import.meta.url);
|
|
1042
|
-
|
|
814
|
+
const workerUrl = args.workerUrl ? new URL(args.workerUrl) : new URL("./reactor.worker.js", import.meta.url);
|
|
815
|
+
const workerGen = readWorkerGen(args.namespace);
|
|
816
|
+
const workerName = workerNameForGen(args.namespace, workerGen);
|
|
817
|
+
console.info(`[reactor-worker] constructing SharedWorker ${workerName} from ${workerUrl.href}`);
|
|
1043
818
|
const worker = new SharedWorker(workerUrl, {
|
|
1044
|
-
name:
|
|
819
|
+
name: workerName,
|
|
1045
820
|
type: "module"
|
|
1046
821
|
});
|
|
1047
822
|
worker.addEventListener("error", (event) => {
|
|
1048
823
|
console.error(`[reactor-worker] SharedWorker failed to load from ${workerUrl.href}`, event.message || event);
|
|
824
|
+
setWorkerConnectionStatus("failed");
|
|
1049
825
|
});
|
|
1050
826
|
worker.port.onmessageerror = (event) => {
|
|
1051
827
|
console.error("[reactor-worker] port message could not be deserialized", event);
|
|
@@ -1056,28 +832,14 @@ function createWorkerReactorClientModule(args) {
|
|
|
1056
832
|
const documentModelRegistry = new DocumentModelRegistry();
|
|
1057
833
|
documentModelRegistry.registerModules(...args.documentModelModules);
|
|
1058
834
|
documentModelRegistry.registerUpgradeManifests(...args.upgradeManifests);
|
|
1059
|
-
const gitSha = getGitSha();
|
|
1060
835
|
const clientProxy = connectReactorClient(router, {
|
|
1061
|
-
version:
|
|
1062
|
-
|
|
1063
|
-
rpcProtocolVersion: RPC_PROTOCOL_VERSION,
|
|
1064
|
-
models: args.documentModelModules.map((m) => ({
|
|
1065
|
-
id: m.documentModel.global.id,
|
|
1066
|
-
version: m.version ?? 1
|
|
1067
|
-
})),
|
|
1068
|
-
featureFlags: enabledFlagList(args.featureFlags)
|
|
1069
|
-
},
|
|
1070
|
-
construct: {
|
|
1071
|
-
namespace: args.namespace,
|
|
1072
|
-
relationalNamespace: args.relationalNamespace,
|
|
1073
|
-
cdnUrl: args.cdnUrl,
|
|
1074
|
-
packageSpecs: args.packageSpecs,
|
|
1075
|
-
studioMode: args.studioMode,
|
|
1076
|
-
renownChainId: args.renownChainId,
|
|
1077
|
-
featureFlags: args.featureFlags
|
|
1078
|
-
},
|
|
836
|
+
version: buildWorkerVersion(args),
|
|
837
|
+
construct: buildWorkerConstruct(args),
|
|
1079
838
|
packages: args.packageSpecs
|
|
1080
|
-
},
|
|
839
|
+
}, (reason, nextGen) => {
|
|
840
|
+
if (nextGen) adoptWorkerGen(args.namespace, workerGen, nextGen);
|
|
841
|
+
args.onReload(reason);
|
|
842
|
+
}, documentModelRegistry);
|
|
1081
843
|
const busProxy = createReactorEventBusProxy(router);
|
|
1082
844
|
const syncManagerProxy = new SyncManagerProxy(router, busProxy);
|
|
1083
845
|
const modelResolver = new DocumentModelResolver(documentModelRegistry, args.documentModelLoader);
|
|
@@ -1099,6 +861,14 @@ function createWorkerReactorClientModule(args) {
|
|
|
1099
861
|
client: clientProxy,
|
|
1100
862
|
adminClient: createWorkerAdminClient(router),
|
|
1101
863
|
inspector: createInspectorProxy(router),
|
|
864
|
+
registerPackages: async (sources) => {
|
|
865
|
+
await router.request((id) => ({
|
|
866
|
+
k: "register-packages",
|
|
867
|
+
id,
|
|
868
|
+
specs: [],
|
|
869
|
+
sources
|
|
870
|
+
}));
|
|
871
|
+
},
|
|
1102
872
|
reactorModule: {
|
|
1103
873
|
documentModelRegistry,
|
|
1104
874
|
syncModule: { syncManager: syncManagerProxy },
|
|
@@ -1121,7 +891,7 @@ function createWorkerReactorClientModule(args) {
|
|
|
1121
891
|
const timer = setTimeout(() => {
|
|
1122
892
|
pingDeadlines.delete(id);
|
|
1123
893
|
missedPings += 1;
|
|
1124
|
-
if (missedPings >= MAX_MISSED_PINGS) setWorkerConnectionStatus("lost");
|
|
894
|
+
if (missedPings >= MAX_MISSED_PINGS && getWorkerConnectionStatus() !== "failed") setWorkerConnectionStatus("lost");
|
|
1125
895
|
}, PING_DEADLINE_MS);
|
|
1126
896
|
pingDeadlines.set(id, timer);
|
|
1127
897
|
router.post({
|
|
@@ -1141,33 +911,168 @@ function createWorkerReactorClientModule(args) {
|
|
|
1141
911
|
};
|
|
1142
912
|
}
|
|
1143
913
|
//#endregion
|
|
1144
|
-
//#region src/utils/
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
const
|
|
1149
|
-
if (
|
|
1150
|
-
const
|
|
1151
|
-
if (
|
|
1152
|
-
|
|
914
|
+
//#region src/utils/deleted-selection.ts
|
|
915
|
+
/** Closes the drive or document a Deleted event removed, saying why. */
|
|
916
|
+
function closeDeletedSelection(event, host) {
|
|
917
|
+
if (event.type !== DocumentChangeType.Deleted) return;
|
|
918
|
+
const deletedId = event.context?.childId;
|
|
919
|
+
if (!deletedId) return;
|
|
920
|
+
const gone = event.context?.purged ? "has been erased" : "has been deleted";
|
|
921
|
+
if (host.selectedDriveId && deletedId === host.selectedDriveId) {
|
|
922
|
+
host.closeDrive();
|
|
923
|
+
host.notify(`The drive you were viewing ${gone}`);
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
if (host.selectedNodeId && deletedId === host.selectedNodeId) {
|
|
927
|
+
host.closeNode();
|
|
928
|
+
host.notify(`The document you were editing ${gone}`);
|
|
929
|
+
}
|
|
1153
930
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
|
|
931
|
+
//#endregion
|
|
932
|
+
//#region src/utils/worker-startup.ts
|
|
933
|
+
/** Runs the worker's startup seed, showing storage-held while its stores are locked elsewhere. */
|
|
934
|
+
async function startupOwningStores(startup, namespaces, watchOptions) {
|
|
935
|
+
const stopWatching = watchStoreLockWait(namespaces, (waiting) => waiting ? setWorkerConnectionStatus("storage-held") : clearStorageHeld(), watchOptions);
|
|
936
|
+
try {
|
|
937
|
+
await startup({ isWaiting: () => getWorkerConnectionStatus() === "storage-held" });
|
|
938
|
+
clearStorageHeld();
|
|
939
|
+
} finally {
|
|
940
|
+
stopWatching();
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
//#endregion
|
|
944
|
+
//#region src/utils/reactor-worker-url.ts
|
|
945
|
+
/**
|
|
946
|
+
* Stable path of the prebuilt reactor SharedWorker bundle, relative to the
|
|
947
|
+
* deploy base. `ph connect build` emits it next to `__vendor__/`; the dev
|
|
948
|
+
* server serves it from the same path, building lazily on first request.
|
|
949
|
+
*/
|
|
950
|
+
const REACTOR_WORKER_BUNDLE_PATH = "__reactor_worker__/reactor.worker.js";
|
|
951
|
+
/** Written beside the bundle by the prebuild; carries its `sourceDigest`. */
|
|
952
|
+
const REACTOR_WORKER_META_PATH = "__reactor_worker__/worker-meta.json";
|
|
953
|
+
/** `path` under the deploy base, absolute against `origin`. */
|
|
954
|
+
function joinBase(baseUrl, path, origin) {
|
|
955
|
+
return new URL(`${baseUrl}/${path}`.replace(/\/{2,}/g, "/"), origin);
|
|
1165
956
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
957
|
+
/** The build's worker version, if it has one (dev serves unversioned URLs). */
|
|
958
|
+
function reactorWorkerVersion() {
|
|
959
|
+
return typeof PH_CONNECT_REACTOR_WORKER_VERSION !== "undefined" ? PH_CONNECT_REACTOR_WORKER_VERSION : void 0;
|
|
960
|
+
}
|
|
961
|
+
/** A `__reactor_worker__/` file's URL, versioned per build so no stale cache serves it. */
|
|
962
|
+
function workerFileUrl(baseUrl, path, origin, version = reactorWorkerVersion()) {
|
|
963
|
+
const url = joinBase(baseUrl, path, origin);
|
|
964
|
+
if (version) url.searchParams.set("v", version);
|
|
965
|
+
return url;
|
|
966
|
+
}
|
|
967
|
+
/** The bundle's URL under the deploy base, absolute against the page origin. */
|
|
968
|
+
function packagedReactorWorkerUrl(baseUrl, origin) {
|
|
969
|
+
return workerFileUrl(baseUrl, REACTOR_WORKER_BUNDLE_PATH, origin);
|
|
970
|
+
}
|
|
971
|
+
function isWorkerBundleResponse(probe) {
|
|
972
|
+
return probe.ok && (probe.contentType ?? "").includes("javascript");
|
|
973
|
+
}
|
|
974
|
+
/** Null when the deployment serves no bundle metadata (SPA HTML, error status, bad JSON). */
|
|
975
|
+
async function resolvePackagedReactorWorker(baseUrl) {
|
|
976
|
+
const origin = window.location.origin;
|
|
977
|
+
try {
|
|
978
|
+
const res = await fetch(workerFileUrl(baseUrl, REACTOR_WORKER_META_PATH, origin), { cache: "no-cache" });
|
|
979
|
+
if (!res.ok || !(res.headers.get("content-type") ?? "").includes("json")) return null;
|
|
980
|
+
const meta = await res.json();
|
|
981
|
+
if (typeof meta?.sourceDigest !== "string") return null;
|
|
982
|
+
return {
|
|
983
|
+
url: packagedReactorWorkerUrl(baseUrl, origin).href,
|
|
984
|
+
sourceDigest: meta.sourceDigest
|
|
985
|
+
};
|
|
986
|
+
} catch {
|
|
987
|
+
return null;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
function selectReactorWorkerSource({ packaged, bundle }) {
|
|
991
|
+
if (bundle) return {
|
|
992
|
+
kind: "bundle",
|
|
993
|
+
url: bundle.url,
|
|
994
|
+
digest: bundle.sourceDigest
|
|
995
|
+
};
|
|
996
|
+
return packaged ? { kind: "unavailable" } : { kind: "source" };
|
|
997
|
+
}
|
|
998
|
+
//#endregion
|
|
999
|
+
//#region src/utils/worker-package-sources.ts
|
|
1000
|
+
/**
|
|
1001
|
+
* Where `ph connect build` publishes the prebuilt local-package model bundles
|
|
1002
|
+
* and the manifest naming them, next to the worker bundle itself.
|
|
1003
|
+
*/
|
|
1004
|
+
const WORKER_PACKAGES_DIR = "__reactor_worker__/packages/";
|
|
1005
|
+
const WORKER_PACKAGES_MANIFEST = `${WORKER_PACKAGES_DIR}manifest.json`;
|
|
1006
|
+
/**
|
|
1007
|
+
* The project's own models entry as the dev server serves it. Vite's
|
|
1008
|
+
* transform pipeline absolutizes its chunk imports and rewrites bare
|
|
1009
|
+
* specifiers to /node_modules/.vite/deps/ URLs, so the result is directly
|
|
1010
|
+
* importable from a worker - the dev server is the bundler.
|
|
1011
|
+
*/
|
|
1012
|
+
const DEV_PROJECT_MODELS_PATH = "dist/browser/document-models/index.js";
|
|
1013
|
+
/** Source name for the project's own package (vetra's local package). */
|
|
1014
|
+
const PROJECT_PACKAGE_SOURCE_NAME = "ph:project-package";
|
|
1015
|
+
async function probeJavaScript(url) {
|
|
1016
|
+
try {
|
|
1017
|
+
const res = await fetch(url, { method: "HEAD" });
|
|
1018
|
+
return isWorkerBundleResponse({
|
|
1019
|
+
ok: res.ok,
|
|
1020
|
+
contentType: res.headers.get("content-type")
|
|
1021
|
+
});
|
|
1022
|
+
} catch {
|
|
1023
|
+
return false;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
async function fetchManifest(baseUrl) {
|
|
1027
|
+
try {
|
|
1028
|
+
const res = await fetch(workerFileUrl(baseUrl, WORKER_PACKAGES_MANIFEST, window.location.origin));
|
|
1029
|
+
if (!res.ok) return [];
|
|
1030
|
+
const parsed = await res.json();
|
|
1031
|
+
if (!Array.isArray(parsed)) return [];
|
|
1032
|
+
return parsed.filter((entry) => typeof entry === "object" && entry !== null && typeof entry.name === "string" && typeof entry.file === "string");
|
|
1033
|
+
} catch {
|
|
1034
|
+
return [];
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* The project's models source as served right now, with a cache-busting query
|
|
1039
|
+
* so a watch rebuild's re-registration imports the fresh file rather than the
|
|
1040
|
+
* worker's cached module. Null when the dev server does not serve one.
|
|
1041
|
+
*/
|
|
1042
|
+
async function resolveDevProjectSource(baseUrl) {
|
|
1043
|
+
const url = joinBase(baseUrl, DEV_PROJECT_MODELS_PATH, window.location.origin);
|
|
1044
|
+
if (!await probeJavaScript(url)) return null;
|
|
1045
|
+
url.searchParams.set("t", String(Date.now()));
|
|
1046
|
+
return {
|
|
1047
|
+
name: PROJECT_PACKAGE_SOURCE_NAME,
|
|
1048
|
+
url: url.href
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* URL-addressed packages the worker should load: the production manifest's
|
|
1053
|
+
* prebuilt bundles when deployed, plus the dev server's live project models
|
|
1054
|
+
* when present. Either list may be empty; both empty means this deployment
|
|
1055
|
+
* has no local packages (or predates the feature).
|
|
1056
|
+
*/
|
|
1057
|
+
async function resolveLocalPackageSources(baseUrl) {
|
|
1058
|
+
const [manifest, devProject] = await Promise.all([fetchManifest(baseUrl), resolveDevProjectSource(baseUrl)]);
|
|
1059
|
+
const sources = manifest.map((entry) => ({
|
|
1060
|
+
name: entry.name,
|
|
1061
|
+
version: entry.version,
|
|
1062
|
+
url: workerFileUrl(baseUrl, `${WORKER_PACKAGES_DIR}${entry.file}`, window.location.origin).href
|
|
1063
|
+
}));
|
|
1064
|
+
if (devProject) sources.push(devProject);
|
|
1065
|
+
return sources;
|
|
1066
|
+
}
|
|
1067
|
+
/** Calls `onChange` only when the local package is replaced (an HMR rebuild), not on every package notification. */
|
|
1068
|
+
function subscribeLocalPackageChanges(manager, onChange) {
|
|
1069
|
+
let last = manager.localPackage;
|
|
1070
|
+
return manager.subscribe(() => {
|
|
1071
|
+
const current = manager.localPackage;
|
|
1072
|
+
if (current === last) return;
|
|
1073
|
+
last = current;
|
|
1074
|
+
onChange();
|
|
1075
|
+
});
|
|
1171
1076
|
}
|
|
1172
1077
|
//#endregion
|
|
1173
1078
|
//#region src/store/processor-host-module.ts
|
|
@@ -1271,22 +1176,24 @@ function subscribeToPackagesChannel(packageManager) {
|
|
|
1271
1176
|
source.addEventListener("error", () => {});
|
|
1272
1177
|
}
|
|
1273
1178
|
async function clearReactorStorage() {
|
|
1274
|
-
const module =
|
|
1179
|
+
const module = getPHStore()?.reactorClientModule;
|
|
1275
1180
|
if (module?.kind === "worker") {
|
|
1276
1181
|
await module.adminClient.clearStorage();
|
|
1277
1182
|
return;
|
|
1278
1183
|
}
|
|
1279
|
-
if (module?.kind === "browser")
|
|
1184
|
+
if (module?.kind === "browser") {
|
|
1185
|
+
const reactorModule = module.reactorModule;
|
|
1186
|
+
await closeWithin(reactorModule?.groupCommitStorage ?? reactorModule?.pg);
|
|
1187
|
+
}
|
|
1280
1188
|
const targets = (await indexedDB.databases()).map((d) => d.name).filter((n) => !!n && !n.startsWith("ph-pglite-backup::") && /pglite|reactor/i.test(n));
|
|
1281
1189
|
await Promise.all(targets.map((name) => new Promise((resolve) => {
|
|
1282
1190
|
const req = indexedDB.deleteDatabase(name);
|
|
1283
1191
|
req.onsuccess = req.onerror = req.onblocked = () => resolve();
|
|
1284
1192
|
})));
|
|
1285
1193
|
}
|
|
1286
|
-
async function createReactor(localPackage) {
|
|
1287
|
-
if (
|
|
1288
|
-
|
|
1289
|
-
window.ph.loading = true;
|
|
1194
|
+
async function createReactor(localPackage, store) {
|
|
1195
|
+
if (store.loading) return;
|
|
1196
|
+
store.loading = true;
|
|
1290
1197
|
addPHEventHandlers();
|
|
1291
1198
|
setPHToast(toast);
|
|
1292
1199
|
const features = await initFeatureFlags();
|
|
@@ -1305,17 +1212,17 @@ async function createReactor(localPackage) {
|
|
|
1305
1212
|
const runtimeConfig = getRuntimeConfig();
|
|
1306
1213
|
const packageManager = new BrowserPackageManager(phGlobalConfig.routerBasename ?? "", runtimeConfig.packageRegistryUrl ?? null);
|
|
1307
1214
|
setVetraPackageManager(packageManager);
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
} catch {}
|
|
1215
|
+
const releaseRoutes = holdConnectRoutes();
|
|
1216
|
+
await packageManager.init(localPackage, runtimeConfig.localPackage?.version, phGlobalConfig.studioMode, connectConfig.workflowsEnabled, getConnectPluginUi().commonEditors);
|
|
1217
|
+
const { default: registerBundledPackages } = await import("ph-bundled-packages-virtual");
|
|
1218
|
+
registerBundledPackages(packageManager);
|
|
1313
1219
|
const remotePackages = runtimeConfig.packages.filter((p) => p.provider !== "local").map((p) => p.version ? `${p.packageName}@${p.version}` : p.packageName);
|
|
1314
|
-
(await packageManager.addPackages(remotePackages)).map((r) => {
|
|
1220
|
+
(await packageManager.addPackages(remotePackages).finally(releaseRoutes)).map((r) => {
|
|
1315
1221
|
if (r.type === "error") console.error(r.error);
|
|
1316
1222
|
});
|
|
1317
1223
|
if (runtimeConfig.connect?.packages?.liveReload) subscribeToPackagesChannel(packageManager);
|
|
1318
|
-
const
|
|
1224
|
+
const loadedDocumentModels = () => packageManager.packages.flatMap((pkg) => pkg.documentModels).filter((module, index, modules) => modules.findIndex((m) => m.documentModel.global.id === module.documentModel.global.id && m.version === module.version) === index);
|
|
1225
|
+
const documentModelModules = loadedDocumentModels();
|
|
1319
1226
|
const upgradeManifests = packageManager.packages.flatMap((pkg) => pkg.upgradeManifests).filter((manifest, index, manifests) => manifest !== void 0 && manifests.findIndex((m) => m && m.documentType === manifest.documentType) === index);
|
|
1320
1227
|
const discoveryService = packageManager.cdnUrl !== null ? new PackageDiscoveryService(packageManager, new RegistryClient(packageManager.cdnUrl), {
|
|
1321
1228
|
mode: "immediate",
|
|
@@ -1325,55 +1232,104 @@ async function createReactor(localPackage) {
|
|
|
1325
1232
|
const reactorFeatureFlags = runtimeConfig.connect?.reactor?.featureFlags ?? {};
|
|
1326
1233
|
const enabledReactorFlags = Object.entries(reactorFeatureFlags).filter(([, enabled]) => enabled).map(([name]) => name);
|
|
1327
1234
|
if (enabledReactorFlags.length > 0) logger.info(`Reactor feature flags: ${enabledReactorFlags.join(", ")}`);
|
|
1328
|
-
|
|
1329
|
-
|
|
1235
|
+
const createSignaturePolicy = runtimeConfig.connect?.reactor?.createSignaturePolicy;
|
|
1236
|
+
const unsupportedStoredDocuments = runtimeConfig.connect?.reactor?.unsupportedStoredDocuments;
|
|
1237
|
+
const renownEndpoints = {
|
|
1238
|
+
renownUrl: phGlobalConfig.renownUrl,
|
|
1239
|
+
switchboardUrl: phGlobalConfig.switchboardUrl
|
|
1240
|
+
};
|
|
1241
|
+
const plan = planReactorClient();
|
|
1242
|
+
const { multiReactor } = plan;
|
|
1243
|
+
const localReactor = async ({ localAsWorker }) => {
|
|
1244
|
+
if (!localAsWorker) return createBrowserReactor(documentModelModules, upgradeManifests, renown, reactorFeatureFlags, discoveryService, createSignaturePolicy, renownEndpoints, unsupportedStoredDocuments, multiReactor);
|
|
1330
1245
|
const packageSpecs = packageManager.getRegistryPackages().map((p) => p.version ? `${p.name}@${p.version}` : p.name);
|
|
1331
1246
|
const registryClient = new RegistryClient(packageManager.cdnUrl ?? "");
|
|
1247
|
+
const documentModelLoader = { async load(documentType) {
|
|
1248
|
+
const names = packageManager.cdnUrl ? await registryClient.getPackagesByDocumentType(documentType) : [];
|
|
1249
|
+
for (const name of names) {
|
|
1250
|
+
const result = await packageManager.addPackage(name);
|
|
1251
|
+
if (result.type === "error") throw new Error(`Failed to install package "${name}" for document model: ${documentType}`, { cause: result.error });
|
|
1252
|
+
}
|
|
1253
|
+
const module = packageManager.packages.flatMap((p) => p.documentModels).find((m) => m.documentModel.global.id === documentType);
|
|
1254
|
+
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"})`);
|
|
1255
|
+
return module;
|
|
1256
|
+
} };
|
|
1257
|
+
const [sharedDeps, packagedWorker, packageSources] = await Promise.all([
|
|
1258
|
+
getSharedDeps(),
|
|
1259
|
+
resolvePackagedReactorWorker(import.meta.env.BASE_URL),
|
|
1260
|
+
resolveLocalPackageSources(import.meta.env.BASE_URL)
|
|
1261
|
+
]);
|
|
1262
|
+
const workerSource = selectReactorWorkerSource({
|
|
1263
|
+
packaged: isPackagedConnectDist(),
|
|
1264
|
+
bundle: packagedWorker
|
|
1265
|
+
});
|
|
1266
|
+
if (workerSource.kind === "unavailable") {
|
|
1267
|
+
store.loading = false;
|
|
1268
|
+
throw new Error("reactorWorker is enabled but this deployment serves no reactor worker bundle (__reactor_worker__/); rebuild with ph connect build or open with ?reactorWorker=false");
|
|
1269
|
+
}
|
|
1332
1270
|
const workerClient = createWorkerReactorClientModule({
|
|
1271
|
+
workerUrl: workerSource.kind === "bundle" ? workerSource.url : void 0,
|
|
1272
|
+
workerDigest: workerSource.kind === "bundle" ? workerSource.digest : void 0,
|
|
1273
|
+
packageSources,
|
|
1333
1274
|
namespace: REACTOR_INSTANCE_NAMESPACE,
|
|
1334
1275
|
relationalNamespace: RELATIONAL_PGLITE_NAME,
|
|
1335
1276
|
cdnUrl: packageManager.cdnUrl ?? "",
|
|
1336
1277
|
packageSpecs,
|
|
1278
|
+
sharedImports: sharedDeps?.imports,
|
|
1337
1279
|
studioMode: phGlobalConfig.studioMode,
|
|
1280
|
+
workflowsEnabled: connectConfig.workflowsEnabled,
|
|
1338
1281
|
renownChainId,
|
|
1339
1282
|
featureFlags: reactorFeatureFlags,
|
|
1283
|
+
multiReactor,
|
|
1284
|
+
createSignaturePolicy,
|
|
1285
|
+
unsupportedStoredDocuments,
|
|
1286
|
+
renownEndpoints,
|
|
1340
1287
|
documentModelModules,
|
|
1341
1288
|
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
|
-
} },
|
|
1289
|
+
documentModelLoader,
|
|
1352
1290
|
renown,
|
|
1353
|
-
onReload: (reason
|
|
1291
|
+
onReload: (reason) => {
|
|
1354
1292
|
logger.warn("Reactor worker requested reload: @reason", reason);
|
|
1355
|
-
|
|
1356
|
-
window.location.reload();
|
|
1293
|
+
reloadForWorker(reason, () => window.location.reload());
|
|
1357
1294
|
}
|
|
1358
1295
|
});
|
|
1359
|
-
|
|
1296
|
+
const { registerPackages } = workerClient.reactorClientModule;
|
|
1297
|
+
subscribeLocalPackageChanges(packageManager, () => {
|
|
1298
|
+
(async () => {
|
|
1299
|
+
const source = await resolveDevProjectSource(import.meta.env.BASE_URL);
|
|
1300
|
+
if (!source) return;
|
|
1301
|
+
try {
|
|
1302
|
+
await registerPackages([source]);
|
|
1303
|
+
} catch (error) {
|
|
1304
|
+
logger.error("Failed to re-register project models in the reactor worker: @error", error);
|
|
1305
|
+
}
|
|
1306
|
+
})();
|
|
1307
|
+
});
|
|
1360
1308
|
try {
|
|
1361
|
-
await workerClient.syncManagerProxy.startup();
|
|
1309
|
+
await startupOwningStores((options) => workerClient.syncManagerProxy.startup(options), [REACTOR_INSTANCE_NAMESPACE, RELATIONAL_PGLITE_NAME]);
|
|
1362
1310
|
} catch (error) {
|
|
1363
|
-
|
|
1311
|
+
store.loading = false;
|
|
1364
1312
|
logger.error("Reactor worker failed to start: @error", error);
|
|
1365
1313
|
throw error;
|
|
1366
1314
|
}
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
await
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1315
|
+
return workerClient.reactorClientModule;
|
|
1316
|
+
};
|
|
1317
|
+
const { module: reactorClientModule, client: appReactorClient } = await createAppReactorClient({
|
|
1318
|
+
plan,
|
|
1319
|
+
localReactor,
|
|
1320
|
+
remoteDriveUrl: phGlobalConfig.defaultDrivesUrl,
|
|
1321
|
+
signer: renown.signer,
|
|
1322
|
+
documentModelModules: loadedDocumentModels
|
|
1323
|
+
});
|
|
1324
|
+
const drives = await getAppDrives(appReactorClient, reactorClientModule?.client ?? appReactorClient);
|
|
1325
|
+
await login(void 0, renown);
|
|
1326
|
+
const documentCache = new DocumentCache(appReactorClient);
|
|
1327
|
+
const basePath = phGlobalConfig.basePath ?? "/";
|
|
1328
|
+
const routerBasename = phGlobalConfig.routerBasename ?? "/";
|
|
1329
|
+
const mergedGlobalConfig = buildPHGlobalConfig(basePath, routerBasename, runtimeConfig.connect ?? {});
|
|
1330
|
+
setDefaultPHGlobalConfig(mergedGlobalConfig);
|
|
1375
1331
|
setReactorClientModule(reactorClientModule);
|
|
1376
|
-
setReactorClient(
|
|
1332
|
+
setReactorClient(appReactorClient);
|
|
1377
1333
|
const _defaultDrivesUrl = phGlobalConfig.defaultDrivesUrl;
|
|
1378
1334
|
if (_defaultDrivesUrl) {
|
|
1379
1335
|
let switchboardOrigin;
|
|
@@ -1385,51 +1341,46 @@ async function createReactor(localPackage) {
|
|
|
1385
1341
|
if (!renown.user) return void 0;
|
|
1386
1342
|
return renown.getBearerToken({ expiresIn: 10 });
|
|
1387
1343
|
};
|
|
1388
|
-
|
|
1344
|
+
const attachmentService = createRemoteAttachmentService({
|
|
1389
1345
|
remoteUrl: switchboardOrigin,
|
|
1390
1346
|
jwtHandler: attachmentJwtHandler,
|
|
1391
1347
|
uploadTransport: createXhrUploadTransport()
|
|
1392
|
-
})
|
|
1348
|
+
});
|
|
1349
|
+
setAttachmentService(attachmentService);
|
|
1393
1350
|
}
|
|
1394
1351
|
}
|
|
1395
1352
|
setDocumentCache(documentCache);
|
|
1396
1353
|
setRenown(renown);
|
|
1397
|
-
setDrives(drives);
|
|
1398
1354
|
setFeatures(features);
|
|
1355
|
+
const addsDrives = plan.mode !== "remote";
|
|
1399
1356
|
const defaultDrivesConfig = getDefaultDrives(runtimeConfig);
|
|
1400
|
-
if (defaultDrivesConfig.length > 0) addDefaultDrivesForNewReactor(defaultDrivesConfig).catch((error) => console.error("Failed to add default drives:", error));
|
|
1357
|
+
if (addsDrives && defaultDrivesConfig.length > 0) trackDriveArrival(addDefaultDrivesForNewReactor(defaultDrivesConfig)).catch((error) => console.error("Failed to add default drives:", error));
|
|
1401
1358
|
const remoteUrl = getDriveUrl();
|
|
1402
|
-
if (remoteUrl
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
const reactorClient =
|
|
1359
|
+
if (remoteUrl && !addsDrives) logger.warn("The remote reactor client ignores ?driveUrl=@url", remoteUrl);
|
|
1360
|
+
else if (remoteUrl) trackDriveArrival(addRemoteDrive(remoteUrl, void 0).then((driveId) => untilDriveListed(store, driveId))).catch((error) => console.error(`Failed to add remote drive from ${remoteUrl}:`, error));
|
|
1361
|
+
setDrives(drives);
|
|
1362
|
+
const reactorClient = appReactorClient;
|
|
1406
1363
|
for (const driveType of DRIVE_DOCUMENT_TYPES) reactorClient.subscribe({ type: driveType }, (event) => {
|
|
1407
1364
|
logger.verbose("ReactorClient subscription event: @event", event);
|
|
1408
|
-
refreshReactorDataClient(
|
|
1365
|
+
refreshReactorDataClient(appReactorClient).catch((e) => logger.error("@error", e));
|
|
1409
1366
|
});
|
|
1410
1367
|
reactorClient.subscribe({}, (event) => {
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
toast("The drive you were viewing has been deleted");
|
|
1419
|
-
return;
|
|
1420
|
-
}
|
|
1421
|
-
if (selectedNodeId && deletedId === selectedNodeId) {
|
|
1422
|
-
setSelectedNode(void 0);
|
|
1423
|
-
toast("The document you were editing has been deleted");
|
|
1424
|
-
}
|
|
1368
|
+
closeDeletedSelection(event, {
|
|
1369
|
+
selectedDriveId: store.selectedDriveId,
|
|
1370
|
+
selectedNodeId: store.selectedNodeId,
|
|
1371
|
+
closeDrive: () => setSelectedDrive(void 0),
|
|
1372
|
+
closeNode: () => setSelectedNode(void 0),
|
|
1373
|
+
notify: (message) => toast(message)
|
|
1374
|
+
});
|
|
1425
1375
|
});
|
|
1426
|
-
await
|
|
1376
|
+
await refreshAppDrives(appReactorClient, reactorClientModule?.client ?? appReactorClient);
|
|
1427
1377
|
const packagesWithProcessorFactories = packageManager.packages.filter((pkg) => pkg.processorFactory !== void 0);
|
|
1428
|
-
const reactorModule = reactorClientModule
|
|
1429
|
-
if (packagesWithProcessorFactories.length > 0 && !
|
|
1430
|
-
else if (packagesWithProcessorFactories.length > 0 && reactorModule)
|
|
1378
|
+
const reactorModule = reactorClientModule?.kind === "browser" ? reactorClientModule.reactorModule : void 0;
|
|
1379
|
+
if (packagesWithProcessorFactories.length > 0 && !reactorClientModule) logger.info("Remote reactor client: @count processor factory/ies run on the Switchboard, not in the tab", packagesWithProcessorFactories.length);
|
|
1380
|
+
else if (packagesWithProcessorFactories.length > 0 && !reactorModule) for (const pkg of packagesWithProcessorFactories) logger.warn("Skipping processor factory @name: processors are not supported on the worker reactor path yet", pkg.manifest.name);
|
|
1381
|
+
else if (packagesWithProcessorFactories.length > 0 && reactorModule && reactorClientModule) {
|
|
1431
1382
|
const readModels = reactorModule.readModelCoordinator.readModels;
|
|
1432
|
-
const processorHostModule = await createProcessorHostModule(reactorClientModule.client, readModels,
|
|
1383
|
+
const processorHostModule = await createProcessorHostModule(reactorClientModule.client, readModels, store.attachmentService);
|
|
1433
1384
|
if (processorHostModule !== void 0) await Promise.all(packagesWithProcessorFactories.map(async (pkg) => {
|
|
1434
1385
|
const { manifest, processorFactory } = pkg;
|
|
1435
1386
|
const name = manifest.name;
|
|
@@ -1447,11 +1398,7 @@ async function createReactor(localPackage) {
|
|
|
1447
1398
|
}
|
|
1448
1399
|
}));
|
|
1449
1400
|
}
|
|
1450
|
-
|
|
1451
|
-
}
|
|
1452
|
-
function getDidFromUrl() {
|
|
1453
|
-
const didComponent = new URLSearchParams(window.location.search).get("user");
|
|
1454
|
-
return didComponent ? decodeURIComponent(didComponent) : void 0;
|
|
1401
|
+
store.loading = false;
|
|
1455
1402
|
}
|
|
1456
1403
|
function getDriveUrl() {
|
|
1457
1404
|
const driveUrl = new URLSearchParams(window.location.search).get("driveUrl");
|
|
@@ -1460,5 +1407,5 @@ function getDriveUrl() {
|
|
|
1460
1407
|
//#endregion
|
|
1461
1408
|
export { createReactor as n, clearReactorStorage as t };
|
|
1462
1409
|
|
|
1463
|
-
//# sourceMappingURL=reactor-
|
|
1464
|
-
//# debugId=
|
|
1410
|
+
//# sourceMappingURL=reactor-DLCl-WHi.js.map
|
|
1411
|
+
//# debugId=2c212d19-c60e-51df-85b4-428dfc7292c8
|