@liveblocks/core 0.19.3-beta1 → 0.19.3-beta2
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/index.d.ts +16 -3
- package/dist/index.js +21 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -732,10 +732,13 @@ interface History {
|
|
|
732
732
|
*/
|
|
733
733
|
resume: () => void;
|
|
734
734
|
}
|
|
735
|
-
|
|
735
|
+
declare type HistoryEvent = {
|
|
736
736
|
canUndo: boolean;
|
|
737
737
|
canRedo: boolean;
|
|
738
|
-
}
|
|
738
|
+
};
|
|
739
|
+
declare type PendingHasModificationsEvent = {
|
|
740
|
+
hasPendingStorageModifications: boolean;
|
|
741
|
+
};
|
|
739
742
|
declare type BroadcastOptions = {
|
|
740
743
|
/**
|
|
741
744
|
* Whether or not event is queued if the connection is currently closed.
|
|
@@ -852,9 +855,19 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
852
855
|
* room.subscribe("history", ({ canUndo, canRedo }) => {
|
|
853
856
|
* // Do something
|
|
854
857
|
* });
|
|
855
|
-
*
|
|
856
858
|
*/
|
|
857
859
|
(type: "history", listener: Callback<HistoryEvent>): () => void;
|
|
860
|
+
/**
|
|
861
|
+
* Subscribe to pending storage modifications updates.
|
|
862
|
+
*
|
|
863
|
+
* @returns Unsubscribe function.
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* room.subscribe("pending-storage-modifications", ({ hasPendingStorageModifications }) => {
|
|
867
|
+
* // Do something
|
|
868
|
+
* });
|
|
869
|
+
*/
|
|
870
|
+
(type: "pending-storage-modifications", listener: Callback<PendingHasModificationsEvent>): () => void;
|
|
858
871
|
};
|
|
859
872
|
/**
|
|
860
873
|
* Room's history contains functions that let you undo and redo operation made on by the current client on the presence and storage.
|
package/dist/index.js
CHANGED
|
@@ -2725,7 +2725,8 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
2725
2725
|
connection: makeEventSource(),
|
|
2726
2726
|
storage: makeEventSource(),
|
|
2727
2727
|
history: makeEventSource(),
|
|
2728
|
-
storageDidLoad: makeEventSource()
|
|
2728
|
+
storageDidLoad: makeEventSource(),
|
|
2729
|
+
pendingStorageModifications: makeEventSource()
|
|
2729
2730
|
};
|
|
2730
2731
|
const effects = mockedEffects || {
|
|
2731
2732
|
authenticate(auth, createWebSocket) {
|
|
@@ -2893,6 +2894,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
2893
2894
|
return op;
|
|
2894
2895
|
}
|
|
2895
2896
|
});
|
|
2897
|
+
const hasPendingStorageModifs = hasPendingStorageModifications();
|
|
2896
2898
|
for (const op of ops) {
|
|
2897
2899
|
if (op.type === "presence") {
|
|
2898
2900
|
const reverse = {
|
|
@@ -2944,6 +2946,11 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
2944
2946
|
}
|
|
2945
2947
|
}
|
|
2946
2948
|
}
|
|
2949
|
+
if (hasPendingStorageModifs && hasPendingStorageModifications() === false) {
|
|
2950
|
+
eventHub.pendingStorageModifications.notify({
|
|
2951
|
+
hasPendingStorageModifications: false
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2947
2954
|
return {
|
|
2948
2955
|
ops,
|
|
2949
2956
|
reverse: output.reverse,
|
|
@@ -3039,6 +3046,10 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3039
3046
|
);
|
|
3040
3047
|
case "history":
|
|
3041
3048
|
return eventHub.history.subscribe(callback);
|
|
3049
|
+
case "pending-storage-modifications":
|
|
3050
|
+
return eventHub.pendingStorageModifications.subscribe(
|
|
3051
|
+
callback
|
|
3052
|
+
);
|
|
3042
3053
|
default:
|
|
3043
3054
|
return assertNever(first, "Unknown event");
|
|
3044
3055
|
}
|
|
@@ -3444,9 +3455,15 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3444
3455
|
function tryFlushing() {
|
|
3445
3456
|
const storageOps = state.buffer.storageOperations;
|
|
3446
3457
|
if (storageOps.length > 0) {
|
|
3458
|
+
const hasAlreadyPendingModifications = hasPendingStorageModifications();
|
|
3447
3459
|
storageOps.forEach((op) => {
|
|
3448
3460
|
state.offlineOperations.set(nn(op.opId), op);
|
|
3449
3461
|
});
|
|
3462
|
+
if (!hasAlreadyPendingModifications) {
|
|
3463
|
+
eventHub.pendingStorageModifications.notify({
|
|
3464
|
+
hasPendingStorageModifications: true
|
|
3465
|
+
});
|
|
3466
|
+
}
|
|
3450
3467
|
}
|
|
3451
3468
|
if (state.socket === null || state.socket.readyState !== state.socket.OPEN) {
|
|
3452
3469
|
state.buffer.storageOperations = [];
|
|
@@ -3719,7 +3736,8 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3719
3736
|
connection: eventHub.connection.observable,
|
|
3720
3737
|
storage: eventHub.storage.observable,
|
|
3721
3738
|
history: eventHub.history.observable,
|
|
3722
|
-
storageDidLoad: eventHub.storageDidLoad.observable
|
|
3739
|
+
storageDidLoad: eventHub.storageDidLoad.observable,
|
|
3740
|
+
pendingStorageModifications: eventHub.pendingStorageModifications
|
|
3723
3741
|
},
|
|
3724
3742
|
getConnectionState,
|
|
3725
3743
|
isSelfAware: () => isConnectionSelfAware(state.connection.current),
|
|
@@ -3831,7 +3849,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
|
|
|
3831
3849
|
const ws = WebSocketPolyfill || WebSocket;
|
|
3832
3850
|
return (token) => {
|
|
3833
3851
|
return new ws(
|
|
3834
|
-
`${liveblocksServer}/?token=${token}&version=${true ? "0.19.3-
|
|
3852
|
+
`${liveblocksServer}/?token=${token}&version=${true ? "0.19.3-beta2" : "dev"}`
|
|
3835
3853
|
);
|
|
3836
3854
|
};
|
|
3837
3855
|
}
|