@powerhousedao/connect 6.2.3-dev.66 → 6.2.3-dev.67
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 +77 -0
- package/README.md +18 -91
- package/RUNTIME-CONFIG.md +472 -0
- package/dist/{AddDriveModal-D_3jDwjp.js → AddDriveModal-BjgmiHJr.js} +6 -6
- package/dist/AddDriveModal-BjgmiHJr.js.map +1 -0
- package/dist/{ClearStorageModal-zZ8XzwmR.js → ClearStorageModal-_03VgDb5.js} +6 -6
- package/dist/ClearStorageModal-_03VgDb5.js.map +1 -0
- package/dist/{ConfirmDocumentUpgradeModal-CrU2Z1CL.js → ConfirmDocumentUpgradeModal-CoixS60F.js} +5 -5
- package/dist/ConfirmDocumentUpgradeModal-CoixS60F.js.map +1 -0
- package/dist/{CookiesPolicyModal-DQwsgDI9.js → CookiesPolicyModal-BpFjYc7T.js} +4 -4
- package/dist/{CookiesPolicyModal-DQwsgDI9.js.map → CookiesPolicyModal-BpFjYc7T.js.map} +1 -1
- package/dist/{CreateDocumentModal-Cf1APibL.js → CreateDocumentModal-B-cXzeOA.js} +10 -10
- package/dist/CreateDocumentModal-B-cXzeOA.js.map +1 -0
- package/dist/{DebugSettingsModal-DIc5C2lI.js → DebugSettingsModal-CGScJ_r2.js} +8 -8
- package/dist/DebugSettingsModal-CGScJ_r2.js.map +1 -0
- package/dist/{DeleteDriveModal-lE9eCBua.js → DeleteDriveModal-1pAIayG_.js} +5 -5
- package/dist/DeleteDriveModal-1pAIayG_.js.map +1 -0
- package/dist/{DeleteItemModal-BFgcGsm3.js → DeleteItemModal-BUpqmFxS.js} +5 -5
- package/dist/DeleteItemModal-BUpqmFxS.js.map +1 -0
- package/dist/{DisclaimerModal-CF6JkIIu.js → DisclaimerModal-TIJXRYLF.js} +5 -5
- package/dist/DisclaimerModal-TIJXRYLF.js.map +1 -0
- package/dist/{DocumentVersionUnsupportedModal-Cm9Jb9W7.js → DocumentVersionUnsupportedModal-DH9Zzsyw.js} +5 -5
- package/dist/DocumentVersionUnsupportedModal-DH9Zzsyw.js.map +1 -0
- package/dist/{DownloadDocumentWithErrorsModal-CShKhfEQ.js → DownloadDocumentWithErrorsModal-Beh-xw8B.js} +5 -5
- package/dist/DownloadDocumentWithErrorsModal-Beh-xw8B.js.map +1 -0
- package/dist/{DriveAuthRequiredModal-CMwPUyZf.js → DriveAuthRequiredModal-XTcoJKvj.js} +6 -6
- package/dist/DriveAuthRequiredModal-XTcoJKvj.js.map +1 -0
- package/dist/{DriveSettingsModal-BSImj4BH.js → DriveSettingsModal-DZKawN7w.js} +5 -5
- package/dist/DriveSettingsModal-DZKawN7w.js.map +1 -0
- package/dist/{InspectorModal-Dr8-gj6u.js → InspectorModal-DA_TGmM6.js} +16 -16
- package/dist/InspectorModal-DA_TGmM6.js.map +1 -0
- package/dist/{LoginModal-DT_05uva.js → LoginModal-O06ZvWFI.js} +6 -6
- package/dist/LoginModal-O06ZvWFI.js.map +1 -0
- package/dist/{OpenFileDocumentsModal-X9GnX2Bk.js → OpenFileDocumentsModal-BNHD0vg9.js} +6 -6
- package/dist/OpenFileDocumentsModal-BNHD0vg9.js.map +1 -0
- package/dist/{UpgradeDriveModal-DvM-PNWe.js → UpgradeDriveModal-CCWKp5yn.js} +5 -5
- package/dist/UpgradeDriveModal-CCWKp5yn.js.map +1 -0
- package/dist/{app-loader-DrViXipO.js → app-loader-CEN_4I3I.js} +149 -196
- package/dist/app-loader-CEN_4I3I.js.map +1 -0
- package/dist/app-loader-Cj2p8L1I.js +4 -0
- package/dist/{app-skeleton-gzg8cRzm.js → app-skeleton-BFjvlTWd.js} +11 -11
- package/dist/app-skeleton-BFjvlTWd.js.map +1 -0
- package/dist/{app-skeleton-DYLZ7npI.js → app-skeleton-DFg65Rxa.js} +3 -3
- package/dist/{boot-CC_DgQKX.js → boot-JTGLJtmJ.js} +6 -6
- package/dist/boot-JTGLJtmJ.js.map +1 -0
- package/dist/{build-info-DMrToXJe.js → build-info-DkY9PU7c.js} +5 -5
- package/dist/{build-info-DMrToXJe.js.map → build-info-DkY9PU7c.js.map} +1 -1
- package/dist/{components-CjF9XjxP.js → components-2wvJ3_Ho.js} +11 -10
- package/dist/{components-CjF9XjxP.js.map → components-2wvJ3_Ho.js.map} +1 -1
- package/dist/{connect.config-uZF-gnvV.js → connect.config-D1pGNmaF.js} +4 -4
- package/dist/connect.config-D1pGNmaF.js.map +1 -0
- package/dist/{connection-state-C_477Kr_.js → connection-state-B6fleM37.js} +6 -6
- package/dist/connection-state-B6fleM37.js.map +1 -0
- package/dist/{cookie-banner-HPgyuHM5.js → cookie-banner-CAvd3PC3.js} +6 -6
- package/dist/{cookie-banner-HPgyuHM5.js.map → cookie-banner-CAvd3PC3.js.map} +1 -1
- package/dist/document-editor-container-BnEjlmaN.js +307 -0
- package/dist/document-editor-container-BnEjlmaN.js.map +1 -0
- package/dist/document-editor-container-kgS38mkb.js +4 -0
- package/dist/error-boundary-BsUBww61.js +155 -0
- package/dist/error-boundary-BsUBww61.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-CTgT1HG-.js → i18n-D9WYPgk9.js} +4 -4
- package/dist/{i18n-CTgT1HG-.js.map → i18n-D9WYPgk9.js.map} +1 -1
- package/dist/index-B4g8swZG.d.ts +4 -0
- package/dist/layout-BOX6fL5v.js +5 -0
- package/dist/layout.d.ts +2 -28
- package/dist/layout.js +4 -6
- package/dist/{load--K_UgzUy.js → load-CCCHqC0d.js} +11 -11
- package/dist/{load--K_UgzUy.js.map → load-CCCHqC0d.js.map} +1 -1
- package/dist/load-runtime-config-Dhy-b5wT.js +14 -0
- package/dist/load-runtime-config-Dhy-b5wT.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/{open-file-uploads-BcyWmUZn.js → open-file-uploads-B5pr1sA2.js} +4 -4
- package/dist/{open-file-uploads-BcyWmUZn.js.map → open-file-uploads-B5pr1sA2.js.map} +1 -1
- package/dist/{package-manager-BkFRzovd.js → package-manager-x_fK8Hzm.js} +92 -60
- package/dist/package-manager-x_fK8Hzm.js.map +1 -0
- package/dist/{pglite-seed-BsEPByVM.js → pglite-seed-eGzXMld2.js} +4 -4
- package/dist/{pglite-seed-BsEPByVM.js.map → pglite-seed-eGzXMld2.js.map} +1 -1
- package/dist/{plugin-host--lBWChr9.js → plugins-B9VBgzio.js} +75 -83
- package/dist/plugins-B9VBgzio.js.map +1 -0
- package/dist/{preferences-store-DANUajdg.js → preferences-store-CSqauT9V.js} +5 -5
- 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-DxCUDEXL.js → prerendered-shell-peKE7AqI.js} +10 -4
- package/dist/prerendered-shell-peKE7AqI.js.map +1 -0
- package/dist/{reactor-5nod7BfF.js → reactor-BmI-D8O-.js} +25 -156
- package/dist/reactor-BmI-D8O-.js.map +1 -0
- package/dist/{registerServiceWorker-CkVxA2KC.js → registerServiceWorker-APlHkrmH.js} +4 -4
- package/dist/{registerServiceWorker-CkVxA2KC.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 +147 -156
- package/dist/route-tree.d.ts.map +1 -1
- package/dist/route-tree.js +93 -169
- package/dist/route-tree.js.map +1 -1
- 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 +1 -3
- package/dist/router.js +3 -7
- package/dist/sentry-Cuc_Nbba.js +22 -0
- package/dist/sentry-Cuc_Nbba.js.map +1 -0
- package/dist/{settings-DkLhRfEI.js → settings-DjQfTrBe.js} +488 -22
- package/dist/settings-DjQfTrBe.js.map +1 -0
- package/dist/settings-tabs-iTlo2pYz.js +365 -0
- package/dist/settings-tabs-iTlo2pYz.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 -1
- package/dist/shell-plugins.json +1 -0
- package/dist/shell.html +1 -1
- package/dist/start-connect.d.ts +5 -9
- package/dist/start-connect.d.ts.map +1 -1
- package/dist/start-connect.js +5 -6
- package/dist/start-connect.js.map +1 -1
- package/dist/style.css +3127 -4014
- package/dist/ui-b6sMhi5V.js +66 -0
- package/dist/ui-b6sMhi5V.js.map +1 -0
- package/dist/{use-renown-login-BzOSQETV.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 +177 -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 +38 -0
- package/docs/customizing/pages.md +136 -0
- package/docs/customizing/styles-and-branding.md +41 -0
- package/docs/customizing/types-and-troubleshooting.md +44 -0
- package/package.json +41 -18
- package/scripts/prerender-shell.ts +35 -84
- package/skills/customize-connect/SKILL.md +74 -0
- package/src/route-tree.ts +3 -0
- package/src/routeTree.gen.ts +134 -192
- package/src/router/index.ts +2 -51
- package/src/router/register.ts +1 -1
- package/src/routes/__root.tsx +8 -24
- 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 +5 -22
- package/tailwind.css +12 -0
- package/dist/AddDriveModal-D_3jDwjp.js.map +0 -1
- package/dist/ClearStorageModal-zZ8XzwmR.js.map +0 -1
- package/dist/ConfirmDocumentUpgradeModal-CrU2Z1CL.js.map +0 -1
- package/dist/CreateDocumentModal-Cf1APibL.js.map +0 -1
- package/dist/DebugSettingsModal-DIc5C2lI.js.map +0 -1
- package/dist/DeleteDriveModal-lE9eCBua.js.map +0 -1
- package/dist/DeleteItemModal-BFgcGsm3.js.map +0 -1
- package/dist/DisclaimerModal-CF6JkIIu.js.map +0 -1
- package/dist/DocumentVersionUnsupportedModal-Cm9Jb9W7.js.map +0 -1
- package/dist/DownloadDocumentWithErrorsModal-CShKhfEQ.js.map +0 -1
- package/dist/DriveAuthRequiredModal-CMwPUyZf.js.map +0 -1
- package/dist/DriveSettingsModal-BSImj4BH.js.map +0 -1
- package/dist/InspectorModal-Dr8-gj6u.js.map +0 -1
- package/dist/LoginModal-DT_05uva.js.map +0 -1
- package/dist/MissingPackageModal-DtISKgub.js +0 -49
- package/dist/MissingPackageModal-DtISKgub.js.map +0 -1
- package/dist/OpenFileDocumentsModal-X9GnX2Bk.js.map +0 -1
- package/dist/UpgradeDriveModal-DvM-PNWe.js.map +0 -1
- package/dist/app-layout-BIq-ZW-6.js +0 -394
- package/dist/app-layout-BIq-ZW-6.js.map +0 -1
- package/dist/app-loader-CWAH-WxW.js +0 -4
- package/dist/app-loader-DrViXipO.js.map +0 -1
- package/dist/app-skeleton-gzg8cRzm.js.map +0 -1
- package/dist/boot-CC_DgQKX.js.map +0 -1
- package/dist/connect-router-KmNBGS0G.js +0 -434
- package/dist/connect-router-KmNBGS0G.js.map +0 -1
- package/dist/connect.config-uZF-gnvV.js.map +0 -1
- package/dist/connection-state-C_477Kr_.js.map +0 -1
- package/dist/index-UrZFqSgm.d.ts +0 -166
- package/dist/index-UrZFqSgm.d.ts.map +0 -1
- package/dist/layout.d.ts.map +0 -1
- package/dist/multi-reactor-fSKpLBjT.js +0 -220
- package/dist/multi-reactor-fSKpLBjT.js.map +0 -1
- package/dist/package-manager-BkFRzovd.js.map +0 -1
- package/dist/plugin-host--lBWChr9.js.map +0 -1
- package/dist/preferences-store-DANUajdg.js.map +0 -1
- package/dist/prerendered-shell-DxCUDEXL.js.map +0 -1
- package/dist/reactor-5nod7BfF.js.map +0 -1
- package/dist/route-components-BkztQruF.js +0 -148
- package/dist/route-components-BkztQruF.js.map +0 -1
- package/dist/router-8RIbbf6v.js +0 -4
- package/dist/router-C37yATTD.js +0 -604
- package/dist/router-C37yATTD.js.map +0 -1
- package/dist/runtime-config-DdN1Frg7.js +0 -34
- package/dist/runtime-config-DdN1Frg7.js.map +0 -1
- package/dist/runtime-flag-B8IYhkz-.js +0 -4
- package/dist/runtime-flag-CT5OKujT.js +0 -45
- package/dist/runtime-flag-CT5OKujT.js.map +0 -1
- package/dist/sentry-CJb7--mu.js +0 -18
- package/dist/sentry-CJb7--mu.js.map +0 -1
- package/dist/settings-CjvK8OKA.js +0 -91
- package/dist/settings-CjvK8OKA.js.map +0 -1
- package/dist/settings-DkLhRfEI.js.map +0 -1
- package/dist/sidebar-BXf8OEwm.d.ts +0 -34
- package/dist/sidebar-BXf8OEwm.d.ts.map +0 -1
- package/dist/sidebar-lAVFRsni.js +0 -31
- package/dist/sidebar-lAVFRsni.js.map +0 -1
- package/dist/use-renown-login-BzOSQETV.js.map +0 -1
- package/dist/useIsEmbedded-BWJ0qb7w.js +0 -26
- package/dist/useIsEmbedded-BWJ0qb7w.js.map +0 -1
- package/dist/useRegistryPackages-BqIWwXV-.js +0 -452
- package/dist/useRegistryPackages-BqIWwXV-.js.map +0 -1
- package/scripts/critical-css.ts +0 -243
- package/src/router/connect-router.ts +0 -170
- package/src/router/drive-route-loader.ts +0 -116
- package/src/router/navigation.ts +0 -230
- package/src/router/perf-marks.test.tsx +0 -98
- package/src/router/perf-marks.ts +0 -97
- package/src/router/route-components.tsx +0 -98
- package/src/router/route-tree.ts +0 -88
- package/src/router/scroll.ts +0 -69
- package/src/router/search.ts +0 -66
- package/src/router/settings.ts +0 -120
- package/src/router/sidebar.ts +0 -55
- package/src/router/titles.test.ts +0 -24
- package/src/router/titles.ts +0 -33
- package/src/routes/core/_app/$.tsx +0 -13
- package/src/routes/core/_app/_content/d/$driveSlug/{-$nodeSlug}.tsx +0 -52
- package/src/routes/core/_app/_content/index.tsx +0 -3
- package/src/routes/core/_app/_content.tsx +0 -9
- package/src/routes/core/_app/settings/about.tsx +0 -20
- package/src/routes/core/_app/settings/ai-assistant.tsx +0 -20
- package/src/routes/core/_app/settings/danger-zone.tsx +0 -21
- package/src/routes/core/_app/settings/default-editors.tsx +0 -20
- package/src/routes/core/_app/settings/package-manager.tsx +0 -20
- package/src/routes/core/_app/settings.tsx +0 -35
- package/src/routes/core/_app.tsx +0 -10
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/prerender/app-shell.d.ts
|
|
2
|
+
/** `generic`: Connect's chrome. `core`: core's views. `project`: a project's routes. */
|
|
3
|
+
type AppShellKind = "generic" | "core" | "project";
|
|
4
|
+
/** Rendered where the app's name goes. */
|
|
5
|
+
export declare const APP_NAME_TOKEN = "__PH_SHELL_APP_NAME__";
|
|
6
|
+
/** The rendered shell as #root's static markup: no scripts or title, images as
|
|
7
|
+
* boxes, the app's name delimited. */
|
|
8
|
+
export declare function shellMarkup(rendered: string): string;
|
|
9
|
+
/** #root's markup and <head>'s critical CSS (`css`, see shellCss) and guard.
|
|
10
|
+
* `variant` names it for a server that swaps it. */
|
|
11
|
+
export declare function appShell(kind: AppShellKind, variant: "generic" | "core", markup: string, css: string): {
|
|
12
|
+
body: string;
|
|
13
|
+
head: string;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/prerender/shell-css.d.ts
|
|
17
|
+
/** `entry`, a Tailwind stylesheet, built for the classes in `markup` only:
|
|
18
|
+
* its tokens, reset and rules, without third-party CSS. */
|
|
19
|
+
export declare function shellCss(entry: string, markup: string): Promise<string>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/prerender/shell.d.ts
|
|
22
|
+
/** Each prerendered shell's plugin, whose presence in a composition picks it; core's has none. */
|
|
23
|
+
export declare function shellPlugins(): Promise<Partial<Record<ShellVariant, string>>>;
|
|
24
|
+
/** `generic`: Connect's chrome. `core`: core's views, for a composition without the generic plugin. */
|
|
25
|
+
export type ShellVariant = "generic" | "core";
|
|
26
|
+
/** Renders the route tree at `/` before the reactor is up. `kind` picks the
|
|
27
|
+
* loader: Connect's logo for its chrome, core's spinner otherwise. */
|
|
28
|
+
export declare function renderShell(variant?: ShellVariant, kind?: AppShellKind): Promise<string>;
|
|
29
|
+
/** A project's shells, one per variant: its route tree rendered at `/`, with
|
|
30
|
+
* CSS that `stylesheet`, its Tailwind entry, builds for the markup's classes. */
|
|
31
|
+
export declare function renderProjectShells(stylesheet: string): Promise<Partial<Record<ShellVariant, {
|
|
32
|
+
body: string;
|
|
33
|
+
head: string;
|
|
34
|
+
}>>>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export type { AppShellKind };
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=prerender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prerender.d.ts","names":[],"sources":["../src/prerender/app-shell.ts","../src/prerender/shell-css.ts","../src/prerender/shell.tsx"],"mappings":";;KAMY;;qBAGC;;;wBA8DG,YAAY;;;wBAYZ,SACd,MAAM,cACN,6BACA,gBACA;EAME;EAGA;;;;;;wBCnEkB,SAAS,eAAe,iBAAc;;;;wBCatC,gBAAgB,QACpC,QAAQ,OAAO;;YAUL;;;wBAMU,YACpB,UAAS,cACT,OAAM,eACL;;;wBA4DmB,oBAAoB,qBAAkB,QAAA,QAAA,OAAA;EACP;EAAc"}
|
|
@@ -0,0 +1,177 @@
|
|
|
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]="61013f03-0d8b-51fa-9126-cb3323e95441")}catch(e){}}();
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { primeRuntimeConfig } from "@powerhousedao/connect-core/runtime-config";
|
|
5
|
+
import { PHStoreProvider, createPHStore } from "@powerhousedao/reactor-browser";
|
|
6
|
+
import { RouterProvider, createMemoryHistory } from "@tanstack/react-router";
|
|
7
|
+
import { Icon } from "@powerhousedao/design-system";
|
|
8
|
+
import { DEFAULT_CONNECT_CONFIG } from "@powerhousedao/shared/connect";
|
|
9
|
+
import { getConnectPluginUi, loadConnectPluginUi, registerConnectPlugins, resetConnectPluginUi } from "@powerhousedao/connect-core/plugins";
|
|
10
|
+
import { prerender } from "react-dom/static";
|
|
11
|
+
import { compile, optimize } from "@tailwindcss/node";
|
|
12
|
+
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
15
|
+
//#region src/prerender/app-shell.ts
|
|
16
|
+
/** The marker boot.tsx and the project build look for. */
|
|
17
|
+
const SHELL_MARKER = "data-ph-shell";
|
|
18
|
+
/** Rendered where the app's name goes. */
|
|
19
|
+
const APP_NAME_TOKEN = "__PH_SHELL_APP_NAME__";
|
|
20
|
+
const APP_NAME_REGION = "<!--ph-shell:app-name-->Connect<!--/ph-shell:app-name-->";
|
|
21
|
+
const GUARD_SCRIPT = "(function(){try{var h=document.documentElement;var e=new URLSearchParams(location.search).get('embed');if(e!==null&&e!=='0'&&e!=='false')h.classList.add('ph-shell-embed');var p=location.pathname;if(!/\\/$/.test(p)||/\\/d\\//.test(p))h.classList.add('ph-shell-route')}catch(x){}})();";
|
|
22
|
+
const CURRENT_GUARD_SCRIPT = `(function(){if(!document.documentElement.classList.contains('ph-shell-route'))return;document.querySelectorAll('[${SHELL_MARKER}] [aria-current]').forEach(function(e){e.removeAttribute('aria-current');e.classList.remove('active')})})();`;
|
|
23
|
+
const LOADER_CSS = "@keyframes ph-shell-loader-in{from{opacity:0}to{opacity:1}}.ph-shell-loader{animation:ph-shell-loader-in .2s ease-in both;animation-delay:calc(.25s + var(--ph-shell-t,0ms))}.ph-shell-loader>*{animation-delay:var(--ph-shell-t,0ms)}";
|
|
24
|
+
const ROUTE_GUARD = `.ph-shell-route [${SHELL_MARKER}] #content-view{visibility:hidden}`;
|
|
25
|
+
const GUARD_CSS = {
|
|
26
|
+
generic: `.ph-shell-embed [${SHELL_MARKER}] #sidebar{display:none}` + ROUTE_GUARD + LOADER_CSS,
|
|
27
|
+
core: `.ph-shell-embed [${SHELL_MARKER}] header{display:none}[${SHELL_MARKER}] header button{visibility:hidden}@keyframes ph-shell-loader-in{from{opacity:0}to{opacity:1}}.ph-shell-loader{animation:ph-shell-loader-in .2s ease-in both;animation-delay:calc(.25s + var(--ph-shell-t,0ms))}.ph-shell-loader>*{animation-delay:var(--ph-shell-t,0ms)}`,
|
|
28
|
+
project: ROUTE_GUARD + LOADER_CSS
|
|
29
|
+
};
|
|
30
|
+
function replaceInlineImages(html) {
|
|
31
|
+
return html.replace(/<img\b[^>]*\bsrc="data:[^"]*"[^>]*>/g, (img) => {
|
|
32
|
+
const attr = (name) => new RegExp(`\\b${name}="([^"]*)"`).exec(img)?.[1];
|
|
33
|
+
if (/(^| )hidden( |$)/.test(attr("class") ?? "")) return "";
|
|
34
|
+
const width = attr("width");
|
|
35
|
+
const height = attr("height");
|
|
36
|
+
return `<span style="display:inline-block;${`${width ? `width:${width}px;` : ""}${height ? `height:${height}px;` : ""}`}"></span>`;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** The rendered shell as #root's static markup: no scripts or title, images as
|
|
40
|
+
* boxes, the app's name delimited. */
|
|
41
|
+
function shellMarkup(rendered) {
|
|
42
|
+
return replaceInlineImages(rendered.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g, "").replace(/<title\b[^>]*>[\s\S]*?<\/title>/g, "")).replaceAll(APP_NAME_TOKEN, APP_NAME_REGION);
|
|
43
|
+
}
|
|
44
|
+
/** #root's markup and <head>'s critical CSS (`css`, see shellCss) and guard.
|
|
45
|
+
* `variant` names it for a server that swaps it. */
|
|
46
|
+
function appShell(kind, variant, markup, css) {
|
|
47
|
+
const guard = GUARD_CSS[kind];
|
|
48
|
+
const marker = `${SHELL_MARKER}="${variant}"`;
|
|
49
|
+
return {
|
|
50
|
+
body: `<div ${marker} inert style="display:contents">${markup}</div><script ${marker}>${CURRENT_GUARD_SCRIPT}<\/script>`,
|
|
51
|
+
head: `<style ${marker}>${css}${guard}</style><script ${marker}>${GUARD_SCRIPT}<\/script>`
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/prerender/shell-css.ts
|
|
56
|
+
let emptyFile;
|
|
57
|
+
const empty = () => {
|
|
58
|
+
if (!emptyFile) {
|
|
59
|
+
emptyFile = join(mkdtempSync(join(tmpdir(), "ph-shell-")), "empty.css");
|
|
60
|
+
writeFileSync(emptyFile, "");
|
|
61
|
+
}
|
|
62
|
+
return emptyFile;
|
|
63
|
+
};
|
|
64
|
+
const isVendor = (id) => id.endsWith("/vendor.css") || !(id.startsWith(".") || id.startsWith("/") || id.startsWith("tailwindcss") || id.startsWith("@powerhousedao/"));
|
|
65
|
+
const CLASS_ATTRIBUTE = /\sclass="([^"]*)"/g;
|
|
66
|
+
/** `entry`, a Tailwind stylesheet, built for the classes in `markup` only:
|
|
67
|
+
* its tokens, reset and rules, without third-party CSS. */
|
|
68
|
+
async function shellCss(entry, markup) {
|
|
69
|
+
const compiler = await compile(readFileSync(entry, "utf8"), {
|
|
70
|
+
base: dirname(entry),
|
|
71
|
+
from: entry,
|
|
72
|
+
onDependency: () => {},
|
|
73
|
+
customCssResolver: (id) => Promise.resolve(isVendor(id) ? empty() : void 0)
|
|
74
|
+
});
|
|
75
|
+
const classes = new Set([...markup.matchAll(CLASS_ATTRIBUTE)].flatMap((m) => m[1].split(/\s+/)));
|
|
76
|
+
const css = compiler.build([...classes].filter(Boolean));
|
|
77
|
+
return optimize(css, {
|
|
78
|
+
file: entry,
|
|
79
|
+
minify: true
|
|
80
|
+
}).code;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/prerender/shell-loader.tsx
|
|
84
|
+
/** Class of the shell's loader; scripts/prerender-shell.ts fades it in. */
|
|
85
|
+
const SHELL_LOADER_CLASS = "ph-shell-loader";
|
|
86
|
+
function ShellLoader() {
|
|
87
|
+
return /* @__PURE__ */ jsx("div", {
|
|
88
|
+
role: "status",
|
|
89
|
+
"aria-label": "Starting Connect",
|
|
90
|
+
className: `${SHELL_LOADER_CLASS} pointer-events-none fixed inset-0 z-10 flex items-center justify-center`,
|
|
91
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
92
|
+
className: "animate-pulse rounded-full bg-background p-4 text-foreground shadow-lg motion-reduce:animate-none",
|
|
93
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
94
|
+
name: "ConnectSmall",
|
|
95
|
+
size: 40
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function CoreShellLoader() {
|
|
101
|
+
return /* @__PURE__ */ jsx("div", {
|
|
102
|
+
role: "status",
|
|
103
|
+
"aria-label": "Starting",
|
|
104
|
+
className: `${SHELL_LOADER_CLASS} pointer-events-none fixed inset-0 z-10 flex items-center justify-center`,
|
|
105
|
+
children: /* @__PURE__ */ jsx("div", { className: "size-5 animate-spin rounded-full border-2 border-core-border border-t-core-muted motion-reduce:animate-none" })
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/prerender/shell.tsx
|
|
110
|
+
async function loadDefaultConfig(variant) {
|
|
111
|
+
primeRuntimeConfig({ connect: {
|
|
112
|
+
...DEFAULT_CONNECT_CONFIG,
|
|
113
|
+
composition: variant === "core" ? [] : void 0
|
|
114
|
+
} });
|
|
115
|
+
registerConnectPlugins(connectPlugins);
|
|
116
|
+
const plugin = (await shellPlugins())[variant];
|
|
117
|
+
await loadConnectPluginUi(plugin ? [{ module: plugin }] : []);
|
|
118
|
+
}
|
|
119
|
+
const connectPlugins = () => import("./plugins-B9VBgzio.js").then((m) => m.connectPlugins);
|
|
120
|
+
/** Each prerendered shell's plugin, whose presence in a composition picks it; core's has none. */
|
|
121
|
+
async function shellPlugins() {
|
|
122
|
+
return Object.fromEntries(Object.entries(await connectPlugins()).flatMap(([module, definition]) => definition.shell ? [[definition.shell, module]] : []));
|
|
123
|
+
}
|
|
124
|
+
/** Renders the route tree at `/` before the reactor is up. `kind` picks the
|
|
125
|
+
* loader: Connect's logo for its chrome, core's spinner otherwise. */
|
|
126
|
+
async function renderShell(variant = "generic", kind = variant) {
|
|
127
|
+
await loadDefaultConfig(variant);
|
|
128
|
+
const [{ routeTree }, { RouterChrome }, routerModule] = await Promise.all([
|
|
129
|
+
import("@powerhousedao/connect/route-tree"),
|
|
130
|
+
import("./route-views-D8I-1PWU.js"),
|
|
131
|
+
import("@powerhousedao/connect-core/router")
|
|
132
|
+
]);
|
|
133
|
+
const store = createPHStore();
|
|
134
|
+
delete globalThis.__TSR_CACHE__;
|
|
135
|
+
const connectRouter = routerModule.createConnectRouter({
|
|
136
|
+
routeTree,
|
|
137
|
+
store,
|
|
138
|
+
history: createMemoryHistory({ initialEntries: ["/"] }),
|
|
139
|
+
InnerWrap: RouterChrome,
|
|
140
|
+
appName: APP_NAME_TOKEN,
|
|
141
|
+
shell: kind === "project",
|
|
142
|
+
pluginUi: getConnectPluginUi()
|
|
143
|
+
});
|
|
144
|
+
routerModule.bindConnectRouter(connectRouter, store);
|
|
145
|
+
await connectRouter.router.load();
|
|
146
|
+
const { appRoute } = routerModule.connectRoutes(routeTree);
|
|
147
|
+
const layoutPending = appRoute.options.pendingComponent;
|
|
148
|
+
const Loader = kind === "generic" ? ShellLoader : kind === "project" && layoutPending ? () => null : CoreShellLoader;
|
|
149
|
+
const errors = [];
|
|
150
|
+
const { prelude } = await prerender(/* @__PURE__ */ jsxs(PHStoreProvider, {
|
|
151
|
+
store,
|
|
152
|
+
children: [/* @__PURE__ */ jsx(RouterProvider, { router: connectRouter.router }), /* @__PURE__ */ jsx(Loader, {})]
|
|
153
|
+
}), {
|
|
154
|
+
progressiveChunkSize: Number.POSITIVE_INFINITY,
|
|
155
|
+
onError: (error) => {
|
|
156
|
+
errors.push(error);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
resetConnectPluginUi(routeTree);
|
|
160
|
+
if (errors.length) throw new AggregateError(errors, "The app shell failed to prerender");
|
|
161
|
+
return await new Response(prelude).text();
|
|
162
|
+
}
|
|
163
|
+
/** A project's shells, one per variant: its route tree rendered at `/`, with
|
|
164
|
+
* CSS that `stylesheet`, its Tailwind entry, builds for the markup's classes. */
|
|
165
|
+
async function renderProjectShells(stylesheet) {
|
|
166
|
+
const shells = {};
|
|
167
|
+
for (const variant of ["generic", "core"]) {
|
|
168
|
+
const markup = shellMarkup(await renderShell(variant, "project"));
|
|
169
|
+
shells[variant] = appShell("project", variant, markup, await shellCss(stylesheet, markup));
|
|
170
|
+
}
|
|
171
|
+
return shells;
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
export { APP_NAME_TOKEN, appShell, renderProjectShells, renderShell, shellCss, shellMarkup, shellPlugins };
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=prerender.js.map
|
|
177
|
+
//# debugId=61013f03-0d8b-51fa-9126-cb3323e95441
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prerender.js","sources":["../src/prerender/app-shell.ts","../src/prerender/shell-css.ts","../src/prerender/shell-loader.tsx","../src/prerender/shell.tsx"],"sourcesContent":["// Turns a rendered shell into what index.html carries: #root's markup and <head>'s CSS.\n\n/** The marker boot.tsx and the project build look for. */\nexport const SHELL_MARKER = \"data-ph-shell\";\n\n/** `generic`: Connect's chrome. `core`: core's views. `project`: a project's routes. */\nexport type AppShellKind = \"generic\" | \"core\" | \"project\";\n\n/** Rendered where the app's name goes. */\nexport const APP_NAME_TOKEN = \"__PH_SHELL_APP_NAME__\";\n\n// The app's name, delimited for the project build to fill in; the default is core's own.\n// Keep in sync with builder-tools' app-shell.ts.\nconst APP_NAME_REGION =\n \"<!--ph-shell:app-name-->Connect<!--/ph-shell:app-name-->\";\n\n// Before first paint: no sidebar in an embed, and the home view hidden off the home path.\nconst GUARD_SCRIPT =\n `(function(){try{var h=document.documentElement;` +\n `var e=new URLSearchParams(location.search).get('embed');` +\n `if(e!==null&&e!=='0'&&e!=='false')h.classList.add('ph-shell-embed');` +\n `var p=location.pathname;` +\n `if(!/\\\\/$/.test(p)||/\\\\/d\\\\//.test(p))h.classList.add('ph-shell-route')` +\n `}catch(x){}})();`;\n\n// The shell renders `/`: off it, its links mark no current page until the app routes.\nconst CURRENT_GUARD_SCRIPT =\n `(function(){if(!document.documentElement.classList.contains('ph-shell-route'))return;` +\n `document.querySelectorAll('[${SHELL_MARKER}] [aria-current]').forEach(function(e){` +\n `e.removeAttribute('aria-current');e.classList.remove('active')})})();`;\n\n// The loader fades in late so fast loads never show it; --ph-shell-t (set when\n// React re-renders the shell) keeps both animations on the navigation's clock.\nconst LOADER_CSS =\n `@keyframes ph-shell-loader-in{from{opacity:0}to{opacity:1}}` +\n `.ph-shell-loader{animation:ph-shell-loader-in .2s ease-in both;animation-delay:calc(.25s + var(--ph-shell-t,0ms))}` +\n `.ph-shell-loader>*{animation-delay:var(--ph-shell-t,0ms)}`;\n\n// The shell renders `/`: off the home path its content view hides until the app routes.\nconst ROUTE_GUARD = `.ph-shell-route [${SHELL_MARKER}] #content-view{visibility:hidden}`;\n\n// Core's header goes in an embed, and its static theme toggle shows the wrong glyph in one theme.\nconst GUARD_CSS: Record<AppShellKind, string> = {\n generic:\n `.ph-shell-embed [${SHELL_MARKER}] #sidebar{display:none}` +\n ROUTE_GUARD +\n LOADER_CSS,\n core:\n `.ph-shell-embed [${SHELL_MARKER}] header{display:none}` +\n `[${SHELL_MARKER}] header button{visibility:hidden}` +\n LOADER_CSS,\n project: ROUTE_GUARD + LOADER_CSS,\n};\n\n// Data-URI images (the login button's PNGs) weigh more than the rest of the\n// shell; a box of their size keeps the layout.\nfunction replaceInlineImages(html: string) {\n return html.replace(/<img\\b[^>]*\\bsrc=\"data:[^\"]*\"[^>]*>/g, (img) => {\n const attr = (name: string) =>\n new RegExp(`\\\\b${name}=\"([^\"]*)\"`).exec(img)?.[1];\n // A hidden variant (e.g. the hover image) needs no box.\n if (/(^| )hidden( |$)/.test(attr(\"class\") ?? \"\")) return \"\";\n const width = attr(\"width\");\n const height = attr(\"height\");\n const size = `${width ? `width:${width}px;` : \"\"}${height ? `height:${height}px;` : \"\"}`;\n return `<span style=\"display:inline-block;${size}\"></span>`;\n });\n}\n\n/** The rendered shell as #root's static markup: no scripts or title, images as\n * boxes, the app's name delimited. */\nexport function shellMarkup(rendered: string) {\n // The router's scroll restoration script is for hydration, and the page keeps\n // its own title until the app's routes set one.\n return replaceInlineImages(\n rendered\n .replace(/<script\\b[^>]*>[\\s\\S]*?<\\/script>/g, \"\")\n .replace(/<title\\b[^>]*>[\\s\\S]*?<\\/title>/g, \"\"),\n ).replaceAll(APP_NAME_TOKEN, APP_NAME_REGION);\n}\n\n/** #root's markup and <head>'s critical CSS (`css`, see shellCss) and guard.\n * `variant` names it for a server that swaps it. */\nexport function appShell(\n kind: AppShellKind,\n variant: \"generic\" | \"core\",\n markup: string,\n css: string,\n) {\n const guard = GUARD_CSS[kind];\n const marker = `${SHELL_MARKER}=\"${variant}\"`;\n return {\n // Inert: clicks and focus wait for the app; a static shell does nothing with them.\n body:\n `<div ${marker} inert style=\"display:contents\">${markup}</div>` +\n `<script ${marker}>${CURRENT_GUARD_SCRIPT}</script>`,\n head:\n `<style ${marker}>${css}${guard}</style>` +\n `<script ${marker}>${GUARD_SCRIPT}</script>`,\n };\n}\n","// The loading screen's CSS: Tailwind builds a stylesheet for just the classes its markup uses.\nimport { compile, optimize } from \"@tailwindcss/node\";\nimport { mkdtempSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nlet emptyFile: string | undefined;\nconst empty = () => {\n if (!emptyFile) {\n emptyFile = join(mkdtempSync(join(tmpdir(), \"ph-shell-\")), \"empty.css\");\n writeFileSync(emptyFile, \"\");\n }\n return emptyFile;\n};\n\n// Plain third-party CSS stays out: a vendor.css, or another package's stylesheet.\nconst isVendor = (id: string) =>\n id.endsWith(\"/vendor.css\") ||\n !(\n id.startsWith(\".\") ||\n id.startsWith(\"/\") ||\n id.startsWith(\"tailwindcss\") ||\n id.startsWith(\"@powerhousedao/\")\n );\n\nconst CLASS_ATTRIBUTE = /\\sclass=\"([^\"]*)\"/g;\n\n/** `entry`, a Tailwind stylesheet, built for the classes in `markup` only:\n * its tokens, reset and rules, without third-party CSS. */\nexport async function shellCss(entry: string, markup: string) {\n const compiler = await compile(readFileSync(entry, \"utf8\"), {\n base: dirname(entry),\n from: entry,\n onDependency: () => {},\n customCssResolver: (id) =>\n Promise.resolve(isVendor(id) ? empty() : undefined),\n });\n const classes = new Set(\n [...markup.matchAll(CLASS_ATTRIBUTE)].flatMap((m) => m[1].split(/\\s+/)),\n );\n const css = compiler.build([...classes].filter(Boolean));\n return optimize(css, { file: entry, minify: true }).code;\n}\n","import { Icon } from \"@powerhousedao/design-system\";\n\n/** Class of the shell's loader; scripts/prerender-shell.ts fades it in. */\nexport const SHELL_LOADER_CLASS = \"ph-shell-loader\";\n\n// The static shell's \"starting\" state: a pulsing Powerhouse logo, CSS only.\nexport function ShellLoader() {\n return (\n <div\n role=\"status\"\n aria-label=\"Starting Connect\"\n className={`${SHELL_LOADER_CLASS} pointer-events-none fixed inset-0 z-10 flex items-center justify-center`}\n >\n <div className=\"animate-pulse rounded-full bg-background p-4 text-foreground shadow-lg motion-reduce:animate-none\">\n <Icon name=\"ConnectSmall\" size={40} />\n </div>\n </div>\n );\n}\n\n// Core's \"starting\" state: a small neutral spinner, no logo.\nexport function CoreShellLoader() {\n return (\n <div\n role=\"status\"\n aria-label=\"Starting\"\n className={`${SHELL_LOADER_CLASS} pointer-events-none fixed inset-0 z-10 flex items-center justify-center`}\n >\n <div className=\"size-5 animate-spin rounded-full border-2 border-core-border border-t-core-muted motion-reduce:animate-none\" />\n </div>\n );\n}\n","// Renders the app shell at `/` before the reactor is up; `pnpm build` writes it to dist/shell.html.\nimport { createPHStore, PHStoreProvider } from \"@powerhousedao/reactor-browser\";\nimport type { AnyRoute } from \"@tanstack/react-router\";\nimport { createMemoryHistory, RouterProvider } from \"@tanstack/react-router\";\nimport { prerender } from \"react-dom/static\";\nimport {\n getConnectPluginUi,\n loadConnectPluginUi,\n registerConnectPlugins,\n resetConnectPluginUi,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { primeRuntimeConfig } from \"@powerhousedao/connect-core/runtime-config\";\nimport type { RuntimePowerhouseConfig } from \"@powerhousedao/shared/connect\";\nimport { DEFAULT_CONNECT_CONFIG } from \"@powerhousedao/shared/connect\";\nimport type { AppShellKind } from \"./app-shell.js\";\nimport { APP_NAME_TOKEN, appShell, shellMarkup } from \"./app-shell.js\";\nimport { shellCss } from \"./shell-css.js\";\nimport { CoreShellLoader, ShellLoader } from \"./shell-loader.js\";\n\nexport { appShell, shellCss, shellMarkup };\nexport type { AppShellKind };\n\nasync function loadDefaultConfig(variant: ShellVariant) {\n // The config file is read at runtime; the shell renders Connect's defaults.\n // Not through the config loader: its cache is the realm's, so a dev server's\n // next render would read the variant primed last.\n primeRuntimeConfig({\n connect: {\n ...DEFAULT_CONNECT_CONFIG,\n // Core's shell is the one for a composition without a plugin that has a shell.\n composition: variant === \"core\" ? [] : undefined,\n },\n } as RuntimePowerhouseConfig);\n registerConnectPlugins(connectPlugins);\n const plugin = (await shellPlugins())[variant];\n await loadConnectPluginUi(plugin ? [{ module: plugin }] : []);\n}\n\nconst connectPlugins = () =>\n import(\"../plugins/index.js\").then((m) => m.connectPlugins);\n\n/** Each prerendered shell's plugin, whose presence in a composition picks it; core's has none. */\nexport async function shellPlugins(): Promise<\n Partial<Record<ShellVariant, string>>\n> {\n return Object.fromEntries(\n Object.entries(await connectPlugins()).flatMap(([module, definition]) =>\n definition.shell ? [[definition.shell, module]] : [],\n ),\n );\n}\n\n/** `generic`: Connect's chrome. `core`: core's views, for a composition without the generic plugin. */\nexport type ShellVariant = \"generic\" | \"core\";\n\nexport { APP_NAME_TOKEN };\n\n/** Renders the route tree at `/` before the reactor is up. `kind` picks the\n * loader: Connect's logo for its chrome, core's spinner otherwise. */\nexport async function renderShell(\n variant: ShellVariant = \"generic\",\n kind: AppShellKind = variant,\n): Promise<string> {\n await loadDefaultConfig(variant);\n // After the config: these modules read it as they evaluate.\n const [{ routeTree }, { RouterChrome }, routerModule] = await Promise.all([\n import(\"@powerhousedao/connect/route-tree\"),\n import(\"../components/route-views.js\"),\n import(\"@powerhousedao/connect-core/router\"),\n ]);\n // No reactor and no drives, as the app is until the reactor is up.\n const store = createPHStore();\n // A server router reuses the tree processed for the last variant; plugins' routes change it.\n delete (globalThis as { __TSR_CACHE__?: unknown }).__TSR_CACHE__;\n const connectRouter = routerModule.createConnectRouter({\n routeTree,\n store,\n history: createMemoryHistory({ initialEntries: [\"/\"] }),\n InnerWrap: RouterChrome,\n // The project's name is only known at its build; scripts/prerender-shell.ts marks this.\n appName: APP_NAME_TOKEN,\n // A project's layout shows its pendingComponent in place of the page.\n shell: kind === \"project\",\n pluginUi: getConnectPluginUi(),\n });\n routerModule.bindConnectRouter(connectRouter, store);\n await connectRouter.router.load();\n // A project layout's own pending view is its loader; core's spinner without one.\n const { appRoute } = routerModule.connectRoutes(routeTree as AnyRoute);\n const layoutPending = appRoute.options.pendingComponent;\n const Loader =\n kind === \"generic\"\n ? ShellLoader\n : kind === \"project\" && layoutPending\n ? () => null\n : CoreShellLoader;\n\n const errors: unknown[] = [];\n const { prelude } = await prerender(\n <PHStoreProvider store={store}>\n <RouterProvider router={connectRouter.router} />\n <Loader />\n </PHStoreProvider>,\n {\n // Inline every boundary; outlined ones need React's runtime to reveal.\n progressiveChunkSize: Number.POSITIVE_INFINITY,\n onError: (error) => {\n errors.push(error);\n },\n },\n );\n // The next variant renders the tree with its own plugins' UI.\n resetConnectPluginUi(routeTree as AnyRoute);\n // A boundary that errored renders its fallback, which is not the shell.\n if (errors.length) {\n throw new AggregateError(errors, \"The app shell failed to prerender\");\n }\n return await new Response(prelude).text();\n}\n\n/** A project's shells, one per variant: its route tree rendered at `/`, with\n * CSS that `stylesheet`, its Tailwind entry, builds for the markup's classes. */\nexport async function renderProjectShells(stylesheet: string) {\n const shells: Partial<Record<ShellVariant, { body: string; head: string }>> =\n {};\n for (const variant of [\"generic\", \"core\"] as const) {\n const markup = shellMarkup(await renderShell(variant, \"project\"));\n const css = await shellCss(stylesheet, markup);\n shells[variant] = appShell(\"project\", variant, markup, css);\n }\n return shells;\n}\n"],"names":[],"mappings":"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","debug_id":"61013f03-0d8b-51fa-9126-cb3323e95441"}
|
|
@@ -1,5 +1,5 @@
|
|
|
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]="0d9ea2f0-19d5-5ebd-9396-34af1dffa9f6")}catch(e){}}();
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/prerendered-shell.tsx
|
|
@@ -29,6 +29,12 @@ function LoadingShell({ Fallback }) {
|
|
|
29
29
|
dangerouslySetInnerHTML: { __html: shellHtml }
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
const Blank = () => null;
|
|
33
|
+
/** The router's pending view: the shell while a cold start's route chunks
|
|
34
|
+
* load, so a lazy layout leaves no blank frame; nothing once released. */
|
|
35
|
+
function ColdStartPending() {
|
|
36
|
+
return /* @__PURE__ */ jsx(LoadingShell, { Fallback: Blank });
|
|
37
|
+
}
|
|
32
38
|
/** Drops the shell once the app shows; later loads use their own fallback. */
|
|
33
39
|
function useReleasePrerenderedShell(released) {
|
|
34
40
|
useEffect(() => {
|
|
@@ -39,7 +45,7 @@ function useReleasePrerenderedShell(released) {
|
|
|
39
45
|
}, [released]);
|
|
40
46
|
}
|
|
41
47
|
//#endregion
|
|
42
|
-
export { useReleasePrerenderedShell as i,
|
|
48
|
+
export { useReleasePrerenderedShell as a, hasPrerenderedShell as i, LoadingShell as n, adoptPrerenderedShell as r, ColdStartPending as t };
|
|
43
49
|
|
|
44
|
-
//# sourceMappingURL=prerendered-shell-
|
|
45
|
-
//# debugId=
|
|
50
|
+
//# sourceMappingURL=prerendered-shell-peKE7AqI.js.map
|
|
51
|
+
//# debugId=0d9ea2f0-19d5-5ebd-9396-34af1dffa9f6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prerendered-shell-peKE7AqI.js","sources":["../src/components/prerendered-shell.tsx"],"sourcesContent":["// The app shell `ph connect build` prerenders into #root. React renders the same\n// markup while the app loads, so the swap to the app has no blank frame.\nimport type { ComponentType, CSSProperties } from \"react\";\nimport { useEffect, useState } from \"react\";\n\n/** Marks the prerendered markup; the build's guard CSS keys on it too. */\nexport const SHELL_MARKER = \"data-ph-shell\";\n\n/** Set on `<html>` by the build's pre-paint guard (scripts/prerender-shell.ts). */\nexport const SHELL_GUARD_CLASSES = [\"ph-shell-route\", \"ph-shell-embed\"];\n\nlet shellHtml: string | undefined;\n\n/** Keeps `root`'s prerendered shell to render until the app shows. */\nexport function adoptPrerenderedShell(root: Element | null) {\n shellHtml = root?.querySelector(`:scope > [${SHELL_MARKER}]`)?.innerHTML;\n}\n\nexport function hasPrerenderedShell() {\n return shellHtml !== undefined;\n}\n\n/** The prerendered shell until the app releases it, else `Fallback`. */\nexport function LoadingShell({ Fallback }: { Fallback: ComponentType }) {\n // A remount restarts CSS animations; this keeps the loader's on the page's clock.\n const [style] = useState(\n () =>\n ({\n display: \"contents\",\n \"--ph-shell-t\": `-${Math.round(performance.now())}ms`,\n }) as CSSProperties,\n );\n if (shellHtml === undefined) return <Fallback />;\n return (\n <div\n {...{ [SHELL_MARKER]: \"\" }}\n inert\n style={style}\n dangerouslySetInnerHTML={{ __html: shellHtml }}\n />\n );\n}\n\nconst Blank = () => null;\n\n/** The router's pending view: the shell while a cold start's route chunks\n * load, so a lazy layout leaves no blank frame; nothing once released. */\nexport function ColdStartPending() {\n return <LoadingShell Fallback={Blank} />;\n}\n\n/** Drops the shell once the app shows; later loads use their own fallback. */\nexport function useReleasePrerenderedShell(released: boolean) {\n useEffect(() => {\n if (!released) return;\n shellHtml = undefined;\n // The pre-paint guard's classes and critical CSS were for the shell only.\n document.documentElement.classList.remove(...SHELL_GUARD_CLASSES);\n for (const style of document.head.querySelectorAll(\n `style[${SHELL_MARKER}]`,\n )) {\n style.remove();\n }\n }, [released]);\n}\n"],"names":[],"mappings":";;;;;;AAMA,MAAa,eAAe;;AAG5B,MAAa,sBAAsB,CAAC,kBAAkB,gBAAgB;AAEtE,IAAI;;AAGJ,SAAgB,sBAAsB,MAAsB;CAC1D,YAAY,MAAM,cAAc,aAAa,aAAa,EAAE,CAAC,EAAE;AACjE;AAEA,SAAgB,sBAAsB;CACpC,OAAO,cAAc,KAAA;AACvB;;AAGA,SAAgB,aAAa,EAAE,YAAyC;CAEtE,MAAM,CAAC,SAAS,gBAEX;EACC,SAAS;EACT,gBAAgB,IAAI,KAAK,MAAM,YAAY,IAAI,CAAC,EAAE;CACpD,EACJ;CACA,IAAI,cAAc,KAAA,GAAW,OAAO,oBAAC,UAAD,CAAW,CAAA;CAC/C,OACE,oBAAC,OAAD;GACS,eAAe;EACtB,OAAA;EACO;EACP,yBAAyB,EAAE,QAAQ,UAAU;CAC9C,CAAA;AAEL;AAEA,MAAM,cAAc;;;AAIpB,SAAgB,mBAAmB;CACjC,OAAO,oBAAC,cAAD,EAAc,UAAU,MAAQ,CAAA;AACzC;;AAGA,SAAgB,2BAA2B,UAAmB;CAC5D,gBAAgB;EACd,IAAI,CAAC,UAAU;EACf,YAAY,KAAA;EAEZ,SAAS,gBAAgB,UAAU,OAAO,GAAG,mBAAmB;EAChE,KAAK,MAAM,SAAS,SAAS,KAAK,iBAChC,SAAS,aAAa,EACxB,GACE,MAAM,OAAO;CAEjB,GAAG,CAAC,QAAQ,CAAC;AACf","debug_id":"0d9ea2f0-19d5-5ebd-9396-34af1dffa9f6"}
|
|
@@ -1,20 +1,21 @@
|
|
|
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 {
|
|
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]="49a9ad17-723c-54d2-972e-fb779ceaa7a8")}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-DkY9PU7c.js";
|
|
5
|
+
import { r as getSharedDeps, t as BrowserPackageManager } from "./package-manager-x_fK8Hzm.js";
|
|
6
|
+
import { r as toast } from "./toast-C6WW-_O-.js";
|
|
4
7
|
import { a as closeWithin, n as watchStoreLockWait, o as configureConnectChannelScheme, s as createConnectSignerConfig } from "./store-lock-Bi3B9VJD.js";
|
|
5
8
|
import { a as resolvePgMajorForRuntime, f as toStoredDocumentsRefused, r as loadPGliteModule } from "./pglite-major-p4_YefAE.js";
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { r as getSharedDeps, t as BrowserPackageManager } from "./package-manager-BkFRzovd.js";
|
|
10
|
-
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-C_477Kr_.js";
|
|
11
|
-
import { t as isRuntimeFlagEnabled } from "./runtime-flag-CT5OKujT.js";
|
|
12
|
-
import { BrowserLocalStorage, DRIVE_DOCUMENT_TYPES, DocumentCache, DocumentChangeType, ReactorBuilder, ReactorClientBuilder, RegistryClient, addDrive, addPHEventHandlers, addRemoteDrive, createAnalyticsStore, getDrives, getFullReactorClient, getPHStore, isDriveAuthError, login, refreshReactorDataClient, setAttachmentService, setDefaultPHGlobalConfig, setDocumentCache, setDriveMetadata, setDrives, setFeatures, setFullReactorClient, setPGliteDB, setPHToast, setPackageDiscoveryService, setReactorClient, setReactorClientModule, setRenown, setSelectedDrive, setSelectedNode, setVetraPackageManager, trackDriveArrival, untilDriveListed, waitForDocumentReady } from "@powerhousedao/reactor-browser";
|
|
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";
|
|
13
12
|
import { ConsoleLogger, logger, setLogLevel as setLogLevel$1 } from "document-model";
|
|
13
|
+
import { getConnectPluginUi } from "@powerhousedao/connect-core/plugins";
|
|
14
14
|
import { createRelationalDb } from "@powerhousedao/shared/processors";
|
|
15
15
|
import { DocumentModelRegistry, DocumentModelResolver, HardenedPGliteDialect, LocalChannelFactory, LocalChannelPortRegistry, PGLITE_IDB_STORAGE_FACTS, ReactorEventTypes, createReactorHostModuleBase } from "@powerhousedao/reactor";
|
|
16
16
|
import { MessageRouter, RPC_PROTOCOL_VERSION, SyncManagerProxy, connectReactorClient, createInspectorProxy, createPortTransport, createReactorEventBusProxy, createRelationalPgliteProxy, createWorkerAdminClient, isFingerprintMismatchReload, postReactorIdentity } from "@powerhousedao/reactor-browser/rpc";
|
|
17
17
|
import { Kysely } from "kysely";
|
|
18
|
+
import { createAppReactorClient, getAppDrives, getRuntimeConfig, planReactorClient, refreshAppDrives } from "@powerhousedao/connect-core/runtime";
|
|
18
19
|
import { createAttachmentClient, createRemoteAttachmentService, createXhrUploadTransport } from "@powerhousedao/reactor-attachments/client";
|
|
19
20
|
import { BrowserKeyStorage, RenownBuilder, RenownCryptoBuilder } from "@renown/sdk";
|
|
20
21
|
import { OpenFeature } from "@openfeature/web-sdk";
|
|
@@ -940,48 +941,6 @@ async function startupOwningStores(startup, namespaces, watchOptions) {
|
|
|
940
941
|
}
|
|
941
942
|
}
|
|
942
943
|
//#endregion
|
|
943
|
-
//#region src/utils/reactor-worker-flag.ts
|
|
944
|
-
const REACTOR_WORKER_QUERY_KEY = "reactorWorker";
|
|
945
|
-
const REACTOR_WORKER_STORAGE_KEY = "ph:reactorWorker";
|
|
946
|
-
function isReactorWorkerEnabled() {
|
|
947
|
-
return isRuntimeFlagEnabled({
|
|
948
|
-
queryKey: REACTOR_WORKER_QUERY_KEY,
|
|
949
|
-
storageKey: REACTOR_WORKER_STORAGE_KEY,
|
|
950
|
-
readConfigFlag: () => getRuntimeConfig().connect.instance?.reactorWorker ?? false
|
|
951
|
-
});
|
|
952
|
-
}
|
|
953
|
-
//#endregion
|
|
954
|
-
//#region src/utils/multi-reactor-flag.ts
|
|
955
|
-
function isMultiReactorEnabled() {
|
|
956
|
-
return getRuntimeConfig().connect.instance?.multiReactor ?? false;
|
|
957
|
-
}
|
|
958
|
-
//#endregion
|
|
959
|
-
//#region src/store/reactor-client-mode.ts
|
|
960
|
-
const MODES = /* @__PURE__ */ new Set([
|
|
961
|
-
"in-process",
|
|
962
|
-
"worker",
|
|
963
|
-
"remote",
|
|
964
|
-
"router"
|
|
965
|
-
]);
|
|
966
|
-
function fromQuery() {
|
|
967
|
-
if (typeof window === "undefined") return void 0;
|
|
968
|
-
try {
|
|
969
|
-
const value = new URLSearchParams(window.location.search).get("reactorClient");
|
|
970
|
-
return value && MODES.has(value) ? value : void 0;
|
|
971
|
-
} catch {
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
function resolveReactorClientMode() {
|
|
976
|
-
const override = fromQuery();
|
|
977
|
-
if (override) return override;
|
|
978
|
-
const configured = getRuntimeConfig().connect.instance?.reactorClient;
|
|
979
|
-
if (configured && MODES.has(configured)) return configured;
|
|
980
|
-
if (isMultiReactorEnabled()) return "router";
|
|
981
|
-
if (isReactorWorkerEnabled()) return "worker";
|
|
982
|
-
return "in-process";
|
|
983
|
-
}
|
|
984
|
-
//#endregion
|
|
985
944
|
//#region src/utils/reactor-worker-url.ts
|
|
986
945
|
/**
|
|
987
946
|
* Stable path of the prebuilt reactor SharedWorker bundle, relative to the
|
|
@@ -1116,95 +1075,6 @@ function subscribeLocalPackageChanges(manager, onChange) {
|
|
|
1116
1075
|
});
|
|
1117
1076
|
}
|
|
1118
1077
|
//#endregion
|
|
1119
|
-
//#region src/store/app-reactor-client.ts
|
|
1120
|
-
const loadMultiReactor = () => import("./multi-reactor-fSKpLBjT.js");
|
|
1121
|
-
/**
|
|
1122
|
-
* Pick the client for the resolved mode:
|
|
1123
|
-
* - `in-process` / `worker`: the local client, router module never loaded.
|
|
1124
|
-
* - `router`: the local reactor plus remote backends.
|
|
1125
|
-
* - `remote`: a remote-only router — a full IReactorClient that proxies to
|
|
1126
|
-
* the Switchboard over GraphQL with NO local reactor (no PGlite).
|
|
1127
|
-
*/
|
|
1128
|
-
async function selectAppReactorClient(params) {
|
|
1129
|
-
if (params.mode === "remote") {
|
|
1130
|
-
setFullReactorClient(void 0);
|
|
1131
|
-
const remote = await buildRemoteOnly(params);
|
|
1132
|
-
setFullReactorClient(remote);
|
|
1133
|
-
return remote;
|
|
1134
|
-
}
|
|
1135
|
-
if (params.mode !== "router") {
|
|
1136
|
-
if (getPHStore()?.fullReactorClient) setFullReactorClient(void 0);
|
|
1137
|
-
return requireModule(params).client;
|
|
1138
|
-
}
|
|
1139
|
-
setFullReactorClient(void 0);
|
|
1140
|
-
const routed = await buildRouter(params);
|
|
1141
|
-
setFullReactorClient(routed);
|
|
1142
|
-
return routed ?? requireModule(params).client;
|
|
1143
|
-
}
|
|
1144
|
-
function requireModule(params) {
|
|
1145
|
-
if (!params.module) throw new Error(`reactorClient mode "${params.mode}" needs a local reactor, but none was built`);
|
|
1146
|
-
return params.module;
|
|
1147
|
-
}
|
|
1148
|
-
/** A Switchboard that cannot answer must not fail boot: list the tab's drives. */
|
|
1149
|
-
async function getAppDrives(client, local) {
|
|
1150
|
-
if (client === local) return getDrives(local);
|
|
1151
|
-
try {
|
|
1152
|
-
return await getDrives(client);
|
|
1153
|
-
} catch (error) {
|
|
1154
|
-
logger.warn("Could not list drives through the router; listing the local reactor's: @error", error);
|
|
1155
|
-
return getDrives(local);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
async function refreshAppDrives(client, local) {
|
|
1159
|
-
if (client === local) return refreshReactorDataClient(client);
|
|
1160
|
-
setDrives(await getAppDrives(client, local));
|
|
1161
|
-
}
|
|
1162
|
-
async function buildRouter(params) {
|
|
1163
|
-
if (!params.remoteDriveUrl) {
|
|
1164
|
-
logger.warn("multiReactor is on but no remote drive URL is configured; using the local reactor only");
|
|
1165
|
-
return;
|
|
1166
|
-
}
|
|
1167
|
-
let multiReactor;
|
|
1168
|
-
try {
|
|
1169
|
-
multiReactor = await (params.loadRouter ?? loadMultiReactor)();
|
|
1170
|
-
} catch (error) {
|
|
1171
|
-
logger.error("Could not load the multi-reactor router: @error", error);
|
|
1172
|
-
return;
|
|
1173
|
-
}
|
|
1174
|
-
const remoteGraphqlUrl = multiReactor.deriveSwitchboardGraphqlUrl(params.remoteDriveUrl);
|
|
1175
|
-
if (!remoteGraphqlUrl) {
|
|
1176
|
-
logger.warn("multiReactor is on but the remote drive URL @url does not parse; using the local reactor only", params.remoteDriveUrl);
|
|
1177
|
-
return;
|
|
1178
|
-
}
|
|
1179
|
-
logger.info("Multi-reactor routing to @url", remoteGraphqlUrl);
|
|
1180
|
-
return multiReactor.buildMultiReactorClient({
|
|
1181
|
-
module: requireModule(params),
|
|
1182
|
-
remoteGraphqlUrl,
|
|
1183
|
-
signer: params.signer,
|
|
1184
|
-
documentModelModules: params.documentModelModules
|
|
1185
|
-
});
|
|
1186
|
-
}
|
|
1187
|
-
/**
|
|
1188
|
-
* The `remote` mode: a remote-only router — a full IReactorClient that proxies
|
|
1189
|
-
* to the Switchboard over GraphQL with NO local backend, so no local reactor
|
|
1190
|
-
* and no PGlite are ever built. A missing/unparseable remote URL is a hard
|
|
1191
|
-
* config error here (unlike `router`, there is no local reactor to fall back
|
|
1192
|
-
* to).
|
|
1193
|
-
*/
|
|
1194
|
-
async function buildRemoteOnly(params) {
|
|
1195
|
-
if (!params.remoteDriveUrl) throw new Error("reactorClient \"remote\" needs a remote drive URL — declare a remote backend / default drive the client can proxy to");
|
|
1196
|
-
const multiReactor = await (params.loadRouter ?? loadMultiReactor)();
|
|
1197
|
-
const remoteGraphqlUrl = multiReactor.deriveSwitchboardGraphqlUrl(params.remoteDriveUrl);
|
|
1198
|
-
if (!remoteGraphqlUrl) throw new Error(`reactorClient "remote": the remote drive URL "${params.remoteDriveUrl}" does not resolve to a Switchboard GraphQL endpoint`);
|
|
1199
|
-
logger.info("Remote reactor client → @url", remoteGraphqlUrl);
|
|
1200
|
-
return multiReactor.buildMultiReactorClient({
|
|
1201
|
-
module: void 0,
|
|
1202
|
-
remoteGraphqlUrl,
|
|
1203
|
-
signer: params.signer,
|
|
1204
|
-
documentModelModules: params.documentModelModules
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
//#endregion
|
|
1208
1078
|
//#region src/store/processor-host-module.ts
|
|
1209
1079
|
var NullAttachmentService = class {
|
|
1210
1080
|
reserve() {
|
|
@@ -1342,11 +1212,12 @@ async function createReactor(localPackage, store) {
|
|
|
1342
1212
|
const runtimeConfig = getRuntimeConfig();
|
|
1343
1213
|
const packageManager = new BrowserPackageManager(phGlobalConfig.routerBasename ?? "", runtimeConfig.packageRegistryUrl ?? null);
|
|
1344
1214
|
setVetraPackageManager(packageManager);
|
|
1345
|
-
|
|
1215
|
+
const releaseRoutes = holdConnectRoutes();
|
|
1216
|
+
await packageManager.init(localPackage, runtimeConfig.localPackage?.version, phGlobalConfig.studioMode, connectConfig.workflowsEnabled, getConnectPluginUi().commonEditors);
|
|
1346
1217
|
const { default: registerBundledPackages } = await import("ph-bundled-packages-virtual");
|
|
1347
1218
|
registerBundledPackages(packageManager);
|
|
1348
1219
|
const remotePackages = runtimeConfig.packages.filter((p) => p.provider !== "local").map((p) => p.version ? `${p.packageName}@${p.version}` : p.packageName);
|
|
1349
|
-
(await packageManager.addPackages(remotePackages)).map((r) => {
|
|
1220
|
+
(await packageManager.addPackages(remotePackages).finally(releaseRoutes)).map((r) => {
|
|
1350
1221
|
if (r.type === "error") console.error(r.error);
|
|
1351
1222
|
});
|
|
1352
1223
|
if (runtimeConfig.connect?.packages?.liveReload) subscribeToPackagesChannel(packageManager);
|
|
@@ -1367,12 +1238,10 @@ async function createReactor(localPackage, store) {
|
|
|
1367
1238
|
renownUrl: phGlobalConfig.renownUrl,
|
|
1368
1239
|
switchboardUrl: phGlobalConfig.switchboardUrl
|
|
1369
1240
|
};
|
|
1370
|
-
const
|
|
1371
|
-
const multiReactor =
|
|
1372
|
-
const
|
|
1373
|
-
|
|
1374
|
-
let reactorClientModule;
|
|
1375
|
-
if (localAsWorker) {
|
|
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);
|
|
1376
1245
|
const packageSpecs = packageManager.getRegistryPackages().map((p) => p.version ? `${p.name}@${p.version}` : p.name);
|
|
1377
1246
|
const registryClient = new RegistryClient(packageManager.cdnUrl ?? "");
|
|
1378
1247
|
const documentModelLoader = { async load(documentType) {
|
|
@@ -1424,7 +1293,6 @@ async function createReactor(localPackage, store) {
|
|
|
1424
1293
|
reloadForWorker(reason, () => window.location.reload());
|
|
1425
1294
|
}
|
|
1426
1295
|
});
|
|
1427
|
-
reactorClientModule = workerClient.reactorClientModule;
|
|
1428
1296
|
const { registerPackages } = workerClient.reactorClientModule;
|
|
1429
1297
|
subscribeLocalPackageChanges(packageManager, () => {
|
|
1430
1298
|
(async () => {
|
|
@@ -1444,10 +1312,11 @@ async function createReactor(localPackage, store) {
|
|
|
1444
1312
|
logger.error("Reactor worker failed to start: @error", error);
|
|
1445
1313
|
throw error;
|
|
1446
1314
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1315
|
+
return workerClient.reactorClientModule;
|
|
1316
|
+
};
|
|
1317
|
+
const { module: reactorClientModule, client: appReactorClient } = await createAppReactorClient({
|
|
1318
|
+
plan,
|
|
1319
|
+
localReactor,
|
|
1451
1320
|
remoteDriveUrl: phGlobalConfig.defaultDrivesUrl,
|
|
1452
1321
|
signer: renown.signer,
|
|
1453
1322
|
documentModelModules: loadedDocumentModels
|
|
@@ -1483,7 +1352,7 @@ async function createReactor(localPackage, store) {
|
|
|
1483
1352
|
setDocumentCache(documentCache);
|
|
1484
1353
|
setRenown(renown);
|
|
1485
1354
|
setFeatures(features);
|
|
1486
|
-
const addsDrives = mode !== "remote";
|
|
1355
|
+
const addsDrives = plan.mode !== "remote";
|
|
1487
1356
|
const defaultDrivesConfig = getDefaultDrives(runtimeConfig);
|
|
1488
1357
|
if (addsDrives && defaultDrivesConfig.length > 0) trackDriveArrival(addDefaultDrivesForNewReactor(defaultDrivesConfig)).catch((error) => console.error("Failed to add default drives:", error));
|
|
1489
1358
|
const remoteUrl = getDriveUrl();
|
|
@@ -1538,5 +1407,5 @@ function getDriveUrl() {
|
|
|
1538
1407
|
//#endregion
|
|
1539
1408
|
export { createReactor as n, clearReactorStorage as t };
|
|
1540
1409
|
|
|
1541
|
-
//# sourceMappingURL=reactor-
|
|
1542
|
-
//# debugId=
|
|
1410
|
+
//# sourceMappingURL=reactor-BmI-D8O-.js.map
|
|
1411
|
+
//# debugId=49a9ad17-723c-54d2-972e-fb779ceaa7a8
|