@livestore/sync-cf 0.4.0-dev.7 → 0.4.0-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cf-worker/do/pull.d.ts.map +1 -1
  3. package/dist/cf-worker/do/pull.js +14 -12
  4. package/dist/cf-worker/do/pull.js.map +1 -1
  5. package/dist/cf-worker/do/push.d.ts.map +1 -1
  6. package/dist/cf-worker/do/push.js +1 -1
  7. package/dist/cf-worker/do/push.js.map +1 -1
  8. package/dist/cf-worker/do/sync-storage.d.ts +8 -5
  9. package/dist/cf-worker/do/sync-storage.d.ts.map +1 -1
  10. package/dist/cf-worker/do/sync-storage.js +64 -19
  11. package/dist/cf-worker/do/sync-storage.js.map +1 -1
  12. package/package.json +4 -4
  13. package/src/cf-worker/do/pull.ts +17 -16
  14. package/src/cf-worker/do/push.ts +1 -0
  15. package/src/cf-worker/do/sync-storage.ts +106 -27
  16. package/dist/cf-worker/cf-types.d.ts +0 -2
  17. package/dist/cf-worker/cf-types.d.ts.map +0 -1
  18. package/dist/cf-worker/cf-types.js +0 -2
  19. package/dist/cf-worker/cf-types.js.map +0 -1
  20. package/dist/cf-worker/durable-object.d.ts +0 -189
  21. package/dist/cf-worker/durable-object.d.ts.map +0 -1
  22. package/dist/cf-worker/durable-object.js +0 -317
  23. package/dist/cf-worker/durable-object.js.map +0 -1
  24. package/dist/common/ws-message-types.d.ts +0 -270
  25. package/dist/common/ws-message-types.d.ts.map +0 -1
  26. package/dist/common/ws-message-types.js +0 -57
  27. package/dist/common/ws-message-types.js.map +0 -1
  28. package/dist/sync-impl/mod.d.ts +0 -2
  29. package/dist/sync-impl/mod.d.ts.map +0 -1
  30. package/dist/sync-impl/mod.js +0 -2
  31. package/dist/sync-impl/mod.js.map +0 -1
  32. package/dist/sync-impl/ws-impl.d.ts +0 -7
  33. package/dist/sync-impl/ws-impl.d.ts.map +0 -1
  34. package/dist/sync-impl/ws-impl.js +0 -175
  35. package/dist/sync-impl/ws-impl.js.map +0 -1
@@ -1,270 +0,0 @@
1
- import { Schema } from '@livestore/utils/effect';
2
- export declare const PullReq: Schema.Struct<{
3
- _tag: Schema.tag<"WSMessage.PullReq">;
4
- } & {
5
- requestId: typeof Schema.String;
6
- /** Omitting the cursor will start from the beginning */
7
- cursor: Schema.optional<typeof Schema.Number>;
8
- }>;
9
- export type PullReq = typeof PullReq.Type;
10
- export declare const SyncMetadata: Schema.Struct<{
11
- /** ISO date format */
12
- createdAt: typeof Schema.String;
13
- }>;
14
- export type SyncMetadata = typeof SyncMetadata.Type;
15
- export declare const PullRes: Schema.Struct<{
16
- _tag: Schema.tag<"WSMessage.PullRes">;
17
- } & {
18
- batch: Schema.Array$<Schema.Struct<{
19
- eventEncoded: Schema.Struct<{
20
- name: typeof Schema.String;
21
- args: typeof Schema.Any;
22
- seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
23
- parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
24
- clientId: typeof Schema.String;
25
- sessionId: typeof Schema.String;
26
- }>;
27
- metadata: Schema.Option<Schema.Struct<{
28
- /** ISO date format */
29
- createdAt: typeof Schema.String;
30
- }>>;
31
- }>>;
32
- requestId: Schema.Struct<{
33
- context: Schema.Literal<["pull", "push"]>;
34
- requestId: typeof Schema.String;
35
- }>;
36
- remaining: typeof Schema.Number;
37
- }>;
38
- export type PullRes = typeof PullRes.Type;
39
- export declare const PushReq: Schema.Struct<{
40
- _tag: Schema.tag<"WSMessage.PushReq">;
41
- } & {
42
- requestId: typeof Schema.String;
43
- batch: Schema.Array$<Schema.Struct<{
44
- name: typeof Schema.String;
45
- args: typeof Schema.Any;
46
- seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
47
- parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
48
- clientId: typeof Schema.String;
49
- sessionId: typeof Schema.String;
50
- }>>;
51
- }>;
52
- export type PushReq = typeof PushReq.Type;
53
- export declare const PushAck: Schema.Struct<{
54
- _tag: Schema.tag<"WSMessage.PushAck">;
55
- } & {
56
- requestId: typeof Schema.String;
57
- }>;
58
- export type PushAck = typeof PushAck.Type;
59
- export declare const Error: Schema.Struct<{
60
- _tag: Schema.tag<"WSMessage.Error">;
61
- } & {
62
- requestId: typeof Schema.String;
63
- message: typeof Schema.String;
64
- }>;
65
- export type Error = typeof Error.Type;
66
- export declare const Ping: Schema.Struct<{
67
- _tag: Schema.tag<"WSMessage.Ping">;
68
- } & {
69
- requestId: Schema.Literal<["ping"]>;
70
- }>;
71
- export type Ping = typeof Ping.Type;
72
- export declare const Pong: Schema.Struct<{
73
- _tag: Schema.tag<"WSMessage.Pong">;
74
- } & {
75
- requestId: Schema.Literal<["ping"]>;
76
- }>;
77
- export type Pong = typeof Pong.Type;
78
- export declare const AdminResetRoomReq: Schema.Struct<{
79
- _tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
80
- } & {
81
- requestId: typeof Schema.String;
82
- adminSecret: typeof Schema.String;
83
- }>;
84
- export type AdminResetRoomReq = typeof AdminResetRoomReq.Type;
85
- export declare const AdminResetRoomRes: Schema.Struct<{
86
- _tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
87
- } & {
88
- requestId: typeof Schema.String;
89
- }>;
90
- export type AdminResetRoomRes = typeof AdminResetRoomRes.Type;
91
- export declare const AdminInfoReq: Schema.Struct<{
92
- _tag: Schema.tag<"WSMessage.AdminInfoReq">;
93
- } & {
94
- requestId: typeof Schema.String;
95
- adminSecret: typeof Schema.String;
96
- }>;
97
- export type AdminInfoReq = typeof AdminInfoReq.Type;
98
- export declare const AdminInfoRes: Schema.Struct<{
99
- _tag: Schema.tag<"WSMessage.AdminInfoRes">;
100
- } & {
101
- requestId: typeof Schema.String;
102
- info: Schema.Struct<{
103
- durableObjectId: typeof Schema.String;
104
- }>;
105
- }>;
106
- export type AdminInfoRes = typeof AdminInfoRes.Type;
107
- export declare const Message: Schema.Union<[Schema.Struct<{
108
- _tag: Schema.tag<"WSMessage.PullReq">;
109
- } & {
110
- requestId: typeof Schema.String;
111
- /** Omitting the cursor will start from the beginning */
112
- cursor: Schema.optional<typeof Schema.Number>;
113
- }>, Schema.Struct<{
114
- _tag: Schema.tag<"WSMessage.PullRes">;
115
- } & {
116
- batch: Schema.Array$<Schema.Struct<{
117
- eventEncoded: Schema.Struct<{
118
- name: typeof Schema.String;
119
- args: typeof Schema.Any;
120
- seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
121
- parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
122
- clientId: typeof Schema.String;
123
- sessionId: typeof Schema.String;
124
- }>;
125
- metadata: Schema.Option<Schema.Struct<{
126
- /** ISO date format */
127
- createdAt: typeof Schema.String;
128
- }>>;
129
- }>>;
130
- requestId: Schema.Struct<{
131
- context: Schema.Literal<["pull", "push"]>;
132
- requestId: typeof Schema.String;
133
- }>;
134
- remaining: typeof Schema.Number;
135
- }>, Schema.Struct<{
136
- _tag: Schema.tag<"WSMessage.PushReq">;
137
- } & {
138
- requestId: typeof Schema.String;
139
- batch: Schema.Array$<Schema.Struct<{
140
- name: typeof Schema.String;
141
- args: typeof Schema.Any;
142
- seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
143
- parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
144
- clientId: typeof Schema.String;
145
- sessionId: typeof Schema.String;
146
- }>>;
147
- }>, Schema.Struct<{
148
- _tag: Schema.tag<"WSMessage.PushAck">;
149
- } & {
150
- requestId: typeof Schema.String;
151
- }>, Schema.Struct<{
152
- _tag: Schema.tag<"WSMessage.Error">;
153
- } & {
154
- requestId: typeof Schema.String;
155
- message: typeof Schema.String;
156
- }>, Schema.Struct<{
157
- _tag: Schema.tag<"WSMessage.Ping">;
158
- } & {
159
- requestId: Schema.Literal<["ping"]>;
160
- }>, Schema.Struct<{
161
- _tag: Schema.tag<"WSMessage.Pong">;
162
- } & {
163
- requestId: Schema.Literal<["ping"]>;
164
- }>, Schema.Struct<{
165
- _tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
166
- } & {
167
- requestId: typeof Schema.String;
168
- adminSecret: typeof Schema.String;
169
- }>, Schema.Struct<{
170
- _tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
171
- } & {
172
- requestId: typeof Schema.String;
173
- }>, Schema.Struct<{
174
- _tag: Schema.tag<"WSMessage.AdminInfoReq">;
175
- } & {
176
- requestId: typeof Schema.String;
177
- adminSecret: typeof Schema.String;
178
- }>, Schema.Struct<{
179
- _tag: Schema.tag<"WSMessage.AdminInfoRes">;
180
- } & {
181
- requestId: typeof Schema.String;
182
- info: Schema.Struct<{
183
- durableObjectId: typeof Schema.String;
184
- }>;
185
- }>]>;
186
- export type Message = typeof Message.Type;
187
- export type MessageEncoded = typeof Message.Encoded;
188
- export declare const BackendToClientMessage: Schema.Union<[Schema.Struct<{
189
- _tag: Schema.tag<"WSMessage.PullRes">;
190
- } & {
191
- batch: Schema.Array$<Schema.Struct<{
192
- eventEncoded: Schema.Struct<{
193
- name: typeof Schema.String;
194
- args: typeof Schema.Any;
195
- seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
196
- parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
197
- clientId: typeof Schema.String;
198
- sessionId: typeof Schema.String;
199
- }>;
200
- metadata: Schema.Option<Schema.Struct<{
201
- /** ISO date format */
202
- createdAt: typeof Schema.String;
203
- }>>;
204
- }>>;
205
- requestId: Schema.Struct<{
206
- context: Schema.Literal<["pull", "push"]>;
207
- requestId: typeof Schema.String;
208
- }>;
209
- remaining: typeof Schema.Number;
210
- }>, Schema.Struct<{
211
- _tag: Schema.tag<"WSMessage.PushAck">;
212
- } & {
213
- requestId: typeof Schema.String;
214
- }>, Schema.Struct<{
215
- _tag: Schema.tag<"WSMessage.AdminResetRoomRes">;
216
- } & {
217
- requestId: typeof Schema.String;
218
- }>, Schema.Struct<{
219
- _tag: Schema.tag<"WSMessage.AdminInfoRes">;
220
- } & {
221
- requestId: typeof Schema.String;
222
- info: Schema.Struct<{
223
- durableObjectId: typeof Schema.String;
224
- }>;
225
- }>, Schema.Struct<{
226
- _tag: Schema.tag<"WSMessage.Error">;
227
- } & {
228
- requestId: typeof Schema.String;
229
- message: typeof Schema.String;
230
- }>, Schema.Struct<{
231
- _tag: Schema.tag<"WSMessage.Pong">;
232
- } & {
233
- requestId: Schema.Literal<["ping"]>;
234
- }>]>;
235
- export type BackendToClientMessage = typeof BackendToClientMessage.Type;
236
- export declare const ClientToBackendMessage: Schema.Union<[Schema.Struct<{
237
- _tag: Schema.tag<"WSMessage.PullReq">;
238
- } & {
239
- requestId: typeof Schema.String;
240
- /** Omitting the cursor will start from the beginning */
241
- cursor: Schema.optional<typeof Schema.Number>;
242
- }>, Schema.Struct<{
243
- _tag: Schema.tag<"WSMessage.PushReq">;
244
- } & {
245
- requestId: typeof Schema.String;
246
- batch: Schema.Array$<Schema.Struct<{
247
- name: typeof Schema.String;
248
- args: typeof Schema.Any;
249
- seqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
250
- parentSeqNum: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
251
- clientId: typeof Schema.String;
252
- sessionId: typeof Schema.String;
253
- }>>;
254
- }>, Schema.Struct<{
255
- _tag: Schema.tag<"WSMessage.AdminResetRoomReq">;
256
- } & {
257
- requestId: typeof Schema.String;
258
- adminSecret: typeof Schema.String;
259
- }>, Schema.Struct<{
260
- _tag: Schema.tag<"WSMessage.AdminInfoReq">;
261
- } & {
262
- requestId: typeof Schema.String;
263
- adminSecret: typeof Schema.String;
264
- }>, Schema.Struct<{
265
- _tag: Schema.tag<"WSMessage.Ping">;
266
- } & {
267
- requestId: Schema.Literal<["ping"]>;
268
- }>]>;
269
- export type ClientToBackendMessage = typeof ClientToBackendMessage.Type;
270
- //# sourceMappingURL=ws-message-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ws-message-types.d.ts","sourceRoot":"","sources":["../../src/common/ws-message-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,eAAO,MAAM,OAAO;;;;IAElB,wDAAwD;;EAEH,CAAA;AAEvD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,YAAY;IACvB,sBAAsB;;EAEoC,CAAA;AAE5D,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD,eAAO,MAAM,OAAO;;;;;;;;;;;;;YANlB,sBAAsB;;;;;;;;;EAe+B,CAAA;AAEvD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,OAAO;;;;;;;;;;;;EAGmC,CAAA;AAEvD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,OAAO;;;;EAEmC,CAAA;AAEvD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,KAAK;;;;;EAGmC,CAAA;AAErD,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAErC,eAAO,MAAM,IAAI;;;;EAEmC,CAAA;AAEpD,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAA;AAEnC,eAAO,MAAM,IAAI;;;;EAE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Struct('WSMessage.PullReq', {
4
- requestId: Schema.String,
5
- /** Omitting the cursor will start from the beginning */
6
- cursor: Schema.optional(Schema.Number),
7
- }).annotations({ title: '@livestore/sync-cf:PullReq' });
8
- export const SyncMetadata = Schema.Struct({
9
- /** ISO date format */
10
- createdAt: Schema.String,
11
- }).annotations({ title: '@livestore/sync-cf:SyncMetadata' });
12
- export const PullRes = Schema.TaggedStruct('WSMessage.PullRes', {
13
- batch: Schema.Array(Schema.Struct({
14
- eventEncoded: LiveStoreEvent.AnyEncodedGlobal,
15
- metadata: Schema.Option(SyncMetadata),
16
- })),
17
- requestId: Schema.Struct({ context: Schema.Literal('pull', 'push'), requestId: Schema.String }),
18
- remaining: Schema.Number,
19
- }).annotations({ title: '@livestore/sync-cf:PullRes' });
20
- export const PushReq = Schema.TaggedStruct('WSMessage.PushReq', {
21
- requestId: Schema.String,
22
- batch: Schema.Array(LiveStoreEvent.AnyEncodedGlobal),
23
- }).annotations({ title: '@livestore/sync-cf:PushReq' });
24
- export const PushAck = Schema.TaggedStruct('WSMessage.PushAck', {
25
- requestId: Schema.String,
26
- }).annotations({ title: '@livestore/sync-cf:PushAck' });
27
- export const Error = Schema.TaggedStruct('WSMessage.Error', {
28
- requestId: Schema.String,
29
- message: Schema.String,
30
- }).annotations({ title: '@livestore/sync-cf:Error' });
31
- export const Ping = Schema.TaggedStruct('WSMessage.Ping', {
32
- requestId: Schema.Literal('ping'),
33
- }).annotations({ title: '@livestore/sync-cf:Ping' });
34
- export const Pong = Schema.TaggedStruct('WSMessage.Pong', {
35
- requestId: Schema.Literal('ping'),
36
- }).annotations({ title: '@livestore/sync-cf:Pong' });
37
- export const AdminResetRoomReq = Schema.TaggedStruct('WSMessage.AdminResetRoomReq', {
38
- requestId: Schema.String,
39
- adminSecret: Schema.String,
40
- }).annotations({ title: '@livestore/sync-cf:AdminResetRoomReq' });
41
- export const AdminResetRoomRes = Schema.TaggedStruct('WSMessage.AdminResetRoomRes', {
42
- requestId: Schema.String,
43
- }).annotations({ title: '@livestore/sync-cf:AdminResetRoomRes' });
44
- export const AdminInfoReq = Schema.TaggedStruct('WSMessage.AdminInfoReq', {
45
- requestId: Schema.String,
46
- adminSecret: Schema.String,
47
- }).annotations({ title: '@livestore/sync-cf:AdminInfoReq' });
48
- export const AdminInfoRes = Schema.TaggedStruct('WSMessage.AdminInfoRes', {
49
- requestId: Schema.String,
50
- info: Schema.Struct({
51
- durableObjectId: Schema.String,
52
- }),
53
- }).annotations({ title: '@livestore/sync-cf:AdminInfoRes' });
54
- export const Message = Schema.Union(PullReq, PullRes, PushReq, PushAck, Error, Ping, Pong, AdminResetRoomReq, AdminResetRoomRes, AdminInfoReq, AdminInfoRes).annotations({ title: '@livestore/sync-cf:Message' });
55
- export const BackendToClientMessage = Schema.Union(PullRes, PushAck, AdminResetRoomRes, AdminInfoRes, Error, Pong);
56
- export const ClientToBackendMessage = Schema.Union(PullReq, PushReq, AdminResetRoomReq, AdminInfoReq, Ping);
57
- //# sourceMappingURL=ws-message-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ws-message-types.js","sourceRoot":"","sources":["../../src/common/ws-message-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,mBAAmB,EAAE;IAC9D,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACvC,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,4BAA4B,EAAE,CAAC,CAAA;AAIvD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC,MAAM;CACzB,CAAC,CAAC,WAAW,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M,CAAC,MAAM;KAC/B,CAAC;CACH,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,CAAC,CAAA;AAI5D,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CACjC,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,CACb,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,4BAA4B,EAAE,CAAC,CAAA;AAKtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;AAGlH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,IAAI,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './ws-impl.ts';
2
- //# sourceMappingURL=mod.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/sync-impl/mod.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from "./ws-impl.js";
2
- //# sourceMappingURL=mod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/sync-impl/mod.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -1,7 +0,0 @@
1
- import type { SyncBackendConstructor } from '@livestore/common';
2
- import type { SyncMetadata } from '../common/ws-message-types.ts';
3
- export interface WsSyncOptions {
4
- url: string;
5
- }
6
- export declare const makeCfSync: (options: WsSyncOptions) => SyncBackendConstructor<SyncMetadata>;
7
- //# sourceMappingURL=ws-impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ws-impl.d.ts","sourceRoot":"","sources":["../../src/sync-impl/ws-impl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAoB5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,eAAO,MAAM,UAAU,GACpB,SAAS,aAAa,KAAG,sBAAsB,CAAC,YAAY,CAuHzD,CAAA"}
@@ -1,175 +0,0 @@
1
- /// <reference lib="dom" />
2
- import { InvalidPullError, InvalidPushError, UnexpectedError } from '@livestore/common';
3
- import { EventSequenceNumber } from '@livestore/common/schema';
4
- import { LS_DEV, shouldNeverHappen } from '@livestore/utils';
5
- import { Deferred, Effect, Option, PubSub, Queue, Schedule, Schema, Stream, SubscriptionRef, UrlParams, WebSocket, } from '@livestore/utils/effect';
6
- import { nanoid } from '@livestore/utils/nanoid';
7
- import { SearchParamsSchema, WSMessage } from "../common/mod.js";
8
- export const makeCfSync = (options) => ({ storeId, payload }) => Effect.gen(function* () {
9
- const urlParamsData = yield* Schema.encode(SearchParamsSchema)({
10
- storeId,
11
- payload,
12
- }).pipe(UnexpectedError.mapToUnexpectedError);
13
- const urlParams = UrlParams.fromInput(urlParamsData);
14
- const wsUrl = `${options.url}/websocket?${UrlParams.toString(urlParams)}`;
15
- const { isConnected, incomingMessages, send } = yield* connect(wsUrl);
16
- /**
17
- * We need to account for the scenario where push-caused PullRes message arrive before the pull-caused PullRes message.
18
- * i.e. a scenario where the WS connection is created but before the server processed the initial pull, a push from
19
- * another client triggers a PullRes message sent to this client which we need to stash until our pull-caused
20
- * PullRes message arrives at which point we can combine the stashed events with the pull-caused events and continue.
21
- */
22
- const stashedPullBatch = [];
23
- // We currently only support one pull stream for a sync backend.
24
- let pullStarted = false;
25
- const api = {
26
- isConnected,
27
- // Currently we're already eagerly connecting when the sync backend is created but we might want to refactor this later to clean this up
28
- connect: Effect.void,
29
- pull: (args) => Effect.gen(function* () {
30
- if (pullStarted) {
31
- return shouldNeverHappen(`Pull already started for this sync backend.`);
32
- }
33
- pullStarted = true;
34
- let pullResponseReceived = false;
35
- const requestId = nanoid();
36
- const cursor = Option.getOrUndefined(args)?.cursor.global;
37
- yield* send(WSMessage.PullReq.make({ cursor, requestId }));
38
- return Stream.fromPubSub(incomingMessages).pipe(Stream.tap((_) => _._tag === 'WSMessage.Error' && _.requestId === requestId
39
- ? new InvalidPullError({ message: _.message })
40
- : Effect.void), Stream.filterMap((msg) => {
41
- if (msg._tag === 'WSMessage.PullRes') {
42
- if (msg.requestId.context === 'pull') {
43
- if (msg.requestId.requestId === requestId) {
44
- pullResponseReceived = true;
45
- if (stashedPullBatch.length > 0 && msg.remaining === 0) {
46
- const pullResHead = msg.batch.at(-1)?.eventEncoded.seqNum ?? EventSequenceNumber.ROOT.global;
47
- // Index where stashed events are greater than pullResHead
48
- const newPartialBatchIndex = stashedPullBatch.findIndex((batchItem) => batchItem.eventEncoded.seqNum > pullResHead);
49
- const batchWithNewStashedEvents = newPartialBatchIndex === -1 ? [] : stashedPullBatch.slice(newPartialBatchIndex);
50
- const combinedBatch = [...msg.batch, ...batchWithNewStashedEvents];
51
- return Option.some({ ...msg, batch: combinedBatch, remaining: 0 });
52
- }
53
- else {
54
- return Option.some(msg);
55
- }
56
- }
57
- else {
58
- // Ignore
59
- return Option.none();
60
- }
61
- }
62
- else {
63
- if (pullResponseReceived) {
64
- return Option.some(msg);
65
- }
66
- else {
67
- stashedPullBatch.push(...msg.batch);
68
- return Option.none();
69
- }
70
- }
71
- }
72
- return Option.none();
73
- }));
74
- }).pipe(Stream.unwrap),
75
- push: (batch) => Effect.gen(function* () {
76
- const pushAck = yield* Deferred.make();
77
- const requestId = nanoid();
78
- yield* Stream.fromPubSub(incomingMessages).pipe(Stream.tap((_) => _._tag === 'WSMessage.Error' && _.requestId === requestId
79
- ? Deferred.fail(pushAck, new InvalidPushError({ reason: { _tag: 'Unexpected', message: _.message } }))
80
- : Effect.void), Stream.filter((_) => _._tag === 'WSMessage.PushAck' && _.requestId === requestId), Stream.take(1), Stream.tap(() => Deferred.succeed(pushAck, void 0)), Stream.runDrain, Effect.tapCauseLogPretty, Effect.fork);
81
- yield* send(WSMessage.PushReq.make({ batch, requestId }));
82
- yield* pushAck;
83
- }),
84
- metadata: {
85
- name: '@livestore/cf-sync',
86
- description: 'LiveStore sync backend implementation using Cloudflare Workers & Durable Objects',
87
- protocol: 'ws',
88
- url: options.url,
89
- },
90
- };
91
- return api;
92
- });
93
- const connect = (wsUrl) => Effect.gen(function* () {
94
- const isConnected = yield* SubscriptionRef.make(false);
95
- const socketRef = { current: undefined };
96
- const incomingMessages = yield* PubSub.unbounded().pipe(Effect.acquireRelease(PubSub.shutdown));
97
- const waitUntilOnline = isConnected.changes.pipe(Stream.filter(Boolean), Stream.take(1), Stream.runDrain);
98
- const send = (message) => Effect.gen(function* () {
99
- // Wait first until we're online
100
- yield* waitUntilOnline;
101
- // TODO use MsgPack instead of JSON to speed up the serialization / reduce the size of the messages
102
- socketRef.current.send(Schema.encodeSync(Schema.parseJson(WSMessage.Message))(message));
103
- if (LS_DEV) {
104
- yield* Effect.spanEvent(`Sent message: ${message._tag}`, message._tag === 'WSMessage.PushReq'
105
- ? {
106
- seqNum: message.batch[0].seqNum,
107
- parentSeqNum: message.batch[0].parentSeqNum,
108
- batchLength: message.batch.length,
109
- }
110
- : message._tag === 'WSMessage.PullReq'
111
- ? { cursor: message.cursor ?? '-' }
112
- : {});
113
- }
114
- });
115
- const innerConnect = Effect.gen(function* () {
116
- // If the browser already tells us we're offline, then we'll at least wait until the browser
117
- // thinks we're online again. (We'll only know for sure once the WS conneciton is established.)
118
- while (typeof navigator !== 'undefined' && navigator.onLine === false) {
119
- yield* Effect.sleep(1000);
120
- }
121
- // TODO bring this back in a cross-platform way
122
- // if (navigator.onLine === false) {
123
- // yield* Effect.async((cb) => self.addEventListener('online', () => cb(Effect.void)))
124
- // }
125
- const socket = yield* WebSocket.makeWebSocket({ url: wsUrl, reconnect: Schedule.exponential(100) });
126
- // socket.binaryType = 'arraybuffer'
127
- yield* SubscriptionRef.set(isConnected, true);
128
- socketRef.current = socket;
129
- const connectionClosed = yield* Deferred.make();
130
- const pongMessages = yield* Queue.unbounded().pipe(Effect.acquireRelease(Queue.shutdown));
131
- yield* Effect.eventListener(socket, 'message', (event) => Effect.gen(function* () {
132
- const decodedEventRes = Schema.decodeUnknownEither(Schema.parseJson(WSMessage.BackendToClientMessage))(event.data);
133
- if (decodedEventRes._tag === 'Left') {
134
- console.error('Sync: Invalid message received', decodedEventRes.left);
135
- return;
136
- }
137
- else {
138
- if (decodedEventRes.right._tag === 'WSMessage.Pong') {
139
- yield* Queue.offer(pongMessages, decodedEventRes.right);
140
- }
141
- else {
142
- // yield* Effect.logDebug(`decodedEventRes: ${decodedEventRes.right._tag}`)
143
- yield* PubSub.publish(incomingMessages, decodedEventRes.right);
144
- }
145
- }
146
- }));
147
- yield* Effect.eventListener(socket, 'close', () => Deferred.succeed(connectionClosed, void 0));
148
- yield* Effect.eventListener(socket, 'error', () => Effect.gen(function* () {
149
- socket.close(3000, 'Sync: WebSocket error');
150
- yield* Deferred.succeed(connectionClosed, void 0);
151
- }));
152
- // NOTE it seems that this callback doesn't work reliably on a worker but only via `window.addEventListener`
153
- // We might need to proxy the event from the main thread to the worker if we want this to work reliably.
154
- if (typeof self !== 'undefined' && typeof self.addEventListener === 'function') {
155
- // TODO support an Expo equivalent for this
156
- yield* Effect.eventListener(self, 'offline', () => Deferred.succeed(connectionClosed, void 0));
157
- }
158
- yield* Effect.addFinalizer(() => Effect.gen(function* () {
159
- socketRef.current = undefined;
160
- yield* SubscriptionRef.set(isConnected, false);
161
- }));
162
- const checkPingPong = Effect.gen(function* () {
163
- // TODO include pong latency infomation in network status
164
- yield* send({ _tag: 'WSMessage.Ping', requestId: 'ping' });
165
- // NOTE those numbers might need more fine-tuning to allow for bad network conditions
166
- yield* Queue.take(pongMessages).pipe(Effect.timeout(5000));
167
- yield* Effect.sleep(25_000);
168
- }).pipe(Effect.withSpan('@livestore/sync-cf:connect:checkPingPong'), Effect.ignore);
169
- yield* waitUntilOnline.pipe(Effect.andThen(checkPingPong.pipe(Effect.forever)), Effect.tapErrorCause(() => Deferred.succeed(connectionClosed, void 0)), Effect.forkScoped);
170
- yield* connectionClosed;
171
- }).pipe(Effect.scoped, Effect.withSpan('@livestore/sync-cf:connect'));
172
- yield* innerConnect.pipe(Effect.forever, Effect.interruptible, Effect.tapCauseLogPretty, Effect.forkScoped);
173
- return { isConnected, incomingMessages, send };
174
- });
175
- //# sourceMappingURL=ws-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ws-impl.js","sourceRoot":"","sources":["../../src/sync-impl/ws-impl.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAG3B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EACL,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAM,EACN,eAAe,EACf,SAAS,EACT,SAAS,GACV,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAOhE,MAAM,CAAC,MAAM,UAAU,GACrB,CAAC,OAAsB,EAAwC,EAAE,CACjE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CACvB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC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