@powerhousedao/connect 6.2.3-dev.105 → 6.2.3-dev.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClearStorageModal-3jgHpxTJ.js → ClearStorageModal-DNn_eBCf.js} +4 -4
- package/dist/{ClearStorageModal-3jgHpxTJ.js.map → ClearStorageModal-DNn_eBCf.js.map} +1 -1
- package/dist/{DebugSettingsModal-DK2Tuqej.js → DebugSettingsModal-CLjp4E_J.js} +4 -4
- package/dist/{DebugSettingsModal-DK2Tuqej.js.map → DebugSettingsModal-CLjp4E_J.js.map} +1 -1
- package/dist/{InspectorModal-afHdGcZ_.js → InspectorModal-C1wIW9Ls.js} +4 -4
- package/dist/{InspectorModal-afHdGcZ_.js.map → InspectorModal-C1wIW9Ls.js.map} +1 -1
- package/dist/{app-loader-BdiNBr_r.js → app-loader-Bj7vK1Tv.js} +4 -4
- package/dist/{app-loader-BdiNBr_r.js.map → app-loader-Bj7vK1Tv.js.map} +1 -1
- package/dist/app-loader-UwYKrd75.js +4 -0
- package/dist/{boot-C9OwZN-C.js → boot-DeQrjh3G.js} +4 -4
- package/dist/{boot-C9OwZN-C.js.map → boot-DeQrjh3G.js.map} +1 -1
- package/dist/{build-info-xKmr-hkl.js → build-info-DnVzHFU6.js} +5 -5
- package/dist/{build-info-xKmr-hkl.js.map → build-info-DnVzHFU6.js.map} +1 -1
- package/dist/{components-FL6IsddU.js → components-CvQDV8IV.js} +4 -4
- package/dist/{components-FL6IsddU.js.map → components-CvQDV8IV.js.map} +1 -1
- package/dist/generic.js +1 -1
- package/dist/{load-CTAUEJfQ.js → load-DKZf8yHz.js} +6 -6
- package/dist/{load-CTAUEJfQ.js.map → load-DKZf8yHz.js.map} +1 -1
- package/dist/{load-runtime-config-cH-gRzfW.js → load-runtime-config-DDKEDjGb.js} +4 -4
- package/dist/{load-runtime-config-cH-gRzfW.js.map → load-runtime-config-DDKEDjGb.js.map} +1 -1
- package/dist/main.js +2 -2
- package/dist/{package-manager-NWzJRRyK.js → package-manager-Bq_IGvx5.js} +6 -6
- package/dist/{package-manager-NWzJRRyK.js.map → package-manager-Bq_IGvx5.js.map} +1 -1
- package/dist/{plugins-DaEBpGLp.js → plugins-BJHHJpIK.js} +4 -4
- package/dist/{plugins-DaEBpGLp.js.map → plugins-BJHHJpIK.js.map} +1 -1
- package/dist/prerender.js +1 -1
- package/dist/{reactor-DWmu76V2.js → reactor-DqvcF9fB.js} +5 -5
- package/dist/{reactor-DWmu76V2.js.map → reactor-DqvcF9fB.js.map} +1 -1
- package/dist/{settings-Bbmxc_va.js → settings-C_Q3majh.js} +6 -6
- package/dist/{settings-Bbmxc_va.js.map → settings-C_Q3majh.js.map} +1 -1
- package/dist/{settings-tabs-Dc1BDN8r.js → settings-tabs-BRjtiM_v.js} +4 -4
- package/dist/{settings-tabs-Dc1BDN8r.js.map → settings-tabs-BRjtiM_v.js.map} +1 -1
- package/dist/start-connect.js +2 -2
- package/dist/{ui-PQSue1GI.js → ui-2WQWmdf-.js} +7 -7
- package/dist/{ui-PQSue1GI.js.map → ui-2WQWmdf-.js.map} +1 -1
- package/package.json +16 -16
- package/dist/app-loader-DmQg4c9o.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-info-
|
|
1
|
+
{"version":3,"file":"build-info-DnVzHFU6.js","sources":["../src/utils/build-info.ts"],"sourcesContent":["import { buildTreeUrl, shortGitSha } from \"@powerhousedao/shared\";\nimport { packageJson } from \"./package-json.js\";\n\nexport { shortGitSha };\n\ndeclare const CONNECT_VERSION: string | undefined;\ndeclare const CONNECT_GIT_SHA: string | undefined;\ndeclare const PH_CONNECT_BUILD_HASH: string | undefined;\ndeclare const CONNECT_PACKAGED_DIST: boolean | undefined;\n\nexport function getVersion(): string {\n if (typeof CONNECT_VERSION !== \"undefined\") return CONNECT_VERSION;\n return (\n process.env.WORKSPACE_VERSION ??\n process.env.npm_package_version ??\n packageJson.version\n );\n}\n\n/** True in the tsdown dist projects install; false in the monorepo app, where Vite bundles the worker. */\nexport function isPackagedConnectDist(): boolean {\n return typeof CONNECT_PACKAGED_DIST !== \"undefined\" && CONNECT_PACKAGED_DIST;\n}\n\nexport function getGitSha(): string {\n if (typeof CONNECT_GIT_SHA !== \"undefined\") return CONNECT_GIT_SHA;\n return process.env.WORKSPACE_GIT_SHA ?? \"unknown\";\n}\n\n/**\n * Build identity baked in at build time (define PH_CONNECT_BUILD_HASH —\n * see builder-tools' connectBuildHashPlugin). Identical builds of the same\n * inputs produce the same hash; any change to the deployed content (Connect\n * version, project config, package list, build options) changes it.\n */\nexport function getBuildHash(): string {\n if (typeof PH_CONNECT_BUILD_HASH !== \"undefined\")\n return PH_CONNECT_BUILD_HASH;\n return \"unknown\";\n}\n\nexport function getGitUrl(): string | null {\n return buildTreeUrl(getGitSha());\n}\n"],"names":[],"mappings":";;;;AAUA,SAAgB,aAAqB;CACS,OAAA;AAM9C;;AAGA,SAAgB,wBAAiC;CAC/C,OAAA;AACF;AAEA,SAAgB,YAAoB;CACU,OAAA;AAE9C;;;;;;;AAQA,SAAgB,eAAuB;CACrC,IAAI,OAAO,0BAA0B,aACnC,OAAO;CACT,OAAO;AACT;AAEA,SAAgB,YAA2B;CACzC,OAAO,aAAa,UAAU,CAAC;AACjC","debug_id":"e9fd8320-9baa-53db-8429-c7c37ecabc1f"}
|
|
@@ -1,8 +1,8 @@
|
|
|
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]="fe163483-a2e0-508f-8f7a-164f6fea30a1")}catch(e){}}();
|
|
3
3
|
import { t as DriveIcon } from "./drive-icon-BIpd8edR.js";
|
|
4
4
|
import { n as setPrerenderingCustomShell, t as AppSkeleton } from "./app-skeleton-CMUP2zaz.js";
|
|
5
|
-
import { i as Analytics, n as App, r as OpenPanel, t as AppLoader } from "./app-loader-
|
|
5
|
+
import { i as Analytics, n as App, r as OpenPanel, t as AppLoader } from "./app-loader-Bj7vK1Tv.js";
|
|
6
6
|
import { t as setBannerShown } from "./preferences-store-DxYAnGCc.js";
|
|
7
7
|
import { t as Root } from "./root-v9fj27sn.js";
|
|
8
8
|
import { n as getConnectRouter, t as Router } from "./router-CWIsjETx.js";
|
|
@@ -117,5 +117,5 @@ const SearchBar = () => {
|
|
|
117
117
|
//#endregion
|
|
118
118
|
export { Analytics, App, AppLoader, AppSkeleton, DotsLoader, DriveIcon, Footer, OpenPanel, Root, Router, SearchBar, getConnectRouter, loadLocalPackage, setPrerenderingCustomShell };
|
|
119
119
|
|
|
120
|
-
//# sourceMappingURL=components-
|
|
121
|
-
//# debugId=
|
|
120
|
+
//# sourceMappingURL=components-CvQDV8IV.js.map
|
|
121
|
+
//# debugId=fe163483-a2e0-508f-8f7a-164f6fea30a1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components-
|
|
1
|
+
{"version":3,"file":"components-CvQDV8IV.js","sources":["../src/utils/openUrl.ts","../src/components/dots-loader.tsx","../src/components/footer.tsx","../src/components/search-bar.tsx"],"sourcesContent":["const openBrowserUrl = (url: string) => window.open(url, \"_blank\");\n\nexport const openUrl = openBrowserUrl;\n","import { useEffect, useState } from \"react\";\n\nexport const DotsLoader = () => {\n const [dots, setDots] = useState(0);\n\n useEffect(() => {\n const id = setInterval(() => {\n setDots((dots) => (dots === 3 ? 0 : dots + 1));\n }, 200);\n return () => {\n clearInterval(id);\n };\n }, []);\n\n return <span>{new Array(dots).fill(\".\").join(\"\")}</span>;\n};\n","import { setBannerShown } from \"../hooks/preferences-store.js\";\nimport { openUrl } from \"@powerhousedao/connect/utils\";\nimport { Icon } from \"@powerhousedao/design-system\";\nimport {\n Footer as DesignSystemFooter,\n FooterLink,\n} from \"@powerhousedao/design-system/connect\";\nimport { showPHModal } from \"@powerhousedao/reactor-browser\";\nimport { Trans } from \"react-i18next\";\n\nexport const Footer = () => {\n return (\n <DesignSystemFooter>\n <FooterLink onClick={() => setBannerShown(true)}>\n <Trans i18nKey=\"footer.cookiePolicy\" />\n </FooterLink>\n <FooterLink onClick={() => showPHModal({ type: \"disclaimer\" })}>\n <Trans i18nKey=\"footer.disclaimer\" />\n </FooterLink>\n <FooterLink\n id=\"ph-logo-link\"\n onClick={() => openUrl(\"https://www.powerhouse.inc/\")}\n >\n <Trans\n i18nKey=\"footer.builtWith\"\n components={{\n icon: (\n <Icon name=\"PowerhouseLogoSmall\" size={16} className=\"mx-1\" />\n ),\n }}\n />\n </FooterLink>\n </DesignSystemFooter>\n );\n};\n","import { Icon } from \"@powerhousedao/design-system\";\nimport type { ConnectSearchBarProps } from \"@powerhousedao/design-system/connect\";\nimport { ConnectSearchBar } from \"@powerhousedao/design-system/connect\";\nimport { useTranslation } from \"react-i18next\";\n\nconst defaultFilterItems: ConnectSearchBarProps[\"filterItems\"] = [\n {\n id: \"project\",\n label: \".project\",\n icon: <Icon name=\"Project\" color=\"#FF6A55\" size={16} />,\n },\n {\n id: \"budget\",\n label: \".budget\",\n icon: <Icon name=\"BarChart\" color=\"#8E55EA\" size={16} />,\n },\n {\n id: \"profile\",\n label: \".profile\",\n icon: <Icon name=\"Person\" color=\"#3E90F0\" size={16} />,\n },\n {\n id: \"legal\",\n label: \".legal\",\n icon: <Icon name=\"Briefcase\" color=\"#4BAB71\" size={16} />,\n },\n {\n id: \"atlas\",\n label: \".Atlas\",\n icon: <Icon name=\"Globe\" color=\"#FF8A00\" size={16} />,\n },\n];\n\nexport const SearchBar = () => {\n const { t } = useTranslation();\n\n return (\n <ConnectSearchBar\n className=\"m-4 shrink-0 bg-muted\"\n placeholder={t(\"searchbar.placeholder\")}\n filterLabel={t(\"searchbar.filterLabel\")}\n filterItems={defaultFilterItems}\n />\n );\n};\n"],"names":["DesignSystemFooter"],"mappings":";;;;;;;;;;;;;;;;AAAA,MAAM,kBAAkB,QAAgB,OAAO,KAAK,KAAK,QAAQ;AAEjE,MAAa,UAAU;;;ACAvB,MAAa,mBAAmB;CAC9B,MAAM,CAAC,MAAM,WAAW,SAAS,CAAC;CAElC,gBAAgB;EACd,MAAM,KAAK,kBAAkB;GAC3B,SAAS,SAAU,SAAS,IAAI,IAAI,OAAO,CAAE;EAC/C,GAAG,GAAG;EACN,aAAa;GACX,cAAc,EAAE;EAClB;CACF,GAAG,CAAC,CAAC;CAEL,OAAO,oBAAC,QAAD,EAAA,UAAO,IAAI,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,EAAE,EAAQ,CAAA;AACzD;;;ACLA,MAAa,eAAe;CAC1B,OACE,qBAACA,UAAD,EAAA,UAAA;EACE,oBAAC,YAAD;GAAY,eAAe,eAAe,IAAI;GAC5C,UAAA,oBAAC,OAAD,EAAO,SAAQ,sBAAuB,CAAA;EAC5B,CAAA;EACZ,oBAAC,YAAD;GAAY,eAAe,YAAY,EAAE,MAAM,aAAa,CAAC;GAC3D,UAAA,oBAAC,OAAD,EAAO,SAAQ,oBAAqB,CAAA;EAC1B,CAAA;EACZ,oBAAC,YAAD;GACE,IAAG;GACH,eAAe,QAAQ,6BAA6B;GAEpD,UAAA,oBAAC,OAAD;IACE,SAAQ;IACR,YAAY,EACV,MACE,oBAAC,MAAD;KAAM,MAAK;KAAsB,MAAM;KAAI,WAAU;IAAQ,CAAA,EAEjE;GACD,CAAA;EACS,CAAA;CACM,EAAA,CAAA;AAExB;;;AC7BA,MAAM,qBAA2D;CAC/D;EACE,IAAI;EACJ,OAAO;EACP,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAU,OAAM;GAAU,MAAM;EAAK,CAAA;CACxD;CACA;EACE,IAAI;EACJ,OAAO;EACP,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAW,OAAM;GAAU,MAAM;EAAK,CAAA;CACzD;CACA;EACE,IAAI;EACJ,OAAO;EACP,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAS,OAAM;GAAU,MAAM;EAAK,CAAA;CACvD;CACA;EACE,IAAI;EACJ,OAAO;EACP,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAY,OAAM;GAAU,MAAM;EAAK,CAAA;CAC1D;CACA;EACE,IAAI;EACJ,OAAO;EACP,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAQ,OAAM;GAAU,MAAM;EAAK,CAAA;CACtD;AACF;AAEA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,MAAM,eAAe;CAE7B,OACE,oBAAC,kBAAD;EACE,WAAU;EACV,aAAa,EAAE,uBAAuB;EACtC,aAAa,EAAE,uBAAuB;EACtC,aAAa;CACd,CAAA;AAEL","debug_id":"fe163483-a2e0-508f-8f7a-164f6fea30a1"}
|
package/dist/generic.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
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]="a22e7ee3-a1b4-5773-abee-29f7a20f6fb3")}catch(e){}}();
|
|
3
3
|
import { a as useDriveRouteData, i as useConnectChrome, n as ModalDialog, o as useNavRoutes, r as SidebarItem, s as useSidebarMode, t as ContentOutlet } from "./layout-Dj3_KscE.js";
|
|
4
4
|
import { r as ErrorBoundary } from "./error-boundary-BsUBww61.js";
|
|
5
|
-
import { _ as SidebarNavItems, a as settingsTab, c as Home, d as NodeView, f as DrivePending, g as SidebarDriveItems, h as Sidebar, i as aiAssistantEnabled, l as HomeAddDriveItem, m as AppLayout, o as ConnectHomeScreen, r as SettingsPage, s as DriveLayout, t as genericSettingsTabs, u as HomeDriveItem, v as useVisibleDrives } from "./settings-tabs-
|
|
5
|
+
import { _ as SidebarNavItems, a as settingsTab, c as Home, d as NodeView, f as DrivePending, g as SidebarDriveItems, h as Sidebar, i as aiAssistantEnabled, l as HomeAddDriveItem, m as AppLayout, o as ConnectHomeScreen, r as SettingsPage, s as DriveLayout, t as genericSettingsTabs, u as HomeDriveItem, v as useVisibleDrives } from "./settings-tabs-BRjtiM_v.js";
|
|
6
6
|
import { n as EditorLoader } from "./document-editor-container-Dkk87_q1.js";
|
|
7
7
|
import { Suspense, lazy } from "react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1,13 +1,13 @@
|
|
|
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 { t as loadRuntimeConfig } from "./load-runtime-config-
|
|
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]="37291a23-7678-5c88-b278-83c0509634df")}catch(e){}}();
|
|
3
|
+
import { t as loadRuntimeConfig } from "./load-runtime-config-DDKEDjGb.js";
|
|
4
4
|
import { r as connectConfig } from "./connect.config-DL9nKtlW.js";
|
|
5
|
-
import { t as getBuildHash } from "./build-info-
|
|
5
|
+
import { t as getBuildHash } from "./build-info-DnVzHFU6.js";
|
|
6
6
|
import { r as setUser } from "./sentry-Cuc_Nbba.js";
|
|
7
7
|
import "./i18n-D9WYPgk9.js";
|
|
8
8
|
import { a as detectMigrationMajor, o as detectReactorPgMajor } from "./connection-state-0ippUGEC.js";
|
|
9
9
|
import { n as seedPendingPgVersion } from "./pglite-seed-CZsMNsV8.js";
|
|
10
|
-
import { n as createReactor } from "./reactor-
|
|
10
|
+
import { n as createReactor } from "./reactor-DqvcF9fB.js";
|
|
11
11
|
import { useEffect } from "react";
|
|
12
12
|
import { initTheme, useUser } from "@powerhousedao/reactor-browser";
|
|
13
13
|
import { logger } from "document-model";
|
|
@@ -129,5 +129,5 @@ async function loadComponent(localPackage, store) {
|
|
|
129
129
|
//#endregion
|
|
130
130
|
export { loadComponent };
|
|
131
131
|
|
|
132
|
-
//# sourceMappingURL=load-
|
|
133
|
-
//# debugId=
|
|
132
|
+
//# sourceMappingURL=load-DKZf8yHz.js.map
|
|
133
|
+
//# debugId=37291a23-7678-5c88-b278-83c0509634df
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-
|
|
1
|
+
{"version":3,"file":"load-DKZf8yHz.js","sources":["../src/hooks/utils.ts","../src/hooks/useCheckLatestVersion.ts","../src/store/user.ts","../src/components/load.tsx"],"sourcesContent":["import { getBuildHash } from \"../utils/build-info.js\";\n\nexport const isMac = window.navigator.appVersion.includes(\"Mac\");\n\nexport interface BuildHashStatus {\n /** Hash baked into the running build. */\n currentHash: string;\n /** Hash the server is currently serving. */\n deployedHash: string;\n /** true when the running build matches what the server serves. */\n isCurrent: boolean;\n}\n\n/**\n * Same-origin build-identity probe. The build bakes a hash of the inputs that\n * determine the deployed content into the bundle (define\n * `PH_CONNECT_BUILD_HASH`, see builder-tools' connectBuildHashPlugin) and\n * emits `build-hash.json` next to the app (served no-cache). Comparing the\n * two tells us whether the server is serving a different build than the one\n * this page was loaded from — the reliable \"a new deploy went out\" signal.\n * Unlike the old GitHub-raw version check it works on localhost (it compares\n * against what the origin actually serves, not a remote branch head) and\n * needs no network beyond the app's own origin.\n *\n * Returns null when there is nothing to compare: dev/studio builds (no hash\n * baked), a server predating `build-hash.json`, an offline fetch, or a\n * malformed body.\n */\nexport const getBuildHashStatus = async (): Promise<BuildHashStatus | null> => {\n const currentHash = getBuildHash();\n if (!currentHash || currentHash === \"unknown\") return null;\n try {\n const result = await fetch(`${import.meta.env.BASE_URL}build-hash.json`, {\n cache: \"no-cache\",\n });\n if (!result.ok) return null;\n const data = (await result.json()) as { hash?: unknown };\n if (typeof data.hash !== \"string\" || !data.hash) return null;\n return {\n currentHash,\n deployedHash: data.hash,\n isCurrent: data.hash === currentHash,\n };\n } catch {\n return null;\n }\n};\n","import { connectConfig } from \"@powerhousedao/connect/config\";\nimport { getBuildHashStatus } from \"./utils.js\";\nimport { logger } from \"document-model\";\nimport { useEffect } from \"react\";\n\n// Session-scoped guard: records the deployed hash this tab already reloaded\n// for, so a broken or rolling deploy (server hash keeps changing under us)\n// cannot turn the tab into a reload loop. Cleared implicitly with the tab.\nconst RELOADED_FOR_KEY = \"ph-reloaded-for-build-hash\";\n\n/**\n * Drop the service worker's stale caches (precache + the NetworkFirst shell\n * cache) before reloading onto a new deploy, so the post-reload navigation\n * is answered from the network / fresh build instead of leftovers of the\n * build we are leaving. Best-effort: if the Caches API is unavailable or a\n * delete fails, the reload still picks up the new shell (the navigation\n * route is NetworkFirst).\n */\nasync function clearStaleCaches(): Promise<void> {\n try {\n if (!(\"caches\" in window)) return;\n const keys = await window.caches.keys();\n await Promise.all(\n keys\n .filter((key) => key.includes(\"precache\") || key.includes(\"ph-shell\"))\n .map((key) => window.caches.delete(key)),\n );\n } catch (error) {\n logger.warn(\n \"Failed to clear stale caches before update reload @error\",\n error,\n );\n }\n}\n\n/**\n * Detects that the server is serving a different build than the one this\n * page was loaded from (a new deploy) and reloads onto it — once per session\n * per deployed hash. Checked on mount and whenever the tab returns to the\n * foreground, so a deploy that lands while the tab sits open is picked up on\n * the next focus without a manual reload. The in-tab \"new version available\"\n * service-worker prompt (ServiceWorkerUpdatePrompt) remains the opt-in path\n * for workers that are waiting but not yet controlling.\n */\nexport const useCheckLatestVersion = () => {\n useEffect(() => {\n if (\n import.meta.env.MODE === \"development\" ||\n connectConfig.studioMode ||\n !connectConfig.warnOutdatedApp\n ) {\n return;\n }\n\n const checkBuildHash = async () => {\n const status = await getBuildHashStatus();\n if (!status || status.isCurrent) return;\n\n const reloadedFor = window.sessionStorage.getItem(RELOADED_FOR_KEY);\n if (reloadedFor === status.deployedHash) return;\n window.sessionStorage.setItem(RELOADED_FOR_KEY, status.deployedHash);\n\n logger.info(\n \"New deploy detected — reloading from build @currentHash to @deployedHash\",\n status.currentHash,\n status.deployedHash,\n );\n await clearStaleCaches();\n window.location.reload();\n };\n\n void checkBuildHash();\n const onVisibilityChange = () => {\n if (document.visibilityState === \"visible\") void checkBuildHash();\n };\n document.addEventListener(\"visibilitychange\", onVisibilityChange);\n return () => {\n document.removeEventListener(\"visibilitychange\", onVisibilityChange);\n };\n }, []);\n};\n","import { useUser } from \"@powerhousedao/reactor-browser\";\nimport type { User as SentryUser } from \"@sentry/react\";\nimport { useEffect } from \"react\";\nimport { setUser as setSentryUser } from \"../services/sentry.js\";\n\nexport function useSetSentryUser() {\n const user = useUser();\n useEffect(() => {\n let sentryUser: SentryUser | null = null;\n if (user) {\n // saves the user info except the credential\n const { credential: _credential, ...rest } = user;\n sentryUser = { id: rest.did, username: rest.ens?.name, ...rest };\n }\n setSentryUser(sentryUser);\n }, [user]);\n}\n","import { useCheckLatestVersion } from \"@powerhousedao/connect/hooks\";\nimport \"@powerhousedao/connect/i18n\";\nimport { createReactor, useSetSentryUser } from \"@powerhousedao/connect/store\";\nimport {\n detectMigrationMajor,\n detectReactorPgMajor,\n seedPendingPgVersion,\n} from \"@powerhousedao/connect/utils\";\nimport type { PHStore } from \"@powerhousedao/reactor-browser\";\nimport { initTheme } from \"@powerhousedao/reactor-browser\";\nimport type { DocumentModelLib } from \"document-model\";\nimport { type ReactNode } from \"react\";\nimport { loadRuntimeConfig } from \"../load-runtime-config.js\";\n\nexport async function loadComponent(\n localPackage: DocumentModelLib | Promise<DocumentModelLib> | undefined,\n store: PHStore,\n) {\n await seedPendingPgVersion();\n await Promise.all([detectReactorPgMajor(), detectMigrationMajor()]);\n await loadRuntimeConfig();\n await createReactor(await localPackage, store);\n return {\n default: ({ children }: { children?: ReactNode }) => {\n initTheme();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useSetSentryUser();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useCheckLatestVersion();\n return children;\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAEqB,OAAO,UAAU,WAAW,SAAS,KAAK;;;;;;;;;;;;;;;;AA0B/D,MAAa,qBAAqB,YAA6C;CAC7E,MAAM,cAAc,aAAa;CACjC,IAAI,CAAC,eAAe,gBAAgB,WAAW,OAAO;CACtD,IAAI;EACF,MAAM,SAAS,MAAM,MAAM,GAAG,YAAY,IAAI,SAAS,kBAAkB,EACvE,OAAO,WACT,CAAC;EACD,IAAI,CAAC,OAAO,IAAI,OAAO;EACvB,MAAM,OAAQ,MAAM,OAAO,KAAK;EAChC,IAAI,OAAO,KAAK,SAAS,YAAY,CAAC,KAAK,MAAM,OAAO;EACxD,OAAO;GACL;GACA,cAAc,KAAK;GACnB,WAAW,KAAK,SAAS;EAC3B;CACF,QAAQ;EACN,OAAO;CACT;AACF;;;ACtCA,MAAM,mBAAmB;;;;;;;;;AAUzB,eAAe,mBAAkC;CAC/C,IAAI;EACF,IAAI,EAAE,YAAY,SAAS;EAC3B,MAAM,OAAO,MAAM,OAAO,OAAO,KAAK;EACtC,MAAM,QAAQ,IACZ,KACG,QAAQ,QAAQ,IAAI,SAAS,UAAU,KAAK,IAAI,SAAS,UAAU,CAAC,CAAC,CACrE,KAAK,QAAQ,OAAO,OAAO,OAAO,GAAG,CAAC,CAC3C;CACF,SAAS,OAAO;EACd,OAAO,KACL,4DACA,KACF;CACF;AACF;;;;;;;;;;AAWA,MAAa,8BAA8B;CACzC,gBAAgB;EACd,IACE,YAAY,IAAI,SAAS,iBACzB,cAAc,cACd,CAAC,cAAc,iBAEf;EAGF,MAAM,iBAAiB,YAAY;GACjC,MAAM,SAAS,MAAM,mBAAmB;GACxC,IAAI,CAAC,UAAU,OAAO,WAAW;GAGjC,IADoB,OAAO,eAAe,QAAQ,gBACpC,MAAM,OAAO,cAAc;GACzC,OAAO,eAAe,QAAQ,kBAAkB,OAAO,YAAY;GAEnE,OAAO,KACL,4EACA,OAAO,aACP,OAAO,YACT;GACA,MAAM,iBAAiB;GACvB,OAAO,SAAS,OAAO;EACzB;EAEA,eAAoB;EACpB,MAAM,2BAA2B;GAC/B,IAAI,SAAS,oBAAoB,WAAW,eAAoB;EAClE;EACA,SAAS,iBAAiB,oBAAoB,kBAAkB;EAChE,aAAa;GACX,SAAS,oBAAoB,oBAAoB,kBAAkB;EACrE;CACF,GAAG,CAAC,CAAC;AACP;;;AC3EA,SAAgB,mBAAmB;CACjC,MAAM,OAAO,QAAQ;CACrB,gBAAgB;EACd,IAAI,aAAgC;EACpC,IAAI,MAAM;GAER,MAAM,EAAE,YAAY,aAAa,GAAG,SAAS;GAC7C,aAAa;IAAE,IAAI,KAAK;IAAK,UAAU,KAAK,KAAK;IAAM,GAAG;GAAK;EACjE;EACA,QAAc,UAAU;CAC1B,GAAG,CAAC,IAAI,CAAC;AACX;;;ACFA,eAAsB,cACpB,cACA,OACA;CACA,MAAM,qBAAqB;CAC3B,MAAM,QAAQ,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,CAAC;CAClE,MAAM,kBAAkB;CACxB,MAAM,cAAc,MAAM,cAAc,KAAK;CAC7C,OAAO,EACL,UAAU,EAAE,eAAyC;EACnD,UAAU;EAEV,iBAAiB;EAEjB,sBAAsB;EACtB,OAAO;CACT,EACF;AACF","debug_id":"37291a23-7678-5c88-b278-83c0509634df"}
|
|
@@ -1,8 +1,8 @@
|
|
|
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]="e9f160dd-1837-56fe-bf37-5027c2394110")}catch(e){}}();
|
|
3
3
|
import { loadRuntimeConfig } from "@powerhousedao/connect-core/runtime-config";
|
|
4
4
|
//#region src/load-runtime-config.ts
|
|
5
|
-
const connectPlugins = () => import("./plugins-
|
|
5
|
+
const connectPlugins = () => import("./plugins-BJHHJpIK.js").then((m) => m.connectPlugins);
|
|
6
6
|
/** Core's loader, with Connect's built-in plugins for the composition. */
|
|
7
7
|
function loadRuntimeConfig$1() {
|
|
8
8
|
return loadRuntimeConfig({ plugins: connectPlugins });
|
|
@@ -10,5 +10,5 @@ function loadRuntimeConfig$1() {
|
|
|
10
10
|
//#endregion
|
|
11
11
|
export { loadRuntimeConfig$1 as t };
|
|
12
12
|
|
|
13
|
-
//# sourceMappingURL=load-runtime-config-
|
|
14
|
-
//# debugId=
|
|
13
|
+
//# sourceMappingURL=load-runtime-config-DDKEDjGb.js.map
|
|
14
|
+
//# debugId=e9f160dd-1837-56fe-bf37-5027c2394110
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-runtime-config-
|
|
1
|
+
{"version":3,"file":"load-runtime-config-DDKEDjGb.js","sources":["../src/load-runtime-config.ts"],"sourcesContent":["import { loadRuntimeConfig as loadCoreRuntimeConfig } from \"@powerhousedao/connect-core/runtime-config\";\n\n// The built-ins: a declared composition's transform the config, and the active\n// ones' UI loads (every one's without a composition).\nconst connectPlugins = () =>\n import(\"./plugins/index.js\").then((m) => m.connectPlugins);\n\n/** Core's loader, with Connect's built-in plugins for the composition. */\nexport function loadRuntimeConfig() {\n return loadCoreRuntimeConfig({ plugins: connectPlugins });\n}\n"],"names":["loadRuntimeConfig","loadCoreRuntimeConfig"],"mappings":";;;;AAIA,MAAM,uBACJ,OAAO,wBAAqB,CAAC,MAAM,MAAM,EAAE,cAAc;;AAG3D,SAAgBA,sBAAoB;CAClC,OAAOC,kBAAsB,EAAE,SAAS,eAAe,CAAC;AAC1D","debug_id":"e9f160dd-1837-56fe-bf37-5027c2394110"}
|
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
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]="1f52a123-ef3c-5452-bdfa-b05d09bb17c0")}catch(e){}}();
|
|
3
|
-
import { t as bootConnect } from "./boot-
|
|
3
|
+
import { t as bootConnect } from "./boot-DeQrjh3G.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region main.tsx
|
|
6
6
|
const root = await bootConnect();
|
|
7
7
|
if (root) {
|
|
8
|
-
const { AppLoader } = await import("./app-loader-
|
|
8
|
+
const { AppLoader } = await import("./app-loader-UwYKrd75.js");
|
|
9
9
|
root.render(/* @__PURE__ */ jsx(AppLoader, {}));
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
@@ -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]="e760bea5-678f-545c-aa5f-765c61f486ac")}catch(e){}}();
|
|
3
3
|
import { t as refreshPwaManifestLink } from "./pwa-manifest-link-DNwWvnLV.js";
|
|
4
4
|
import { holdConnectRoutes, registerPackageRoutes } from "@powerhousedao/connect-core/router";
|
|
5
5
|
import { BrowserLocalStorage } from "@powerhousedao/reactor-browser";
|
|
@@ -229,14 +229,14 @@ var BrowserPackageManager = class {
|
|
|
229
229
|
this.addLocalPackage(common.manifest.name, genericChrome ? common : {
|
|
230
230
|
...common,
|
|
231
231
|
editors: []
|
|
232
|
-
}, "6.2.3-dev.
|
|
232
|
+
}, "6.2.3-dev.106");
|
|
233
233
|
if (studioMode) {
|
|
234
234
|
const vetra = await import("@powerhousedao/vetra");
|
|
235
|
-
this.addLocalPackage(vetra.manifest.name, vetra, "6.2.3-dev.
|
|
235
|
+
this.addLocalPackage(vetra.manifest.name, vetra, "6.2.3-dev.106");
|
|
236
236
|
}
|
|
237
237
|
if (workflowsEnabled) {
|
|
238
238
|
const workflow = await import("@powerhousedao/workflow");
|
|
239
|
-
this.addLocalPackage(workflow.manifest.name, workflow, "6.2.3-dev.
|
|
239
|
+
this.addLocalPackage(workflow.manifest.name, workflow, "6.2.3-dev.106");
|
|
240
240
|
}
|
|
241
241
|
if (localPackage) this.updateLocalPackage(localPackage, localPackageVersion);
|
|
242
242
|
for (const packageName of this.#storage.keys()) {
|
|
@@ -546,5 +546,5 @@ var BrowserPackageManager = class {
|
|
|
546
546
|
//#endregion
|
|
547
547
|
export { pageSharedImports as i, sharedDepMismatchWarnings as n, getSharedDeps as r, BrowserPackageManager as t };
|
|
548
548
|
|
|
549
|
-
//# sourceMappingURL=package-manager-
|
|
550
|
-
//# debugId=
|
|
549
|
+
//# sourceMappingURL=package-manager-Bq_IGvx5.js.map
|
|
550
|
+
//# debugId=e760bea5-678f-545c-aa5f-765c61f486ac
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager-NWzJRRyK.js","sources":["../src/shared-deps.ts","../src/utils/pwa-idb.ts","../src/package-manager.ts"],"sourcesContent":["import {\n EXTERNALIZABLE_SHARED_SPECIFIERS,\n resolveDynamicBaseUrl,\n} from \"@powerhousedao/shared/connect\";\n\n// Set by `ph connect build`, and by a dev server that serves a prebuilt\n// vendor: the content-hashed shared-deps module URL.\ndeclare const PH_CONNECT_SHARED_DEPS_URL: string | undefined;\n\nfunction builtSharedDepsUrl(): string | undefined {\n return typeof PH_CONNECT_SHARED_DEPS_URL !== \"undefined\"\n ? PH_CONNECT_SHARED_DEPS_URL\n : undefined;\n}\n\n/**\n * The shared-deps module URL: this build's hashed copy, else the stable path.\n * Null on a dev server without a vendor, where the request could only 404.\n */\nexport function sharedDepsModuleUrl(\n runtimeBase: string,\n built: string | undefined,\n dev: boolean,\n): string | null {\n if (built) return resolveDynamicBaseUrl(built, runtimeBase);\n return dev ? null : `${runtimeBase}__vendor__/shared-deps.js`;\n}\n\nexport type SharedDeps = {\n imports: Record<string, string>;\n versions: Record<string, string>;\n};\n\n/**\n * Resolve the vendor's import-map values to absolute URLs: the\n * dynamic-base placeholder (present in dynamic-base builds) is replaced\n * with the runtime base — which `import.meta.env.BASE_URL` already is,\n * since the dynamic-base plugin rewrites it to the resolved base — and\n * the result is made absolute against the page origin. Absolute URLs are\n * what the worker needs: its imports have no document context, so\n * relative or placeholder-based values would not resolve there.\n */\nexport function normalizeVendorImports(\n rawImports: Record<string, string>,\n runtimeBase: string,\n): Record<string, string> {\n // `location` is a browser global; the fallback keeps the helper usable\n // from node-based tests, where no origin exists.\n const origin =\n (globalThis as { location?: Location }).location?.origin ??\n \"http://localhost\";\n return Object.fromEntries(\n Object.entries(rawImports).map(([spec, value]) => [\n spec,\n new URL(resolveDynamicBaseUrl(value, runtimeBase), origin).href,\n ]),\n );\n}\n\nlet cached: Promise<SharedDeps | null> | null = null;\n\n/**\n * The vendor's shared-deps table: import-map entries for the shared\n * dependency set plus the resolved version of every shared package in this\n * build. Fails soft (`null`) when the vendor is not present (dev without\n * a prebuilt vendor, or a `PH_CONNECT_VENDOR=0` build) — callers treat that\n * as \"no sharing\".\n * The promise is cached: the vendor table is immutable per build.\n */\nexport function getSharedDeps(): Promise<SharedDeps | null> {\n cached ??= (async () => {\n const url = sharedDepsModuleUrl(\n import.meta.env.BASE_URL,\n builtSharedDepsUrl(),\n import.meta.env.DEV,\n );\n if (url === null) return null;\n try {\n const mod = (await import(/* @vite-ignore */ url)) as {\n imports: Record<string, string>;\n versions: Record<string, string>;\n };\n return {\n imports: normalizeVendorImports(mod.imports, import.meta.env.BASE_URL),\n versions: mod.versions,\n };\n } catch {\n return null;\n }\n })();\n return cached;\n}\n\n/** The shared-dep entries of an import map (exact and trailing-slash), as absolute URLs. */\nexport function sharedImportsFromImportMap(\n importMapJson: string | null | undefined,\n pageUrl: string,\n): Record<string, string> {\n let imports: Record<string, string> = {};\n try {\n imports =\n (\n JSON.parse(importMapJson ?? \"{}\") as {\n imports?: Record<string, string>;\n }\n ).imports ?? {};\n } catch {\n return {};\n }\n const isShared = (key: string) => {\n const spec = key.endsWith(\"/\") ? key.slice(0, -1) : key;\n return EXTERNALIZABLE_SHARED_SPECIFIERS.some(\n (shared) => spec === shared || spec.startsWith(`${shared}/`),\n );\n };\n return Object.fromEntries(\n Object.entries(imports)\n .filter(([key]) => isShared(key))\n .map(([key, url]) => [key, new URL(url, pageUrl).href]),\n );\n}\n\n/** Without a vendor table, dev's import map points the shared deps at shims a worker can import. */\nexport function pageSharedImports(): Record<string, string> {\n const script = document.querySelector('script[type=\"importmap\"]');\n return sharedImportsFromImportMap(script?.textContent, window.location.href);\n}\n","import {\n PWA_IDB_KEY,\n PWA_IDB_NAME,\n PWA_IDB_STORE,\n PWA_IDB_VERSION,\n type PHConnectPwa,\n type PHConnectPwaIcon,\n} from \"@powerhousedao/shared/connect\";\n\n// The page-owned mirror of the effective PWA fragment contributed by the\n// currently-installed packages. The service worker reads this (read-only) to\n// serve a live web-app manifest — a SW cannot reach localStorage (where the\n// package list lives), so BrowserPackageManager writes the merged fragment\n// here on every package change. The db/store/key/version constants are the\n// SHARED source of truth in @powerhousedao/shared/connect, imported by both\n// this writer and the SW reader so the two cannot desync.\n\nexport type PwaFragmentRecord = {\n version: 1;\n fragment: PHConnectPwa;\n updatedAt: number;\n};\n\n// Self-contained IDB open (not reusing pglite-idb) so this module — and its\n// pure `resolveFragmentAssetUrls` — carries no dependency on connect.config,\n// keeping it importable in isolation.\nfunction openPwaIdb(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const req = indexedDB.open(PWA_IDB_NAME, PWA_IDB_VERSION);\n req.onupgradeneeded = () => {\n if (!req.result.objectStoreNames.contains(PWA_IDB_STORE)) {\n req.result.createObjectStore(PWA_IDB_STORE);\n }\n };\n req.onerror = () => reject(req.error ?? new Error(\"ph-pwa open failed\"));\n req.onblocked = () => reject(new Error(\"ph-pwa open blocked\"));\n req.onsuccess = () => resolve(req.result);\n });\n}\n\n/** Write (replace) the single merged fragment record. Best-effort: a failure to\n * mirror the manifest must never break package installation, so callers ignore\n * rejections. No-op when IndexedDB is unavailable (SSR/tests). */\nexport async function writeMergedPwaFragment(\n fragment: PHConnectPwa,\n): Promise<void> {\n if (typeof indexedDB === \"undefined\") return;\n const db = await openPwaIdb();\n try {\n await new Promise<void>((resolve, reject) => {\n const tx = db.transaction(PWA_IDB_STORE, \"readwrite\");\n tx.oncomplete = () => resolve();\n tx.onerror = () =>\n reject(tx.error ?? new Error(\"PWA fragment write failed\"));\n tx.objectStore(PWA_IDB_STORE).put(\n {\n version: 1,\n fragment,\n updatedAt: Date.now(),\n } satisfies PwaFragmentRecord,\n PWA_IDB_KEY,\n );\n });\n } finally {\n db.close();\n }\n}\n\n/** Resolve `src` against the package `baseUrl`, absolute srcs passing through.\n * `baseUrl` may itself be relative (e.g. a same-origin-proxied registry, or the\n * dev `/node_modules/…` path), so it is first made absolute against the app\n * origin — `new URL(src, relativeBase)` would otherwise throw and silently\n * leave the src unresolved. A malformed src is left untouched. */\nfunction toAbsoluteAssetUrl(src: string, baseUrl: string): string {\n try {\n const origin =\n typeof location !== \"undefined\" ? location.href : \"http://localhost/\";\n return new URL(src, new URL(baseUrl, origin)).toString();\n } catch {\n return src;\n }\n}\n\nfunction resolveIconSrc(\n icon: PHConnectPwaIcon,\n baseUrl: string,\n): PHConnectPwaIcon {\n return { ...icon, src: toAbsoluteAssetUrl(icon.src, baseUrl) };\n}\n\n/**\n * Rewrite a package fragment's relative asset srcs (manifest icons and\n * file-handler icons) to absolute URLs against the package's base — a runtime\n * package's assets live on the registry CDN, not the app origin, so the served\n * manifest must point there. `baseUrl` null (a local/bundled package whose\n * assets are app-origin-relative) leaves srcs untouched.\n */\nexport function resolveFragmentAssetUrls(\n config: PHConnectPwa,\n baseUrl: string | null,\n): PHConnectPwa {\n if (!baseUrl || !config.manifest) return config;\n const m = config.manifest;\n const resolveIcons = (icons?: PHConnectPwaIcon[]) =>\n icons?.map((icon) => resolveIconSrc(icon, baseUrl));\n return {\n ...config,\n manifest: {\n ...m,\n icons: resolveIcons(m.icons),\n file_handlers: m.file_handlers?.map((handler) => ({\n ...handler,\n icons: resolveIcons(handler.icons),\n })),\n },\n };\n}\n","import type { PackageRoute } from \"@powerhousedao/connect-core/router\";\nimport {\n holdConnectRoutes,\n registerPackageRoutes,\n} from \"@powerhousedao/connect-core/router\";\nimport * as common from \"@powerhousedao/powerhouse-vetra-packages\";\nimport type {\n IPackagesListener,\n PackageManagerInstallResult,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n BrowserLocalStorage,\n type IPackageListerUnsubscribe,\n type IPackageManager,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n checkSharedDeps,\n CONNECT_LAYER_ORDER,\n formatSharedDepWarnings,\n mergePwaConfig,\n type PHConnectPwa,\n type PwaContribution,\n withInferredCategory,\n} from \"@powerhousedao/shared/connect\";\nimport {\n type DocumentModelLib,\n type DocumentModelModule,\n PwaConfigSchema,\n} from \"@powerhousedao/shared/document-model\";\nimport { toCdnUrl } from \"@powerhousedao/shared/registry/urls\";\nimport { getSharedDeps } from \"./shared-deps.js\";\nimport {\n resolveFragmentAssetUrls,\n writeMergedPwaFragment,\n} from \"./utils/pwa-idb.js\";\nimport { refreshPwaManifestLink } from \"./utils/pwa-manifest-link.js\";\n\ntype PackageMeta = {\n name: string;\n importUrl: string | null;\n stylesheetUrl: string | null;\n version?: string;\n /**\n * Full spec the user asked for (e.g. `@scope/pkg@2.0.0-beta.2`). Kept so a\n * reload re-installs exactly the tag/version originally picked rather than\n * sliding to `latest`. Absent for legacy entries and local packages.\n */\n spec?: string;\n};\n\n/**\n * Strip any `@tag` / `@version` suffix from a package spec, returning the bare\n * package name. Mirrors `parsePackageSpec` on the UI side.\n */\nfunction parseBareName(spec: string): string {\n const trimmed = spec.trim();\n const at = trimmed.startsWith(\"@\")\n ? trimmed.lastIndexOf(\"@\")\n : trimmed.indexOf(\"@\");\n return at > 0 ? trimmed.slice(0, at) : trimmed;\n}\n\n/** Loads the routes a package offers (its `./connect-routes`). */\nexport type PackageRoutesLoader = () => Promise<{\n connectRoutes: readonly PackageRoute[];\n}>;\n\ntype PackageWithMeta = PackageMeta & {\n loadedPackage: DocumentModelLib<any>;\n spec?: string;\n loadRoutes?: PackageRoutesLoader;\n};\n\ntype FetchedPackageJson = {\n version?: string;\n dependencies?: Record<string, unknown>;\n peerDependencies?: Record<string, unknown>;\n};\n\nasync function fetchPackageJson(\n baseUrl: string,\n): Promise<FetchedPackageJson | null> {\n try {\n const res = await fetch(baseUrl);\n if (!res.ok) return null;\n const pkg = (await res.json()) as {\n version?: unknown;\n dependencies?: Record<string, unknown>;\n peerDependencies?: Record<string, unknown>;\n };\n return {\n version: typeof pkg.version === \"string\" ? pkg.version : undefined,\n dependencies: pkg.dependencies,\n peerDependencies: pkg.peerDependencies,\n };\n } catch {\n return null;\n }\n}\n\nasync function fetchPackageJsonVersion(\n baseUrl: string,\n): Promise<string | undefined> {\n return (await fetchPackageJson(baseUrl))?.version;\n}\n\n/**\n * Human-readable warnings for shared-dep mismatches between a package's npm\n * `package.json` (as served by the CDN) and the host's shared-deps version\n * table. Empty when either side is unavailable — a dev / vendor-off host has\n * no table to compare against, and a missing package.json means the check\n * can't run. Used by both the install flow and the package-manager UI.\n */\nexport function sharedDepMismatchWarnings(\n pkgJson: FetchedPackageJson | null,\n hostVersions: Record<string, string> | null | undefined,\n): string[] {\n if (!pkgJson || !hostVersions) return [];\n return formatSharedDepWarnings(checkSharedDeps(pkgJson, hostVersions));\n}\n\n// The bundled packages' versions, inlined by bundled-package-versions.ts.\ndeclare const PH_COMMON_PACKAGE_VERSION: string;\ndeclare const PH_VETRA_PACKAGE_VERSION: string;\ndeclare const PH_WORKFLOW_PACKAGE_VERSION: string;\n\nconst LOCAL_PACKAGE_NAME = \"Local\" as const;\n\n// Package CSS goes in external-packages: above Connect's reset so it can style\n// its editors, below Connect's utilities so it can't override them.\nexport const LAYER_ORDER = CONNECT_LAYER_ORDER;\nconst LAYER_ORDER_ATTR = \"data-ph-layer-order\";\n\n// Layer order is set by the first declaration in the document, and a project's\n// style.css declares Tailwind's layers first, so this goes first in <head>.\n\nexport function declareExternalPackagesLayer(): void {\n if (document.head.querySelector(`style[${LAYER_ORDER_ATTR}]`)) return;\n const order = document.createElement(\"style\");\n order.setAttribute(LAYER_ORDER_ATTR, \"\");\n order.textContent = LAYER_ORDER;\n document.head.prepend(order);\n}\n\nexport class BrowserPackageManager implements IPackageManager {\n registryUrl: string | null;\n #storage: BrowserLocalStorage<PackageMeta>;\n #packages: Map<string, DocumentModelLib<any>> = new Map();\n #subscribers = new Set<IPackagesListener>();\n #packagesMemo: DocumentModelLib<any>[] = [];\n #stylesheets: Map<string, HTMLStyleElement> = new Map();\n /** Takes each package's offered routes out of the router. */\n #routes: Map<string, () => void> = new Map();\n #localPackage: DocumentModelLib<any> | undefined;\n\n #cdnUrl: string | null;\n #localPackageVersion: string | undefined;\n #localPackageNames: Set<string> = new Set([LOCAL_PACKAGE_NAME]);\n #pwaSyncTimer: ReturnType<typeof setTimeout> | undefined;\n /** Serialized last-mirrored PWA fragment; lets a sync skip the IndexedDB\n * write + manifest re-attach when nothing PWA-relevant changed. */\n #lastSyncedFragmentJson: string | undefined;\n\n constructor(namespace: string, registryUrl: string | null) {\n this.#storage = new BrowserLocalStorage<PackageMeta>(\n namespace + \":PH_PACKAGES\",\n );\n this.registryUrl = registryUrl;\n this.#cdnUrl = registryUrl !== null ? toCdnUrl(registryUrl) : null;\n }\n\n async init(\n localPackage?: DocumentModelLib<any>,\n localPackageVersion?: string,\n studioMode?: boolean,\n workflowsEnabled?: boolean,\n genericChrome = true,\n ) {\n // Common's editors (drive explorer, document model editor) are the generic\n // chrome's; without it, core gets only common's document models.\n this.addLocalPackage(\n common.manifest.name,\n genericChrome ? common : { ...common, editors: [] },\n PH_COMMON_PACKAGE_VERSION,\n );\n // Vetra is builder-only and not CDN-loadable; lazy-load it (code-split\n // chunk, never fetched in production) only in studio mode.\n if (studioMode) {\n const vetra = await import(\"@powerhousedao/vetra\");\n this.addLocalPackage(\n vetra.manifest.name,\n vetra,\n PH_VETRA_PACKAGE_VERSION,\n );\n }\n // Same shape for the workflow package, behind its own independent flag.\n // Only the package root: `./pieces` and `./reactor` are node-only.\n if (workflowsEnabled) {\n const workflow = await import(\"@powerhousedao/workflow\");\n this.addLocalPackage(\n workflow.manifest.name,\n workflow,\n PH_WORKFLOW_PACKAGE_VERSION,\n );\n }\n if (localPackage) {\n this.updateLocalPackage(localPackage, localPackageVersion);\n }\n for (const packageName of this.#storage.keys()) {\n // Re-hydrate with the originally-requested spec so a tag/version pick\n // sticks across reloads. Fall back to the bare key for legacy entries\n // (pre-spec) and for entries that never had a tag.\n const existingMeta = this.#storage.get(packageName);\n const specForReload = existingMeta?.spec ?? packageName;\n console.debug(\n `[Connect][PackageManager] Rehydrating \"${packageName}\" via spec \"${specForReload}\"`,\n );\n const result = await this.addPackage(specForReload);\n // Previously-installed package that no longer resolves (version\n // withdrawn from npm, registry moved, etc.) would otherwise\n // 404-toast on every boot forever. Drop it from persistent storage\n // so the failure is one-shot instead of sticky.\n if (result.type === \"error\") {\n this.#storage.delete(packageName);\n }\n }\n }\n\n addLocalPackage(\n name: string,\n loadedPackage: DocumentModelLib<any>,\n version?: string,\n loadRoutes?: PackageRoutesLoader,\n ) {\n this.#localPackageNames.add(name);\n this.#registerPackage({\n name,\n importUrl: null,\n stylesheetUrl: null,\n loadedPackage,\n version,\n loadRoutes,\n });\n }\n\n updateLocalPackage(pkg: DocumentModelLib<any>, version?: string) {\n console.debug(\"Updating local package:\", pkg);\n this.#localPackage = pkg;\n this.#registerPackage({\n name: LOCAL_PACKAGE_NAME,\n stylesheetUrl: null,\n importUrl: null,\n loadedPackage: pkg,\n });\n if (version) {\n this.#localPackageVersion = version;\n this.#notifyPackagesChanged();\n return;\n }\n fetchPackageJsonVersion(\"/package.json\")\n .then((fetchedVersion) => {\n this.#localPackageVersion = fetchedVersion;\n if (fetchedVersion) this.#notifyPackagesChanged();\n })\n .catch(() => {});\n }\n\n get packages() {\n return this.#packagesMemo;\n }\n\n get localPackage(): DocumentModelLib<any> | undefined {\n return this.#localPackage;\n }\n\n get cdnUrl(): string | null {\n return this.#cdnUrl;\n }\n\n getPackageSource(packageName: string) {\n // check vs packages registered as local (Common, Vetra, bundled packages...)\n if (this.#localPackageNames.has(packageName)) {\n return \"common\";\n }\n // check if the package has the same name as the local project\n if (packageName === this.#localPackage?.manifest.name) return \"project\";\n const packageMeta = this.#storage.get(packageName);\n // if meta does not exist the package is not installed\n if (!packageMeta) return null;\n // if imported from node_modules then the package is installed locally\n if (packageMeta.importUrl === `/node_modules/${packageName}`)\n return \"local-install\";\n // all other import urls point to a registry\n return \"registry-install\";\n }\n\n /**\n * Return the registry-installed packages keyed by their storage name (which\n * is the registry spec, e.g. \"@powerhousedao/clint-common\"), with the\n * installed version when known. Excludes bundled (common) packages, the\n * local project package, and packages resolved out of `/node_modules/`.\n */\n getRegistryPackages(): { name: string; version: string | undefined }[] {\n const out: { name: string; version: string | undefined }[] = [];\n for (const [name, meta] of this.#storage) {\n if (this.#localPackageNames.has(name)) continue;\n if (name === LOCAL_PACKAGE_NAME) continue;\n if (meta.importUrl === `/node_modules/${name}`) continue;\n out.push({ name, version: meta.version });\n }\n return out;\n }\n\n getPackageVersion(packageName: string): string | undefined {\n if (packageName === this.#localPackage?.manifest.name) {\n return this.#localPackageVersion;\n }\n return this.#storage.get(packageName)?.version;\n }\n\n /**\n * The spec the user requested when this package was installed (e.g.\n * `name@dev` or `name@6.2.1`). Undefined for bare-name installs, legacy\n * entries, and local packages — the Package Manager treats that as the\n * `latest` stream when picking update targets.\n */\n getPackageSpec(packageName: string): string | undefined {\n return this.#storage.get(packageName)?.spec;\n }\n\n async addPackage(packageSpec: string): Promise<PackageManagerInstallResult> {\n // `packageSpec` may include a `@tag` / `@version` suffix (e.g. user picked\n // a specific version in the package manager UI, or re-hydrated on reload\n // from the persisted spec). We always register/look up by the bare name so\n // status tracking, version lookups, and uninstall all go through a single\n // canonical key. The spec itself is kept on the meta so reloads re-fetch\n // the same tag.\n const bareName = parseBareName(packageSpec);\n const hasTagOrVersion = bareName !== packageSpec;\n console.debug(\n `[Connect][PackageManager] addPackage spec=\"${packageSpec}\" bareName=\"${bareName}\"`,\n );\n\n const existingPackage = this.#packages.get(bareName);\n if (existingPackage) {\n const requestedVersion = hasTagOrVersion\n ? packageSpec.slice(bareName.length + 1)\n : undefined;\n const currentVersion = this.#storage.get(bareName)?.version;\n const isLocal = this.#localPackageNames.has(bareName);\n const sameVersion =\n !requestedVersion ||\n !currentVersion ||\n requestedVersion === currentVersion;\n if (isLocal || sameVersion) {\n console.debug(\n `[Connect][PackageManager] \"${bareName}\" already loaded; skipping re-fetch`,\n );\n return {\n type: \"success\",\n package: existingPackage,\n };\n }\n console.debug(\n `[Connect][PackageManager] \"${bareName}\" version bump ${currentVersion} → ${requestedVersion}; refetching`,\n );\n }\n try {\n const packageWithMeta = await this.#loadPackage(packageSpec);\n // `#loadPackage*` set `name` to whatever spec it built the URL from.\n // Canonicalize to the bare name for the map/storage keys, and stash the\n // original spec separately so reloads re-use it.\n packageWithMeta.name = bareName;\n if (hasTagOrVersion) {\n packageWithMeta.spec = packageSpec;\n }\n // Swap stylesheets only once the new package is in hand. If `#loadPackage`\n // throws above, the old stylesheet stays mounted and the UI keeps\n // rendering the previous version instead of unstyled markup.\n if (existingPackage) {\n this.#unmountStylesheet(bareName);\n }\n this.#registerPackage(packageWithMeta);\n\n return {\n type: \"success\",\n package: packageWithMeta.loadedPackage,\n };\n } catch (error) {\n const normalized =\n error instanceof Error ? error : new Error(String(error));\n console.error(\n `[Connect][PackageManager] Failed to install package \"${packageSpec}\": ${normalized.message}`,\n normalized,\n );\n return {\n type: \"error\",\n error: normalized,\n };\n }\n }\n\n async addPackages(packageNames: string[]) {\n const results: PackageManagerInstallResult[] = [];\n for (const packageName of packageNames) {\n const result = await this.addPackage(packageName);\n results.push(result);\n }\n return results;\n }\n\n removePackage(name: string) {\n this.#syncRoutes(name, undefined);\n this.#packages.delete(name);\n this.#storage.delete(name);\n this.#unmountStylesheet(name);\n this.#notifyPackagesChanged();\n }\n\n subscribe(handler: IPackagesListener): IPackageListerUnsubscribe {\n this.#subscribers.add(handler);\n return () => {\n this.#subscribers.delete(handler);\n };\n }\n\n load(documentType: string): Promise<DocumentModelModule<any>> {\n const documentModelModule = Array.from(\n this.#packages.values().flatMap((p) => p.documentModels),\n ).find((m) => m.documentModel.global.id === documentType);\n\n if (documentModelModule) return Promise.resolve(documentModelModule);\n return Promise.reject(new Error(\"Model not available\"));\n }\n\n async #loadPackageFromNodeModules(name: string): Promise<PackageWithMeta> {\n // Installed under its bare name; the spec may carry a version or tag.\n const dir = `/node_modules/${parseBareName(name)}`;\n const importUrl = `${dir}/browser/index.js`;\n const stylesheetUrl = `${dir}/style.css`;\n\n const packageWithMeta = await this.#importPackage({\n name,\n importUrl,\n stylesheetUrl,\n });\n packageWithMeta.version = await fetchPackageJsonVersion(\n `${dir}/package.json`,\n );\n\n return packageWithMeta;\n }\n\n async #loadPackageFromRegistry(name: string): Promise<PackageWithMeta> {\n const importUrl = `${this.#cdnUrl}/${name}/browser/index.js`;\n const stylesheetUrl = `${this.#cdnUrl}/${name}/style.css`;\n const packageWithMeta = await this.#importPackage({\n name,\n importUrl,\n stylesheetUrl,\n });\n const pkgJson = await fetchPackageJson(\n `${this.#cdnUrl}/${name}/package.json`,\n );\n packageWithMeta.version = pkgJson?.version;\n\n // Non-blocking warning: a package that pins a shared dep at a version\n // the host's vendor was built without still installs, but the host's\n // copy is what runs — surface the mismatch before it surprises the\n // user at runtime.\n const warnings = sharedDepMismatchWarnings(\n pkgJson,\n (await getSharedDeps())?.versions,\n );\n if (warnings.length > 0) {\n console.error(\n `[package-manager] shared-deps mismatch for ${name}:\\n` +\n warnings.join(\"\\n\"),\n );\n }\n\n return packageWithMeta;\n }\n\n async #importPackage(packageMeta: PackageMeta): Promise<PackageWithMeta> {\n const { name, importUrl, stylesheetUrl } = packageMeta;\n if (!importUrl) {\n throw new Error(`Import url not defined for package \"${name}\".`);\n }\n\n const loadedPackage = (await import(\n /* @vite-ignore */ importUrl\n )) as DocumentModelLib<any>;\n // Beside the package's entry: browser/connect-routes.js.\n const routesUrl = importUrl.replace(/index\\.js$/, \"connect-routes.js\");\n\n return {\n name,\n loadedPackage,\n importUrl,\n stylesheetUrl,\n loadRoutes: () => import(/* @vite-ignore */ routesUrl),\n };\n }\n\n async #loadPackage(packageName: string): Promise<PackageWithMeta> {\n if (this.#localPackageNames.has(packageName)) {\n throw new Error(\n `Package \"${packageName}\" is a local package and cannot be loaded dynamically.`,\n );\n }\n\n // only attemp to load from node_modules in dev mode\n if (!import.meta.env.PROD) {\n try {\n const packageWithMeta =\n await this.#loadPackageFromNodeModules(packageName);\n return packageWithMeta;\n } catch (error) {\n // Expected for a package installed only in Connect, not the project.\n console.debug(\n `\"${packageName}\" isn't in node_modules; loading it from the registry.`,\n error,\n );\n }\n }\n\n if (!this.registryUrl) {\n throw new Error(\"Registry url not defined.\");\n }\n\n return await this.#loadPackageFromRegistry(packageName);\n }\n\n /** Replaces `name`'s offered routes with `pkg`'s; the project's own package\n * is left out, as its host build already has its routes. */\n #syncRoutes(\n name: string,\n pkg: DocumentModelLib<any> | undefined,\n loadRoutes?: PackageRoutesLoader,\n ) {\n this.#routes.get(name)?.();\n this.#routes.delete(name);\n const offers = pkg?.manifest.connectRoutes && loadRoutes;\n if (!offers || name === LOCAL_PACKAGE_NAME) return;\n // A replacement before the routes load cancels them.\n let cancelled = false;\n this.#routes.set(name, () => {\n cancelled = true;\n });\n // Unknown paths wait for these routes before showing not found.\n const release = holdConnectRoutes();\n loadRoutes()\n .then(({ connectRoutes }) => {\n if (!cancelled) {\n this.#routes.set(name, registerPackageRoutes(connectRoutes));\n }\n })\n .catch((error: unknown) => {\n console.error(\n `[package-manager] ${name}'s routes failed to load:`,\n error,\n );\n })\n .finally(release);\n }\n\n #registerPackage(packageWithMeta: PackageWithMeta) {\n const { name, loadedPackage, importUrl, stylesheetUrl, version, spec } =\n packageWithMeta;\n\n if (stylesheetUrl !== null) {\n this.#mountStylesheet(name, stylesheetUrl);\n }\n this.#syncRoutes(name, loadedPackage, packageWithMeta.loadRoutes);\n this.#packages.set(name, loadedPackage);\n this.#storage.set(name, {\n name,\n importUrl,\n stylesheetUrl,\n version,\n ...(spec ? { spec } : {}),\n });\n console.debug(\n `[Connect][PackageManager] Registered \"${name}\" (version=${version ?? \"?\"}, spec=${spec ?? \"—\"})`,\n );\n\n this.#notifyPackagesChanged();\n }\n\n #mountStylesheet(name: string, href: string) {\n const existing = this.#stylesheets.get(name);\n if (existing) return existing;\n\n declareExternalPackagesLayer();\n const style = document.createElement(\"style\");\n style.textContent = `@import url(\"${href}\") layer(external-packages);`;\n document.head.appendChild(style);\n\n this.#stylesheets.set(name, style);\n }\n\n #unmountStylesheet(name: string): void {\n const style = this.#stylesheets.get(name);\n if (!style) return;\n\n style.remove();\n this.#stylesheets.delete(name);\n }\n\n #notifyPackagesChanged() {\n this.#packagesMemo = Array.from(this.#packages.values());\n const packages = this.packages;\n this.#subscribers.forEach((handler) => {\n handler({ packages });\n });\n this.#schedulePwaSync();\n }\n\n /**\n * Debounced mirror of every loaded package's PWA fragment into IndexedDB, so\n * the service worker can serve a web-app manifest that reflects packages\n * installed AT RUNTIME (a SW can't read localStorage, where the package list\n * lives). Debounced because `init()` rehydrates many packages in a burst;\n * coalescing collapses that into a single write.\n */\n #schedulePwaSync() {\n if (typeof indexedDB === \"undefined\") return;\n clearTimeout(this.#pwaSyncTimer);\n this.#pwaSyncTimer = setTimeout(() => {\n void this.#syncPwaFragments();\n }, 50);\n }\n\n async #syncPwaFragments() {\n const contributions: PwaContribution[] = [];\n for (const [name, loadedPackage] of this.#packages) {\n const manifest = loadedPackage.manifest;\n let config: PHConnectPwa = {};\n if (manifest.pwa) {\n // Third-party package code must not inject arbitrary manifest fields the\n // SW will serve — validate strictly and skip (with a warning) on failure.\n const parsed = PwaConfigSchema.safeParse(manifest.pwa);\n if (parsed.success) {\n // A package's assets live at its base (CDN for registry installs);\n // make relative icon srcs absolute so the served manifest resolves.\n const importUrl = this.#storage.get(name)?.importUrl ?? null;\n const baseUrl = importUrl\n ? importUrl.replace(/browser\\/index\\.js$/, \"\")\n : null;\n config = resolveFragmentAssetUrls(parsed.data, baseUrl);\n } else {\n console.warn(\n `[Connect][PWA] \"${name}\" ships an invalid pwa fragment; skipped.`,\n parsed.error,\n );\n }\n }\n // `categories` is derived from the manifest's `category` field (not\n // authored under `pwa`); it unions into the SW-served manifest so a\n // runtime-installed package's category shows up like a build-time one.\n config = withInferredCategory(config, manifest.category);\n if (Object.keys(config).length === 0) continue;\n contributions.push({ source: name, config });\n }\n // Fold in load order (base-first ordering is preserved so a package cannot\n // hijack the built-in .phd/.phdm handler at merge time either).\n const merged = mergePwaConfig(contributions);\n // Most package operations don't touch PWA config; skip the write + manifest\n // re-attach (which forces a redundant manifest re-fetch) when unchanged.\n const mergedJson = JSON.stringify(merged);\n if (mergedJson === this.#lastSyncedFragmentJson) return;\n try {\n await writeMergedPwaFragment(merged);\n } catch (error) {\n // Leave #lastSyncedFragmentJson unset so a later sync retries the write.\n console.debug(\n \"[Connect][PWA] fragment mirror to IndexedDB failed:\",\n error,\n );\n return;\n }\n this.#lastSyncedFragmentJson = mergedJson;\n // The SW serves the manifest fresh from IndexedDB, but the browser only\n // parsed <link rel=\"manifest\"> at page load — re-attach it so it\n // re-consumes the now-updated manifest without a manual reload. (Kept out\n // of the write's try/catch so a DOM error isn't mislabeled as an IDB\n // failure; refreshPwaManifestLink is itself non-throwing.)\n refreshPwaManifestLink();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AASA,SAAS,qBAAyC;CAChD,OAAO,OAAO,+BAA+B,cACzC,6BACA,KAAA;AACN;;;;;AAMA,SAAgB,oBACd,aACA,OACA,KACe;CACf,IAAI,OAAO,OAAO,sBAAsB,OAAO,WAAW;CAC1D,OAAO,MAAM,OAAO,GAAG,YAAY;AACrC;;;;;;;;;;AAgBA,SAAgB,uBACd,YACA,aACwB;CAGxB,MAAM,SACH,WAAuC,UAAU,UAClD;CACF,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAChD,MACA,IAAI,IAAI,sBAAsB,OAAO,WAAW,GAAG,MAAM,CAAC,CAAC,IAC7D,CAAC,CACH;AACF;AAEA,IAAI,SAA4C;;;;;;;;;AAUhD,SAAgB,gBAA4C;CAC1D,YAAY,YAAY;EACtB,MAAM,MAAM,oBACV,YAAY,IAAI,UAChB,mBAAmB,GACnB,YAAY,IAAI,GAClB;EACA,IAAI,QAAQ,MAAM,OAAO;EACzB,IAAI;GACF,MAAM,MAAO,MAAM;;IAA0B;;GAI7C,OAAO;IACL,SAAS,uBAAuB,IAAI,SAAS,YAAY,IAAI,QAAQ;IACrE,UAAU,IAAI;GAChB;EACF,QAAQ;GACN,OAAO;EACT;CACF,EAAA,CAAG;CACH,OAAO;AACT;;AAGA,SAAgB,2BACd,eACA,SACwB;CACxB,IAAI,UAAkC,CAAC;CACvC,IA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","debug_id":"56ef8944-822c-5638-8cc2-344ed06ef74f"}
|
|
1
|
+
{"version":3,"file":"package-manager-Bq_IGvx5.js","sources":["../src/shared-deps.ts","../src/utils/pwa-idb.ts","../src/package-manager.ts"],"sourcesContent":["import {\n EXTERNALIZABLE_SHARED_SPECIFIERS,\n resolveDynamicBaseUrl,\n} from \"@powerhousedao/shared/connect\";\n\n// Set by `ph connect build`, and by a dev server that serves a prebuilt\n// vendor: the content-hashed shared-deps module URL.\ndeclare const PH_CONNECT_SHARED_DEPS_URL: string | undefined;\n\nfunction builtSharedDepsUrl(): string | undefined {\n return typeof PH_CONNECT_SHARED_DEPS_URL !== \"undefined\"\n ? PH_CONNECT_SHARED_DEPS_URL\n : undefined;\n}\n\n/**\n * The shared-deps module URL: this build's hashed copy, else the stable path.\n * Null on a dev server without a vendor, where the request could only 404.\n */\nexport function sharedDepsModuleUrl(\n runtimeBase: string,\n built: string | undefined,\n dev: boolean,\n): string | null {\n if (built) return resolveDynamicBaseUrl(built, runtimeBase);\n return dev ? null : `${runtimeBase}__vendor__/shared-deps.js`;\n}\n\nexport type SharedDeps = {\n imports: Record<string, string>;\n versions: Record<string, string>;\n};\n\n/**\n * Resolve the vendor's import-map values to absolute URLs: the\n * dynamic-base placeholder (present in dynamic-base builds) is replaced\n * with the runtime base — which `import.meta.env.BASE_URL` already is,\n * since the dynamic-base plugin rewrites it to the resolved base — and\n * the result is made absolute against the page origin. Absolute URLs are\n * what the worker needs: its imports have no document context, so\n * relative or placeholder-based values would not resolve there.\n */\nexport function normalizeVendorImports(\n rawImports: Record<string, string>,\n runtimeBase: string,\n): Record<string, string> {\n // `location` is a browser global; the fallback keeps the helper usable\n // from node-based tests, where no origin exists.\n const origin =\n (globalThis as { location?: Location }).location?.origin ??\n \"http://localhost\";\n return Object.fromEntries(\n Object.entries(rawImports).map(([spec, value]) => [\n spec,\n new URL(resolveDynamicBaseUrl(value, runtimeBase), origin).href,\n ]),\n );\n}\n\nlet cached: Promise<SharedDeps | null> | null = null;\n\n/**\n * The vendor's shared-deps table: import-map entries for the shared\n * dependency set plus the resolved version of every shared package in this\n * build. Fails soft (`null`) when the vendor is not present (dev without\n * a prebuilt vendor, or a `PH_CONNECT_VENDOR=0` build) — callers treat that\n * as \"no sharing\".\n * The promise is cached: the vendor table is immutable per build.\n */\nexport function getSharedDeps(): Promise<SharedDeps | null> {\n cached ??= (async () => {\n const url = sharedDepsModuleUrl(\n import.meta.env.BASE_URL,\n builtSharedDepsUrl(),\n import.meta.env.DEV,\n );\n if (url === null) return null;\n try {\n const mod = (await import(/* @vite-ignore */ url)) as {\n imports: Record<string, string>;\n versions: Record<string, string>;\n };\n return {\n imports: normalizeVendorImports(mod.imports, import.meta.env.BASE_URL),\n versions: mod.versions,\n };\n } catch {\n return null;\n }\n })();\n return cached;\n}\n\n/** The shared-dep entries of an import map (exact and trailing-slash), as absolute URLs. */\nexport function sharedImportsFromImportMap(\n importMapJson: string | null | undefined,\n pageUrl: string,\n): Record<string, string> {\n let imports: Record<string, string> = {};\n try {\n imports =\n (\n JSON.parse(importMapJson ?? \"{}\") as {\n imports?: Record<string, string>;\n }\n ).imports ?? {};\n } catch {\n return {};\n }\n const isShared = (key: string) => {\n const spec = key.endsWith(\"/\") ? key.slice(0, -1) : key;\n return EXTERNALIZABLE_SHARED_SPECIFIERS.some(\n (shared) => spec === shared || spec.startsWith(`${shared}/`),\n );\n };\n return Object.fromEntries(\n Object.entries(imports)\n .filter(([key]) => isShared(key))\n .map(([key, url]) => [key, new URL(url, pageUrl).href]),\n );\n}\n\n/** Without a vendor table, dev's import map points the shared deps at shims a worker can import. */\nexport function pageSharedImports(): Record<string, string> {\n const script = document.querySelector('script[type=\"importmap\"]');\n return sharedImportsFromImportMap(script?.textContent, window.location.href);\n}\n","import {\n PWA_IDB_KEY,\n PWA_IDB_NAME,\n PWA_IDB_STORE,\n PWA_IDB_VERSION,\n type PHConnectPwa,\n type PHConnectPwaIcon,\n} from \"@powerhousedao/shared/connect\";\n\n// The page-owned mirror of the effective PWA fragment contributed by the\n// currently-installed packages. The service worker reads this (read-only) to\n// serve a live web-app manifest — a SW cannot reach localStorage (where the\n// package list lives), so BrowserPackageManager writes the merged fragment\n// here on every package change. The db/store/key/version constants are the\n// SHARED source of truth in @powerhousedao/shared/connect, imported by both\n// this writer and the SW reader so the two cannot desync.\n\nexport type PwaFragmentRecord = {\n version: 1;\n fragment: PHConnectPwa;\n updatedAt: number;\n};\n\n// Self-contained IDB open (not reusing pglite-idb) so this module — and its\n// pure `resolveFragmentAssetUrls` — carries no dependency on connect.config,\n// keeping it importable in isolation.\nfunction openPwaIdb(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const req = indexedDB.open(PWA_IDB_NAME, PWA_IDB_VERSION);\n req.onupgradeneeded = () => {\n if (!req.result.objectStoreNames.contains(PWA_IDB_STORE)) {\n req.result.createObjectStore(PWA_IDB_STORE);\n }\n };\n req.onerror = () => reject(req.error ?? new Error(\"ph-pwa open failed\"));\n req.onblocked = () => reject(new Error(\"ph-pwa open blocked\"));\n req.onsuccess = () => resolve(req.result);\n });\n}\n\n/** Write (replace) the single merged fragment record. Best-effort: a failure to\n * mirror the manifest must never break package installation, so callers ignore\n * rejections. No-op when IndexedDB is unavailable (SSR/tests). */\nexport async function writeMergedPwaFragment(\n fragment: PHConnectPwa,\n): Promise<void> {\n if (typeof indexedDB === \"undefined\") return;\n const db = await openPwaIdb();\n try {\n await new Promise<void>((resolve, reject) => {\n const tx = db.transaction(PWA_IDB_STORE, \"readwrite\");\n tx.oncomplete = () => resolve();\n tx.onerror = () =>\n reject(tx.error ?? new Error(\"PWA fragment write failed\"));\n tx.objectStore(PWA_IDB_STORE).put(\n {\n version: 1,\n fragment,\n updatedAt: Date.now(),\n } satisfies PwaFragmentRecord,\n PWA_IDB_KEY,\n );\n });\n } finally {\n db.close();\n }\n}\n\n/** Resolve `src` against the package `baseUrl`, absolute srcs passing through.\n * `baseUrl` may itself be relative (e.g. a same-origin-proxied registry, or the\n * dev `/node_modules/…` path), so it is first made absolute against the app\n * origin — `new URL(src, relativeBase)` would otherwise throw and silently\n * leave the src unresolved. A malformed src is left untouched. */\nfunction toAbsoluteAssetUrl(src: string, baseUrl: string): string {\n try {\n const origin =\n typeof location !== \"undefined\" ? location.href : \"http://localhost/\";\n return new URL(src, new URL(baseUrl, origin)).toString();\n } catch {\n return src;\n }\n}\n\nfunction resolveIconSrc(\n icon: PHConnectPwaIcon,\n baseUrl: string,\n): PHConnectPwaIcon {\n return { ...icon, src: toAbsoluteAssetUrl(icon.src, baseUrl) };\n}\n\n/**\n * Rewrite a package fragment's relative asset srcs (manifest icons and\n * file-handler icons) to absolute URLs against the package's base — a runtime\n * package's assets live on the registry CDN, not the app origin, so the served\n * manifest must point there. `baseUrl` null (a local/bundled package whose\n * assets are app-origin-relative) leaves srcs untouched.\n */\nexport function resolveFragmentAssetUrls(\n config: PHConnectPwa,\n baseUrl: string | null,\n): PHConnectPwa {\n if (!baseUrl || !config.manifest) return config;\n const m = config.manifest;\n const resolveIcons = (icons?: PHConnectPwaIcon[]) =>\n icons?.map((icon) => resolveIconSrc(icon, baseUrl));\n return {\n ...config,\n manifest: {\n ...m,\n icons: resolveIcons(m.icons),\n file_handlers: m.file_handlers?.map((handler) => ({\n ...handler,\n icons: resolveIcons(handler.icons),\n })),\n },\n };\n}\n","import type { PackageRoute } from \"@powerhousedao/connect-core/router\";\nimport {\n holdConnectRoutes,\n registerPackageRoutes,\n} from \"@powerhousedao/connect-core/router\";\nimport * as common from \"@powerhousedao/powerhouse-vetra-packages\";\nimport type {\n IPackagesListener,\n PackageManagerInstallResult,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n BrowserLocalStorage,\n type IPackageListerUnsubscribe,\n type IPackageManager,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n checkSharedDeps,\n CONNECT_LAYER_ORDER,\n formatSharedDepWarnings,\n mergePwaConfig,\n type PHConnectPwa,\n type PwaContribution,\n withInferredCategory,\n} from \"@powerhousedao/shared/connect\";\nimport {\n type DocumentModelLib,\n type DocumentModelModule,\n PwaConfigSchema,\n} from \"@powerhousedao/shared/document-model\";\nimport { toCdnUrl } from \"@powerhousedao/shared/registry/urls\";\nimport { getSharedDeps } from \"./shared-deps.js\";\nimport {\n resolveFragmentAssetUrls,\n writeMergedPwaFragment,\n} from \"./utils/pwa-idb.js\";\nimport { refreshPwaManifestLink } from \"./utils/pwa-manifest-link.js\";\n\ntype PackageMeta = {\n name: string;\n importUrl: string | null;\n stylesheetUrl: string | null;\n version?: string;\n /**\n * Full spec the user asked for (e.g. `@scope/pkg@2.0.0-beta.2`). Kept so a\n * reload re-installs exactly the tag/version originally picked rather than\n * sliding to `latest`. Absent for legacy entries and local packages.\n */\n spec?: string;\n};\n\n/**\n * Strip any `@tag` / `@version` suffix from a package spec, returning the bare\n * package name. Mirrors `parsePackageSpec` on the UI side.\n */\nfunction parseBareName(spec: string): string {\n const trimmed = spec.trim();\n const at = trimmed.startsWith(\"@\")\n ? trimmed.lastIndexOf(\"@\")\n : trimmed.indexOf(\"@\");\n return at > 0 ? trimmed.slice(0, at) : trimmed;\n}\n\n/** Loads the routes a package offers (its `./connect-routes`). */\nexport type PackageRoutesLoader = () => Promise<{\n connectRoutes: readonly PackageRoute[];\n}>;\n\ntype PackageWithMeta = PackageMeta & {\n loadedPackage: DocumentModelLib<any>;\n spec?: string;\n loadRoutes?: PackageRoutesLoader;\n};\n\ntype FetchedPackageJson = {\n version?: string;\n dependencies?: Record<string, unknown>;\n peerDependencies?: Record<string, unknown>;\n};\n\nasync function fetchPackageJson(\n baseUrl: string,\n): Promise<FetchedPackageJson | null> {\n try {\n const res = await fetch(baseUrl);\n if (!res.ok) return null;\n const pkg = (await res.json()) as {\n version?: unknown;\n dependencies?: Record<string, unknown>;\n peerDependencies?: Record<string, unknown>;\n };\n return {\n version: typeof pkg.version === \"string\" ? pkg.version : undefined,\n dependencies: pkg.dependencies,\n peerDependencies: pkg.peerDependencies,\n };\n } catch {\n return null;\n }\n}\n\nasync function fetchPackageJsonVersion(\n baseUrl: string,\n): Promise<string | undefined> {\n return (await fetchPackageJson(baseUrl))?.version;\n}\n\n/**\n * Human-readable warnings for shared-dep mismatches between a package's npm\n * `package.json` (as served by the CDN) and the host's shared-deps version\n * table. Empty when either side is unavailable — a dev / vendor-off host has\n * no table to compare against, and a missing package.json means the check\n * can't run. Used by both the install flow and the package-manager UI.\n */\nexport function sharedDepMismatchWarnings(\n pkgJson: FetchedPackageJson | null,\n hostVersions: Record<string, string> | null | undefined,\n): string[] {\n if (!pkgJson || !hostVersions) return [];\n return formatSharedDepWarnings(checkSharedDeps(pkgJson, hostVersions));\n}\n\n// The bundled packages' versions, inlined by bundled-package-versions.ts.\ndeclare const PH_COMMON_PACKAGE_VERSION: string;\ndeclare const PH_VETRA_PACKAGE_VERSION: string;\ndeclare const PH_WORKFLOW_PACKAGE_VERSION: string;\n\nconst LOCAL_PACKAGE_NAME = \"Local\" as const;\n\n// Package CSS goes in external-packages: above Connect's reset so it can style\n// its editors, below Connect's utilities so it can't override them.\nexport const LAYER_ORDER = CONNECT_LAYER_ORDER;\nconst LAYER_ORDER_ATTR = \"data-ph-layer-order\";\n\n// Layer order is set by the first declaration in the document, and a project's\n// style.css declares Tailwind's layers first, so this goes first in <head>.\n\nexport function declareExternalPackagesLayer(): void {\n if (document.head.querySelector(`style[${LAYER_ORDER_ATTR}]`)) return;\n const order = document.createElement(\"style\");\n order.setAttribute(LAYER_ORDER_ATTR, \"\");\n order.textContent = LAYER_ORDER;\n document.head.prepend(order);\n}\n\nexport class BrowserPackageManager implements IPackageManager {\n registryUrl: string | null;\n #storage: BrowserLocalStorage<PackageMeta>;\n #packages: Map<string, DocumentModelLib<any>> = new Map();\n #subscribers = new Set<IPackagesListener>();\n #packagesMemo: DocumentModelLib<any>[] = [];\n #stylesheets: Map<string, HTMLStyleElement> = new Map();\n /** Takes each package's offered routes out of the router. */\n #routes: Map<string, () => void> = new Map();\n #localPackage: DocumentModelLib<any> | undefined;\n\n #cdnUrl: string | null;\n #localPackageVersion: string | undefined;\n #localPackageNames: Set<string> = new Set([LOCAL_PACKAGE_NAME]);\n #pwaSyncTimer: ReturnType<typeof setTimeout> | undefined;\n /** Serialized last-mirrored PWA fragment; lets a sync skip the IndexedDB\n * write + manifest re-attach when nothing PWA-relevant changed. */\n #lastSyncedFragmentJson: string | undefined;\n\n constructor(namespace: string, registryUrl: string | null) {\n this.#storage = new BrowserLocalStorage<PackageMeta>(\n namespace + \":PH_PACKAGES\",\n );\n this.registryUrl = registryUrl;\n this.#cdnUrl = registryUrl !== null ? toCdnUrl(registryUrl) : null;\n }\n\n async init(\n localPackage?: DocumentModelLib<any>,\n localPackageVersion?: string,\n studioMode?: boolean,\n workflowsEnabled?: boolean,\n genericChrome = true,\n ) {\n // Common's editors (drive explorer, document model editor) are the generic\n // chrome's; without it, core gets only common's document models.\n this.addLocalPackage(\n common.manifest.name,\n genericChrome ? common : { ...common, editors: [] },\n PH_COMMON_PACKAGE_VERSION,\n );\n // Vetra is builder-only and not CDN-loadable; lazy-load it (code-split\n // chunk, never fetched in production) only in studio mode.\n if (studioMode) {\n const vetra = await import(\"@powerhousedao/vetra\");\n this.addLocalPackage(\n vetra.manifest.name,\n vetra,\n PH_VETRA_PACKAGE_VERSION,\n );\n }\n // Same shape for the workflow package, behind its own independent flag.\n // Only the package root: `./pieces` and `./reactor` are node-only.\n if (workflowsEnabled) {\n const workflow = await import(\"@powerhousedao/workflow\");\n this.addLocalPackage(\n workflow.manifest.name,\n workflow,\n PH_WORKFLOW_PACKAGE_VERSION,\n );\n }\n if (localPackage) {\n this.updateLocalPackage(localPackage, localPackageVersion);\n }\n for (const packageName of this.#storage.keys()) {\n // Re-hydrate with the originally-requested spec so a tag/version pick\n // sticks across reloads. Fall back to the bare key for legacy entries\n // (pre-spec) and for entries that never had a tag.\n const existingMeta = this.#storage.get(packageName);\n const specForReload = existingMeta?.spec ?? packageName;\n console.debug(\n `[Connect][PackageManager] Rehydrating \"${packageName}\" via spec \"${specForReload}\"`,\n );\n const result = await this.addPackage(specForReload);\n // Previously-installed package that no longer resolves (version\n // withdrawn from npm, registry moved, etc.) would otherwise\n // 404-toast on every boot forever. Drop it from persistent storage\n // so the failure is one-shot instead of sticky.\n if (result.type === \"error\") {\n this.#storage.delete(packageName);\n }\n }\n }\n\n addLocalPackage(\n name: string,\n loadedPackage: DocumentModelLib<any>,\n version?: string,\n loadRoutes?: PackageRoutesLoader,\n ) {\n this.#localPackageNames.add(name);\n this.#registerPackage({\n name,\n importUrl: null,\n stylesheetUrl: null,\n loadedPackage,\n version,\n loadRoutes,\n });\n }\n\n updateLocalPackage(pkg: DocumentModelLib<any>, version?: string) {\n console.debug(\"Updating local package:\", pkg);\n this.#localPackage = pkg;\n this.#registerPackage({\n name: LOCAL_PACKAGE_NAME,\n stylesheetUrl: null,\n importUrl: null,\n loadedPackage: pkg,\n });\n if (version) {\n this.#localPackageVersion = version;\n this.#notifyPackagesChanged();\n return;\n }\n fetchPackageJsonVersion(\"/package.json\")\n .then((fetchedVersion) => {\n this.#localPackageVersion = fetchedVersion;\n if (fetchedVersion) this.#notifyPackagesChanged();\n })\n .catch(() => {});\n }\n\n get packages() {\n return this.#packagesMemo;\n }\n\n get localPackage(): DocumentModelLib<any> | undefined {\n return this.#localPackage;\n }\n\n get cdnUrl(): string | null {\n return this.#cdnUrl;\n }\n\n getPackageSource(packageName: string) {\n // check vs packages registered as local (Common, Vetra, bundled packages...)\n if (this.#localPackageNames.has(packageName)) {\n return \"common\";\n }\n // check if the package has the same name as the local project\n if (packageName === this.#localPackage?.manifest.name) return \"project\";\n const packageMeta = this.#storage.get(packageName);\n // if meta does not exist the package is not installed\n if (!packageMeta) return null;\n // if imported from node_modules then the package is installed locally\n if (packageMeta.importUrl === `/node_modules/${packageName}`)\n return \"local-install\";\n // all other import urls point to a registry\n return \"registry-install\";\n }\n\n /**\n * Return the registry-installed packages keyed by their storage name (which\n * is the registry spec, e.g. \"@powerhousedao/clint-common\"), with the\n * installed version when known. Excludes bundled (common) packages, the\n * local project package, and packages resolved out of `/node_modules/`.\n */\n getRegistryPackages(): { name: string; version: string | undefined }[] {\n const out: { name: string; version: string | undefined }[] = [];\n for (const [name, meta] of this.#storage) {\n if (this.#localPackageNames.has(name)) continue;\n if (name === LOCAL_PACKAGE_NAME) continue;\n if (meta.importUrl === `/node_modules/${name}`) continue;\n out.push({ name, version: meta.version });\n }\n return out;\n }\n\n getPackageVersion(packageName: string): string | undefined {\n if (packageName === this.#localPackage?.manifest.name) {\n return this.#localPackageVersion;\n }\n return this.#storage.get(packageName)?.version;\n }\n\n /**\n * The spec the user requested when this package was installed (e.g.\n * `name@dev` or `name@6.2.1`). Undefined for bare-name installs, legacy\n * entries, and local packages — the Package Manager treats that as the\n * `latest` stream when picking update targets.\n */\n getPackageSpec(packageName: string): string | undefined {\n return this.#storage.get(packageName)?.spec;\n }\n\n async addPackage(packageSpec: string): Promise<PackageManagerInstallResult> {\n // `packageSpec` may include a `@tag` / `@version` suffix (e.g. user picked\n // a specific version in the package manager UI, or re-hydrated on reload\n // from the persisted spec). We always register/look up by the bare name so\n // status tracking, version lookups, and uninstall all go through a single\n // canonical key. The spec itself is kept on the meta so reloads re-fetch\n // the same tag.\n const bareName = parseBareName(packageSpec);\n const hasTagOrVersion = bareName !== packageSpec;\n console.debug(\n `[Connect][PackageManager] addPackage spec=\"${packageSpec}\" bareName=\"${bareName}\"`,\n );\n\n const existingPackage = this.#packages.get(bareName);\n if (existingPackage) {\n const requestedVersion = hasTagOrVersion\n ? packageSpec.slice(bareName.length + 1)\n : undefined;\n const currentVersion = this.#storage.get(bareName)?.version;\n const isLocal = this.#localPackageNames.has(bareName);\n const sameVersion =\n !requestedVersion ||\n !currentVersion ||\n requestedVersion === currentVersion;\n if (isLocal || sameVersion) {\n console.debug(\n `[Connect][PackageManager] \"${bareName}\" already loaded; skipping re-fetch`,\n );\n return {\n type: \"success\",\n package: existingPackage,\n };\n }\n console.debug(\n `[Connect][PackageManager] \"${bareName}\" version bump ${currentVersion} → ${requestedVersion}; refetching`,\n );\n }\n try {\n const packageWithMeta = await this.#loadPackage(packageSpec);\n // `#loadPackage*` set `name` to whatever spec it built the URL from.\n // Canonicalize to the bare name for the map/storage keys, and stash the\n // original spec separately so reloads re-use it.\n packageWithMeta.name = bareName;\n if (hasTagOrVersion) {\n packageWithMeta.spec = packageSpec;\n }\n // Swap stylesheets only once the new package is in hand. If `#loadPackage`\n // throws above, the old stylesheet stays mounted and the UI keeps\n // rendering the previous version instead of unstyled markup.\n if (existingPackage) {\n this.#unmountStylesheet(bareName);\n }\n this.#registerPackage(packageWithMeta);\n\n return {\n type: \"success\",\n package: packageWithMeta.loadedPackage,\n };\n } catch (error) {\n const normalized =\n error instanceof Error ? error : new Error(String(error));\n console.error(\n `[Connect][PackageManager] Failed to install package \"${packageSpec}\": ${normalized.message}`,\n normalized,\n );\n return {\n type: \"error\",\n error: normalized,\n };\n }\n }\n\n async addPackages(packageNames: string[]) {\n const results: PackageManagerInstallResult[] = [];\n for (const packageName of packageNames) {\n const result = await this.addPackage(packageName);\n results.push(result);\n }\n return results;\n }\n\n removePackage(name: string) {\n this.#syncRoutes(name, undefined);\n this.#packages.delete(name);\n this.#storage.delete(name);\n this.#unmountStylesheet(name);\n this.#notifyPackagesChanged();\n }\n\n subscribe(handler: IPackagesListener): IPackageListerUnsubscribe {\n this.#subscribers.add(handler);\n return () => {\n this.#subscribers.delete(handler);\n };\n }\n\n load(documentType: string): Promise<DocumentModelModule<any>> {\n const documentModelModule = Array.from(\n this.#packages.values().flatMap((p) => p.documentModels),\n ).find((m) => m.documentModel.global.id === documentType);\n\n if (documentModelModule) return Promise.resolve(documentModelModule);\n return Promise.reject(new Error(\"Model not available\"));\n }\n\n async #loadPackageFromNodeModules(name: string): Promise<PackageWithMeta> {\n // Installed under its bare name; the spec may carry a version or tag.\n const dir = `/node_modules/${parseBareName(name)}`;\n const importUrl = `${dir}/browser/index.js`;\n const stylesheetUrl = `${dir}/style.css`;\n\n const packageWithMeta = await this.#importPackage({\n name,\n importUrl,\n stylesheetUrl,\n });\n packageWithMeta.version = await fetchPackageJsonVersion(\n `${dir}/package.json`,\n );\n\n return packageWithMeta;\n }\n\n async #loadPackageFromRegistry(name: string): Promise<PackageWithMeta> {\n const importUrl = `${this.#cdnUrl}/${name}/browser/index.js`;\n const stylesheetUrl = `${this.#cdnUrl}/${name}/style.css`;\n const packageWithMeta = await this.#importPackage({\n name,\n importUrl,\n stylesheetUrl,\n });\n const pkgJson = await fetchPackageJson(\n `${this.#cdnUrl}/${name}/package.json`,\n );\n packageWithMeta.version = pkgJson?.version;\n\n // Non-blocking warning: a package that pins a shared dep at a version\n // the host's vendor was built without still installs, but the host's\n // copy is what runs — surface the mismatch before it surprises the\n // user at runtime.\n const warnings = sharedDepMismatchWarnings(\n pkgJson,\n (await getSharedDeps())?.versions,\n );\n if (warnings.length > 0) {\n console.error(\n `[package-manager] shared-deps mismatch for ${name}:\\n` +\n warnings.join(\"\\n\"),\n );\n }\n\n return packageWithMeta;\n }\n\n async #importPackage(packageMeta: PackageMeta): Promise<PackageWithMeta> {\n const { name, importUrl, stylesheetUrl } = packageMeta;\n if (!importUrl) {\n throw new Error(`Import url not defined for package \"${name}\".`);\n }\n\n const loadedPackage = (await import(\n /* @vite-ignore */ importUrl\n )) as DocumentModelLib<any>;\n // Beside the package's entry: browser/connect-routes.js.\n const routesUrl = importUrl.replace(/index\\.js$/, \"connect-routes.js\");\n\n return {\n name,\n loadedPackage,\n importUrl,\n stylesheetUrl,\n loadRoutes: () => import(/* @vite-ignore */ routesUrl),\n };\n }\n\n async #loadPackage(packageName: string): Promise<PackageWithMeta> {\n if (this.#localPackageNames.has(packageName)) {\n throw new Error(\n `Package \"${packageName}\" is a local package and cannot be loaded dynamically.`,\n );\n }\n\n // only attemp to load from node_modules in dev mode\n if (!import.meta.env.PROD) {\n try {\n const packageWithMeta =\n await this.#loadPackageFromNodeModules(packageName);\n return packageWithMeta;\n } catch (error) {\n // Expected for a package installed only in Connect, not the project.\n console.debug(\n `\"${packageName}\" isn't in node_modules; loading it from the registry.`,\n error,\n );\n }\n }\n\n if (!this.registryUrl) {\n throw new Error(\"Registry url not defined.\");\n }\n\n return await this.#loadPackageFromRegistry(packageName);\n }\n\n /** Replaces `name`'s offered routes with `pkg`'s; the project's own package\n * is left out, as its host build already has its routes. */\n #syncRoutes(\n name: string,\n pkg: DocumentModelLib<any> | undefined,\n loadRoutes?: PackageRoutesLoader,\n ) {\n this.#routes.get(name)?.();\n this.#routes.delete(name);\n const offers = pkg?.manifest.connectRoutes && loadRoutes;\n if (!offers || name === LOCAL_PACKAGE_NAME) return;\n // A replacement before the routes load cancels them.\n let cancelled = false;\n this.#routes.set(name, () => {\n cancelled = true;\n });\n // Unknown paths wait for these routes before showing not found.\n const release = holdConnectRoutes();\n loadRoutes()\n .then(({ connectRoutes }) => {\n if (!cancelled) {\n this.#routes.set(name, registerPackageRoutes(connectRoutes));\n }\n })\n .catch((error: unknown) => {\n console.error(\n `[package-manager] ${name}'s routes failed to load:`,\n error,\n );\n })\n .finally(release);\n }\n\n #registerPackage(packageWithMeta: PackageWithMeta) {\n const { name, loadedPackage, importUrl, stylesheetUrl, version, spec } =\n packageWithMeta;\n\n if (stylesheetUrl !== null) {\n this.#mountStylesheet(name, stylesheetUrl);\n }\n this.#syncRoutes(name, loadedPackage, packageWithMeta.loadRoutes);\n this.#packages.set(name, loadedPackage);\n this.#storage.set(name, {\n name,\n importUrl,\n stylesheetUrl,\n version,\n ...(spec ? { spec } : {}),\n });\n console.debug(\n `[Connect][PackageManager] Registered \"${name}\" (version=${version ?? \"?\"}, spec=${spec ?? \"—\"})`,\n );\n\n this.#notifyPackagesChanged();\n }\n\n #mountStylesheet(name: string, href: string) {\n const existing = this.#stylesheets.get(name);\n if (existing) return existing;\n\n declareExternalPackagesLayer();\n const style = document.createElement(\"style\");\n style.textContent = `@import url(\"${href}\") layer(external-packages);`;\n document.head.appendChild(style);\n\n this.#stylesheets.set(name, style);\n }\n\n #unmountStylesheet(name: string): void {\n const style = this.#stylesheets.get(name);\n if (!style) return;\n\n style.remove();\n this.#stylesheets.delete(name);\n }\n\n #notifyPackagesChanged() {\n this.#packagesMemo = Array.from(this.#packages.values());\n const packages = this.packages;\n this.#subscribers.forEach((handler) => {\n handler({ packages });\n });\n this.#schedulePwaSync();\n }\n\n /**\n * Debounced mirror of every loaded package's PWA fragment into IndexedDB, so\n * the service worker can serve a web-app manifest that reflects packages\n * installed AT RUNTIME (a SW can't read localStorage, where the package list\n * lives). Debounced because `init()` rehydrates many packages in a burst;\n * coalescing collapses that into a single write.\n */\n #schedulePwaSync() {\n if (typeof indexedDB === \"undefined\") return;\n clearTimeout(this.#pwaSyncTimer);\n this.#pwaSyncTimer = setTimeout(() => {\n void this.#syncPwaFragments();\n }, 50);\n }\n\n async #syncPwaFragments() {\n const contributions: PwaContribution[] = [];\n for (const [name, loadedPackage] of this.#packages) {\n const manifest = loadedPackage.manifest;\n let config: PHConnectPwa = {};\n if (manifest.pwa) {\n // Third-party package code must not inject arbitrary manifest fields the\n // SW will serve — validate strictly and skip (with a warning) on failure.\n const parsed = PwaConfigSchema.safeParse(manifest.pwa);\n if (parsed.success) {\n // A package's assets live at its base (CDN for registry installs);\n // make relative icon srcs absolute so the served manifest resolves.\n const importUrl = this.#storage.get(name)?.importUrl ?? null;\n const baseUrl = importUrl\n ? importUrl.replace(/browser\\/index\\.js$/, \"\")\n : null;\n config = resolveFragmentAssetUrls(parsed.data, baseUrl);\n } else {\n console.warn(\n `[Connect][PWA] \"${name}\" ships an invalid pwa fragment; skipped.`,\n parsed.error,\n );\n }\n }\n // `categories` is derived from the manifest's `category` field (not\n // authored under `pwa`); it unions into the SW-served manifest so a\n // runtime-installed package's category shows up like a build-time one.\n config = withInferredCategory(config, manifest.category);\n if (Object.keys(config).length === 0) continue;\n contributions.push({ source: name, config });\n }\n // Fold in load order (base-first ordering is preserved so a package cannot\n // hijack the built-in .phd/.phdm handler at merge time either).\n const merged = mergePwaConfig(contributions);\n // Most package operations don't touch PWA config; skip the write + manifest\n // re-attach (which forces a redundant manifest re-fetch) when unchanged.\n const mergedJson = JSON.stringify(merged);\n if (mergedJson === this.#lastSyncedFragmentJson) return;\n try {\n await writeMergedPwaFragment(merged);\n } catch (error) {\n // Leave #lastSyncedFragmentJson unset so a later sync retries the write.\n console.debug(\n \"[Connect][PWA] fragment mirror to IndexedDB failed:\",\n error,\n );\n return;\n }\n this.#lastSyncedFragmentJson = mergedJson;\n // The SW serves the manifest fresh from IndexedDB, but the browser only\n // parsed <link rel=\"manifest\"> at page load — re-attach it so it\n // re-consumes the now-updated manifest without a manual reload. (Kept out\n // of the write's try/catch so a DOM error isn't mislabeled as an IDB\n // failure; refreshPwaManifestLink is itself non-throwing.)\n refreshPwaManifestLink();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AASA,SAAS,qBAAyC;CAChD,OAAO,OAAO,+BAA+B,cACzC,6BACA,KAAA;AACN;;;;;AAMA,SAAgB,oBACd,aACA,OACA,KACe;CACf,IAAI,OAAO,OAAO,sBAAsB,OAAO,WAAW;CAC1D,OAAO,MAAM,OAAO,GAAG,YAAY;AACrC;;;;;;;;;;AAgBA,SAAgB,uBACd,YACA,aACwB;CAGxB,MAAM,SACH,WAAuC,UAAU,UAClD;CACF,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAChD,MACA,IAAI,IAAI,sBAAsB,OAAO,WAAW,GAAG,MAAM,CAAC,CAAC,IAC7D,CAAC,CACH;AACF;AAEA,IAAI,SAA4C;;;;;;;;;AAUhD,SAAgB,gBAA4C;CAC1D,YAAY,YAAY;EACtB,MAAM,MAAM,oBACV,YAAY,IAAI,UAChB,mBAAmB,GACnB,YAAY,IAAI,GAClB;EACA,IAAI,QAAQ,MAAM,OAAO;EACzB,IAAI;GACF,MAAM,MAAO,MAAM;;IAA0B;;GAI7C,OAAO;IACL,SA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Aa,KAAK,UAAU,MAAM;EACxC,IAAI,eAAe,KAAK,yBAAyB;EACjD,IAAI;GACF,MAAM,uBAAuB,MAAM;EACrC,SAAS,OAAO;GAEd,QAAQ,MACN,uDACA,KACF;GACA;EACF;EACA,KAAK,0BAA0B;EAM/B,uBAAuB;CACzB;AACF","debug_id":"e760bea5-678f-545c-aa5f-765c61f486ac"}
|
|
@@ -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]="76171bba-0406-5ce5-99de-e4cfccae080c")}catch(e){}}();
|
|
3
3
|
import { a as genericConfigSchema, i as openPanelConfigSchema, n as vetraStudioConfigSchema, o as assistantConfigSchema, r as sentryConfigSchema, t as workflowsConnectConfigSchema } from "./workflows-C3qEvx1R.js";
|
|
4
4
|
import { DEFAULT_CONNECT_CONFIG } from "@powerhousedao/shared/connect";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -182,7 +182,7 @@ const driveSectionOff = {
|
|
|
182
182
|
const connectPlugins = {
|
|
183
183
|
[GENERIC_PLUGIN]: {
|
|
184
184
|
create: createGenericPlugin,
|
|
185
|
-
ui: () => import("./ui-
|
|
185
|
+
ui: () => import("./ui-2WQWmdf-.js").then((m) => m.default),
|
|
186
186
|
shell: "generic",
|
|
187
187
|
whenAbsent: (config) => ({
|
|
188
188
|
...config,
|
|
@@ -260,5 +260,5 @@ const connectPlugins = {
|
|
|
260
260
|
//#endregion
|
|
261
261
|
export { connectPlugins };
|
|
262
262
|
|
|
263
|
-
//# sourceMappingURL=plugins-
|
|
264
|
-
//# debugId=
|
|
263
|
+
//# sourceMappingURL=plugins-BJHHJpIK.js.map
|
|
264
|
+
//# debugId=76171bba-0406-5ce5-99de-e4cfccae080c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins-DaEBpGLp.js","sources":["../src/plugins/entry-config.ts","../src/plugins/assistant.ts","../src/plugins/generic.ts","../src/plugins/openpanel.ts","../src/plugins/sentry.ts","../src/plugins/ids.ts","../src/plugins/vetra-studio.ts","../src/plugins/workflows.ts","../src/plugins/index.ts"],"sourcesContent":["import { PluginError } from \"@powerhousedao/host-core/plugins\";\nimport { z } from \"zod\";\n\n/**\n * Validate a built-in plugin's entry config against its configSchema, the way\n * host-core's resolveHostPlugins does on the server: a failure names the\n * plugin and every offending key instead of surfacing a bare ZodError from\n * the runtime-config load.\n */\nexport function parseEntryConfig<S extends z.ZodType>(\n specifier: string,\n schema: S,\n rawConfig: unknown,\n): z.output<S> {\n const parsed = schema.safeParse(rawConfig);\n if (!parsed.success) {\n throw new PluginError(\n `config for Connect plugin \"${specifier}\" is invalid:\\n` +\n z.prettifyError(parsed.error),\n `Fix the entry's config in the host's runner.plugins.`,\n );\n }\n return parsed.data;\n}\n","import type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n assistantConfigSchema,\n type AssistantConfigInput,\n} from \"../plugin-configs/assistant.js\";\n\n/**\n * The Connect AI assistant (`@powerhousedao/connect/plugins/assistant`).\n * Presence flips `ai.assistantEnabled` on; absence forces it off. The\n * assistant FAB in app.tsx already renders on `ai.assistantEnabled`, so this\n * plugin's config shuffle is immediately visible in the UI.\n *\n * It takes no entry config: `ai.assistantEnabled` is the only key of the\n * `connect.ai` slice, and presence is that switch. The endpoint and agent are\n * user settings in the browser, not host config.\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { assistantConfigSchema, type AssistantConfigInput };\n\nexport const createAssistantPlugin: ConnectPluginFactory = (rawConfig) => {\n parseEntryConfig(\n \"@powerhousedao/connect/plugins/assistant\",\n assistantConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-assistant\",\n appliesTo: \"connect\",\n configSchema: assistantConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n return {\n ...served,\n ai: { ...served.ai, assistantEnabled: true },\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createAssistantPlugin;\n","import { DEFAULT_CONNECT_CONFIG } from \"@powerhousedao/shared/connect\";\nimport type {\n PHBackground,\n PHConnectExplorerIcons,\n PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n genericConfigSchema,\n type GenericConfig,\n type GenericConfigInput,\n} from \"../plugin-configs/generic.js\";\n\n/**\n * The generic Connect shell plugin (`@powerhousedao/connect/plugins/generic`).\n *\n * It OWNS the drive-chrome UI toggles — `allowAddDrive` and the per-section\n * `sections.{remote,local}` switches (enabled / allowAdd / allowDelete) —\n * the explorer's `icons` (local/remote drive fallbacks, folder, document and\n * per-type document icons, which override the icons a package ships) and the\n * home screen's `homeBackground` (its layers over a page colour). These\n * describe nothing outside the generic chrome (connect.config.ts reads the\n * toggles to decide whether the add-drive affordance and the drive sections\n * render; the explorer components read the icons; the home screen is the\n * chrome's landing page), so under uniform runners they are configured HERE,\n * through this plugin's entry config, not as free-standing top-level\n * connect.drives / connect.home values:\n *\n * - present + entry provides a value -> that value\n * - present + entry omits it -> inherit DEFAULT_CONNECT_CONFIG\n * - absent from the composition -> zeroed off (see its whenAbsent\n * in ./index.ts — no chrome, no\n * toggles)\n *\n * The top-level served value is deliberately NOT a fallback: ownership means a\n * single source. `branding` is intentionally NOT handled here — it has reach\n * beyond the chrome (e.g. document.title), so it stays a Connect-level config\n * value that survives this plugin's absence.\n *\n * Icons and background images are image refs; a project path in host.js is\n * resolved to a data URI by the Connect build before the composition reaches\n * the browser, a URL or data URI passes through (the only forms for config\n * applied after the build). `null` keeps the built-in icon / gradient.\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { genericConfigSchema, type GenericConfig, type GenericConfigInput };\n\nconst DEFAULT_DRIVES = DEFAULT_CONNECT_CONFIG.drives;\nconst DEFAULT_HOME = DEFAULT_CONNECT_CONFIG.home;\n\nexport const createGenericPlugin: ConnectPluginFactory = (rawConfig) => {\n const config: GenericConfig = parseEntryConfig(\n \"@powerhousedao/connect/plugins/generic\",\n genericConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-generic\",\n appliesTo: \"connect\",\n configSchema: genericConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n const entrySections = config.sections ?? {};\n return {\n ...served,\n drives: {\n ...served.drives,\n // Owned: entry value, else the single-source default — never the\n // served top-level value.\n allowAddDrive:\n config.allowAddDrive ?? DEFAULT_DRIVES?.allowAddDrive,\n sections: {\n remote: {\n ...DEFAULT_DRIVES?.sections?.remote,\n ...entrySections.remote,\n },\n local: {\n ...DEFAULT_DRIVES?.sections?.local,\n ...entrySections.local,\n },\n },\n // Owned: the entry's icons (already resolved by the build), else\n // the default — the built-in icons.\n icons: (config.icons ?? null) as PHConnectExplorerIcons | null,\n } as never,\n home: {\n ...served.home,\n // Owned: the entry's background (images resolved by the build),\n // else the default — the bundled gradient.\n background: (config.homeBackground ??\n DEFAULT_HOME?.background ??\n null) as PHBackground | null,\n },\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createGenericPlugin;\n","import type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n openPanelConfigSchema,\n type OpenPanelConfigInput,\n} from \"../plugin-configs/openpanel.js\";\n\n/**\n * OpenPanel analytics (`@powerhousedao/connect/plugins/openpanel`). Presence\n * is activation: the entry config (clientId, trackUiEvents, trackOperations)\n * merges into the served `openPanel` block; absence clears the clientId and\n * turns tracking off. Config shuffle today; the Analytics/OpenPanel\n * components that consume it already live in the app tree.\n *\n * The entry config IS the `connect.openPanel` slice, so it is typed and\n * validated by that slice's single-source schema (a typo'd key fails).\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { openPanelConfigSchema, type OpenPanelConfigInput };\n\nexport const createOpenPanelPlugin: ConnectPluginFactory = (rawConfig) => {\n const config = parseEntryConfig(\n \"@powerhousedao/connect/plugins/openpanel\",\n openPanelConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-openpanel\",\n appliesTo: \"connect\",\n configSchema: openPanelConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n return {\n ...served,\n openPanel: { ...served.openPanel, ...config } as never,\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createOpenPanelPlugin;\n","import type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n sentryConfigSchema,\n type SentryConfigInput,\n} from \"../plugin-configs/sentry.js\";\n\n/**\n * Sentry error reporting (`@powerhousedao/connect/plugins/sentry`). Presence\n * is activation: listing it merges the entry config (dsn, env, tracing) into\n * the served `sentry` block; omitting it nulls the dsn (see the absence\n * zeroing in plugin-host). A thin config shuffle today — the SentryProvider\n * that reads this slice already exists in the app.\n *\n * The entry config IS the `connect.sentry` slice, so it is typed and\n * validated by that slice's single-source schema (a typo'd key fails).\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { sentryConfigSchema, type SentryConfigInput };\n\nexport const createSentryPlugin: ConnectPluginFactory = (rawConfig) => {\n const config = parseEntryConfig(\n \"@powerhousedao/connect/plugins/sentry\",\n sentryConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-sentry\",\n appliesTo: \"connect\",\n configSchema: sentryConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n return {\n ...served,\n sentry: { ...served.sentry, ...config } as never,\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createSentryPlugin;\n","/** The generic shell: Connect's sidebar, home screen and settings tabs. */\nexport const GENERIC_PLUGIN = \"@powerhousedao/connect/plugins/generic\";\n","import type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n vetraStudioConfigSchema,\n type VetraStudioConfigInput,\n} from \"../plugin-configs/vetra-studio.js\";\n\n/**\n * Vetra Studio, browser side (`@powerhousedao/vetra-studio/connect`). Its\n * presence turns Connect's studio mode on; the classic `app.studioMode`\n * consumer paths run unchanged, and absence forces studio off (the zeroing in\n * plugin-host). Lives here, in Connect's own source, because the studio-mode\n * behaviour is Connect browser behaviour — the published vetra-studio/connect\n * module is only the server-resolvable identity of the same plugin.\n *\n * It takes no entry config: presence is the switch, and the rest of the\n * `connect.app` slice is Connect-level config, not this plugin's.\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { vetraStudioConfigSchema, type VetraStudioConfigInput };\n\nexport const createVetraStudioPlugin: ConnectPluginFactory = (rawConfig) => {\n parseEntryConfig(\n \"@powerhousedao/vetra-studio/connect\",\n vetraStudioConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"vetra-studio-connect\",\n appliesTo: \"connect\",\n configSchema: vetraStudioConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n return {\n ...served,\n app: { ...served.app, studioMode: true },\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createVetraStudioPlugin;\n","import { findToken } from \"@powerhousedao/host-core/schema\";\nimport type {\n PHConnectDefaultDrive,\n PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n workflowsConnectConfigSchema,\n type WorkflowsConnectConfig,\n type WorkflowsConnectConfigInput,\n} from \"../plugin-configs/workflows.js\";\n\n/**\n * The workflows plugin, browser side (`@powerhousedao/connect/plugins/\n * workflows`) — the Connect half of the link whose server half is\n * `@powerhousedao/switchboard/plugins/workflows` (workflow-plugins plan).\n *\n * Presence is activation: listed, Connect loads the workflow package (so\n * Workflow Studio, the drive app the Workflows drive names as its preferred\n * editor, exists) and attaches the configured drive as a remote default\n * drive. Absent from a declared composition, `app.workflowsEnabled` is zeroed\n * (its whenAbsent in ./index.ts) — the classic `workflows.enabled` /\n * `connect.app.workflowsEnabled` values stop being the switch.\n *\n * `drive` is the switchboard's drive URL (`http://host:port/d/<slug>`). The\n * drive has to be a REMOTE of the switchboard that runs the workflow runtime:\n * Workflow Studio reaches that runtime through the selected drive's\n * switchboard, so a local copy would render the studio against the wrong\n * endpoint. Host files write it as the output token\n * `switchboard.drives.workflows.url`; `ph run` resolves it (from the\n * compound's live member or the switchboard's run record) before this\n * config reaches the browser.\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport {\n workflowsConnectConfigSchema,\n type WorkflowsConnectConfig,\n type WorkflowsConnectConfigInput,\n};\n\nconst LOG = \"[connect:plugins:workflows]\";\n\nfunction withDrive(\n drives: PHConnectDefaultDrive[] | undefined,\n url: string,\n name: string | undefined,\n): PHConnectDefaultDrive[] {\n const existing = drives ?? [];\n if (existing.some((drive) => \"url\" in drive && drive.url === url)) {\n return existing;\n }\n return [...existing, { url, name: name ?? null, icon: null }];\n}\n\nexport const createWorkflowsPlugin: ConnectPluginFactory = (rawConfig) => {\n const config: WorkflowsConnectConfig = parseEntryConfig(\n \"@powerhousedao/connect/plugins/workflows\",\n workflowsConnectConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-workflows\",\n appliesTo: \"connect\",\n configSchema: workflowsConnectConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n const out: PHConnectRuntimeConfig = {\n ...served,\n app: { ...served.app, workflowsEnabled: true } as never,\n };\n const drive = config.drive;\n if (typeof drive === \"string\") {\n out.drives = {\n ...served.drives,\n defaultDrives: withDrive(\n served.drives?.defaultDrives,\n drive,\n config.name,\n ),\n } as never;\n } else if (drive !== undefined) {\n console.warn(\n `${LOG} drive is an unresolved output token (${findToken(drive)?.key ?? \"unknown\"}); no Workflows drive attached.`,\n );\n }\n return out;\n },\n },\n };\n return plugin;\n};\n\nexport default createWorkflowsPlugin;\n","import type { ConnectPluginDefinition } from \"@powerhousedao/connect-core/plugins\";\nimport createAssistantPlugin from \"./assistant.js\";\nimport createGenericPlugin from \"./generic.js\";\nimport createOpenPanelPlugin from \"./openpanel.js\";\nimport createSentryPlugin from \"./sentry.js\";\nimport { GENERIC_PLUGIN } from \"./ids.js\";\nimport createVetraStudioPlugin from \"./vetra-studio.js\";\nimport createWorkflowsPlugin from \"./workflows.js\";\n\nexport { GENERIC_PLUGIN };\n\n// Sentry and OpenPanel start only once the viewer accepts analytics cookies.\nconst ANALYTICS_CONSENT = { consent: true };\n\n// Each built-in zeroes the config slice it owns when a composition leaves it out.\nconst driveSectionOff = { enabled: false, allowAdd: false, allowDelete: false };\n\n/** Connect's built-in plugins, by the specifier a composition names. */\nexport const connectPlugins: Record<string, ConnectPluginDefinition> = {\n [GENERIC_PLUGIN]: {\n create: createGenericPlugin,\n ui: () => import(\"../generic/ui.js\").then((m) => m.default),\n shell: \"generic\",\n // The drive-chrome toggles, explorer icons and home screen go: no\n // add-drive affordance, the sections off, built-in icons, no home\n // background. Branding is not zeroed: it is Connect-level and outlives\n // the plugin.\n whenAbsent: (config) => ({\n ...config,\n drives: {\n ...config.drives,\n allowAddDrive: false,\n sections: { remote: driveSectionOff, local: driveSectionOff },\n icons: null,\n } as never,\n home: { ...config.home, background: null } as never,\n }),\n },\n \"@powerhousedao/connect/plugins/sentry\": {\n create: createSentryPlugin,\n ui: () => Promise.resolve(ANALYTICS_CONSENT),\n whenAbsent: (config) => ({\n ...config,\n sentry: { ...config.sentry, dsn: null } as never,\n }),\n },\n \"@powerhousedao/connect/plugins/openpanel\": {\n create: createOpenPanelPlugin,\n ui: () => Promise.resolve(ANALYTICS_CONSENT),\n whenAbsent: (config) => ({\n ...config,\n openPanel: {\n ...config.openPanel,\n clientId: \"\",\n trackUiEvents: false,\n trackOperations: false,\n } as never,\n }),\n },\n \"@powerhousedao/connect/plugins/assistant\": {\n create: createAssistantPlugin,\n whenAbsent: (config) => ({\n ...config,\n ai: { ...config.ai, assistantEnabled: false } as never,\n }),\n },\n \"@powerhousedao/connect/plugins/workflows\": {\n create: createWorkflowsPlugin,\n // The workflow package (Workflow Studio) loads only when the plugin is\n // composed in; the classic workflows.enabled value is not the switch.\n whenAbsent: (config) => ({\n ...config,\n app: { ...config.app, workflowsEnabled: false } as never,\n }),\n },\n \"@powerhousedao/vetra-studio/connect\": {\n create: createVetraStudioPlugin,\n // Studio sign-in (#studio-sign-in=<bearer>), for agents.\n ui: () => import(\"./vetra-studio/ui.js\").then((m) => m.default),\n whenAbsent: (config) => ({\n ...config,\n app: { ...config.app, studioMode: false } as never,\n }),\n },\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AASA,SAAgB,iBACd,WACA,QACA,WACa;CACb,MAAM,SAAS,OAAO,UAAU,SAAS;CACzC,IAAI,CAAC,OAAO,SACV,MAAM,IAAI,YACR,8BAA8B,UAAU,mBACtC,EAAE,c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kB;CAAE,SAAS;CAAO,UAAU;CAAO,aAAa;AAAM;;AAG9E,MAAa,iBAA0D;EACpE,iBAAiB;EAChB,QAAQ;EACR,UAAU,OAAO,mBAAmB,CAAC,MAAM,MAAM,EAAE,OAAO;EAC1D,OAAO;EAKP,aAAa,YAAY;GACvB,GAAG;GACH,QAAQ;IACN,GAAG,OAAO;IACV,eAAe;IACf,UAAU;KAAE,QAAQ;KAAiB,OAAO;IAAgB;IAC5D,OAAO;GACT;GACA,MAAM;IAAE,GAAG,OAAO;IAAM,YAAY;GAAK;EAC3C;CACF;CACA,yCAAyC;EACvC,QAAQ;EACR,UAAU,QAAQ,QAAQ,iBAAiB;EAC3C,aAAa,YAAY;GACvB,GAAG;GACH,QAAQ;IAAE,GAAG,OAAO;IAAQ,KAAK;GAAK;EACxC;CACF;CACA,4CAA4C;EAC1C,QAAQ;EACR,UAAU,QAAQ,QAAQ,iBAAiB;EAC3C,aAAa,YAAY;GACvB,GAAG;GACH,WAAW;IACT,GAAG,OAAO;IACV,UAAU;IACV,eAAe;IACf,iBAAiB;GACnB;EACF;CACF;CACA,4CAA4C;EAC1C,QAAQ;EACR,aAAa,YAAY;GACvB,GAAG;GACH,IAAI;IAAE,GAAG,OAAO;IAAI,kBAAkB;GAAM;EAC9C;CACF;CACA,4CAA4C;EAC1C,QAAQ;EAGR,aAAa,YAAY;GACvB,GAAG;GACH,KAAK;IAAE,GAAG,OAAO;IAAK,kBAAkB;GAAM;EAChD;CACF;CACA,uCAAuC;EACrC,QAAQ;EAER,UAAU,OAAO,mBAAuB,CAAC,MAAM,MAAM,EAAE,OAAO;EAC9D,aAAa,YAAY;GACvB,GAAG;GACH,KAAK;IAAE,GAAG,OAAO;IAAK,YAAY;GAAM;EAC1C;CACF;AACF","debug_id":"de286430-df9a-5299-aa7d-4d5748669ab2"}
|
|
1
|
+
{"version":3,"file":"plugins-BJHHJpIK.js","sources":["../src/plugins/entry-config.ts","../src/plugins/assistant.ts","../src/plugins/generic.ts","../src/plugins/openpanel.ts","../src/plugins/sentry.ts","../src/plugins/ids.ts","../src/plugins/vetra-studio.ts","../src/plugins/workflows.ts","../src/plugins/index.ts"],"sourcesContent":["import { PluginError } from \"@powerhousedao/host-core/plugins\";\nimport { z } from \"zod\";\n\n/**\n * Validate a built-in plugin's entry config against its configSchema, the way\n * host-core's resolveHostPlugins does on the server: a failure names the\n * plugin and every offending key instead of surfacing a bare ZodError from\n * the runtime-config load.\n */\nexport function parseEntryConfig<S extends z.ZodType>(\n specifier: string,\n schema: S,\n rawConfig: unknown,\n): z.output<S> {\n const parsed = schema.safeParse(rawConfig);\n if (!parsed.success) {\n throw new PluginError(\n `config for Connect plugin \"${specifier}\" is invalid:\\n` +\n z.prettifyError(parsed.error),\n `Fix the entry's config in the host's runner.plugins.`,\n );\n }\n return parsed.data;\n}\n","import type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n assistantConfigSchema,\n type AssistantConfigInput,\n} from \"../plugin-configs/assistant.js\";\n\n/**\n * The Connect AI assistant (`@powerhousedao/connect/plugins/assistant`).\n * Presence flips `ai.assistantEnabled` on; absence forces it off. The\n * assistant FAB in app.tsx already renders on `ai.assistantEnabled`, so this\n * plugin's config shuffle is immediately visible in the UI.\n *\n * It takes no entry config: `ai.assistantEnabled` is the only key of the\n * `connect.ai` slice, and presence is that switch. The endpoint and agent are\n * user settings in the browser, not host config.\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { assistantConfigSchema, type AssistantConfigInput };\n\nexport const createAssistantPlugin: ConnectPluginFactory = (rawConfig) => {\n parseEntryConfig(\n \"@powerhousedao/connect/plugins/assistant\",\n assistantConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-assistant\",\n appliesTo: \"connect\",\n configSchema: assistantConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n return {\n ...served,\n ai: { ...served.ai, assistantEnabled: true },\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createAssistantPlugin;\n","import { DEFAULT_CONNECT_CONFIG } from \"@powerhousedao/shared/connect\";\nimport type {\n PHBackground,\n PHConnectExplorerIcons,\n PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n genericConfigSchema,\n type GenericConfig,\n type GenericConfigInput,\n} from \"../plugin-configs/generic.js\";\n\n/**\n * The generic Connect shell plugin (`@powerhousedao/connect/plugins/generic`).\n *\n * It OWNS the drive-chrome UI toggles — `allowAddDrive` and the per-section\n * `sections.{remote,local}` switches (enabled / allowAdd / allowDelete) —\n * the explorer's `icons` (local/remote drive fallbacks, folder, document and\n * per-type document icons, which override the icons a package ships) and the\n * home screen's `homeBackground` (its layers over a page colour). These\n * describe nothing outside the generic chrome (connect.config.ts reads the\n * toggles to decide whether the add-drive affordance and the drive sections\n * render; the explorer components read the icons; the home screen is the\n * chrome's landing page), so under uniform runners they are configured HERE,\n * through this plugin's entry config, not as free-standing top-level\n * connect.drives / connect.home values:\n *\n * - present + entry provides a value -> that value\n * - present + entry omits it -> inherit DEFAULT_CONNECT_CONFIG\n * - absent from the composition -> zeroed off (see its whenAbsent\n * in ./index.ts — no chrome, no\n * toggles)\n *\n * The top-level served value is deliberately NOT a fallback: ownership means a\n * single source. `branding` is intentionally NOT handled here — it has reach\n * beyond the chrome (e.g. document.title), so it stays a Connect-level config\n * value that survives this plugin's absence.\n *\n * Icons and background images are image refs; a project path in host.js is\n * resolved to a data URI by the Connect build before the composition reaches\n * the browser, a URL or data URI passes through (the only forms for config\n * applied after the build). `null` keeps the built-in icon / gradient.\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { genericConfigSchema, type GenericConfig, type GenericConfigInput };\n\nconst DEFAULT_DRIVES = DEFAULT_CONNECT_CONFIG.drives;\nconst DEFAULT_HOME = DEFAULT_CONNECT_CONFIG.home;\n\nexport const createGenericPlugin: ConnectPluginFactory = (rawConfig) => {\n const config: GenericConfig = parseEntryConfig(\n \"@powerhousedao/connect/plugins/generic\",\n genericConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-generic\",\n appliesTo: \"connect\",\n configSchema: genericConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n const entrySections = config.sections ?? {};\n return {\n ...served,\n drives: {\n ...served.drives,\n // Owned: entry value, else the single-source default — never the\n // served top-level value.\n allowAddDrive:\n config.allowAddDrive ?? DEFAULT_DRIVES?.allowAddDrive,\n sections: {\n remote: {\n ...DEFAULT_DRIVES?.sections?.remote,\n ...entrySections.remote,\n },\n local: {\n ...DEFAULT_DRIVES?.sections?.local,\n ...entrySections.local,\n },\n },\n // Owned: the entry's icons (already resolved by the build), else\n // the default — the built-in icons.\n icons: (config.icons ?? null) as PHConnectExplorerIcons | null,\n } as never,\n home: {\n ...served.home,\n // Owned: the entry's background (images resolved by the build),\n // else the default — the bundled gradient.\n background: (config.homeBackground ??\n DEFAULT_HOME?.background ??\n null) as PHBackground | null,\n },\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createGenericPlugin;\n","import type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n openPanelConfigSchema,\n type OpenPanelConfigInput,\n} from \"../plugin-configs/openpanel.js\";\n\n/**\n * OpenPanel analytics (`@powerhousedao/connect/plugins/openpanel`). Presence\n * is activation: the entry config (clientId, trackUiEvents, trackOperations)\n * merges into the served `openPanel` block; absence clears the clientId and\n * turns tracking off. Config shuffle today; the Analytics/OpenPanel\n * components that consume it already live in the app tree.\n *\n * The entry config IS the `connect.openPanel` slice, so it is typed and\n * validated by that slice's single-source schema (a typo'd key fails).\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { openPanelConfigSchema, type OpenPanelConfigInput };\n\nexport const createOpenPanelPlugin: ConnectPluginFactory = (rawConfig) => {\n const config = parseEntryConfig(\n \"@powerhousedao/connect/plugins/openpanel\",\n openPanelConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-openpanel\",\n appliesTo: \"connect\",\n configSchema: openPanelConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n return {\n ...served,\n openPanel: { ...served.openPanel, ...config } as never,\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createOpenPanelPlugin;\n","import type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n sentryConfigSchema,\n type SentryConfigInput,\n} from \"../plugin-configs/sentry.js\";\n\n/**\n * Sentry error reporting (`@powerhousedao/connect/plugins/sentry`). Presence\n * is activation: listing it merges the entry config (dsn, env, tracing) into\n * the served `sentry` block; omitting it nulls the dsn (see the absence\n * zeroing in plugin-host). A thin config shuffle today — the SentryProvider\n * that reads this slice already exists in the app.\n *\n * The entry config IS the `connect.sentry` slice, so it is typed and\n * validated by that slice's single-source schema (a typo'd key fails).\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { sentryConfigSchema, type SentryConfigInput };\n\nexport const createSentryPlugin: ConnectPluginFactory = (rawConfig) => {\n const config = parseEntryConfig(\n \"@powerhousedao/connect/plugins/sentry\",\n sentryConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-sentry\",\n appliesTo: \"connect\",\n configSchema: sentryConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n return {\n ...served,\n sentry: { ...served.sentry, ...config } as never,\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createSentryPlugin;\n","/** The generic shell: Connect's sidebar, home screen and settings tabs. */\nexport const GENERIC_PLUGIN = \"@powerhousedao/connect/plugins/generic\";\n","import type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n vetraStudioConfigSchema,\n type VetraStudioConfigInput,\n} from \"../plugin-configs/vetra-studio.js\";\n\n/**\n * Vetra Studio, browser side (`@powerhousedao/vetra-studio/connect`). Its\n * presence turns Connect's studio mode on; the classic `app.studioMode`\n * consumer paths run unchanged, and absence forces studio off (the zeroing in\n * plugin-host). Lives here, in Connect's own source, because the studio-mode\n * behaviour is Connect browser behaviour — the published vetra-studio/connect\n * module is only the server-resolvable identity of the same plugin.\n *\n * It takes no entry config: presence is the switch, and the rest of the\n * `connect.app` slice is Connect-level config, not this plugin's.\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport { vetraStudioConfigSchema, type VetraStudioConfigInput };\n\nexport const createVetraStudioPlugin: ConnectPluginFactory = (rawConfig) => {\n parseEntryConfig(\n \"@powerhousedao/vetra-studio/connect\",\n vetraStudioConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"vetra-studio-connect\",\n appliesTo: \"connect\",\n configSchema: vetraStudioConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n return {\n ...served,\n app: { ...served.app, studioMode: true },\n };\n },\n },\n };\n return plugin;\n};\n\nexport default createVetraStudioPlugin;\n","import { findToken } from \"@powerhousedao/host-core/schema\";\nimport type {\n PHConnectDefaultDrive,\n PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport type {\n ConnectPlugin,\n ConnectPluginFactory,\n} from \"@powerhousedao/connect-core/plugins\";\nimport { parseEntryConfig } from \"./entry-config.js\";\nimport {\n workflowsConnectConfigSchema,\n type WorkflowsConnectConfig,\n type WorkflowsConnectConfigInput,\n} from \"../plugin-configs/workflows.js\";\n\n/**\n * The workflows plugin, browser side (`@powerhousedao/connect/plugins/\n * workflows`) — the Connect half of the link whose server half is\n * `@powerhousedao/switchboard/plugins/workflows` (workflow-plugins plan).\n *\n * Presence is activation: listed, Connect loads the workflow package (so\n * Workflow Studio, the drive app the Workflows drive names as its preferred\n * editor, exists) and attaches the configured drive as a remote default\n * drive. Absent from a declared composition, `app.workflowsEnabled` is zeroed\n * (its whenAbsent in ./index.ts) — the classic `workflows.enabled` /\n * `connect.app.workflowsEnabled` values stop being the switch.\n *\n * `drive` is the switchboard's drive URL (`http://host:port/d/<slug>`). The\n * drive has to be a REMOTE of the switchboard that runs the workflow runtime:\n * Workflow Studio reaches that runtime through the selected drive's\n * switchboard, so a local copy would render the studio against the wrong\n * endpoint. Host files write it as the output token\n * `switchboard.drives.workflows.url`; `ph run` resolves it (from the\n * compound's live member or the switchboard's run record) before this\n * config reaches the browser.\n */\n\n// Schema and PHPluginConfigs augmentation: ../plugin-configs (zod-only).\nexport {\n workflowsConnectConfigSchema,\n type WorkflowsConnectConfig,\n type WorkflowsConnectConfigInput,\n};\n\nconst LOG = \"[connect:plugins:workflows]\";\n\nfunction withDrive(\n drives: PHConnectDefaultDrive[] | undefined,\n url: string,\n name: string | undefined,\n): PHConnectDefaultDrive[] {\n const existing = drives ?? [];\n if (existing.some((drive) => \"url\" in drive && drive.url === url)) {\n return existing;\n }\n return [...existing, { url, name: name ?? null, icon: null }];\n}\n\nexport const createWorkflowsPlugin: ConnectPluginFactory = (rawConfig) => {\n const config: WorkflowsConnectConfig = parseEntryConfig(\n \"@powerhousedao/connect/plugins/workflows\",\n workflowsConnectConfigSchema,\n rawConfig,\n );\n const plugin: ConnectPlugin = {\n name: \"connect-workflows\",\n appliesTo: \"connect\",\n configSchema: workflowsConnectConfigSchema,\n hooks: {\n transformConnectConfig(served: PHConnectRuntimeConfig) {\n const out: PHConnectRuntimeConfig = {\n ...served,\n app: { ...served.app, workflowsEnabled: true } as never,\n };\n const drive = config.drive;\n if (typeof drive === \"string\") {\n out.drives = {\n ...served.drives,\n defaultDrives: withDrive(\n served.drives?.defaultDrives,\n drive,\n config.name,\n ),\n } as never;\n } else if (drive !== undefined) {\n console.warn(\n `${LOG} drive is an unresolved output token (${findToken(drive)?.key ?? \"unknown\"}); no Workflows drive attached.`,\n );\n }\n return out;\n },\n },\n };\n return plugin;\n};\n\nexport default createWorkflowsPlugin;\n","import type { ConnectPluginDefinition } from \"@powerhousedao/connect-core/plugins\";\nimport createAssistantPlugin from \"./assistant.js\";\nimport createGenericPlugin from \"./generic.js\";\nimport createOpenPanelPlugin from \"./openpanel.js\";\nimport createSentryPlugin from \"./sentry.js\";\nimport { GENERIC_PLUGIN } from \"./ids.js\";\nimport createVetraStudioPlugin from \"./vetra-studio.js\";\nimport createWorkflowsPlugin from \"./workflows.js\";\n\nexport { GENERIC_PLUGIN };\n\n// Sentry and OpenPanel start only once the viewer accepts analytics cookies.\nconst ANALYTICS_CONSENT = { consent: true };\n\n// Each built-in zeroes the config slice it owns when a composition leaves it out.\nconst driveSectionOff = { enabled: false, allowAdd: false, allowDelete: false };\n\n/** Connect's built-in plugins, by the specifier a composition names. */\nexport const connectPlugins: Record<string, ConnectPluginDefinition> = {\n [GENERIC_PLUGIN]: {\n create: createGenericPlugin,\n ui: () => import(\"../generic/ui.js\").then((m) => m.default),\n shell: \"generic\",\n // The drive-chrome toggles, explorer icons and home screen go: no\n // add-drive affordance, the sections off, built-in icons, no home\n // background. Branding is not zeroed: it is Connect-level and outlives\n // the plugin.\n whenAbsent: (config) => ({\n ...config,\n drives: {\n ...config.drives,\n allowAddDrive: false,\n sections: { remote: driveSectionOff, local: driveSectionOff },\n icons: null,\n } as never,\n home: { ...config.home, background: null } as never,\n }),\n },\n \"@powerhousedao/connect/plugins/sentry\": {\n create: createSentryPlugin,\n ui: () => Promise.resolve(ANALYTICS_CONSENT),\n whenAbsent: (config) => ({\n ...config,\n sentry: { ...config.sentry, dsn: null } as never,\n }),\n },\n \"@powerhousedao/connect/plugins/openpanel\": {\n create: createOpenPanelPlugin,\n ui: () => Promise.resolve(ANALYTICS_CONSENT),\n whenAbsent: (config) => ({\n ...config,\n openPanel: {\n ...config.openPanel,\n clientId: \"\",\n trackUiEvents: false,\n trackOperations: false,\n } as never,\n }),\n },\n \"@powerhousedao/connect/plugins/assistant\": {\n create: createAssistantPlugin,\n whenAbsent: (config) => ({\n ...config,\n ai: { ...config.ai, assistantEnabled: false } as never,\n }),\n },\n \"@powerhousedao/connect/plugins/workflows\": {\n create: createWorkflowsPlugin,\n // The workflow package (Workflow Studio) loads only when the plugin is\n // composed in; the classic workflows.enabled value is not the switch.\n whenAbsent: (config) => ({\n ...config,\n app: { ...config.app, workflowsEnabled: false } as never,\n }),\n },\n \"@powerhousedao/vetra-studio/connect\": {\n create: createVetraStudioPlugin,\n // Studio sign-in (#studio-sign-in=<bearer>), for agents.\n ui: () => import(\"./vetra-studio/ui.js\").then((m) => m.default),\n whenAbsent: (config) => ({\n ...config,\n app: { ...config.app, studioMode: false } as never,\n }),\n },\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AASA,SAAgB,iBACd,WACA,QACA,WACa;CACb,MAAM,SAAS,OAAO,UAAU,SAAS;CACzC,IAAI,CAAC,OAAO,SACV,MAAM,IAAI,YACR,8BAA8B,UAAU,mBACtC,EAAE,cAAc,OAAO,KAAK,GAC9B,sDACF;CAEF,OAAO,OAAO;AAChB;;;ACEA,MAAa,yBAA+C,cAAc;CACxE,iBACE,4CACA,uBACA,SACF;CAcA,OAAO;EAZL,MAAM;EACN,WAAW;EACX,cAAc;EACd,OAAO,EACL,uBAAuB,QAAgC;GACrD,OAAO;IACL,GAAG;IACH,IAAI;KAAE,GAAG,OAAO;KAAI,kBAAkB;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