@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,113 @@
|
|
|
1
|
+
# Override Connect's routes, loading, not found and errors
|
|
2
|
+
|
|
3
|
+
## Override a Connect route
|
|
4
|
+
|
|
5
|
+
Every page Connect shows is a file route in `@powerhousedao/connect`'s `src/routes/` (`node_modules/@powerhousedao/connect/src/routes/` in a project). A project file at the same path replaces Connect's file. Each of Connect's files exports `options`: everything but the component (loader, search params, pending view, title). An override spreads them and sets its own `component`:
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
// hosts/connect/routes/_app/d/$driveSlug.tsx
|
|
9
|
+
import { useDriveRouteData } from "@powerhousedao/connect/layout";
|
|
10
|
+
import { options } from "@powerhousedao/connect/routes/_app/d/$driveSlug";
|
|
11
|
+
import { createFileRoute, Outlet } from "@tanstack/react-router";
|
|
12
|
+
|
|
13
|
+
export const Route = createFileRoute("/_app/d/$driveSlug")({
|
|
14
|
+
...options,
|
|
15
|
+
component: InventoryDrive,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function InventoryDrive() {
|
|
19
|
+
const { drive, folder, documentId } = useDriveRouteData();
|
|
20
|
+
if (!drive) return null;
|
|
21
|
+
// The node route renders the open document in the outlet.
|
|
22
|
+
if (documentId) return <Outlet />;
|
|
23
|
+
return <p>{folder?.name ?? drive.header.name}</p>;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Path | File | What it renders |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| (every page) | `__root.tsx` | The page, the title, the loading shell. Not overridable. |
|
|
30
|
+
| (layout) | `_app.tsx` | The sidebar beside the content; see [Replace the layout](./layout.md#replace-the-layout). |
|
|
31
|
+
| `/` | `_app/index.tsx` | Home: the drives. |
|
|
32
|
+
| `/d/$driveSlug` | `_app/d/$driveSlug.tsx` | The drive: its drive app, or the sign-in gate, around the node route. |
|
|
33
|
+
| `/d/$driveSlug/{-$nodeSlug}` | `_app/d/$driveSlug/{-$nodeSlug}.tsx` | The open document: its editor, or its revision history with `?history`. Nothing on a folder. |
|
|
34
|
+
| `/settings` | `_app/settings.tsx` | The settings page around the shown tab. |
|
|
35
|
+
| `/settings/<tab>` | `_app/settings/<tab>.tsx` | One settings tab. |
|
|
36
|
+
| unknown paths | `_app/$.tsx` | The 404 page. |
|
|
37
|
+
|
|
38
|
+
- `useDriveRouteData()` returns the open `drive`, `folder` and `documentId` from the drive routes' loaders, live.
|
|
39
|
+
- Connect's routes nested under an overridden one stay: the node route renders in an overridden drive route's `<Outlet />`, and the tabs in an overridden settings page's.
|
|
40
|
+
- Drive apps and editors come from packages, not routes. Override a route only to change Connect around them.
|
|
41
|
+
- Without the generic plugin, each of Connect's files shows core's view instead (a header, an index of drives, a directory listing, a JSON view). An override shows the same view either way.
|
|
42
|
+
- `_app.tsx` and `__root.tsx` are not overridden here: a project's `_app.tsx` replaces the layout ([layout.md](./layout.md)), and the root route is Connect's.
|
|
43
|
+
- To hide a route, override it with a `beforeLoad` that throws `notFound()` or `redirect()`.
|
|
44
|
+
|
|
45
|
+
## Loading, not found and errors
|
|
46
|
+
|
|
47
|
+
Connect uses the router's own states: a route's `pendingComponent`, `notFoundComponent` and `errorComponent`. A project sets them on its routes, or on its overrides of Connect's routes (see [Override a Connect route](#override-a-connect-route)). The loading screen is in [layout.md](./layout.md#the-loading-screen).
|
|
48
|
+
|
|
49
|
+
### Slow routes
|
|
50
|
+
|
|
51
|
+
A route whose loader takes longer than its `pendingMs` shows its `pendingComponent`. Connect's drive routes show a "Loading drive…" note on a cold start and keep the open view on warm navigations. An override spreads their `options` and can set its own:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
export const Route = createFileRoute("/_app/d/$driveSlug")({
|
|
55
|
+
...options,
|
|
56
|
+
pendingComponent: DriveSkeleton,
|
|
57
|
+
component: InventoryDrive,
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Not found
|
|
62
|
+
|
|
63
|
+
| What | Where to change it |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| A path no route serves | Override `_app/$.tsx`, spreading its `options`. It renders inside the layout, titled `Not found · <app>`; the URL stays as typed. Its loader waits for packages' routes still loading (up to 10 s), so a deep link to a package's page shows the loading state, not this page. |
|
|
66
|
+
| A drive that isn't listed once drives arrive | `notFoundComponent` on an override of `_app/d/$driveSlug.tsx`; `isDriveNotFound(data)` gives the slug. |
|
|
67
|
+
| A project route's own `notFound()` | That route's `notFoundComponent`. |
|
|
68
|
+
| Anything else | Connect's 404 page. |
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
// hosts/connect/routes/_app/d/$driveSlug.tsx
|
|
72
|
+
import { isDriveNotFound } from "@powerhousedao/connect/router";
|
|
73
|
+
import { options } from "@powerhousedao/connect/routes/_app/d/$driveSlug";
|
|
74
|
+
import type { NotFoundRouteProps } from "@tanstack/react-router";
|
|
75
|
+
|
|
76
|
+
export const Route = createFileRoute("/_app/d/$driveSlug")({
|
|
77
|
+
...options,
|
|
78
|
+
component: InventoryDrive,
|
|
79
|
+
notFoundComponent: ({ data }: NotFoundRouteProps) =>
|
|
80
|
+
isDriveNotFound(data) ? <p>No drive {data.driveSlug}.</p> : <p>Not found.</p>,
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A project route throws `notFound()` the same way:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
export const Route = createFileRoute("/_app/documents/$documentId")({
|
|
88
|
+
loader: async ({ context, params }) => {
|
|
89
|
+
// ...
|
|
90
|
+
throw notFound();
|
|
91
|
+
},
|
|
92
|
+
notFoundComponent: () => <p className="p-6">No such document.</p>,
|
|
93
|
+
component: DocumentSummary,
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Errors
|
|
98
|
+
|
|
99
|
+
A loader or render error shows the route's `errorComponent`, else Connect's error view (with the generic plugin) or core's. It gets `{ error, reset }`; `reset()` retries the route. Connect reports the error to Sentry when Sentry is configured.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
export const Route = createFileRoute("/_app/reports")({
|
|
103
|
+
loader: loadReports,
|
|
104
|
+
errorComponent: ({ error, reset }) => (
|
|
105
|
+
<div role="alert">
|
|
106
|
+
<p>{error.message}</p>
|
|
107
|
+
<button onClick={reset}>Try again</button>
|
|
108
|
+
</div>
|
|
109
|
+
),
|
|
110
|
+
component: Reports,
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Extend Connect from a package
|
|
2
|
+
|
|
3
|
+
## Offer a package's routes
|
|
4
|
+
|
|
5
|
+
A package's `hosts/connect/routes/` also adds routes to every Connect that loads the package, e.g. a Reports page or a settings tab, without code:
|
|
6
|
+
|
|
7
|
+
- Offered: every route file but `_app.tsx` and the files that override Connect's `_app/` routes. Those two only apply to the package's own host. A child of an override joins the loading Connect's route with that id.
|
|
8
|
+
- `ph build` builds them as `./connect-routes` (`dist/browser/connect-routes.js`), in the same build as the package, and sets `connectRoutes: true` in the package's manifest. A module both import, e.g. a store or a React context an editor and a route share, is one chunk, so they share its state. Connect loads the module when it loads a package with the flag, and takes the routes out when the package is removed, replaced or reinstalled.
|
|
9
|
+
- They join the loading Connect's routes by id (`/_app`, `/_app/settings`, `/_app/d/$driveSlug`, ...). A route at an id that Connect already serves is skipped with a warning; `staticData.nav` and `staticData.settings` list them as for a project's routes.
|
|
10
|
+
- A deep link or reload on a package's page waits for the package: Connect holds unknown paths while packages and their routes load (see [Not found](./overrides.md#not-found)).
|
|
11
|
+
- Removing a package while one of its pages is open takes the app home first.
|
|
12
|
+
- Bundled packages (`ph install --local`, `provider: "local"`) register in a production build through the page's import map, as on the dev server.
|
|
13
|
+
- An offered route imports `@powerhousedao/connect-core` (`ContentOutlet`, `useDriveRouteData`, `RouteSelection`, `ModalDialog`), `@tanstack/react-router` and `@powerhousedao/reactor-browser`, which Connect shares with packages. `@powerhousedao/connect` is not shared, so `ph build` fails, naming the file, if an offered route imports it, or reaches a module that does. The rest of the package gets a warning: its build would bundle a copy of the Connect modules it uses, apart from the app's state.
|
|
14
|
+
- The project's own package is the exception: its host build already has its routes.
|
|
15
|
+
|
|
16
|
+
## Register routes from code
|
|
17
|
+
|
|
18
|
+
A package that Connect loads can also register routes from its own module. The registrations live in one registry per page, on `globalThis`, so a package bundled with its own copy of `@powerhousedao/connect-core` still reaches the app. A production build also shares `@powerhousedao/connect-core` and `@tanstack/react-router` through the import map, so the package and Connect use one router.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { registerConnectRoutes } from "@powerhousedao/connect-core/router";
|
|
22
|
+
import { createRoute } from "@tanstack/react-router";
|
|
23
|
+
|
|
24
|
+
// A settings tab; a router already running takes it in.
|
|
25
|
+
registerConnectRoutes(({ settingsRoute }) => [
|
|
26
|
+
createRoute({
|
|
27
|
+
getParentRoute: () => settingsRoute,
|
|
28
|
+
path: "inventory",
|
|
29
|
+
staticData: { settings: { label: "Inventory", order: 50 } },
|
|
30
|
+
component: InventorySettings,
|
|
31
|
+
}),
|
|
32
|
+
]);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- It returns the unregister.
|
|
36
|
+
- A route at a path a route already serves is skipped with a warning.
|
|
37
|
+
- Core's views are styled with Tailwind classes and `theme.css` tokens (`bg-core-bg`, `text-core-fg`, ...). Core ships no compiled CSS: its host builds with Tailwind 4 and imports `@powerhousedao/connect-core/theme.css`, which defines the tokens and makes Tailwind scan core's sources. `@powerhousedao/connect/tailwind.css` does this; see [Styles](./styles-and-branding.md#styles).
|
|
38
|
+
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Pages, sidebar links and settings tabs
|
|
2
|
+
|
|
3
|
+
A project adds pages to Connect with file routes in `hosts/connect/routes/`. A route lists itself in the sidebar, changes the sidebar on its page, adds a settings tab and sets its title through its own options.
|
|
4
|
+
|
|
5
|
+
## Add a page
|
|
6
|
+
|
|
7
|
+
1. Add the router to the project, in the version Connect uses (the `@tanstack/react-router` entry in `@powerhousedao/connect`'s `package.json`):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @tanstack/react-router@1.170.41
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Create a route file. A file in `_app/` renders inside Connect's layout; its route id starts with `/_app`, and the URL does not:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
// hosts/connect/routes/_app/inventory.tsx
|
|
17
|
+
import { useDrives } from "@powerhousedao/reactor-browser";
|
|
18
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
19
|
+
|
|
20
|
+
export const Route = createFileRoute("/_app/inventory")({
|
|
21
|
+
component: Inventory,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function Inventory() {
|
|
25
|
+
const drives = useDrives();
|
|
26
|
+
return <div className="p-6">{drives?.length ?? 0} drives</div>;
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
3. Run `ph connect studio` and open `/inventory`.
|
|
31
|
+
|
|
32
|
+
A file outside `_app/` is a full page, without Connect's layout:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// hosts/connect/routes/status.tsx
|
|
36
|
+
import { useDrives } from "@powerhousedao/reactor-browser";
|
|
37
|
+
import { createFileRoute, Link } from "@tanstack/react-router";
|
|
38
|
+
|
|
39
|
+
export const Route = createFileRoute("/status")({
|
|
40
|
+
component: Status,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function Status() {
|
|
44
|
+
const drives = useDrives();
|
|
45
|
+
return (
|
|
46
|
+
<div className="p-6">
|
|
47
|
+
<h1>{drives?.length ?? 0} drives</h1>
|
|
48
|
+
<Link to="/">Back to Connect</Link>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Rules:
|
|
55
|
+
|
|
56
|
+
- Connect reads routes only from `hosts/connect/routes/`.
|
|
57
|
+
- Core routes are `/`, `/d/$driveSlug/{-$nodeSlug}`, `/settings` with its Appearance and Packages tabs, and the catch-all `$`. They live in `@powerhousedao/connect-core`. A file in `_app/` at a core route's path overrides it; see [Override a Connect route](./overrides.md#override-a-connect-route). Any other route at a core route's URL fails the build.
|
|
58
|
+
- Files and folders starting with `-` are not routes. Use them for shared components.
|
|
59
|
+
- Route groups, `(name)/`, only organize files.
|
|
60
|
+
- Each route is code-split into its own chunk.
|
|
61
|
+
- Inside a route, navigate with the router's `Link` and `useNavigate`. They are typed with the project's routes and Connect's.
|
|
62
|
+
|
|
63
|
+
## Add a sidebar link
|
|
64
|
+
|
|
65
|
+
A route in `_app/` lists itself in the sidebar with `staticData.nav`:
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
// hosts/connect/routes/_app/inventory.tsx
|
|
69
|
+
export const Route = createFileRoute("/_app/inventory")({
|
|
70
|
+
staticData: { nav: { label: "Inventory", icon: BoxIcon, order: 10 } },
|
|
71
|
+
component: Inventory,
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- Links come after the drives, sorted by `order`, then by `label`.
|
|
76
|
+
- `icon` is optional: any component that takes `size` (and `className`), e.g. from `lucide-react`.
|
|
77
|
+
- Routes with path params (`$id`) are not listed: the sidebar cannot fill in the param.
|
|
78
|
+
|
|
79
|
+
## Hide or collapse the sidebar on a page
|
|
80
|
+
|
|
81
|
+
`staticData.sidebar` changes the sidebar for a route and its children:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// hosts/connect/routes/_app/focus.tsx
|
|
85
|
+
export const Route = createFileRoute("/_app/focus")({
|
|
86
|
+
// "hidden" drops the sidebar; "collapsed" keeps only its header and footer.
|
|
87
|
+
staticData: { sidebar: "hidden" },
|
|
88
|
+
component: () => <div className="p-6">No sidebar here.</div>,
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The deepest matched route that sets `sidebar` decides. Embedded mode (`?embed=1`) always hides the sidebar.
|
|
93
|
+
|
|
94
|
+
## Add a settings tab
|
|
95
|
+
|
|
96
|
+
Settings is the page at `/settings`, with one child route per tab. A file in `_app/settings/` with `staticData.settings` adds a tab:
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
// hosts/connect/routes/_app/settings/inventory.tsx
|
|
100
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
101
|
+
|
|
102
|
+
export const Route = createFileRoute("/_app/settings/inventory")({
|
|
103
|
+
staticData: {
|
|
104
|
+
settings: {
|
|
105
|
+
label: "Inventory",
|
|
106
|
+
// Connect's tabs use multiples of 10, from 0 to 90.
|
|
107
|
+
order: 50,
|
|
108
|
+
// Optional: the tab is hidden, and its URL redirects to the first tab, while this is false.
|
|
109
|
+
enabled: (context) => !!context.store.drives?.length,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
component: () => <div>Inventory settings</div>,
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `icon` and `destructive` are optional.
|
|
117
|
+
- The page title becomes `Settings · Inventory · <app>`. The tab needs no `head`.
|
|
118
|
+
- The generic plugin adds its tabs (Package Manager, Default Editors, Danger Zone, About, AI Assistant) as code routes and hides core's (Appearance, Packages); without it, core's are listed. A project file at a tab's path, e.g. `_app/settings/about.tsx`, replaces that tab; it spreads the tab's options from `genericSettingsTabs` (`@powerhousedao/connect/generic`), e.g. `...genericSettingsTabs.about`, to keep its label, icon and order.
|
|
119
|
+
|
|
120
|
+
## Set the page title
|
|
121
|
+
|
|
122
|
+
A route sets the document title with `head`. Connect's titles end with the app name:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
export const Route = createFileRoute("/_app/inventory")({
|
|
126
|
+
head: ({ match }) => ({
|
|
127
|
+
meta: [{ title: `Inventory · ${match.context.appName ?? "Connect"}` }],
|
|
128
|
+
}),
|
|
129
|
+
component: Inventory,
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- The deepest route with a title wins. Without one, the page keeps Connect's: the app name.
|
|
134
|
+
- `head` also receives `loaderData`, e.g. `` title: `${loaderData?.name} · ${appName}` ``.
|
|
135
|
+
- Connect's own titles are in `@powerhousedao/connect-core`'s `src/router/titles.ts`: `<node> · <drive> · <app>`, `Settings · <tab> · <app>`, `Not found · <app>`.
|
|
136
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Styles and branding
|
|
2
|
+
|
|
3
|
+
## Styles
|
|
4
|
+
|
|
5
|
+
A project's `style.css` is the page's one Tailwind build. It imports Connect's Tailwind source rather than Connect's compiled CSS:
|
|
6
|
+
|
|
7
|
+
```css
|
|
8
|
+
/* style.css */
|
|
9
|
+
@layer theme, base, components, external-packages, utilities;
|
|
10
|
+
@import "tailwindcss";
|
|
11
|
+
@import "@powerhousedao/connect/tailwind.css";
|
|
12
|
+
|
|
13
|
+
@theme {
|
|
14
|
+
--color-brand: #f60;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- `@powerhousedao/connect/tailwind.css` brings the design system's tokens, core's theme, Connect's own rules and the `@source` lines for the classes Connect's code uses. Tailwind generates those classes in the project's build, next to the project's own.
|
|
19
|
+
- One build means one copy of each utility, in one `utilities` layer, ordered by Tailwind. Importing a second build (`@powerhousedao/connect/style.css`, or a package's compiled `dist/style.css`) emits the utilities again in source order, so a later `.px-3` beats an earlier `.pl-7`.
|
|
20
|
+
- Third-party CSS (toasts, the JSON viewer, the workflow canvas) comes in through `vendor.css` files: plain rules that Tailwind passes through.
|
|
21
|
+
- Override tokens in `@theme`, and add plain CSS below it. Plain rules outside a `@layer` win over all of Connect's CSS, which is layered; put a rule in `@layer components` to let utilities override it.
|
|
22
|
+
- The design system defines the `dark` variant (`.dark` on `<html>`), so a project's `dark:` classes follow Connect's theme toggle.
|
|
23
|
+
- `ph migrate` rewrites the imports at the top of an existing `style.css` to these and keeps the rest of the file.
|
|
24
|
+
|
|
25
|
+
## Name and icon per host
|
|
26
|
+
|
|
27
|
+
`connect.branding.appName` and `connect.branding.favicon` in `powerhouse.config.json` name the app and set its tab icon for every host. A host overrides either in its `config`:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
// hosts/lab/host.js
|
|
31
|
+
export default {
|
|
32
|
+
name: "lab",
|
|
33
|
+
runner: { module: "@powerhousedao/ph-cli/runners/connect" },
|
|
34
|
+
config: { branding: { appName: "Lab", favicon: "hosts/lab/icon.svg" } },
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- A host's `config` merges over the project's `connect` block field by field, so a host inherits what it doesn't set.
|
|
39
|
+
- `branding.favicon` is a file (`.ico`, `.svg` or `.png`) relative to the project. `ph run lab dev` serves it and `ph run lab build` builds it as `icon.ico`; the built `powerhouse.config.json` leaves the path out. `ph connect build --favicon` wins over it.
|
|
40
|
+
- `ph run lab build` bakes the host's `config` into the build, over `powerhouse.config.json`: the `<title>` and the loading screen take its `branding.appName`, and the build uses its `app.basePath` and `pwa`.
|
|
41
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Types, troubleshooting and upgrading
|
|
2
|
+
|
|
3
|
+
## Types
|
|
4
|
+
|
|
5
|
+
The build generates `.ph/connect-routes.gen.ts`: the route tree of Connect's routes and the project's. It registers the router type, so `createFileRoute` ids, `Link`, `useNavigate`, loader data and search params are typed.
|
|
6
|
+
|
|
7
|
+
- `ph connect build`, `ph connect studio`, `ph connect preview` and `ph build` generate it. `ph connect studio` regenerates it as route files change.
|
|
8
|
+
- The project's `tsconfig.json` includes `.ph/connect-routes.gen.ts` and maps both `"@powerhousedao/connect-core/route-tree"` and `"@powerhousedao/connect/route-tree"` to `["./.ph/connect-routes.gen.ts"]` in `paths`. New projects are scaffolded with them. In an older project, add them by hand, and drop `.ph` from `exclude`. Core's router types name the tree by `@powerhousedao/connect-core/route-tree`; without that path they use core's own routes.
|
|
9
|
+
- Until the first build, both specifiers resolve to core's own tree. Project routes show type errors (unknown route ids) until `ph connect build` or `ph connect studio` has run.
|
|
10
|
+
- `ph connect build` type-checks the routes and fails on errors. `--ignore-type-errors` skips the check.
|
|
11
|
+
- `@tanstack/react-router` must be the version Connect uses. The routes and Connect share one router, and its types come from the project's copy.
|
|
12
|
+
|
|
13
|
+
## Troubleshooting
|
|
14
|
+
|
|
15
|
+
| Symptom | Cause |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `Connect could not mount the routes in hosts/connect/routes/` | A route outside `_app/` collides with one of Connect's, or two project files have one path. The message names the files. |
|
|
18
|
+
| A new routes folder is ignored by a running `ph connect studio` | Connect checks for the folder at startup. Restart it. |
|
|
19
|
+
| `createFileRoute("/_app/x")` is a type error | The tree is not generated yet, or the tsconfig lacks the `route-tree` path. See [Types](#types). |
|
|
20
|
+
| A sidebar link reloads the whole app | It is a plain `href`. Navigate through the router; see [Replace the sidebar](./layout.md#replace-the-sidebar). |
|
|
21
|
+
| A `staticData.nav` route is missing from the sidebar | Its path has a param, or it is not in `_app/`, or a replaced layout does not render `SidebarNavItems`/`useNavRoutes`. |
|
|
22
|
+
| A route's search param is gone after navigating | Only global params survive a navigation. Pass the param in `search` on the link. |
|
|
23
|
+
| A loader sees no drive on a deep link | The drive has not arrived yet; see [Load data](./data-and-navigation.md#load-data). |
|
|
24
|
+
| A class has no effect, e.g. `pl-7` next to `px-3` | `style.css` imports a second Tailwind build, such as `@powerhousedao/connect/style.css`. Import `@powerhousedao/connect/tailwind.css` instead, or run `ph migrate`; see [Styles](./styles-and-branding.md#styles). |
|
|
25
|
+
|
|
26
|
+
## Upgrading
|
|
27
|
+
|
|
28
|
+
`ph migrate` updates a project for this version:
|
|
29
|
+
|
|
30
|
+
- `style.css` imports `@powerhousedao/connect/tailwind.css` instead of `@powerhousedao/design-system/theme.css` and `@powerhousedao/connect/style.css`. The project's own rules stay.
|
|
31
|
+
- `tsconfig.json` includes `.ph/connect-routes.gen.ts`, the generated tree that types the project's routes.
|
|
32
|
+
|
|
33
|
+
Two `@powerhousedao/reactor-browser` types lost a member, which a project that used them updates by hand:
|
|
34
|
+
|
|
35
|
+
- `PHModal` has no `missingPackage` modal.
|
|
36
|
+
- `PHGlobal` has no `revisionHistoryVisible`. `useRevisionHistoryVisible`, `showRevisionHistory` and `hideRevisionHistory` work as before.
|
|
37
|
+
|
|
38
|
+
The generic plugin's UI moved behind the plugin, which a project's routes follow by hand:
|
|
39
|
+
|
|
40
|
+
- `AppLayout`, `ConnectSidebar`, `SidebarDriveItems`, `SidebarNavItems` and `OpenDocument` import from `@powerhousedao/connect/generic`, not `/layout`.
|
|
41
|
+
- `@powerhousedao/connect/route-views` exports only `ConnectRoot`; `Home`, `DriveLayout`, `NodeView`, `DrivePending` and `SettingsPage` import from `/generic`.
|
|
42
|
+
- `generic()`, `genericActive`, `IfPlugin` and `useIsPluginActive` are gone; a plugin's `ui()` provides its views.
|
|
43
|
+
- Connect's About, AI Assistant, Danger Zone, Default Editors and Package Manager tabs are the generic plugin's code routes, so `@powerhousedao/connect/routes/_app/settings/<tab>` no longer exists for them. An override imports the tab's options as `genericSettingsTabs["<tab>"]` from `@powerhousedao/connect/generic` instead; links to these tabs are untyped, so use `useLinkProps({ settings: "<tab>" })`.
|
|
44
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/connect",
|
|
3
3
|
"productName": "Powerhouse-Connect",
|
|
4
|
-
"version": "6.2.3-dev.
|
|
4
|
+
"version": "6.2.3-dev.67",
|
|
5
5
|
"description": "Powerhouse Connect",
|
|
6
6
|
"main": "dist/index.html",
|
|
7
7
|
"type": "module",
|
|
@@ -10,10 +10,16 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
13
|
+
"skills",
|
|
14
|
+
"docs",
|
|
15
|
+
"CUSTOMIZING.md",
|
|
16
|
+
"RUNTIME-CONFIG.md",
|
|
13
17
|
"src/routes",
|
|
14
18
|
"src/router",
|
|
19
|
+
"src/route-tree.ts",
|
|
15
20
|
"src/routeTree.gen.ts",
|
|
16
21
|
"style.css",
|
|
22
|
+
"tailwind.css",
|
|
17
23
|
"fonts.css",
|
|
18
24
|
"nginx.conf",
|
|
19
25
|
"nginx.sh",
|
|
@@ -44,14 +50,30 @@
|
|
|
44
50
|
"types": "./dist/layout.d.ts",
|
|
45
51
|
"import": "./dist/layout.js"
|
|
46
52
|
},
|
|
53
|
+
"./generic": {
|
|
54
|
+
"source": "./src/generic/index.ts",
|
|
55
|
+
"types": "./dist/generic.d.ts",
|
|
56
|
+
"import": "./dist/generic.js"
|
|
57
|
+
},
|
|
47
58
|
"./route-tree": {
|
|
48
|
-
"source": "./src/
|
|
59
|
+
"source": "./src/route-tree.ts",
|
|
49
60
|
"types": "./dist/route-tree.d.ts",
|
|
50
61
|
"import": "./dist/route-tree.js"
|
|
51
62
|
},
|
|
63
|
+
"./prerender": {
|
|
64
|
+
"source": "./src/prerender/shell.tsx",
|
|
65
|
+
"types": "./dist/prerender.d.ts",
|
|
66
|
+
"import": "./dist/prerender.js"
|
|
67
|
+
},
|
|
68
|
+
"./route-views": {
|
|
69
|
+
"source": "./src/route-views/index.ts",
|
|
70
|
+
"types": "./dist/route-views.d.ts",
|
|
71
|
+
"import": "./dist/route-views.js"
|
|
72
|
+
},
|
|
52
73
|
"./routes/*": "./src/routes/*.tsx",
|
|
53
74
|
"./assets/*": "./assets/*",
|
|
54
75
|
"./style.css": "./dist/style.css",
|
|
76
|
+
"./tailwind.css": "./tailwind.css",
|
|
55
77
|
"./fonts.css": "./fonts.css",
|
|
56
78
|
"./package.json": "./package.json"
|
|
57
79
|
},
|
|
@@ -80,26 +102,28 @@
|
|
|
80
102
|
"@openfeature/core": "1.9.1",
|
|
81
103
|
"@openfeature/web-sdk": "1.6.2",
|
|
82
104
|
"@openpanel/web": "^1.4.1",
|
|
83
|
-
"@powerhousedao/config": "6.2.3-dev.
|
|
84
|
-
"@powerhousedao/
|
|
105
|
+
"@powerhousedao/config": "6.2.3-dev.67",
|
|
106
|
+
"@powerhousedao/connect-core": "6.2.3-dev.67",
|
|
107
|
+
"@powerhousedao/design-system": "6.2.3-dev.67",
|
|
85
108
|
"@powerhousedao/document-engineering": "1.40.5",
|
|
86
|
-
"@powerhousedao/host-core": "6.2.3-dev.
|
|
87
|
-
"@powerhousedao/powerhouse-vetra-packages": "6.2.3-dev.
|
|
88
|
-
"@powerhousedao/reactor": "6.2.3-dev.
|
|
89
|
-
"@powerhousedao/reactor-attachments": "6.2.3-dev.
|
|
90
|
-
"@powerhousedao/reactor-browser": "6.2.3-dev.
|
|
91
|
-
"@powerhousedao/reactor-mcp": "6.2.3-dev.
|
|
92
|
-
"@powerhousedao/reactor-router": "6.2.3-dev.
|
|
93
|
-
"@powerhousedao/shared": "6.2.3-dev.
|
|
94
|
-
"@powerhousedao/vetra": "6.2.3-dev.
|
|
95
|
-
"@powerhousedao/workflow": "6.2.3-dev.
|
|
109
|
+
"@powerhousedao/host-core": "6.2.3-dev.67",
|
|
110
|
+
"@powerhousedao/powerhouse-vetra-packages": "6.2.3-dev.67",
|
|
111
|
+
"@powerhousedao/reactor": "6.2.3-dev.67",
|
|
112
|
+
"@powerhousedao/reactor-attachments": "6.2.3-dev.67",
|
|
113
|
+
"@powerhousedao/reactor-browser": "6.2.3-dev.67",
|
|
114
|
+
"@powerhousedao/reactor-mcp": "6.2.3-dev.67",
|
|
115
|
+
"@powerhousedao/reactor-router": "6.2.3-dev.67",
|
|
116
|
+
"@powerhousedao/shared": "6.2.3-dev.67",
|
|
117
|
+
"@powerhousedao/vetra": "6.2.3-dev.67",
|
|
118
|
+
"@powerhousedao/workflow": "6.2.3-dev.67",
|
|
96
119
|
"@privy-io/react-auth": "3.35.0",
|
|
97
120
|
"@rainbow-me/rainbowkit": "^2.2.11",
|
|
98
|
-
"@renown/sdk": "6.2.3-dev.
|
|
121
|
+
"@renown/sdk": "6.2.3-dev.67",
|
|
99
122
|
"@sentry/react": "^10.17.0",
|
|
123
|
+
"@tailwindcss/node": "4.2.2",
|
|
100
124
|
"@tanstack/react-query": "^5.90.2",
|
|
101
125
|
"@tanstack/react-router": "^1.170.41",
|
|
102
|
-
"document-model": "6.2.3-dev.
|
|
126
|
+
"document-model": "6.2.3-dev.67",
|
|
103
127
|
"i18next": "^25.5.3",
|
|
104
128
|
"kysely": "0.28.16",
|
|
105
129
|
"kysely-pglite-dialect": "1.2.0",
|
|
@@ -118,7 +142,6 @@
|
|
|
118
142
|
"@tailwindcss/cli": "4.2.2",
|
|
119
143
|
"@tailwindcss/vite": "4.2.2",
|
|
120
144
|
"@tanstack/react-router-devtools": "1.167.2",
|
|
121
|
-
"@tanstack/router-cli": "1.167.40",
|
|
122
145
|
"@tanstack/router-core": "1.171.34",
|
|
123
146
|
"@tanstack/router-plugin": "1.168.42",
|
|
124
147
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -149,7 +172,7 @@
|
|
|
149
172
|
"test": "vitest --run",
|
|
150
173
|
"dev": "vite dev",
|
|
151
174
|
"build": "pnpm run build:bundle && pnpm run build:css && pnpm run build:shell",
|
|
152
|
-
"build:bundle": "
|
|
175
|
+
"build:bundle": "tsdown",
|
|
153
176
|
"build:css": "pnpm exec tailwindcss -i style.css -o dist/style.css",
|
|
154
177
|
"build:shell": "vite build --config vite.prerender.config.ts --logLevel warn && node scripts/prerender-shell.ts",
|
|
155
178
|
"build:debug": "cross-env PH_DEBUG_BUILD=true vite build",
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
// Writes dist/shell.html (#root's markup)
|
|
2
|
-
import {
|
|
3
|
-
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
1
|
+
// Writes dist/shell{,-core}.html (#root's markup), dist/shell{,-core}-head.html (critical CSS + guard) and shell-plugins.json.
|
|
2
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
4
3
|
import { dirname, join } from "node:path";
|
|
5
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import
|
|
5
|
+
import type * as Prerender from "../src/prerender/shell.tsx";
|
|
7
6
|
|
|
8
7
|
process.env.NODE_ENV = "production";
|
|
9
8
|
|
|
@@ -11,90 +10,42 @@ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
|
11
10
|
const prerenderDir = join(root, ".prerender");
|
|
12
11
|
const distDir = join(root, "dist");
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
const SHELL_MARKER = "data-ph-shell";
|
|
13
|
+
type ShellVariant = "generic" | "core";
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
`if(e!==null&&e!=='0'&&e!=='false')h.classList.add('ph-shell-embed');` +
|
|
22
|
-
`var p=location.pathname;` +
|
|
23
|
-
`if(!/\\/$/.test(p)||/\\/d\\//.test(p))h.classList.add('ph-shell-route')` +
|
|
24
|
-
`}catch(x){}})();`;
|
|
15
|
+
const FILE_PREFIX: Record<ShellVariant, string> = {
|
|
16
|
+
generic: "shell",
|
|
17
|
+
core: "shell-core",
|
|
18
|
+
};
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`.ph-shell-route [${SHELL_MARKER}] #content-view{visibility:hidden}` +
|
|
31
|
-
`@keyframes ph-shell-loader-in{from{opacity:0}to{opacity:1}}` +
|
|
32
|
-
`.ph-shell-loader{animation:ph-shell-loader-in .2s ease-in both;animation-delay:calc(.25s + var(--ph-shell-t,0ms))}` +
|
|
33
|
-
`.ph-shell-loader .animate-pulse{animation-delay:var(--ph-shell-t,0ms)}`;
|
|
20
|
+
const { renderShell, shellMarkup, shellCss, appShell, shellPlugins } =
|
|
21
|
+
(await import(
|
|
22
|
+
pathToFileURL(join(prerenderDir, "shell.js")).href
|
|
23
|
+
)) as typeof Prerender;
|
|
34
24
|
|
|
35
|
-
|
|
36
|
-
// shell; a box of their size keeps the layout.
|
|
37
|
-
function replaceInlineImages(html: string) {
|
|
38
|
-
return html.replace(/<img\b[^>]*\bsrc="data:[^"]*"[^>]*>/g, (img) => {
|
|
39
|
-
const attr = (name: string) =>
|
|
40
|
-
new RegExp(`\\b${name}="([^"]*)"`).exec(img)?.[1];
|
|
41
|
-
// A hidden variant (e.g. the hover image) needs no box.
|
|
42
|
-
if (/(^| )hidden( |$)/.test(attr("class") ?? "")) return "";
|
|
43
|
-
const width = attr("width");
|
|
44
|
-
const height = attr("height");
|
|
45
|
-
const size = `${width ? `width:${width}px;` : ""}${height ? `height:${height}px;` : ""}`;
|
|
46
|
-
return `<span style="display:inline-block;${size}"></span>`;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const { renderShell } = (await import(
|
|
51
|
-
pathToFileURL(join(prerenderDir, "shell.js")).href
|
|
52
|
-
)) as { renderShell: () => Promise<string> };
|
|
53
|
-
|
|
54
|
-
// The router's scroll restoration script is for hydration, and the page keeps
|
|
55
|
-
// its own title until the app's routes set one.
|
|
56
|
-
const markup = replaceInlineImages(
|
|
57
|
-
(await renderShell())
|
|
58
|
-
.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g, "")
|
|
59
|
-
.replace(/<title\b[^>]*>[\s\S]*?<\/title>/g, ""),
|
|
60
|
-
);
|
|
61
|
-
writeFileSync(join(prerenderDir, "shell.html"), markup);
|
|
25
|
+
mkdirSync(distDir, { recursive: true });
|
|
62
26
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
shell: process.platform === "win32",
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
const css = pruneCriticalCss(
|
|
82
|
-
readFileSync(join(prerenderDir, "shell.css"), "utf8"),
|
|
83
|
-
markup,
|
|
84
|
-
GUARD_CSS,
|
|
85
|
-
);
|
|
27
|
+
const plugins = await shellPlugins();
|
|
28
|
+
const variants = ["core", ...Object.keys(plugins)] as ShellVariant[];
|
|
29
|
+
|
|
30
|
+
for (const variant of variants) {
|
|
31
|
+
const name = FILE_PREFIX[variant];
|
|
32
|
+
const markup = shellMarkup(await renderShell(variant));
|
|
33
|
+
// Connect's stylesheet, built for the markup's classes only.
|
|
34
|
+
const css = await shellCss(join(root, "style.css"), markup);
|
|
35
|
+
const shell = appShell(variant, variant, markup, css);
|
|
36
|
+
writeFileSync(join(distDir, `${name}.html`), shell.body);
|
|
37
|
+
writeFileSync(join(distDir, `${name}-head.html`), shell.head);
|
|
38
|
+
console.log(
|
|
39
|
+
`[connect] prerendered the ${variant} app shell: ${markup.length} B markup, ${shell.head.length} B head`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
86
42
|
|
|
87
|
-
|
|
43
|
+
// Each plugin specifier to the shell it picks; core's has none.
|
|
88
44
|
writeFileSync(
|
|
89
|
-
join(distDir, "shell.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
`<style ${SHELL_MARKER}>${css}${GUARD_CSS}</style>` +
|
|
96
|
-
`<script ${SHELL_MARKER}>${GUARD_SCRIPT}</script>`,
|
|
97
|
-
);
|
|
98
|
-
console.log(
|
|
99
|
-
`[connect] prerendered the app shell: ${markup.length} B markup, ${css.length} B critical CSS`,
|
|
45
|
+
join(distDir, "shell-plugins.json"),
|
|
46
|
+
JSON.stringify(
|
|
47
|
+
Object.fromEntries(
|
|
48
|
+
Object.entries(plugins).map(([variant, module]) => [module, variant]),
|
|
49
|
+
),
|
|
50
|
+
),
|
|
100
51
|
);
|