@party-stack/runtime 0.3.7 → 0.4.1

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 (57) hide show
  1. package/lib/coordinator/createPersistedCollectionCoordinator.d.ts +4 -2
  2. package/lib/coordinator/createPersistedCollectionCoordinator.d.ts.map +1 -1
  3. package/lib/coordinator/createPersistedCollectionCoordinator.js +492 -280
  4. package/lib/coordinator/createPersistedCollectionCoordinator.js.map +1 -1
  5. package/lib/coordinator/index.d.ts +2 -2
  6. package/lib/coordinator/index.js +2 -2
  7. package/lib/effection/index.d.ts +4 -2
  8. package/lib/effection/index.d.ts.map +1 -1
  9. package/lib/effection/index.js +25 -25
  10. package/lib/effection/index.js.map +1 -1
  11. package/lib/index.d.ts +11 -10
  12. package/lib/index.js +10 -8
  13. package/lib/memory/MemoryBlobBytesStore.d.ts +8 -6
  14. package/lib/memory/MemoryBlobBytesStore.d.ts.map +1 -1
  15. package/lib/memory/MemoryBlobBytesStore.js +22 -20
  16. package/lib/memory/MemoryBlobBytesStore.js.map +1 -1
  17. package/lib/types.d.ts +31 -29
  18. package/lib/types.d.ts.map +1 -1
  19. package/lib/types.js +0 -1
  20. package/lib/utils/BrowserAuthenticationCancelledError.d.ts +3 -1
  21. package/lib/utils/BrowserAuthenticationCancelledError.d.ts.map +1 -1
  22. package/lib/utils/BrowserAuthenticationCancelledError.js +10 -6
  23. package/lib/utils/BrowserAuthenticationCancelledError.js.map +1 -1
  24. package/lib/utils/createCollectionPersistence.d.ts +7 -0
  25. package/lib/utils/createCollectionPersistence.d.ts.map +1 -0
  26. package/lib/utils/createCollectionPersistence.js +24 -0
  27. package/lib/utils/createCollectionPersistence.js.map +1 -0
  28. package/lib/utils/createDefaultRuntime.d.ts +4 -1
  29. package/lib/utils/createDefaultRuntime.d.ts.map +1 -1
  30. package/lib/utils/createDefaultRuntime.js +15 -11
  31. package/lib/utils/createDefaultRuntime.js.map +1 -1
  32. package/lib/utils/createLocalCollection.d.ts +8 -6
  33. package/lib/utils/createLocalCollection.d.ts.map +1 -1
  34. package/lib/utils/createLocalCollection.js +19 -18
  35. package/lib/utils/createLocalCollection.js.map +1 -1
  36. package/lib/utils/defineRuntime.d.ts +3 -2
  37. package/lib/utils/defineRuntime.d.ts.map +1 -1
  38. package/lib/utils/defineRuntime.js +26 -30
  39. package/lib/utils/defineRuntime.js.map +1 -1
  40. package/package.json +12 -18
  41. package/lib/coordinator/index.d.ts.map +0 -1
  42. package/lib/coordinator/index.js.map +0 -1
  43. package/lib/index.d.ts.map +0 -1
  44. package/lib/index.js.map +0 -1
  45. package/lib/memory/MemoryBlobBytesStore.test.d.ts +0 -2
  46. package/lib/memory/MemoryBlobBytesStore.test.d.ts.map +0 -1
  47. package/lib/memory/MemoryBlobBytesStore.test.js +0 -12
  48. package/lib/memory/MemoryBlobBytesStore.test.js.map +0 -1
  49. package/lib/types.js.map +0 -1
  50. package/lib/utils/createLocalCollection.test.d.ts +0 -2
  51. package/lib/utils/createLocalCollection.test.d.ts.map +0 -1
  52. package/lib/utils/createLocalCollection.test.js +0 -237
  53. package/lib/utils/createLocalCollection.test.js.map +0 -1
  54. package/lib/utils/defineRuntime.test.d.ts +0 -2
  55. package/lib/utils/defineRuntime.test.d.ts.map +0 -1
  56. package/lib/utils/defineRuntime.test.js +0 -40
  57. package/lib/utils/defineRuntime.test.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"createPersistedCollectionCoordinator.js","sourceRoot":"","sources":["../../src/coordinator/createPersistedCollectionCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,GAIrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAatE,MAAM,mBAAmB,GACrB,4BAA4B,CAAC;AACjC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AA+FjC,MAAM,gBAAgB,GAAG,IAAI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],"sources":["../../src/coordinator/createPersistedCollectionCoordinator.ts"],"sourcesContent":["import {\n isCoordinationHost,\n type Coordination,\n type CoordinationServiceClient,\n type CoordinationServiceServer,\n} from \"@party-stack/coordination\";\nimport {\n safeRandomUUID,\n SingleProcessCoordinator,\n toTransportedLoadSubsetOptions,\n toPersistedCollectionDurabilityError,\n} from \"@tanstack/db-sqlite-persistence-core\";\nimport type { LoadSubsetOptions } from \"@tanstack/db\";\nimport type {\n ApplyLocalMutationsResponse,\n ApplyCommittedTxResponse,\n HydrationPersistenceAdapter,\n PersistedCollectionCoordinator,\n PersistedIndexSpec,\n PersistedMutationEnvelope,\n PersistenceAdapter,\n PersistedTx,\n RemoteSubsetOwner,\n ProtocolEnvelope,\n PullSinceResponse,\n ReplayableTxDelta,\n} from \"@tanstack/db-sqlite-persistence-core\";\n\nconst PERSISTENCE_SERVICE = \"party-stack.persistence.v1\";\nconst MAX_DEDUPLICATION_ENTRIES = 1_000;\nconst MAX_PENDING_RELAYS = 1_000;\nconst MAX_COLLECTION_POSITIONS = 128;\n\ninterface CollectionPosition {\n term: number;\n seq: number;\n rowVersion: number;\n}\n\ninterface EnsureLeadershipInput {\n collectionId: string;\n}\n\ninterface EnsureRemoteSubsetInput {\n collectionId: string;\n options: LoadSubsetOptions;\n acquisitionId: string;\n}\n\ninterface ApplyCommittedTxInput {\n schemaVersion?: number;\n collectionId: string;\n tx: PersistedTx;\n}\n\ninterface EnsurePersistedIndexInput {\n schemaVersion?: number;\n collectionId: string;\n signature: string;\n spec: PersistedIndexSpec;\n}\n\ninterface ApplyLocalMutationsInput {\n schemaVersion?: number;\n collectionId: string;\n rpcId: string;\n envelopeId: string;\n mutations: PersistedMutationEnvelope[];\n}\n\ninterface PullSinceInput {\n schemaVersion?: number;\n collectionId: string;\n rpcId: string;\n fromRowVersion: number;\n}\n\ninterface RelayMessageInput {\n collectionId: string;\n message: ProtocolEnvelope<unknown>;\n}\n\ninterface PersistenceCoordinationService {\n methods: {\n ensureLeadership(input: EnsureLeadershipInput): Promise<void>;\n ensureRemoteSubset(input: EnsureRemoteSubsetInput): Promise<void>;\n releaseRemoteSubset(input: EnsureRemoteSubsetInput): Promise<void>;\n applyCommittedTx(input: ApplyCommittedTxInput): Promise<ApplyCommittedTxResponse>;\n ensurePersistedIndex(input: EnsurePersistedIndexInput): Promise<void>;\n applyLocalMutations(input: ApplyLocalMutationsInput): Promise<ApplyLocalMutationsResponse>;\n pullSince(input: PullSinceInput): Promise<PullSinceResponse>;\n relayMessage(input: RelayMessageInput): Promise<void>;\n };\n events: {\n message: RelayMessageInput;\n };\n}\n\ntype AdapterWithPullSince = PersistenceAdapter & {\n pullSince?: (\n collectionId: string,\n fromRowVersion: number\n ) => Promise<\n | {\n latestRowVersion: number;\n latestTerm?: number;\n latestSeq?: number;\n requiresFullReload: true;\n }\n | {\n latestRowVersion: number;\n latestTerm?: number;\n latestSeq?: number;\n requiresFullReload: false;\n changedKeys: Array<string | number>;\n deletedKeys: Array<string | number>;\n deltas?: Array<ReplayableTxDelta<Record<string, unknown>, string | number>>;\n }\n >;\n};\n\nconst coordinatorCache = new WeakMap<\n Coordination,\n WeakMap<PersistenceAdapter, PersistedCollectionCoordinator>\n>();\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction relayKey(collectionId: string, message: ProtocolEnvelope<unknown>): string {\n const payload = isRecord(message.payload) ? message.payload : {};\n return JSON.stringify([\n collectionId,\n message.senderId,\n payload.type,\n payload.txId,\n payload.resetEpoch,\n payload.term,\n payload.seq,\n ]);\n}\n\nexport function createPersistedCollectionCoordinator(\n coordination: Coordination,\n adapter: PersistenceAdapter\n): PersistedCollectionCoordinator {\n let adapters = coordinatorCache.get(coordination);\n if (!adapters) {\n adapters = new WeakMap();\n coordinatorCache.set(coordination, adapters);\n }\n const existing = adapters.get(adapter);\n if (existing) return existing;\n\n const created = new CoordinationPersistenceShim(coordination, adapter);\n adapters.set(adapter, created);\n return created;\n}\n\nclass CoordinationPersistenceShim implements PersistedCollectionCoordinator {\n private readonly nodeId = safeRandomUUID();\n private readonly collectionAdapters = new Map<string, AdapterWithPullSince>();\n private readonly collectionSubscriptions = new Map<string, number>();\n private readonly resumeChecks = new Map<string, Set<(force?: boolean) => Promise<void>>>();\n private readonly localMutationBursts = new Map<\n string,\n {\n pending: Set<string>;\n needsReload: boolean;\n timer?: ReturnType<typeof setTimeout>;\n }\n >();\n private stopResumeListeners: (() => void) | undefined;\n private checkingResume = false;\n private resumeRequested = false;\n\n private requestResumeCheck = (): void => {\n this.resumeRequested = true;\n if (this.checkingResume) return;\n this.checkingResume = true;\n void (async () => {\n try {\n while (this.resumeRequested && this.resumeChecks.size > 0) {\n this.resumeRequested = false;\n await Promise.all(\n [...this.resumeChecks.values()].flatMap((checks) =>\n [...checks].map((check) => check())\n )\n );\n }\n } finally {\n this.checkingResume = false;\n this.resumeRequested = false;\n }\n })();\n };\n\n private startResumeListeners(): void {\n if (this.stopResumeListeners || typeof window === \"undefined\" || typeof document === \"undefined\")\n return;\n const page = window;\n const visibility = document;\n const onVisible = () => {\n if (visibility.visibilityState === \"visible\") this.requestResumeCheck();\n };\n page.addEventListener(\"pageshow\", this.requestResumeCheck);\n page.addEventListener(\"focus\", onVisible);\n visibility.addEventListener(\"visibilitychange\", onVisible);\n this.stopResumeListeners = () => {\n page.removeEventListener(\"pageshow\", this.requestResumeCheck);\n page.removeEventListener(\"focus\", onVisible);\n visibility.removeEventListener(\"visibilitychange\", onVisible);\n };\n }\n\n setAdapterForCollection(collectionId: string, adapter: HydrationPersistenceAdapter): void {\n this.collectionAdapters.set(collectionId, adapter);\n this.positions.delete(collectionId);\n }\n\n private adapterForCollection(collectionId: string, schemaVersion?: number): AdapterWithPullSince {\n const adapter = this.collectionAdapters.get(collectionId) ?? this.adapter;\n if (schemaVersion !== undefined && this.schemaVersion(adapter) !== schemaVersion) {\n throw new Error(\n `Persistence schema mismatch for collection \"${collectionId}\". Reload the coordination host before writing through another schema version.`\n );\n }\n return adapter;\n }\n\n private schemaVersion(adapter: PersistenceAdapter): number | undefined {\n return \"schemaVersion\" in adapter && typeof adapter.schemaVersion === \"number\"\n ? adapter.schemaVersion\n : undefined;\n }\n private readonly positions = new Map<string, Promise<CollectionPosition>>();\n private readonly appliedEnvelopes = new Map<string, Extract<ApplyLocalMutationsResponse, { ok: true }>>();\n private readonly relayedMessages = new Set<string>();\n private readonly service: CoordinationServiceClient<PersistenceCoordinationService>;\n private readonly server: CoordinationServiceServer<PersistenceCoordinationService> | undefined;\n private pendingRelays = 0;\n private readonly remoteSubsets = new SingleProcessCoordinator();\n private readonly acquisitionIds = new WeakMap<LoadSubsetOptions, Map<string, string>>();\n private readonly remoteAcquisitions = new Map<\n string,\n {\n collectionId: string;\n options: LoadSubsetOptions;\n }\n >();\n\n constructor(\n private readonly coordination: Coordination,\n private readonly adapter: AdapterWithPullSince\n ) {\n this.service = coordination.service<PersistenceCoordinationService>(PERSISTENCE_SERVICE);\n this.server = isCoordinationHost(coordination)\n ? coordination.serve<PersistenceCoordinationService>(PERSISTENCE_SERVICE, {\n ensureLeadership: () => Promise.resolve(),\n ensureRemoteSubset: async (input) => {\n let options = this.remoteAcquisitions.get(input.acquisitionId)?.options;\n if (!options) {\n options = input.options;\n this.remoteAcquisitions.set(input.acquisitionId, {\n collectionId: input.collectionId,\n options,\n });\n }\n try {\n await this.remoteSubsets.requestEnsureRemoteSubset(input.collectionId, options);\n } catch (error) {\n // Owner invocation transfers a lease even if loading fails.\n // Release it before dropping our strong reference to its options.\n if (this.remoteAcquisitions.get(input.acquisitionId)?.options === options) {\n this.remoteAcquisitions.delete(input.acquisitionId);\n await this.remoteSubsets\n .requestReleaseRemoteSubset(input.collectionId, options)\n .catch(() => undefined);\n }\n throw error;\n }\n },\n releaseRemoteSubset: (input) => {\n const options = this.remoteAcquisitions.get(input.acquisitionId)?.options;\n this.remoteAcquisitions.delete(input.acquisitionId);\n return options\n ? this.remoteSubsets.requestReleaseRemoteSubset(input.collectionId, options)\n : Promise.resolve();\n },\n applyCommittedTx: (input) => this.applyCommittedTx(input),\n ensurePersistedIndex: (input) =>\n this.adapterForCollection(input.collectionId, input.schemaVersion).ensureIndex(\n input.collectionId,\n input.signature,\n input.spec\n ),\n applyLocalMutations: (input) => this.applyMutations(input),\n pullSince: (input) => this.handlePullSince(input),\n relayMessage: (input) => this.relayMessage(input),\n })\n : undefined;\n }\n\n getNodeId(): string {\n return this.nodeId;\n }\n\n subscribe(collectionId: string, callback: (message: ProtocolEnvelope<unknown>) => void): () => void {\n let active = true;\n let observed: { latestTerm: number; latestSeq: number; latestRowVersion: number } | undefined;\n const unsubscribe = this.service.events.subscribe(\"message\", (event) => {\n if (!active) return;\n if (event.collectionId === collectionId) {\n const payload = event.message.payload;\n const burst = this.localMutationBursts.get(collectionId);\n if (\n burst &&\n isRecord(payload) &&\n payload.type === \"tx:committed\" &&\n typeof payload.txId === \"string\" &&\n !burst.pending.has(payload.txId)\n ) {\n burst.needsReload = true;\n }\n if (\n isRecord(payload) &&\n payload.type === \"tx:committed\" &&\n typeof payload.term === \"number\" &&\n typeof payload.seq === \"number\" &&\n typeof payload.latestRowVersion === \"number\" &&\n (!observed ||\n payload.term > observed.latestTerm ||\n (payload.term === observed.latestTerm && payload.seq > observed.latestSeq))\n ) {\n observed = {\n latestTerm: payload.term,\n latestSeq: payload.seq,\n latestRowVersion: payload.latestRowVersion,\n };\n }\n callback(event.message);\n }\n });\n const checkResume = async (force = false) => {\n try {\n if (!active) return;\n const adapter = this.adapterForCollection(collectionId);\n const current = await adapter.getStreamPosition?.(collectionId);\n if (!active) return;\n if (\n !force &&\n current &&\n observed &&\n current.latestTerm === observed.latestTerm &&\n current.latestSeq === observed.latestSeq &&\n current.latestRowVersion === observed.latestRowVersion\n )\n return;\n // A local reset notification makes upstream reload active subsets atomically.\n // No storage reset or broadcast is performed. Before our first notification,\n // the hydration position is unknown, so a resume conservatively reloads once.\n callback({\n v: 1,\n dbName: this.coordinationScope(),\n collectionId,\n senderId: `resume:${this.nodeId}`,\n ts: Date.now(),\n payload: {\n type: \"collection:reset\",\n schemaVersion: this.schemaVersion(adapter) ?? 1,\n resetEpoch: 0,\n },\n });\n observed = current;\n } catch (error) {\n if (active) console.warn(`Failed to refresh resumed collection \"${collectionId}\".`, error);\n }\n };\n const checks = this.resumeChecks.get(collectionId) ?? new Set();\n checks.add(checkResume);\n this.resumeChecks.set(collectionId, checks);\n this.startResumeListeners();\n this.collectionSubscriptions.set(\n collectionId,\n (this.collectionSubscriptions.get(collectionId) ?? 0) + 1\n );\n return () => {\n if (!active) return;\n active = false;\n checks.delete(checkResume);\n if (checks.size === 0) {\n this.resumeChecks.delete(collectionId);\n const burst = this.localMutationBursts.get(collectionId);\n if (burst?.timer !== undefined) clearTimeout(burst.timer);\n this.localMutationBursts.delete(collectionId);\n }\n if (this.resumeChecks.size === 0) {\n this.stopResumeListeners?.();\n this.stopResumeListeners = undefined;\n }\n try {\n unsubscribe();\n } finally {\n const remaining = this.collectionSubscriptions.get(collectionId)! - 1;\n if (remaining > 0) {\n this.collectionSubscriptions.set(collectionId, remaining);\n } else {\n this.collectionSubscriptions.delete(collectionId);\n this.collectionAdapters.delete(collectionId);\n this.positions.delete(collectionId);\n }\n }\n };\n }\n\n publish(collectionId: string, message: ProtocolEnvelope<unknown>): void {\n if (this.server && isCoordinationHost(this.coordination) && this.coordination.isLeader) {\n this.publishMessage({\n collectionId,\n message,\n });\n return;\n }\n if (this.pendingRelays >= MAX_PENDING_RELAYS) {\n console.warn(\n `Dropping persistence relay for \"${collectionId}\" because the pending relay limit was reached.`\n );\n return;\n }\n this.pendingRelays += 1;\n void this.service.methods\n .relayMessage({\n collectionId,\n message,\n })\n .catch((error: unknown) => {\n console.warn(`Failed to relay persistence message for \"${collectionId}\".`, error);\n })\n .finally(() => {\n this.pendingRelays -= 1;\n });\n }\n\n isLeader(): boolean {\n return isCoordinationHost(this.coordination) && this.coordination.isLeader;\n }\n\n ensureLeadership(): Promise<void> {\n return this.service.methods.ensureLeadership({\n collectionId: \"*\",\n });\n }\n\n requestEnsureRemoteSubset(collectionId: string, options: LoadSubsetOptions): Promise<void> {\n let collectionIds = this.acquisitionIds.get(options);\n if (!collectionIds) {\n collectionIds = new Map();\n this.acquisitionIds.set(options, collectionIds);\n }\n let acquisitionId = collectionIds.get(collectionId);\n if (!acquisitionId) {\n acquisitionId = safeRandomUUID();\n collectionIds.set(collectionId, acquisitionId);\n }\n return this.service.methods.ensureRemoteSubset({\n collectionId,\n options: toTransportedLoadSubsetOptions(options) as LoadSubsetOptions,\n acquisitionId,\n });\n }\n\n requestReleaseRemoteSubset(collectionId: string, options: LoadSubsetOptions): Promise<void> {\n const collectionIds = this.acquisitionIds.get(options);\n const acquisitionId = collectionIds?.get(collectionId);\n if (!acquisitionId) return Promise.resolve();\n collectionIds!.delete(collectionId);\n if (collectionIds!.size === 0) this.acquisitionIds.delete(options);\n return this.service.methods.releaseRemoteSubset({ collectionId, options: {}, acquisitionId });\n }\n\n registerRemoteSubsetOwner(collectionId: string, owner: RemoteSubsetOwner): () => void {\n const unregister = this.remoteSubsets.registerRemoteSubsetOwner(collectionId, owner);\n let registered = true;\n return () => {\n if (!registered) return;\n registered = false;\n unregister();\n for (const [id, acquisition] of this.remoteAcquisitions) {\n if (acquisition.collectionId === collectionId) this.remoteAcquisitions.delete(id);\n }\n };\n }\n\n requestApplyCommittedTx(\n collectionId: string,\n tx: PersistedTx,\n scopedAdapter?: HydrationPersistenceAdapter\n ): Promise<ApplyCommittedTxResponse> {\n return this.isLeader()\n ? this.applyCommittedTx({ collectionId, tx }, scopedAdapter)\n : this.service.methods.applyCommittedTx({\n collectionId,\n tx,\n schemaVersion:\n this.schemaVersion(scopedAdapter ?? this.adapterForCollection(collectionId)) ??\n this.schemaVersion(this.adapterForCollection(collectionId)),\n });\n }\n\n private async applyCommittedTx(\n { collectionId, tx, schemaVersion }: ApplyCommittedTxInput,\n scopedAdapter?: HydrationPersistenceAdapter\n ): Promise<ApplyCommittedTxResponse> {\n try {\n await (scopedAdapter ?? this.adapterForCollection(collectionId, schemaVersion)).applyCommittedTx(\n collectionId,\n tx\n );\n } catch (error) {\n throw toPersistedCollectionDurabilityError(collectionId, error);\n }\n this.positions.delete(collectionId);\n return {\n type: \"rpc:applyCommittedTx:res\",\n rpcId: safeRandomUUID(),\n ok: true,\n term: tx.term,\n seq: tx.seq,\n latestRowVersion: tx.rowVersion,\n };\n }\n\n requestEnsurePersistedIndex(\n collectionId: string,\n signature: string,\n spec: PersistedIndexSpec,\n scopedAdapter?: HydrationPersistenceAdapter,\n localEnsureCompleted?: boolean\n ): Promise<void> {\n if (this.isLeader()) {\n return localEnsureCompleted\n ? Promise.resolve()\n : (scopedAdapter ?? this.adapterForCollection(collectionId)).ensureIndex(\n collectionId,\n signature,\n spec\n );\n }\n return this.service.methods.ensurePersistedIndex({\n collectionId,\n signature,\n spec,\n schemaVersion:\n this.schemaVersion(scopedAdapter ?? this.adapterForCollection(collectionId)) ??\n this.schemaVersion(this.adapterForCollection(collectionId)),\n });\n }\n\n async requestApplyLocalMutations(\n collectionId: string,\n mutations: PersistedMutationEnvelope[]\n ): Promise<ApplyLocalMutationsResponse> {\n const envelopeId = safeRandomUUID();\n const burst = this.resumeChecks.has(collectionId)\n ? (this.localMutationBursts.get(collectionId) ?? {\n pending: new Set<string>(),\n needsReload: false,\n timer: undefined,\n })\n : undefined;\n if (burst) {\n if (burst.timer !== undefined) clearTimeout(burst.timer);\n if (burst.pending.size > 0) burst.needsReload = true;\n burst.pending.add(envelopeId);\n this.localMutationBursts.set(collectionId, burst);\n }\n try {\n return await this.service.methods.applyLocalMutations({\n collectionId,\n rpcId: safeRandomUUID(),\n envelopeId,\n schemaVersion: this.schemaVersion(this.adapterForCollection(collectionId)),\n mutations,\n });\n } finally {\n burst?.pending.delete(envelopeId);\n if (burst && burst.pending.size === 0 && this.localMutationBursts.get(collectionId) === burst) {\n // Upstream advances its observed sequence from local RPC acknowledgements\n // before queued commit messages can run. Reconcile overlapping foreign\n // commits after the local mutation burst, without changing RPC positions.\n burst.timer = setTimeout(() => {\n if (this.localMutationBursts.get(collectionId) !== burst) return;\n this.localMutationBursts.delete(collectionId);\n if (burst.needsReload) {\n for (const check of this.resumeChecks.get(collectionId) ?? []) void check(true);\n }\n }, 0);\n }\n }\n }\n\n pullSince(collectionId: string, fromRowVersion: number): Promise<PullSinceResponse> {\n return this.service.methods.pullSince({\n collectionId,\n rpcId: safeRandomUUID(),\n fromRowVersion,\n schemaVersion: this.schemaVersion(this.adapterForCollection(collectionId)),\n });\n }\n\n private relayMessage(input: RelayMessageInput): Promise<void> {\n const key = relayKey(input.collectionId, input.message);\n if (this.relayedMessages.has(key)) {\n return Promise.resolve();\n }\n this.relayedMessages.add(key);\n if (this.relayedMessages.size > MAX_DEDUPLICATION_ENTRIES) {\n const oldest = this.relayedMessages.values().next().value;\n if (oldest) {\n this.relayedMessages.delete(oldest);\n }\n }\n this.publishMessage(input);\n return Promise.resolve();\n }\n\n private publishMessage(input: RelayMessageInput): void {\n this.server?.events.publish(\"message\", input);\n }\n\n private async position(collectionId: string): Promise<CollectionPosition> {\n let position = this.positions.get(collectionId);\n if (!position) {\n const adapter = this.adapterForCollection(collectionId);\n position = Promise.resolve(\n adapter.getStreamPosition\n ? adapter.getStreamPosition(collectionId)\n : adapter.loadResumeSnapshot(collectionId, { includeRows: false })\n ).then((current) => ({\n term: (current?.latestTerm ?? 0) + 1,\n seq: current?.latestSeq ?? 0,\n rowVersion: current?.latestRowVersion ?? 0,\n }));\n }\n this.positions.delete(collectionId);\n this.positions.set(collectionId, position);\n while (this.positions.size > MAX_COLLECTION_POSITIONS) {\n const oldest = this.positions.keys().next().value;\n if (oldest !== undefined) this.positions.delete(oldest);\n }\n void position.catch(() => {\n if (this.positions.get(collectionId) === position) this.positions.delete(collectionId);\n });\n return position;\n }\n\n private async applyMutations(input: ApplyLocalMutationsInput): Promise<ApplyLocalMutationsResponse> {\n const adapter = this.adapterForCollection(input.collectionId, input.schemaVersion);\n const envelopeKey = JSON.stringify([input.collectionId, input.envelopeId]);\n const previous = this.appliedEnvelopes.get(envelopeKey);\n if (previous) {\n return {\n ...previous,\n rpcId: input.rpcId,\n };\n }\n\n const position = await this.position(input.collectionId);\n const nextPosition = { ...position, seq: position.seq + 1, rowVersion: position.rowVersion + 1 };\n const txId = input.envelopeId;\n await adapter.applyCommittedTx(input.collectionId, {\n txId,\n term: nextPosition.term,\n seq: nextPosition.seq,\n rowVersion: nextPosition.rowVersion,\n mutations: input.mutations.map(({ mutationId, ...mutation }) => {\n void mutationId;\n return mutation;\n }),\n });\n Object.assign(position, nextPosition);\n const committed: ProtocolEnvelope<unknown> = {\n v: 1,\n dbName: this.coordinationScope(),\n collectionId: input.collectionId,\n senderId: this.nodeId,\n ts: Date.now(),\n payload: {\n type: \"tx:committed\",\n term: position.term,\n seq: position.seq,\n txId,\n latestRowVersion: position.rowVersion,\n requiresFullReload: false,\n changedRows: input.mutations\n .filter((mutation) => mutation.type !== \"delete\")\n .map((mutation) => ({\n key: mutation.key,\n value: mutation.value,\n })),\n deletedKeys: input.mutations\n .filter((mutation) => mutation.type === \"delete\")\n .map((mutation) => mutation.key),\n rowMetadataMutations: input.mutations.flatMap((mutation) =>\n mutation.type !== \"delete\" &&\n (mutation.metadataChanged || mutation.metadata !== undefined)\n ? [\n mutation.metadata === undefined\n ? { type: \"delete\" as const, key: mutation.key }\n : { type: \"set\" as const, key: mutation.key, value: mutation.metadata },\n ]\n : []\n ),\n },\n };\n this.publishMessage({\n collectionId: input.collectionId,\n message: committed,\n });\n\n const response: Extract<ApplyLocalMutationsResponse, { ok: true }> = {\n type: \"rpc:applyLocalMutations:res\",\n rpcId: input.rpcId,\n ok: true,\n term: position.term,\n seq: position.seq,\n latestRowVersion: position.rowVersion,\n acceptedMutationIds: input.mutations.map((mutation) => mutation.mutationId),\n };\n this.appliedEnvelopes.set(envelopeKey, response);\n if (this.appliedEnvelopes.size > MAX_DEDUPLICATION_ENTRIES) {\n const oldest = this.appliedEnvelopes.keys().next().value;\n if (oldest) {\n this.appliedEnvelopes.delete(oldest);\n }\n }\n return response;\n }\n\n private async handlePullSince(input: PullSinceInput): Promise<PullSinceResponse> {\n const adapter = this.adapterForCollection(input.collectionId, input.schemaVersion);\n const current = await adapter.getStreamPosition?.(input.collectionId);\n const position = current\n ? { term: current.latestTerm, seq: current.latestSeq, rowVersion: current.latestRowVersion }\n : await this.position(input.collectionId);\n const result = await adapter.pullSince?.(input.collectionId, input.fromRowVersion);\n if (!result || result.requiresFullReload) {\n return {\n type: \"rpc:pullSince:res\",\n rpcId: input.rpcId,\n ok: true,\n latestTerm: result?.latestTerm ?? position.term,\n latestSeq: result?.latestSeq ?? position.seq,\n latestRowVersion: result?.latestRowVersion ?? position.rowVersion,\n requiresFullReload: true,\n };\n }\n return {\n type: \"rpc:pullSince:res\",\n rpcId: input.rpcId,\n ok: true,\n latestTerm: result?.latestTerm ?? position.term,\n latestSeq: result?.latestSeq ?? position.seq,\n latestRowVersion: result.latestRowVersion,\n requiresFullReload: false,\n changedKeys: result.changedKeys,\n deletedKeys: result.deletedKeys,\n deltas: result.deltas,\n };\n }\n\n private coordinationScope(): string {\n return \"scope\" in this.coordination && typeof this.coordination.scope === \"string\"\n ? this.coordination.scope\n : \"party-stack\";\n }\n}\n"],"mappings":";;;AA4BA,MAAM,sBAAsB;AAC5B,MAAM,4BAA4B;AAClC,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AA0FjC,MAAM,mCAAmB,IAAI,QAG3B;AAEF,SAAS,SAAS,OAAkD;CAChE,OAAO,OAAO,UAAU,YAAY,UAAU;AAClD;AAEA,SAAS,SAAS,cAAsB,SAA4C;CAChF,MAAM,UAAU,SAAS,QAAQ,OAAO,IAAI,QAAQ,UAAU,CAAC;CAC/D,OAAO,KAAK,UAAU;EAClB;EACA,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACZ,CAAC;A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S;GAC3C,WAAW,QAAQ,aAAa,SAAS;GACzC,kBAAkB,QAAQ,oBAAoB,SAAS;GACvD,oBAAoB;EACxB;EAEJ,OAAO;GACH,MAAM;GACN,OAAO,MAAM;GACb,IAAI;GACJ,YAAY,QAAQ,cAAc,SAAS;GAC3C,WAAW,QAAQ,aAAa,SAAS;GACzC,kBAAkB,OAAO;GACzB,oBAAoB;GACpB,aAAa,OAAO;GACpB,aAAa,OAAO;GACpB,QAAQ,OAAO;EACnB;CACJ;CAEA,oBAAoC;EAChC,OAAO,WAAW,KAAK,gBAAgB,OAAO,KAAK,aAAa,UAAU,WACpE,KAAK,aAAa,QAClB;CACV;AACJ"}
@@ -1,2 +1,2 @@
1
- export { createPersistedCollectionCoordinator } from "./createPersistedCollectionCoordinator.js";
2
- //# sourceMappingURL=index.d.ts.map
1
+ import { createPersistedCollectionCoordinator } from "./createPersistedCollectionCoordinator.js";
2
+ export { createPersistedCollectionCoordinator };
@@ -1,2 +1,2 @@
1
- export { createPersistedCollectionCoordinator } from "./createPersistedCollectionCoordinator.js";
2
- //# sourceMappingURL=index.js.map
1
+ import { createPersistedCollectionCoordinator } from "./createPersistedCollectionCoordinator.js";
2
+ export { createPersistedCollectionCoordinator };
@@ -1,5 +1,7 @@
1
- import { type Operation, type Stream } from "effection";
2
- import type { RuntimeAdapter, RuntimeAdapterProvider } from "../types.js";
1
+ import { RuntimeAdapter, RuntimeAdapterProvider } from "../types.js";
2
+ import { Operation, Stream } from "effection";
3
+ //#region src/effection/index.d.ts
3
4
  export declare function useRuntimeAdapter(provider: RuntimeAdapter | RuntimeAdapterProvider, owner: string, namespace: string): Operation<RuntimeAdapter>;
4
5
  export declare function useConnectivityChanges(runtime: RuntimeAdapter): Operation<Stream<boolean, void>>;
6
+ //#endregion
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,SAAS,EACd,KAAK,MAAM,EACd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACR,cAAc,EACd,sBAAsB,EACzB,MAAM,aAAa,CAAC;AAErB,wBAAgB,iBAAiB,CAC7B,QAAQ,EAAE,cAAc,GAAG,sBAAsB,EACjD,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAClB,SAAS,CAAC,cAAc,CAAC,CAgB3B;AAED,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,cAAc,GACxB,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAalC"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/effection/index.ts"],"mappings":";;;wBAGgB,kBACZ,UAAU,iBAAiB,wBAC3B,eACA,oBACD,UAAU;wBAcG,uBAAuB,SAAS,iBAAiB,UAAU"}
@@ -1,28 +1,28 @@
1
- import { createSignal, resource, until, } from "effection";
2
- export function useRuntimeAdapter(provider, owner, namespace) {
3
- return resource(function* (provide) {
4
- const runtime = typeof provider === "function"
5
- ? yield* until(Promise.resolve(provider(owner, namespace)))
6
- : provider;
7
- try {
8
- yield* provide(runtime);
9
- }
10
- finally {
11
- yield* until(Promise.resolve(runtime.cleanup?.()));
12
- }
13
- });
1
+ import { createSignal, resource, until } from "effection";
2
+ //#region src/effection/index.ts
3
+ function useRuntimeAdapter(provider, owner, namespace) {
4
+ return resource(function* (provide) {
5
+ const runtime = typeof provider === "function" ? yield* until(Promise.resolve(provider(owner, namespace))) : provider;
6
+ try {
7
+ yield* provide(runtime);
8
+ } finally {
9
+ yield* until(Promise.resolve(runtime.cleanup?.()));
10
+ }
11
+ });
14
12
  }
15
- export function useConnectivityChanges(runtime) {
16
- return resource(function* (provide) {
17
- const signal = createSignal();
18
- const unsubscribe = runtime.connectivity?.subscribe((isConnected) => signal.send(isConnected));
19
- try {
20
- yield* provide(signal);
21
- }
22
- finally {
23
- unsubscribe?.();
24
- signal.close();
25
- }
26
- });
13
+ function useConnectivityChanges(runtime) {
14
+ return resource(function* (provide) {
15
+ const signal = createSignal();
16
+ const unsubscribe = runtime.connectivity?.subscribe((isConnected) => signal.send(isConnected));
17
+ try {
18
+ yield* provide(signal);
19
+ } finally {
20
+ unsubscribe?.();
21
+ signal.close();
22
+ }
23
+ });
27
24
  }
25
+ //#endregion
26
+ export { useConnectivityChanges, useRuntimeAdapter };
27
+
28
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/effection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,KAAK,GAGR,MAAM,WAAW,CAAC;AAMnB,MAAM,UAAU,iBAAiB,CAC7B,QAAiD,EACjD,KAAa,EACb,SAAiB;IAEjB,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO;QAC9B,MAAM,OAAO,GACT,OAAO,QAAQ,KAAK,UAAU;YAC1B,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CACR,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAC9C;YACH,CAAC,CAAC,QAAQ,CAAC;QACnB,IAAI,CAAC;YACD,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;gBAAS,CAAC;YACP,KAAK,CAAC,CAAC,KAAK,CACR,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CACvC,CAAC;QACN,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,sBAAsB,CAClC,OAAuB;IAEvB,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO;QAC9B,MAAM,MAAM,GAAG,YAAY,EAAiB,CAAC;QAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,SAAS,CAC/C,CAAC,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAC5C,CAAC;QACF,IAAI,CAAC;YACD,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACP,WAAW,EAAE,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/effection/index.ts"],"sourcesContent":["import { createSignal, resource, until, type Operation, type Stream } from \"effection\";\nimport type { RuntimeAdapter, RuntimeAdapterProvider } from \"../types.js\";\n\nexport function useRuntimeAdapter(\n provider: RuntimeAdapter | RuntimeAdapterProvider,\n owner: string,\n namespace: string\n): Operation<RuntimeAdapter> {\n return resource(function* (provide) {\n const runtime =\n typeof provider === \"function\"\n ? yield* until(Promise.resolve(provider(owner, namespace)))\n : provider;\n try {\n yield* provide(runtime);\n } finally {\n yield* until(Promise.resolve(runtime.cleanup?.()));\n }\n });\n}\n\nexport function useConnectivityChanges(runtime: RuntimeAdapter): Operation<Stream<boolean, void>> {\n return resource(function* (provide) {\n const signal = createSignal<boolean, void>();\n const unsubscribe = runtime.connectivity?.subscribe((isConnected) => signal.send(isConnected));\n try {\n yield* provide(signal);\n } finally {\n unsubscribe?.();\n signal.close();\n }\n });\n}\n"],"mappings":";;AAGA,SAAgB,kBACZ,UACA,OACA,WACyB;CACzB,OAAO,SAAS,WAAW,SAAS;EAChC,MAAM,UACF,OAAO,aAAa,aACd,OAAO,MAAM,QAAQ,QAAQ,SAAS,OAAO,SAAS,CAAC,CAAC,IACxD;EACV,IAAI;GACA,OAAO,QAAQ,OAAO;EAC1B,UAAU;GACN,OAAO,MAAM,QAAQ,QAAQ,QAAQ,UAAU,CAAC,CAAC;EACrD;CACJ,CAAC;AACL;AAEA,SAAgB,uBAAuB,SAA2D;CAC9F,OAAO,SAAS,WAAW,SAAS;EAChC,MAAM,SAAS,aAA4B;EAC3C,MAAM,cAAc,QAAQ,cAAc,WAAW,gBAAgB,OAAO,KAAK,WAAW,CAAC;EAC7F,IAAI;GACA,OAAO,QAAQ,MAAM;EACzB,UAAU;GACN,cAAc;GACd,OAAO,MAAM;EACjB;CACJ,CAAC;AACL"}
package/lib/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export { createPersistedCollectionCoordinator } from "./coordinator/index.js";
2
- export { createDefaultRuntime } from "./utils/createDefaultRuntime.js";
3
- export { defineRuntime } from "./utils/defineRuntime.js";
4
- export { createLocalCollection } from "./utils/createLocalCollection.js";
5
- export { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
6
- export { BrowserAuthenticationCancelledError } from "./utils/BrowserAuthenticationCancelledError.js";
7
- export { CoordinationClosedError, CoordinationError, CoordinationProtocolError, CoordinationServiceError, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, SingleProcessCoordination, isCoordinationHost, } from "@party-stack/coordination";
8
- export type { BlobBytesStore, BrowserAuthentication, BrowserAuthenticationPresentation, BrowserAuthenticationSession, SecretStore, NetworkConnectivity, PersistenceAdapter, RuntimeAdapter, RuntimeAdapterProvider, } from "./types.js";
9
- export type { Coordination, CoordinationCallOptions, CoordinationClient, CoordinationErrorCode, CoordinationHost, CoordinationMethodInput, CoordinationMethodResult, CoordinationOptions, CoordinationService, CoordinationServiceClient, CoordinationServiceEvents, CoordinationServiceHandler, CoordinationServiceHandlers, CoordinationServiceMethods, CoordinationServicePublisher, CoordinationServiceServer, CoordinationTaskContext, LockBroadcastCoordinationOptions, } from "@party-stack/coordination";
10
- //# sourceMappingURL=index.d.ts.map
1
+ import { createPersistedCollectionCoordinator } from "./coordinator/createPersistedCollectionCoordinator.js";
2
+ import "./coordinator/index.js";
3
+ import { BlobBytesStore, BrowserAuthentication, BrowserAuthenticationPresentation, BrowserAuthenticationSession, NetworkConnectivity, PersistenceAdapter, RuntimeAdapter, RuntimeAdapterProvider, SecretStore } from "./types.js";
4
+ import { createDefaultRuntime } from "./utils/createDefaultRuntime.js";
5
+ import { defineRuntime } from "./utils/defineRuntime.js";
6
+ import { createCollectionPersistence } from "./utils/createCollectionPersistence.js";
7
+ import { createLocalCollection } from "./utils/createLocalCollection.js";
8
+ import { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
9
+ import { BrowserAuthenticationCancelledError } from "./utils/BrowserAuthenticationCancelledError.js";
10
+ import { Coordination, CoordinationCallOptions, CoordinationClient, CoordinationClosedError, CoordinationError, CoordinationErrorCode, CoordinationHost, CoordinationMethodInput, CoordinationMethodResult, CoordinationOptions, CoordinationProtocolError, CoordinationService, CoordinationServiceClient, CoordinationServiceError, CoordinationServiceEvents, CoordinationServiceHandler, CoordinationServiceHandlers, CoordinationServiceMethods, CoordinationServicePublisher, CoordinationServiceServer, CoordinationTaskContext, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, LockBroadcastCoordinationOptions, SingleProcessCoordination, isCoordinationHost } from "@party-stack/coordination";
11
+ export { type BlobBytesStore, type BrowserAuthentication, BrowserAuthenticationCancelledError, type BrowserAuthenticationPresentation, type BrowserAuthenticationSession, type Coordination, type CoordinationCallOptions, type CoordinationClient, CoordinationClosedError, CoordinationError, type CoordinationErrorCode, type CoordinationHost, type CoordinationMethodInput, type CoordinationMethodResult, type CoordinationOptions, CoordinationProtocolError, type CoordinationService, type CoordinationServiceClient, CoordinationServiceError, type CoordinationServiceEvents, type CoordinationServiceHandler, type CoordinationServiceHandlers, type CoordinationServiceMethods, type CoordinationServicePublisher, type CoordinationServiceServer, type CoordinationTaskContext, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, type LockBroadcastCoordinationOptions, MemoryBlobBytesStore, type NetworkConnectivity, type PersistenceAdapter, type RuntimeAdapter, type RuntimeAdapterProvider, type SecretStore, SingleProcessCoordination, createCollectionPersistence, createDefaultRuntime, createLocalCollection, createPersistedCollectionCoordinator, defineRuntime, isCoordinationHost };
package/lib/index.js CHANGED
@@ -1,8 +1,10 @@
1
- export { createPersistedCollectionCoordinator } from "./coordinator/index.js";
2
- export { createDefaultRuntime } from "./utils/createDefaultRuntime.js";
3
- export { defineRuntime } from "./utils/defineRuntime.js";
4
- export { createLocalCollection } from "./utils/createLocalCollection.js";
5
- export { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
6
- export { BrowserAuthenticationCancelledError } from "./utils/BrowserAuthenticationCancelledError.js";
7
- export { CoordinationClosedError, CoordinationError, CoordinationProtocolError, CoordinationServiceError, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, SingleProcessCoordination, isCoordinationHost, } from "@party-stack/coordination";
8
- //# sourceMappingURL=index.js.map
1
+ import { createPersistedCollectionCoordinator } from "./coordinator/createPersistedCollectionCoordinator.js";
2
+ import "./coordinator/index.js";
3
+ import { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
4
+ import { defineRuntime } from "./utils/defineRuntime.js";
5
+ import { createDefaultRuntime } from "./utils/createDefaultRuntime.js";
6
+ import { createCollectionPersistence } from "./utils/createCollectionPersistence.js";
7
+ import { createLocalCollection } from "./utils/createLocalCollection.js";
8
+ import { BrowserAuthenticationCancelledError } from "./utils/BrowserAuthenticationCancelledError.js";
9
+ import { CoordinationClosedError, CoordinationError, CoordinationProtocolError, CoordinationServiceError, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, SingleProcessCoordination, isCoordinationHost } from "@party-stack/coordination";
10
+ export { BrowserAuthenticationCancelledError, CoordinationClosedError, CoordinationError, CoordinationProtocolError, CoordinationServiceError, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, MemoryBlobBytesStore, SingleProcessCoordination, createCollectionPersistence, createDefaultRuntime, createLocalCollection, createPersistedCollectionCoordinator, defineRuntime, isCoordinationHost };
@@ -1,9 +1,11 @@
1
- import type { BlobBytesStore } from "../types.js";
1
+ import { BlobBytesStore } from "../types.js";
2
+ //#region src/memory/MemoryBlobBytesStore.d.ts
2
3
  export declare class MemoryBlobBytesStore implements BlobBytesStore {
3
- readonly blobs: Map<string, Blob>;
4
- constructor(blobs?: Map<string, Blob>);
5
- write(id: string, blob: Blob): Promise<void>;
6
- read(id: string): Promise<Blob>;
7
- delete(id: string): Promise<void>;
4
+ readonly blobs: Map<string, Blob>;
5
+ constructor(blobs?: Map<string, Blob>);
6
+ write(id: string, blob: Blob): Promise<void>;
7
+ read(id: string): Promise<Blob>;
8
+ delete(id: string): Promise<void>;
8
9
  }
10
+ //#endregion
9
11
  //# sourceMappingURL=MemoryBlobBytesStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryBlobBytesStore.d.ts","sourceRoot":"","sources":["../../src/memory/MemoryBlobBytesStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,qBAAa,oBAAqB,YAAW,cAAc;IAC3C,QAAQ,CAAC,KAAK;gBAAL,KAAK,oBAA0B;IAEpD,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIpC"}
1
+ {"version":3,"file":"MemoryBlobBytesStore.d.ts","names":[],"sources":["../../src/memory/MemoryBlobBytesStore.ts"],"mappings":";;qBAEa,gCAAgC;WACpB,OAAK,YAAA;EAA1B,YAAqB,QAAK,YAAA;EAE1B,MAAM,YAAY,MAAM,OAAO;EAK/B,KAAK,aAAa,QAAQ;EAK1B,OAAO,aAAa"}
@@ -1,21 +1,23 @@
1
- export class MemoryBlobBytesStore {
2
- blobs;
3
- constructor(blobs = new Map()) {
4
- this.blobs = blobs;
5
- }
6
- write(id, blob) {
7
- this.blobs.set(id, blob);
8
- return Promise.resolve();
9
- }
10
- read(id) {
11
- const blob = this.blobs.get(id);
12
- return blob
13
- ? Promise.resolve(blob)
14
- : Promise.reject(new Error(`Blob bytes not found for "${id}".`));
15
- }
16
- delete(id) {
17
- this.blobs.delete(id);
18
- return Promise.resolve();
19
- }
20
- }
1
+ //#region src/memory/MemoryBlobBytesStore.ts
2
+ var MemoryBlobBytesStore = class {
3
+ blobs;
4
+ constructor(blobs = /* @__PURE__ */ new Map()) {
5
+ this.blobs = blobs;
6
+ }
7
+ write(id, blob) {
8
+ this.blobs.set(id, blob);
9
+ return Promise.resolve();
10
+ }
11
+ read(id) {
12
+ const blob = this.blobs.get(id);
13
+ return blob ? Promise.resolve(blob) : Promise.reject(/* @__PURE__ */ new Error(`Blob bytes not found for "${id}".`));
14
+ }
15
+ delete(id) {
16
+ this.blobs.delete(id);
17
+ return Promise.resolve();
18
+ }
19
+ };
20
+ //#endregion
21
+ export { MemoryBlobBytesStore };
22
+
21
23
  //# sourceMappingURL=MemoryBlobBytesStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryBlobBytesStore.js","sourceRoot":"","sources":["../../src/memory/MemoryBlobBytesStore.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,oBAAoB;IACR;IAArB,YAAqB,QAAQ,IAAI,GAAG,EAAgB;QAA/B,UAAK,GAAL,KAAK,CAA0B;IAAG,CAAC;IAExD,KAAK,CAAC,EAAU,EAAE,IAAU;QACxB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACzB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC,EAAU;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChC,OAAO,IAAI;YACP,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACvB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,CAAC,EAAU;QACb,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ"}
1
+ {"version":3,"file":"MemoryBlobBytesStore.js","names":[],"sources":["../../src/memory/MemoryBlobBytesStore.ts"],"sourcesContent":["import type { BlobBytesStore } from \"../types.js\";\n\nexport class MemoryBlobBytesStore implements BlobBytesStore {\n constructor(readonly blobs = new Map<string, Blob>()) {}\n\n write(id: string, blob: Blob): Promise<void> {\n this.blobs.set(id, blob);\n return Promise.resolve();\n }\n\n read(id: string): Promise<Blob> {\n const blob = this.blobs.get(id);\n return blob ? Promise.resolve(blob) : Promise.reject(new Error(`Blob bytes not found for \"${id}\".`));\n }\n\n delete(id: string): Promise<void> {\n this.blobs.delete(id);\n return Promise.resolve();\n }\n}\n"],"mappings":";AAEA,IAAa,uBAAb,MAA4D;CACnC;CAArB,YAAY,wBAAiB,IAAI,IAAkB,GAAG;EAAjC,KAAA,QAAA;CAAkC;CAEvD,MAAM,IAAY,MAA2B;EACzC,KAAK,MAAM,IAAI,IAAI,IAAI;EACvB,OAAO,QAAQ,QAAQ;CAC3B;CAEA,KAAK,IAA2B;EAC5B,MAAM,OAAO,KAAK,MAAM,IAAI,EAAE;EAC9B,OAAO,OAAO,QAAQ,QAAQ,IAAI,IAAI,QAAQ,uBAAO,IAAI,MAAM,6BAA6B,GAAG,GAAG,CAAC;CACvG;CAEA,OAAO,IAA2B;EAC9B,KAAK,MAAM,OAAO,EAAE;EACpB,OAAO,QAAQ,QAAQ;CAC3B;AACJ"}
package/lib/types.d.ts CHANGED
@@ -1,44 +1,46 @@
1
- import type { Coordination } from "@party-stack/coordination";
2
- import type { PersistenceAdapter } from "@tanstack/db-sqlite-persistence-core";
1
+ import { Coordination } from "@party-stack/coordination";
2
+ import { PersistedCollectionPersistence, PersistenceAdapter } from "@tanstack/db-sqlite-persistence-core";
3
+ //#region src/types.d.ts
3
4
  export interface BlobBytesStore {
4
- write(id: string, blob: Blob): Promise<void>;
5
- read(id: string): Promise<Blob>;
6
- delete(id: string): Promise<void>;
5
+ write(id: string, blob: Blob): Promise<void>;
6
+ read(id: string): Promise<Blob>;
7
+ delete(id: string): Promise<void>;
7
8
  }
8
9
  export interface NetworkConnectivity {
9
- readonly isConnected: boolean;
10
- subscribe(callback: (isConnected: boolean) => void): () => void;
10
+ readonly isConnected: boolean;
11
+ subscribe(callback: (isConnected: boolean) => void): () => void;
11
12
  }
12
13
  export interface SecretStore {
13
- get(key: string): Promise<string | undefined>;
14
- set(key: string, value: string): Promise<void>;
15
- delete(key: string): Promise<void>;
14
+ get(key: string): Promise<string | undefined>;
15
+ set(key: string, value: string): Promise<void>;
16
+ delete(key: string): Promise<void>;
16
17
  }
17
18
  export type BrowserAuthenticationPresentation = "popup" | "redirect";
18
19
  export interface BrowserAuthenticationSession {
19
- open(authorizationUrl: string): Promise<{
20
- callbackUrl: string;
21
- }>;
22
- close(): void | Promise<void>;
20
+ open(authorizationUrl: string): Promise<{
21
+ callbackUrl: string;
22
+ }>;
23
+ close(): void | Promise<void>;
23
24
  }
24
25
  export interface BrowserAuthentication {
25
- start(options: {
26
- redirectUrl: string;
27
- presentation?: BrowserAuthenticationPresentation;
28
- }): BrowserAuthenticationSession;
26
+ start(options: {
27
+ redirectUrl: string;
28
+ presentation?: BrowserAuthenticationPresentation;
29
+ }): BrowserAuthenticationSession;
29
30
  }
30
- export type { PersistenceAdapter } from "@tanstack/db-sqlite-persistence-core";
31
31
  export interface RuntimeAdapter {
32
- readonly owner: string;
33
- readonly namespace: string;
34
- blobBytes: BlobBytesStore;
35
- coordination: Coordination;
36
- connectivity?: NetworkConnectivity;
37
- browserAuthentication?: BrowserAuthentication;
38
- secrets?: SecretStore;
39
- persistence?: PersistenceAdapter;
40
- cleanup?: () => void | Promise<void>;
41
- destroy?: () => void | Promise<void>;
32
+ readonly owner: string;
33
+ readonly namespace: string;
34
+ blobBytes: BlobBytesStore;
35
+ coordination: Coordination;
36
+ connectivity?: NetworkConnectivity;
37
+ browserAuthentication?: BrowserAuthentication;
38
+ secrets?: SecretStore;
39
+ persistence?: PersistedCollectionPersistence;
40
+ cleanup?: () => void | Promise<void>;
41
+ destroy?: () => void | Promise<void>;
42
42
  }
43
43
  export type RuntimeAdapterProvider = (owner: string, namespace: string) => RuntimeAdapter | Promise<RuntimeAdapter>;
44
+ //#endregion
45
+ export type { PersistenceAdapter };
44
46
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,MAAM,WAAW,cAAc;IAC3B,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,SAAS,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACnE;AAED,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,GA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AK,aAAa,QAAQ;EAC1B,OAAO,aAAa;;iBAGP;WACJ;EACT,UAAU,WAAW;;iBAGR;EACb,IAAI,cAAc;EAClB,IAAI,aAAa,gBAAgB;EACjC,OAAO,cAAc;;YAGb;iBAEK;EACb,KAAK,2BAA2B;IAAU;;EAC1C,gBAAgB;;iBAGH;EACb,MAAM;IACF;IACA,eAAe;MACf;;iBAKS;WACJ;WACA;EACT,WAAW;EACX,cAAc;EACd,eAAe;EACf,wBAAwB;EACxB,UAAU;EACV,cAAc;EACd,uBAAuB;EACvB,uBAAuB;;YAGf,0BACR,eACA,sBACC,iBAAiB,QAAQ"}
package/lib/types.js CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,4 +1,6 @@
1
+ //#region src/utils/BrowserAuthenticationCancelledError.d.ts
1
2
  export declare class BrowserAuthenticationCancelledError extends Error {
2
- constructor(message?: string);
3
+ constructor(message?: string);
3
4
  }
5
+ //#endregion
4
6
  //# sourceMappingURL=BrowserAuthenticationCancelledError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserAuthenticationCancelledError.d.ts","sourceRoot":"","sources":["../../src/utils/BrowserAuthenticationCancelledError.ts"],"names":[],"mappings":"AAAA,qBAAa,mCAAoC,SAAQ,KAAK;gBAC9C,OAAO,SAA0C;CAIhE"}
1
+ {"version":3,"file":"BrowserAuthenticationCancelledError.d.ts","names":[],"sources":["../../src/utils/BrowserAuthenticationCancelledError.ts"],"mappings":";qBAAa,4CAA4C;EACrD,YAAY"}
@@ -1,7 +1,11 @@
1
- export class BrowserAuthenticationCancelledError extends Error {
2
- constructor(message = "Browser authentication was cancelled.") {
3
- super(message);
4
- this.name = "BrowserAuthenticationCancelledError";
5
- }
6
- }
1
+ //#region src/utils/BrowserAuthenticationCancelledError.ts
2
+ var BrowserAuthenticationCancelledError = class extends Error {
3
+ constructor(message = "Browser authentication was cancelled.") {
4
+ super(message);
5
+ this.name = "BrowserAuthenticationCancelledError";
6
+ }
7
+ };
8
+ //#endregion
9
+ export { BrowserAuthenticationCancelledError };
10
+
7
11
  //# sourceMappingURL=BrowserAuthenticationCancelledError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserAuthenticationCancelledError.js","sourceRoot":"","sources":["../../src/utils/BrowserAuthenticationCancelledError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IAC1D,YAAY,OAAO,GAAG,uCAAuC;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC;IACtD,CAAC;CACJ"}
1
+ {"version":3,"file":"BrowserAuthenticationCancelledError.js","names":[],"sources":["../../src/utils/BrowserAuthenticationCancelledError.ts"],"sourcesContent":["export class BrowserAuthenticationCancelledError extends Error {\n constructor(message = \"Browser authentication was cancelled.\") {\n super(message);\n this.name = \"BrowserAuthenticationCancelledError\";\n }\n}\n"],"mappings":";AAAA,IAAa,sCAAb,cAAyD,MAAM;CAC3D,YAAY,UAAU,yCAAyC;EAC3D,MAAM,OAAO;EACb,KAAK,OAAO;CAChB;AACJ"}
@@ -0,0 +1,7 @@
1
+ import { Coordination } from "@party-stack/coordination";
2
+ import { PersistedCollectionPersistence } from "@tanstack/db-sqlite-persistence-core";
3
+ //#region src/utils/createCollectionPersistence.d.ts
4
+ /** Use the runtime coordinator while preserving the persistence factory's standard resolvers. */
5
+ export declare function createCollectionPersistence(coordination: Coordination, persistence: PersistedCollectionPersistence): PersistedCollectionPersistence;
6
+ //#endregion
7
+ //# sourceMappingURL=createCollectionPersistence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCollectionPersistence.d.ts","names":[],"sources":["../../src/utils/createCollectionPersistence.ts"],"mappings":";;;;wBAKgB,4BACZ,cAAc,cACd,aAAa,iCACd"}
@@ -0,0 +1,24 @@
1
+ import { createPersistedCollectionCoordinator } from "../coordinator/createPersistedCollectionCoordinator.js";
2
+ //#region src/utils/createCollectionPersistence.ts
3
+ /** Use the runtime coordinator while preserving the persistence factory's standard resolvers. */
4
+ function createCollectionPersistence(coordination, persistence) {
5
+ const coordinator = createPersistedCollectionCoordinator(coordination, persistence.adapter);
6
+ return {
7
+ ...persistence,
8
+ coordinator,
9
+ resolvePersistenceForMode: (mode) => ({
10
+ ...persistence.resolvePersistenceForMode?.(mode) ?? persistence,
11
+ coordinator
12
+ }),
13
+ resolvePersistenceForCollection: (context) => {
14
+ return {
15
+ ...persistence.resolvePersistenceForCollection?.(context) ?? persistence.resolvePersistenceForMode?.(context.mode) ?? persistence,
16
+ coordinator
17
+ };
18
+ }
19
+ };
20
+ }
21
+ //#endregion
22
+ export { createCollectionPersistence };
23
+
24
+ //# sourceMappingURL=createCollectionPersistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCollectionPersistence.js","names":[],"sources":["../../src/utils/createCollectionPersistence.ts"],"sourcesContent":["import { createPersistedCollectionCoordinator } from \"../coordinator/createPersistedCollectionCoordinator.js\";\nimport type { Coordination } from \"@party-stack/coordination\";\nimport type { PersistedCollectionPersistence } from \"@tanstack/db-sqlite-persistence-core\";\n\n/** Use the runtime coordinator while preserving the persistence factory's standard resolvers. */\nexport function createCollectionPersistence(\n coordination: Coordination,\n persistence: PersistedCollectionPersistence\n): PersistedCollectionPersistence {\n const coordinator = createPersistedCollectionCoordinator(coordination, persistence.adapter);\n return {\n ...persistence,\n coordinator,\n resolvePersistenceForMode: (mode) => ({\n ...(persistence.resolvePersistenceForMode?.(mode) ?? persistence),\n coordinator,\n }),\n resolvePersistenceForCollection: (context) => {\n const resolved =\n persistence.resolvePersistenceForCollection?.(context) ??\n persistence.resolvePersistenceForMode?.(context.mode) ??\n persistence;\n return { ...resolved, coordinator };\n },\n };\n}\n"],"mappings":";;;AAKA,SAAgB,4BACZ,cACA,aAC8B;CAC9B,MAAM,cAAc,qCAAqC,cAAc,YAAY,OAAO;CAC1F,OAAO;EACH,GAAG;EACH;EACA,4BAA4B,UAAU;GAClC,GAAI,YAAY,4BAA4B,IAAI,KAAK;GACrD;EACJ;EACA,kCAAkC,YAAY;GAK1C,OAAO;IAAE,GAHL,YAAY,kCAAkC,OAAO,KACrD,YAAY,4BAA4B,QAAQ,IAAI,KACpD;IACkB;GAAY;EACtC;CACJ;AACJ"}
@@ -1,2 +1,5 @@
1
- export declare const createDefaultRuntime: (owner: string, namespace: string) => import("../types.js").RuntimeAdapter;
1
+ import { RuntimeAdapter } from "../types.js";
2
+ //#region src/utils/createDefaultRuntime.d.ts
3
+ export declare const createDefaultRuntime: (owner: string, namespace: string) => RuntimeAdapter;
4
+ //#endregion
2
5
  //# sourceMappingURL=createDefaultRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createDefaultRuntime.d.ts","sourceRoot":"","sources":["../../src/utils/createDefaultRuntime.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,4EAc/B,CAAC"}
1
+ {"version":3,"file":"createDefaultRuntime.d.ts","names":["_$___types_js0.RuntimeAdapter"],"sources":["../../src/utils/createDefaultRuntime.ts"],"mappings":";;qBAIa,uBAAoB,eAAA,sBAApBA"}
@@ -1,15 +1,19 @@
1
- import { SingleProcessCoordination } from "@party-stack/coordination";
2
1
  import { MemoryBlobBytesStore } from "../memory/MemoryBlobBytesStore.js";
3
2
  import { defineRuntime } from "./defineRuntime.js";
4
- export const createDefaultRuntime = defineRuntime((owner, namespace) => {
5
- const scope = `party-stack:${owner}:${namespace}`;
6
- const coordination = new SingleProcessCoordination({ scope });
7
- return {
8
- owner,
9
- namespace,
10
- blobBytes: new MemoryBlobBytesStore(),
11
- coordination,
12
- cleanup: () => coordination.close(),
13
- };
3
+ import { SingleProcessCoordination } from "@party-stack/coordination";
4
+ //#region src/utils/createDefaultRuntime.ts
5
+ const createDefaultRuntime = defineRuntime((owner, namespace) => {
6
+ const scope = `party-stack:${owner}:${namespace}`;
7
+ const coordination = new SingleProcessCoordination({ scope });
8
+ return {
9
+ owner,
10
+ namespace,
11
+ blobBytes: new MemoryBlobBytesStore(),
12
+ coordination,
13
+ cleanup: () => coordination.close()
14
+ };
14
15
  });
16
+ //#endregion
17
+ export { createDefaultRuntime };
18
+
15
19
  //# sourceMappingURL=createDefaultRuntime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createDefaultRuntime.js","sourceRoot":"","sources":["../../src/utils/createDefaultRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC,CAC9C,KAAK,EACL,SAAS,EACX,EAAE;IACA,MAAM,KAAK,GAAG,eAAe,KAAK,IAAI,SAAS,EAAE,CAAC;IAClD,MAAM,YAAY,GACd,IAAI,yBAAyB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,OAAO;QACH,KAAK;QACL,SAAS;QACT,SAAS,EAAE,IAAI,oBAAoB,EAAE;QACrC,YAAY;QACZ,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE;KACtC,CAAC;AACN,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"createDefaultRuntime.js","names":[],"sources":["../../src/utils/createDefaultRuntime.ts"],"sourcesContent":["import { SingleProcessCoordination } from \"@party-stack/coordination\";\nimport { MemoryBlobBytesStore } from \"../memory/MemoryBlobBytesStore.js\";\nimport { defineRuntime } from \"./defineRuntime.js\";\n\nexport const createDefaultRuntime = defineRuntime((owner, namespace) => {\n const scope = `party-stack:${owner}:${namespace}`;\n const coordination = new SingleProcessCoordination({ scope });\n return {\n owner,\n namespace,\n blobBytes: new MemoryBlobBytesStore(),\n coordination,\n cleanup: () => coordination.close(),\n };\n});\n"],"mappings":";;;;AAIA,MAAa,uBAAuB,eAAe,OAAO,cAAc;CACpE,MAAM,QAAQ,eAAe,MAAM,GAAG;CACtC,MAAM,eAAe,IAAI,0BAA0B,EAAE,MAAM,CAAC;CAC5D,OAAO;EACH;EACA;EACA,WAAW,IAAI,qBAAqB;EACpC;EACA,eAAe,aAAa,MAAM;CACtC;AACJ,CAAC"}