@loro-dev/streams-crdt 0.16.0 → 0.16.1
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/flock.d.ts +1 -1
- package/dist/flock.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/loro.d.ts +1 -1
- package/dist/loro.js +1 -1
- package/dist/{stream-id-DwQujw_H.js → stream-id-BERJQKYV.js} +84 -30
- package/dist/{stream-id-DwQujw_H.js.map → stream-id-BERJQKYV.js.map} +1 -1
- package/dist/{stream-id-BEEukuNT.d.ts → stream-id-DEOH5LmQ.d.ts} +10 -1
- package/package.json +1 -1
package/dist/flock.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as WriteOnlyAppendResult, A as PayloadProtectionProviderConfig, B as StreamsAuthProvider, C as LocalSyncStats, D as PayloadProtectionOpenInput, E as PayloadProtectionKind, F as Result, G as TransportCreateStreamSuccess, H as StreamsCrdtShardUrlsOptions, I as SnapshotCodec, J as TransportJoinParams, K as TransportDeleteStreamSuccess, L as SnapshotTransformHook, M as PayloadProtectionSealInput, N as PayloadProtectionSealResult, O as PayloadProtectionOptions, P as PayloadProtectionWritePolicy, Q as TransportSyncSuccess, R as SnapshotUploadOptions, S as JsonValue, T as PayloadProtectionFailureReason, U as TransportCatchupParams, V as StreamsCrdtOptions, W as TransportCatchupSuccess, X as TransportSnapshotUploadSuccess, Y as TransportRoomStatus, Z as TransportSubscription, _ as EphemeralStreamCrdtOptions, a as StreamsCrdt, at as RemoteCursor, b as IsolatedCrdtAdapter, c as CrdtApplyReturn, ct as createInitialRemoteCursor, d as E2eeOptions, et as BeforeRemoteCursorSaveContext, f as E2eeProvider, g as EphemeralStreamAdaptor, h as E2eeWritePolicy, i as EphemeralStreamCrdt, it as IndexedDbRemoteCursorStoreOptions, j as PayloadProtectionReadPolicy, k as PayloadProtectionProvider, l as CrdtUnresolvedSpan, m as E2eeReadPolicy, n as PayloadProtectionError, nt as InMemoryRemoteCursorStore, o as CrdtAdapter, ot as RemoteCursorSaveSource, p as E2eeProviderConfig, q as TransportError, r as LocalAppendFailedError, rt as IndexedDbRemoteCursorStore, s as CrdtApplyOutcome, st as RemoteCursorStore, t as isValidRillId, tt as BeforeRemoteCursorSaveHook, u as CrdtUpdateBatch, v as EphemeralStreamJoinParams, w as PayloadProtectionContext, x as JsonObject, y as EphemeralStreamSubscription, z as StreamsAuthContext } from "./stream-id-
|
|
1
|
+
import { $ as WriteOnlyAppendResult, A as PayloadProtectionProviderConfig, B as StreamsAuthProvider, C as LocalSyncStats, D as PayloadProtectionOpenInput, E as PayloadProtectionKind, F as Result, G as TransportCreateStreamSuccess, H as StreamsCrdtShardUrlsOptions, I as SnapshotCodec, J as TransportJoinParams, K as TransportDeleteStreamSuccess, L as SnapshotTransformHook, M as PayloadProtectionSealInput, N as PayloadProtectionSealResult, O as PayloadProtectionOptions, P as PayloadProtectionWritePolicy, Q as TransportSyncSuccess, R as SnapshotUploadOptions, S as JsonValue, T as PayloadProtectionFailureReason, U as TransportCatchupParams, V as StreamsCrdtOptions, W as TransportCatchupSuccess, X as TransportSnapshotUploadSuccess, Y as TransportRoomStatus, Z as TransportSubscription, _ as EphemeralStreamCrdtOptions, a as StreamsCrdt, at as RemoteCursor, b as IsolatedCrdtAdapter, c as CrdtApplyReturn, ct as createInitialRemoteCursor, d as E2eeOptions, et as BeforeRemoteCursorSaveContext, f as E2eeProvider, g as EphemeralStreamAdaptor, h as E2eeWritePolicy, i as EphemeralStreamCrdt, it as IndexedDbRemoteCursorStoreOptions, j as PayloadProtectionReadPolicy, k as PayloadProtectionProvider, l as CrdtUnresolvedSpan, m as E2eeReadPolicy, n as PayloadProtectionError, nt as InMemoryRemoteCursorStore, o as CrdtAdapter, ot as RemoteCursorSaveSource, p as E2eeProviderConfig, q as TransportError, r as LocalAppendFailedError, rt as IndexedDbRemoteCursorStore, s as CrdtApplyOutcome, st as RemoteCursorStore, t as isValidRillId, tt as BeforeRemoteCursorSaveHook, u as CrdtUpdateBatch, v as EphemeralStreamJoinParams, w as PayloadProtectionContext, x as JsonObject, y as EphemeralStreamSubscription, z as StreamsAuthContext } from "./stream-id-DEOH5LmQ.js";
|
|
2
2
|
import { ExportBundle, Flock, VersionVector, VersionVector as VersionVector$1 } from "@loro-dev/flock-wasm";
|
|
3
3
|
|
|
4
4
|
//#region src/flock.d.ts
|
package/dist/flock.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createInitialRemoteCursor, c as PayloadProtectionError, i as IndexedDbRemoteCursorStore, n as StreamsCrdt, o as EphemeralStreamCrdt, r as InMemoryRemoteCursorStore, s as LocalAppendFailedError, t as isValidRillId } from "./stream-id-
|
|
1
|
+
import { a as createInitialRemoteCursor, c as PayloadProtectionError, i as IndexedDbRemoteCursorStore, n as StreamsCrdt, o as EphemeralStreamCrdt, r as InMemoryRemoteCursorStore, s as LocalAppendFailedError, t as isValidRillId } from "./stream-id-BERJQKYV.js";
|
|
2
2
|
import { Flock } from "@loro-dev/flock-wasm";
|
|
3
3
|
//#region src/flock.ts
|
|
4
4
|
function isAfter(entry, current) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as WriteOnlyAppendResult, A as PayloadProtectionProviderConfig, B as StreamsAuthProvider, C as LocalSyncStats, D as PayloadProtectionOpenInput, E as PayloadProtectionKind, F as Result, G as TransportCreateStreamSuccess, H as StreamsCrdtShardUrlsOptions, I as SnapshotCodec, J as TransportJoinParams, K as TransportDeleteStreamSuccess, L as SnapshotTransformHook, M as PayloadProtectionSealInput, N as PayloadProtectionSealResult, O as PayloadProtectionOptions, P as PayloadProtectionWritePolicy, Q as TransportSyncSuccess, R as SnapshotUploadOptions, S as JsonValue, T as PayloadProtectionFailureReason, U as TransportCatchupParams, V as StreamsCrdtOptions, W as TransportCatchupSuccess, X as TransportSnapshotUploadSuccess, Y as TransportRoomStatus, Z as TransportSubscription, _ as EphemeralStreamCrdtOptions, a as StreamsCrdt, at as RemoteCursor, b as IsolatedCrdtAdapter, c as CrdtApplyReturn, ct as createInitialRemoteCursor, d as E2eeOptions, et as BeforeRemoteCursorSaveContext, f as E2eeProvider, g as EphemeralStreamAdaptor, h as E2eeWritePolicy, i as EphemeralStreamCrdt, it as IndexedDbRemoteCursorStoreOptions, j as PayloadProtectionReadPolicy, k as PayloadProtectionProvider, l as CrdtUnresolvedSpan, m as E2eeReadPolicy, n as PayloadProtectionError, nt as InMemoryRemoteCursorStore, o as CrdtAdapter, ot as RemoteCursorSaveSource, p as E2eeProviderConfig, q as TransportError, r as LocalAppendFailedError, rt as IndexedDbRemoteCursorStore, s as CrdtApplyOutcome, st as RemoteCursorStore, t as isValidRillId, tt as BeforeRemoteCursorSaveHook, u as CrdtUpdateBatch, v as EphemeralStreamJoinParams, w as PayloadProtectionContext, x as JsonObject, y as EphemeralStreamSubscription, z as StreamsAuthContext } from "./stream-id-
|
|
1
|
+
import { $ as WriteOnlyAppendResult, A as PayloadProtectionProviderConfig, B as StreamsAuthProvider, C as LocalSyncStats, D as PayloadProtectionOpenInput, E as PayloadProtectionKind, F as Result, G as TransportCreateStreamSuccess, H as StreamsCrdtShardUrlsOptions, I as SnapshotCodec, J as TransportJoinParams, K as TransportDeleteStreamSuccess, L as SnapshotTransformHook, M as PayloadProtectionSealInput, N as PayloadProtectionSealResult, O as PayloadProtectionOptions, P as PayloadProtectionWritePolicy, Q as TransportSyncSuccess, R as SnapshotUploadOptions, S as JsonValue, T as PayloadProtectionFailureReason, U as TransportCatchupParams, V as StreamsCrdtOptions, W as TransportCatchupSuccess, X as TransportSnapshotUploadSuccess, Y as TransportRoomStatus, Z as TransportSubscription, _ as EphemeralStreamCrdtOptions, a as StreamsCrdt, at as RemoteCursor, b as IsolatedCrdtAdapter, c as CrdtApplyReturn, ct as createInitialRemoteCursor, d as E2eeOptions, et as BeforeRemoteCursorSaveContext, f as E2eeProvider, g as EphemeralStreamAdaptor, h as E2eeWritePolicy, i as EphemeralStreamCrdt, it as IndexedDbRemoteCursorStoreOptions, j as PayloadProtectionReadPolicy, k as PayloadProtectionProvider, l as CrdtUnresolvedSpan, m as E2eeReadPolicy, n as PayloadProtectionError, nt as InMemoryRemoteCursorStore, o as CrdtAdapter, ot as RemoteCursorSaveSource, p as E2eeProviderConfig, q as TransportError, r as LocalAppendFailedError, rt as IndexedDbRemoteCursorStore, s as CrdtApplyOutcome, st as RemoteCursorStore, t as isValidRillId, tt as BeforeRemoteCursorSaveHook, u as CrdtUpdateBatch, v as EphemeralStreamJoinParams, w as PayloadProtectionContext, x as JsonObject, y as EphemeralStreamSubscription, z as StreamsAuthContext } from "./stream-id-DEOH5LmQ.js";
|
|
2
2
|
export { BeforeRemoteCursorSaveContext, BeforeRemoteCursorSaveHook, CrdtAdapter, CrdtApplyOutcome, CrdtApplyReturn, CrdtUnresolvedSpan, CrdtUpdateBatch, PayloadProtectionError as E2eeError, PayloadProtectionError, E2eeOptions, E2eeProvider, E2eeProviderConfig, E2eeReadPolicy, E2eeWritePolicy, EphemeralStreamAdaptor, EphemeralStreamCrdt, EphemeralStreamCrdtOptions, EphemeralStreamJoinParams, EphemeralStreamSubscription, InMemoryRemoteCursorStore, IndexedDbRemoteCursorStore, IndexedDbRemoteCursorStoreOptions, IsolatedCrdtAdapter, JsonObject, JsonValue, LocalAppendFailedError, LocalSyncStats, PayloadProtectionContext, PayloadProtectionFailureReason, PayloadProtectionKind, PayloadProtectionOpenInput, PayloadProtectionOptions, PayloadProtectionProvider, PayloadProtectionProviderConfig, PayloadProtectionReadPolicy, PayloadProtectionSealInput, PayloadProtectionSealResult, PayloadProtectionWritePolicy, RemoteCursor, RemoteCursorSaveSource, RemoteCursorStore, Result, SnapshotCodec, SnapshotTransformHook, SnapshotUploadOptions, StreamsAuthContext, StreamsAuthProvider, StreamsCrdt, StreamsCrdtOptions, StreamsCrdtShardUrlsOptions, TransportCatchupParams, TransportCatchupSuccess, TransportCreateStreamSuccess, TransportDeleteStreamSuccess, TransportError, TransportJoinParams, TransportRoomStatus, TransportSnapshotUploadSuccess, TransportSubscription, TransportSyncSuccess, WriteOnlyAppendResult, createInitialRemoteCursor, isValidRillId };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createInitialRemoteCursor, c as PayloadProtectionError, i as IndexedDbRemoteCursorStore, n as StreamsCrdt, o as EphemeralStreamCrdt, r as InMemoryRemoteCursorStore, s as LocalAppendFailedError, t as isValidRillId } from "./stream-id-
|
|
1
|
+
import { a as createInitialRemoteCursor, c as PayloadProtectionError, i as IndexedDbRemoteCursorStore, n as StreamsCrdt, o as EphemeralStreamCrdt, r as InMemoryRemoteCursorStore, s as LocalAppendFailedError, t as isValidRillId } from "./stream-id-BERJQKYV.js";
|
|
2
2
|
export { PayloadProtectionError as E2eeError, PayloadProtectionError, EphemeralStreamCrdt, InMemoryRemoteCursorStore, IndexedDbRemoteCursorStore, LocalAppendFailedError, StreamsCrdt, createInitialRemoteCursor, isValidRillId };
|
package/dist/loro.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as WriteOnlyAppendResult, A as PayloadProtectionProviderConfig, B as StreamsAuthProvider, C as LocalSyncStats, D as PayloadProtectionOpenInput, E as PayloadProtectionKind, F as Result, G as TransportCreateStreamSuccess, H as StreamsCrdtShardUrlsOptions, I as SnapshotCodec, J as TransportJoinParams, K as TransportDeleteStreamSuccess, L as SnapshotTransformHook, M as PayloadProtectionSealInput, N as PayloadProtectionSealResult, O as PayloadProtectionOptions, P as PayloadProtectionWritePolicy, Q as TransportSyncSuccess, R as SnapshotUploadOptions, S as JsonValue, T as PayloadProtectionFailureReason, U as TransportCatchupParams, V as StreamsCrdtOptions, W as TransportCatchupSuccess, X as TransportSnapshotUploadSuccess, Y as TransportRoomStatus, Z as TransportSubscription, _ as EphemeralStreamCrdtOptions, a as StreamsCrdt, at as RemoteCursor, b as IsolatedCrdtAdapter, c as CrdtApplyReturn, ct as createInitialRemoteCursor, d as E2eeOptions, et as BeforeRemoteCursorSaveContext, f as E2eeProvider, g as EphemeralStreamAdaptor, h as E2eeWritePolicy, i as EphemeralStreamCrdt, it as IndexedDbRemoteCursorStoreOptions, j as PayloadProtectionReadPolicy, k as PayloadProtectionProvider, l as CrdtUnresolvedSpan, m as E2eeReadPolicy, n as PayloadProtectionError, nt as InMemoryRemoteCursorStore, o as CrdtAdapter, ot as RemoteCursorSaveSource, p as E2eeProviderConfig, q as TransportError, r as LocalAppendFailedError, rt as IndexedDbRemoteCursorStore, s as CrdtApplyOutcome, st as RemoteCursorStore, t as isValidRillId, tt as BeforeRemoteCursorSaveHook, u as CrdtUpdateBatch, v as EphemeralStreamJoinParams, w as PayloadProtectionContext, x as JsonObject, y as EphemeralStreamSubscription, z as StreamsAuthContext } from "./stream-id-
|
|
1
|
+
import { $ as WriteOnlyAppendResult, A as PayloadProtectionProviderConfig, B as StreamsAuthProvider, C as LocalSyncStats, D as PayloadProtectionOpenInput, E as PayloadProtectionKind, F as Result, G as TransportCreateStreamSuccess, H as StreamsCrdtShardUrlsOptions, I as SnapshotCodec, J as TransportJoinParams, K as TransportDeleteStreamSuccess, L as SnapshotTransformHook, M as PayloadProtectionSealInput, N as PayloadProtectionSealResult, O as PayloadProtectionOptions, P as PayloadProtectionWritePolicy, Q as TransportSyncSuccess, R as SnapshotUploadOptions, S as JsonValue, T as PayloadProtectionFailureReason, U as TransportCatchupParams, V as StreamsCrdtOptions, W as TransportCatchupSuccess, X as TransportSnapshotUploadSuccess, Y as TransportRoomStatus, Z as TransportSubscription, _ as EphemeralStreamCrdtOptions, a as StreamsCrdt, at as RemoteCursor, b as IsolatedCrdtAdapter, c as CrdtApplyReturn, ct as createInitialRemoteCursor, d as E2eeOptions, et as BeforeRemoteCursorSaveContext, f as E2eeProvider, g as EphemeralStreamAdaptor, h as E2eeWritePolicy, i as EphemeralStreamCrdt, it as IndexedDbRemoteCursorStoreOptions, j as PayloadProtectionReadPolicy, k as PayloadProtectionProvider, l as CrdtUnresolvedSpan, m as E2eeReadPolicy, n as PayloadProtectionError, nt as InMemoryRemoteCursorStore, o as CrdtAdapter, ot as RemoteCursorSaveSource, p as E2eeProviderConfig, q as TransportError, r as LocalAppendFailedError, rt as IndexedDbRemoteCursorStore, s as CrdtApplyOutcome, st as RemoteCursorStore, t as isValidRillId, tt as BeforeRemoteCursorSaveHook, u as CrdtUpdateBatch, v as EphemeralStreamJoinParams, w as PayloadProtectionContext, x as JsonObject, y as EphemeralStreamSubscription, z as StreamsAuthContext } from "./stream-id-DEOH5LmQ.js";
|
|
2
2
|
import { LoroDoc } from "loro-crdt";
|
|
3
3
|
|
|
4
4
|
//#region src/loro.d.ts
|
package/dist/loro.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createInitialRemoteCursor, c as PayloadProtectionError, i as IndexedDbRemoteCursorStore, n as StreamsCrdt, o as EphemeralStreamCrdt, r as InMemoryRemoteCursorStore, s as LocalAppendFailedError, t as isValidRillId } from "./stream-id-
|
|
1
|
+
import { a as createInitialRemoteCursor, c as PayloadProtectionError, i as IndexedDbRemoteCursorStore, n as StreamsCrdt, o as EphemeralStreamCrdt, r as InMemoryRemoteCursorStore, s as LocalAppendFailedError, t as isValidRillId } from "./stream-id-BERJQKYV.js";
|
|
2
2
|
import { LoroDoc, VersionVector, decodeImportBlobMeta } from "loro-crdt";
|
|
3
3
|
//#region src/loro.ts
|
|
4
4
|
function batchImportUpdates(doc, updates) {
|
|
@@ -3175,12 +3175,46 @@ var StreamsCrdt = class StreamsCrdt {
|
|
|
3175
3175
|
}
|
|
3176
3176
|
}
|
|
3177
3177
|
async syncOnce(operation, parentSignal) {
|
|
3178
|
-
|
|
3178
|
+
return this.enqueueExclusive(async () => {
|
|
3179
|
+
await this.adapter.flushLocalExports?.();
|
|
3180
|
+
return this.syncOnceExclusive(operation, parentSignal);
|
|
3181
|
+
});
|
|
3182
|
+
}
|
|
3183
|
+
/** Caller owns opQueue; never wait for the background flush from here. */
|
|
3184
|
+
async syncOnceExclusive(operation, parentSignal) {
|
|
3185
|
+
const state = this.joinState;
|
|
3186
|
+
if (state != null && !state.closed) while (!state.closed && state.pendingLocal.length > 0) await this.flushPendingLocalBatchExclusive(state);
|
|
3187
|
+
if ((state == null || state.closed) && this.frozenLocalAppend?.source === "pending") {
|
|
3188
|
+
const frozen = this.frozenLocalAppend;
|
|
3189
|
+
const appended = await this.appendFrozenLocalBatchRemote(frozen);
|
|
3190
|
+
await this.catchupLocalAppend(frozen);
|
|
3191
|
+
this.commitProducerAck(appended.producerAck);
|
|
3192
|
+
}
|
|
3193
|
+
const initial = await this.finalizeDirectLocalAppendIfNeeded(await this.resolveInitialRemoteState(operation, parentSignal));
|
|
3194
|
+
let cursor = initial.cursor;
|
|
3195
|
+
if (state != null && !state.closed) {
|
|
3196
|
+
state.cursor = cursor;
|
|
3197
|
+
state.streamCursor = initial.streamCursor;
|
|
3198
|
+
while (!state.closed && state.pendingLocal.length > 0) {
|
|
3199
|
+
await this.flushPendingLocalBatchExclusive(state);
|
|
3200
|
+
cursor = state.cursor;
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3179
3203
|
const localBatch = this.exportUpdates(cursor.serverLowerBoundVersion);
|
|
3180
|
-
if (localBatch.batch != null)
|
|
3204
|
+
if (localBatch.batch != null) {
|
|
3205
|
+
const appended = await this.appendLocalBatchDurably(cursor, localBatch.batch);
|
|
3206
|
+
cursor = appended.cursor;
|
|
3207
|
+
if (state != null && !state.closed) {
|
|
3208
|
+
state.cursor = cursor;
|
|
3209
|
+
state.streamCursor = appended.streamCursor;
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3181
3212
|
return cursor;
|
|
3182
3213
|
}
|
|
3183
3214
|
async performInitialJoinSync(preferredLiveMode, parentSignal) {
|
|
3215
|
+
return this.enqueueExclusive(() => this.performInitialJoinSyncExclusive(preferredLiveMode, parentSignal));
|
|
3216
|
+
}
|
|
3217
|
+
async performInitialJoinSyncExclusive(preferredLiveMode, parentSignal) {
|
|
3184
3218
|
const initial = await this.finalizeDirectLocalAppendIfNeeded(await this.resolveInitialRemoteState("join", parentSignal));
|
|
3185
3219
|
let cursor = initial.cursor;
|
|
3186
3220
|
let localExportRefVersion = cursor.serverLowerBoundVersion;
|
|
@@ -3190,9 +3224,7 @@ var StreamsCrdt = class StreamsCrdt {
|
|
|
3190
3224
|
localExportRefVersion = exportedLocal.nextRefVersion;
|
|
3191
3225
|
const exportedBatch = exportedLocal.batch;
|
|
3192
3226
|
if (exportedBatch != null) {
|
|
3193
|
-
const
|
|
3194
|
-
const appendStreamCursor = streamCursor;
|
|
3195
|
-
const committed = await this.enqueueExclusive(() => this.appendLocalBatchDurably(appendCursor, exportedBatch, void 0, "direct", appendStreamCursor));
|
|
3227
|
+
const committed = await this.appendLocalBatchDurably(cursor, exportedBatch, void 0, "direct", streamCursor);
|
|
3196
3228
|
cursor = committed.cursor;
|
|
3197
3229
|
streamCursor = committed.streamCursor;
|
|
3198
3230
|
}
|
|
@@ -3971,6 +4003,50 @@ var StreamsCrdt = class StreamsCrdt {
|
|
|
3971
4003
|
return this.drainQueuedBatch(this.pendingWriteOnly);
|
|
3972
4004
|
}
|
|
3973
4005
|
/**
|
|
4006
|
+
* One FIFO transaction, called only while holding opQueue. Selecting the
|
|
4007
|
+
* head and committing its ACK/count must share the lock: sync may drain
|
|
4008
|
+
* the queue while a background writer is queued or sleeping between retries.
|
|
4009
|
+
*/
|
|
4010
|
+
async flushPendingLocalBatchExclusive(state) {
|
|
4011
|
+
while (!state.closed) {
|
|
4012
|
+
const drained = await this.drainPendingBatch(state);
|
|
4013
|
+
if (drained == null || state.closed) return false;
|
|
4014
|
+
try {
|
|
4015
|
+
let committedCount;
|
|
4016
|
+
const initial = await this.finalizeDirectLocalAppendIfNeeded({
|
|
4017
|
+
cursor: state.cursor,
|
|
4018
|
+
streamCursor: state.streamCursor
|
|
4019
|
+
});
|
|
4020
|
+
state.cursor = initial.cursor;
|
|
4021
|
+
state.streamCursor = initial.streamCursor;
|
|
4022
|
+
if (this.cursorManager.isCursorComplete(state.cursor)) {
|
|
4023
|
+
state.cursor = await this.appendLocalBatch(state.cursor, drained.batch, drained.count, state.streamCursor);
|
|
4024
|
+
const streamCursor = this.consumeCommittedLocalStreamCursor();
|
|
4025
|
+
if (streamCursor != null) state.streamCursor = streamCursor;
|
|
4026
|
+
committedCount = this.consumeCommittedPendingCount() ?? drained.count;
|
|
4027
|
+
if (!state.closed) this.snapshotManager.schedule(state);
|
|
4028
|
+
} else {
|
|
4029
|
+
const appended = await this.appendLocalBatchRemote(state.cursor, drained.batch, drained.count, "pending");
|
|
4030
|
+
this.commitProducerAck(appended.producerAck);
|
|
4031
|
+
committedCount = appended.pendingCount ?? drained.count;
|
|
4032
|
+
}
|
|
4033
|
+
for (let i = 0; i < committedCount; i += 1) state.pendingLocal.popFront();
|
|
4034
|
+
this.notifySyncWaiters(state, committedCount);
|
|
4035
|
+
state.flushHeadBatchOnly = false;
|
|
4036
|
+
state.lastWriteError = void 0;
|
|
4037
|
+
this.setWriteSubStatus(state, "ok");
|
|
4038
|
+
return true;
|
|
4039
|
+
} catch (error) {
|
|
4040
|
+
if (isPayloadTooLargeError(error) && drained.count > 1 && this.abandonPendingFrozenLocalAppend()) {
|
|
4041
|
+
state.flushHeadBatchOnly = true;
|
|
4042
|
+
continue;
|
|
4043
|
+
}
|
|
4044
|
+
throw error;
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
return false;
|
|
4048
|
+
}
|
|
4049
|
+
/**
|
|
3974
4050
|
* Drains `pendingLocal` to the server in strict FIFO order.
|
|
3975
4051
|
*
|
|
3976
4052
|
* FIFO invariant: batches are only popped after a durable append, and a
|
|
@@ -3995,34 +4071,12 @@ var StreamsCrdt = class StreamsCrdt {
|
|
|
3995
4071
|
this.clearWriteRetryTimer(state);
|
|
3996
4072
|
state.flushingLocal = true;
|
|
3997
4073
|
try {
|
|
3998
|
-
|
|
3999
|
-
const drained = await this.drainPendingBatch(state);
|
|
4000
|
-
if (drained == null) return;
|
|
4074
|
+
while (!state.closed) {
|
|
4001
4075
|
let attempts = 0;
|
|
4002
4076
|
while (!state.closed) try {
|
|
4003
|
-
|
|
4004
|
-
if (this.cursorManager.isCursorComplete(state.cursor)) {
|
|
4005
|
-
state.cursor = await this.enqueueExclusive(async () => this.appendLocalBatch(state.cursor, drained.batch, drained.count, state.streamCursor));
|
|
4006
|
-
const committedStreamCursor = this.consumeCommittedLocalStreamCursor();
|
|
4007
|
-
if (committedStreamCursor != null) state.streamCursor = committedStreamCursor;
|
|
4008
|
-
committedCount = this.consumeCommittedPendingCount() ?? drained.count;
|
|
4009
|
-
this.snapshotManager.schedule(state);
|
|
4010
|
-
} else {
|
|
4011
|
-
const appended = await this.enqueueExclusive(async () => this.appendLocalBatchRemote(state.cursor, drained.batch, drained.count, "pending"));
|
|
4012
|
-
this.commitProducerAck(appended.producerAck);
|
|
4013
|
-
committedCount = appended.pendingCount ?? drained.count;
|
|
4014
|
-
}
|
|
4015
|
-
for (let i = 0; i < committedCount; i += 1) state.pendingLocal.popFront();
|
|
4016
|
-
this.notifySyncWaiters(state, committedCount);
|
|
4017
|
-
state.flushHeadBatchOnly = false;
|
|
4018
|
-
state.lastWriteError = void 0;
|
|
4019
|
-
this.setWriteSubStatus(state, "ok");
|
|
4077
|
+
if (!await this.enqueueExclusive(() => this.flushPendingLocalBatchExclusive(state))) return;
|
|
4020
4078
|
break;
|
|
4021
4079
|
} catch (error) {
|
|
4022
|
-
if (isPayloadTooLargeError(error) && drained.count > 1 && this.abandonPendingFrozenLocalAppend()) {
|
|
4023
|
-
state.flushHeadBatchOnly = true;
|
|
4024
|
-
continue outer;
|
|
4025
|
-
}
|
|
4026
4080
|
const classified = classifyFetchError(error);
|
|
4027
4081
|
const transportError = toTransportError(error);
|
|
4028
4082
|
if (!classified.retriable || isAuthOrProtocolError(error)) {
|
|
@@ -4201,4 +4255,4 @@ function isValidRillId(id) {
|
|
|
4201
4255
|
//#endregion
|
|
4202
4256
|
export { createInitialRemoteCursor as a, PayloadProtectionError as c, IndexedDbRemoteCursorStore as i, StreamsCrdt as n, EphemeralStreamCrdt as o, InMemoryRemoteCursorStore as r, LocalAppendFailedError as s, isValidRillId as t };
|
|
4203
4257
|
|
|
4204
|
-
//# sourceMappingURL=stream-id-
|
|
4258
|
+
//# sourceMappingURL=stream-id-BERJQKYV.js.map
|