foldkit-sync 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,9 @@
1
- import { Clock, Config, Context, Duration, Effect, Layer, Metric, PubSub, Schema, Scope } from "effect";
1
+ import { Config, Context, Duration, Effect, Exit, Layer, Metric, PubSub, Schema, Scope, Stream } from "effect";
2
+ import { UrlRequest } from "foldkit/navigation";
3
+ import { Subscriptions } from "foldkit/subscription";
4
+ import * as Url from "foldkit/url";
5
+ import { AppScope, Contract, MergeConstructors, MergeFields, MessageSet, RunnableApplication, Surface, WritableProjection } from "foldkit-surface";
6
+ import { Document, HtmlBuilder } from "foldkit/html";
2
7
  //#region src/errors.d.ts
3
8
  declare const StorageError_base: Schema.Class<StorageError, Schema.TaggedStruct<"StorageError", {
4
9
  readonly message: Schema.String;
@@ -25,6 +30,12 @@ declare const InvalidReplicaHistoryError_base: Schema.Class<InvalidReplicaHistor
25
30
  }>, import("effect/Cause").YieldableError>;
26
31
  /** The persisted replica history is internally inconsistent. */
27
32
  export declare class InvalidReplicaHistoryError extends InvalidReplicaHistoryError_base {}
33
+ declare const InvalidExchangeError_base: Schema.Class<InvalidExchangeError, Schema.TaggedStruct<"InvalidExchangeError", {
34
+ readonly message: Schema.String;
35
+ readonly cause: Schema.optional<Schema.Unknown>;
36
+ }>, import("effect/Cause").YieldableError>;
37
+ /** The server's exchange response did not match the protocol schema. */
38
+ export declare class InvalidExchangeError extends InvalidExchangeError_base {}
28
39
  declare const InvalidOutboxError_base: Schema.Class<InvalidOutboxError, Schema.TaggedStruct<"InvalidOutboxError", {
29
40
  readonly message: Schema.String;
30
41
  }>, import("effect/Cause").YieldableError>;
@@ -50,6 +61,16 @@ declare const ForeignRejectionError_base: Schema.Class<ForeignRejectionError, Sc
50
61
  }>, import("effect/Cause").YieldableError>;
51
62
  /** The server rejected an operation the replica never sent. */
52
63
  export declare class ForeignRejectionError extends ForeignRejectionError_base {}
64
+ declare const ForeignAcknowledgementError_base: Schema.Class<ForeignAcknowledgementError, Schema.TaggedStruct<"ForeignAcknowledgementError", {
65
+ readonly opId: Schema.String;
66
+ readonly message: Schema.String;
67
+ }>, import("effect/Cause").YieldableError>;
68
+ /**
69
+ * The server answered an operation this request never sent, or both
70
+ * acknowledged and rejected it. Acting on either would let a faulty or hostile
71
+ * server delete local work.
72
+ */
73
+ export declare class ForeignAcknowledgementError extends ForeignAcknowledgementError_base {}
53
74
  declare const ReplicaClosedError_base: Schema.Class<ReplicaClosedError, Schema.TaggedStruct<"ReplicaClosedError", {
54
75
  readonly message: Schema.String;
55
76
  }>, import("effect/Cause").YieldableError>;
@@ -62,18 +83,27 @@ declare const UnsupportedReplicaVersionError_base: Schema.Class<UnsupportedRepli
62
83
  }>, import("effect/Cause").YieldableError>;
63
84
  /** The stored replica state targets a protocol or schema version this build does not support. */
64
85
  export declare class UnsupportedReplicaVersionError extends UnsupportedReplicaVersionError_base {}
65
- type ReplicaError = StorageError | WrongReplicaStorageError | InvalidReplicaHistoryError | UnsupportedReplicaVersionError | InvalidOutboxError | CheckpointRegressionError | CommittedOrderError | ForeignRejectionError | ReplicaClosedError;
86
+ declare const ReplayError_base: Schema.Class<ReplayError, Schema.TaggedStruct<"ReplayError", {
87
+ readonly message: Schema.String;
88
+ readonly cause: Schema.optional<Schema.Unknown>;
89
+ }>, import("effect/Cause").YieldableError>;
90
+ /**
91
+ * `replay` threw for a submitted Message, so it could never be applied here or
92
+ * on any other replica; nothing was written.
93
+ */
94
+ export declare class ReplayError extends ReplayError_base {}
95
+ type ReplicaError = StorageError | ReplayError | WrongReplicaStorageError | InvalidReplicaHistoryError | InvalidExchangeError | UnsupportedReplicaVersionError | InvalidOutboxError | CheckpointRegressionError | CommittedOrderError | ForeignRejectionError | ForeignAcknowledgementError | ReplicaClosedError;
66
96
  //#endregion
67
97
  //#region src/indexedDb.d.ts
68
98
  /** Persists a replica's state with compare-and-swap on its revision. */
69
- interface Storage<State = unknown> {
99
+ interface Storage {
70
100
  load: () => Effect.Effect<unknown, StorageError>;
71
- save: (state: State, expectedRevision: number | null) => Effect.Effect<void, StorageError>;
101
+ save: (state: unknown, expectedRevision: number | null) => Effect.Effect<void, StorageError>;
72
102
  /** Idempotent; the caller closes the connection explicitly. */
73
103
  close: Effect.Effect<void>;
74
104
  }
75
105
  /** One database per document/replica; CAS prevents two tabs from sharing a writer identity. */
76
- export declare const indexedDb: <State = unknown>(name: Config.Config<string> | string, factory?: IDBFactory) => Effect.Effect<Storage<State>, StorageError, Scope.Scope>;
106
+ export declare const indexedDb: (name: string | Config.Config<string>, factory?: IDBFactory | undefined) => Effect.Effect<Storage, StorageError, Scope.Scope>;
77
107
  //#endregion
78
108
  //#region src/ids.d.ts
79
109
  /** Identifies the replicated document a replica or operation belongs to. */
@@ -85,75 +115,103 @@ export type ReplicaId = typeof ReplicaId.Type;
85
115
  /** The stable identity of one operation within a document. */
86
116
  export declare const OpId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/OpId">;
87
117
  export type OpId = typeof OpId.Type;
118
+ /**
119
+ * A position in the committed document order. `0` is the start; a committed
120
+ * operation's `serverSequence` and a replica's `cursor` are the same family.
121
+ */
122
+ export declare const Sequence: Schema.brand<Schema.Number, "@foldkit-sync/Sequence">;
123
+ export type Sequence = typeof Sequence.Type;
124
+ /** A replica's own operation counter within a document; 1-based. */
125
+ export declare const LocalSequence: Schema.brand<Schema.Number, "@foldkit-sync/LocalSequence">;
126
+ export type LocalSequence = typeof LocalSequence.Type;
88
127
  export declare const documentId: (value: string) => DocumentId;
89
128
  export declare const replicaId: (value: string) => ReplicaId;
90
129
  export declare const opId: (value: string) => OpId;
130
+ export declare const sequence: (value: number) => Sequence;
131
+ export declare const localSequence: (value: number) => LocalSequence;
91
132
  //#endregion
92
- //#region src/lww.d.ts
93
- /** A logical write time; replica ids break concurrent ties using UTF-16 order. */
94
- declare const Stamp: Schema.Struct<{
95
- readonly counter: Schema.Number;
96
- readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
97
- }>;
98
- declare const ClockState: Schema.Struct<{
99
- readonly schemaVersion: Schema.Literal<1>;
100
- readonly documentId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/DocumentId">;
101
- readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
102
- readonly revision: Schema.Number;
103
- }>;
104
- type LwwClockState = typeof ClockState.Type;
105
- interface LwwClock {
106
- /** Persists a timestamp beyond the saved counter and supplied observation. */
107
- next: (observedCounter?: number) => Effect.Effect<typeof Stamp.Type, StorageError>;
108
- /** Drains accepted allocations, then closes storage. Repeated calls no-op. */
109
- close: Effect.Effect<void>;
133
+ //#region src/transport.d.ts
134
+ declare const TransportError_base: Schema.Class<TransportError, Schema.TaggedStruct<"SyncTransportError", {
135
+ readonly message: Schema.String;
136
+ }>, import("effect/Cause").YieldableError>;
137
+ /** The wire failure of a transport. A refusal is a result, not an error. */
138
+ export declare class TransportError extends TransportError_base {}
139
+ /** One request/response frame, as it crosses a wire. */
140
+ interface ExchangeFrame {
141
+ readonly id: string;
142
+ readonly cursor: number;
143
+ readonly pending: ReadonlyArray<Operation>;
144
+ }
145
+ interface ExchangeReply {
146
+ readonly id: string;
147
+ readonly result?: unknown;
148
+ readonly error?: string;
149
+ }
150
+ interface TransportShape {
151
+ readonly exchange: (cursor: number, pending: ReadonlyArray<Operation>) => Effect.Effect<unknown, TransportError>;
110
152
  }
153
+ declare const Transport_base: Context.ServiceClass<Transport, "foldkit-sync/Transport", TransportShape>;
111
154
  /**
112
- * Opens a durable clock over the caller's storage.
155
+ * The seam the replica syncs through.
113
156
  *
114
- * Allocations are serialized through a `SynchronizedRef` and each persists before
115
- * its stamp is returned. A crash after the save may skip a timestamp but never
116
- * reuse one. Storage is owned by the caller; a failed open closes it so a partial
117
- * initialization does not leak the connection.
157
+ * A service, not a concrete client, so an application substitutes an in-process
158
+ * transport, a socket, or a test double without the replica knowing. A refusal
159
+ * arrives in the exchange result; only a wire failure is a `TransportError`.
118
160
  */
119
- export declare const openLwwClock: (options: {
120
- readonly documentId: DocumentId;
121
- readonly replicaId: ReplicaId;
122
- readonly storage: Storage<LwwClockState>;
123
- }) => Effect.Effect<LwwClock, StorageError | UnsupportedClockVersionError>;
161
+ export declare class Transport extends Transport_base {}
162
+ /** A transport backed by an in-process handler, for tests and single-process demos. */
163
+ export declare const layerLoopback: (handler: (cursor: number, pending: ReadonlyArray<Operation>) => unknown | Promise<unknown>) => Layer.Layer<Transport>;
164
+ /** Wraps the promise-based client the replica already speaks. */
165
+ export declare const layerFromPromise: (transport: TransportClient) => Layer.Layer<Transport>;
166
+ /** Bridges the service back to the promise client the replica consumes. */
167
+ export declare const toPromise: (transport: TransportShape) => TransportClient;
124
168
  /**
125
- * A schema and reducer helper for a last-writer-wins register.
126
- * Allocate a unique stamp per write before dispatch, and retain it in the Message.
127
- * Merge is for decoded values; the application's schema validates wire input.
169
+ * Serves one accepted socket, answering each exchange frame.
170
+ *
171
+ * The counterpart to `layerSocket`: the handler returns the exchange result, or
172
+ * throws and the failure is written back as an error frame. Returns a function
173
+ * that stops serving.
128
174
  */
129
- export declare const lwwRegister: <Value, Encoded, RD, RE>(value: Schema.Codec<Value, Encoded, RD, RE>) => {
130
- schema: Schema.Struct<{
131
- readonly stamp: Schema.Struct<{
132
- readonly counter: Schema.Number;
133
- readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
134
- }>;
135
- readonly value: Schema.Codec<Value, Encoded, RD, RE>;
136
- }>;
137
- merge: (left: {
138
- readonly stamp: {
139
- readonly counter: number;
140
- readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
141
- };
142
- readonly value: Value;
143
- }, right: {
144
- readonly stamp: {
145
- readonly counter: number;
146
- readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
147
- };
148
- readonly value: Value;
149
- }) => {
150
- readonly stamp: {
151
- readonly counter: number;
152
- readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
153
- };
154
- readonly value: Value;
155
- };
156
- };
175
+ export declare const serveSocket: (socket: SocketLike, options: {
176
+ readonly exchange: (cursor: number, pending: ReadonlyArray<Operation>) => unknown | Promise<unknown>;
177
+ }) => (() => void);
178
+ /** The minimal socket the layer needs; the global `WebSocket` satisfies it. */
179
+ interface SocketLike {
180
+ send(data: string): void;
181
+ close(): void;
182
+ onMessage(listener: (data: string) => void): () => void;
183
+ onClose(listener: () => void): () => void;
184
+ /**
185
+ * Optional. When provided, exchanges wait for it before sending, so a
186
+ * transport can connect asynchronously. Absent means already connected.
187
+ */
188
+ onOpen?(listener: () => void): () => void;
189
+ }
190
+ interface SocketOptions {
191
+ readonly url: string;
192
+ /** Injectable for tests; defaults to the platform `WebSocket`. */
193
+ readonly makeSocket?: ((url: string) => SocketLike) | undefined;
194
+ /** Reconnect attempts after a close before queued work fails. Default 5. */
195
+ readonly maxRetries?: number | undefined;
196
+ /** Base delay of the exponential reconnect backoff. Default `50 millis`. */
197
+ readonly retryBase?: Duration.Input | undefined;
198
+ /** Exchanges queued or in flight before new ones fail. Default 64. */
199
+ readonly maxQueue?: number | undefined;
200
+ }
201
+ /** The default socket factory: the platform `WebSocket`, as a `SocketLike`. */
202
+ export declare const nativeSocket: (url: string) => SocketLike;
203
+ /**
204
+ * A WebSocket client transport.
205
+ *
206
+ * One connection is live at a time. While it is connecting, exchanges queue; if
207
+ * it closes, the transport reconnects on an exponential, jittered backoff and
208
+ * re-sends every queued and in-flight frame with its original id, so a lost
209
+ * reply is answered rather than dropped and a late reply cannot resolve a newer
210
+ * frame. Once the retries are exhausted (or the layer closes) queued work fails
211
+ * with a `TransportError`; a queue over `maxQueue` fails new exchanges with
212
+ * backpressure. The socket is released when the layer's scope ends.
213
+ */
214
+ export declare const layerSocket: (options: SocketOptions) => Layer.Layer<Transport, TransportError>;
157
215
  //#endregion
158
216
  //#region src/sync.d.ts
159
217
  /** Wire and persisted-format versions. A bump must handle the older value explicitly. */
@@ -165,26 +223,27 @@ declare const OperationSchema: Schema.Struct<{
165
223
  readonly schemaVersion: Schema.Literal<1>;
166
224
  readonly documentId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/DocumentId">;
167
225
  readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
168
- readonly localSequence: Schema.Number;
226
+ readonly localSequence: Schema.brand<Schema.Number, "@foldkit-sync/LocalSequence">;
169
227
  readonly opId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/OpId">;
170
- readonly baseCursor: Schema.Number;
228
+ readonly baseCursor: Schema.brand<Schema.Number, "@foldkit-sync/Sequence">;
171
229
  readonly message: Schema.Unknown;
172
230
  }>;
173
231
  type Operation = typeof OperationSchema.Type;
174
232
  /** An operation the server committed, with its authoritative order and actor. */
175
233
  declare const CommittedSchema: Schema.Struct<{
176
- readonly serverSequence: Schema.Number;
234
+ readonly serverSequence: Schema.brand<Schema.Number, "@foldkit-sync/Sequence">;
177
235
  readonly actorId: Schema.NonEmptyString;
178
236
  readonly protocolVersion: Schema.Literal<1>;
179
237
  readonly schemaVersion: Schema.Literal<1>;
180
238
  readonly documentId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/DocumentId">;
181
239
  readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
182
- readonly localSequence: Schema.Number;
240
+ readonly localSequence: Schema.brand<Schema.Number, "@foldkit-sync/LocalSequence">;
183
241
  readonly opId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/OpId">;
184
- readonly baseCursor: Schema.Number;
242
+ readonly baseCursor: Schema.brand<Schema.Number, "@foldkit-sync/Sequence">;
185
243
  readonly message: Schema.Unknown;
186
244
  }>;
187
- type Committed = typeof CommittedSchema.Type;
245
+ /** Named to avoid colliding with `foldkit-durable`'s `Committed`. */
246
+ type CommittedOperation = typeof CommittedSchema.Type;
188
247
  /** Counters and a histogram an application can scrape. */
189
248
  export declare const syncMetrics: {
190
249
  exchanges: Metric.Counter<number>;
@@ -193,10 +252,11 @@ export declare const syncMetrics: {
193
252
  exchangePending: Metric.Histogram<number>;
194
253
  };
195
254
  interface Checkpoint<Shared> {
196
- readonly cursor: number;
255
+ readonly cursor: Sequence;
197
256
  readonly model: Shared;
198
257
  }
199
258
  interface Exchange<Shared> {
259
+ /** Server-committed operations as they arrived; validated against `CommittedOperation` on adoption. */
200
260
  readonly operations: ReadonlyArray<unknown>;
201
261
  readonly rejected: ReadonlyArray<OpId>;
202
262
  /** Sends from the request that are durably committed, so the replica can drop them. */
@@ -207,11 +267,11 @@ interface Exchange<Shared> {
207
267
  interface ReplicaState<Shared> {
208
268
  readonly protocolVersion: typeof PROTOCOL_VERSION;
209
269
  readonly schemaVersion: typeof SCHEMA_VERSION;
210
- readonly documentId: string;
211
- readonly replicaId: string;
270
+ readonly documentId: DocumentId;
271
+ readonly replicaId: ReplicaId;
212
272
  readonly revision: number;
213
- readonly nextLocalSequence: number;
214
- readonly cursor: number;
273
+ readonly nextLocalSequence: LocalSequence;
274
+ readonly cursor: Sequence;
215
275
  readonly committed: Shared;
216
276
  readonly committedIds: ReadonlyArray<string>;
217
277
  readonly pending: ReadonlyArray<Operation>;
@@ -221,27 +281,52 @@ interface ReplicaState<Shared> {
221
281
  * is the primary seam.
222
282
  */
223
283
  interface TransportClient {
224
- exchange(cursor: number, pending: ReadonlyArray<Operation>): Promise<unknown>;
284
+ exchange(cursor: Sequence, pending: ReadonlyArray<Operation>): Promise<unknown>;
225
285
  }
226
286
  /** A redacted view of a replica's state, for a UI to explain and recover. */
227
287
  interface ReplicaStatus {
228
288
  readonly pending: number;
229
- readonly cursor: number;
289
+ readonly cursor: Sequence;
230
290
  /** The last exchange failure, cleared by a successful exchange. */
231
291
  readonly lastError: string | undefined;
232
292
  /** Operations the server refused, most recent first. */
233
293
  readonly rejected: ReadonlyArray<OpId>;
234
294
  }
295
+ /**
296
+ * A consistent status and optimistic-shared pair, read from one replica state.
297
+ * `Replica.changes` emits it so a UI can hold a single subscription.
298
+ */
299
+ interface ReplicaSnapshot<Shared> {
300
+ readonly status: ReplicaStatus;
301
+ readonly shared: Shared;
302
+ }
235
303
  interface Replica<Message, Shared> {
236
304
  /** The optimistic projection: committed state with pending operations replayed. */
237
305
  readonly shared: Effect.Effect<Shared>;
238
306
  readonly pending: Effect.Effect<ReadonlyArray<Operation>>;
239
- readonly cursor: Effect.Effect<number>;
240
- /** Waiting/recovery information without exposing Messages or the Model. */
307
+ readonly cursor: Effect.Effect<Sequence>;
308
+ /**
309
+ * Waiting/recovery information without exposing Messages or the Model. It is a
310
+ * snapshot; `statusChanges` re-emits it after every submit and exchange.
311
+ */
241
312
  readonly status: Effect.Effect<ReplicaStatus>;
313
+ /** The status, re-emitted after every submit and exchange. */
314
+ readonly statusChanges: Stream.Stream<ReplicaStatus>;
315
+ /**
316
+ * The status and the optimistic shared value together, re-emitted after every
317
+ * submit and exchange, so a UI can subscribe once instead of to both.
318
+ */
319
+ readonly changes: Stream.Stream<ReplicaSnapshot<Shared>>;
242
320
  readonly submit: (message: Message) => Effect.Effect<void, ReplicaError>;
243
321
  /** Reconciles against the server. The `Transport` service must be provided. */
244
322
  readonly synchronize: Effect.Effect<void, ReplicaError | TransportError, Transport>;
323
+ /**
324
+ * The exchange loop: exchanges once, then after every `submit`, until the
325
+ * replica closes or the fiber is interrupted. A transport failure is recorded
326
+ * in `status.lastError` and retried on the next wake, so the fiber never
327
+ * fails. Fork it with `Effect.forkScoped` and provide `Transport`.
328
+ */
329
+ readonly start: Effect.Effect<void, never, Transport>;
245
330
  readonly close: Effect.Effect<void>;
246
331
  }
247
332
  interface SyncDefinition<Message, Shared, MessageEncoded, SharedEncoded> {
@@ -254,11 +339,34 @@ interface SyncDefinition<Message, Shared, MessageEncoded, SharedEncoded> {
254
339
  }
255
340
  interface Sync<Message, Shared> {
256
341
  readonly documentId: DocumentId;
257
- readonly normalizeOperation: (input: unknown) => Operation;
258
- readonly operationFrom: (input: unknown, documentId: DocumentId) => Operation;
259
- readonly committedFrom: (input: unknown, documentId: DocumentId) => Committed;
260
- readonly decodeExchange: (input: unknown) => Exchange<Shared>;
261
- readonly openReplica: (replicaId: ReplicaId, storage: Storage<ReplicaState<Shared>>) => Effect.Effect<Replica<Message, Shared>, ReplicaError>;
342
+ /**
343
+ * Low-level wire codecs for adapters and the transport. Most applications use
344
+ * `journalContract` and `openReplica`; these are exposed for a custom
345
+ * transport or a server that must speak the operation envelope directly.
346
+ */
347
+ readonly codec: {
348
+ readonly normalizeOperation: (input: unknown) => Operation;
349
+ readonly operationFrom: (input: unknown, documentId: DocumentId) => Operation;
350
+ readonly committedFrom: (input: unknown, documentId: DocumentId) => CommittedOperation;
351
+ readonly decodeExchange: (input: unknown) => Exchange<Shared>;
352
+ };
353
+ /** The codecs and pure reducer `foldkit-durable`'s `makeJournal` consumes. */
354
+ readonly journalContract: () => JournalContract<Operation, Shared>;
355
+ readonly openReplica: (replicaId: ReplicaId, storage: Storage) => Effect.Effect<Replica<Message, Shared>, ReplicaError>;
356
+ }
357
+ /** Structural match for `foldkit-durable`'s journal options; Sync stays independent. */
358
+ interface JournalContract<Operation, Shared> {
359
+ readonly operation: {
360
+ /** Operations are stored in their encoded form, so this is the identity. */
361
+ readonly encode: (operation: Operation) => Operation;
362
+ readonly decode: (input: unknown) => Operation;
363
+ };
364
+ readonly snapshot: {
365
+ readonly encode: (snapshot: Shared) => unknown;
366
+ readonly decode: (input: unknown) => Shared;
367
+ };
368
+ readonly empty: () => Shared;
369
+ readonly reduce: (snapshot: Shared, operation: Operation) => Shared;
262
370
  }
263
371
  /**
264
372
  * Binds the replicated-state protocol to one application contract.
@@ -269,88 +377,244 @@ interface Sync<Message, Shared> {
269
377
  */
270
378
  export declare const defineSync: <Message, Shared, MessageEncoded, SharedEncoded>(definition: SyncDefinition<Message, Shared, MessageEncoded, SharedEncoded>) => Sync<Message, Shared>;
271
379
  //#endregion
272
- //#region src/transport.d.ts
273
- declare const TransportError_base: Schema.Class<TransportError, Schema.TaggedStruct<"SyncTransportError", {
274
- readonly message: Schema.String;
275
- }>, import("effect/Cause").YieldableError>;
276
- /** The wire failure of a transport. A refusal is a result, not an error. */
277
- export declare class TransportError extends TransportError_base {}
278
- /** One request/response frame, as it crosses a wire. */
279
- interface ExchangeFrame {
280
- readonly id: string;
281
- readonly cursor: number;
282
- readonly pending: ReadonlyArray<Operation>;
380
+ //#region src/make.d.ts
381
+ type MessageConstructor<Message> = (...args: never[]) => Message;
382
+ /** The Message union a tuple of constructors produces. */
383
+ type MsgOf<Ms extends readonly unknown[]> = Ms[number] extends ((...args: never[]) => infer M) ? M : never;
384
+ type AppMessage<AppModel, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>> = Schema.Schema.Type<AppScope<AppModel, F, Cases>['Message']>;
385
+ /** The `_tag` literal of the Message a constructor produces. */
386
+ type TagOf<C> = C extends ((...args: never[]) => infer M) ? M extends {
387
+ readonly _tag: infer T extends string;
388
+ } ? T : never : never;
389
+ /**
390
+ * A journal contract that also carries the declared authorization policy, in
391
+ * the shape `makeJournal` takes, so `makeJournal({ ...contract })` applies it.
392
+ */
393
+ interface PolicyJournalContract<Operation, Shared, Principal> extends JournalContract<Operation, Shared> {
394
+ readonly authorize?: (request: {
395
+ readonly principal: Principal;
396
+ readonly operation: Operation;
397
+ readonly snapshot: Shared;
398
+ }) => boolean;
283
399
  }
284
- interface ExchangeReply {
285
- readonly id: string;
286
- readonly result?: unknown;
287
- readonly error?: string;
400
+ /** What a per-variant `authorize` rule sees before the journal commits. */
401
+ interface AuthorizeRequest<Principal, Message, Shared> {
402
+ readonly principal: Principal;
403
+ readonly message: Message;
404
+ readonly shared: Shared;
288
405
  }
289
- interface TransportShape {
290
- readonly exchange: (cursor: number, pending: ReadonlyArray<Operation>) => Effect.Effect<unknown, TransportError>;
406
+ /**
407
+ * Per-variant policy, keyed by durable tag: `message` is that variant exactly,
408
+ * `shared` the authoritative snapshot. A variant without a rule is allowed; the
409
+ * server may still refuse on its own grounds.
410
+ */
411
+ type AuthorizePolicy<Principal, Fields extends Schema.Struct.Fields, Ms extends readonly unknown[]> = { readonly [K in TagOf<Ms[number]>]?: (request: AuthorizeRequest<Principal, Extract<MsgOf<Ms>, {
412
+ readonly _tag: K;
413
+ }>, Schema.Struct.Type<Fields>>) => boolean; };
414
+ interface BaseOptions<Principal, Fields extends Schema.Struct.Fields, Ms extends readonly unknown[]> {
415
+ readonly documentId: DocumentId;
416
+ /** Name for the generated `surface`; defaults to the document id. */
417
+ readonly name?: string;
418
+ /**
419
+ * Replaces the replay derived from the application's `update`. It is a pure
420
+ * reducer over the shared subset; only durable Messages reach it, and it runs
421
+ * during admission, replay, and optimistic projection. It is not guarded: the
422
+ * author owns its agreement with `update`.
423
+ */
424
+ readonly replay?: (shared: Schema.Struct.Type<NoInfer<Fields>>, message: MsgOf<NoInfer<Ms>>) => Schema.Struct.Type<NoInfer<Fields>>;
425
+ /** Authorization the server journal applies before committing; see `AuthorizePolicy`. */
426
+ readonly authorize?: AuthorizePolicy<Principal, NoInfer<Fields>, NoInfer<Ms>>;
427
+ }
428
+ interface MakeOptions<AppModel, Fields extends Schema.Struct.Fields, Subset, Ms extends readonly MessageConstructor<any>[], Principal = unknown> extends BaseOptions<Principal, Fields, Ms> {
429
+ /** The writable projection of the shared fields. */
430
+ readonly shared: WritableProjection<AppModel, Fields>;
431
+ /** The Message subset the replica durably records and replays. */
432
+ readonly durable: MessageSet<AppModel, any, Subset, Ms>;
291
433
  }
292
- declare const Transport_base: Context.ServiceClass<Transport, "foldkit-sync/Transport", TransportShape>;
293
434
  /**
294
- * The seam the replica syncs through.
295
- *
296
- * A service, not a concrete client, so an application substitutes an in-process
297
- * transport, a socket, or a test double without the replica knowing. A refusal
298
- * arrives in the exchange result; only a wire failure is a `TransportError`.
435
+ * One feature's contribution to a document: the fields it shares and the
436
+ * Messages it records. `compose` merges fragments into one, to spread into
437
+ * `make`; a field declared twice with a different codec or a tag declared twice
438
+ * is rejected there.
299
439
  */
300
- export declare class Transport extends Transport_base {}
301
- /** A transport backed by an in-process handler, for tests and single-process demos. */
302
- export declare const layerLoopback: (handler: (cursor: number, pending: ReadonlyArray<Operation>) => unknown | Promise<unknown>) => Layer.Layer<Transport>;
303
- /** Wraps the promise-based client the replica already speaks. */
304
- export declare const layerFromPromise: (transport: TransportClient) => Layer.Layer<Transport>;
305
- /** Bridges the service back to the promise client the replica consumes. */
306
- export declare const toPromise: (transport: TransportShape) => TransportClient;
440
+ interface SyncFragment<AppModel, Fields extends Schema.Struct.Fields, Subset, Ms extends readonly MessageConstructor<any>[]> {
441
+ readonly shared: WritableProjection<AppModel, Fields>;
442
+ readonly durable: MessageSet<AppModel, any, Subset, Ms>;
443
+ }
444
+ type SharedOf<Fs extends readonly SyncFragment<any, any, any, any>[]> = { readonly [K in keyof Fs]: Fs[K]['shared']; };
445
+ type DurableOf<Fs extends readonly SyncFragment<any, any, any, any>[]> = { readonly [K in keyof Fs]: Fs[K]['durable']; };
446
+ /** The merged shared fields of several fragments. */
447
+ type FragmentFields<Fs extends readonly SyncFragment<any, any, any, any>[]> = MergeFields<SharedOf<Fs>>;
448
+ /** The concatenated durable constructors of several fragments. */
449
+ type FragmentConstructors<Fs extends readonly SyncFragment<any, any, any, any>[]> = MergeConstructors<DurableOf<Fs>>;
450
+ /** The union of Messages several fragments record. */
451
+ type FragmentMessages<Fs extends readonly SyncFragment<any, any, any, any>[]> = Fs[number] extends SyncFragment<any, any, infer V, any> ? V : never;
307
452
  /**
308
- * Serves one accepted socket, answering each exchange frame.
309
- *
310
- * The counterpart to `layerSocket`: the handler returns the exchange result, or
311
- * throws and the failure is written back as an error frame. Returns a function
312
- * that stops serving.
453
+ * The value `make` returns: the low-level `Sync` protocol plus the writable
454
+ * projection, the declared Messages, and a read-only Surface over the
455
+ * projection. Exported so a consumer can name the type.
313
456
  */
314
- export declare const serveSocket: (socket: SocketLike, options: {
315
- readonly exchange: (cursor: number, pending: ReadonlyArray<Operation>) => unknown | Promise<unknown>;
316
- }) => (() => void);
317
- /** The minimal socket the layer needs; the global `WebSocket` satisfies it. */
318
- interface SocketLike {
319
- send(data: string): void;
320
- close(): void;
321
- onMessage(listener: (data: string) => void): () => void;
322
- onClose(listener: () => void): () => void;
457
+ interface DefinedSync<AppModel, Fields extends Schema.Struct.Fields, Message, Ms extends readonly unknown[], Principal = unknown> extends Sync<Message, Schema.Struct.Type<Fields>> {
458
+ readonly surface: Surface<AppModel, Schema.Struct.Type<Fields>, MsgOf<Ms>, void>;
459
+ readonly projection: WritableProjection<AppModel, Fields>;
460
+ readonly messages: Ms;
461
+ /** For `Module`: this contract owns the shared projection's paths and records the durable tags. */
462
+ readonly contract: Contract;
463
+ /** The durable journal's codecs, reducer, and, when declared, authorization. */
464
+ readonly journalContract: () => PolicyJournalContract<Operation, Schema.Struct.Type<Fields>, Principal>;
465
+ }
466
+ /** The sync constructors specialized to one application. */
467
+ interface ApplicationSync<AppModel, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>, Principal = unknown> {
323
468
  /**
324
- * Optional. When provided, exchanges wait for it before sending, so a
325
- * transport can connect asynchronously. Absent means already connected.
469
+ * Fixes the `Principal` that `authorize` rules see. A `Principal` cannot be a
470
+ * positional type argument beside an inferred Model, so it is supplied here:
471
+ * `Sync.forApplication(App).withPrincipal<User>()`. Type-only.
326
472
  */
327
- onOpen?(listener: () => void): () => void;
473
+ readonly withPrincipal: <P>() => ApplicationSync<AppModel, F, Cases, P>;
474
+ /** One feature's shared fields and durable Messages, for `compose`. */
475
+ readonly fragment: <Fields extends Schema.Struct.Fields, Subset, Ms extends readonly MessageConstructor<AppMessage<AppModel, F, Cases>>[]>(config: {
476
+ readonly shared: WritableProjection<AppModel, Fields>;
477
+ readonly durable: MessageSet<AppModel, any, Subset, Ms>;
478
+ }) => SyncFragment<AppModel, Fields, Subset, Ms>;
479
+ /**
480
+ * Merges fragments into one: `make({ documentId, ...compose(Todos, Members) })`.
481
+ * A field declared twice with a different codec, a tag declared twice, or a
482
+ * fragment from another application throws.
483
+ */
484
+ readonly compose: <const Fs extends readonly SyncFragment<AppModel, any, any, any>[]>(...fragments: Fs) => SyncFragment<AppModel, FragmentFields<Fs>, FragmentMessages<Fs>, FragmentConstructors<Fs>>;
485
+ readonly make: <Fields extends Schema.Struct.Fields, Subset, Ms extends readonly MessageConstructor<AppMessage<AppModel, F, Cases>>[]>(options: MakeOptions<AppModel, Fields, Subset, Ms, Principal>) => DefinedSync<AppModel, Fields, AppMessage<AppModel, F, Cases>, Ms, Principal>;
328
486
  }
329
- interface SocketOptions {
330
- readonly url: string;
331
- /** Injectable for tests; defaults to the platform `WebSocket`. */
332
- readonly makeSocket?: ((url: string) => SocketLike) | undefined;
333
- /** Reconnect attempts after a close before queued work fails. Default 5. */
334
- readonly maxRetries?: number | undefined;
335
- /** Base delay of the exponential reconnect backoff. Default `50 millis`. */
336
- readonly retryBase?: Duration.Input | undefined;
337
- /** Exchanges queued or in flight before new ones fail. Default 64. */
338
- readonly maxQueue?: number | undefined;
487
+ /**
488
+ * Specializes the sync constructors to a `Surface.application`, so
489
+ * `Sync.forApplication(App).make({ documentId, shared, durable })` derives the
490
+ * shared codec, the initial snapshot, the durable predicate, and replay from
491
+ * the application, and refuses a subset that belongs to another application.
492
+ * `defineSync` remains the protocol primitive when there is no application to
493
+ * derive from.
494
+ */
495
+ export declare const forApplication: <AppModel, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>>(app: RunnableApplication<AppModel, F, Cases, any>) => ApplicationSync<AppModel, F, Cases>;
496
+ //#endregion
497
+ //#region src/mount.d.ts
498
+ /**
499
+ * The URL as part of the application: `onUrlChange` names the Message the
500
+ * runtime sends for the current URL at start and on every navigation (so a
501
+ * `foldkit-mirror` URL mirror reads back in), `init` reduces the URL into the
502
+ * Model before the first render, and `onUrlRequest` names the Message for a
503
+ * link click; omitted, the mount follows the link itself (an internal one is
504
+ * pushed, an external one loaded).
505
+ */
506
+ interface MountUrl<Model, Message> {
507
+ readonly init?: ((model: Model, url: Url.Url) => Model) | undefined;
508
+ readonly onUrlChange: (url: Url.Url) => Message;
509
+ readonly onUrlRequest?: ((request: UrlRequest) => Message) | undefined;
510
+ }
511
+ interface MountOptions<Model, Message, Shared, Resources> {
512
+ /** An open replica of this contract; `mount` does not close it. */
513
+ readonly replica: Replica<Message, Shared>;
514
+ /** The element the application renders into; Foldkit requires it to have an `id`. */
515
+ readonly container: HTMLElement;
516
+ readonly view: (model: Model, h: HtmlBuilder<Message>) => Document;
517
+ readonly subscriptions?: Subscriptions<Model, Message, Resources> | undefined;
518
+ readonly resources?: Layer.Layer<Resources> | undefined;
519
+ /** Route the URL through the application; without it the mount ignores the URL. */
520
+ readonly url?: MountUrl<Model, Message> | undefined;
521
+ /**
522
+ * Reflects a refused or failed persist in the Model, after the durable edit
523
+ * has been reverted. Omitted, the edit is reverted silently.
524
+ */
525
+ readonly onPersistenceFailure?: ((model: Model, error: ReplicaError) => Model) | undefined;
526
+ }
527
+ interface Mounted<Model, Message> {
528
+ /** Sends an application Message through the runtime; the `Exit` reports a decode failure. */
529
+ readonly dispatch: (message: Message) => Exit.Exit<void, unknown>;
530
+ /** The Model after the last transition. */
531
+ readonly model: () => Model;
532
+ /** Notified after every transition; with `model` and `dispatch`, the host an agent binds to. */
533
+ readonly subscribe: (listener: () => void) => () => void;
534
+ /**
535
+ * Every application Message the runtime applies, from any origin, so an
536
+ * agent contract that declares a `completion` can see the Message that
537
+ * finishes its work. The mount's private Messages are not reported.
538
+ */
539
+ readonly observe: (listener: (message: Message) => void) => () => void;
540
+ /** Waits for in-flight persists, then disposes the runtime. The replica stays open. */
541
+ readonly dispose: () => Promise<void>;
542
+ }
543
+ /** The application's Message union, as `Surface.application` types it. */
544
+ type MessageOf<App> = App extends RunnableApplication<any, any, any, any> ? Schema.Schema.Type<App['Message']> : never;
545
+ export declare const mount: <Model, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>, Fields extends Schema.Struct.Fields, Ms extends readonly unknown[], Resources = never, Principal = unknown>(app: RunnableApplication<Model, F, Cases, Resources>, sync: DefinedSync<Model, Fields, MessageOf<RunnableApplication<Model, F, Cases, Resources>>, Ms, Principal>, options: MountOptions<Model, MessageOf<RunnableApplication<Model, F, Cases, Resources>>, Schema.Struct.Type<Fields>, Resources>) => Mounted<Model, MessageOf<RunnableApplication<Model, F, Cases, Resources>>>;
546
+ //#endregion
547
+ //#region src/lww.d.ts
548
+ /** A logical write time; replica ids break concurrent ties using UTF-16 order. */
549
+ declare const Stamp: Schema.Struct<{
550
+ readonly counter: Schema.Number;
551
+ readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
552
+ }>;
553
+ declare const ClockState: Schema.Struct<{
554
+ readonly schemaVersion: Schema.Literal<1>;
555
+ readonly documentId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/DocumentId">;
556
+ readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
557
+ readonly revision: Schema.Number;
558
+ }>;
559
+ type LwwClockState = typeof ClockState.Type;
560
+ interface LwwClock {
561
+ /** Persists a timestamp beyond the saved counter and supplied observation. */
562
+ next: (observedCounter?: number) => Effect.Effect<typeof Stamp.Type, StorageError>;
563
+ /** Drains accepted allocations, then closes storage. Repeated calls no-op. */
564
+ close: Effect.Effect<void>;
339
565
  }
340
- /** The default socket factory: the platform `WebSocket`, as a `SocketLike`. */
341
- export declare const nativeSocket: (url: string) => SocketLike;
342
566
  /**
343
- * A WebSocket client transport.
567
+ * Opens a durable clock over the caller's storage.
344
568
  *
345
- * One connection is live at a time. While it is connecting, exchanges queue; if
346
- * it closes, the transport reconnects on an exponential, jittered backoff and
347
- * re-sends every queued and in-flight frame with its original id, so a lost
348
- * reply is answered rather than dropped and a late reply cannot resolve a newer
349
- * frame. Once the retries are exhausted (or the layer closes) queued work fails
350
- * with a `TransportError`; a queue over `maxQueue` fails new exchanges with
351
- * backpressure. The socket is released when the layer's scope ends.
569
+ * Allocations are serialized through a `SynchronizedRef` and each persists before
570
+ * its stamp is returned. A crash after the save may skip a timestamp but never
571
+ * reuse one. Storage is owned by the caller; a failed open closes it so a partial
572
+ * initialization does not leak the connection.
352
573
  */
353
- export declare const layerSocket: (options: SocketOptions) => Layer.Layer<Transport, TransportError>;
574
+ export declare const openLwwClock: (options: {
575
+ readonly documentId: DocumentId;
576
+ readonly replicaId: ReplicaId;
577
+ readonly storage: Storage;
578
+ }) => Effect.Effect<{
579
+ next: (observedCounter?: any) => Effect.Effect<{
580
+ readonly counter: number;
581
+ readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
582
+ }, StorageError, never>;
583
+ close: Effect.Effect<void, never, never>;
584
+ }, StorageError | UnsupportedClockVersionError, never>;
585
+ /**
586
+ * A schema and reducer helper for a last-writer-wins register.
587
+ * Allocate a unique stamp per write before dispatch, and retain it in the Message.
588
+ * Merge is for decoded values; the application's schema validates wire input.
589
+ */
590
+ export declare const lwwRegister: <Value, Encoded, RD, RE>(value: Schema.Codec<Value, Encoded, RD, RE>) => {
591
+ schema: Schema.Struct<{
592
+ readonly stamp: Schema.Struct<{
593
+ readonly counter: Schema.Number;
594
+ readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
595
+ }>;
596
+ readonly value: Schema.Codec<Value, Encoded, RD, RE>;
597
+ }>;
598
+ merge: (left: {
599
+ readonly stamp: {
600
+ readonly counter: number;
601
+ readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
602
+ };
603
+ readonly value: Value;
604
+ }, right: {
605
+ readonly stamp: {
606
+ readonly counter: number;
607
+ readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
608
+ };
609
+ readonly value: Value;
610
+ }) => {
611
+ readonly stamp: {
612
+ readonly counter: number;
613
+ readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
614
+ };
615
+ readonly value: Value;
616
+ };
617
+ };
354
618
  //#endregion
355
619
  //#region src/presence.d.ts
356
620
  /** One peer's presence. A `null` value means the peer left. */
@@ -399,6 +663,11 @@ interface Presence<Update> {
399
663
  readonly prune: Effect.Effect<void>;
400
664
  /** Notified when the peer set changes. */
401
665
  readonly subscribe: (listener: () => void) => () => void;
666
+ /**
667
+ * The live peers, re-emitted whenever the set changes. The `Stream` form of
668
+ * `subscribe`, for a consumer that composes with Effect.
669
+ */
670
+ readonly changes: Stream.Stream<ReadonlyArray<PresencePeer<Update>>>;
402
671
  /** Stops consuming the channel; the enclosing scope also does this on exit. */
403
672
  readonly close: Effect.Effect<void>;
404
673
  }
@@ -409,9 +678,28 @@ interface Presence<Update> {
409
678
  * a peer that stops refreshing is dropped, not replayed. Time comes from the
410
679
  * `Clock`, so a `TestClock` drives the TTL deterministically.
411
680
  */
412
- export declare const createPresence: <Update>(options: PresenceOptions<Update>) => Effect.Effect<Presence<Update>, never, Scope.Scope | Clock.Clock>;
681
+ export declare const createPresence: <Update>(options: PresenceOptions<Update>) => Effect.Effect<{
682
+ set: (value: Update) => Effect.Effect<void, never, never>;
683
+ leave: Effect.Effect<void, never, never>;
684
+ peers: Effect.Effect<{
685
+ id: string;
686
+ value: Update;
687
+ updatedAt: number;
688
+ }[], never, never>;
689
+ prune: Effect.Effect<void, never, never>;
690
+ subscribe: (listener: () => void) => () => boolean;
691
+ changes: Stream.Stream<{
692
+ id: string;
693
+ value: Update;
694
+ updatedAt: number;
695
+ }[], never, never>;
696
+ close: Effect.Effect<void, never, never>;
697
+ }, never, Scope.Scope>;
413
698
  /** An in-process channel, for tests and single-process demos. */
414
- export declare const loopbackPresenceChannel: <Update>() => Effect.Effect<PresenceChannel<Update>>;
699
+ export declare const loopbackPresenceChannel: <Update>() => Effect.Effect<{
700
+ updates: PubSub.PubSub<PresenceUpdate<Update>>;
701
+ publish: (update: PresenceUpdate<Update>) => Effect.Effect<boolean, never, never>;
702
+ }, never, never>;
415
703
  /** Broadcasts presence updates among connected peers. */
416
704
  interface PresenceHub<Update> {
417
705
  /** Registers a peer's send; returns a leave function. */
@@ -420,10 +708,15 @@ interface PresenceHub<Update> {
420
708
  publish(update: PresenceUpdate<Update>): void;
421
709
  }
422
710
  export declare const createPresenceHub: <Update>() => PresenceHub<Update>;
423
- /** A presence channel fed by frames arriving on a socket, sent back over it. */
711
+ /**
712
+ * A presence channel fed by stamped frames from the server, sent back without an
713
+ * id: the server owns peer identity, so a client cannot assert another's.
714
+ */
424
715
  export declare const socketPresenceChannel: <Update>(socket: SocketLike) => Effect.Effect<PresenceChannel<Update>, never, Scope.Scope>;
425
- /** Serves presence frames on an accepted socket, fanning them through the hub. */
426
- export declare const servePresence: <Update>(socket: SocketLike, hub: PresenceHub<Update>) => (() => void);
716
+ /** Serves presence frames on an accepted socket, stamping the connection's identity. */
717
+ export declare const servePresence: <Update>(socket: SocketLike, hub: PresenceHub<Update>, options: {
718
+ readonly peerId: string;
719
+ }) => (() => void);
427
720
  //#endregion
428
- export type { Checkpoint, Committed, Exchange, ExchangeFrame, ExchangeReply, LwwClock, LwwClockState, Operation, Presence, PresenceChannel, PresenceHub, PresenceOptions, PresencePeer, PresenceUpdate, Replica, ReplicaError, ReplicaState, ReplicaStatus, SocketLike, SocketOptions, Storage, Sync, SyncDefinition, TransportClient, TransportShape };
721
+ export type { ApplicationSync, AuthorizePolicy, AuthorizeRequest, Checkpoint, CommittedOperation, DefinedSync, Exchange, ExchangeFrame, ExchangeReply, FragmentMessages, JournalContract, LwwClock, LwwClockState, MakeOptions, MountOptions, MountUrl, Mounted, MsgOf, Operation, PolicyJournalContract, Presence, PresenceChannel, PresenceHub, PresenceOptions, PresencePeer, PresenceUpdate, Replica, ReplicaError, ReplicaSnapshot, ReplicaState, ReplicaStatus, SocketLike, SocketOptions, Storage, Sync, SyncDefinition, SyncFragment, TransportClient, TransportShape };
429
722
  //# sourceMappingURL=index.d.mts.map