foldkit-sync 0.12.4 → 0.14.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.
Files changed (82) hide show
  1. package/README.md +77 -25
  2. package/dist/diagnostics.d.ts +71 -0
  3. package/dist/diagnostics.d.ts.map +1 -0
  4. package/dist/diagnostics.js +67 -0
  5. package/dist/diagnostics.js.map +1 -0
  6. package/dist/{do.d.mts → do.d.ts} +12 -2
  7. package/dist/do.d.ts.map +1 -0
  8. package/dist/{do.mjs → do.js} +15 -9
  9. package/dist/do.js.map +1 -0
  10. package/dist/{entity.d.mts → entity.d.ts} +1 -1
  11. package/dist/entity.d.ts.map +1 -0
  12. package/dist/{entity.mjs → entity.js} +1 -1
  13. package/dist/entity.js.map +1 -0
  14. package/dist/errors.d.ts +91 -0
  15. package/dist/errors.d.ts.map +1 -0
  16. package/dist/errors.js +75 -0
  17. package/dist/errors.js.map +1 -0
  18. package/dist/ids.d.ts +30 -0
  19. package/dist/ids.d.ts.map +1 -0
  20. package/dist/ids.js +28 -0
  21. package/dist/ids.js.map +1 -0
  22. package/dist/index.d.ts +106 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +77 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/indexedDb.d.ts +62 -0
  27. package/dist/indexedDb.d.ts.map +1 -0
  28. package/dist/indexedDb.js +128 -0
  29. package/dist/indexedDb.js.map +1 -0
  30. package/dist/{journal.d.mts → journal.d.ts} +29 -5
  31. package/dist/journal.d.ts.map +1 -0
  32. package/dist/{journal-D5h-jqXE.mjs → journal.js} +43 -32
  33. package/dist/journal.js.map +1 -0
  34. package/dist/lww.d.ts +76 -0
  35. package/dist/lww.d.ts.map +1 -0
  36. package/dist/lww.js +121 -0
  37. package/dist/lww.js.map +1 -0
  38. package/dist/make.d.ts +162 -0
  39. package/dist/make.d.ts.map +1 -0
  40. package/dist/make.js +153 -0
  41. package/dist/make.js.map +1 -0
  42. package/dist/mount.d.ts +138 -0
  43. package/dist/mount.d.ts.map +1 -0
  44. package/dist/mount.js +344 -0
  45. package/dist/mount.js.map +1 -0
  46. package/dist/presence.d.ts +116 -0
  47. package/dist/presence.d.ts.map +1 -0
  48. package/dist/presence.js +277 -0
  49. package/dist/presence.js.map +1 -0
  50. package/dist/{remote.d.mts → remote.d.ts} +4 -11
  51. package/dist/remote.d.ts.map +1 -0
  52. package/dist/{remote.mjs → remote.js} +8 -7
  53. package/dist/remote.js.map +1 -0
  54. package/dist/revalidate.d.ts +6 -0
  55. package/dist/revalidate.d.ts.map +1 -0
  56. package/dist/revalidate.js +10 -0
  57. package/dist/revalidate.js.map +1 -0
  58. package/dist/sync.d.ts +276 -0
  59. package/dist/sync.d.ts.map +1 -0
  60. package/dist/sync.js +512 -0
  61. package/dist/sync.js.map +1 -0
  62. package/dist/transport.d.ts +151 -0
  63. package/dist/transport.d.ts.map +1 -0
  64. package/dist/{transport-BZ6utYmB.mjs → transport.js} +20 -30
  65. package/dist/transport.js.map +1 -0
  66. package/package.json +25 -25
  67. package/dist/do.d.mts.map +0 -1
  68. package/dist/do.mjs.map +0 -1
  69. package/dist/entity.d.mts.map +0 -1
  70. package/dist/entity.mjs.map +0 -1
  71. package/dist/index.d.mts +0 -397
  72. package/dist/index.d.mts.map +0 -1
  73. package/dist/index.mjs +0 -1613
  74. package/dist/index.mjs.map +0 -1
  75. package/dist/journal-D5h-jqXE.mjs.map +0 -1
  76. package/dist/journal.d.mts.map +0 -1
  77. package/dist/journal.mjs +0 -1
  78. package/dist/make-DJ0Q1SSc.d.mts +0 -702
  79. package/dist/make-DJ0Q1SSc.d.mts.map +0 -1
  80. package/dist/remote.d.mts.map +0 -1
  81. package/dist/remote.mjs.map +0 -1
  82. package/dist/transport-BZ6utYmB.mjs.map +0 -1
package/dist/index.d.mts DELETED
@@ -1,397 +0,0 @@
1
- import { $ as InvalidOutboxError, A as ExchangeReply, B as nativeSocket, C as ReplicaStatus, D as defineSync, E as TransportClient, F as TransportError, G as OutboxEntry, H as serveSocket, I as TransportShape, J as CheckpointRegressionError, K as Storage, L as layerFromPromise, M as SocketLike, N as SocketOptions, O as syncMetrics, P as Transport, Q as InvalidExchangeError, R as layerLoopback, S as ReplicaState, T as SyncDefinition, U as toPromise, V as portSocket, W as workerSocket, X as ForeignAcknowledgementError, Y as CommittedOrderError, Z as ForeignRejectionError, _ as JournalContract, _t as sequence, a as DefinedSync, at as UnsupportedClockVersionError, b as Replica, c as MsgOf, ct as DocumentId, d as SyncFragment, dt as ReplicaId, et as InvalidReplicaHistoryError, f as forApplication, ft as Sequence, g as Exchange, gt as replicaId, h as CommittedOperation, ht as opId, i as AuthorizeRequest, it as StorageError, j as NotifyFrame, k as ExchangeFrame, l as PolicyJournalContract, lt as LocalSequence, m as CommitStamp, mt as localSequence, n as AuthorizeDecision, nt as ReplicaClosedError, o as FragmentMessages, ot as UnsupportedReplicaVersionError, p as Checkpoint, pt as documentId, q as indexedDb, r as AuthorizePolicy, rt as ReplicaError, s as MakeOptions, st as WrongReplicaStorageError, t as ApplicationSync, tt as ReplayError, u as StampPolicy, ut as OpId, v as Operation, w as Sync$1, x as ReplicaSnapshot, y as Rejection, z as layerSocket } from "./make-DJ0Q1SSc.mjs";
2
- import { Duration, Effect, Exit, Layer, PubSub, Schema, Scope, Stream } from "effect";
3
- import { RunnableApplication } from "foldkit-surface";
4
- import { UrlRequest } from "foldkit/navigation";
5
- import { Subscriptions } from "foldkit/subscription";
6
- import * as Url from "foldkit/url";
7
- import { Document, HtmlBuilder } from "foldkit/html";
8
- import * as Update from "foldkit/update";
9
- /** One peer's presence. A `null` value means the peer left. */
10
- interface PresenceUpdate<Update> {
11
- readonly id: string;
12
- readonly value: Update | null;
13
- }
14
- /**
15
- * The ephemeral channel presence travels on.
16
- *
17
- * `updates` is the inbound bus a peer consumes; `publish` sends one to the bus.
18
- * Splitting them keeps an inbound update from being echoed straight back out.
19
- * This is deliberately not the durable transport: presence is broadcast, never
20
- * journaled, so a dropped or duplicated update is harmless.
21
- */
22
- interface PresenceChannel<Update> {
23
- readonly updates: PubSub.PubSub<PresenceUpdate<Update>>;
24
- readonly publish: (update: PresenceUpdate<Update>) => Effect.Effect<void>;
25
- }
26
- interface PresenceOptions<Update> {
27
- /** This peer's identity on the channel. */
28
- readonly id: string;
29
- /** How long a peer may go without refreshing before it is dropped. */
30
- readonly ttl: Duration.Input;
31
- /**
32
- * Validates the untrusted value a peer sends before it is stored. Presence
33
- * crosses a wire, so this is required rather than trusting the type
34
- * parameter; a value it rejects is dropped.
35
- */
36
- readonly decodeValue: (value: unknown) => Update;
37
- readonly channel?: PresenceChannel<Update> | undefined;
38
- /**
39
- * The least time between two values sent on the channel. `set` still takes effect here at
40
- * once; a value set sooner waits, and only the latest one waiting is sent when the time is
41
- * up. A departure is never held back. Absent, every `set` is sent at once.
42
- */
43
- readonly throttle?: Duration.Input | undefined;
44
- }
45
- interface PresencePeer<Update> {
46
- readonly id: string;
47
- readonly value: Update;
48
- readonly updatedAt: number;
49
- }
50
- interface Presence<Update> {
51
- /** Sets this peer's value and broadcasts it, no sooner than `throttle` allows. */
52
- readonly set: (value: Update) => Effect.Effect<void>;
53
- /** Removes this peer and broadcasts the departure. */
54
- readonly leave: Effect.Effect<void>;
55
- /** Live peers, self included, with stale ones excluded. */
56
- readonly peers: Effect.Effect<ReadonlyArray<PresencePeer<Update>>>;
57
- /** Drops expired peers; notifies if any went. */
58
- readonly prune: Effect.Effect<void>;
59
- /** Notified when the peer set changes. */
60
- readonly subscribe: (listener: () => void) => () => void;
61
- /**
62
- * The live peers, re-emitted whenever the set changes. The `Stream` form of
63
- * `subscribe`, for a consumer that composes with Effect.
64
- */
65
- readonly changes: Stream.Stream<ReadonlyArray<PresencePeer<Update>>>;
66
- /** Stops consuming the channel; the enclosing scope also does this on exit. */
67
- readonly close: Effect.Effect<void>;
68
- }
69
- /**
70
- * Tracks ephemeral peers with a time-to-live.
71
- *
72
- * Nothing here touches the durable log: presence is state a peer refreshes, and
73
- * a peer that stops refreshing is dropped, not replayed. Time comes from the
74
- * `Clock`, so a `TestClock` drives the TTL deterministically.
75
- */
76
- export declare const createPresence: <Update>(options: PresenceOptions<Update>) => Effect.Effect<{
77
- set: (value: Update) => Effect.Effect<void, never, never>;
78
- leave: Effect.Effect<void, never, never>;
79
- peers: Effect.Effect<{
80
- id: string;
81
- value: Update;
82
- updatedAt: number;
83
- }[], never, never>;
84
- prune: Effect.Effect<void, never, never>;
85
- subscribe: (listener: () => void) => () => boolean;
86
- changes: Stream.Stream<{
87
- id: string;
88
- value: Update;
89
- updatedAt: number;
90
- }[], never, never>;
91
- close: Effect.Effect<void, never, never>;
92
- }, never, Scope.Scope>;
93
- /** An in-process channel, for tests and single-process demos. */
94
- export declare const loopbackPresenceChannel: <Update>() => Effect.Effect<{
95
- updates: PubSub.PubSub<PresenceUpdate<Update>>;
96
- publish: (update: PresenceUpdate<Update>) => Effect.Effect<boolean, never, never>;
97
- }, never, never>;
98
- /** Broadcasts presence updates among connected peers. */
99
- interface PresenceHub<Update> {
100
- /** Registers a peer's send; returns a leave function. */
101
- join(send: (update: PresenceUpdate<Update>) => void): () => void;
102
- /** Fans an update out to every joined peer. */
103
- publish(update: PresenceUpdate<Update>): void;
104
- }
105
- export declare const createPresenceHub: <Update>() => PresenceHub<Update>;
106
- /**
107
- * A presence channel fed by stamped frames from the server, sent back without an
108
- * id: the server owns peer identity, so a client cannot assert another's.
109
- */
110
- export declare const socketPresenceChannel: <Update>(socket: SocketLike) => Effect.Effect<PresenceChannel<Update>, never, Scope.Scope>;
111
- /**
112
- * Serves presence frames on an accepted socket, stamping the connection's
113
- * identity, until the socket closes or the returned function is called.
114
- * With `opens`, the connection joins only once it answers that it may open
115
- * the document the presence accompanies: until then, and for good when it
116
- * is refused or fails, nothing reaches it and nothing it sends is relayed.
117
- */
118
- export declare const servePresence: <Update>(socket: SocketLike, hub: PresenceHub<Update>, options: {
119
- readonly peerId: string;
120
- readonly opens?: Effect.Effect<boolean, unknown> | undefined;
121
- }) => (() => void);
122
- /** A logical write time; replica ids break concurrent ties using UTF-16 order. */
123
- declare const Stamp: Schema.Struct<{
124
- readonly counter: Schema.Number;
125
- readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
126
- }>;
127
- declare const ClockState: Schema.Struct<{
128
- readonly schemaVersion: Schema.Literal<1>;
129
- readonly documentId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/DocumentId">;
130
- readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
131
- readonly revision: Schema.Number;
132
- }>;
133
- type LwwClockState = typeof ClockState.Type;
134
- interface LwwClock {
135
- /** Persists a timestamp beyond the saved counter and supplied observation. */
136
- next: (observedCounter?: number) => Effect.Effect<typeof Stamp.Type, StorageError>;
137
- /** Drains accepted allocations, then closes storage. Repeated calls no-op. */
138
- close: Effect.Effect<void>;
139
- }
140
- /**
141
- * Opens a durable clock over the caller's storage.
142
- *
143
- * Allocations are serialized through a `SynchronizedRef` and each persists before
144
- * its stamp is returned. A crash after the save may skip a timestamp but never
145
- * reuse one. Storage is owned by the caller; a failed open closes it so a partial
146
- * initialization does not leak the connection.
147
- */
148
- export declare const openLwwClock: (options: {
149
- readonly documentId: DocumentId;
150
- readonly replicaId: ReplicaId;
151
- readonly storage: Storage;
152
- }) => Effect.Effect<{
153
- next: (observedCounter?: any) => Effect.Effect<{
154
- readonly counter: number;
155
- readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
156
- }, StorageError, never>;
157
- close: Effect.Effect<void, never, never>;
158
- }, StorageError | UnsupportedClockVersionError, never>;
159
- /**
160
- * A schema and reducer helper for a last-writer-wins register.
161
- * Allocate a unique stamp per write before dispatch, and retain it in the Message.
162
- * Merge is for decoded values; the application's schema validates wire input.
163
- */
164
- export declare const lwwRegister: <Value, Encoded, RD, RE>(value: Schema.Codec<Value, Encoded, RD, RE>) => {
165
- schema: Schema.Struct<{
166
- readonly stamp: Schema.Struct<{
167
- readonly counter: Schema.Number;
168
- readonly replicaId: Schema.brand<Schema.NonEmptyString, "@foldkit-sync/ReplicaId">;
169
- }>;
170
- readonly value: Schema.Codec<Value, Encoded, RD, RE>;
171
- }>;
172
- merge: (left: {
173
- readonly stamp: {
174
- readonly counter: number;
175
- readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
176
- };
177
- readonly value: Value;
178
- }, right: {
179
- readonly stamp: {
180
- readonly counter: number;
181
- readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
182
- };
183
- readonly value: Value;
184
- }) => {
185
- readonly stamp: {
186
- readonly counter: number;
187
- readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
188
- };
189
- readonly value: Value;
190
- };
191
- };
192
- /**
193
- * A Command that dispatches `message` as the next transition, which under `Sync.mount`
194
- * means within this one: the mount applies it straight after the `update` that returned
195
- * it, and persists it if it is durable, before any other Message is processed. This is
196
- * how a local intent turns into a durable fact that needs something only the intent's
197
- * transition knows, such as an id minted from local state, without a later Message
198
- * seeing the Model before the fact. Elsewhere, or once a parent has mapped the Command,
199
- * it is an ordinary Command that yields `message`, and so is one a durable Message's
200
- * update returns: replay would not apply it, and with derived replay the durable Message's
201
- * persist fails with `ReplayError` as for any Command.
202
- */
203
- export declare const fact: <Message>(message: Message) => {
204
- readonly name: string;
205
- readonly effect: Effect.Effect<Message>;
206
- };
207
- /**
208
- * The URL as part of the application: `onUrlChange` names the Message the
209
- * runtime sends for the current URL at start and on every navigation (so a
210
- * `foldkit-mirror` URL mirror reads back in), `init` reduces the URL into the
211
- * Model before the first render, and `onUrlRequest` names the Message for a
212
- * link click; omitted, the mount follows the link itself (an internal one is
213
- * pushed, an external one loaded).
214
- */
215
- interface MountUrl<Model, Message> {
216
- readonly init?: ((model: Model, url: Url.Url) => Model) | undefined;
217
- readonly onUrlChange: (url: Url.Url) => Message;
218
- readonly onUrlRequest?: ((request: UrlRequest) => Message) | undefined;
219
- }
220
- interface MountOptions<Model, Message, Shared, Resources> {
221
- /** An open replica of this contract; `mount` does not close it. */
222
- readonly replica: Replica<Message, Shared>;
223
- /** The element the application renders into; Foldkit requires it to have an `id`. */
224
- readonly container: HTMLElement;
225
- readonly view: (model: Model, h: HtmlBuilder<Message>) => Document;
226
- readonly subscriptions?: Subscriptions<Model, Message, Resources> | undefined;
227
- readonly resources?: Layer.Layer<Resources> | undefined;
228
- /** Route the URL through the application; without it the mount ignores the URL. */
229
- readonly url?: MountUrl<Model, Message> | undefined;
230
- /**
231
- * Reflects a refused or failed persist in the Model, after the durable edit
232
- * has been reverted. Omitted, the edit is reverted silently.
233
- */
234
- readonly onPersistenceFailure?: ((model: Model, error: ReplicaError) => Model) | undefined;
235
- /**
236
- * Runs when the mount replaces the shared slice outside `update`: an exchange committed,
237
- * acknowledged or rejected something, or a persist failed and its edit was reverted.
238
- * `previous` is the Model before; what it returns is the transition, so an application
239
- * can carry local state across the change (a selection held by what it points at) or
240
- * return Commands (a DOM the change has to reach). Omitted, the Model is `next`. It is
241
- * not called for a status that changes nothing the Model shows, such as the first.
242
- */
243
- readonly onReinstall?: ((next: Model, previous: Model, change: Reinstall) => Update.Return<Model, Message, Resources>) | undefined;
244
- /**
245
- * Runs on the Model after every update of the mounted application, a durable
246
- * Message's and a reinstall's included, and never in replay: for local state
247
- * derived from the shared slice, which a durable transition may not write
248
- * (the overlays `foldkit-sync/remote` keeps in Remote). With nothing to
249
- * change it returns the Model it was given.
250
- */
251
- readonly afterUpdate?: ((model: Model) => Update.Return<Model, Message, Resources>) | undefined;
252
- }
253
- /**
254
- * What a reinstall came from. `reset` is a server reset: the replica's
255
- * committed history is a new one, so anything an application derived from
256
- * the old one (reads cached by commit sequence, say) is to be read again.
257
- */
258
- interface Reinstall {
259
- readonly reset: boolean;
260
- }
261
- /**
262
- * The shared slice as the server has confirmed it, outside the Model. It is a
263
- * source for waiting consumers, the shape `Agent.when({ source })` reads, and
264
- * not a Projection: it does not render and is not derived from the Model.
265
- */
266
- interface CommittedView<Shared> {
267
- readonly get: () => Shared;
268
- /** Told after every exchange, including one that moves no cursor (a checkpoint). */
269
- readonly subscribe: (listener: () => void) => () => void;
270
- }
271
- interface Mounted<Model, Message, Shared = unknown> {
272
- /** Sends an application Message through the runtime; the `Exit` reports a decode failure. */
273
- readonly dispatch: (message: Message) => Exit.Exit<void, unknown>;
274
- /** The Model after the last transition. */
275
- readonly model: () => Model;
276
- /** Notified after every transition; with `model` and `dispatch`, the host an agent binds to. */
277
- readonly subscribe: (listener: () => void) => () => void;
278
- /**
279
- * Every application Message the runtime applies, from any origin, so an
280
- * agent contract that declares a `completion` can see the Message that
281
- * finishes its work. The mount's private Messages are not reported.
282
- */
283
- readonly observe: (listener: (message: Message) => void) => () => void;
284
- /**
285
- * The shared slice without pending local edits, for an agent that must not
286
- * report an optimistic edit as done: `Agent.when({ source: mounted.committed, … })`.
287
- */
288
- readonly committed: CommittedView<Shared>;
289
- /**
290
- * Resolves once the Model has caught up with the replica: no persist in
291
- * flight or unanswered, every replica status the mount was told of seen,
292
- * and every reinstall it asked for applied. It observes and never does the
293
- * work. Frames are not its to wait for (`Frames.track` in
294
- * `foldkit-mixins/testing` is), nor I/O a Command started. Rejects after
295
- * `dispose`.
296
- */
297
- readonly settled: () => Promise<void>;
298
- /** Waits for in-flight persists, then disposes the runtime. The replica stays open. */
299
- readonly dispose: () => Promise<void>;
300
- }
301
- /** The application's Message union, as `Surface.application` types it. */
302
- type MessageOf<App> = App extends RunnableApplication<any, any, any, any> ? Schema.Schema.Type<App['Message']> : never;
303
- 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>>, Schema.Struct.Type<Fields>>;
304
- /**
305
- * The contract `Sync.define` and `Sync.forApplication(App).make` produce: the
306
- * wire codecs, the server journal's contract, and `openReplica`.
307
- *
308
- * This is the type; `Sync` is also the value namespace below, the way
309
- * `Effect.Effect` is both.
310
- */
311
- export type Sync<Message, Shared> = Sync$1<Message, Shared>;
312
- /** The package's public surface, grouped. Each entry is the exported function itself. */
313
- export declare const Sync: {
314
- /** Derives a sync contract from a Foldkit application: `Sync.forApplication(App).make({…})`. */
315
- forApplication: typeof forApplication;
316
- /** The protocol primitive, for a client with no Foldkit application to derive from. */
317
- define: typeof defineSync;
318
- /** Runs a Foldkit application over an open replica with one reducer. */
319
- mount: typeof mount;
320
- /** A Command whose Message the mount applies within the transition that returned it. */
321
- fact: typeof fact;
322
- /** Counters and a histogram an application can scrape. */
323
- metrics: {
324
- exchanges: import("effect/Metric").Counter<number>;
325
- applied: import("effect/Metric").Counter<number>;
326
- checkpoints: import("effect/Metric").Counter<number>;
327
- exchangePending: import("effect/Metric").Histogram<number>;
328
- };
329
- /** The only storage adapter: one IndexedDB database per document/replica. */
330
- indexedDb: (name: string | import("effect/Config").Config<string>, factory?: IDBFactory | undefined) => import("effect/Effect").Effect<Required<Storage>, StorageError, import("effect/Scope").Scope>;
331
- /** The `Transport` service's layers, and the bridges to and from a promise client. */
332
- transport: {
333
- /** A reconnecting WebSocket client layer. */
334
- socket: typeof layerSocket;
335
- /** An in-process layer, for tests and single-process demos. */
336
- loopback: typeof layerLoopback;
337
- /** Wraps the promise-based client the replica already speaks. */
338
- fromPromise: typeof layerFromPromise;
339
- /** Bridges the service back to that promise client. */
340
- toPromise: typeof toPromise;
341
- /** The server side of one accepted socket connection. */
342
- serve: typeof serveSocket;
343
- /** The accepted end of a Cloudflare `WebSocketPair`, for `serve`. */
344
- workerSocket: typeof workerSocket;
345
- /** The default socket factory: the platform `WebSocket`. */
346
- nativeSocket: typeof nativeSocket;
347
- /** A socket over a `MessagePort`, closed by `close()` or an abort signal. */
348
- portSocket: typeof portSocket;
349
- };
350
- /** An ephemeral, TTL'd peer registry, deliberately outside the durable log. */
351
- presence: {
352
- make: <Update>(options: PresenceOptions<Update>) => import("effect/Effect").Effect<{
353
- set: (value: Update) => import("effect/Effect").Effect<void, never, never>;
354
- leave: import("effect/Effect").Effect<void, never, never>;
355
- peers: import("effect/Effect").Effect<{
356
- id: string;
357
- value: Update;
358
- updatedAt: number;
359
- }[], never, never>;
360
- prune: import("effect/Effect").Effect<void, never, never>;
361
- subscribe: (listener: () => void) => () => boolean;
362
- changes: import("effect/Stream").Stream<{
363
- id: string;
364
- value: Update;
365
- updatedAt: number;
366
- }[], never, never>;
367
- close: import("effect/Effect").Effect<void, never, never>;
368
- }, never, import("effect/Scope").Scope>;
369
- /** Broadcasts presence updates among connected peers, on the server. */
370
- hub: typeof createPresenceHub;
371
- /** Serves presence frames on an accepted socket, stamping the connection's identity. */
372
- serve: typeof servePresence;
373
- socketChannel: typeof socketPresenceChannel;
374
- loopbackChannel: <Update>() => import("effect/Effect").Effect<{
375
- updates: import("effect/PubSub").PubSub<PresenceUpdate<Update>>;
376
- publish: (update: PresenceUpdate<Update>) => import("effect/Effect").Effect<boolean, never, never>;
377
- }, never, never>;
378
- };
379
- /** Last-writer-wins registers (experimental): a per-field merge on logical time. */
380
- lww: {
381
- register: typeof lwwRegister;
382
- /** The durable counter a stamp is allocated from, before dispatch. */
383
- openClock: (options: {
384
- readonly documentId: DocumentId;
385
- readonly replicaId: ReplicaId;
386
- readonly storage: Storage;
387
- }) => import("effect/Effect").Effect<{
388
- next: (observedCounter?: any) => import("effect/Effect").Effect<{
389
- readonly counter: number;
390
- readonly replicaId: string & import("effect/Brand").Brand<"@foldkit-sync/ReplicaId">;
391
- }, StorageError, never>;
392
- close: import("effect/Effect").Effect<void, never, never>;
393
- }, StorageError | UnsupportedClockVersionError, never>;
394
- };
395
- };
396
- export { type ApplicationSync, type AuthorizeDecision, type AuthorizePolicy, type AuthorizeRequest, type Checkpoint, CheckpointRegressionError, type CommitStamp, type CommittedOperation, CommittedOrderError, type CommittedView, type DefinedSync, DocumentId, type Exchange, type ExchangeFrame, type ExchangeReply, ForeignAcknowledgementError, ForeignRejectionError, type FragmentMessages, InvalidExchangeError, InvalidOutboxError, InvalidReplicaHistoryError, type JournalContract, LocalSequence, type LwwClock, type LwwClockState, type MakeOptions, type MountOptions, type MountUrl, type Mounted, type MsgOf, type NotifyFrame, OpId, type Operation, type OutboxEntry, type PolicyJournalContract, type Presence, type PresenceChannel, type PresenceHub, type PresenceOptions, type PresencePeer, type PresenceUpdate, type Reinstall, type Rejection, ReplayError, type Replica, ReplicaClosedError, type ReplicaError, ReplicaId, type ReplicaSnapshot, type ReplicaState, type ReplicaStatus, Sequence, type SocketLike, type SocketOptions, type StampPolicy, type Storage, StorageError, type SyncDefinition, type SyncFragment, Transport, type TransportClient, TransportError, type TransportShape, UnsupportedClockVersionError, UnsupportedReplicaVersionError, WrongReplicaStorageError, defineSync, documentId, forApplication, indexedDb, layerFromPromise, layerLoopback, layerSocket, localSequence, nativeSocket, opId, portSocket, replicaId, sequence, serveSocket, syncMetrics, toPromise, workerSocket };
397
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":["SyncContract","_$__indexedDb_js0.Storage","_$__errors_js0.StorageError","_$__presence_js0.PresenceOptions","_$__presence_js0.PresenceUpdate","_$__ids_js0.DocumentId","_$__ids_js0.ReplicaId","_$__errors_js0.UnsupportedClockVersionError"],"sources":["../src/presence.ts","../src/lww.ts","../src/mount.ts","../src/index.ts"],"mappings":";;;;;;;;;UAciB,eAAe;WACrB;WACA,OAAO;;;;;;;;;;UAWD,gBAAgB;WACtB,SAAS,OAAO,OAAO,eAAe;WACtC,UAAU,QAAQ,eAAe,YAAY,OAAO;;UAG9C,gBAAgB;;WAEtB;;W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