@powerhousedao/connect 6.2.3-dev.76 → 6.2.3-dev.78
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-BoF649HH.js → ClearStorageModal-Bv3yx3XD.js} +4 -4
- package/dist/{ClearStorageModal-BoF649HH.js.map → ClearStorageModal-Bv3yx3XD.js.map} +1 -1
- package/dist/{DebugSettingsModal-CKYdzHg3.js → DebugSettingsModal-DBCbplSU.js} +4 -4
- package/dist/{DebugSettingsModal-CKYdzHg3.js.map → DebugSettingsModal-DBCbplSU.js.map} +1 -1
- package/dist/{InspectorModal-B-CpFjkk.js → InspectorModal-C16IuKy9.js} +4 -4
- package/dist/{InspectorModal-B-CpFjkk.js.map → InspectorModal-C16IuKy9.js.map} +1 -1
- package/dist/{OpenFileDocumentsModal-B9c-CsKT.js → OpenFileDocumentsModal-DJsC1oR1.js} +10 -6
- package/dist/OpenFileDocumentsModal-DJsC1oR1.js.map +1 -0
- package/dist/{app-loader-CmhLUvkl.js → app-loader-BoL6R1vN.js} +7 -7
- package/dist/{app-loader-CmhLUvkl.js.map → app-loader-BoL6R1vN.js.map} +1 -1
- package/dist/app-loader-RoYImvm2.js +4 -0
- package/dist/app-skeleton-CPjpFScH.js +4 -0
- package/dist/{app-skeleton-ClRUYLE_.js → app-skeleton-WGKR7IBB.js} +17 -6
- package/dist/app-skeleton-WGKR7IBB.js.map +1 -0
- package/dist/{boot-DFAA5MSo.js → boot-CSPFrYcp.js} +5 -5
- package/dist/{boot-DFAA5MSo.js.map → boot-CSPFrYcp.js.map} +1 -1
- package/dist/{build-info-CLUgn9BD.js → build-info-DUlEdYeT.js} +5 -5
- package/dist/{build-info-CLUgn9BD.js.map → build-info-DUlEdYeT.js.map} +1 -1
- package/dist/{components-FreYm0r0.js → components-DnF3Nq24.js} +7 -7
- package/dist/{components-FreYm0r0.js.map → components-DnF3Nq24.js.map} +1 -1
- package/dist/generic.js +1 -1
- package/dist/{load-DjfJv058.js → load-DtN7O04V.js} +6 -6
- package/dist/{load-DjfJv058.js.map → load-DtN7O04V.js.map} +1 -1
- package/dist/{load-runtime-config-BF0w1ZDg.js → load-runtime-config-BpLOOkva.js} +4 -4
- package/dist/{load-runtime-config-BF0w1ZDg.js.map → load-runtime-config-BpLOOkva.js.map} +1 -1
- package/dist/main.js +2 -2
- package/dist/{package-manager-KIBOxb_u.js → package-manager-DYaxrAmr.js} +6 -6
- package/dist/{package-manager-KIBOxb_u.js.map → package-manager-DYaxrAmr.js.map} +1 -1
- package/dist/{plugins-D-wbWV2q.js → plugins-D3BJDmsQ.js} +4 -4
- package/dist/{plugins-D-wbWV2q.js.map → plugins-D3BJDmsQ.js.map} +1 -1
- package/dist/prerender.d.ts.map +1 -1
- package/dist/prerender.js +23 -16
- package/dist/prerender.js.map +1 -1
- package/dist/{reactor-CiSse3hi.js → reactor-CZLsF9Jy.js} +23 -13
- package/dist/reactor-CZLsF9Jy.js.map +1 -0
- package/dist/route-tree.js +1 -1
- package/dist/{route-views-D_873yb_.js → route-views-C84NRBou.js} +3 -3
- package/dist/{route-views-DmmQ1DzX.js → route-views-CKBivPxe.js} +4 -4
- package/dist/{route-views-DmmQ1DzX.js.map → route-views-CKBivPxe.js.map} +1 -1
- package/dist/{route-views-2aB1ZZPP.js → route-views-zHuBM6Nq.js} +4 -4
- package/dist/{route-views-2aB1ZZPP.js.map → route-views-zHuBM6Nq.js.map} +1 -1
- package/dist/route-views.js +3 -3
- package/dist/{router-DXpaaTeR.js → router-9jEQB-nr.js} +4 -4
- package/dist/{router-DXpaaTeR.js.map → router-9jEQB-nr.js.map} +1 -1
- package/dist/router-D8NyXlh0.js +4 -0
- package/dist/{settings-DuFReMb1.js → settings-F-qoymK-.js} +6 -6
- package/dist/{settings-DuFReMb1.js.map → settings-F-qoymK-.js.map} +1 -1
- package/dist/{settings-tabs-DNVwbelT.js → settings-tabs-QyWk0HzI.js} +4 -4
- package/dist/{settings-tabs-DNVwbelT.js.map → settings-tabs-QyWk0HzI.js.map} +1 -1
- package/dist/start-connect.js +2 -2
- package/dist/{ui-BOWaqYlz.js → ui-vaMYxGL2.js} +7 -7
- package/dist/{ui-BOWaqYlz.js.map → ui-vaMYxGL2.js.map} +1 -1
- package/package.json +16 -16
- package/dist/OpenFileDocumentsModal-B9c-CsKT.js.map +0 -1
- package/dist/app-loader-DjQ2opEo.js +0 -4
- package/dist/app-skeleton-BHgmbYld.js +0 -4
- package/dist/app-skeleton-ClRUYLE_.js.map +0 -1
- package/dist/reactor-CiSse3hi.js.map +0 -1
- package/dist/router-CBzb5FUq.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-DFAA5MSo.js","sources":["../src/utils/performance-observer.ts","../src/warm-modules.ts","../src/boot.tsx"],"sourcesContent":["import { track } from \"../services/openpanel/buffer.js\";\nimport type { PHGlobal } from \"@powerhousedao/reactor-browser\";\n\n/**\n * Startup performance measurement.\n *\n * Captures First Contentful Paint (FCP) and Largest Contentful Paint (LCP) via\n * the Performance API and reports each to the OpenPanel analytics buffer (a\n * consent-gated, never-throwing queue). Call {@link initPerformanceObserver}\n * at the very top of the entry module, before the runtime config is fetched,\n * so FCP is caught even if the browser has already painted — a\n * `PerformanceObserver` with `buffered: true` replays entries that fired\n * before `observe()` was called.\n *\n * This module is intentionally dependency-light (only the OpenPanel event\n * buffer, which has no runtime imports of its own) so it is safe to load\n * before the runtime config is fetched. Every API access is guarded: nothing\n * here may throw into the application.\n */\n\nfunction navigationType(): string | undefined {\n try {\n const entry = performance.getEntriesByType(\"navigation\")[0] as\n | PerformanceNavigationTiming\n | undefined;\n return entry?.type; // \"navigate\" | \"reload\" | \"back_forward\" | \"prerender\"\n } catch {\n return undefined;\n }\n}\n\n// window.ph is the app's global bag (PHGlobal). This module owns a\n// `performance` sub-object it writes into; `PhWithPerformance` is a named\n// stand-in for that write so it type-checks without touching the shared\n// PHGlobal definition.\ntype PhWithPerformance = PHGlobal & { performance?: Record<string, number> };\n\n/**\n * Mirror the metric on `window.ph.performance` for devtools inspection. Only\n * writes to an already-existing `window.ph` (owned by the entry module) —\n * never creates or replaces it, so it can't clobber the app's global state.\n */\nfunction storeOnWindow(name: string, value: number): void {\n try {\n const ph = window.ph as PhWithPerformance | undefined;\n if (!ph) return;\n ph.performance = ph.performance ?? {};\n ph.performance[name] = value;\n } catch {\n // devtools mirror is best-effort only\n }\n}\n\nfunction report(name: string, ms: number): void {\n const value = Math.round(ms);\n const props: Record<string, unknown> = { ms: value };\n const navType = navigationType();\n if (navType) props.navigation = navType;\n\n storeOnWindow(name, value);\n\n // The console summary is a developer aid. In a production build it is noise\n // in every user's console and in every support screenshot, so it is gated\n // out of the bundle there.\n if (!import.meta.env.PROD) {\n try {\n console.info(`[connect:performance] ${name}: ${value}ms`, props);\n } catch {\n // console is best-effort only\n }\n }\n\n try {\n track(`performance.${name}`, props);\n } catch {\n // analytics must never throw into the app\n }\n}\n\n/**\n * Starts the observers. Returns a disposer that detaches all of them. The app\n * never needs it — the observers live as long as the page does — but it keeps\n * the module testable and leaves no listener behind.\n */\nexport function initPerformanceObserver(): () => void {\n if (\n typeof window === \"undefined\" ||\n typeof PerformanceObserver === \"undefined\"\n ) {\n return () => undefined;\n }\n\n const teardown: Array<() => void> = [];\n\n /** Registers a listener and queues its removal on dispose. */\n const listen = (\n target: EventTarget,\n type: string,\n handler: () => void,\n once = true,\n ): void => {\n target.addEventListener(type, handler, { once });\n teardown.push(() => target.removeEventListener(type, handler));\n };\n\n // FCP — from the \"paint\" buffer. It fires once, so stop observing after it.\n try {\n const fcpObserver = new PerformanceObserver((list) => {\n for (const entry of list.getEntries()) {\n if (entry.name === \"first-contentful-paint\") {\n fcpObserver.disconnect();\n report(\"first_contentful_paint\", entry.startTime);\n }\n }\n });\n fcpObserver.observe({ type: \"paint\", buffered: true });\n teardown.push(() => fcpObserver.disconnect());\n } catch (err) {\n console.warn(\"[connect:performance] FCP observer failed:\", err);\n }\n\n // LCP — the final value only settles on an interaction or page hide, so latch\n // the latest candidate and report on the first terminal signal.\n let lcpMs = 0;\n let lcpReported = false;\n let lcpObserver: PerformanceObserver | undefined;\n\n /** Latches the newest candidate of a batch. The last entry is the newest. */\n const latch = (entries: ArrayLike<{ startTime: number }>): void => {\n if (entries.length > 0) {\n lcpMs = entries[entries.length - 1].startTime;\n }\n };\n\n const reportLcp = (): void => {\n // Several terminal signals can fire in one session (a click, then the page\n // hiding, then pagehide). The metric is sent for the first one only: every\n // repeat would be a double-count downstream.\n if (lcpReported) return;\n lcpReported = true;\n\n // A PerformanceObserver delivers entries in a task of its own, so a\n // terminal signal early in the page's life arrives while the newest\n // candidate is still buffered. Drain it before disconnecting — otherwise\n // an early click costs the session its LCP entirely.\n try {\n latch(lcpObserver?.takeRecords() ?? []);\n } catch {\n // draining is best-effort; report whatever was already delivered\n }\n\n lcpObserver?.disconnect();\n if (lcpMs > 0) report(\"largest_contentful_paint\", lcpMs);\n };\n\n try {\n lcpObserver = new PerformanceObserver((list) => {\n latch(list.getEntries());\n });\n lcpObserver.observe({ type: \"largest-contentful-paint\", buffered: true });\n teardown.push(() => lcpObserver?.disconnect());\n\n listen(window, \"pagehide\", reportLcp);\n listen(window, \"pointerdown\", reportLcp);\n listen(window, \"keydown\", reportLcp);\n // Not `once`: a page that loads in a background tab, or that the user tabs\n // away from and back, fires visibilitychange more than once, and only the\n // transition to \"hidden\" is terminal. A one-shot listener would be spent\n // on an earlier \"visible\" event and never see the hide.\n listen(\n document,\n \"visibilitychange\",\n () => {\n if (document.visibilityState === \"hidden\") reportLcp();\n },\n false,\n );\n } catch (err) {\n console.warn(\"[connect:performance] LCP observer failed:\", err);\n }\n\n return () => {\n for (const detach of teardown) {\n try {\n detach();\n } catch {\n // teardown is best-effort only\n }\n }\n teardown.length = 0;\n };\n}\n","// The app graph's largest packages; none reads the runtime config when evaluated.\nconst STAGES: (() => Promise<unknown>)[] = [\n () => import(\"@powerhousedao/reactor-browser\"),\n () => import(\"@powerhousedao/design-system/connect\"),\n];\n\nconst nextTask = () => new Promise((resolve) => setTimeout(resolve, 0));\n\n/** Evaluates them one task each; imported with the app they'd be one long task. */\nexport async function warmModules(stages = STAGES) {\n for (const stage of stages) {\n await nextTask();\n // The app's own import reports a failure.\n await stage().catch(() => undefined);\n }\n}\n","// Imported by package name so projects resolve its fonts from Connect's dependencies.\nimport \"@powerhousedao/connect/fonts.css\";\nimport type { ComponentType, PropsWithChildren, ReactNode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport {\n adoptPrerenderedShell,\n hasPrerenderedShell,\n} from \"./components/prerendered-shell.js\";\nimport { loadRuntimeConfig } from \"./load-runtime-config.js\";\nimport { initPerformanceObserver } from \"./utils/performance-observer.js\";\nimport { warmModules } from \"./warm-modules.js\";\n\n/**\n * The two-phase startup shared by both entry points.\n *\n * Phase 1 paints the config-independent skeleton, so first contentful paint\n * does not wait on the `powerhouse.config.json` round-trip. Phase 2 awaits the\n * config and hands the caller back the root to render the config-dependent app\n * into — every module that reads the runtime config at module-evaluation\n * throws if the cache isn't warm, so the app graph may only be imported after\n * this resolves.\n *\n * Kept dependency-light on purpose: it loads before the config is fetched, so\n * nothing in its import graph may read the config.\n */\n\n/** All the bootstrap needs of a React root — and all a test has to stand in for. */\ntype RenderTarget = { render: (node: ReactNode) => void };\n\nexport type BootDeps = {\n loadConfig: () => Promise<unknown>;\n importSkeleton: () => Promise<{ default: ComponentType<PropsWithChildren> }>;\n createRoot: () => RenderTarget;\n initObserver: () => () => void;\n /** True when #root holds a prerendered shell, which stays until the app renders. */\n adoptShell: () => boolean;\n /** Evaluates the app's large packages while the config loads. */\n warmModules: () => Promise<unknown>;\n};\n\nconst defaultDeps: BootDeps = {\n loadConfig: () => loadRuntimeConfig(),\n importSkeleton: () => import(\"./components/app-skeleton.js\"),\n createRoot: () => createRoot(document.getElementById(\"root\")!),\n initObserver: initPerformanceObserver,\n adoptShell: () => {\n adoptPrerenderedShell(document.getElementById(\"root\"));\n return hasPrerenderedShell();\n },\n warmModules: () => warmModules(),\n};\n\n/**\n * Shown when startup cannot proceed. Deliberately built from plain elements:\n * this renders precisely when the runtime config is unavailable, so it must\n * not depend on anything that reads it.\n */\nfunction BootError({ error }: { error: unknown }): ReactNode {\n const message = error instanceof Error ? error.message : String(error);\n return (\n <div\n role=\"alert\"\n className=\"flex h-screen flex-col items-center justify-center gap-3 bg-background p-6 text-center\"\n >\n <h1 className=\"text-lg font-semibold text-foreground\">\n Connect could not start\n </h1>\n <p className=\"max-w-prose text-sm text-foreground\">\n Its runtime configuration could not be loaded. This is usually temporary\n — reloading often resolves it.\n </p>\n <pre className=\"max-w-prose overflow-x-auto rounded-sm bg-card px-3 py-2 text-left text-xs text-foreground\">\n {message}\n </pre>\n <button\n type=\"button\"\n className=\"rounded-sm bg-card px-4 py-2 text-sm font-medium text-foreground shadow-sm\"\n onClick={() => {\n window.location.reload();\n }}\n >\n Reload\n </button>\n </div>\n );\n}\n\n/**\n * Paints the skeleton, then waits for the runtime config.\n *\n * Returns the root to render the app into, or `null` when startup failed — in\n * which case the error state is already painted and the caller must not import\n * the config-dependent app. It resolves rather than rejecting on failure: both\n * entry points await this at their module's top level, where a rejection would\n * surface only as an unhandled rejection behind a skeleton that never goes\n * away.\n */\nexport async function bootConnect(\n overrides: Partial<BootDeps> = {},\n): Promise<RenderTarget | null> {\n const {\n loadConfig,\n importSkeleton,\n createRoot: makeRoot,\n initObserver,\n adoptShell,\n warmModules: warm,\n } = { ...defaultDeps, ...overrides };\n\n if (!window.ph) {\n window.ph = {};\n }\n\n // Before anything else: the observers use `buffered: true`, so they catch\n // the browser's paint even when setup runs a tick after it fired.\n initObserver();\n\n // Started here and awaited at the bottom. The config fetch and the skeleton\n // chunk are independent round-trips, so they overlap; awaiting the chunk\n // first would put the config fetch — and with it everything the app needs —\n // behind it, which measured ~180ms of extra time-to-usable on a 150ms-RTT\n // connection. Mapping the rejection to a value here also means a config\n // failure is handled from the start, never an unhandled rejection.\n const config = loadConfig().then(\n () => ({ ok: true }) as const,\n (error: unknown) => ({ ok: false, error }) as const,\n );\n\n const hasShell = adoptShell();\n const root = makeRoot();\n\n try {\n // The prerendered shell is already painted; the skeleton would replace it.\n if (!hasShell) {\n const { default: AppSkeleton } = await importSkeleton();\n root.render(<AppSkeleton />);\n }\n } catch (error) {\n console.error(\"[connect:boot] the app skeleton failed to load:\", error);\n root.render(<BootError error={error} />);\n return null;\n }\n\n const warmed = warm().catch(() => undefined);\n const result = await config;\n if (!result.ok) {\n console.error(\n \"[connect:boot] the runtime config failed to load:\",\n result.error,\n );\n root.render(<BootError error={result.error} />);\n return null;\n }\n // The app imports these modules anyway; warmed, they evaluate in tasks of their own.\n await warmed;\n\n return root;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,iBAAqC;CAC5C,IAAI;EAIF,OAHc,YAAY,iBAAiB,YAAY,CAAC,CAAC,EAG7C,EAAE;CAChB,QAAQ;EACN;CACF;AACF;;;;;;AAaA,SAAS,cAAc,MAAc,OAAqB;CACxD,IAAI;EACF,MAAM,KAAK,OAAO;EAClB,IAAI,CAAC,IAAI;EACT,GAAG,cAAc,GAAG,eAAe,CAAC;EACpC,GAAG,YAAY,QAAQ;CACzB,QAAQ,CAER;AACF;AAEA,SAAS,OAAO,MAAc,IAAkB;CAC9C,MAAM,QAAQ,KAAK,MAAM,EAAE;CAC3B,MAAM,QAAiC,EAAE,IAAI,MAAM;CACnD,MAAM,UAAU,eAAe;CAC/B,IAAI,SAAS,MAAM,aAAa;CAEhC,cAAc,MAAM,KAAK;CAKzB,IAAI,CAAC,YAAY,IAAI,MACnB,IAAI;EACF,QAAQ,KAAK,yBAAyB,KAAK,IAAI,MAAM,KAAK,KAAK;CACjE,QAAQ,CAER;CAGF,IAAI;EACF,MAAM,eAAe,QAAQ,KAAK;CACpC,QAAQ,CAER;AACF;;;;;;AAOA,SAAgB,0BAAsC;CACpD,IACE,OAAO,WAAW,eAClB,OAAO,wBAAwB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AEnC,IAAI,CAAC,OAAO,IACV,OAAO,KAAK,CAAC;CAKf,aAAa;CAQb,MAAM,SAAS,WAAW,CAAC,CAAC,YACnB,EAAE,IAAI,KAAK,KACjB,WAAoB;EAAE,IAAI;EAAO;CAAM,EAC1C;CAEA,MAAM,WAAW,WAAW;CAC5B,MAAM,OAAO,SAAS;CAEtB,IAAI;EAEF,IAAI,CAAC,UAAU;GACb,MAAM,EAAE,SAAS,gBAAgB,MAAM,eAAe;GACtD,KAAK,OAAO,oBAAC,aAAD,CAAc,CAAA,CAAC;EAC7B;CACF,SAAS,OAAO;EACd,QAAQ,MAAM,mDAAmD,KAAK;EACtE,KAAK,OAAO,oBAAC,WAAD,EAAkB,MAAQ,CAAA,CAAC;EACvC,OAAO;CACT;CAEA,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;CAC3C,MAAM,SAAS,MAAM;CACrB,IAAI,CAAC,OAAO,IAAI;EACd,QAAQ,MACN,qDACA,OAAO,KACT;EACA,KAAK,OAAO,oBAAC,WAAD,EAAW,OAAO,OAAO,MAAQ,CAAA,CAAC;EAC9C,OAAO;CACT;CAEA,MAAM;CAEN,OAAO;AACT","debug_id":"a5e0dcb0-78c9-51d5-a687-56a259d6f39d"}
|
|
1
|
+
{"version":3,"file":"boot-CSPFrYcp.js","sources":["../src/utils/performance-observer.ts","../src/warm-modules.ts","../src/boot.tsx"],"sourcesContent":["import { track } from \"../services/openpanel/buffer.js\";\nimport type { PHGlobal } from \"@powerhousedao/reactor-browser\";\n\n/**\n * Startup performance measurement.\n *\n * Captures First Contentful Paint (FCP) and Largest Contentful Paint (LCP) via\n * the Performance API and reports each to the OpenPanel analytics buffer (a\n * consent-gated, never-throwing queue). Call {@link initPerformanceObserver}\n * at the very top of the entry module, before the runtime config is fetched,\n * so FCP is caught even if the browser has already painted — a\n * `PerformanceObserver` with `buffered: true` replays entries that fired\n * before `observe()` was called.\n *\n * This module is intentionally dependency-light (only the OpenPanel event\n * buffer, which has no runtime imports of its own) so it is safe to load\n * before the runtime config is fetched. Every API access is guarded: nothing\n * here may throw into the application.\n */\n\nfunction navigationType(): string | undefined {\n try {\n const entry = performance.getEntriesByType(\"navigation\")[0] as\n | PerformanceNavigationTiming\n | undefined;\n return entry?.type; // \"navigate\" | \"reload\" | \"back_forward\" | \"prerender\"\n } catch {\n return undefined;\n }\n}\n\n// window.ph is the app's global bag (PHGlobal). This module owns a\n// `performance` sub-object it writes into; `PhWithPerformance` is a named\n// stand-in for that write so it type-checks without touching the shared\n// PHGlobal definition.\ntype PhWithPerformance = PHGlobal & { performance?: Record<string, number> };\n\n/**\n * Mirror the metric on `window.ph.performance` for devtools inspection. Only\n * writes to an already-existing `window.ph` (owned by the entry module) —\n * never creates or replaces it, so it can't clobber the app's global state.\n */\nfunction storeOnWindow(name: string, value: number): void {\n try {\n const ph = window.ph as PhWithPerformance | undefined;\n if (!ph) return;\n ph.performance = ph.performance ?? {};\n ph.performance[name] = value;\n } catch {\n // devtools mirror is best-effort only\n }\n}\n\nfunction report(name: string, ms: number): void {\n const value = Math.round(ms);\n const props: Record<string, unknown> = { ms: value };\n const navType = navigationType();\n if (navType) props.navigation = navType;\n\n storeOnWindow(name, value);\n\n // The console summary is a developer aid. In a production build it is noise\n // in every user's console and in every support screenshot, so it is gated\n // out of the bundle there.\n if (!import.meta.env.PROD) {\n try {\n console.info(`[connect:performance] ${name}: ${value}ms`, props);\n } catch {\n // console is best-effort only\n }\n }\n\n try {\n track(`performance.${name}`, props);\n } catch {\n // analytics must never throw into the app\n }\n}\n\n/**\n * Starts the observers. Returns a disposer that detaches all of them. The app\n * never needs it — the observers live as long as the page does — but it keeps\n * the module testable and leaves no listener behind.\n */\nexport function initPerformanceObserver(): () => void {\n if (\n typeof window === \"undefined\" ||\n typeof PerformanceObserver === \"undefined\"\n ) {\n return () => undefined;\n }\n\n const teardown: Array<() => void> = [];\n\n /** Registers a listener and queues its removal on dispose. */\n const listen = (\n target: EventTarget,\n type: string,\n handler: () => void,\n once = true,\n ): void => {\n target.addEventListener(type, handler, { once });\n teardown.push(() => target.removeEventListener(type, handler));\n };\n\n // FCP — from the \"paint\" buffer. It fires once, so stop observing after it.\n try {\n const fcpObserver = new PerformanceObserver((list) => {\n for (const entry of list.getEntries()) {\n if (entry.name === \"first-contentful-paint\") {\n fcpObserver.disconnect();\n report(\"first_contentful_paint\", entry.startTime);\n }\n }\n });\n fcpObserver.observe({ type: \"paint\", buffered: true });\n teardown.push(() => fcpObserver.disconnect());\n } catch (err) {\n console.warn(\"[connect:performance] FCP observer failed:\", err);\n }\n\n // LCP — the final value only settles on an interaction or page hide, so latch\n // the latest candidate and report on the first terminal signal.\n let lcpMs = 0;\n let lcpReported = false;\n let lcpObserver: PerformanceObserver | undefined;\n\n /** Latches the newest candidate of a batch. The last entry is the newest. */\n const latch = (entries: ArrayLike<{ startTime: number }>): void => {\n if (entries.length > 0) {\n lcpMs = entries[entries.length - 1].startTime;\n }\n };\n\n const reportLcp = (): void => {\n // Several terminal signals can fire in one session (a click, then the page\n // hiding, then pagehide). The metric is sent for the first one only: every\n // repeat would be a double-count downstream.\n if (lcpReported) return;\n lcpReported = true;\n\n // A PerformanceObserver delivers entries in a task of its own, so a\n // terminal signal early in the page's life arrives while the newest\n // candidate is still buffered. Drain it before disconnecting — otherwise\n // an early click costs the session its LCP entirely.\n try {\n latch(lcpObserver?.takeRecords() ?? []);\n } catch {\n // draining is best-effort; report whatever was already delivered\n }\n\n lcpObserver?.disconnect();\n if (lcpMs > 0) report(\"largest_contentful_paint\", lcpMs);\n };\n\n try {\n lcpObserver = new PerformanceObserver((list) => {\n latch(list.getEntries());\n });\n lcpObserver.observe({ type: \"largest-contentful-paint\", buffered: true });\n teardown.push(() => lcpObserver?.disconnect());\n\n listen(window, \"pagehide\", reportLcp);\n listen(window, \"pointerdown\", reportLcp);\n listen(window, \"keydown\", reportLcp);\n // Not `once`: a page that loads in a background tab, or that the user tabs\n // away from and back, fires visibilitychange more than once, and only the\n // transition to \"hidden\" is terminal. A one-shot listener would be spent\n // on an earlier \"visible\" event and never see the hide.\n listen(\n document,\n \"visibilitychange\",\n () => {\n if (document.visibilityState === \"hidden\") reportLcp();\n },\n false,\n );\n } catch (err) {\n console.warn(\"[connect:performance] LCP observer failed:\", err);\n }\n\n return () => {\n for (const detach of teardown) {\n try {\n detach();\n } catch {\n // teardown is best-effort only\n }\n }\n teardown.length = 0;\n };\n}\n","// The app graph's largest packages; none reads the runtime config when evaluated.\nconst STAGES: (() => Promise<unknown>)[] = [\n () => import(\"@powerhousedao/reactor-browser\"),\n () => import(\"@powerhousedao/design-system/connect\"),\n];\n\nconst nextTask = () => new Promise((resolve) => setTimeout(resolve, 0));\n\n/** Evaluates them one task each; imported with the app they'd be one long task. */\nexport async function warmModules(stages = STAGES) {\n for (const stage of stages) {\n await nextTask();\n // The app's own import reports a failure.\n await stage().catch(() => undefined);\n }\n}\n","// Imported by package name so projects resolve its fonts from Connect's dependencies.\nimport \"@powerhousedao/connect/fonts.css\";\nimport type { ComponentType, PropsWithChildren, ReactNode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport {\n adoptPrerenderedShell,\n hasPrerenderedShell,\n} from \"./components/prerendered-shell.js\";\nimport { loadRuntimeConfig } from \"./load-runtime-config.js\";\nimport { initPerformanceObserver } from \"./utils/performance-observer.js\";\nimport { warmModules } from \"./warm-modules.js\";\n\n/**\n * The two-phase startup shared by both entry points.\n *\n * Phase 1 paints the config-independent skeleton, so first contentful paint\n * does not wait on the `powerhouse.config.json` round-trip. Phase 2 awaits the\n * config and hands the caller back the root to render the config-dependent app\n * into — every module that reads the runtime config at module-evaluation\n * throws if the cache isn't warm, so the app graph may only be imported after\n * this resolves.\n *\n * Kept dependency-light on purpose: it loads before the config is fetched, so\n * nothing in its import graph may read the config.\n */\n\n/** All the bootstrap needs of a React root — and all a test has to stand in for. */\ntype RenderTarget = { render: (node: ReactNode) => void };\n\nexport type BootDeps = {\n loadConfig: () => Promise<unknown>;\n importSkeleton: () => Promise<{ default: ComponentType<PropsWithChildren> }>;\n createRoot: () => RenderTarget;\n initObserver: () => () => void;\n /** True when #root holds a prerendered shell, which stays until the app renders. */\n adoptShell: () => boolean;\n /** Evaluates the app's large packages while the config loads. */\n warmModules: () => Promise<unknown>;\n};\n\nconst defaultDeps: BootDeps = {\n loadConfig: () => loadRuntimeConfig(),\n importSkeleton: () => import(\"./components/app-skeleton.js\"),\n createRoot: () => createRoot(document.getElementById(\"root\")!),\n initObserver: initPerformanceObserver,\n adoptShell: () => {\n adoptPrerenderedShell(document.getElementById(\"root\"));\n return hasPrerenderedShell();\n },\n warmModules: () => warmModules(),\n};\n\n/**\n * Shown when startup cannot proceed. Deliberately built from plain elements:\n * this renders precisely when the runtime config is unavailable, so it must\n * not depend on anything that reads it.\n */\nfunction BootError({ error }: { error: unknown }): ReactNode {\n const message = error instanceof Error ? error.message : String(error);\n return (\n <div\n role=\"alert\"\n className=\"flex h-screen flex-col items-center justify-center gap-3 bg-background p-6 text-center\"\n >\n <h1 className=\"text-lg font-semibold text-foreground\">\n Connect could not start\n </h1>\n <p className=\"max-w-prose text-sm text-foreground\">\n Its runtime configuration could not be loaded. This is usually temporary\n — reloading often resolves it.\n </p>\n <pre className=\"max-w-prose overflow-x-auto rounded-sm bg-card px-3 py-2 text-left text-xs text-foreground\">\n {message}\n </pre>\n <button\n type=\"button\"\n className=\"rounded-sm bg-card px-4 py-2 text-sm font-medium text-foreground shadow-sm\"\n onClick={() => {\n window.location.reload();\n }}\n >\n Reload\n </button>\n </div>\n );\n}\n\n/**\n * Paints the skeleton, then waits for the runtime config.\n *\n * Returns the root to render the app into, or `null` when startup failed — in\n * which case the error state is already painted and the caller must not import\n * the config-dependent app. It resolves rather than rejecting on failure: both\n * entry points await this at their module's top level, where a rejection would\n * surface only as an unhandled rejection behind a skeleton that never goes\n * away.\n */\nexport async function bootConnect(\n overrides: Partial<BootDeps> = {},\n): Promise<RenderTarget | null> {\n const {\n loadConfig,\n importSkeleton,\n createRoot: makeRoot,\n initObserver,\n adoptShell,\n warmModules: warm,\n } = { ...defaultDeps, ...overrides };\n\n if (!window.ph) {\n window.ph = {};\n }\n\n // Before anything else: the observers use `buffered: true`, so they catch\n // the browser's paint even when setup runs a tick after it fired.\n initObserver();\n\n // Started here and awaited at the bottom. The config fetch and the skeleton\n // chunk are independent round-trips, so they overlap; awaiting the chunk\n // first would put the config fetch — and with it everything the app needs —\n // behind it, which measured ~180ms of extra time-to-usable on a 150ms-RTT\n // connection. Mapping the rejection to a value here also means a config\n // failure is handled from the start, never an unhandled rejection.\n const config = loadConfig().then(\n () => ({ ok: true }) as const,\n (error: unknown) => ({ ok: false, error }) as const,\n );\n\n const hasShell = adoptShell();\n const root = makeRoot();\n\n try {\n // The prerendered shell is already painted; the skeleton would replace it.\n if (!hasShell) {\n const { default: AppSkeleton } = await importSkeleton();\n root.render(<AppSkeleton />);\n }\n } catch (error) {\n console.error(\"[connect:boot] the app skeleton failed to load:\", error);\n root.render(<BootError error={error} />);\n return null;\n }\n\n const warmed = warm().catch(() => undefined);\n const result = await config;\n if (!result.ok) {\n console.error(\n \"[connect:boot] the runtime config failed to load:\",\n result.error,\n );\n root.render(<BootError error={result.error} />);\n return null;\n }\n // The app imports these modules anyway; warmed, they evaluate in tasks of their own.\n await warmed;\n\n return root;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,iBAAqC;CAC5C,IAAI;EAIF,OAHc,YAAY,iBAAiB,YAAY,CAAC,CAAC,EAG7C,EAAE;CAChB,QAAQ;EACN;CACF;AACF;;;;;;AAaA,SAAS,cAAc,MAAc,OAAqB;CACxD,IAAI;EACF,MAAM,KAAK,OAAO;EAClB,IAAI,CAAC,IAAI;EACT,GAAG,cAAc,GAAG,eAAe,CAAC;EACpC,GAAG,YAAY,QAAQ;CACzB,QAAQ,CAER;AACF;AAEA,SAAS,OAAO,MAAc,IAAkB;CAC9C,MAAM,QAAQ,KAAK,MAAM,EAAE;CAC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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]="61d8d220-44a6-5ca4-87ef-5db50403ae31")}catch(e){}}();
|
|
3
3
|
import { buildTreeUrl, shortGitSha } from "@powerhousedao/shared";
|
|
4
4
|
//#region src/utils/build-info.ts
|
|
5
5
|
function getVersion() {
|
|
6
|
-
return "6.2.3-dev.
|
|
6
|
+
return "6.2.3-dev.78";
|
|
7
7
|
}
|
|
8
8
|
/** True in the tsdown dist projects install; false in the monorepo app, where Vite bundles the worker. */
|
|
9
9
|
function isPackagedConnectDist() {
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
12
|
function getGitSha() {
|
|
13
|
-
return "
|
|
13
|
+
return "1c899a137d71c6be7e24a23bbe2163e07f2cc5a1";
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Build identity baked in at build time (define PH_CONNECT_BUILD_HASH —
|
|
@@ -28,5 +28,5 @@ function getGitUrl() {
|
|
|
28
28
|
//#endregion
|
|
29
29
|
export { isPackagedConnectDist as a, getVersion as i, getGitSha as n, shortGitSha as o, getGitUrl as r, getBuildHash as t };
|
|
30
30
|
|
|
31
|
-
//# sourceMappingURL=build-info-
|
|
32
|
-
//# debugId=
|
|
31
|
+
//# sourceMappingURL=build-info-DUlEdYeT.js.map
|
|
32
|
+
//# debugId=61d8d220-44a6-5ca4-87ef-5db50403ae31
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-info-
|
|
1
|
+
{"version":3,"file":"build-info-DUlEdYeT.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":"61d8d220-44a6-5ca4-87ef-5db50403ae31"}
|
|
@@ -1,11 +1,11 @@
|
|
|
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]="2fcdb617-2523-576e-af68-7c61f2b8f6ec")}catch(e){}}();
|
|
3
3
|
import { t as DriveIcon } from "./drive-icon-BIpd8edR.js";
|
|
4
|
-
import { t as AppSkeleton } from "./app-skeleton-
|
|
5
|
-
import { i as Analytics, n as App, r as OpenPanel, t as AppLoader } from "./app-loader-
|
|
4
|
+
import { n as setPrerenderingCustomShell, t as AppSkeleton } from "./app-skeleton-WGKR7IBB.js";
|
|
5
|
+
import { i as Analytics, n as App, r as OpenPanel, t as AppLoader } from "./app-loader-BoL6R1vN.js";
|
|
6
6
|
import { t as setBannerShown } from "./preferences-store-DxYAnGCc.js";
|
|
7
7
|
import { t as Root } from "./root-B1Pq9x6S.js";
|
|
8
|
-
import { n as getConnectRouter, t as Router } from "./router-
|
|
8
|
+
import { n as getConnectRouter, t as Router } from "./router-9jEQB-nr.js";
|
|
9
9
|
import { useEffect, useState } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { ConnectSearchBar, Footer as Footer$1, FooterLink } from "@powerhousedao/design-system/connect";
|
|
@@ -115,7 +115,7 @@ const SearchBar = () => {
|
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
117
|
//#endregion
|
|
118
|
-
export { Analytics, App, AppLoader, AppSkeleton, DotsLoader, DriveIcon, Footer, OpenPanel, Root, Router, SearchBar, getConnectRouter, loadLocalPackage };
|
|
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-DnF3Nq24.js.map
|
|
121
|
+
//# debugId=2fcdb617-2523-576e-af68-7c61f2b8f6ec
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components-
|
|
1
|
+
{"version":3,"file":"components-DnF3Nq24.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,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tC,aAAa,EAAE,uBAAuB;EACtC,aAAa;CACd,CAAA;AAEL","debug_id":"2fcdb617-2523-576e-af68-7c61f2b8f6ec"}
|
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 useNavRoutes, i as useDriveRouteData, n as ModalDialog, o as useSidebarMode, r as SidebarItem, t as ContentOutlet } from "./layout-wfvkfP4J.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-QyWk0HzI.js";
|
|
6
6
|
import { n as EditorLoader } from "./document-editor-container-FNIEsf8H.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]="c2e0bae1-af5f-5afc-b308-71a4f6e8ed31")}catch(e){}}();
|
|
3
|
+
import { t as loadRuntimeConfig } from "./load-runtime-config-BpLOOkva.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-DUlEdYeT.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-Bwm9Agwy.js";
|
|
9
9
|
import { n as seedPendingPgVersion } from "./pglite-seed-QPbGbLB_.js";
|
|
10
|
-
import { n as createReactor } from "./reactor-
|
|
10
|
+
import { n as createReactor } from "./reactor-CZLsF9Jy.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-DtN7O04V.js.map
|
|
133
|
+
//# debugId=c2e0bae1-af5f-5afc-b308-71a4f6e8ed31
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-
|
|
1
|
+
{"version":3,"file":"load-DtN7O04V.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,K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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":"c2e0bae1-af5f-5afc-b308-71a4f6e8ed31"}
|
|
@@ -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]="51e617b2-e5e3-58ed-875b-ef2917c46179")}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-D3BJDmsQ.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-BpLOOkva.js.map
|
|
14
|
+
//# debugId=51e617b2-e5e3-58ed-875b-ef2917c46179
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-runtime-config-
|
|
1
|
+
{"version":3,"file":"load-runtime-config-BpLOOkva.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":"51e617b2-e5e3-58ed-875b-ef2917c46179"}
|
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-CSPFrYcp.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-RoYImvm2.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]="f64b7eca-bec5-5f0f-85e1-cca31ee725e3")}catch(e){}}();
|
|
3
3
|
import { t as refreshPwaManifestLink } from "./pwa-manifest-link-DQRJpF0r.js";
|
|
4
4
|
import { holdConnectRoutes, registerPackageRoutes } from "@powerhousedao/connect-core/router";
|
|
5
5
|
import { BrowserLocalStorage } from "@powerhousedao/reactor-browser";
|
|
@@ -222,14 +222,14 @@ var BrowserPackageManager = class {
|
|
|
222
222
|
this.addLocalPackage(common.manifest.name, genericChrome ? common : {
|
|
223
223
|
...common,
|
|
224
224
|
editors: []
|
|
225
|
-
}, "6.2.3-dev.
|
|
225
|
+
}, "6.2.3-dev.78");
|
|
226
226
|
if (studioMode) {
|
|
227
227
|
const vetra = await import("@powerhousedao/vetra");
|
|
228
|
-
this.addLocalPackage(vetra.manifest.name, vetra, "6.2.3-dev.
|
|
228
|
+
this.addLocalPackage(vetra.manifest.name, vetra, "6.2.3-dev.78");
|
|
229
229
|
}
|
|
230
230
|
if (workflowsEnabled) {
|
|
231
231
|
const workflow = await import("@powerhousedao/workflow");
|
|
232
|
-
this.addLocalPackage(workflow.manifest.name, workflow, "6.2.3-dev.
|
|
232
|
+
this.addLocalPackage(workflow.manifest.name, workflow, "6.2.3-dev.78");
|
|
233
233
|
}
|
|
234
234
|
if (localPackage) this.updateLocalPackage(localPackage, localPackageVersion);
|
|
235
235
|
for (const packageName of this.#storage.keys()) {
|
|
@@ -539,5 +539,5 @@ var BrowserPackageManager = class {
|
|
|
539
539
|
//#endregion
|
|
540
540
|
export { pageSharedImports as i, sharedDepMismatchWarnings as n, getSharedDeps as r, BrowserPackageManager as t };
|
|
541
541
|
|
|
542
|
-
//# sourceMappingURL=package-manager-
|
|
543
|
-
//# debugId=
|
|
542
|
+
//# sourceMappingURL=package-manager-DYaxrAmr.js.map
|
|
543
|
+
//# debugId=f64b7eca-bec5-5f0f-85e1-cca31ee725e3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager-KIBOxb_u.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`: 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/** The shared-deps module URL: this build's hashed copy, else the stable dev path. */\nexport function sharedDepsModuleUrl(\n runtimeBase: string,\n built: string | undefined = builtSharedDepsUrl(),\n): string {\n return built\n ? resolveDynamicBaseUrl(built, runtimeBase)\n : `${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 production vendor's shared-deps table: import-map entries for the\n * shared dependency set plus the resolved version of every shared package\n * in this build. Fails soft (`null`) when the vendor is not present (dev,\n * or a `PH_CONNECT_VENDOR=0` build) — callers treat that 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 try {\n const mod = (await import(\n /* @vite-ignore */ sharedDepsModuleUrl(import.meta.env.BASE_URL)\n )) 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/** Dev has no vendor table, but its 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":";;;;;;;;;;AAQA,SAAS,qBAAyC;CAChD,OAAO,OAAO,+BAA+B,cACzC,6BACA,KAAA;AACN;;AAGA,SAAgB,oBACd,aACA,QAA4B,mBAAmB,GACvC;CACR,OAAO,QACH,sBAAsB,OAAO,WAAW,IACxC,GAAG,YAAY;AACrB;;;;;;;;;;AAgBA,SAAgB,uBACd,YACA,aACwB;CAGxB,MAAM,SACH,WAAuC,UAAU,UAClD;CACF,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,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BAAyB,OAAO,MAAM,OAAO;IACxD,OACE,QAAQ,KACN,mBAAmB,KAAK,4CACxB,OAAO,KACT;GAEJ;GAIA,SAAS,qBAAqB,QAAQ,SAAS,QAAQ;GACvD,IAAI,OAAO,KAAK,MAAM,CAAC,CAAC,WAAW,GAAG;GACtC,cAAc,KAAK;IAAE,QAAQ;IAAM;GAAO,CAAC;EAC7C;EAGA,MAAM,SAAS,eAAe,aAAa;EAG3C,MAAM,aAAa,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":"4724dcf7-f9ad-5b61-b566-3a6fa8d5aea6"}
|
|
1
|
+
{"version":3,"file":"package-manager-DYaxrAmr.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`: 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/** The shared-deps module URL: this build's hashed copy, else the stable dev path. */\nexport function sharedDepsModuleUrl(\n runtimeBase: string,\n built: string | undefined = builtSharedDepsUrl(),\n): string {\n return built\n ? resolveDynamicBaseUrl(built, runtimeBase)\n : `${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 production vendor's shared-deps table: import-map entries for the\n * shared dependency set plus the resolved version of every shared package\n * in this build. Fails soft (`null`) when the vendor is not present (dev,\n * or a `PH_CONNECT_VENDOR=0` build) — callers treat that 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 try {\n const mod = (await import(\n /* @vite-ignore */ sharedDepsModuleUrl(import.meta.env.BASE_URL)\n )) 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/** Dev has no vendor table, but its 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":";;;;;;;;;;AAQA,SAAS,qBAAyC;CAChD,OAAO,OAAO,+BAA+B,cACzC,6BACA,KAAA;AACN;;AAGA,SAAgB,oBACd,aACA,QAA4B,mBAAmB,GACvC;CACR,OAAO,QACH,sBAAsB,OAAO,WAAW,IACxC,GAAG,YAAY;AACrB;;;;;;;;;;AAgBA,SAAgB,uBACd,YACA,aACwB;CAGxB,MAAM,SACH,WAAuC,UAAU,UAClD;CACF,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,WA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