@livestore/sync-cf 0.3.0-dev.27 → 0.3.0-dev.29
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 +16 -19
- package/dist/cf-worker/durable-object.d.ts.map +1 -1
- package/dist/cf-worker/durable-object.js +24 -21
- package/dist/cf-worker/durable-object.js.map +1 -1
- package/dist/common/ws-message-types.d.ts +9 -9
- package/dist/common/ws-message-types.d.ts.map +1 -1
- package/dist/common/ws-message-types.js +3 -3
- package/dist/common/ws-message-types.js.map +1 -1
- package/dist/sync-impl/ws-impl.js +2 -2
- package/dist/sync-impl/ws-impl.js.map +1 -1
- package/package.json +3 -3
- package/src/cf-worker/durable-object.ts +28 -25
- package/src/common/ws-message-types.ts +3 -3
- package/src/sync-impl/ws-impl.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LiveStoreEvent } from '@livestore/common/schema'
|
|
2
2
|
import { Schema } from '@livestore/utils/effect'
|
|
3
3
|
|
|
4
4
|
export const PullReq = Schema.TaggedStruct('WSMessage.PullReq', {
|
|
@@ -19,7 +19,7 @@ export type SyncMetadata = typeof SyncMetadata.Type
|
|
|
19
19
|
export const PullRes = Schema.TaggedStruct('WSMessage.PullRes', {
|
|
20
20
|
batch: Schema.Array(
|
|
21
21
|
Schema.Struct({
|
|
22
|
-
|
|
22
|
+
eventEncoded: LiveStoreEvent.AnyEncodedGlobal,
|
|
23
23
|
metadata: Schema.Option(SyncMetadata),
|
|
24
24
|
}),
|
|
25
25
|
),
|
|
@@ -31,7 +31,7 @@ export type PullRes = typeof PullRes.Type
|
|
|
31
31
|
|
|
32
32
|
export const PushReq = Schema.TaggedStruct('WSMessage.PushReq', {
|
|
33
33
|
requestId: Schema.String,
|
|
34
|
-
batch: Schema.Array(
|
|
34
|
+
batch: Schema.Array(LiveStoreEvent.AnyEncodedGlobal),
|
|
35
35
|
}).annotations({ title: '@livestore/sync-cf:PushReq' })
|
|
36
36
|
|
|
37
37
|
export type PushReq = typeof PushReq.Type
|
package/src/sync-impl/ws-impl.ts
CHANGED
|
@@ -83,10 +83,10 @@ export const makeCfSync =
|
|
|
83
83
|
pullResponseReceived = true
|
|
84
84
|
|
|
85
85
|
if (stashedPullBatch.length > 0 && msg.remaining === 0) {
|
|
86
|
-
const pullResHead = msg.batch.at(-1)?.
|
|
86
|
+
const pullResHead = msg.batch.at(-1)?.eventEncoded.id ?? EventId.ROOT.global
|
|
87
87
|
// Index where stashed events are greater than pullResHead
|
|
88
88
|
const newPartialBatchIndex = stashedPullBatch.findIndex(
|
|
89
|
-
(batchItem) => batchItem.
|
|
89
|
+
(batchItem) => batchItem.eventEncoded.id > pullResHead,
|
|
90
90
|
)
|
|
91
91
|
const batchWithNewStashedEvents =
|
|
92
92
|
newPartialBatchIndex === -1 ? [] : stashedPullBatch.slice(newPartialBatchIndex)
|