@livestore/sync-cf 0.3.0-dev.3 → 0.3.0-dev.30
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/.tsbuildinfo +1 -1
- package/dist/cf-worker/durable-object.d.ts +58 -47
- package/dist/cf-worker/durable-object.d.ts.map +1 -1
- package/dist/cf-worker/durable-object.js +233 -156
- package/dist/cf-worker/durable-object.js.map +1 -1
- package/dist/cf-worker/mod.d.ts +3 -0
- package/dist/cf-worker/mod.d.ts.map +1 -0
- package/dist/cf-worker/mod.js +3 -0
- package/dist/cf-worker/mod.js.map +1 -0
- package/dist/cf-worker/worker.d.ts +12 -0
- package/dist/cf-worker/worker.d.ts.map +1 -0
- package/dist/cf-worker/worker.js +58 -0
- package/dist/cf-worker/worker.js.map +1 -0
- package/dist/common/mod.d.ts +7 -0
- package/dist/common/mod.d.ts.map +1 -0
- package/dist/common/mod.js +7 -0
- package/dist/common/mod.js.map +1 -0
- package/dist/common/ws-message-types.d.ts +163 -266
- package/dist/common/ws-message-types.d.ts.map +1 -1
- package/dist/common/ws-message-types.js +19 -24
- package/dist/common/ws-message-types.js.map +1 -1
- package/dist/sync-impl/mod.d.ts +2 -0
- package/dist/sync-impl/mod.d.ts.map +1 -0
- package/dist/sync-impl/mod.js +2 -0
- package/dist/sync-impl/mod.js.map +1 -0
- package/dist/sync-impl/ws-impl.d.ts +3 -15
- package/dist/sync-impl/ws-impl.d.ts.map +1 -1
- package/dist/sync-impl/ws-impl.js +89 -36
- package/dist/sync-impl/ws-impl.js.map +1 -1
- package/package.json +15 -13
- package/src/cf-worker/durable-object.ts +309 -177
- package/src/cf-worker/mod.ts +2 -0
- package/src/cf-worker/worker.ts +85 -0
- package/src/common/mod.ts +8 -0
- package/src/common/ws-message-types.ts +22 -36
- package/src/sync-impl/ws-impl.ts +146 -100
- package/dist/cf-worker/index.d.ts +0 -8
- package/dist/cf-worker/index.d.ts.map +0 -1
- package/dist/cf-worker/index.js +0 -67
- package/dist/cf-worker/index.js.map +0 -1
- package/dist/common/index.d.ts +0 -2
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js +0 -2
- package/dist/common/index.js.map +0 -1
- package/dist/sync-impl/index.d.ts +0 -2
- package/dist/sync-impl/index.d.ts.map +0 -1
- package/dist/sync-impl/index.js +0 -2
- package/dist/sync-impl/index.js.map +0 -1
- package/src/cf-worker/index.ts +0 -84
- package/src/common/index.ts +0 -1
- /package/src/sync-impl/{index.ts → mod.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
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
|
|
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;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;;;IA3GjC,wDAAwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2GiD,CAAA;AAC3G,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC,IAAI,CAAA"}
|
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LiveStoreEvent } from '@livestore/common/schema';
|
|
2
2
|
import { Schema } from '@livestore/utils/effect';
|
|
3
3
|
export const PullReq = Schema.TaggedStruct('WSMessage.PullReq', {
|
|
4
4
|
requestId: Schema.String,
|
|
5
5
|
/** Omitting the cursor will start from the beginning */
|
|
6
6
|
cursor: Schema.optional(Schema.Number),
|
|
7
|
-
});
|
|
7
|
+
}).annotations({ title: '@livestore/sync-cf:PullReq' });
|
|
8
8
|
export const SyncMetadata = Schema.Struct({
|
|
9
9
|
/** ISO date format */
|
|
10
10
|
createdAt: Schema.String,
|
|
11
|
-
});
|
|
11
|
+
}).annotations({ title: '@livestore/sync-cf:SyncMetadata' });
|
|
12
12
|
export const PullRes = Schema.TaggedStruct('WSMessage.PullRes', {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
mutationEventEncoded: MutationEvent.EncodedAny,
|
|
13
|
+
batch: Schema.Array(Schema.Struct({
|
|
14
|
+
eventEncoded: LiveStoreEvent.AnyEncodedGlobal,
|
|
16
15
|
metadata: Schema.Option(SyncMetadata),
|
|
17
16
|
})),
|
|
17
|
+
requestId: Schema.Struct({ context: Schema.Literal('pull', 'push'), requestId: Schema.String }),
|
|
18
18
|
remaining: Schema.Number,
|
|
19
|
-
});
|
|
20
|
-
export const PushBroadcast = Schema.TaggedStruct('WSMessage.PushBroadcast', {
|
|
21
|
-
mutationEventEncoded: MutationEvent.EncodedAny,
|
|
22
|
-
metadata: Schema.Option(SyncMetadata),
|
|
23
|
-
});
|
|
19
|
+
}).annotations({ title: '@livestore/sync-cf:PullRes' });
|
|
24
20
|
export const PushReq = Schema.TaggedStruct('WSMessage.PushReq', {
|
|
25
21
|
requestId: Schema.String,
|
|
26
|
-
batch: Schema.Array(
|
|
27
|
-
});
|
|
22
|
+
batch: Schema.Array(LiveStoreEvent.AnyEncodedGlobal),
|
|
23
|
+
}).annotations({ title: '@livestore/sync-cf:PushReq' });
|
|
28
24
|
export const PushAck = Schema.TaggedStruct('WSMessage.PushAck', {
|
|
29
25
|
requestId: Schema.String,
|
|
30
|
-
|
|
31
|
-
});
|
|
26
|
+
}).annotations({ title: '@livestore/sync-cf:PushAck' });
|
|
32
27
|
export const Error = Schema.TaggedStruct('WSMessage.Error', {
|
|
33
28
|
requestId: Schema.String,
|
|
34
29
|
message: Schema.String,
|
|
35
|
-
});
|
|
30
|
+
}).annotations({ title: '@livestore/sync-cf:Error' });
|
|
36
31
|
export const Ping = Schema.TaggedStruct('WSMessage.Ping', {
|
|
37
32
|
requestId: Schema.Literal('ping'),
|
|
38
|
-
});
|
|
33
|
+
}).annotations({ title: '@livestore/sync-cf:Ping' });
|
|
39
34
|
export const Pong = Schema.TaggedStruct('WSMessage.Pong', {
|
|
40
35
|
requestId: Schema.Literal('ping'),
|
|
41
|
-
});
|
|
36
|
+
}).annotations({ title: '@livestore/sync-cf:Pong' });
|
|
42
37
|
export const AdminResetRoomReq = Schema.TaggedStruct('WSMessage.AdminResetRoomReq', {
|
|
43
38
|
requestId: Schema.String,
|
|
44
39
|
adminSecret: Schema.String,
|
|
45
|
-
});
|
|
40
|
+
}).annotations({ title: '@livestore/sync-cf:AdminResetRoomReq' });
|
|
46
41
|
export const AdminResetRoomRes = Schema.TaggedStruct('WSMessage.AdminResetRoomRes', {
|
|
47
42
|
requestId: Schema.String,
|
|
48
|
-
});
|
|
43
|
+
}).annotations({ title: '@livestore/sync-cf:AdminResetRoomRes' });
|
|
49
44
|
export const AdminInfoReq = Schema.TaggedStruct('WSMessage.AdminInfoReq', {
|
|
50
45
|
requestId: Schema.String,
|
|
51
46
|
adminSecret: Schema.String,
|
|
52
|
-
});
|
|
47
|
+
}).annotations({ title: '@livestore/sync-cf:AdminInfoReq' });
|
|
53
48
|
export const AdminInfoRes = Schema.TaggedStruct('WSMessage.AdminInfoRes', {
|
|
54
49
|
requestId: Schema.String,
|
|
55
50
|
info: Schema.Struct({
|
|
56
51
|
durableObjectId: Schema.String,
|
|
57
52
|
}),
|
|
58
|
-
});
|
|
59
|
-
export const Message = Schema.Union(PullReq, PullRes,
|
|
60
|
-
export const BackendToClientMessage = Schema.Union(PullRes,
|
|
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);
|
|
61
56
|
export const ClientToBackendMessage = Schema.Union(PullReq, PushReq, AdminResetRoomReq, AdminInfoReq, Ping);
|
|
62
57
|
//# sourceMappingURL=ws-message-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-message-types.js","sourceRoot":"","sources":["../../src/common/ws-message-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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;A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M,CAAC,YAAY,CAAC,wBAAwB,EAAE;IACxE,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/sync-impl/mod.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/sync-impl/mod.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Scope } from '@livestore/utils/effect';
|
|
3
|
-
import { Effect } from '@livestore/utils/effect';
|
|
1
|
+
import type { SyncBackendConstructor } from '@livestore/common';
|
|
4
2
|
import type { SyncMetadata } from '../common/ws-message-types.js';
|
|
5
|
-
export interface WsSyncOptions
|
|
6
|
-
type: 'cf';
|
|
3
|
+
export interface WsSyncOptions {
|
|
7
4
|
url: string;
|
|
8
|
-
roomId: string;
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
syncBackend: WsSyncOptions;
|
|
12
|
-
}
|
|
13
|
-
declare global {
|
|
14
|
-
interface LiveStoreGlobal extends LiveStoreGlobalCf {
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export declare const makeWsSync: (options: WsSyncOptions) => Effect.Effect<SyncBackend<SyncMetadata>, never, Scope.Scope>;
|
|
18
|
-
export {};
|
|
6
|
+
export declare const makeCfSync: (options: WsSyncOptions) => SyncBackendConstructor<SyncMetadata>;
|
|
19
7
|
//# sourceMappingURL=ws-impl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-impl.d.ts","sourceRoot":"","sources":["../../src/sync-impl/ws-impl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
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,44 +1,92 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
|
-
import { InvalidPullError, InvalidPushError } from '@livestore/common';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { InvalidPullError, InvalidPushError, UnexpectedError } from '@livestore/common';
|
|
3
|
+
import { EventId } 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';
|
|
5
6
|
import { nanoid } from '@livestore/utils/nanoid';
|
|
6
|
-
import { WSMessage } from '../common/
|
|
7
|
-
export const
|
|
8
|
-
const
|
|
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)}`;
|
|
9
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;
|
|
10
25
|
const api = {
|
|
11
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,
|
|
12
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;
|
|
13
35
|
const requestId = nanoid();
|
|
14
36
|
const cursor = Option.getOrUndefined(args)?.cursor.global;
|
|
15
37
|
yield* send(WSMessage.PullReq.make({ cursor, requestId }));
|
|
16
|
-
return Stream.fromPubSub(incomingMessages).pipe(Stream.
|
|
38
|
+
return Stream.fromPubSub(incomingMessages).pipe(Stream.tap((_) => _._tag === 'WSMessage.Error' && _.requestId === requestId
|
|
17
39
|
? new InvalidPullError({ message: _.message })
|
|
18
|
-
: Effect.void), Stream.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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.id ?? EventId.ROOT.global;
|
|
47
|
+
// Index where stashed events are greater than pullResHead
|
|
48
|
+
const newPartialBatchIndex = stashedPullBatch.findIndex((batchItem) => batchItem.eventEncoded.id > 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
|
+
}));
|
|
27
74
|
}).pipe(Stream.unwrap),
|
|
28
75
|
push: (batch) => Effect.gen(function* () {
|
|
29
|
-
const
|
|
76
|
+
const pushAck = yield* Deferred.make();
|
|
30
77
|
const requestId = nanoid();
|
|
31
|
-
yield* Stream.fromPubSub(incomingMessages).pipe(Stream.
|
|
32
|
-
? Deferred.fail(
|
|
33
|
-
: Effect.void), Stream.filter(
|
|
34
|
-
// TODO bring back filterting of "own events"
|
|
35
|
-
// Stream.filter((_) => _.mutationId === mutationEventEncoded.id.global),
|
|
36
|
-
Stream.take(1), Stream.tap(() => Deferred.succeed(ready, void 0)), Stream.runDrain, Effect.tapCauseLogPretty, Effect.fork);
|
|
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);
|
|
37
81
|
yield* send(WSMessage.PushReq.make({ batch, requestId }));
|
|
38
|
-
yield*
|
|
39
|
-
const createdAt = new Date().toISOString();
|
|
40
|
-
return { metadata: Array.from({ length: batch.length }, () => Option.some({ createdAt })) };
|
|
82
|
+
yield* pushAck;
|
|
41
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
|
+
},
|
|
42
90
|
};
|
|
43
91
|
return api;
|
|
44
92
|
});
|
|
@@ -50,17 +98,19 @@ const connect = (wsUrl) => Effect.gen(function* () {
|
|
|
50
98
|
const send = (message) => Effect.gen(function* () {
|
|
51
99
|
// Wait first until we're online
|
|
52
100
|
yield* waitUntilOnline;
|
|
53
|
-
yield* Effect.spanEvent(`Sending message: ${message._tag}`, message._tag === 'WSMessage.PushReq'
|
|
54
|
-
? {
|
|
55
|
-
id: message.batch[0].id.global,
|
|
56
|
-
parentId: message.batch[0].parentId.global,
|
|
57
|
-
batchLength: message.batch.length,
|
|
58
|
-
}
|
|
59
|
-
: message._tag === 'WSMessage.PullReq'
|
|
60
|
-
? { cursor: message.cursor ?? '-' }
|
|
61
|
-
: {});
|
|
62
101
|
// TODO use MsgPack instead of JSON to speed up the serialization / reduce the size of the messages
|
|
63
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
|
+
id: message.batch[0].id,
|
|
107
|
+
parentId: message.batch[0].parentId,
|
|
108
|
+
batchLength: message.batch.length,
|
|
109
|
+
}
|
|
110
|
+
: message._tag === 'WSMessage.PullReq'
|
|
111
|
+
? { cursor: message.cursor ?? '-' }
|
|
112
|
+
: {});
|
|
113
|
+
}
|
|
64
114
|
});
|
|
65
115
|
const innerConnect = Effect.gen(function* () {
|
|
66
116
|
// If the browser already tells us we're offline, then we'll at least wait until the browser
|
|
@@ -68,10 +118,12 @@ const connect = (wsUrl) => Effect.gen(function* () {
|
|
|
68
118
|
while (typeof navigator !== 'undefined' && navigator.onLine === false) {
|
|
69
119
|
yield* Effect.sleep(1000);
|
|
70
120
|
}
|
|
121
|
+
// TODO bring this back in a cross-platform way
|
|
71
122
|
// if (navigator.onLine === false) {
|
|
72
123
|
// yield* Effect.async((cb) => self.addEventListener('online', () => cb(Effect.void)))
|
|
73
124
|
// }
|
|
74
125
|
const socket = yield* WebSocket.makeWebSocket({ url: wsUrl, reconnect: Schedule.exponential(100) });
|
|
126
|
+
// socket.binaryType = 'arraybuffer'
|
|
75
127
|
yield* SubscriptionRef.set(isConnected, true);
|
|
76
128
|
socketRef.current = socket;
|
|
77
129
|
const connectionClosed = yield* Deferred.make();
|
|
@@ -100,7 +152,8 @@ const connect = (wsUrl) => Effect.gen(function* () {
|
|
|
100
152
|
// NOTE it seems that this callback doesn't work reliably on a worker but only via `window.addEventListener`
|
|
101
153
|
// We might need to proxy the event from the main thread to the worker if we want this to work reliably.
|
|
102
154
|
// eslint-disable-next-line unicorn/prefer-global-this
|
|
103
|
-
if (typeof self !== 'undefined') {
|
|
155
|
+
if (typeof self !== 'undefined' && typeof self.addEventListener === 'function') {
|
|
156
|
+
// TODO support an Expo equivalent for this
|
|
104
157
|
// eslint-disable-next-line unicorn/prefer-global-this
|
|
105
158
|
yield* Effect.eventListener(self, 'offline', () => Deferred.succeed(connectionClosed, void 0));
|
|
106
159
|
}
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,mBAAmB,CAAA;
|
|
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,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,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,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ErE,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IAE3G,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAA;AAChD,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/sync-cf",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.30",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
5
6
|
"exports": {
|
|
6
7
|
".": {
|
|
7
|
-
"types": "./dist/sync-impl/
|
|
8
|
-
"default": "./dist/sync-impl/
|
|
8
|
+
"types": "./dist/sync-impl/mod.d.ts",
|
|
9
|
+
"default": "./dist/sync-impl/mod.js"
|
|
10
|
+
},
|
|
11
|
+
"./cf-worker": {
|
|
12
|
+
"types": "./dist/cf-worker/mod.d.ts",
|
|
13
|
+
"default": "./dist/cf-worker/mod.js"
|
|
9
14
|
}
|
|
10
15
|
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@livestore/common": "0.3.0-dev.30",
|
|
18
|
+
"@livestore/utils": "0.3.0-dev.30"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@cloudflare/workers-types": "^4.20250303.0"
|
|
22
|
+
},
|
|
11
23
|
"files": [
|
|
12
24
|
"dist",
|
|
13
25
|
"src",
|
|
14
26
|
"package.json",
|
|
15
27
|
"README.md"
|
|
16
28
|
],
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@livestore/common": "0.3.0-dev.3",
|
|
19
|
-
"@livestore/utils": "0.3.0-dev.3"
|
|
20
|
-
},
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@cloudflare/workers-types": "4.20241022.0",
|
|
23
|
-
"wrangler": "^3.84.0"
|
|
24
|
-
},
|
|
25
29
|
"publishConfig": {
|
|
26
30
|
"access": "public"
|
|
27
31
|
},
|
|
28
32
|
"scripts": {
|
|
29
|
-
"dev": "wrangler dev --inspector-port 9230",
|
|
30
|
-
"deploy": "wrangler publish",
|
|
31
33
|
"test": "echo 'No tests yet'"
|
|
32
34
|
}
|
|
33
35
|
}
|