syncorejs 0.2.3 → 0.2.5

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 (94) hide show
  1. package/dist/_dashboard/assets/ConfirmActionDialog-Db4VzVp6.js +1 -0
  2. package/dist/_dashboard/assets/circle-x-VsB4Z8W4.js +1 -0
  3. package/dist/_dashboard/assets/data.lazy-DjdU9CzX.js +18 -0
  4. package/dist/_dashboard/assets/file-code-BrOKjG4n.js +1 -0
  5. package/dist/_dashboard/assets/functions.lazy-DvDwAGHq.js +1 -0
  6. package/dist/_dashboard/assets/funnel-BH8EMMJI.js +1 -0
  7. package/dist/_dashboard/assets/index-DT9ZEELb.css +1 -0
  8. package/dist/_dashboard/assets/index-DrSG4qZZ.js +54 -0
  9. package/dist/_dashboard/assets/loader-circle-CmJFSYga.js +1 -0
  10. package/dist/_dashboard/assets/logs.lazy-50KTk5yd.js +1 -0
  11. package/dist/_dashboard/assets/play-DS52VsLN.js +1 -0
  12. package/dist/_dashboard/assets/queries.lazy-CfysRWkz.js +1 -0
  13. package/dist/_dashboard/assets/scheduler.lazy-BB88mZk-.js +1 -0
  14. package/dist/_dashboard/assets/select-THYcR8Wt.js +1 -0
  15. package/dist/_dashboard/assets/separator-BU7xg615.js +1 -0
  16. package/dist/_dashboard/assets/shared-Bh0wwC2k.js +1 -0
  17. package/dist/_dashboard/assets/sql.lazy-CHtU9Qnt.js +13 -0
  18. package/dist/_dashboard/assets/storage.lazy-CneN7wVU.js +1 -0
  19. package/dist/_dashboard/assets/table-2-CH8JoMXf.js +1 -0
  20. package/dist/_dashboard/index.html +18 -0
  21. package/dist/_vendor/cli/app.d.mts.map +1 -1
  22. package/dist/_vendor/cli/app.mjs +16 -5
  23. package/dist/_vendor/cli/app.mjs.map +1 -1
  24. package/dist/_vendor/core/cli.d.mts.map +1 -1
  25. package/dist/_vendor/core/cli.mjs +358 -16
  26. package/dist/_vendor/core/cli.mjs.map +1 -1
  27. package/dist/_vendor/core/index.d.mts +3 -3
  28. package/dist/_vendor/core/runtime/devtools.d.mts.map +1 -1
  29. package/dist/_vendor/core/runtime/devtools.mjs +131 -0
  30. package/dist/_vendor/core/runtime/devtools.mjs.map +1 -1
  31. package/dist/_vendor/core/runtime/functions.d.mts +3 -3
  32. package/dist/_vendor/core/runtime/functions.mjs.map +1 -1
  33. package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs +1 -1
  34. package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs.map +1 -1
  35. package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +4 -1
  36. package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -1
  37. package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +6 -3
  38. package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -1
  39. package/dist/_vendor/core/runtime/internal/engines/shared.mjs +5 -1
  40. package/dist/_vendor/core/runtime/internal/engines/shared.mjs.map +1 -1
  41. package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs +99 -13
  42. package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs.map +1 -1
  43. package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs +38 -4
  44. package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs.map +1 -1
  45. package/dist/_vendor/core/runtime/runtime.d.mts +65 -8
  46. package/dist/_vendor/core/runtime/runtime.d.mts.map +1 -1
  47. package/dist/_vendor/core/runtime/runtime.mjs.map +1 -1
  48. package/dist/_vendor/core/transport.d.mts.map +1 -1
  49. package/dist/_vendor/core/transport.mjs +30 -5
  50. package/dist/_vendor/core/transport.mjs.map +1 -1
  51. package/dist/_vendor/devtools-protocol/index.d.ts +75 -1
  52. package/dist/_vendor/devtools-protocol/index.d.ts.map +1 -1
  53. package/dist/_vendor/devtools-protocol/index.js.map +1 -1
  54. package/dist/_vendor/next/index.js +9 -1
  55. package/dist/_vendor/next/index.js.map +1 -1
  56. package/dist/_vendor/platform-expo/index.d.ts +1 -1
  57. package/dist/_vendor/platform-expo/index.d.ts.map +1 -1
  58. package/dist/_vendor/platform-expo/index.js +6 -1
  59. package/dist/_vendor/platform-expo/index.js.map +1 -1
  60. package/dist/_vendor/platform-node/index.d.mts +2 -1
  61. package/dist/_vendor/platform-node/index.d.mts.map +1 -1
  62. package/dist/_vendor/platform-node/index.mjs +27 -2
  63. package/dist/_vendor/platform-node/index.mjs.map +1 -1
  64. package/dist/_vendor/platform-node/ipc-react.mjs +4 -0
  65. package/dist/_vendor/platform-node/ipc-react.mjs.map +1 -1
  66. package/dist/_vendor/platform-web/external-change.d.ts +2 -2
  67. package/dist/_vendor/platform-web/external-change.js +2 -2
  68. package/dist/_vendor/platform-web/external-change.js.map +1 -1
  69. package/dist/_vendor/platform-web/index.d.ts +13 -10
  70. package/dist/_vendor/platform-web/index.d.ts.map +1 -1
  71. package/dist/_vendor/platform-web/index.js +66 -10
  72. package/dist/_vendor/platform-web/index.js.map +1 -1
  73. package/dist/_vendor/platform-web/indexeddb.d.ts +3 -3
  74. package/dist/_vendor/platform-web/indexeddb.js +3 -3
  75. package/dist/_vendor/platform-web/indexeddb.js.map +1 -1
  76. package/dist/_vendor/platform-web/opfs.d.ts +3 -1
  77. package/dist/_vendor/platform-web/opfs.d.ts.map +1 -1
  78. package/dist/_vendor/platform-web/opfs.js +29 -3
  79. package/dist/_vendor/platform-web/opfs.js.map +1 -1
  80. package/dist/_vendor/platform-web/persistence.d.ts +31 -1
  81. package/dist/_vendor/platform-web/persistence.d.ts.map +1 -1
  82. package/dist/_vendor/platform-web/persistence.js.map +1 -1
  83. package/dist/_vendor/platform-web/react.d.ts.map +1 -1
  84. package/dist/_vendor/platform-web/react.js +9 -1
  85. package/dist/_vendor/platform-web/react.js.map +1 -1
  86. package/dist/_vendor/react/index.d.ts +6 -5
  87. package/dist/_vendor/react/index.d.ts.map +1 -1
  88. package/dist/_vendor/react/index.js +6 -5
  89. package/dist/_vendor/react/index.js.map +1 -1
  90. package/dist/_vendor/svelte/index.d.ts +8 -6
  91. package/dist/_vendor/svelte/index.d.ts.map +1 -1
  92. package/dist/_vendor/svelte/index.js +7 -5
  93. package/dist/_vendor/svelte/index.js.map +1 -1
  94. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { CreateWebPersistenceOptions, StoredWebFile, SyncoreWebPersistence, WebPersistenceMode, createWebPersistence, isOpfsAvailable } from "./persistence.js";
1
+ import { CreateWebPersistenceOptions, StoredWebFile, StoredWebFileMetadata, StoredWebFileRange, SyncoreWebPersistence, WebPersistenceMode, createWebPersistence, isOpfsAvailable } from "./persistence.js";
2
2
  import { BroadcastChannelExternalChangeSignal, BroadcastChannelExternalChangeSignalOptions, SqlJsExternalChangeApplier, SqlJsExternalChangeApplierOptions, createDefaultSyncChannelName } from "./external-change.js";
3
3
  import { AttachWebWorkerRuntimeOptions, AttachedWebWorkerRuntime, CreateWebWorkerClientProviderOptions, ManagedWebWorkerClient, SyncoreWebWorkerClient, SyncoreWorkerMessageEndpoint, WebWorkerSyncoreSchema, WorkerQueryWatch, attachWebWorkerRuntime, createManagedWebWorkerClient, createSyncoreWebWorkerClient, createWebWorkerClient } from "./worker.js";
4
4
  import { IndexedDbPersistenceOptions, SyncoreIndexedDbPersistence } from "./indexeddb.js";
@@ -66,7 +66,8 @@ interface CreateWebRuntimeOptions<TSchema extends WebSyncoreSchema = WebSyncoreS
66
66
  driver?: SyncoreRuntimeOptions<TSchema>["driver"];
67
67
  /**
68
68
  * Custom blob storage adapter. Defaults to `BrowserFileStorageAdapter`
69
- * backed by the same persistence layer as the SQL driver.
69
+ * only when the resolved persistence layer is OPFS. IndexedDB persistence is
70
+ * data-only unless a custom adapter is provided explicitly.
70
71
  *
71
72
  * Override when you want to store files in a different location (e.g. an
72
73
  * in-memory adapter for tests).
@@ -203,8 +204,8 @@ interface WebExternalChangeSupport {
203
204
  * Create a full Syncore runtime directly in the browser (main thread or
204
205
  * shared worker).
205
206
  *
206
- * This function sets up SQL.js, the OPFS/IndexedDB persistence layer, blob
207
- * storage, cross-tab change synchronisation via `BroadcastChannel`, and
207
+ * This function sets up SQL.js, the OPFS/IndexedDB persistence layer,
208
+ * OPFS-backed blob storage when available, cross-tab change synchronisation via `BroadcastChannel`, and
208
209
  * auto-connects to the devtools server in development.
209
210
  *
210
211
  * @remarks
@@ -243,7 +244,7 @@ declare function createWebExternalChangeSupport(options: {
243
244
  *
244
245
  * Behaves identically to {@link createWebExternalChangeSupport} but accepts
245
246
  * the same options shape used by `createExpoSyncoreRuntime`, making it easy
246
- * to share config when bootstrapping an Expo web runtime.\
247
+ * to share config when bootstrapping an Expo web runtime.
247
248
  *
248
249
  * Called internally by the Expo platform adapter. Use directly only when
249
250
  * constructing the runtime outside of `createExpoSyncoreRuntime`.
@@ -348,7 +349,7 @@ interface BrowserWebSocketDevtoolsSinkOptions {
348
349
  capabilities?: SyncoreDevtoolsCapabilities;
349
350
  }
350
351
  /**
351
- * A {@link DevtoolsSink} that forwards runtime events to the Syncore devtools
352
+ * A DevtoolsSink that forwards runtime events to the Syncore devtools
352
353
  * dashboard over a persistent WebSocket connection with auto-reconnect.
353
354
  *
354
355
  * Returned by {@link createBrowserWebSocketDevtoolsSink}. You typically do not
@@ -389,8 +390,8 @@ declare function createBrowserWebSocketDevtoolsSink(options: BrowserWebSocketDev
389
390
  /**
390
391
  * Browser file/blob storage adapter backed by `SyncoreWebPersistence`.
391
392
  *
392
- * Stores binary blobs (images, documents, etc.) in the same OPFS or
393
- * IndexedDB store as the SQLite database. Pass an instance to
393
+ * Stores binary blobs (images, documents, etc.) in OPFS alongside the SQLite
394
+ * database. Pass an instance to
394
395
  * `CreateWebRuntimeOptions.storage` to enable Syncore's Storage API
395
396
  * (`ctx.storage.put`, `ctx.storage.get`, etc.) in browser functions.
396
397
  *
@@ -398,7 +399,7 @@ declare function createBrowserWebSocketDevtoolsSink(options: BrowserWebSocketDev
398
399
  * const runtime = await createWebSyncoreRuntime({
399
400
  * schema,
400
401
  * functions,
401
- * storage: (persistence) => new BrowserFileStorageAdapter(persistence, "files"),
402
+ * storage: new BrowserFileStorageAdapter(persistence, "files"),
402
403
  * });
403
404
  * ```
404
405
  */
@@ -409,9 +410,11 @@ declare class BrowserFileStorageAdapter implements SyncoreStorageAdapter {
409
410
  put(id: string, input: StorageWriteInput): Promise<StorageObject>;
410
411
  get(id: string): Promise<StorageObject | null>;
411
412
  read(id: string): Promise<Uint8Array | null>;
413
+ supportsRange(): boolean;
414
+ readRange(id: string, offset: number, length: number): Promise<Uint8Array | null>;
412
415
  delete(id: string): Promise<void>;
413
416
  list(): Promise<StorageObject[]>;
414
417
  }
415
418
  //#endregion
416
- export { AttachWebWorkerRuntimeOptions, AttachedWebWorkerRuntime, BroadcastChannelExternalChangeSignal, BroadcastChannelExternalChangeSignalOptions, BrowserFileStorageAdapter, BrowserSyncoreSchema, BrowserWebSocketDevtoolsSink, BrowserWebSocketDevtoolsSinkOptions, CreateBrowserRuntimeOptions, CreateBrowserWorkerRuntimeOptions, CreateWebPersistenceOptions, CreateWebRuntimeOptions, CreateWebWorkerClientProviderOptions, CreateWebWorkerRuntimeOptions, IndexedDbPersistenceOptions, ManagedWebWorkerClient, OpfsPersistenceOptions, SqlJsExternalChangeApplier, SqlJsExternalChangeApplierOptions, StoredWebFile, SyncoreIndexedDbPersistence, SyncoreOpfsPersistence, SyncoreWebPersistence, SyncoreWebWorkerClient, SyncoreWorkerMessageEndpoint, WebExternalChangeSupport, WebPersistenceMode, WebSyncoreSchema, WebWorkerSyncoreSchema, WorkerQueryWatch, attachWebWorkerRuntime, createBrowserSyncoreClient, createBrowserSyncoreRuntime, createBrowserWebSocketDevtoolsSink, createBrowserWorkerRuntime, createDefaultSyncChannelName, createExpoWebExternalChangeSupport, createManagedWebWorkerClient, createSyncoreWebWorkerClient, createWebExternalChangeSupport, createWebPersistence, createWebSyncoreClient, createWebSyncoreRuntime, createWebWorkerClient, createWebWorkerRuntime, isOpfsAvailable };
419
+ export { AttachWebWorkerRuntimeOptions, AttachedWebWorkerRuntime, BroadcastChannelExternalChangeSignal, BroadcastChannelExternalChangeSignalOptions, BrowserFileStorageAdapter, BrowserSyncoreSchema, BrowserWebSocketDevtoolsSink, BrowserWebSocketDevtoolsSinkOptions, CreateBrowserRuntimeOptions, CreateBrowserWorkerRuntimeOptions, CreateWebPersistenceOptions, CreateWebRuntimeOptions, CreateWebWorkerClientProviderOptions, CreateWebWorkerRuntimeOptions, IndexedDbPersistenceOptions, ManagedWebWorkerClient, OpfsPersistenceOptions, SqlJsExternalChangeApplier, SqlJsExternalChangeApplierOptions, StoredWebFile, StoredWebFileMetadata, StoredWebFileRange, SyncoreIndexedDbPersistence, SyncoreOpfsPersistence, SyncoreWebPersistence, SyncoreWebWorkerClient, SyncoreWorkerMessageEndpoint, WebExternalChangeSupport, WebPersistenceMode, WebSyncoreSchema, WebWorkerSyncoreSchema, WorkerQueryWatch, attachWebWorkerRuntime, createBrowserSyncoreClient, createBrowserSyncoreRuntime, createBrowserWebSocketDevtoolsSink, createBrowserWorkerRuntime, createDefaultSyncChannelName, createExpoWebExternalChangeSupport, createManagedWebWorkerClient, createSyncoreWebWorkerClient, createWebExternalChangeSupport, createWebPersistence, createWebSyncoreClient, createWebSyncoreRuntime, createWebWorkerClient, createWebWorkerRuntime, isOpfsAvailable };
417
420
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;KAoDY,gBAAA,iBACM,gBAAA,GAAmB,gBAAA,IACjC,OAAA;;;;;KAKQ,oBAAA,iBACM,gBAAA,GAAmB,gBAAA,IACjC,gBAAA,CAAiB,OAAA;AAPV;AAKX;;;;;;;;;;;;;;;AAE4B;AAyB5B;;AAhCW,UAgCM,uBAAA,iBACC,gBAAA,GAAmB,gBAAA;EAAnB;EAGhB,MAAA,EAAQ,OAAA;EAAA;;;;EAMR,SAAA,EAAW,qBAAA,CAAsB,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;EAAA,iBAE7B,WAAA;EAAA,iBACA,SAAA;cADA,WAAA,EAAa,qBAAA,EACb,SAAA;EAOb,GAAA,CAAI,EAAA,UAAY,KAAA,EAAO,iBAAA,GAAoB,OAAA,CAAQ,aAAA;EAgBnD,GAAA,CAAI,EAAA,WAAa,OAAA,CAAQ,aAAA;EAazB,IAAA,CAAK,EAAA,WAAa,OAAA,CAAQ,UAAA;EAKhC,aAAA,CAAA;EAIM,SAAA,CACJ,EAAA,UACA,MAAA,UACA,MAAA,WACC,OAAA,CAAQ,UAAA;EAaL,MAAA,CAAO,EAAA,WAAa,OAAA;EAIpB,IAAA,CAAA,GAAQ,OAAA,CAAQ,aAAA;AAAA"}
@@ -14,8 +14,8 @@ const DATA_SOURCE_ALIAS_PREFIX = "data-source-alias";
14
14
  * Create a full Syncore runtime directly in the browser (main thread or
15
15
  * shared worker).
16
16
  *
17
- * This function sets up SQL.js, the OPFS/IndexedDB persistence layer, blob
18
- * storage, cross-tab change synchronisation via `BroadcastChannel`, and
17
+ * This function sets up SQL.js, the OPFS/IndexedDB persistence layer,
18
+ * OPFS-backed blob storage when available, cross-tab change synchronisation via `BroadcastChannel`, and
19
19
  * auto-connects to the devtools server in development.
20
20
  *
21
21
  * @remarks
@@ -43,7 +43,9 @@ async function createWebSyncoreRuntime(options) {
43
43
  ...wasmUrl ? { wasmUrl } : {},
44
44
  ...options.locateFile ? { locateFile: options.locateFile } : {}
45
45
  });
46
- const storage = options.storage ?? new BrowserFileStorageAdapter(persistence, options.storageNamespace ?? options.databaseName ?? "syncore");
46
+ const storageNamespace = options.storageNamespace ?? options.databaseName ?? "syncore";
47
+ const storage = options.storage ?? (persistence.storageProtocol === "opfs" ? new BrowserFileStorageAdapter(persistence, storageNamespace) : new UnavailableBrowserStorageAdapter(BROWSER_STORAGE_UNAVAILABLE_REASON));
48
+ const runtimeCapabilities = createBrowserRuntimeCapabilities(persistence, storage, Boolean(options.storage));
47
49
  const externalChangeSupport = createWebExternalChangeSupport({
48
50
  databaseName: options.databaseName ?? "syncore",
49
51
  persistence,
@@ -69,7 +71,7 @@ async function createWebSyncoreRuntime(options) {
69
71
  databaseLabel,
70
72
  dataSourceAlias,
71
73
  storageIdentity,
72
- capabilities: createBrowserDevtoolsCapabilities()
74
+ capabilities: createBrowserDevtoolsCapabilities(runtimeCapabilities)
73
75
  };
74
76
  if (appName) sinkOptions.appName = appName;
75
77
  if (origin) sinkOptions.origin = origin;
@@ -94,6 +96,7 @@ async function createWebSyncoreRuntime(options) {
94
96
  ...externalChangeSupport.applier ? { externalChangeApplier: externalChangeSupport.applier } : {},
95
97
  platform: options.platform ?? "browser",
96
98
  ...options.capabilities ? { capabilities: options.capabilities } : {},
99
+ runtimeCapabilities,
97
100
  ...resolvedDevtools ? { devtools: resolvedDevtools } : {},
98
101
  ...options.scheduler ? { scheduler: options.scheduler } : {}
99
102
  });
@@ -151,7 +154,7 @@ function createWebExternalChangeSupport(options) {
151
154
  *
152
155
  * Behaves identically to {@link createWebExternalChangeSupport} but accepts
153
156
  * the same options shape used by `createExpoSyncoreRuntime`, making it easy
154
- * to share config when bootstrapping an Expo web runtime.\
157
+ * to share config when bootstrapping an Expo web runtime.
155
158
  *
156
159
  * Called internally by the Expo platform adapter. Use directly only when
157
160
  * constructing the runtime outside of `createExpoSyncoreRuntime`.
@@ -437,7 +440,22 @@ function withRuntimeSummaryMeta(summary, options) {
437
440
  capabilities: options.capabilities ?? createBrowserDevtoolsCapabilities()
438
441
  };
439
442
  }
440
- function createBrowserDevtoolsCapabilities() {
443
+ function createBrowserRuntimeCapabilities(persistence, storage, hasExplicitStorage) {
444
+ if (!hasExplicitStorage && persistence.storageProtocol !== "opfs") return { storage: {
445
+ available: false,
446
+ reason: BROWSER_STORAGE_UNAVAILABLE_REASON,
447
+ protocol: persistence.storageProtocol,
448
+ supportsRange: false
449
+ } };
450
+ return { storage: {
451
+ available: true,
452
+ protocol: hasExplicitStorage ? "custom" : persistence.storageProtocol,
453
+ ...storage.supportsRange ? { supportsRange: storage.supportsRange() !== false } : {}
454
+ } };
455
+ }
456
+ function createBrowserDevtoolsCapabilities(runtimeCapabilities) {
457
+ const storageCapability = runtimeCapabilities?.storage;
458
+ const storageAvailable = storageCapability?.available !== false;
441
459
  return {
442
460
  sql: {
443
461
  read: false,
@@ -450,6 +468,14 @@ function createBrowserDevtoolsCapabilities() {
450
468
  mutate: true,
451
469
  importExport: true
452
470
  },
471
+ storage: {
472
+ browse: storageAvailable,
473
+ download: storageAvailable,
474
+ readRange: storageCapability?.supportsRange === true,
475
+ delete: storageAvailable,
476
+ maxPreviewBytes: 8e4,
477
+ ...!storageAvailable && storageCapability?.reason ? { reason: storageCapability.reason } : {}
478
+ },
453
479
  scheduler: {
454
480
  read: true,
455
481
  edit: true
@@ -706,14 +732,15 @@ const SESSION_NOUNS = [
706
732
  "Thunder",
707
733
  "Drift"
708
734
  ];
735
+ const BROWSER_STORAGE_UNAVAILABLE_REASON = "Browser file storage requires OPFS. IndexedDB is used for data only.";
709
736
  function generateUniqueSessionName() {
710
737
  return `${SESSION_ADJECTIVES[Math.floor(Math.random() * SESSION_ADJECTIVES.length)]} ${SESSION_NOUNS[Math.floor(Math.random() * SESSION_NOUNS.length)]}`;
711
738
  }
712
739
  /**
713
740
  * Browser file/blob storage adapter backed by `SyncoreWebPersistence`.
714
741
  *
715
- * Stores binary blobs (images, documents, etc.) in the same OPFS or
716
- * IndexedDB store as the SQLite database. Pass an instance to
742
+ * Stores binary blobs (images, documents, etc.) in OPFS alongside the SQLite
743
+ * database. Pass an instance to
717
744
  * `CreateWebRuntimeOptions.storage` to enable Syncore's Storage API
718
745
  * (`ctx.storage.put`, `ctx.storage.get`, etc.) in browser functions.
719
746
  *
@@ -721,7 +748,7 @@ function generateUniqueSessionName() {
721
748
  * const runtime = await createWebSyncoreRuntime({
722
749
  * schema,
723
750
  * functions,
724
- * storage: (persistence) => new BrowserFileStorageAdapter(persistence, "files"),
751
+ * storage: new BrowserFileStorageAdapter(persistence, "files"),
725
752
  * });
726
753
  * ```
727
754
  */
@@ -731,6 +758,7 @@ var BrowserFileStorageAdapter = class {
731
758
  constructor(persistence, namespace) {
732
759
  this.persistence = persistence;
733
760
  this.namespace = namespace;
761
+ if (persistence.storageProtocol !== "opfs") throw new Error(BROWSER_STORAGE_UNAVAILABLE_REASON);
734
762
  }
735
763
  async put(id, input) {
736
764
  const bytes = normalizeBinary(input.data);
@@ -755,11 +783,18 @@ var BrowserFileStorageAdapter = class {
755
783
  async read(id) {
756
784
  return (await this.persistence.getFile(this.namespace, id))?.bytes ?? null;
757
785
  }
786
+ supportsRange() {
787
+ return Boolean(this.persistence.getFileRange);
788
+ }
789
+ async readRange(id, offset, length) {
790
+ if (!this.persistence.getFileRange) return null;
791
+ return (await this.persistence.getFileRange(this.namespace, id, offset, length))?.bytes ?? null;
792
+ }
758
793
  async delete(id) {
759
794
  await this.persistence.deleteFile(this.namespace, id);
760
795
  }
761
796
  async list() {
762
- return (await this.persistence.listFiles(this.namespace)).map((file) => ({
797
+ return (this.persistence.listFileMetadata ? await this.persistence.listFileMetadata(this.namespace) : await this.persistence.listFiles(this.namespace)).map((file) => ({
763
798
  id: file.id,
764
799
  path: `${this.persistence.storageProtocol}://${this.namespace}/${file.id}`,
765
800
  size: file.size,
@@ -767,6 +802,27 @@ var BrowserFileStorageAdapter = class {
767
802
  }));
768
803
  }
769
804
  };
805
+ var UnavailableBrowserStorageAdapter = class {
806
+ reason;
807
+ constructor(reason) {
808
+ this.reason = reason;
809
+ }
810
+ async put() {
811
+ throw new Error(this.reason);
812
+ }
813
+ async get() {
814
+ throw new Error(this.reason);
815
+ }
816
+ async read() {
817
+ throw new Error(this.reason);
818
+ }
819
+ supportsRange() {
820
+ return false;
821
+ }
822
+ async delete() {
823
+ throw new Error(this.reason);
824
+ }
825
+ };
770
826
  function normalizeBinary(data) {
771
827
  if (typeof data === "string") return new TextEncoder().encode(data);
772
828
  if (data instanceof Uint8Array) return data;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["scope"],"sources":["../src/index.ts"],"sourcesContent":["import {\n createDevtoolsCommandHandler,\n createDevtoolsSubscriptionHost,\n type DevtoolsCommandHandler,\n type DevtoolsSink,\n type DevtoolsSubscriptionHost,\n type SyncoreDataModel,\n generateId,\n SyncoreRuntime,\n type SchedulerOptions,\n type SyncoreCapabilities,\n type SyncoreRuntimeOptions,\n type SyncoreStorageAdapter,\n type StorageObject,\n type StorageWriteInput\n} from \"@syncore/core\";\nimport {\n SYNCORE_DEVTOOLS_MAX_SUPPORTED_PROTOCOL_VERSION,\n SYNCORE_DEVTOOLS_MIN_SUPPORTED_PROTOCOL_VERSION,\n SYNCORE_DEVTOOLS_PROTOCOL_VERSION,\n type SyncoreDevtoolsClientMessage,\n type SyncoreDevtoolsCapabilities,\n type SyncoreDevtoolsMessage,\n type SyncoreRuntimeSummary\n} from \"@syncore/devtools-protocol\";\nimport {\n createWebPersistence,\n type SyncoreWebPersistence,\n type WebPersistenceMode\n} from \"./persistence.js\";\nimport {\n BroadcastChannelExternalChangeSignal,\n createDefaultSyncChannelName,\n SqlJsExternalChangeApplier\n} from \"./external-change.js\";\nimport { SqlJsDriver } from \"./sqljs.js\";\nimport {\n attachWebWorkerRuntime,\n type SyncoreWorkerMessageEndpoint\n} from \"./worker.js\";\nexport * from \"./worker.js\";\nexport * from \"./persistence.js\";\nexport * from \"./indexeddb.js\";\nexport * from \"./opfs.js\";\nexport * from \"./external-change.js\";\n\n/**\n * Schema type constraint for web-platform Syncore runtimes.\n *\n * Pass any schema produced by `defineSchema()` where this type is expected.\n * Defaults to the unconstrained `SyncoreDataModel` when omitted.\n */\nexport type WebSyncoreSchema<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> = TSchema;\n/**\n * Alias of {@link WebSyncoreSchema} for the `syncorejs/browser` surface.\n * @see WebSyncoreSchema\n */\nexport type BrowserSyncoreSchema<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> = WebSyncoreSchema<TSchema>;\n\nconst DEVTOOLS_META_NAMESPACE = \"__syncore_devtools_meta__\";\nconst STORAGE_SCOPE_ID_PREFIX = \"storage-scope\";\nconst DATA_SOURCE_ALIAS_PREFIX = \"data-source-alias\";\n\n/**\n * Options for constructing a browser Syncore runtime.\n *\n * Use this when you want to host the full runtime directly in a browser tab or\n * dedicated Web Worker. In most React or Svelte apps you should call\n * `createWebWorkerSyncoreRuntime()` inside a worker file instead, so that\n * SQLite and query execution run off the main thread.\n *\n * At minimum you must supply `schema` and `functions`. Everything else has\n * sensible defaults (OPFS persistence, SQL.js driver, auto-devtools connect).\n *\n * ```ts\n * const runtime = await createWebSyncoreRuntime({\n * schema,\n * functions,\n * databaseName: \"my-app\",\n * });\n * ```\n */\nexport interface CreateWebRuntimeOptions<\n TSchema extends WebSyncoreSchema = WebSyncoreSchema\n> {\n /** The data model that defines the available tables and indexes. */\n schema: TSchema;\n\n /**\n * The registered function map. In practice this is always the `functions`\n * export from `syncore/_generated/functions.ts`.\n */\n functions: SyncoreRuntimeOptions<TSchema>[\"functions\"];\n\n /**\n * Resolved Syncore component instances to mount alongside the root app.\n * Only required when your app installs Syncore component packages.\n */\n components?: SyncoreRuntimeOptions<TSchema>[\"components\"];\n\n /**\n * Platform capabilities injected into `ctx.capabilities` inside function\n * handlers. Use this to expose browser APIs (e.g. `navigator.geolocation`)\n * to your Syncore functions in a portable way.\n */\n capabilities?: SyncoreCapabilities;\n\n /**\n * Custom SQLite driver. Defaults to a `SqlJsDriver` backed by the\n * persistence layer chosen by `persistenceMode` / `persistence`.\n *\n * Override only when you need a non-standard SQLite binding.\n */\n driver?: SyncoreRuntimeOptions<TSchema>[\"driver\"];\n\n /**\n * Custom blob storage adapter. Defaults to `BrowserFileStorageAdapter`\n * backed by the same persistence layer as the SQL driver.\n *\n * Override when you want to store files in a different location (e.g. an\n * in-memory adapter for tests).\n */\n storage?: SyncoreStorageAdapter;\n\n /**\n * An explicit persistence implementation. When provided, `persistenceMode`,\n * `persistenceDatabaseName`, and `opfsRootDirectoryName` are ignored.\n *\n * Most apps should omit this and let Syncore choose the best available mode\n * automatically via `persistenceMode`.\n */\n persistence?: SyncoreWebPersistence;\n\n /**\n * Which browser storage backend Syncore should use when it creates the\n * persistence layer for you.\n *\n * - `\"opfs\"` — Origin Private File System (recommended for modern browsers;\n * supports large databases and true WAL mode).\n * - `\"indexeddb\"` — IndexedDB-backed persistence (wider compatibility).\n *\n * Defaults to the best mode available in the current browser.\n */\n persistenceMode?: WebPersistenceMode;\n\n /**\n * Logical name used to namespace the SQL.js database and local storage keys.\n *\n * Set a stable value (e.g. your app’s slug) so the database persists across\n * page reloads with a predictable name. Defaults to `\"syncore\"`.\n */\n databaseName?: string;\n\n /**\n * IndexedDB database name used to store persistence metadata (e.g. the OPFS\n * scope identifier). Defaults to `databaseName`.\n */\n persistenceDatabaseName?: string;\n\n /**\n * OPFS root directory name for the SQLite database file and blob storage.\n * Defaults to `databaseName` or `\"syncore\"`.\n */\n opfsRootDirectoryName?: string;\n\n /**\n * Namespace prefix for blob storage keys. Defaults to `databaseName` or\n * `\"syncore\"`.\n */\n storageNamespace?: string;\n\n /**\n * Explicit URL for the `sql.js` WebAssembly binary.\n *\n * Syncore resolves the URL automatically in most bundler setups. Override\n * this only if the auto-resolved URL is incorrect (e.g. in a custom CDN\n * deploy or a worker with a different asset base path).\n */\n wasmUrl?: string;\n\n /**\n * Custom file resolver for SQL.js support files (wasm + worker scripts).\n *\n * Takes a filename (e.g. `\"sql-wasm.wasm\"`) and returns the full URL.\n * Equivalent to sql.js’s `locateFile` option. Use `wasmUrl` instead when\n * you only need to override the `.wasm` path.\n */\n locateFile?: (fileName: string) => string;\n\n /**\n * Platform label reported to the devtools dashboard.\n * Defaults to `\"browser\"`.\n */\n platform?: string;\n\n /** Human-readable app name shown in the devtools dashboard header. */\n appName?: string;\n\n /**\n * Explicit devtools WebSocket server URL.\n * Defaults to `ws://127.0.0.1:4311` (the Syncore devtools default port).\n */\n devtoolsUrl?: string;\n\n /**\n * Devtools event sink. Pass `false` to disable devtools entirely\n * (recommended for production builds). Omit to auto-connect to the local\n * devtools server when running in development.\n */\n devtools?: DevtoolsSink | false;\n\n /** Scheduler configuration for background and recurring jobs. */\n scheduler?: SchedulerOptions;\n}\n\n/**\n * Options for hosting a Syncore runtime inside a dedicated browser Worker.\n *\n * Extends {@link CreateWebRuntimeOptions} with the `endpoint` field that wires\n * the runtime to the worker’s message port. Use this inside a worker entry\n * file (`syncore.worker.ts`):\n *\n * ```ts\n * // syncore.worker.ts\n * import { createWebWorkerSyncoreRuntime } from \"syncorejs/browser\";\n * import schema from \"./syncore/schema\";\n * import { functions } from \"./syncore/_generated/functions\";\n *\n * createWebWorkerSyncoreRuntime({\n * schema,\n * functions,\n * endpoint: self as unknown as SyncoreWorkerMessageEndpoint,\n * });\n * ```\n */\nexport interface CreateWebWorkerRuntimeOptions<\n TSchema extends WebSyncoreSchema = WebSyncoreSchema\n> extends CreateWebRuntimeOptions<TSchema> {\n /** The message endpoint exposed by the current worker global. */\n endpoint: SyncoreWorkerMessageEndpoint;\n}\n\n/**\n * Alias of {@link CreateWebRuntimeOptions} for the `syncorejs/browser` surface.\n * @see CreateWebRuntimeOptions\n */\nexport type CreateBrowserRuntimeOptions<\n TSchema extends BrowserSyncoreSchema = BrowserSyncoreSchema\n> = CreateWebRuntimeOptions<TSchema>;\n\n/**\n * Alias of {@link CreateWebWorkerRuntimeOptions} for the `syncorejs/browser` surface.\n * @see CreateWebWorkerRuntimeOptions\n */\nexport type CreateBrowserWorkerRuntimeOptions<\n TSchema extends BrowserSyncoreSchema = BrowserSyncoreSchema\n> = CreateWebWorkerRuntimeOptions<TSchema>;\n\n/**\n * Internal bookkeeping for the browser cross-tab change synchronisation layer.\n *\n * Holds the `BroadcastChannel`-based signal that publishes and receives\n * database-change events between tabs, and optionally an `applier` that\n * reconciles incoming changes into an in-memory SQL.js database.\n *\n * You do not need to use this directly — `createWebSyncoreRuntime` builds it\n * for you from your options. Exposed for advanced setups (e.g. Expo web) that\n * construct the change support layer independently.\n */\nexport interface WebExternalChangeSupport {\n signal: BroadcastChannelExternalChangeSignal;\n applier?: SqlJsExternalChangeApplier;\n}\n\n/**\n * Create a full Syncore runtime directly in the browser (main thread or\n * shared worker).\n *\n * This function sets up SQL.js, the OPFS/IndexedDB persistence layer, blob\n * storage, cross-tab change synchronisation via `BroadcastChannel`, and\n * auto-connects to the devtools server in development.\n *\n * @remarks\n * Most React/Svelte apps should run the runtime inside a `Worker` using\n * `createWebWorkerSyncoreRuntime()` instead, so that SQLite queries don’t\n * block the main thread. Use `createWebSyncoreRuntime` only when a worker is\n * not practical (e.g. in Electron renderer processes or certain test setups).\n *\n * ```ts\n * const runtime = await createWebSyncoreRuntime({ schema, functions });\n * await runtime.start();\n * const client = runtime.createClient();\n * ```\n */\nexport async function createWebSyncoreRuntime<\n TSchema extends WebSyncoreSchema\n>(\n options: CreateWebRuntimeOptions<TSchema>\n): Promise<SyncoreRuntime<TSchema>> {\n const persistence =\n options.persistence ??\n (await createWebPersistence({\n ...(options.persistenceMode ? { mode: options.persistenceMode } : {}),\n ...(options.persistenceDatabaseName\n ? { indexedDbDatabaseName: options.persistenceDatabaseName }\n : {}),\n opfsRootDirectoryName:\n options.opfsRootDirectoryName ?? options.databaseName ?? \"syncore\"\n }));\n const wasmUrl =\n options.wasmUrl ??\n (options.locateFile || !isBrowserLikeRuntime()\n ? undefined\n : await resolveDefaultWebWasmUrl());\n const driver =\n options.driver ??\n (await SqlJsDriver.create({\n databaseName: options.databaseName ?? \"syncore\",\n persistence,\n ...(wasmUrl ? { wasmUrl } : {}),\n ...(options.locateFile ? { locateFile: options.locateFile } : {})\n }));\n const storage =\n options.storage ??\n new BrowserFileStorageAdapter(\n persistence,\n options.storageNamespace ?? options.databaseName ?? \"syncore\"\n );\n const externalChangeSupport = createWebExternalChangeSupport({\n databaseName: options.databaseName ?? \"syncore\",\n persistence,\n driver\n });\n const appName = options.appName ?? resolveWebAppName();\n const origin = resolveWebOrigin();\n const sessionLabel = resolveWebSessionLabel();\n const databaseLabel = options.databaseName ?? \"syncore\";\n const storageScopeId = await resolvePersistedStorageScopeId(\n persistence,\n databaseLabel\n );\n const dataSourceAlias = await resolvePersistedDataSourceAlias(\n persistence,\n databaseLabel\n );\n const storageIdentity = [\n origin ?? \"unknown-origin\",\n persistence.storageProtocol,\n databaseLabel,\n storageScopeId\n ].join(\"::\");\n const autoDevtools =\n options.devtools === undefined && shouldAutoConnectDevtools()\n ? (() => {\n const sinkOptions: BrowserWebSocketDevtoolsSinkOptions = {\n url: options.devtoolsUrl ?? resolveDefaultDevtoolsUrl(),\n targetKind: \"client\",\n storageProtocol: persistence.storageProtocol,\n databaseLabel,\n dataSourceAlias,\n storageIdentity,\n capabilities: createBrowserDevtoolsCapabilities()\n };\n if (appName) {\n sinkOptions.appName = appName;\n }\n if (origin) {\n sinkOptions.origin = origin;\n }\n if (sessionLabel) {\n sinkOptions.sessionLabel = sessionLabel;\n }\n return createBrowserWebSocketDevtoolsSink(sinkOptions);\n })()\n : undefined;\n const resolvedDevtools =\n options.devtools === false ? undefined : (options.devtools ?? autoDevtools);\n\n announceBrowserSession({\n enabled: resolvedDevtools !== undefined,\n sessionLabel,\n appName,\n origin,\n devtoolsUrl:\n options.devtools && typeof options.devtools === \"object\"\n ? undefined\n : options.devtoolsUrl ?? resolveDefaultDevtoolsUrl()\n });\n\n const runtime = new SyncoreRuntime({\n schema: options.schema,\n functions: options.functions,\n ...(options.components ? { components: options.components } : {}),\n driver,\n storage,\n externalChangeSignal: externalChangeSupport.signal,\n ...(externalChangeSupport.applier\n ? { externalChangeApplier: externalChangeSupport.applier }\n : {}),\n platform: options.platform ?? \"browser\",\n ...(options.capabilities ? { capabilities: options.capabilities } : {}),\n ...(resolvedDevtools ? { devtools: resolvedDevtools } : {}),\n ...(options.scheduler ? { scheduler: options.scheduler } : {})\n });\n\n if (isAttachableBrowserDevtoolsSink(resolvedDevtools)) {\n resolvedDevtools.attachRuntime(runtime);\n resolvedDevtools.attachCommandHandler(\n createDevtoolsCommandHandler({\n driver,\n schema: options.schema,\n functions: options.functions,\n admin: runtime.getAdmin()\n })\n );\n resolvedDevtools.attachSubscriptionHost(\n createDevtoolsSubscriptionHost({\n driver,\n schema: options.schema,\n functions: options.functions,\n admin: runtime.getAdmin()\n })\n );\n }\n\n return runtime;\n}\n\nfunction isAttachableBrowserDevtoolsSink(\n sink: DevtoolsSink | undefined\n): sink is BrowserWebSocketDevtoolsSink {\n return (\n !!sink &&\n typeof (sink as BrowserWebSocketDevtoolsSink).attachRuntime === \"function\" &&\n typeof (sink as BrowserWebSocketDevtoolsSink).attachCommandHandler ===\n \"function\" &&\n typeof (sink as BrowserWebSocketDevtoolsSink).attachSubscriptionHost ===\n \"function\"\n );\n}\n\n/**\n * Build a {@link WebExternalChangeSupport} bundle for a given database and\n * persistence layer.\n *\n * Creates a `BroadcastChannel`-based signal so that all tabs sharing the same\n * `databaseName` are notified when a mutation commits. When `driver` is a\n * `SqlJsDriver` (i.e. an in-memory database), an `applier` is also created so\n * the local database can be updated from the latest on-disk snapshot.\n *\n * Called automatically by `createWebSyncoreRuntime`. Exposed for advanced use\n * cases such as the Expo web adapter.\n */\nexport function createWebExternalChangeSupport(options: {\n databaseName: string;\n persistence: SyncoreWebPersistence;\n driver: CreateWebRuntimeOptions<SyncoreDataModel>[\"driver\"] | undefined;\n}): WebExternalChangeSupport {\n const signal = new BroadcastChannelExternalChangeSignal({\n channelName: createDefaultSyncChannelName(options.databaseName)\n });\n const sqlDriver =\n options.driver instanceof SqlJsDriver ? options.driver : undefined;\n\n if (!sqlDriver) {\n return { signal };\n }\n\n return {\n signal,\n applier: new SqlJsExternalChangeApplier({\n databaseName: options.databaseName,\n persistence: options.persistence,\n createDatabase: (bytes) => sqlDriver.createDatabaseFromBytes(bytes),\n replaceDatabase: (database) => {\n sqlDriver.replaceDatabase(database);\n }\n })\n };\n}\n\n/**\n * Build a {@link WebExternalChangeSupport} bundle for an Expo app running on\n * the web platform.\n *\n * Behaves identically to {@link createWebExternalChangeSupport} but accepts\n * the same options shape used by `createExpoSyncoreRuntime`, making it easy\n * to share config when bootstrapping an Expo web runtime.\\\n *\n * Called internally by the Expo platform adapter. Use directly only when\n * constructing the runtime outside of `createExpoSyncoreRuntime`.\n */\nexport async function createExpoWebExternalChangeSupport(options: {\n databaseName: string;\n locateFile?: (fileName: string) => string;\n wasmUrl?: string;\n persistenceDatabaseName?: string;\n opfsRootDirectoryName?: string;\n persistenceMode?: WebPersistenceMode;\n}): Promise<WebExternalChangeSupport> {\n const persistence = await createWebPersistence({\n ...(options.persistenceMode ? { mode: options.persistenceMode } : {}),\n ...(options.persistenceDatabaseName\n ? { indexedDbDatabaseName: options.persistenceDatabaseName }\n : {}),\n opfsRootDirectoryName: options.opfsRootDirectoryName ?? options.databaseName\n });\n const wasmUrl =\n options.wasmUrl ??\n (options.locateFile || !isBrowserLikeRuntime()\n ? undefined\n : await resolveDefaultWebWasmUrl());\n const driver = await SqlJsDriver.create({\n databaseName: options.databaseName,\n persistence,\n ...(wasmUrl ? { wasmUrl } : {}),\n ...(options.locateFile ? { locateFile: options.locateFile } : {})\n });\n\n return createWebExternalChangeSupport({\n databaseName: options.databaseName,\n persistence,\n driver\n });\n}\n\n/**\n * Start a Syncore runtime inside a browser `Worker` and wire it to the\n * worker’s own message endpoint.\n *\n * This is the function you call **inside your worker file** (`syncore.worker.ts`).\n * It creates the full runtime (SQL.js + OPFS + BroadcastChannel) in the worker\n * context and begins listening for messages from the main-thread client.\n *\n * ```ts\n * // syncore.worker.ts\n * import { createWebWorkerRuntime } from \"syncorejs/browser\";\n * import schema from \"./syncore/schema\";\n * import { functions } from \"./syncore/_generated/functions\";\n *\n * void createWebWorkerRuntime({\n * schema,\n * functions,\n * endpoint: self as unknown as SyncoreWorkerMessageEndpoint,\n * });\n * ```\n *\n * On the main thread, connect with `createManagedWebWorkerClient()` or\n * `SyncoreNextProvider` (Next.js).\n */\nexport function createWebWorkerRuntime<\n TSchema extends WebSyncoreSchema\n>(options: CreateWebWorkerRuntimeOptions<TSchema>) {\n return attachWebWorkerRuntime({\n endpoint: options.endpoint,\n createRuntime: () =>\n createWebSyncoreRuntime({\n ...options,\n platform: options.platform ?? \"browser-worker\"\n })\n });\n}\n\n/**\n * Alias of {@link createWebWorkerRuntime} for the `syncorejs/browser` surface.\n * @see createWebWorkerRuntime\n */\nexport function createBrowserWorkerRuntime(\n options: CreateBrowserWorkerRuntimeOptions\n) {\n return createWebWorkerRuntime(options);\n}\n\n/**\n * Create a same-process Syncore client from a started browser runtime.\n *\n * Use this when the runtime lives in the same context as the client (e.g.\n * main-thread runtime in an Electron renderer or a test harness). For\n * worker-based setups use `createManagedWebWorkerClient()` instead, which\n * communicates with the worker over `postMessage`.\n *\n * ```ts\n * const runtime = await createWebSyncoreRuntime({ schema, functions });\n * await runtime.start();\n * const client = createWebSyncoreClient(runtime);\n * ```\n */\nexport function createWebSyncoreClient<\n TSchema extends WebSyncoreSchema\n>(runtime: SyncoreRuntime<TSchema>) {\n return runtime.createClient();\n}\n\n/**\n * Alias of {@link createWebSyncoreRuntime} for the `syncorejs/browser` surface.\n * @see createWebSyncoreRuntime\n */\nexport function createBrowserSyncoreRuntime<\n TSchema extends BrowserSyncoreSchema\n>(options: CreateBrowserRuntimeOptions<TSchema>) {\n return createWebSyncoreRuntime(options);\n}\n\n/**\n * Alias of {@link createWebSyncoreClient} for the `syncorejs/browser` surface.\n * @see createWebSyncoreClient\n */\nexport function createBrowserSyncoreClient<\n TSchema extends BrowserSyncoreSchema\n>(runtime: SyncoreRuntime<TSchema>) {\n return createWebSyncoreClient(runtime);\n}\n\n/**\n * Configuration options for {@link createBrowserWebSocketDevtoolsSink}.\n *\n * All fields except `url` are optional — `createWebSyncoreRuntime` fills them\n * in automatically from the runtime’s own metadata.\n */\nexport interface BrowserWebSocketDevtoolsSinkOptions {\n /** WebSocket URL of the Syncore devtools server, e.g. `\"ws://127.0.0.1:4311\"`. */\n url: string;\n /**\n * How long to wait before attempting a reconnect after the WebSocket closes,\n * in milliseconds. Defaults to `1200`.\n */\n reconnectDelayMs?: number;\n /** Human-readable app name shown in the devtools dashboard header. */\n appName?: string;\n /** Origin label (e.g. `window.location.origin`) shown in the devtools session list. */\n origin?: string;\n /** Session label auto-generated from the tab’s URL path; helps distinguish multiple open tabs. */\n sessionLabel?: string;\n /** Kind of this devtools participant. Always `\"client\"` for browser runtimes. */\n targetKind?: \"client\";\n /** Persistence protocol tag reported to devtools (e.g. `\"opfs\"`, `\"indexeddb\"`). */\n storageProtocol?: string;\n /** Logical database name used to group sessions in the devtools UI. */\n databaseLabel?: string;\n /** Stable alias for the data source, used by devtools for cross-session continuity. */\n dataSourceAlias?: string;\n /**\n * Opaque identity string that uniquely identifies this database across origin\n * + persistence protocol + name, used by devtools for data-source tracking.\n */\n storageIdentity?: string;\n /** Capability flags advertising what devtools features this runtime supports. */\n capabilities?: SyncoreDevtoolsCapabilities;\n}\n\nasync function resolveDefaultWebWasmUrl(): Promise<string | undefined> {\n try {\n const module = await import(\"./web-sqljs-wasm.js\");\n return module.resolveDefaultWebSqlJsWasmUrl();\n } catch (error) {\n if (!isBrowserLikeRuntime()) {\n return undefined;\n }\n throw new Error(\n \"Syncore could not resolve the default sql.js WebAssembly asset. \" +\n \"Pass wasmUrl or locateFile to createWebSyncoreRuntime/createBrowserWorkerRuntime for this bundler.\",\n { cause: error }\n );\n }\n}\n\nfunction isBrowserLikeRuntime(): boolean {\n const scope = globalThis as typeof globalThis & {\n WorkerGlobalScope?: unknown;\n };\n return typeof window !== \"undefined\" || scope.WorkerGlobalScope !== undefined;\n}\n\n/**\n * A {@link DevtoolsSink} that forwards runtime events to the Syncore devtools\n * dashboard over a persistent WebSocket connection with auto-reconnect.\n *\n * Returned by {@link createBrowserWebSocketDevtoolsSink}. You typically do not\n * use this interface directly — `createWebSyncoreRuntime` creates and manages\n * the sink automatically when running in development.\n */\nexport interface BrowserWebSocketDevtoolsSink extends DevtoolsSink {\n /** Attach the runtime so the sink can pull metadata for devtools messages. */\n attachRuntime(runtime: SyncoreRuntime<WebSyncoreSchema>): void;\n /** Attach the command handler that processes devtools RPC commands. */\n attachCommandHandler(handler: DevtoolsCommandHandler): void;\n /** Attach the subscription host for live query streaming. */\n attachSubscriptionHost(host: DevtoolsSubscriptionHost): void;\n /** Close the WebSocket and stop reconnecting. Call on runtime shutdown. */\n dispose(): void;\n}\n\n/**\n * Create a WebSocket-based devtools sink that connects to the Syncore devtools\n * server and forwards runtime events in real time.\n *\n * The sink auto-reconnects if the connection drops (e.g. while the devtools\n * dashboard is restarting) and buffers events that arrive before the socket is\n * open.\n *\n * In most cases you do not need to call this directly — `createWebSyncoreRuntime`\n * creates and attaches the sink automatically when `devtools` is omitted and the\n * page is served from a local/private hostname.\n *\n * ```ts\n * const sink = createBrowserWebSocketDevtoolsSink({\n * url: \"ws://127.0.0.1:4311\",\n * appName: \"My App\",\n * });\n * const runtime = await createWebSyncoreRuntime({ schema, functions, devtools: sink });\n * ```\n */\nexport function createBrowserWebSocketDevtoolsSink(\n options: BrowserWebSocketDevtoolsSinkOptions\n): BrowserWebSocketDevtoolsSink {\n let socket: WebSocket | undefined;\n let disposed = false;\n let connectTimer: ReturnType<typeof setTimeout> | undefined;\n let getSummary: (() => SyncoreRuntimeSummary) | undefined;\n let onCommand: DevtoolsCommandHandler | undefined;\n let subscriptionHost: DevtoolsSubscriptionHost | undefined;\n const pendingMessages: SyncoreDevtoolsMessage[] = [];\n let latestHello:\n | {\n runtimeId: string;\n platform: string;\n }\n | undefined;\n\n const connect = () => {\n if (disposed || typeof WebSocket === \"undefined\") {\n return;\n }\n socket = new WebSocket(options.url);\n socket.onopen = () => {\n if (latestHello) {\n sendNow({\n type: \"hello\",\n protocolVersion: SYNCORE_DEVTOOLS_PROTOCOL_VERSION,\n minSupportedProtocolVersion:\n SYNCORE_DEVTOOLS_MIN_SUPPORTED_PROTOCOL_VERSION,\n maxSupportedProtocolVersion:\n SYNCORE_DEVTOOLS_MAX_SUPPORTED_PROTOCOL_VERSION,\n runtimeId: latestHello.runtimeId,\n platform: latestHello.platform,\n ...(options.appName ? { appName: options.appName } : {}),\n ...(options.origin ? { origin: options.origin } : {}),\n ...(options.sessionLabel\n ? { sessionLabel: options.sessionLabel }\n : {}),\n ...(options.targetKind ? { targetKind: options.targetKind } : {}),\n ...(options.storageProtocol\n ? { storageProtocol: options.storageProtocol }\n : {}),\n ...(options.databaseLabel ? { databaseLabel: options.databaseLabel } : {}),\n ...(options.dataSourceAlias\n ? { dataSourceAlias: options.dataSourceAlias }\n : {}),\n ...(options.storageIdentity\n ? { storageIdentity: options.storageIdentity }\n : {}),\n capabilities: options.capabilities ?? createBrowserDevtoolsCapabilities()\n });\n }\n flushPendingMessages();\n };\n socket.onmessage = (event) => {\n if (typeof event.data !== \"string\") {\n return;\n }\n const message = JSON.parse(event.data) as\n | SyncoreDevtoolsMessage\n | SyncoreDevtoolsClientMessage;\n if (message.type === \"ping\") {\n send({ type: \"pong\" });\n } else if (message.type === \"command\" && onCommand) {\n onCommand(message.payload)\n .then((responsePayload) => {\n const runtimeId =\n latestHello?.runtimeId ?? getSummary?.().runtimeId;\n if (!runtimeId) {\n return;\n }\n send({\n type: \"command.result\",\n commandId: message.commandId,\n runtimeId,\n payload: responsePayload\n });\n })\n .catch((err) => {\n const runtimeId =\n latestHello?.runtimeId ?? getSummary?.().runtimeId;\n if (!runtimeId) {\n return;\n }\n send({\n type: \"command.result\",\n commandId: message.commandId,\n runtimeId,\n payload: {\n kind: \"error\",\n message: err instanceof Error ? err.message : \"Unknown error\"\n }\n });\n });\n } else if (message.type === \"subscribe\" && subscriptionHost) {\n void subscriptionHost.subscribe(\n message.subscriptionId,\n message.payload,\n (payload) => {\n const runtimeId =\n latestHello?.runtimeId ?? getSummary?.().runtimeId;\n if (!runtimeId) {\n return;\n }\n send({\n type: \"subscription.data\",\n subscriptionId: message.subscriptionId,\n runtimeId,\n payload\n });\n }\n );\n } else if (message.type === \"unsubscribe\") {\n subscriptionHost?.unsubscribe(message.subscriptionId);\n }\n };\n socket.onclose = scheduleReconnect;\n socket.onerror = () => {\n socket?.close();\n };\n };\n\n const scheduleReconnect = () => {\n if (disposed || connectTimer) {\n return;\n }\n connectTimer = setTimeout(() => {\n connectTimer = undefined;\n connect();\n }, options.reconnectDelayMs ?? 1200);\n };\n\n const sendNow = (message: SyncoreDevtoolsMessage) => {\n if (socket?.readyState === WebSocket.OPEN) {\n socket.send(JSON.stringify(message));\n }\n };\n\n const flushPendingMessages = () => {\n while (pendingMessages.length > 0) {\n const nextMessage = pendingMessages.shift();\n if (nextMessage) {\n sendNow(nextMessage);\n }\n }\n };\n\n const send = (message: SyncoreDevtoolsMessage) => {\n if (socket?.readyState === WebSocket.OPEN) {\n sendNow(message);\n return;\n }\n pendingMessages.push(message);\n };\n\n connect();\n\n return {\n emit(event) {\n if (event.type === \"runtime.connected\") {\n latestHello = {\n runtimeId: event.runtimeId,\n platform: event.platform\n };\n send({\n type: \"hello\",\n protocolVersion: SYNCORE_DEVTOOLS_PROTOCOL_VERSION,\n minSupportedProtocolVersion:\n SYNCORE_DEVTOOLS_MIN_SUPPORTED_PROTOCOL_VERSION,\n maxSupportedProtocolVersion:\n SYNCORE_DEVTOOLS_MAX_SUPPORTED_PROTOCOL_VERSION,\n runtimeId: event.runtimeId,\n platform: event.platform,\n ...(options.appName ? { appName: options.appName } : {}),\n ...(options.origin ? { origin: options.origin } : {}),\n ...(options.sessionLabel\n ? { sessionLabel: options.sessionLabel }\n : {}),\n ...(options.targetKind ? { targetKind: options.targetKind } : {}),\n ...(options.storageProtocol\n ? { storageProtocol: options.storageProtocol }\n : {}),\n ...(options.databaseLabel ? { databaseLabel: options.databaseLabel } : {}),\n ...(options.dataSourceAlias\n ? { dataSourceAlias: options.dataSourceAlias }\n : {}),\n ...(options.storageIdentity\n ? { storageIdentity: options.storageIdentity }\n : {}),\n capabilities: options.capabilities ?? createBrowserDevtoolsCapabilities()\n });\n }\n send({ type: \"event\", event });\n },\n attachRuntime(runtime) {\n getSummary = () =>\n withRuntimeSummaryMeta(runtime.getAdmin().getRuntimeSummary(), options);\n },\n attachCommandHandler(handler) {\n onCommand = handler;\n },\n attachSubscriptionHost(host) {\n subscriptionHost = host;\n },\n dispose() {\n disposed = true;\n if (connectTimer) {\n clearTimeout(connectTimer);\n }\n subscriptionHost?.dispose();\n socket?.close();\n }\n };\n}\n\nfunction withRuntimeSummaryMeta(\n summary: SyncoreRuntimeSummary,\n options: BrowserWebSocketDevtoolsSinkOptions\n): SyncoreRuntimeSummary {\n return {\n ...summary,\n ...(options.appName ? { appName: options.appName } : {}),\n ...(options.origin ? { origin: options.origin } : {}),\n ...(options.sessionLabel ? { sessionLabel: options.sessionLabel } : {}),\n ...(options.targetKind ? { targetKind: options.targetKind } : {}),\n ...(options.storageProtocol\n ? { storageProtocol: options.storageProtocol }\n : {}),\n ...(options.databaseLabel ? { databaseLabel: options.databaseLabel } : {}),\n ...(options.dataSourceAlias ? { dataSourceAlias: options.dataSourceAlias } : {}),\n ...(options.storageIdentity\n ? { storageIdentity: options.storageIdentity }\n : {}),\n capabilities: options.capabilities ?? createBrowserDevtoolsCapabilities()\n };\n}\n\nfunction createBrowserDevtoolsCapabilities(): SyncoreDevtoolsCapabilities {\n return {\n sql: {\n read: false,\n write: false,\n live: false,\n reason: \"SQL Console is not available for browser runtimes.\"\n },\n data: {\n browse: true,\n mutate: true,\n importExport: true\n },\n scheduler: {\n read: true,\n edit: true\n }\n };\n}\n\nfunction shouldAutoConnectDevtools(): boolean {\n const hostname = resolveWebHostname();\n if (!hostname) {\n return false;\n }\n return (\n hostname === \"localhost\" ||\n isPrivateNetworkHostname(hostname) ||\n hostname.endsWith(\".local\")\n );\n}\n\nfunction resolveDefaultDevtoolsUrl(): string {\n return \"ws://127.0.0.1:4311\";\n}\n\nfunction resolveLocationString(\n key: \"href\" | \"origin\" | \"hostname\"\n): string | undefined {\n try {\n const value = globalThis.location?.[key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveGlobalOrigin(): string | undefined {\n try {\n const value = (globalThis as { origin?: unknown }).origin;\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction parseUrlCandidate(candidate: string | undefined): URL | undefined {\n if (!candidate || candidate === \"null\") {\n return undefined;\n }\n try {\n const parsed = new URL(candidate);\n if (parsed.protocol === \"blob:\" && parsed.pathname.length > 0) {\n try {\n return new URL(parsed.pathname);\n } catch {\n return parsed;\n }\n }\n return parsed;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveWebHostname(): string | undefined {\n const directHostname = resolveLocationString(\"hostname\");\n if (directHostname) {\n return directHostname;\n }\n return (\n parseUrlCandidate(resolveLocationString(\"href\"))?.hostname ||\n parseUrlCandidate(resolveLocationString(\"origin\"))?.hostname ||\n parseUrlCandidate(resolveGlobalOrigin())?.hostname ||\n undefined\n );\n}\n\nfunction isPrivateNetworkHostname(hostname: string): boolean {\n const normalized = hostname.toLowerCase().replace(/^\\[|\\]$/g, \"\");\n if (normalized === \"::1\") {\n return true;\n }\n if (normalized.startsWith(\"fc\") || normalized.startsWith(\"fd\")) {\n return true;\n }\n const match = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.exec(normalized);\n if (!match) {\n return false;\n }\n const octets = match.slice(1).map((part) => Number(part));\n if (octets.some((part) => Number.isNaN(part) || part < 0 || part > 255)) {\n return false;\n }\n const first = octets[0];\n const second = octets[1];\n if (first === undefined || second === undefined) {\n return false;\n }\n return (\n first === 10 ||\n first === 127 ||\n (first === 169 && second === 254) ||\n (first === 172 && second >= 16 && second <= 31) ||\n (first === 192 && second === 168)\n );\n}\n\nfunction resolveWebOrigin(): string | undefined {\n const directOrigin = resolveLocationString(\"origin\");\n if (directOrigin && directOrigin !== \"null\") {\n return directOrigin;\n }\n const parsedOrigin =\n parseUrlCandidate(resolveLocationString(\"href\"))?.origin ||\n parseUrlCandidate(resolveGlobalOrigin())?.origin;\n return parsedOrigin && parsedOrigin !== \"null\" ? parsedOrigin : undefined;\n}\n\nfunction resolveWebAppName(): string | undefined {\n try {\n return resolveWebHostname() ?? globalThis.document?.title ?? undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveWebSessionLabel(): string | undefined {\n try {\n if (typeof navigator === \"undefined\") {\n return undefined;\n }\n\n // Generate or retrieve a persistent unique name for this browser instance.\n // This makes it much easier to identify which browser tab/window you're\n // looking at in the devtools dashboard.\n const STORAGE_KEY = \"syncore-session-name\";\n let uniqueName: string | null = null;\n\n try {\n uniqueName = globalThis.localStorage?.getItem(STORAGE_KEY) ?? null;\n } catch {\n /* localStorage may not be available */\n }\n\n if (!uniqueName) {\n uniqueName = generateUniqueSessionName();\n\n try {\n globalThis.localStorage?.setItem(STORAGE_KEY, uniqueName);\n } catch {\n /* ignore storage errors */\n }\n }\n\n const browser = resolveBrowserName(navigator);\n\n return `${uniqueName} (${browser})`;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveBrowserName(\n nav: Navigator & {\n userAgentData?: {\n brands?: Array<{\n brand: string;\n }>;\n };\n }\n): string {\n const brands = nav.userAgentData?.brands?.map((entry) => entry.brand) ?? [];\n\n if (brands.some((brand) => /microsoft edge/i.test(brand))) {\n return \"Edge\";\n }\n if (brands.some((brand) => /firefox/i.test(brand))) {\n return \"Firefox\";\n }\n if (brands.some((brand) => /opera/i.test(brand))) {\n return \"Opera\";\n }\n if (brands.some((brand) => /chrome|chromium/i.test(brand))) {\n return \"Chrome\";\n }\n if (brands.some((brand) => /safari/i.test(brand))) {\n return \"Safari\";\n }\n\n const userAgent = nav.userAgent;\n if (/Firefox\\//i.test(userAgent)) {\n return \"Firefox\";\n }\n if (/Edg\\//i.test(userAgent)) {\n return \"Edge\";\n }\n if (/OPR\\/|Opera/i.test(userAgent)) {\n return \"Opera\";\n }\n if (/Chrome\\/|CriOS\\//i.test(userAgent)) {\n return \"Chrome\";\n }\n if (/Safari\\//i.test(userAgent)) {\n return \"Safari\";\n }\n return \"Browser\";\n}\n\nasync function resolvePersistedStorageScopeId(\n persistence: SyncoreWebPersistence,\n databaseLabel: string\n): Promise<string> {\n const id = `${STORAGE_SCOPE_ID_PREFIX}:${databaseLabel}`;\n const existing = await persistence.getFile(DEVTOOLS_META_NAMESPACE, id);\n\n if (existing) {\n const value = new TextDecoder().decode(existing.bytes).trim();\n if (value.length > 0) {\n return value;\n }\n }\n\n const nextValue = generateId();\n await persistence.putFile(\n DEVTOOLS_META_NAMESPACE,\n id,\n new TextEncoder().encode(nextValue),\n \"text/plain\"\n );\n return nextValue;\n}\n\nasync function resolvePersistedDataSourceAlias(\n persistence: SyncoreWebPersistence,\n databaseLabel: string\n): Promise<string> {\n const id = `${DATA_SOURCE_ALIAS_PREFIX}:${databaseLabel}`;\n const existing = await persistence.getFile(DEVTOOLS_META_NAMESPACE, id);\n\n if (existing) {\n const value = new TextDecoder().decode(existing.bytes).trim();\n if (value.length > 0) {\n return value;\n }\n }\n\n const nextValue = generateUniqueSessionName();\n await persistence.putFile(\n DEVTOOLS_META_NAMESPACE,\n id,\n new TextEncoder().encode(nextValue),\n \"text/plain\"\n );\n return nextValue;\n}\n\nfunction announceBrowserSession(options: {\n enabled: boolean;\n sessionLabel?: string | undefined;\n appName?: string | undefined;\n origin?: string | undefined;\n devtoolsUrl?: string | undefined;\n}): void {\n if (!options.enabled || !options.sessionLabel) {\n return;\n }\n\n const announcedSessions = getAnnouncedBrowserSessions();\n if (announcedSessions.has(options.sessionLabel)) {\n return;\n }\n announcedSessions.add(options.sessionLabel);\n\n try {\n const details = [\n options.appName ? `app=${options.appName}` : undefined,\n options.origin ? `origin=${options.origin}` : undefined,\n options.devtoolsUrl ? `devtools=${options.devtoolsUrl}` : undefined\n ].filter((value): value is string => value !== undefined);\n\n console.info(\n `[syncore] Browser session: ${options.sessionLabel}${details.length > 0 ? ` (${details.join(\", \")})` : \"\"}`\n );\n } catch {\n /* ignore console failures */\n }\n}\n\nfunction getAnnouncedBrowserSessions(): Set<string> {\n const key = \"__syncoreAnnouncedBrowserSessions\";\n const scope = globalThis as typeof globalThis & {\n [key]?: Set<string>;\n };\n if (!scope[key]) {\n scope[key] = new Set<string>();\n }\n return scope[key];\n}\n\n/* ------------------------------------------------------------------ */\n/* Unique session name generator */\n/* ------------------------------------------------------------------ */\n\nconst SESSION_ADJECTIVES = [\n \"Acrobatic\",\n \"Bold\",\n \"Cosmic\",\n \"Daring\",\n \"Electric\",\n \"Fierce\",\n \"Golden\",\n \"Hidden\",\n \"Iron\",\n \"Jade\",\n \"Keen\",\n \"Lunar\",\n \"Mystic\",\n \"Noble\",\n \"Orbital\",\n \"Primal\",\n \"Quick\",\n \"Radiant\",\n \"Shadow\",\n \"Turbo\",\n \"Ultra\",\n \"Vivid\",\n \"Wicked\",\n \"Xenon\",\n \"Zen\",\n \"Arctic\",\n \"Binary\",\n \"Cyber\",\n \"Digital\",\n \"Ember\",\n \"Frozen\",\n \"Galactic\",\n \"Hyper\",\n \"Infra\",\n \"Jumbo\",\n \"Kinetic\",\n \"Liquid\",\n \"Magnetic\",\n \"Neon\",\n \"Onyx\",\n \"Phantom\",\n \"Quantum\",\n \"Rapid\",\n \"Sonic\",\n \"Titan\",\n \"Velvet\",\n \"Wild\",\n \"Blazing\",\n \"Crystal\",\n \"Dynamic\"\n] as const;\n\nconst SESSION_NOUNS = [\n \"Monkey\",\n \"Phoenix\",\n \"Tiger\",\n \"Dragon\",\n \"Falcon\",\n \"Panther\",\n \"Wolf\",\n \"Eagle\",\n \"Cobra\",\n \"Shark\",\n \"Raven\",\n \"Fox\",\n \"Lynx\",\n \"Hawk\",\n \"Bear\",\n \"Jaguar\",\n \"Viper\",\n \"Owl\",\n \"Stallion\",\n \"Dolphin\",\n \"Developer\",\n \"Hacker\",\n \"Wizard\",\n \"Ninja\",\n \"Pilot\",\n \"Pioneer\",\n \"Voyager\",\n \"Explorer\",\n \"Runner\",\n \"Ranger\",\n \"Maverick\",\n \"Spartan\",\n \"Viking\",\n \"Sentinel\",\n \"Guardian\",\n \"Nomad\",\n \"Cipher\",\n \"Vector\",\n \"Matrix\",\n \"Prism\",\n \"Nebula\",\n \"Comet\",\n \"Pulse\",\n \"Vertex\",\n \"Flux\",\n \"Storm\",\n \"Blaze\",\n \"Frost\",\n \"Thunder\",\n \"Drift\"\n] as const;\n\nfunction generateUniqueSessionName(): string {\n const adj =\n SESSION_ADJECTIVES[Math.floor(Math.random() * SESSION_ADJECTIVES.length)]!;\n const noun = SESSION_NOUNS[Math.floor(Math.random() * SESSION_NOUNS.length)]!;\n return `${adj} ${noun}`;\n}\n\n/**\n * Browser file/blob storage adapter backed by `SyncoreWebPersistence`.\n *\n * Stores binary blobs (images, documents, etc.) in the same OPFS or\n * IndexedDB store as the SQLite database. Pass an instance to\n * `CreateWebRuntimeOptions.storage` to enable Syncore's Storage API\n * (`ctx.storage.put`, `ctx.storage.get`, etc.) in browser functions.\n *\n * ```ts\n * const runtime = await createWebSyncoreRuntime({\n * schema,\n * functions,\n * storage: (persistence) => new BrowserFileStorageAdapter(persistence, \"files\"),\n * });\n * ```\n */\nexport class BrowserFileStorageAdapter implements SyncoreStorageAdapter {\n constructor(\n private readonly persistence: SyncoreWebPersistence,\n private readonly namespace: string\n ) {}\n\n async put(id: string, input: StorageWriteInput): Promise<StorageObject> {\n const bytes = normalizeBinary(input.data);\n await this.persistence.putFile(\n this.namespace,\n id,\n bytes,\n input.contentType ?? null\n );\n return {\n id,\n path: `${this.persistence.storageProtocol}://${this.namespace}/${id}`,\n size: bytes.byteLength,\n contentType: input.contentType ?? null\n };\n }\n\n async get(id: string): Promise<StorageObject | null> {\n const file = await this.persistence.getFile(this.namespace, id);\n if (!file) {\n return null;\n }\n return {\n id,\n path: `${this.persistence.storageProtocol}://${this.namespace}/${id}`,\n size: file.size,\n contentType: file.contentType\n };\n }\n\n async read(id: string): Promise<Uint8Array | null> {\n const file = await this.persistence.getFile(this.namespace, id);\n return file?.bytes ?? null;\n }\n\n async delete(id: string): Promise<void> {\n await this.persistence.deleteFile(this.namespace, id);\n }\n\n async list(): Promise<StorageObject[]> {\n const files = await this.persistence.listFiles(this.namespace);\n return files.map((file) => ({\n id: file.id,\n path: `${this.persistence.storageProtocol}://${this.namespace}/${file.id}`,\n size: file.size,\n contentType: file.contentType\n }));\n }\n}\n\nfunction normalizeBinary(data: StorageWriteInput[\"data\"]): Uint8Array {\n if (typeof data === \"string\") {\n return new TextEncoder().encode(data);\n }\n if (data instanceof Uint8Array) {\n return data;\n }\n return new Uint8Array(data);\n}\n"],"mappings":";;;;;;;;;AA+DA,MAAM,0BAA0B;AAChC,MAAM,0BAA0B;AAChC,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;AAyOjC,eAAsB,wBAGpB,SACkC;CAClC,MAAM,cACJ,QAAQ,eACP,MAAM,qBAAqB;EAC1B,GAAI,QAAQ,kBAAkB,EAAE,MAAM,QAAQ,gBAAgB,IAAI,CAAC;EACnE,GAAI,QAAQ,0BACR,EAAE,uBAAuB,QAAQ,wBAAwB,IACzD,CAAC;EACL,uBACE,QAAQ,yBAAyB,QAAQ,gBAAgB;CAC7D,CAAC;CACH,MAAM,UACJ,QAAQ,YACP,QAAQ,cAAc,CAAC,qBAAqB,IACzC,KAAA,IACA,MAAM,yBAAyB;CACrC,MAAM,SACJ,QAAQ,UACP,MAAM,YAAY,OAAO;EACxB,cAAc,QAAQ,gBAAgB;EACtC;EACA,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;EAC7B,GAAI,QAAQ,aAAa,EAAE,YAAY,QAAQ,WAAW,IAAI,CAAC;CACjE,CAAC;CACH,MAAM,UACJ,QAAQ,WACR,IAAI,0BACF,aACA,QAAQ,oBAAoB,QAAQ,gBAAgB,SACtD;CACF,MAAM,wBAAwB,+BAA+B;EAC3D,cAAc,QAAQ,gBAAgB;EACtC;EACA;CACF,CAAC;CACD,MAAM,UAAU,QAAQ,WAAW,kBAAkB;CACrD,MAAM,SAAS,iBA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;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,4BAAoC;CAI3C,OAAO,GAFL,mBAAmB,KAAK,MAAM,KAAK,OAAO,IAAI,mBAAmB,MAAM,GAE3D,GADD,cAAc,KAAK,MAAM,KAAK,OAAO,IAAI,cAAc,MAAM;AAE5E;;;;;;;;;;;;;;;;;AAkBA,IAAa,4BAAb,MAAwE;CAEnD;CACA;CAFnB,YACE,aACA,WACA;EAFiB,KAAA,cAAA;EACA,KAAA,YAAA;CAChB;CAEH,MAAM,IAAI,IAAY,OAAkD;EACtE,MAAM,QAAQ,gBAAgB,MAAM,IAAI;EACxC,MAAM,KAAK,YAAY,QACrB,KAAK,WACL,IACA,OACA,MAAM,eAAe,IACvB;EACA,OAAO;GACL;GACA,MAAM,GAAG,KAAK,YAAY,gBAAgB,KAAK,KAAK,UAAU,GAAG;GACjE,MAAM,MAAM;GACZ,aAAa,MAAM,eAAe;EACpC;CACF;CAEA,MAAM,IAAI,IAA2C;EACnD,MAAM,OAAO,MAAM,KAAK,YAAY,QAAQ,KAAK,WAAW,EAAE;EAC9D,IAAI,CAAC,MACH,OAAO;EAET,OAAO;GACL;GACA,MAAM,GAAG,KAAK,YAAY,gBAAgB,KAAK,KAAK,UAAU,GAAG;GACjE,MAAM,KAAK;GACX,aAAa,KAAK;EACpB;CACF;CAEA,MAAM,KAAK,IAAwC;EAEjD,QAAO,MADY,KAAK,YAAY,QAAQ,KAAK,WAAW,EAAE,IACjD,SAAS;CACxB;CAEA,MAAM,OAAO,IAA2B;EACtC,MAAM,KAAK,YAAY,WAAW,KAAK,WAAW,EAAE;CACtD;CAEA,MAAM,OAAiC;EAErC,QAAO,MADa,KAAK,YAAY,UAAU,KAAK,SAAS,GAChD,KAAK,UAAU;GAC1B,IAAI,KAAK;GACT,MAAM,GAAG,KAAK,YAAY,gBAAgB,KAAK,KAAK,UAAU,GAAG,KAAK;GACtE,MAAM,KAAK;GACX,aAAa,KAAK;EACpB,EAAE;CACJ;AACF;AAEA,SAAS,gBAAgB,MAA6C;CACpE,IAAI,OAAO,SAAS,UAClB,OAAO,IAAI,YAAY,EAAE,OAAO,IAAI;CAEtC,IAAI,gBAAgB,YAClB,OAAO;CAET,OAAO,IAAI,WAAW,IAAI;AAC5B"}
1
+ {"version":3,"file":"index.js","names":["scope"],"sources":["../src/index.ts"],"sourcesContent":["import {\n createDevtoolsCommandHandler,\n createDevtoolsSubscriptionHost,\n type DevtoolsCommandHandler,\n type DevtoolsSink,\n type DevtoolsSubscriptionHost,\n type SyncoreDataModel,\n generateId,\n SyncoreRuntime,\n type SchedulerOptions,\n type SyncoreCapabilities,\n type SyncoreRuntimeCapabilities,\n type SyncoreRuntimeOptions,\n type SyncoreStorageAdapter,\n type StorageObject,\n type StorageWriteInput\n} from \"@syncore/core\";\nimport {\n SYNCORE_DEVTOOLS_MAX_SUPPORTED_PROTOCOL_VERSION,\n SYNCORE_DEVTOOLS_MIN_SUPPORTED_PROTOCOL_VERSION,\n SYNCORE_DEVTOOLS_PROTOCOL_VERSION,\n type SyncoreDevtoolsClientMessage,\n type SyncoreDevtoolsCapabilities,\n type SyncoreDevtoolsMessage,\n type SyncoreRuntimeSummary\n} from \"@syncore/devtools-protocol\";\nimport {\n createWebPersistence,\n type SyncoreWebPersistence,\n type WebPersistenceMode\n} from \"./persistence.js\";\nimport {\n BroadcastChannelExternalChangeSignal,\n createDefaultSyncChannelName,\n SqlJsExternalChangeApplier\n} from \"./external-change.js\";\nimport { SqlJsDriver } from \"./sqljs.js\";\nimport {\n attachWebWorkerRuntime,\n type SyncoreWorkerMessageEndpoint\n} from \"./worker.js\";\nexport * from \"./worker.js\";\nexport * from \"./persistence.js\";\nexport * from \"./indexeddb.js\";\nexport * from \"./opfs.js\";\nexport * from \"./external-change.js\";\n\n/**\n * Schema type constraint for web-platform Syncore runtimes.\n *\n * Pass any schema produced by `defineSchema()` where this type is expected.\n * Defaults to the unconstrained `SyncoreDataModel` when omitted.\n */\nexport type WebSyncoreSchema<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> = TSchema;\n/**\n * Alias of {@link WebSyncoreSchema} for the `syncorejs/browser` surface.\n * @see WebSyncoreSchema\n */\nexport type BrowserSyncoreSchema<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> = WebSyncoreSchema<TSchema>;\n\nconst DEVTOOLS_META_NAMESPACE = \"__syncore_devtools_meta__\";\nconst STORAGE_SCOPE_ID_PREFIX = \"storage-scope\";\nconst DATA_SOURCE_ALIAS_PREFIX = \"data-source-alias\";\n\n/**\n * Options for constructing a browser Syncore runtime.\n *\n * Use this when you want to host the full runtime directly in a browser tab or\n * dedicated Web Worker. In most React or Svelte apps you should call\n * `createWebWorkerSyncoreRuntime()` inside a worker file instead, so that\n * SQLite and query execution run off the main thread.\n *\n * At minimum you must supply `schema` and `functions`. Everything else has\n * sensible defaults (OPFS persistence, SQL.js driver, auto-devtools connect).\n *\n * ```ts\n * const runtime = await createWebSyncoreRuntime({\n * schema,\n * functions,\n * databaseName: \"my-app\",\n * });\n * ```\n */\nexport interface CreateWebRuntimeOptions<\n TSchema extends WebSyncoreSchema = WebSyncoreSchema\n> {\n /** The data model that defines the available tables and indexes. */\n schema: TSchema;\n\n /**\n * The registered function map. In practice this is always the `functions`\n * export from `syncore/_generated/functions.ts`.\n */\n functions: SyncoreRuntimeOptions<TSchema>[\"functions\"];\n\n /**\n * Resolved Syncore component instances to mount alongside the root app.\n * Only required when your app installs Syncore component packages.\n */\n components?: SyncoreRuntimeOptions<TSchema>[\"components\"];\n\n /**\n * Platform capabilities injected into `ctx.capabilities` inside function\n * handlers. Use this to expose browser APIs (e.g. `navigator.geolocation`)\n * to your Syncore functions in a portable way.\n */\n capabilities?: SyncoreCapabilities;\n\n /**\n * Custom SQLite driver. Defaults to a `SqlJsDriver` backed by the\n * persistence layer chosen by `persistenceMode` / `persistence`.\n *\n * Override only when you need a non-standard SQLite binding.\n */\n driver?: SyncoreRuntimeOptions<TSchema>[\"driver\"];\n\n /**\n * Custom blob storage adapter. Defaults to `BrowserFileStorageAdapter`\n * only when the resolved persistence layer is OPFS. IndexedDB persistence is\n * data-only unless a custom adapter is provided explicitly.\n *\n * Override when you want to store files in a different location (e.g. an\n * in-memory adapter for tests).\n */\n storage?: SyncoreStorageAdapter;\n\n /**\n * An explicit persistence implementation. When provided, `persistenceMode`,\n * `persistenceDatabaseName`, and `opfsRootDirectoryName` are ignored.\n *\n * Most apps should omit this and let Syncore choose the best available mode\n * automatically via `persistenceMode`.\n */\n persistence?: SyncoreWebPersistence;\n\n /**\n * Which browser storage backend Syncore should use when it creates the\n * persistence layer for you.\n *\n * - `\"opfs\"` — Origin Private File System (recommended for modern browsers;\n * supports large databases and true WAL mode).\n * - `\"indexeddb\"` — IndexedDB-backed persistence (wider compatibility).\n *\n * Defaults to the best mode available in the current browser.\n */\n persistenceMode?: WebPersistenceMode;\n\n /**\n * Logical name used to namespace the SQL.js database and local storage keys.\n *\n * Set a stable value (e.g. your app’s slug) so the database persists across\n * page reloads with a predictable name. Defaults to `\"syncore\"`.\n */\n databaseName?: string;\n\n /**\n * IndexedDB database name used to store persistence metadata (e.g. the OPFS\n * scope identifier). Defaults to `databaseName`.\n */\n persistenceDatabaseName?: string;\n\n /**\n * OPFS root directory name for the SQLite database file and blob storage.\n * Defaults to `databaseName` or `\"syncore\"`.\n */\n opfsRootDirectoryName?: string;\n\n /**\n * Namespace prefix for blob storage keys. Defaults to `databaseName` or\n * `\"syncore\"`.\n */\n storageNamespace?: string;\n\n /**\n * Explicit URL for the `sql.js` WebAssembly binary.\n *\n * Syncore resolves the URL automatically in most bundler setups. Override\n * this only if the auto-resolved URL is incorrect (e.g. in a custom CDN\n * deploy or a worker with a different asset base path).\n */\n wasmUrl?: string;\n\n /**\n * Custom file resolver for SQL.js support files (wasm + worker scripts).\n *\n * Takes a filename (e.g. `\"sql-wasm.wasm\"`) and returns the full URL.\n * Equivalent to sql.js’s `locateFile` option. Use `wasmUrl` instead when\n * you only need to override the `.wasm` path.\n */\n locateFile?: (fileName: string) => string;\n\n /**\n * Platform label reported to the devtools dashboard.\n * Defaults to `\"browser\"`.\n */\n platform?: string;\n\n /** Human-readable app name shown in the devtools dashboard header. */\n appName?: string;\n\n /**\n * Explicit devtools WebSocket server URL.\n * Defaults to `ws://127.0.0.1:4311` (the Syncore devtools default port).\n */\n devtoolsUrl?: string;\n\n /**\n * Devtools event sink. Pass `false` to disable devtools entirely\n * (recommended for production builds). Omit to auto-connect to the local\n * devtools server when running in development.\n */\n devtools?: DevtoolsSink | false;\n\n /** Scheduler configuration for background and recurring jobs. */\n scheduler?: SchedulerOptions;\n}\n\n/**\n * Options for hosting a Syncore runtime inside a dedicated browser Worker.\n *\n * Extends {@link CreateWebRuntimeOptions} with the `endpoint` field that wires\n * the runtime to the worker’s message port. Use this inside a worker entry\n * file (`syncore.worker.ts`):\n *\n * ```ts\n * // syncore.worker.ts\n * import { createWebWorkerSyncoreRuntime } from \"syncorejs/browser\";\n * import schema from \"./syncore/schema\";\n * import { functions } from \"./syncore/_generated/functions\";\n *\n * createWebWorkerSyncoreRuntime({\n * schema,\n * functions,\n * endpoint: self as unknown as SyncoreWorkerMessageEndpoint,\n * });\n * ```\n */\nexport interface CreateWebWorkerRuntimeOptions<\n TSchema extends WebSyncoreSchema = WebSyncoreSchema\n> extends CreateWebRuntimeOptions<TSchema> {\n /** The message endpoint exposed by the current worker global. */\n endpoint: SyncoreWorkerMessageEndpoint;\n}\n\n/**\n * Alias of {@link CreateWebRuntimeOptions} for the `syncorejs/browser` surface.\n * @see CreateWebRuntimeOptions\n */\nexport type CreateBrowserRuntimeOptions<\n TSchema extends BrowserSyncoreSchema = BrowserSyncoreSchema\n> = CreateWebRuntimeOptions<TSchema>;\n\n/**\n * Alias of {@link CreateWebWorkerRuntimeOptions} for the `syncorejs/browser` surface.\n * @see CreateWebWorkerRuntimeOptions\n */\nexport type CreateBrowserWorkerRuntimeOptions<\n TSchema extends BrowserSyncoreSchema = BrowserSyncoreSchema\n> = CreateWebWorkerRuntimeOptions<TSchema>;\n\n/**\n * Internal bookkeeping for the browser cross-tab change synchronisation layer.\n *\n * Holds the `BroadcastChannel`-based signal that publishes and receives\n * database-change events between tabs, and optionally an `applier` that\n * reconciles incoming changes into an in-memory SQL.js database.\n *\n * You do not need to use this directly — `createWebSyncoreRuntime` builds it\n * for you from your options. Exposed for advanced setups (e.g. Expo web) that\n * construct the change support layer independently.\n */\nexport interface WebExternalChangeSupport {\n signal: BroadcastChannelExternalChangeSignal;\n applier?: SqlJsExternalChangeApplier;\n}\n\n/**\n * Create a full Syncore runtime directly in the browser (main thread or\n * shared worker).\n *\n * This function sets up SQL.js, the OPFS/IndexedDB persistence layer,\n * OPFS-backed blob storage when available, cross-tab change synchronisation via `BroadcastChannel`, and\n * auto-connects to the devtools server in development.\n *\n * @remarks\n * Most React/Svelte apps should run the runtime inside a `Worker` using\n * `createWebWorkerSyncoreRuntime()` instead, so that SQLite queries don’t\n * block the main thread. Use `createWebSyncoreRuntime` only when a worker is\n * not practical (e.g. in Electron renderer processes or certain test setups).\n *\n * ```ts\n * const runtime = await createWebSyncoreRuntime({ schema, functions });\n * await runtime.start();\n * const client = runtime.createClient();\n * ```\n */\nexport async function createWebSyncoreRuntime<TSchema extends WebSyncoreSchema>(\n options: CreateWebRuntimeOptions<TSchema>\n): Promise<SyncoreRuntime<TSchema>> {\n const persistence =\n options.persistence ??\n (await createWebPersistence({\n ...(options.persistenceMode ? { mode: options.persistenceMode } : {}),\n ...(options.persistenceDatabaseName\n ? { indexedDbDatabaseName: options.persistenceDatabaseName }\n : {}),\n opfsRootDirectoryName:\n options.opfsRootDirectoryName ?? options.databaseName ?? \"syncore\"\n }));\n const wasmUrl =\n options.wasmUrl ??\n (options.locateFile || !isBrowserLikeRuntime()\n ? undefined\n : await resolveDefaultWebWasmUrl());\n const driver =\n options.driver ??\n (await SqlJsDriver.create({\n databaseName: options.databaseName ?? \"syncore\",\n persistence,\n ...(wasmUrl ? { wasmUrl } : {}),\n ...(options.locateFile ? { locateFile: options.locateFile } : {})\n }));\n const storageNamespace =\n options.storageNamespace ?? options.databaseName ?? \"syncore\";\n const storage =\n options.storage ??\n (persistence.storageProtocol === \"opfs\"\n ? new BrowserFileStorageAdapter(persistence, storageNamespace)\n : new UnavailableBrowserStorageAdapter(\n BROWSER_STORAGE_UNAVAILABLE_REASON\n ));\n const runtimeCapabilities = createBrowserRuntimeCapabilities(\n persistence,\n storage,\n Boolean(options.storage)\n );\n const externalChangeSupport = createWebExternalChangeSupport({\n databaseName: options.databaseName ?? \"syncore\",\n persistence,\n driver\n });\n const appName = options.appName ?? resolveWebAppName();\n const origin = resolveWebOrigin();\n const sessionLabel = resolveWebSessionLabel();\n const databaseLabel = options.databaseName ?? \"syncore\";\n const storageScopeId = await resolvePersistedStorageScopeId(\n persistence,\n databaseLabel\n );\n const dataSourceAlias = await resolvePersistedDataSourceAlias(\n persistence,\n databaseLabel\n );\n const storageIdentity = [\n origin ?? \"unknown-origin\",\n persistence.storageProtocol,\n databaseLabel,\n storageScopeId\n ].join(\"::\");\n const autoDevtools =\n options.devtools === undefined && shouldAutoConnectDevtools()\n ? (() => {\n const sinkOptions: BrowserWebSocketDevtoolsSinkOptions = {\n url: options.devtoolsUrl ?? resolveDefaultDevtoolsUrl(),\n targetKind: \"client\",\n storageProtocol: persistence.storageProtocol,\n databaseLabel,\n dataSourceAlias,\n storageIdentity,\n capabilities: createBrowserDevtoolsCapabilities(runtimeCapabilities)\n };\n if (appName) {\n sinkOptions.appName = appName;\n }\n if (origin) {\n sinkOptions.origin = origin;\n }\n if (sessionLabel) {\n sinkOptions.sessionLabel = sessionLabel;\n }\n return createBrowserWebSocketDevtoolsSink(sinkOptions);\n })()\n : undefined;\n const resolvedDevtools =\n options.devtools === false ? undefined : (options.devtools ?? autoDevtools);\n\n announceBrowserSession({\n enabled: resolvedDevtools !== undefined,\n sessionLabel,\n appName,\n origin,\n devtoolsUrl:\n options.devtools && typeof options.devtools === \"object\"\n ? undefined\n : (options.devtoolsUrl ?? resolveDefaultDevtoolsUrl())\n });\n\n const runtime = new SyncoreRuntime({\n schema: options.schema,\n functions: options.functions,\n ...(options.components ? { components: options.components } : {}),\n driver,\n storage,\n externalChangeSignal: externalChangeSupport.signal,\n ...(externalChangeSupport.applier\n ? { externalChangeApplier: externalChangeSupport.applier }\n : {}),\n platform: options.platform ?? \"browser\",\n ...(options.capabilities ? { capabilities: options.capabilities } : {}),\n runtimeCapabilities,\n ...(resolvedDevtools ? { devtools: resolvedDevtools } : {}),\n ...(options.scheduler ? { scheduler: options.scheduler } : {})\n });\n\n if (isAttachableBrowserDevtoolsSink(resolvedDevtools)) {\n resolvedDevtools.attachRuntime(runtime);\n resolvedDevtools.attachCommandHandler(\n createDevtoolsCommandHandler({\n driver,\n schema: options.schema,\n functions: options.functions,\n admin: runtime.getAdmin()\n })\n );\n resolvedDevtools.attachSubscriptionHost(\n createDevtoolsSubscriptionHost({\n driver,\n schema: options.schema,\n functions: options.functions,\n admin: runtime.getAdmin()\n })\n );\n }\n\n return runtime;\n}\n\nfunction isAttachableBrowserDevtoolsSink(\n sink: DevtoolsSink | undefined\n): sink is BrowserWebSocketDevtoolsSink {\n return (\n !!sink &&\n typeof (sink as BrowserWebSocketDevtoolsSink).attachRuntime ===\n \"function\" &&\n typeof (sink as BrowserWebSocketDevtoolsSink).attachCommandHandler ===\n \"function\" &&\n typeof (sink as BrowserWebSocketDevtoolsSink).attachSubscriptionHost ===\n \"function\"\n );\n}\n\n/**\n * Build a {@link WebExternalChangeSupport} bundle for a given database and\n * persistence layer.\n *\n * Creates a `BroadcastChannel`-based signal so that all tabs sharing the same\n * `databaseName` are notified when a mutation commits. When `driver` is a\n * `SqlJsDriver` (i.e. an in-memory database), an `applier` is also created so\n * the local database can be updated from the latest on-disk snapshot.\n *\n * Called automatically by `createWebSyncoreRuntime`. Exposed for advanced use\n * cases such as the Expo web adapter.\n */\nexport function createWebExternalChangeSupport(options: {\n databaseName: string;\n persistence: SyncoreWebPersistence;\n driver: CreateWebRuntimeOptions<SyncoreDataModel>[\"driver\"] | undefined;\n}): WebExternalChangeSupport {\n const signal = new BroadcastChannelExternalChangeSignal({\n channelName: createDefaultSyncChannelName(options.databaseName)\n });\n const sqlDriver =\n options.driver instanceof SqlJsDriver ? options.driver : undefined;\n\n if (!sqlDriver) {\n return { signal };\n }\n\n return {\n signal,\n applier: new SqlJsExternalChangeApplier({\n databaseName: options.databaseName,\n persistence: options.persistence,\n createDatabase: (bytes) => sqlDriver.createDatabaseFromBytes(bytes),\n replaceDatabase: (database) => {\n sqlDriver.replaceDatabase(database);\n }\n })\n };\n}\n\n/**\n * Build a {@link WebExternalChangeSupport} bundle for an Expo app running on\n * the web platform.\n *\n * Behaves identically to {@link createWebExternalChangeSupport} but accepts\n * the same options shape used by `createExpoSyncoreRuntime`, making it easy\n * to share config when bootstrapping an Expo web runtime.\n *\n * Called internally by the Expo platform adapter. Use directly only when\n * constructing the runtime outside of `createExpoSyncoreRuntime`.\n */\nexport async function createExpoWebExternalChangeSupport(options: {\n databaseName: string;\n locateFile?: (fileName: string) => string;\n wasmUrl?: string;\n persistenceDatabaseName?: string;\n opfsRootDirectoryName?: string;\n persistenceMode?: WebPersistenceMode;\n}): Promise<WebExternalChangeSupport> {\n const persistence = await createWebPersistence({\n ...(options.persistenceMode ? { mode: options.persistenceMode } : {}),\n ...(options.persistenceDatabaseName\n ? { indexedDbDatabaseName: options.persistenceDatabaseName }\n : {}),\n opfsRootDirectoryName: options.opfsRootDirectoryName ?? options.databaseName\n });\n const wasmUrl =\n options.wasmUrl ??\n (options.locateFile || !isBrowserLikeRuntime()\n ? undefined\n : await resolveDefaultWebWasmUrl());\n const driver = await SqlJsDriver.create({\n databaseName: options.databaseName,\n persistence,\n ...(wasmUrl ? { wasmUrl } : {}),\n ...(options.locateFile ? { locateFile: options.locateFile } : {})\n });\n\n return createWebExternalChangeSupport({\n databaseName: options.databaseName,\n persistence,\n driver\n });\n}\n\n/**\n * Start a Syncore runtime inside a browser `Worker` and wire it to the\n * worker’s own message endpoint.\n *\n * This is the function you call **inside your worker file** (`syncore.worker.ts`).\n * It creates the full runtime (SQL.js + OPFS + BroadcastChannel) in the worker\n * context and begins listening for messages from the main-thread client.\n *\n * ```ts\n * // syncore.worker.ts\n * import { createWebWorkerRuntime } from \"syncorejs/browser\";\n * import schema from \"./syncore/schema\";\n * import { functions } from \"./syncore/_generated/functions\";\n *\n * void createWebWorkerRuntime({\n * schema,\n * functions,\n * endpoint: self as unknown as SyncoreWorkerMessageEndpoint,\n * });\n * ```\n *\n * On the main thread, connect with `createManagedWebWorkerClient()` or\n * `SyncoreNextProvider` (Next.js).\n */\nexport function createWebWorkerRuntime<TSchema extends WebSyncoreSchema>(\n options: CreateWebWorkerRuntimeOptions<TSchema>\n) {\n return attachWebWorkerRuntime({\n endpoint: options.endpoint,\n createRuntime: () =>\n createWebSyncoreRuntime({\n ...options,\n platform: options.platform ?? \"browser-worker\"\n })\n });\n}\n\n/**\n * Alias of {@link createWebWorkerRuntime} for the `syncorejs/browser` surface.\n * @see createWebWorkerRuntime\n */\nexport function createBrowserWorkerRuntime(\n options: CreateBrowserWorkerRuntimeOptions\n) {\n return createWebWorkerRuntime(options);\n}\n\n/**\n * Create a same-process Syncore client from a started browser runtime.\n *\n * Use this when the runtime lives in the same context as the client (e.g.\n * main-thread runtime in an Electron renderer or a test harness). For\n * worker-based setups use `createManagedWebWorkerClient()` instead, which\n * communicates with the worker over `postMessage`.\n *\n * ```ts\n * const runtime = await createWebSyncoreRuntime({ schema, functions });\n * await runtime.start();\n * const client = createWebSyncoreClient(runtime);\n * ```\n */\nexport function createWebSyncoreClient<TSchema extends WebSyncoreSchema>(\n runtime: SyncoreRuntime<TSchema>\n) {\n return runtime.createClient();\n}\n\n/**\n * Alias of {@link createWebSyncoreRuntime} for the `syncorejs/browser` surface.\n * @see createWebSyncoreRuntime\n */\nexport function createBrowserSyncoreRuntime<\n TSchema extends BrowserSyncoreSchema\n>(options: CreateBrowserRuntimeOptions<TSchema>) {\n return createWebSyncoreRuntime(options);\n}\n\n/**\n * Alias of {@link createWebSyncoreClient} for the `syncorejs/browser` surface.\n * @see createWebSyncoreClient\n */\nexport function createBrowserSyncoreClient<\n TSchema extends BrowserSyncoreSchema\n>(runtime: SyncoreRuntime<TSchema>) {\n return createWebSyncoreClient(runtime);\n}\n\n/**\n * Configuration options for {@link createBrowserWebSocketDevtoolsSink}.\n *\n * All fields except `url` are optional — `createWebSyncoreRuntime` fills them\n * in automatically from the runtime’s own metadata.\n */\nexport interface BrowserWebSocketDevtoolsSinkOptions {\n /** WebSocket URL of the Syncore devtools server, e.g. `\"ws://127.0.0.1:4311\"`. */\n url: string;\n /**\n * How long to wait before attempting a reconnect after the WebSocket closes,\n * in milliseconds. Defaults to `1200`.\n */\n reconnectDelayMs?: number;\n /** Human-readable app name shown in the devtools dashboard header. */\n appName?: string;\n /** Origin label (e.g. `window.location.origin`) shown in the devtools session list. */\n origin?: string;\n /** Session label auto-generated from the tab’s URL path; helps distinguish multiple open tabs. */\n sessionLabel?: string;\n /** Kind of this devtools participant. Always `\"client\"` for browser runtimes. */\n targetKind?: \"client\";\n /** Persistence protocol tag reported to devtools (e.g. `\"opfs\"`, `\"indexeddb\"`). */\n storageProtocol?: string;\n /** Logical database name used to group sessions in the devtools UI. */\n databaseLabel?: string;\n /** Stable alias for the data source, used by devtools for cross-session continuity. */\n dataSourceAlias?: string;\n /**\n * Opaque identity string that uniquely identifies this database across origin\n * + persistence protocol + name, used by devtools for data-source tracking.\n */\n storageIdentity?: string;\n /** Capability flags advertising what devtools features this runtime supports. */\n capabilities?: SyncoreDevtoolsCapabilities;\n}\n\nasync function resolveDefaultWebWasmUrl(): Promise<string | undefined> {\n try {\n const module = await import(\"./web-sqljs-wasm.js\");\n return module.resolveDefaultWebSqlJsWasmUrl();\n } catch (error) {\n if (!isBrowserLikeRuntime()) {\n return undefined;\n }\n throw new Error(\n \"Syncore could not resolve the default sql.js WebAssembly asset. \" +\n \"Pass wasmUrl or locateFile to createWebSyncoreRuntime/createBrowserWorkerRuntime for this bundler.\",\n { cause: error }\n );\n }\n}\n\nfunction isBrowserLikeRuntime(): boolean {\n const scope = globalThis as typeof globalThis & {\n WorkerGlobalScope?: unknown;\n };\n return typeof window !== \"undefined\" || scope.WorkerGlobalScope !== undefined;\n}\n\n/**\n * A DevtoolsSink that forwards runtime events to the Syncore devtools\n * dashboard over a persistent WebSocket connection with auto-reconnect.\n *\n * Returned by {@link createBrowserWebSocketDevtoolsSink}. You typically do not\n * use this interface directly — `createWebSyncoreRuntime` creates and manages\n * the sink automatically when running in development.\n */\nexport interface BrowserWebSocketDevtoolsSink extends DevtoolsSink {\n /** Attach the runtime so the sink can pull metadata for devtools messages. */\n attachRuntime(runtime: SyncoreRuntime<WebSyncoreSchema>): void;\n /** Attach the command handler that processes devtools RPC commands. */\n attachCommandHandler(handler: DevtoolsCommandHandler): void;\n /** Attach the subscription host for live query streaming. */\n attachSubscriptionHost(host: DevtoolsSubscriptionHost): void;\n /** Close the WebSocket and stop reconnecting. Call on runtime shutdown. */\n dispose(): void;\n}\n\n/**\n * Create a WebSocket-based devtools sink that connects to the Syncore devtools\n * server and forwards runtime events in real time.\n *\n * The sink auto-reconnects if the connection drops (e.g. while the devtools\n * dashboard is restarting) and buffers events that arrive before the socket is\n * open.\n *\n * In most cases you do not need to call this directly — `createWebSyncoreRuntime`\n * creates and attaches the sink automatically when `devtools` is omitted and the\n * page is served from a local/private hostname.\n *\n * ```ts\n * const sink = createBrowserWebSocketDevtoolsSink({\n * url: \"ws://127.0.0.1:4311\",\n * appName: \"My App\",\n * });\n * const runtime = await createWebSyncoreRuntime({ schema, functions, devtools: sink });\n * ```\n */\nexport function createBrowserWebSocketDevtoolsSink(\n options: BrowserWebSocketDevtoolsSinkOptions\n): BrowserWebSocketDevtoolsSink {\n let socket: WebSocket | undefined;\n let disposed = false;\n let connectTimer: ReturnType<typeof setTimeout> | undefined;\n let getSummary: (() => SyncoreRuntimeSummary) | undefined;\n let onCommand: DevtoolsCommandHandler | undefined;\n let subscriptionHost: DevtoolsSubscriptionHost | undefined;\n const pendingMessages: SyncoreDevtoolsMessage[] = [];\n let latestHello:\n | {\n runtimeId: string;\n platform: string;\n }\n | undefined;\n\n const connect = () => {\n if (disposed || typeof WebSocket === \"undefined\") {\n return;\n }\n socket = new WebSocket(options.url);\n socket.onopen = () => {\n if (latestHello) {\n sendNow({\n type: \"hello\",\n protocolVersion: SYNCORE_DEVTOOLS_PROTOCOL_VERSION,\n minSupportedProtocolVersion:\n SYNCORE_DEVTOOLS_MIN_SUPPORTED_PROTOCOL_VERSION,\n maxSupportedProtocolVersion:\n SYNCORE_DEVTOOLS_MAX_SUPPORTED_PROTOCOL_VERSION,\n runtimeId: latestHello.runtimeId,\n platform: latestHello.platform,\n ...(options.appName ? { appName: options.appName } : {}),\n ...(options.origin ? { origin: options.origin } : {}),\n ...(options.sessionLabel\n ? { sessionLabel: options.sessionLabel }\n : {}),\n ...(options.targetKind ? { targetKind: options.targetKind } : {}),\n ...(options.storageProtocol\n ? { storageProtocol: options.storageProtocol }\n : {}),\n ...(options.databaseLabel\n ? { databaseLabel: options.databaseLabel }\n : {}),\n ...(options.dataSourceAlias\n ? { dataSourceAlias: options.dataSourceAlias }\n : {}),\n ...(options.storageIdentity\n ? { storageIdentity: options.storageIdentity }\n : {}),\n capabilities:\n options.capabilities ?? createBrowserDevtoolsCapabilities()\n });\n }\n flushPendingMessages();\n };\n socket.onmessage = (event) => {\n if (typeof event.data !== \"string\") {\n return;\n }\n const message = JSON.parse(event.data) as\n | SyncoreDevtoolsMessage\n | SyncoreDevtoolsClientMessage;\n if (message.type === \"ping\") {\n send({ type: \"pong\" });\n } else if (message.type === \"command\" && onCommand) {\n onCommand(message.payload)\n .then((responsePayload) => {\n const runtimeId =\n latestHello?.runtimeId ?? getSummary?.().runtimeId;\n if (!runtimeId) {\n return;\n }\n send({\n type: \"command.result\",\n commandId: message.commandId,\n runtimeId,\n payload: responsePayload\n });\n })\n .catch((err) => {\n const runtimeId =\n latestHello?.runtimeId ?? getSummary?.().runtimeId;\n if (!runtimeId) {\n return;\n }\n send({\n type: \"command.result\",\n commandId: message.commandId,\n runtimeId,\n payload: {\n kind: \"error\",\n message: err instanceof Error ? err.message : \"Unknown error\"\n }\n });\n });\n } else if (message.type === \"subscribe\" && subscriptionHost) {\n void subscriptionHost.subscribe(\n message.subscriptionId,\n message.payload,\n (payload) => {\n const runtimeId =\n latestHello?.runtimeId ?? getSummary?.().runtimeId;\n if (!runtimeId) {\n return;\n }\n send({\n type: \"subscription.data\",\n subscriptionId: message.subscriptionId,\n runtimeId,\n payload\n });\n }\n );\n } else if (message.type === \"unsubscribe\") {\n subscriptionHost?.unsubscribe(message.subscriptionId);\n }\n };\n socket.onclose = scheduleReconnect;\n socket.onerror = () => {\n socket?.close();\n };\n };\n\n const scheduleReconnect = () => {\n if (disposed || connectTimer) {\n return;\n }\n connectTimer = setTimeout(() => {\n connectTimer = undefined;\n connect();\n }, options.reconnectDelayMs ?? 1200);\n };\n\n const sendNow = (message: SyncoreDevtoolsMessage) => {\n if (socket?.readyState === WebSocket.OPEN) {\n socket.send(JSON.stringify(message));\n }\n };\n\n const flushPendingMessages = () => {\n while (pendingMessages.length > 0) {\n const nextMessage = pendingMessages.shift();\n if (nextMessage) {\n sendNow(nextMessage);\n }\n }\n };\n\n const send = (message: SyncoreDevtoolsMessage) => {\n if (socket?.readyState === WebSocket.OPEN) {\n sendNow(message);\n return;\n }\n pendingMessages.push(message);\n };\n\n connect();\n\n return {\n emit(event) {\n if (event.type === \"runtime.connected\") {\n latestHello = {\n runtimeId: event.runtimeId,\n platform: event.platform\n };\n send({\n type: \"hello\",\n protocolVersion: SYNCORE_DEVTOOLS_PROTOCOL_VERSION,\n minSupportedProtocolVersion:\n SYNCORE_DEVTOOLS_MIN_SUPPORTED_PROTOCOL_VERSION,\n maxSupportedProtocolVersion:\n SYNCORE_DEVTOOLS_MAX_SUPPORTED_PROTOCOL_VERSION,\n runtimeId: event.runtimeId,\n platform: event.platform,\n ...(options.appName ? { appName: options.appName } : {}),\n ...(options.origin ? { origin: options.origin } : {}),\n ...(options.sessionLabel\n ? { sessionLabel: options.sessionLabel }\n : {}),\n ...(options.targetKind ? { targetKind: options.targetKind } : {}),\n ...(options.storageProtocol\n ? { storageProtocol: options.storageProtocol }\n : {}),\n ...(options.databaseLabel\n ? { databaseLabel: options.databaseLabel }\n : {}),\n ...(options.dataSourceAlias\n ? { dataSourceAlias: options.dataSourceAlias }\n : {}),\n ...(options.storageIdentity\n ? { storageIdentity: options.storageIdentity }\n : {}),\n capabilities:\n options.capabilities ?? createBrowserDevtoolsCapabilities()\n });\n }\n send({ type: \"event\", event });\n },\n attachRuntime(runtime) {\n getSummary = () =>\n withRuntimeSummaryMeta(runtime.getAdmin().getRuntimeSummary(), options);\n },\n attachCommandHandler(handler) {\n onCommand = handler;\n },\n attachSubscriptionHost(host) {\n subscriptionHost = host;\n },\n dispose() {\n disposed = true;\n if (connectTimer) {\n clearTimeout(connectTimer);\n }\n subscriptionHost?.dispose();\n socket?.close();\n }\n };\n}\n\nfunction withRuntimeSummaryMeta(\n summary: SyncoreRuntimeSummary,\n options: BrowserWebSocketDevtoolsSinkOptions\n): SyncoreRuntimeSummary {\n return {\n ...summary,\n ...(options.appName ? { appName: options.appName } : {}),\n ...(options.origin ? { origin: options.origin } : {}),\n ...(options.sessionLabel ? { sessionLabel: options.sessionLabel } : {}),\n ...(options.targetKind ? { targetKind: options.targetKind } : {}),\n ...(options.storageProtocol\n ? { storageProtocol: options.storageProtocol }\n : {}),\n ...(options.databaseLabel ? { databaseLabel: options.databaseLabel } : {}),\n ...(options.dataSourceAlias\n ? { dataSourceAlias: options.dataSourceAlias }\n : {}),\n ...(options.storageIdentity\n ? { storageIdentity: options.storageIdentity }\n : {}),\n capabilities: options.capabilities ?? createBrowserDevtoolsCapabilities()\n };\n}\n\nfunction createBrowserRuntimeCapabilities(\n persistence: SyncoreWebPersistence,\n storage: SyncoreStorageAdapter,\n hasExplicitStorage: boolean\n): SyncoreRuntimeCapabilities {\n if (!hasExplicitStorage && persistence.storageProtocol !== \"opfs\") {\n return {\n storage: {\n available: false,\n reason: BROWSER_STORAGE_UNAVAILABLE_REASON,\n protocol: persistence.storageProtocol,\n supportsRange: false\n }\n };\n }\n return {\n storage: {\n available: true,\n protocol: hasExplicitStorage ? \"custom\" : persistence.storageProtocol,\n ...(storage.supportsRange\n ? { supportsRange: storage.supportsRange() !== false }\n : {})\n }\n };\n}\n\nfunction createBrowserDevtoolsCapabilities(\n runtimeCapabilities?: SyncoreRuntimeCapabilities\n): SyncoreDevtoolsCapabilities {\n const storageCapability = runtimeCapabilities?.storage;\n const storageAvailable = storageCapability?.available !== false;\n return {\n sql: {\n read: false,\n write: false,\n live: false,\n reason: \"SQL Console is not available for browser runtimes.\"\n },\n data: {\n browse: true,\n mutate: true,\n importExport: true\n },\n storage: {\n browse: storageAvailable,\n download: storageAvailable,\n readRange: storageCapability?.supportsRange === true,\n delete: storageAvailable,\n maxPreviewBytes: 80_000,\n ...(!storageAvailable && storageCapability?.reason\n ? { reason: storageCapability.reason }\n : {})\n },\n scheduler: {\n read: true,\n edit: true\n }\n };\n}\n\nfunction shouldAutoConnectDevtools(): boolean {\n const hostname = resolveWebHostname();\n if (!hostname) {\n return false;\n }\n return (\n hostname === \"localhost\" ||\n isPrivateNetworkHostname(hostname) ||\n hostname.endsWith(\".local\")\n );\n}\n\nfunction resolveDefaultDevtoolsUrl(): string {\n return \"ws://127.0.0.1:4311\";\n}\n\nfunction resolveLocationString(\n key: \"href\" | \"origin\" | \"hostname\"\n): string | undefined {\n try {\n const value = globalThis.location?.[key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveGlobalOrigin(): string | undefined {\n try {\n const value = (globalThis as { origin?: unknown }).origin;\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction parseUrlCandidate(candidate: string | undefined): URL | undefined {\n if (!candidate || candidate === \"null\") {\n return undefined;\n }\n try {\n const parsed = new URL(candidate);\n if (parsed.protocol === \"blob:\" && parsed.pathname.length > 0) {\n try {\n return new URL(parsed.pathname);\n } catch {\n return parsed;\n }\n }\n return parsed;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveWebHostname(): string | undefined {\n const directHostname = resolveLocationString(\"hostname\");\n if (directHostname) {\n return directHostname;\n }\n return (\n parseUrlCandidate(resolveLocationString(\"href\"))?.hostname ||\n parseUrlCandidate(resolveLocationString(\"origin\"))?.hostname ||\n parseUrlCandidate(resolveGlobalOrigin())?.hostname ||\n undefined\n );\n}\n\nfunction isPrivateNetworkHostname(hostname: string): boolean {\n const normalized = hostname.toLowerCase().replace(/^\\[|\\]$/g, \"\");\n if (normalized === \"::1\") {\n return true;\n }\n if (normalized.startsWith(\"fc\") || normalized.startsWith(\"fd\")) {\n return true;\n }\n const match = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.exec(normalized);\n if (!match) {\n return false;\n }\n const octets = match.slice(1).map((part) => Number(part));\n if (octets.some((part) => Number.isNaN(part) || part < 0 || part > 255)) {\n return false;\n }\n const first = octets[0];\n const second = octets[1];\n if (first === undefined || second === undefined) {\n return false;\n }\n return (\n first === 10 ||\n first === 127 ||\n (first === 169 && second === 254) ||\n (first === 172 && second >= 16 && second <= 31) ||\n (first === 192 && second === 168)\n );\n}\n\nfunction resolveWebOrigin(): string | undefined {\n const directOrigin = resolveLocationString(\"origin\");\n if (directOrigin && directOrigin !== \"null\") {\n return directOrigin;\n }\n const parsedOrigin =\n parseUrlCandidate(resolveLocationString(\"href\"))?.origin ||\n parseUrlCandidate(resolveGlobalOrigin())?.origin;\n return parsedOrigin && parsedOrigin !== \"null\" ? parsedOrigin : undefined;\n}\n\nfunction resolveWebAppName(): string | undefined {\n try {\n return resolveWebHostname() ?? globalThis.document?.title ?? undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveWebSessionLabel(): string | undefined {\n try {\n if (typeof navigator === \"undefined\") {\n return undefined;\n }\n\n // Generate or retrieve a persistent unique name for this browser instance.\n // This makes it much easier to identify which browser tab/window you're\n // looking at in the devtools dashboard.\n const STORAGE_KEY = \"syncore-session-name\";\n let uniqueName: string | null = null;\n\n try {\n uniqueName = globalThis.localStorage?.getItem(STORAGE_KEY) ?? null;\n } catch {\n /* localStorage may not be available */\n }\n\n if (!uniqueName) {\n uniqueName = generateUniqueSessionName();\n\n try {\n globalThis.localStorage?.setItem(STORAGE_KEY, uniqueName);\n } catch {\n /* ignore storage errors */\n }\n }\n\n const browser = resolveBrowserName(navigator);\n\n return `${uniqueName} (${browser})`;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveBrowserName(\n nav: Navigator & {\n userAgentData?: {\n brands?: Array<{\n brand: string;\n }>;\n };\n }\n): string {\n const brands = nav.userAgentData?.brands?.map((entry) => entry.brand) ?? [];\n\n if (brands.some((brand) => /microsoft edge/i.test(brand))) {\n return \"Edge\";\n }\n if (brands.some((brand) => /firefox/i.test(brand))) {\n return \"Firefox\";\n }\n if (brands.some((brand) => /opera/i.test(brand))) {\n return \"Opera\";\n }\n if (brands.some((brand) => /chrome|chromium/i.test(brand))) {\n return \"Chrome\";\n }\n if (brands.some((brand) => /safari/i.test(brand))) {\n return \"Safari\";\n }\n\n const userAgent = nav.userAgent;\n if (/Firefox\\//i.test(userAgent)) {\n return \"Firefox\";\n }\n if (/Edg\\//i.test(userAgent)) {\n return \"Edge\";\n }\n if (/OPR\\/|Opera/i.test(userAgent)) {\n return \"Opera\";\n }\n if (/Chrome\\/|CriOS\\//i.test(userAgent)) {\n return \"Chrome\";\n }\n if (/Safari\\//i.test(userAgent)) {\n return \"Safari\";\n }\n return \"Browser\";\n}\n\nasync function resolvePersistedStorageScopeId(\n persistence: SyncoreWebPersistence,\n databaseLabel: string\n): Promise<string> {\n const id = `${STORAGE_SCOPE_ID_PREFIX}:${databaseLabel}`;\n const existing = await persistence.getFile(DEVTOOLS_META_NAMESPACE, id);\n\n if (existing) {\n const value = new TextDecoder().decode(existing.bytes).trim();\n if (value.length > 0) {\n return value;\n }\n }\n\n const nextValue = generateId();\n await persistence.putFile(\n DEVTOOLS_META_NAMESPACE,\n id,\n new TextEncoder().encode(nextValue),\n \"text/plain\"\n );\n return nextValue;\n}\n\nasync function resolvePersistedDataSourceAlias(\n persistence: SyncoreWebPersistence,\n databaseLabel: string\n): Promise<string> {\n const id = `${DATA_SOURCE_ALIAS_PREFIX}:${databaseLabel}`;\n const existing = await persistence.getFile(DEVTOOLS_META_NAMESPACE, id);\n\n if (existing) {\n const value = new TextDecoder().decode(existing.bytes).trim();\n if (value.length > 0) {\n return value;\n }\n }\n\n const nextValue = generateUniqueSessionName();\n await persistence.putFile(\n DEVTOOLS_META_NAMESPACE,\n id,\n new TextEncoder().encode(nextValue),\n \"text/plain\"\n );\n return nextValue;\n}\n\nfunction announceBrowserSession(options: {\n enabled: boolean;\n sessionLabel?: string | undefined;\n appName?: string | undefined;\n origin?: string | undefined;\n devtoolsUrl?: string | undefined;\n}): void {\n if (!options.enabled || !options.sessionLabel) {\n return;\n }\n\n const announcedSessions = getAnnouncedBrowserSessions();\n if (announcedSessions.has(options.sessionLabel)) {\n return;\n }\n announcedSessions.add(options.sessionLabel);\n\n try {\n const details = [\n options.appName ? `app=${options.appName}` : undefined,\n options.origin ? `origin=${options.origin}` : undefined,\n options.devtoolsUrl ? `devtools=${options.devtoolsUrl}` : undefined\n ].filter((value): value is string => value !== undefined);\n\n console.info(\n `[syncore] Browser session: ${options.sessionLabel}${details.length > 0 ? ` (${details.join(\", \")})` : \"\"}`\n );\n } catch {\n /* ignore console failures */\n }\n}\n\nfunction getAnnouncedBrowserSessions(): Set<string> {\n const key = \"__syncoreAnnouncedBrowserSessions\";\n const scope = globalThis as typeof globalThis & {\n [key]?: Set<string>;\n };\n if (!scope[key]) {\n scope[key] = new Set<string>();\n }\n return scope[key];\n}\n\n/* ------------------------------------------------------------------ */\n/* Unique session name generator */\n/* ------------------------------------------------------------------ */\n\nconst SESSION_ADJECTIVES = [\n \"Acrobatic\",\n \"Bold\",\n \"Cosmic\",\n \"Daring\",\n \"Electric\",\n \"Fierce\",\n \"Golden\",\n \"Hidden\",\n \"Iron\",\n \"Jade\",\n \"Keen\",\n \"Lunar\",\n \"Mystic\",\n \"Noble\",\n \"Orbital\",\n \"Primal\",\n \"Quick\",\n \"Radiant\",\n \"Shadow\",\n \"Turbo\",\n \"Ultra\",\n \"Vivid\",\n \"Wicked\",\n \"Xenon\",\n \"Zen\",\n \"Arctic\",\n \"Binary\",\n \"Cyber\",\n \"Digital\",\n \"Ember\",\n \"Frozen\",\n \"Galactic\",\n \"Hyper\",\n \"Infra\",\n \"Jumbo\",\n \"Kinetic\",\n \"Liquid\",\n \"Magnetic\",\n \"Neon\",\n \"Onyx\",\n \"Phantom\",\n \"Quantum\",\n \"Rapid\",\n \"Sonic\",\n \"Titan\",\n \"Velvet\",\n \"Wild\",\n \"Blazing\",\n \"Crystal\",\n \"Dynamic\"\n] as const;\n\nconst SESSION_NOUNS = [\n \"Monkey\",\n \"Phoenix\",\n \"Tiger\",\n \"Dragon\",\n \"Falcon\",\n \"Panther\",\n \"Wolf\",\n \"Eagle\",\n \"Cobra\",\n \"Shark\",\n \"Raven\",\n \"Fox\",\n \"Lynx\",\n \"Hawk\",\n \"Bear\",\n \"Jaguar\",\n \"Viper\",\n \"Owl\",\n \"Stallion\",\n \"Dolphin\",\n \"Developer\",\n \"Hacker\",\n \"Wizard\",\n \"Ninja\",\n \"Pilot\",\n \"Pioneer\",\n \"Voyager\",\n \"Explorer\",\n \"Runner\",\n \"Ranger\",\n \"Maverick\",\n \"Spartan\",\n \"Viking\",\n \"Sentinel\",\n \"Guardian\",\n \"Nomad\",\n \"Cipher\",\n \"Vector\",\n \"Matrix\",\n \"Prism\",\n \"Nebula\",\n \"Comet\",\n \"Pulse\",\n \"Vertex\",\n \"Flux\",\n \"Storm\",\n \"Blaze\",\n \"Frost\",\n \"Thunder\",\n \"Drift\"\n] as const;\n\nconst BROWSER_STORAGE_UNAVAILABLE_REASON =\n \"Browser file storage requires OPFS. IndexedDB is used for data only.\";\n\nfunction generateUniqueSessionName(): string {\n const adj =\n SESSION_ADJECTIVES[Math.floor(Math.random() * SESSION_ADJECTIVES.length)]!;\n const noun = SESSION_NOUNS[Math.floor(Math.random() * SESSION_NOUNS.length)]!;\n return `${adj} ${noun}`;\n}\n\n/**\n * Browser file/blob storage adapter backed by `SyncoreWebPersistence`.\n *\n * Stores binary blobs (images, documents, etc.) in OPFS alongside the SQLite\n * database. Pass an instance to\n * `CreateWebRuntimeOptions.storage` to enable Syncore's Storage API\n * (`ctx.storage.put`, `ctx.storage.get`, etc.) in browser functions.\n *\n * ```ts\n * const runtime = await createWebSyncoreRuntime({\n * schema,\n * functions,\n * storage: new BrowserFileStorageAdapter(persistence, \"files\"),\n * });\n * ```\n */\nexport class BrowserFileStorageAdapter implements SyncoreStorageAdapter {\n constructor(\n private readonly persistence: SyncoreWebPersistence,\n private readonly namespace: string\n ) {\n if (persistence.storageProtocol !== \"opfs\") {\n throw new Error(BROWSER_STORAGE_UNAVAILABLE_REASON);\n }\n }\n\n async put(id: string, input: StorageWriteInput): Promise<StorageObject> {\n const bytes = normalizeBinary(input.data);\n await this.persistence.putFile(\n this.namespace,\n id,\n bytes,\n input.contentType ?? null\n );\n return {\n id,\n path: `${this.persistence.storageProtocol}://${this.namespace}/${id}`,\n size: bytes.byteLength,\n contentType: input.contentType ?? null\n };\n }\n\n async get(id: string): Promise<StorageObject | null> {\n const file = await this.persistence.getFile(this.namespace, id);\n if (!file) {\n return null;\n }\n return {\n id,\n path: `${this.persistence.storageProtocol}://${this.namespace}/${id}`,\n size: file.size,\n contentType: file.contentType\n };\n }\n\n async read(id: string): Promise<Uint8Array | null> {\n const file = await this.persistence.getFile(this.namespace, id);\n return file?.bytes ?? null;\n }\n\n supportsRange(): boolean {\n return Boolean(this.persistence.getFileRange);\n }\n\n async readRange(\n id: string,\n offset: number,\n length: number\n ): Promise<Uint8Array | null> {\n if (!this.persistence.getFileRange) {\n return null;\n }\n const file = await this.persistence.getFileRange(\n this.namespace,\n id,\n offset,\n length\n );\n return file?.bytes ?? null;\n }\n\n async delete(id: string): Promise<void> {\n await this.persistence.deleteFile(this.namespace, id);\n }\n\n async list(): Promise<StorageObject[]> {\n const files = this.persistence.listFileMetadata\n ? await this.persistence.listFileMetadata(this.namespace)\n : await this.persistence.listFiles(this.namespace);\n return files.map((file) => ({\n id: file.id,\n path: `${this.persistence.storageProtocol}://${this.namespace}/${file.id}`,\n size: file.size,\n contentType: file.contentType\n }));\n }\n}\n\nclass UnavailableBrowserStorageAdapter implements SyncoreStorageAdapter {\n constructor(private readonly reason: string) {}\n\n async put(): Promise<StorageObject> {\n throw new Error(this.reason);\n }\n\n async get(): Promise<StorageObject | null> {\n throw new Error(this.reason);\n }\n\n async read(): Promise<Uint8Array | null> {\n throw new Error(this.reason);\n }\n\n supportsRange(): boolean {\n return false;\n }\n\n async delete(): Promise<void> {\n throw new Error(this.reason);\n }\n}\n\nfunction normalizeBinary(data: StorageWriteInput[\"data\"]): Uint8Array {\n if (typeof data === \"string\") {\n return new TextEncoder().encode(data);\n }\n if (data instanceof Uint8Array) {\n return data;\n }\n return new Uint8Array(data);\n}\n"],"mappings":";;;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QAAQ,KAAK,IAAI,EAAE,KAAK,IACzG;CACF,QAAQ,CAER;AACF;AAEA,SAAS,8BAA2C;CAClD,MAAM,MAAM;CACZ,MAAM,QAAQ;CAGd,IAAI,CAAC,MAAM,MACT,MAAM,uBAAO,IAAI,IAAY;CAE/B,OAAO,MAAM;AACf;AAMA,MAAM,qBAAqB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,qCACJ;AAEF,SAAS,4BAAoC;CAI3C,OAAO,GAFL,mBAAmB,KAAK,MAAM,KAAK,OAAO,IAAI,mBAAmB,MAAM,GAE3D,GADD,cAAc,KAAK,MAAM,KAAK,OAAO,IAAI,cAAc,MAAM;AAE5E;;;;;;;;;;;;;;;;;AAkBA,IAAa,4BAAb,MAAwE;CAEnD;CACA;CAFnB,YACE,aACA,WACA;EAFiB,KAAA,cAAA;EACA,KAAA,YAAA;EAEjB,IAAI,YAAY,oBAAoB,QAClC,MAAM,IAAI,MAAM,kCAAkC;CAEtD;CAEA,MAAM,IAAI,IAAY,OAAkD;EACtE,MAAM,QAAQ,gBAAgB,MAAM,IAAI;EACxC,MAAM,KAAK,YAAY,QACrB,KAAK,WACL,IACA,OACA,MAAM,eAAe,IACvB;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IAAI,MAAM,KAAK,MAAM;CAC7B;CAEA,MAAM,OAAmC;EACvC,MAAM,IAAI,MAAM,KAAK,MAAM;CAC7B;CAEA,gBAAyB;EACvB,OAAO;CACT;CAEA,MAAM,SAAwB;EAC5B,MAAM,IAAI,MAAM,KAAK,MAAM;CAC7B;AACF;AAEA,SAAS,gBAAgB,MAA6C;CACpE,IAAI,OAAO,SAAS,UAClB,OAAO,IAAI,YAAY,EAAE,OAAO,IAAI;CAEtC,IAAI,gBAAgB,YAClB,OAAO;CAET,OAAO,IAAI,WAAW,IAAI;AAC5B"}
@@ -9,9 +9,9 @@ interface IndexedDbPersistenceOptions {
9
9
  /**
10
10
  * IndexedDB-backed {@link SyncoreWebPersistence} implementation.
11
11
  *
12
- * Stores the SQLite database blob and file objects in dedicated IndexedDB
13
- * object stores. Used automatically when OPFS is unavailable or when the
14
- * persistence mode is explicitly set to `"indexeddb"`.
12
+ * Stores the SQLite database blob in IndexedDB. It still satisfies the lower
13
+ * level persistence interface for compatibility, but Syncore's default browser
14
+ * file storage is OPFS-only and will not use IndexedDB for blobs.
15
15
  *
16
16
  * Prefer `createWebPersistence()` over constructing this directly unless
17
17
  * you need to pass a specific IndexedDB database name.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * IndexedDB-backed {@link SyncoreWebPersistence} implementation.
4
4
  *
5
- * Stores the SQLite database blob and file objects in dedicated IndexedDB
6
- * object stores. Used automatically when OPFS is unavailable or when the
7
- * persistence mode is explicitly set to `"indexeddb"`.
5
+ * Stores the SQLite database blob in IndexedDB. It still satisfies the lower
6
+ * level persistence interface for compatibility, but Syncore's default browser
7
+ * file storage is OPFS-only and will not use IndexedDB for blobs.
8
8
  *
9
9
  * Prefer `createWebPersistence()` over constructing this directly unless
10
10
  * you need to pass a specific IndexedDB database name.