@powerhousedao/connect 6.2.3-dev.49 → 6.2.3-dev.50

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.
Files changed (35) hide show
  1. package/dist/{ClearStorageModal-Dd9rm0Ug.js → ClearStorageModal-BZs7-S10.js} +4 -4
  2. package/dist/{ClearStorageModal-Dd9rm0Ug.js.map → ClearStorageModal-BZs7-S10.js.map} +1 -1
  3. package/dist/{DebugSettingsModal-0EaUVs36.js → DebugSettingsModal-DuRuNVqr.js} +4 -4
  4. package/dist/{DebugSettingsModal-0EaUVs36.js.map → DebugSettingsModal-DuRuNVqr.js.map} +1 -1
  5. package/dist/{InspectorModal-U0rwOf2Q.js → InspectorModal-ByqYDGHt.js} +7 -7
  6. package/dist/{InspectorModal-U0rwOf2Q.js.map → InspectorModal-ByqYDGHt.js.map} +1 -1
  7. package/dist/{OpenFileDocumentsModal-BepsaLXX.js → OpenFileDocumentsModal-CPVr7_UN.js} +4 -4
  8. package/dist/{OpenFileDocumentsModal-BepsaLXX.js.map → OpenFileDocumentsModal-CPVr7_UN.js.map} +1 -1
  9. package/dist/{SettingsModal-BOFMjPmP.js → SettingsModal-e1X7sRE0.js} +5 -5
  10. package/dist/{SettingsModal-BOFMjPmP.js.map → SettingsModal-e1X7sRE0.js.map} +1 -1
  11. package/dist/app-loader-DWsWZBTH.js +4 -0
  12. package/dist/{app-loader-DgrLHbwP.js → app-loader-F_rtUgPB.js} +57 -25
  13. package/dist/{app-loader-DgrLHbwP.js.map → app-loader-F_rtUgPB.js.map} +1 -1
  14. package/dist/{build-info-CFBxV6Xr.js → build-info-BEK9jmfs.js} +5 -5
  15. package/dist/{build-info-CFBxV6Xr.js.map → build-info-BEK9jmfs.js.map} +1 -1
  16. package/dist/{components-BtWp82bY.js → components-CP73FuT3.js} +3 -3
  17. package/dist/{connection-state-Eqc2izmt.js → connection-state-BKXJeu74.js} +17 -6
  18. package/dist/{connection-state-Eqc2izmt.js.map → connection-state-BKXJeu74.js.map} +1 -1
  19. package/dist/{load-BNL6CTpV.js → load-BU73BPux.js} +7 -7
  20. package/dist/{load-BNL6CTpV.js.map → load-BU73BPux.js.map} +1 -1
  21. package/dist/main.js +1 -1
  22. package/dist/{pglite-seed-Cl2d-iyl.js → pglite-seed-C7hUK6X_.js} +4 -4
  23. package/dist/{pglite-seed-Cl2d-iyl.js.map → pglite-seed-C7hUK6X_.js.map} +1 -1
  24. package/dist/{reactor-D22fypZB.js → reactor-Dh29UPqN.js} +125 -25
  25. package/dist/reactor-Dh29UPqN.js.map +1 -0
  26. package/dist/reactor.worker.js +202 -49
  27. package/dist/reactor.worker.js.map +1 -1
  28. package/dist/start-connect.js +1 -1
  29. package/dist/store-lock-T8oyiDm4.js +151 -0
  30. package/dist/store-lock-T8oyiDm4.js.map +1 -0
  31. package/package.json +13 -13
  32. package/dist/app-loader-Brz2Nmo5.js +0 -4
  33. package/dist/reactor-D22fypZB.js.map +0 -1
  34. package/dist/renown-trust-DRgHpxlZ.js +0 -34
  35. package/dist/renown-trust-DRgHpxlZ.js.map +0 -1
@@ -1,16 +1,16 @@
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]="7259a2a2-93e0-56d5-81d4-5761bb5a73e0")}catch(e){}}();
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]="6ae0203e-3da2-58bf-a7be-e6ba8cb4a268")}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.49";
6
+ return "6.2.3-dev.50";
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 "390cca8ca3f2d6f76b5b104a4867c664f81f3801";
13
+ return "01a5b0227313c401002362834697fee1ddd28fed";
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-CFBxV6Xr.js.map
32
- //# debugId=7259a2a2-93e0-56d5-81d4-5761bb5a73e0
31
+ //# sourceMappingURL=build-info-BEK9jmfs.js.map
32
+ //# debugId=6ae0203e-3da2-58bf-a7be-e6ba8cb4a268
@@ -1 +1 @@
1
- {"version":3,"file":"build-info-CFBxV6Xr.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":"7259a2a2-93e0-56d5-81d4-5761bb5a73e0"}
1
+ {"version":3,"file":"build-info-BEK9jmfs.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":"6ae0203e-3da2-58bf-a7be-e6ba8cb4a268"}
@@ -1,5 +1,5 @@
1
1
  import { t as AppSkeleton } from "./app-skeleton--Me5zlSz.js";
2
- import { _ as EditorLoader, a as Root, b as Analytics, c as DriveIcon, g as AppContainer, i as Router, l as DotsLoader, n as Sidebar, o as Footer, r as SearchBar, s as DocumentEditor, t as AppLoader, u as App, v as DocumentEditorContainer, y as OpenPanel } from "./app-loader-DgrLHbwP.js";
2
+ import { _ as EditorLoader, a as Root, b as Analytics, c as DriveIcon, g as AppContainer, i as Router, l as DotsLoader, n as Sidebar, o as Footer, r as SearchBar, s as DocumentEditor, t as AppLoader, u as App, v as DocumentEditorContainer, y as OpenPanel } from "./app-loader-F_rtUgPB.js";
3
3
  export { Analytics, App, AppContainer, AppLoader, AppSkeleton, DocumentEditor, DocumentEditorContainer, DotsLoader, DriveIcon, EditorLoader, Footer, OpenPanel, Root, Router, SearchBar, Sidebar };
4
- !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]="fd757d76-0538-5214-bb3c-195151ab6a3e")}catch(e){}}();
5
- //# debugId=fd757d76-0538-5214-bb3c-195151ab6a3e
4
+ !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]="76a823d5-a8c8-53e3-9e0f-75ef041ab622")}catch(e){}}();
5
+ //# debugId=76a823d5-a8c8-53e3-9e0f-75ef041ab622
@@ -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]="5ec85aa0-e174-5d82-871e-e212735c125c")}catch(e){}}();
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]="2e40d4f6-3bef-55f7-885b-19ab72d0bf99")}catch(e){}}();
3
3
  import { n as getRuntimeConfig } from "./runtime-config-DtJIUgYw.js";
4
4
  import { n as isMigratableMajor, t as coerceMajor, u as readPgVersionFile } from "./pglite-major-p4_YefAE.js";
5
5
  import { t as PH_CONNECT_BASE_PATH } from "./connect.config-CaXMoB42.js";
@@ -108,11 +108,22 @@ const listeners = /* @__PURE__ */ new Set();
108
108
  function getWorkerConnectionStatus() {
109
109
  return status;
110
110
  }
111
- function setWorkerConnectionStatus(next) {
112
- if (status === next) return;
111
+ function publish(next) {
113
112
  status = next;
114
113
  for (const listener of [...listeners]) listener();
115
114
  }
115
+ /**
116
+ * "storage-unusable" and "version-conflict" hold until the page reloads, and
117
+ * "storage-held" until {@link clearStorageHeld}; a live worker's pong clears none.
118
+ */
119
+ function setWorkerConnectionStatus(next) {
120
+ if (status === next || status === "storage-unusable" || status === "version-conflict") return;
121
+ if (status === "storage-held" && next === "connected") return;
122
+ publish(next);
123
+ }
124
+ function clearStorageHeld() {
125
+ if (status === "storage-held") publish("connected");
126
+ }
116
127
  function subscribeWorkerConnection(listener) {
117
128
  listeners.add(listener);
118
129
  return () => {
@@ -120,7 +131,7 @@ function subscribeWorkerConnection(listener) {
120
131
  };
121
132
  }
122
133
  //#endregion
123
- export { detectReactorPgMajor as a, getCachedReactorPgMajor as c, subscribeReactorPgMajor as d, PRIMARY_IDB_NAMES as f, RELATIONAL_PGLITE_NAME as h, detectMigrationMajor as i, invalidateReactorPgMajorCache as l, REACTOR_PGLITE_NAME as m, setWorkerConnectionStatus as n, detectRelationalPgMajor as o, REACTOR_INSTANCE_NAMESPACE as p, subscribeWorkerConnection as r, getCachedMigrationMajor as s, getWorkerConnectionStatus as t, subscribeMigrationMajor as u };
134
+ export { detectMigrationMajor as a, getCachedMigrationMajor as c, subscribeMigrationMajor as d, subscribeReactorPgMajor as f, RELATIONAL_PGLITE_NAME as g, REACTOR_PGLITE_NAME as h, subscribeWorkerConnection as i, getCachedReactorPgMajor as l, REACTOR_INSTANCE_NAMESPACE as m, getWorkerConnectionStatus as n, detectReactorPgMajor as o, PRIMARY_IDB_NAMES as p, setWorkerConnectionStatus as r, detectRelationalPgMajor as s, clearStorageHeld as t, invalidateReactorPgMajorCache as u };
124
135
 
125
- //# sourceMappingURL=connection-state-Eqc2izmt.js.map
126
- //# debugId=5ec85aa0-e174-5d82-871e-e212735c125c
136
+ //# sourceMappingURL=connection-state-BKXJeu74.js.map
137
+ //# debugId=2e40d4f6-3bef-55f7-885b-19ab72d0bf99
@@ -1 +1 @@
1
- {"version":3,"file":"connection-state-Eqc2izmt.js","sources":["../src/utils/reactor-namespace.ts","../src/utils/storage-namespace.ts","../src/utils/pglite-runtime.ts","../src/connection-state.ts"],"sourcesContent":["import { getStorageNamespace } from \"@powerhousedao/shared/connect\";\nimport { hashNamespace } from \"@powerhousedao/shared/processors\";\n\nexport type ReactorNamespaceInput = {\n basePath: string;\n explicit?: string;\n endpoint?: string;\n};\n\nexport function resolveReactorNamespace(input: ReactorNamespaceInput): string {\n const explicit = input.explicit?.trim();\n if (explicit) {\n return explicit;\n }\n const base = getStorageNamespace(input.basePath);\n const endpoint = input.endpoint?.trim();\n if (endpoint) {\n return `${base}--${hashNamespace(endpoint, 8)}`;\n }\n return base;\n}\n","import { DEFAULT_RELATIONAL_PROCESSOR_DB_NAME } from \"@powerhousedao/shared/processors\";\nimport { ROOT_STORAGE_NAMESPACE } from \"@powerhousedao/shared/connect\";\nimport { PH_CONNECT_BASE_PATH } from \"../connect.config.js\";\nimport { getRuntimeConfig } from \"../runtime-config.js\";\nimport { resolveReactorNamespace } from \"./reactor-namespace.js\";\n\nexport const REACTOR_INSTANCE_NAMESPACE = resolveReactorNamespace({\n basePath: PH_CONNECT_BASE_PATH,\n explicit: getRuntimeConfig().connect.instance?.namespace ?? undefined,\n});\n\nexport const REACTOR_PGLITE_NAME = REACTOR_INSTANCE_NAMESPACE;\n\nexport const RELATIONAL_PGLITE_NAME =\n REACTOR_INSTANCE_NAMESPACE === ROOT_STORAGE_NAMESPACE\n ? DEFAULT_RELATIONAL_PROCESSOR_DB_NAME\n : `${REACTOR_INSTANCE_NAMESPACE}-${DEFAULT_RELATIONAL_PROCESSOR_DB_NAME}`;\n\n// Here, not pglite-idb.ts, so those IDB helpers stay free of runtime-config\n// and remain importable by the reactor SharedWorker.\nexport const REACTOR_IDB_NAME = `/pglite/${REACTOR_PGLITE_NAME}`;\nexport const RELATIONAL_IDB_NAME = `/pglite/${RELATIONAL_PGLITE_NAME}`;\nexport const PRIMARY_IDB_NAMES = [\n REACTOR_IDB_NAME,\n RELATIONAL_IDB_NAME,\n] as const;\n","import { readPgVersionFile } from \"./pglite-idb.js\";\nimport {\n coerceMajor,\n isMigratableMajor,\n type DetectedMajor,\n} from \"./pglite-major.js\";\nimport { REACTOR_IDB_NAME, RELATIONAL_IDB_NAME } from \"./storage-namespace.js\";\n\nexport {\n CURRENT_PG_MAJOR,\n SUPPORTED_PG_MAJORS,\n coerceMajor,\n resolvePgMajorForRuntime,\n loadPGliteModule,\n loadPgDump,\n type SupportedPgMajor,\n type DetectedMajor,\n} from \"./pglite-major.js\";\n\nlet cachedReactorMajor: DetectedMajor | undefined;\nlet inflight: Promise<DetectedMajor> | undefined;\nconst majorListeners = new Set<() => void>();\n\nlet cachedMigrationMajor: DetectedMajor | undefined;\nlet migrationInflight: Promise<DetectedMajor> | undefined;\nconst migrationListeners = new Set<() => void>();\n\nfunction notifyMajorChanged() {\n for (const l of majorListeners) l();\n}\n\nfunction notifyMigrationChanged() {\n for (const l of migrationListeners) l();\n}\n\nexport function subscribeReactorPgMajor(cb: () => void): () => void {\n majorListeners.add(cb);\n return () => {\n majorListeners.delete(cb);\n };\n}\n\nexport async function detectReactorPgMajor(): Promise<DetectedMajor> {\n if (cachedReactorMajor !== undefined) return cachedReactorMajor;\n if (inflight) return inflight;\n\n inflight = (async () => {\n const major = coerceMajor(await readPgVersionFile(REACTOR_IDB_NAME));\n cachedReactorMajor = major;\n notifyMajorChanged();\n return major;\n })();\n try {\n return await inflight;\n } finally {\n inflight = undefined;\n }\n}\n\nexport function getCachedReactorPgMajor(): DetectedMajor | undefined {\n return cachedReactorMajor;\n}\n\nexport function invalidateReactorPgMajorCache(): void {\n cachedReactorMajor = undefined;\n cachedMigrationMajor = undefined;\n notifyMajorChanged();\n notifyMigrationChanged();\n}\n\nexport async function detectRelationalPgMajor(): Promise<DetectedMajor> {\n return coerceMajor(await readPgVersionFile(RELATIONAL_IDB_NAME));\n}\n\nexport function subscribeMigrationMajor(cb: () => void): () => void {\n migrationListeners.add(cb);\n return () => {\n migrationListeners.delete(cb);\n };\n}\n\nexport function getCachedMigrationMajor(): DetectedMajor | undefined {\n return cachedMigrationMajor;\n}\n\n/**\n * Legacy major the migration banner should prompt for: the first primary store\n * (reactor or relational) on a supported, non-current major. Spans both stores\n * to match migrateAllIfNeeded.\n */\nexport async function detectMigrationMajor(): Promise<DetectedMajor> {\n if (cachedMigrationMajor !== undefined) return cachedMigrationMajor;\n if (migrationInflight) return migrationInflight;\n\n migrationInflight = (async () => {\n const majors = await Promise.all([\n readPgVersionFile(REACTOR_IDB_NAME),\n readPgVersionFile(RELATIONAL_IDB_NAME),\n ]);\n const legacy = majors.find(isMigratableMajor) ?? null;\n cachedMigrationMajor = legacy;\n notifyMigrationChanged();\n return legacy;\n })();\n try {\n return await migrationInflight;\n } finally {\n migrationInflight = undefined;\n }\n}\n","export type WorkerConnectionStatus = \"connected\" | \"lost\" | \"failed\";\n\nlet status: WorkerConnectionStatus = \"connected\";\nconst listeners = new Set<() => void>();\n\nexport function getWorkerConnectionStatus(): WorkerConnectionStatus {\n return status;\n}\n\nexport function setWorkerConnectionStatus(next: WorkerConnectionStatus): void {\n if (status === next) {\n return;\n }\n status = next;\n for (const listener of [...listeners]) {\n listener();\n }\n}\n\nexport function subscribeWorkerConnection(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n"],"names":[],"mappings":";;;;;;;;AASA,SAAgB,wBAAwB,OAAsC;CAC5E,MAAM,WAAW,MAAM,UAAU,KAAK;CACtC,IAAI,UACF,OAAO;CAET,MAAM,OAAO,oBAAoB,MAAM,QAAQ;CAC/C,MAAM,WAAW,MAAM,UAAU,KAAK;CACtC,IAAI,UACF,OAAO,GAAG,KAAK,IAAI,cAAc,UAAU,CAAC;CAE9C,OAAO;AACT;;;ACdA,MAAa,6BAA6B,wBAAwB;CAChE,UAAU;CACV,UAAU,iBAAiB,CAAC,CAAC,QAAQ,UAAU,aAAa,KAAA;AAC9D,CAAC;AAED,MAAa,sBAAsB;AAEnC,MAAa,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qBAAqB,YAAY;EAK/B,MAAM,UAAS,MAJM,QAAQ,IAAI,CAC/B,kBAAkB,gBAAgB,GAClC,kBAAkB,mBAAmB,CACvC,CAAC,EAAA,CACqB,KAAK,iBAAiB,KAAK;EACjD,uBAAuB;EACvB,uBAAuB;EACvB,OAAO;CACT,EAAA,CAAG;CACH,IAAI;EACF,OAAO,MAAM;CACf,UAAU;EACR,oBAAoB,KAAA;CACtB;AACF;;;AC3GA,IAAI,SAAiC;AACrC,MAAM,4BAAY,IAAI,IAAgB;AAEtC,SAAgB,4BAAoD;CAClE,OAAO;AACT;AAEA,SAAgB,0BAA0B,MAAoC;CAC5E,IAAI,WAAW,MACb;CAEF,SAAS;CACT,KAAK,MAAM,YAAY,CAAC,GAAG,SAAS,GAClC,SAAS;AAEb;AAEA,SAAgB,0BAA0B,UAAkC;CAC1E,UAAU,IAAI,QAAQ;CACtB,aAAa;EACX,UAAU,OAAO,QAAQ;CAC3B;AACF","debug_id":"5ec85aa0-e174-5d82-871e-e212735c125c"}
1
+ {"version":3,"file":"connection-state-BKXJeu74.js","sources":["../src/utils/reactor-namespace.ts","../src/utils/storage-namespace.ts","../src/utils/pglite-runtime.ts","../src/connection-state.ts"],"sourcesContent":["import { getStorageNamespace } from \"@powerhousedao/shared/connect\";\nimport { hashNamespace } from \"@powerhousedao/shared/processors\";\n\nexport type ReactorNamespaceInput = {\n basePath: string;\n explicit?: string;\n endpoint?: string;\n};\n\nexport function resolveReactorNamespace(input: ReactorNamespaceInput): string {\n const explicit = input.explicit?.trim();\n if (explicit) {\n return explicit;\n }\n const base = getStorageNamespace(input.basePath);\n const endpoint = input.endpoint?.trim();\n if (endpoint) {\n return `${base}--${hashNamespace(endpoint, 8)}`;\n }\n return base;\n}\n","import { DEFAULT_RELATIONAL_PROCESSOR_DB_NAME } from \"@powerhousedao/shared/processors\";\nimport { ROOT_STORAGE_NAMESPACE } from \"@powerhousedao/shared/connect\";\nimport { PH_CONNECT_BASE_PATH } from \"../connect.config.js\";\nimport { getRuntimeConfig } from \"../runtime-config.js\";\nimport { resolveReactorNamespace } from \"./reactor-namespace.js\";\n\nexport const REACTOR_INSTANCE_NAMESPACE = resolveReactorNamespace({\n basePath: PH_CONNECT_BASE_PATH,\n explicit: getRuntimeConfig().connect.instance?.namespace ?? undefined,\n});\n\nexport const REACTOR_PGLITE_NAME = REACTOR_INSTANCE_NAMESPACE;\n\nexport const RELATIONAL_PGLITE_NAME =\n REACTOR_INSTANCE_NAMESPACE === ROOT_STORAGE_NAMESPACE\n ? DEFAULT_RELATIONAL_PROCESSOR_DB_NAME\n : `${REACTOR_INSTANCE_NAMESPACE}-${DEFAULT_RELATIONAL_PROCESSOR_DB_NAME}`;\n\n// Here, not pglite-idb.ts, so those IDB helpers stay free of runtime-config\n// and remain importable by the reactor SharedWorker.\nexport const REACTOR_IDB_NAME = `/pglite/${REACTOR_PGLITE_NAME}`;\nexport const RELATIONAL_IDB_NAME = `/pglite/${RELATIONAL_PGLITE_NAME}`;\nexport const PRIMARY_IDB_NAMES = [\n REACTOR_IDB_NAME,\n RELATIONAL_IDB_NAME,\n] as const;\n","import { readPgVersionFile } from \"./pglite-idb.js\";\nimport {\n coerceMajor,\n isMigratableMajor,\n type DetectedMajor,\n} from \"./pglite-major.js\";\nimport { REACTOR_IDB_NAME, RELATIONAL_IDB_NAME } from \"./storage-namespace.js\";\n\nexport {\n CURRENT_PG_MAJOR,\n SUPPORTED_PG_MAJORS,\n coerceMajor,\n resolvePgMajorForRuntime,\n loadPGliteModule,\n loadPgDump,\n type SupportedPgMajor,\n type DetectedMajor,\n} from \"./pglite-major.js\";\n\nlet cachedReactorMajor: DetectedMajor | undefined;\nlet inflight: Promise<DetectedMajor> | undefined;\nconst majorListeners = new Set<() => void>();\n\nlet cachedMigrationMajor: DetectedMajor | undefined;\nlet migrationInflight: Promise<DetectedMajor> | undefined;\nconst migrationListeners = new Set<() => void>();\n\nfunction notifyMajorChanged() {\n for (const l of majorListeners) l();\n}\n\nfunction notifyMigrationChanged() {\n for (const l of migrationListeners) l();\n}\n\nexport function subscribeReactorPgMajor(cb: () => void): () => void {\n majorListeners.add(cb);\n return () => {\n majorListeners.delete(cb);\n };\n}\n\nexport async function detectReactorPgMajor(): Promise<DetectedMajor> {\n if (cachedReactorMajor !== undefined) return cachedReactorMajor;\n if (inflight) return inflight;\n\n inflight = (async () => {\n const major = coerceMajor(await readPgVersionFile(REACTOR_IDB_NAME));\n cachedReactorMajor = major;\n notifyMajorChanged();\n return major;\n })();\n try {\n return await inflight;\n } finally {\n inflight = undefined;\n }\n}\n\nexport function getCachedReactorPgMajor(): DetectedMajor | undefined {\n return cachedReactorMajor;\n}\n\nexport function invalidateReactorPgMajorCache(): void {\n cachedReactorMajor = undefined;\n cachedMigrationMajor = undefined;\n notifyMajorChanged();\n notifyMigrationChanged();\n}\n\nexport async function detectRelationalPgMajor(): Promise<DetectedMajor> {\n return coerceMajor(await readPgVersionFile(RELATIONAL_IDB_NAME));\n}\n\nexport function subscribeMigrationMajor(cb: () => void): () => void {\n migrationListeners.add(cb);\n return () => {\n migrationListeners.delete(cb);\n };\n}\n\nexport function getCachedMigrationMajor(): DetectedMajor | undefined {\n return cachedMigrationMajor;\n}\n\n/**\n * Legacy major the migration banner should prompt for: the first primary store\n * (reactor or relational) on a supported, non-current major. Spans both stores\n * to match migrateAllIfNeeded.\n */\nexport async function detectMigrationMajor(): Promise<DetectedMajor> {\n if (cachedMigrationMajor !== undefined) return cachedMigrationMajor;\n if (migrationInflight) return migrationInflight;\n\n migrationInflight = (async () => {\n const majors = await Promise.all([\n readPgVersionFile(REACTOR_IDB_NAME),\n readPgVersionFile(RELATIONAL_IDB_NAME),\n ]);\n const legacy = majors.find(isMigratableMajor) ?? null;\n cachedMigrationMajor = legacy;\n notifyMigrationChanged();\n return legacy;\n })();\n try {\n return await migrationInflight;\n } finally {\n migrationInflight = undefined;\n }\n}\n","export type WorkerConnectionStatus =\n | \"connected\"\n | \"lost\"\n | \"failed\"\n | \"storage-unusable\"\n | \"storage-held\"\n | \"version-conflict\";\n\nlet status: WorkerConnectionStatus = \"connected\";\nconst listeners = new Set<() => void>();\n\nexport function getWorkerConnectionStatus(): WorkerConnectionStatus {\n return status;\n}\n\nfunction publish(next: WorkerConnectionStatus): void {\n status = next;\n for (const listener of [...listeners]) {\n listener();\n }\n}\n\n/**\n * \"storage-unusable\" and \"version-conflict\" hold until the page reloads, and\n * \"storage-held\" until {@link clearStorageHeld}; a live worker's pong clears none.\n */\nexport function setWorkerConnectionStatus(next: WorkerConnectionStatus): void {\n if (\n status === next ||\n status === \"storage-unusable\" ||\n status === \"version-conflict\"\n ) {\n return;\n }\n if (status === \"storage-held\" && next === \"connected\") {\n return;\n }\n publish(next);\n}\n\nexport function clearStorageHeld(): void {\n if (status === \"storage-held\") {\n publish(\"connected\");\n }\n}\n\nexport function subscribeWorkerConnection(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n"],"names":[],"mappings":";;;;;;;;AASA,SAAgB,wBAAwB,OAAsC;CAC5E,MAAM,WAAW,MAAM,UAAU,KAAK;CACtC,IAAI,UACF,OAAO;CAET,MAAM,OAAO,oBAAoB,MAAM,QAAQ;CAC/C,MAAM,WAAW,MAAM,UAAU,KAAK;CACtC,IAAI,UACF,OAAO,GAAG,KAAK,IAAI,cAAc,UAAU,CAAC;CAE9C,OAAO;AACT;;;ACdA,MAAa,6BAA6B,wBAAwB;CAChE,UAAU;CACV,UAAU,iBAAiB,CAAC,CAAC,QAAQ,UAAU,aAAa,KAAA;AAC9D,CAAC;AAED,MAAa,sBAAsB;AAEnC,MAAa,yBACX,+BAA+B,yBAC3B,uCACA,GAAG,2BAA2B,GAAG;AAIvC,MAAa,mBAAmB,WAAW;AAC3C,MAAa,sBAAsB,WAAW;AAC9C,MAAa,oBAAoB,CAC/B,kBACA,mBACF;;;ACNA,IAAI;AACJ,IAAI;AACJ,MAAM,iCAAiB,IAAI,IAAgB;AAE3C,IAAI;AACJ,IAAI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CACf,UAAU;EACR,oBAAoB,KAAA;CACtB;AACF;;;ACrGA,IAAI,SAAiC;AACrC,MAAM,4BAAY,IAAI,IAAgB;AAEtC,SAAgB,4BAAoD;CAClE,OAAO;AACT;AAEA,SAAS,QAAQ,MAAoC;CACnD,SAAS;CACT,KAAK,MAAM,YAAY,CAAC,GAAG,SAAS,GAClC,SAAS;AAEb;;;;;AAMA,SAAgB,0BAA0B,MAAoC;CAC5E,IACE,WAAW,QACX,WAAW,sBACX,WAAW,oBAEX;CAEF,IAAI,WAAW,kBAAkB,SAAS,aACxC;CAEF,QAAQ,IAAI;AACd;AAEA,SAAgB,mBAAyB;CACvC,IAAI,WAAW,gBACb,QAAQ,WAAW;AAEvB;AAEA,SAAgB,0BAA0B,UAAkC;CAC1E,UAAU,IAAI,QAAQ;CACtB,aAAa;EACX,UAAU,OAAO,QAAQ;CAC3B;AACF","debug_id":"2e40d4f6-3bef-55f7-885b-19ab72d0bf99"}
@@ -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]="be7124ab-6500-5d62-b43b-752572fc7b0d")}catch(e){}}();
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]="6d2270e5-54bf-5dba-9744-7d1e3d4bc96b")}catch(e){}}();
3
3
  import { r as loadRuntimeConfig, t as applyConnectBranding } from "./runtime-config-DtJIUgYw.js";
4
4
  import "./i18n-CTgT1HG-.js";
5
5
  import { r as connectConfig } from "./connect.config-CaXMoB42.js";
6
6
  import { n as setUser } from "./sentry-jfDyrxdX.js";
7
- import { t as getBuildHash } from "./build-info-CFBxV6Xr.js";
8
- import { a as detectReactorPgMajor, i as detectMigrationMajor } from "./connection-state-Eqc2izmt.js";
9
- import { n as seedPendingPgVersion } from "./pglite-seed-Cl2d-iyl.js";
10
- import { n as createReactor } from "./reactor-D22fypZB.js";
7
+ import { t as getBuildHash } from "./build-info-BEK9jmfs.js";
8
+ import { a as detectMigrationMajor, o as detectReactorPgMajor } from "./connection-state-BKXJeu74.js";
9
+ import { n as seedPendingPgVersion } from "./pglite-seed-C7hUK6X_.js";
10
+ import { n as createReactor } from "./reactor-Dh29UPqN.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) {
129
129
  //#endregion
130
130
  export { loadComponent };
131
131
 
132
- //# sourceMappingURL=load-BNL6CTpV.js.map
133
- //# debugId=be7124ab-6500-5d62-b43b-752572fc7b0d
132
+ //# sourceMappingURL=load-BU73BPux.js.map
133
+ //# debugId=6d2270e5-54bf-5dba-9744-7d1e3d4bc96b
@@ -1 +1 @@
1
- {"version":3,"file":"load-BNL6CTpV.js","sources":["../src/hooks/useCheckLatestVersion.ts","../src/hooks/utils.ts","../src/store/user.ts","../src/components/load.tsx"],"sourcesContent":["import { connectConfig } from \"@powerhousedao/connect/config\";\nimport { getBuildHashStatus } from \"@powerhousedao/connect/hooks\";\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 { 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 { 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 { initTheme } from \"@powerhousedao/reactor-browser\";\nimport type { DocumentModelLib } from \"document-model\";\nimport { type ReactNode } from \"react\";\nimport { applyConnectBranding, loadRuntimeConfig } from \"../runtime-config.js\";\n\nexport async function loadComponent(localPackage?: DocumentModelLib) {\n await seedPendingPgVersion();\n await Promise.all([detectReactorPgMajor(), detectMigrationMajor()]);\n const runtimeConfig = await loadRuntimeConfig();\n applyConnectBranding(runtimeConfig);\n await createReactor(localPackage);\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":";;;;;;;;;;;;;;AAQA,MAAM,mBAAmB;;;;;;;;;AAUzB,eAAe,mBAAkC;CAC/C,IAAI;EACF,IAAI,EAAE,YAAY,SAAS;EAC3B,MAAM,OAAO,MAAM,OAAO,OAAO,KAAK;EACtC,MAAM,QAAQ,IACZ,KACG,QAAQ,QAAQ,IAAI,SAAS,UAAU,KAAK,IAAI,SAAS,UAAU,CAAC,CAAC,CACrE,KAAK,QAAQ,OAAO,OAAO,OAAO,GAAG,CAAC,CAC3C;CACF,SAAS,OAAO;EACd,OAAO,KACL,4DACA,KACF;CACF;AACF;;;;;;;;;;AAWA,MAAa,8BAA8B;CACzC,gBAAgB;EACd,IACE,YAAY,IAAI,SAAS,iBACzB,cAAc,cACd,CAAC,cAAc,iBAEf;EAGF,MAAM,iBAAiB,YAAY;GACjC,MAAM,SAAS,MAAM,mBAAmB;GACxC,IAAI,CAAC,UAAU,OAAO,WAAW;GAGjC,IADoB,OAAO,eAAe,QAAQ,gBACpC,MAAM,OAAO,cAAc;GACzC,OAAO,eAAe,QAAQ,kBAAkB,OAAO,YAAY;GAEnE,OAAO,KACL,4EACA,OAAO,aACP,OAAO,YACT;GACA,MAAM,iBAAiB;GACvB,OAAO,SAAS,OAAO;EACzB;EAEA,eAAoB;EACpB,MAAM,2BAA2B;GAC/B,IAAI,SAAS,oBAAoB,WAAW,eAAoB;EAClE;EACA,SAAS,iBAAiB,oBAAoB,kBAAk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LatestVersion.ts","../src/hooks/utils.ts","../src/store/user.ts","../src/components/load.tsx"],"sourcesContent":["import { connectConfig } from \"@powerhousedao/connect/config\";\nimport { getBuildHashStatus } from \"@powerhousedao/connect/hooks\";\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 { 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 { 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 { initTheme } from \"@powerhousedao/reactor-browser\";\nimport type { DocumentModelLib } from \"document-model\";\nimport { type ReactNode } from \"react\";\nimport { applyConnectBranding, loadRuntimeConfig } from \"../runtime-config.js\";\n\nexport async function loadComponent(localPackage?: DocumentModelLib) {\n await seedPendingPgVersion();\n await Promise.all([detectReactorPgMajor(), detectMigrationMajor()]);\n const runtimeConfig = await loadRuntimeConfig();\n applyConnectBranding(runtimeConfig);\n await createReactor(localPackage);\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":";;;;;;;;;;;;;;AAQA,MAAM,mBAAmB;;;;;;;;;AAUzB,eAAe,mBAAkC;CAC/C,IAAI;EACF,IAAI,EAAE,YAAY,SAAS;EAC3B,MAAM,OAAO,MAAM,OAAO,OAAO,KAAK;EACtC,MAAM,QAAQ,IACZ,KACG,QAAQ,QAAQ,IAAI,SAAS,UAAU,KAAK,IAAI,SAAS,UAAU,CAAC,CAAC,CACrE,KAAK,QAAQ,OAAO,OAAO,OAAO,GAAG,CAAC,CAC3C;CACF,SAAS,OAAO;EACd,OAAO,KACL,4DACA,KACF;CACF;AACF;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C,aAAa;IAAE,IAAI,KAAK;IAAK,UAAU,KAAK,KAAK;IAAM,GAAG;GAAK;EACjE;EACA,QAAc,UAAU;CAC1B,GAAG,CAAC,IAAI,CAAC;AACX;;;ACHA,eAAsB,cAAc,cAAiC;CACnE,MAAM,qBAAqB;CAC3B,MAAM,QAAQ,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,CAAC;CAClE,MAAM,gBAAgB,MAAM,kBAAkB;CAC9C,qBAAqB,aAAa;CAClC,MAAM,cAAc,YAAY;CAChC,OAAO,EACL,UAAU,EAAE,eAAyC;EACnD,UAAU;EAEV,iBAAiB;EAEjB,sBAAsB;EACtB,OAAO;CACT,EACF;AACF","debug_id":"6d2270e5-54bf-5dba-9744-7d1e3d4bc96b"}
package/dist/main.js CHANGED
@@ -5,7 +5,7 @@ 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-Brz2Nmo5.js");
8
+ const { AppLoader } = await import("./app-loader-DWsWZBTH.js");
9
9
  root.render(/* @__PURE__ */ jsx(AppLoader, {}));
10
10
  }
11
11
  //#endregion
@@ -1,6 +1,6 @@
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]="d59c69fe-5f4d-5aa8-accd-b4fbae2bd47a")}catch(e){}}();
3
- import { l as invalidateReactorPgMajorCache, m as REACTOR_PGLITE_NAME } from "./connection-state-Eqc2izmt.js";
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]="8af1e6db-a4d4-55f4-9a05-667244c0d4ba")}catch(e){}}();
3
+ import { h as REACTOR_PGLITE_NAME, u as invalidateReactorPgMajorCache } from "./connection-state-BKXJeu74.js";
4
4
  //#region src/utils/pglite-seed.ts
5
5
  const PENDING_PG_SEED_KEY = "ph:pending-pg-seed";
6
6
  /**
@@ -45,5 +45,5 @@ async function seedPendingPgVersion() {
45
45
  //#endregion
46
46
  export { seedPendingPgVersion as n, PENDING_PG_SEED_KEY as t };
47
47
 
48
- //# sourceMappingURL=pglite-seed-Cl2d-iyl.js.map
49
- //# debugId=d59c69fe-5f4d-5aa8-accd-b4fbae2bd47a
48
+ //# sourceMappingURL=pglite-seed-C7hUK6X_.js.map
49
+ //# debugId=8af1e6db-a4d4-55f4-9a05-667244c0d4ba
@@ -1 +1 @@
1
- {"version":3,"file":"pglite-seed-Cl2d-iyl.js","sources":["../src/utils/pglite-seed.ts"],"sourcesContent":["import { invalidateReactorPgMajorCache } from \"./pglite-runtime.js\";\nimport { REACTOR_PGLITE_NAME } from \"./storage-namespace.js\";\n\nexport const PENDING_PG_SEED_KEY = \"ph:pending-pg-seed\";\n\n/**\n * If the Debug Inspector requested a forced PG version reset, this runs\n * before the reactor is created on the subsequent page load: opens a fresh\n * PGlite of the requested major against the reactor data dir, lets `initdb`\n * populate `PG_VERSION`, then closes. The next step of app boot then\n * detects this fresh data dir and picks the matching runtime.\n */\nexport async function seedPendingPgVersion(): Promise<void> {\n const raw = localStorage.getItem(PENDING_PG_SEED_KEY);\n if (!raw) return;\n\n const major = parseInt(raw, 10);\n console.info(`[pglite-seed] Seeding fresh PG${major} data dir...`);\n\n try {\n if (major === 16) {\n const { PGlite } = await import(\"pglite-legacy-02\");\n const pg = new PGlite(`idb://${REACTOR_PGLITE_NAME}`);\n try {\n await pg.waitReady;\n } finally {\n await pg.close();\n }\n } else if (major === 17) {\n const { PGlite } = await import(\"@electric-sql/pglite\");\n const pg = new PGlite(`idb://${REACTOR_PGLITE_NAME}`);\n try {\n await pg.waitReady;\n } finally {\n await pg.close();\n }\n } else {\n console.warn(`[pglite-seed] Unsupported version ${raw}, skipping`);\n return;\n }\n console.info(`[pglite-seed] Seeded PG${major} data dir.`);\n } finally {\n localStorage.removeItem(PENDING_PG_SEED_KEY);\n invalidateReactorPgMajorCache();\n }\n}\n"],"names":[],"mappings":";;;;AAGA,MAAa,sBAAsB;;;;;;;;AASnC,eAAsB,uBAAsC;CAC1D,MAAM,MAAM,aAAa,QAAQ,mBAAmB;CACpD,IAAI,CAAC,KAAK;CAEV,MAAM,QAAQ,SAAS,KAAK,EAAE;CAC9B,QAAQ,KAAK,iCAAiC,MAAM,aAAa;CAEjE,IAAI;EACF,IAAI,UAAU,IAAI;GAChB,MAAM,EAAE,WAAW,MAAM,OAAO;GAChC,MAAM,KAAK,IAAI,OAAO,SAAS,qBAAqB;GACpD,IAAI;IACF,MAAM,GAAG;GACX,UAAU;IACR,MAAM,GAAG,MAAM;GACjB;EACF,OAAO,IAAI,UAAU,IAAI;GACvB,MAAM,EAAE,WAAW,MAAM,OAAO;GAChC,MAAM,KAAK,IAAI,OAAO,SAAS,qBAAqB;GACpD,IAAI;IACF,MAAM,GAAG;GACX,UAAU;IACR,MAAM,GAAG,MAAM;GACjB;EACF,OAAO;GACL,QAAQ,KAAK,qCAAqC,IAAI,WAAW;GACjE;EACF;EACA,QAAQ,KAAK,0BAA0B,MAAM,WAAW;CAC1D,UAAU;EACR,aAAa,WAAW,mBAAmB;EAC3C,8BAA8B;CAChC;AACF","debug_id":"d59c69fe-5f4d-5aa8-accd-b4fbae2bd47a"}
1
+ {"version":3,"file":"pglite-seed-C7hUK6X_.js","sources":["../src/utils/pglite-seed.ts"],"sourcesContent":["import { invalidateReactorPgMajorCache } from \"./pglite-runtime.js\";\nimport { REACTOR_PGLITE_NAME } from \"./storage-namespace.js\";\n\nexport const PENDING_PG_SEED_KEY = \"ph:pending-pg-seed\";\n\n/**\n * If the Debug Inspector requested a forced PG version reset, this runs\n * before the reactor is created on the subsequent page load: opens a fresh\n * PGlite of the requested major against the reactor data dir, lets `initdb`\n * populate `PG_VERSION`, then closes. The next step of app boot then\n * detects this fresh data dir and picks the matching runtime.\n */\nexport async function seedPendingPgVersion(): Promise<void> {\n const raw = localStorage.getItem(PENDING_PG_SEED_KEY);\n if (!raw) return;\n\n const major = parseInt(raw, 10);\n console.info(`[pglite-seed] Seeding fresh PG${major} data dir...`);\n\n try {\n if (major === 16) {\n const { PGlite } = await import(\"pglite-legacy-02\");\n const pg = new PGlite(`idb://${REACTOR_PGLITE_NAME}`);\n try {\n await pg.waitReady;\n } finally {\n await pg.close();\n }\n } else if (major === 17) {\n const { PGlite } = await import(\"@electric-sql/pglite\");\n const pg = new PGlite(`idb://${REACTOR_PGLITE_NAME}`);\n try {\n await pg.waitReady;\n } finally {\n await pg.close();\n }\n } else {\n console.warn(`[pglite-seed] Unsupported version ${raw}, skipping`);\n return;\n }\n console.info(`[pglite-seed] Seeded PG${major} data dir.`);\n } finally {\n localStorage.removeItem(PENDING_PG_SEED_KEY);\n invalidateReactorPgMajorCache();\n }\n}\n"],"names":[],"mappings":";;;;AAGA,MAAa,sBAAsB;;;;;;;;AASnC,eAAsB,uBAAsC;CAC1D,MAAM,MAAM,aAAa,QAAQ,mBAAmB;CACpD,IAAI,CAAC,KAAK;CAEV,MAAM,QAAQ,SAAS,KAAK,EAAE;CAC9B,QAAQ,KAAK,iCAAiC,MAAM,aAAa;CAEjE,IAAI;EACF,IAAI,UAAU,IAAI;GAChB,MAAM,EAAE,WAAW,MAAM,OAAO;GAChC,MAAM,KAAK,IAAI,OAAO,SAAS,qBAAqB;GACpD,IAAI;IACF,MAAM,GAAG;GACX,UAAU;IACR,MAAM,GAAG,MAAM;GACjB;EACF,OAAO,IAAI,UAAU,IAAI;GACvB,MAAM,EAAE,WAAW,MAAM,OAAO;GAChC,MAAM,KAAK,IAAI,OAAO,SAAS,qBAAqB;GACpD,IAAI;IACF,MAAM,GAAG;GACX,UAAU;IACR,MAAM,GAAG,MAAM;GACjB;EACF,OAAO;GACL,QAAQ,KAAK,qCAAqC,IAAI,WAAW;GACjE;EACF;EACA,QAAQ,KAAK,0BAA0B,MAAM,WAAW;CAC1D,UAAU;EACR,aAAa,WAAW,mBAAmB;EAC3C,8BAA8B;CAChC;AACF","debug_id":"8af1e6db-a4d4-55f4-9a05-667244c0d4ba"}
@@ -1,23 +1,96 @@
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]="e722fa32-8aef-561c-9533-516bf671c91e")}catch(e){}}();
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]="a7bdc680-a242-51c3-8856-40f8e88e760e")}catch(e){}}();
3
3
  import { n as getRuntimeConfig } from "./runtime-config-DtJIUgYw.js";
4
- import { t as createConnectSignerConfig } from "./renown-trust-DRgHpxlZ.js";
4
+ import { a as closeWithin, n as watchStoreLockWait, o as createConnectSignerConfig } from "./store-lock-T8oyiDm4.js";
5
5
  import { a as resolvePgMajorForRuntime, f as toStoredDocumentsRefused, r as loadPGliteModule } from "./pglite-major-p4_YefAE.js";
6
6
  import { n as buildPHGlobalConfig, o as phGlobalConfig, r as connectConfig } from "./connect.config-CaXMoB42.js";
7
7
  import { r as toast } from "./toast-C6WW-_O-.js";
8
8
  import { r as getSharedDeps, t as BrowserPackageManager } from "./package-manager-BPVMRBoV.js";
9
- import { a as isPackagedConnectDist, i as getVersion, n as getGitSha } from "./build-info-CFBxV6Xr.js";
10
- import { a as detectReactorPgMajor, h as RELATIONAL_PGLITE_NAME, m as REACTOR_PGLITE_NAME, n as setWorkerConnectionStatus, o as detectRelationalPgMajor, p as REACTOR_INSTANCE_NAMESPACE, t as getWorkerConnectionStatus } from "./connection-state-Eqc2izmt.js";
9
+ import { a as isPackagedConnectDist, i as getVersion, n as getGitSha } from "./build-info-BEK9jmfs.js";
10
+ import { g as RELATIONAL_PGLITE_NAME, h as REACTOR_PGLITE_NAME, m as REACTOR_INSTANCE_NAMESPACE, n as getWorkerConnectionStatus, o as detectReactorPgMajor, r as setWorkerConnectionStatus, s as detectRelationalPgMajor, t as clearStorageHeld } from "./connection-state-BKXJeu74.js";
11
11
  import { createRelationalDb } from "@powerhousedao/shared/processors";
12
- import { DocumentModelRegistry, DocumentModelResolver, ReactorEventTypes, createReactorHostModuleBase } from "@powerhousedao/reactor";
13
- import { MessageRouter, RPC_PROTOCOL_VERSION, SyncManagerProxy, connectReactorClient, createInspectorProxy, createPortTransport, createReactorEventBusProxy, createRelationalPgliteProxy, createWorkerAdminClient, postReactorIdentity } from "@powerhousedao/reactor-browser/rpc";
12
+ import { DocumentModelRegistry, DocumentModelResolver, HardenedPGliteDialect, ReactorEventTypes, createReactorHostModuleBase } from "@powerhousedao/reactor";
13
+ import { MessageRouter, RPC_PROTOCOL_VERSION, SyncManagerProxy, connectReactorClient, createInspectorProxy, createPortTransport, createReactorEventBusProxy, createRelationalPgliteProxy, createWorkerAdminClient, isFingerprintMismatchReload, postReactorIdentity } from "@powerhousedao/reactor-browser/rpc";
14
14
  import { Kysely } from "kysely";
15
- import { PGliteDialect } from "kysely-pglite-dialect";
16
15
  import { BrowserLocalStorage, ChannelScheme as ChannelScheme$1, DRIVE_DOCUMENT_TYPES, DocumentCache, DocumentChangeType, ReactorBuilder as ReactorBuilder$1, ReactorClientBuilder as ReactorClientBuilder$1, RegistryClient, addDrive, addPHEventHandlers, addRemoteDrive, createAnalyticsStore, extractDriveSlugFromPath, extractNodeSlugFromPath, getDrives, isDriveAuthError, login, refreshReactorDataClient, setAttachmentService, setDefaultPHGlobalConfig, setDocumentCache, setDriveMetadata, setDrives, setFeatures, setPGliteDB, setPHToast, setPackageDiscoveryService, setReactorClient, setReactorClientModule, setRenown, setSelectedDrive, setSelectedNode, setVetraPackageManager, waitForDocumentReady } from "@powerhousedao/reactor-browser";
17
16
  import { ConsoleLogger, logger, setLogLevel as setLogLevel$1 } from "document-model";
18
17
  import { createAttachmentClient, createRemoteAttachmentService, createXhrUploadTransport } from "@powerhousedao/reactor-attachments/client";
19
18
  import { BrowserKeyStorage, RenownBuilder, RenownCryptoBuilder } from "@renown/sdk";
20
19
  import { OpenFeature } from "@openfeature/web-sdk";
20
+ //#region src/utils/poisoned-store-budget.ts
21
+ const BUDGET_LIMIT = 2;
22
+ const POISONED_STORE = {
23
+ key: "ph-connect:poisoned-store-reloads",
24
+ quietMs: 6e5
25
+ };
26
+ const MISMATCH = {
27
+ key: "ph-connect:mismatch-reloads",
28
+ quietMs: 6e4
29
+ };
30
+ function sessionStore() {
31
+ try {
32
+ return globalThis.sessionStorage;
33
+ } catch {
34
+ return;
35
+ }
36
+ }
37
+ function readRecord(raw) {
38
+ const record = raw ? JSON.parse(raw) : null;
39
+ return typeof record?.count === "number" && typeof record.lastAt === "number" ? {
40
+ count: record.count,
41
+ lastAt: record.lastAt
42
+ } : {
43
+ count: 0,
44
+ lastAt: 0
45
+ };
46
+ }
47
+ function claimReload(budget, storage, now) {
48
+ if (storage === void 0) return false;
49
+ try {
50
+ const previous = readRecord(storage.getItem(budget.key));
51
+ const count = now - previous.lastAt >= budget.quietMs ? 0 : previous.count;
52
+ const allowed = count < BUDGET_LIMIT;
53
+ storage.setItem(budget.key, JSON.stringify({
54
+ count: allowed ? count + 1 : count,
55
+ lastAt: now
56
+ }));
57
+ return allowed;
58
+ } catch {
59
+ return false;
60
+ }
61
+ }
62
+ /** One page reload answers every budgeted reload the page hears, of either budget. */
63
+ let reloadRequested = false;
64
+ function reloadWithinBudget(budget, reload, pastBudget, storage = sessionStore(), now = Date.now()) {
65
+ if (reloadRequested) return;
66
+ if (claimReload(budget, storage, now)) {
67
+ reloadRequested = true;
68
+ reload();
69
+ return;
70
+ }
71
+ setWorkerConnectionStatus(pastBudget);
72
+ }
73
+ /** Past the budget a poisoned store stops reloading and shows storage-unusable, so clear storage stays reachable. */
74
+ function reloadForPoisonedStore(reload, storage, now) {
75
+ reloadWithinBudget(POISONED_STORE, reload, "storage-unusable", storage, now);
76
+ }
77
+ /** onPoisoned for an in-tab store: the page reload reopens it, within the poisoned-store budget. */
78
+ function reloadPageForPoisonedStore(cause, reload = () => window.location.reload()) {
79
+ console.error("[connect] PGlite session poisoned:", cause);
80
+ reloadForPoisonedStore(reload);
81
+ }
82
+ function reloadForWorker(reason, reload, storage, now) {
83
+ if (reason === "storage session poisoned") {
84
+ reloadForPoisonedStore(reload, storage, now);
85
+ return;
86
+ }
87
+ if (isFingerprintMismatchReload(reason)) {
88
+ reloadWithinBudget(MISMATCH, reload, "version-conflict", storage, now);
89
+ return;
90
+ }
91
+ reload();
92
+ }
93
+ //#endregion
21
94
  //#region src/pglite.db.ts
22
95
  async function createMainThreadPGlite(major, dbName) {
23
96
  const { PGlite } = await loadPGliteModule(major);
@@ -63,7 +136,7 @@ async function getDb() {
63
136
  const pgLite = await getRelationalPGlite();
64
137
  return {
65
138
  pgLite,
66
- relationalDb: createRelationalDb(new Kysely({ dialect: new PGliteDialect(pgLite) }))
139
+ relationalDb: createRelationalDb(new Kysely({ dialect: new HardenedPGliteDialect(pgLite, { onPoisoned: reloadPageForPoisonedStore }) }))
67
140
  };
68
141
  }
69
142
  //#endregion
@@ -80,7 +153,7 @@ async function createBrowserReactor(documentModelModules, upgradeManifests, reno
80
153
  };
81
154
  const pg = await getReactorPGlite();
82
155
  const logger = new ConsoleLogger(["reactor-client"]);
83
- const reactorBuilder = new ReactorBuilder$1().withDocumentModelSources(documentModelModules).withUpgradeManifests(upgradeManifests).withChannelScheme(ChannelScheme$1.CONNECT).withExecutorConfig({ featureFlags }).withJwtHandler(jwtHandler).withKysely(new Kysely({ dialect: new PGliteDialect(pg) }));
156
+ const reactorBuilder = new ReactorBuilder$1().withDocumentModelSources(documentModelModules).withUpgradeManifests(upgradeManifests).withChannelScheme(ChannelScheme$1.CONNECT).withExecutorConfig({ featureFlags }).withJwtHandler(jwtHandler).withKysely(new Kysely({ dialect: new HardenedPGliteDialect(pg, { onPoisoned: reloadPageForPoisonedStore }) }));
84
157
  const builder = new ReactorClientBuilder$1().withLogger(logger).withSigner(signerConfig).withReactorBuilder(reactorBuilder);
85
158
  if (documentModelLoader) builder.withDocumentModelLoader(documentModelLoader);
86
159
  if (createSignaturePolicy) builder.withCreateSignaturePolicy(createSignaturePolicy);
@@ -609,20 +682,31 @@ var PackageDiscoveryService = class {
609
682
  //#endregion
610
683
  //#region src/reactor-worker-name.ts
611
684
  const GEN_KEY_PREFIX = "ph-reactor-gen:";
612
- function reactorWorkerName(namespace) {
613
- const gen = readWorkerGen(namespace);
685
+ function genStore() {
686
+ try {
687
+ return globalThis.localStorage;
688
+ } catch {
689
+ return;
690
+ }
691
+ }
692
+ function workerNameForGen(namespace, gen) {
614
693
  return gen ? `ph-reactor:${namespace}#${gen}` : `ph-reactor:${namespace}`;
615
694
  }
616
- function readWorkerGen(namespace) {
695
+ function readWorkerGen(namespace, storage = genStore()) {
617
696
  try {
618
- return localStorage.getItem(GEN_KEY_PREFIX + namespace);
697
+ return storage?.getItem(GEN_KEY_PREFIX + namespace) ?? null;
619
698
  } catch {
620
699
  return null;
621
700
  }
622
701
  }
623
- function bumpWorkerGen(namespace, gen) {
702
+ /**
703
+ * Gens are unordered tokens, so a reload moves the gen on only from the one
704
+ * this tab's worker runs as; a stale worker's reload never undoes a newer one.
705
+ */
706
+ function adoptWorkerGen(namespace, from, to, storage = genStore()) {
624
707
  try {
625
- localStorage.setItem(GEN_KEY_PREFIX + namespace, gen);
708
+ if (storage?.getItem(GEN_KEY_PREFIX + namespace) !== from) return;
709
+ storage.setItem(GEN_KEY_PREFIX + namespace, to);
626
710
  } catch {}
627
711
  }
628
712
  //#endregion
@@ -644,9 +728,11 @@ function toReactorIdentity(user) {
644
728
  }
645
729
  function createWorkerReactorClientModule(args) {
646
730
  const workerUrl = args.workerUrl ? new URL(args.workerUrl) : new URL("./reactor.worker.js", import.meta.url);
647
- console.info(`[reactor-worker] constructing SharedWorker ${reactorWorkerName(args.namespace)} from ${workerUrl.href}`);
731
+ const workerGen = readWorkerGen(args.namespace);
732
+ const workerName = workerNameForGen(args.namespace, workerGen);
733
+ console.info(`[reactor-worker] constructing SharedWorker ${workerName} from ${workerUrl.href}`);
648
734
  const worker = new SharedWorker(workerUrl, {
649
- name: reactorWorkerName(args.namespace),
735
+ name: workerName,
650
736
  type: "module"
651
737
  });
652
738
  worker.addEventListener("error", (event) => {
@@ -690,7 +776,10 @@ function createWorkerReactorClientModule(args) {
690
776
  packageSources: args.packageSources
691
777
  },
692
778
  packages: args.packageSpecs
693
- }, args.onReload, documentModelRegistry);
779
+ }, (reason, nextGen) => {
780
+ if (nextGen) adoptWorkerGen(args.namespace, workerGen, nextGen);
781
+ args.onReload(reason);
782
+ }, documentModelRegistry);
694
783
  const busProxy = createReactorEventBusProxy(router);
695
784
  const syncManagerProxy = new SyncManagerProxy(router, busProxy);
696
785
  const modelResolver = new DocumentModelResolver(documentModelRegistry, args.documentModelLoader);
@@ -780,6 +869,18 @@ function closeDeletedSelection(event, host) {
780
869
  }
781
870
  }
782
871
  //#endregion
872
+ //#region src/utils/worker-startup.ts
873
+ /** Runs the worker's startup seed, showing storage-held while its stores are locked elsewhere. */
874
+ async function startupOwningStores(startup, namespaces, watchOptions) {
875
+ const stopWatching = watchStoreLockWait(namespaces, (waiting) => waiting ? setWorkerConnectionStatus("storage-held") : clearStorageHeld(), watchOptions);
876
+ try {
877
+ await startup({ isWaiting: () => getWorkerConnectionStatus() === "storage-held" });
878
+ clearStorageHeld();
879
+ } finally {
880
+ stopWatching();
881
+ }
882
+ }
883
+ //#endregion
783
884
  //#region src/utils/reactor-worker-flag.ts
784
885
  const REACTOR_WORKER_QUERY_KEY = "reactorWorker";
785
886
  const REACTOR_WORKER_STORAGE_KEY = "ph:reactorWorker";
@@ -1039,7 +1140,7 @@ async function clearReactorStorage() {
1039
1140
  await module.adminClient.clearStorage();
1040
1141
  return;
1041
1142
  }
1042
- if (module?.kind === "browser") await module.reactorModule?.pg?.close();
1143
+ if (module?.kind === "browser") await closeWithin(module.reactorModule?.pg);
1043
1144
  const targets = (await indexedDB.databases()).map((d) => d.name).filter((n) => !!n && !n.startsWith("ph-pglite-backup::") && /pglite|reactor/i.test(n));
1044
1145
  await Promise.all(targets.map((name) => new Promise((resolve) => {
1045
1146
  const req = indexedDB.deleteDatabase(name);
@@ -1144,10 +1245,9 @@ async function createReactor(localPackage) {
1144
1245
  upgradeManifests,
1145
1246
  documentModelLoader,
1146
1247
  renown,
1147
- onReload: (reason, workerGen) => {
1248
+ onReload: (reason) => {
1148
1249
  logger.warn("Reactor worker requested reload: @reason", reason);
1149
- if (workerGen) bumpWorkerGen(REACTOR_INSTANCE_NAMESPACE, workerGen);
1150
- window.location.reload();
1250
+ reloadForWorker(reason, () => window.location.reload());
1151
1251
  }
1152
1252
  });
1153
1253
  reactorClientModule = workerClient.reactorClientModule;
@@ -1164,7 +1264,7 @@ async function createReactor(localPackage) {
1164
1264
  })();
1165
1265
  });
1166
1266
  try {
1167
- await workerClient.syncManagerProxy.startup();
1267
+ await startupOwningStores((options) => workerClient.syncManagerProxy.startup(options), [REACTOR_INSTANCE_NAMESPACE, RELATIONAL_PGLITE_NAME]);
1168
1268
  } catch (error) {
1169
1269
  window.ph.loading = false;
1170
1270
  logger.error("Reactor worker failed to start: @error", error);
@@ -1264,5 +1364,5 @@ function getDriveUrl() {
1264
1364
  //#endregion
1265
1365
  export { createReactor as n, clearReactorStorage as t };
1266
1366
 
1267
- //# sourceMappingURL=reactor-D22fypZB.js.map
1268
- //# debugId=e722fa32-8aef-561c-9533-516bf671c91e
1367
+ //# sourceMappingURL=reactor-Dh29UPqN.js.map
1368
+ //# debugId=a7bdc680-a242-51c3-8856-40f8e88e760e