@liveblocks/core 3.20.0-exp7 → 3.20.0-exp8

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.cts CHANGED
@@ -951,6 +951,22 @@ type LiveTextUpdates = {
951
951
  updates: LiveTextChange[];
952
952
  };
953
953
 
954
+ /**
955
+ * LiveText is a collaborative rich-text primitive built on server-ordered
956
+ * operational transformation.
957
+ *
958
+ * Outbound model (one-in-flight): at most one UpdateTextOp per node is
959
+ * awaiting server acknowledgement at any time. Local edits made while an op
960
+ * is in flight are queued and sent (composed into a single op) once the ack
961
+ * arrives. This guarantees every wire op is expressed against server-state
962
+ * coordinates, so the server can transform it over exactly the (foreign)
963
+ * ops the client hadn't seen — never over the client's own pending ops.
964
+ *
965
+ * Inbound model: accepted remote ops are transformed over the local pending
966
+ * ops before being applied ("before" order: the accepted op wins ties), and
967
+ * the pending ops are re-expressed over the remote op in turn ("after"
968
+ * order), keeping them in server coordinates at all times.
969
+ */
954
970
  declare class LiveText extends AbstractCrdt {
955
971
  #private;
956
972
  constructor(textOrData?: string | LiveTextData, version?: number);
@@ -1001,6 +1017,16 @@ interface ReadonlyUnacknowledgedOps {
1001
1017
  isPossiblyStored(opId: string): boolean;
1002
1018
  }
1003
1019
 
1020
+ type DispatchOptions = {
1021
+ /**
1022
+ * Whether this dispatch should clear the redo stack. Defaults to true when
1023
+ * any forward ops are included (a fresh local mutation), false otherwise.
1024
+ * LiveText uses this to dispatch queued ops after an acknowledgement
1025
+ * (which should not clear redo), and to register fresh local edits that
1026
+ * don't carry wire ops yet (which should).
1027
+ */
1028
+ clearRedoStack?: boolean;
1029
+ };
1004
1030
  /**
1005
1031
  * The managed pool is a namespace registry (i.e. a context) that "owns" all
1006
1032
  * the individual live nodes, ensuring each one has a unique ID, and holding on
@@ -1020,7 +1046,7 @@ interface ManagedPool {
1020
1046
  * - Add reverse operations to the undo/redo stack
1021
1047
  * - Notify room subscribers with updates (in-client, no networking)
1022
1048
  */
1023
- dispatch: (ops: ClientWireOp[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
1049
+ dispatch: (ops: ClientWireOp[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>, options?: DispatchOptions) => void;
1024
1050
  /**
1025
1051
  * Ensures storage can be written to else throws an error.
1026
1052
  * This is used to prevent writing to storage when the user does not have
@@ -1045,7 +1071,7 @@ type CreateManagedPoolOptions = {
1045
1071
  /**
1046
1072
  * Will get invoked when any Live structure calls .dispatch() on the pool.
1047
1073
  */
1048
- onDispatch?: (ops: ClientWireOp[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
1074
+ onDispatch?: (ops: ClientWireOp[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>, options?: DispatchOptions) => void;
1049
1075
  /**
1050
1076
  * Will get invoked when any Live structure calls .assertStorageIsWritable()
1051
1077
  * on the pool. Defaults to true when not provided. Return false if you want
package/dist/index.d.ts CHANGED
@@ -951,6 +951,22 @@ type LiveTextUpdates = {
951
951
  updates: LiveTextChange[];
952
952
  };
953
953
 
954
+ /**
955
+ * LiveText is a collaborative rich-text primitive built on server-ordered
956
+ * operational transformation.
957
+ *
958
+ * Outbound model (one-in-flight): at most one UpdateTextOp per node is
959
+ * awaiting server acknowledgement at any time. Local edits made while an op
960
+ * is in flight are queued and sent (composed into a single op) once the ack
961
+ * arrives. This guarantees every wire op is expressed against server-state
962
+ * coordinates, so the server can transform it over exactly the (foreign)
963
+ * ops the client hadn't seen — never over the client's own pending ops.
964
+ *
965
+ * Inbound model: accepted remote ops are transformed over the local pending
966
+ * ops before being applied ("before" order: the accepted op wins ties), and
967
+ * the pending ops are re-expressed over the remote op in turn ("after"
968
+ * order), keeping them in server coordinates at all times.
969
+ */
954
970
  declare class LiveText extends AbstractCrdt {
955
971
  #private;
956
972
  constructor(textOrData?: string | LiveTextData, version?: number);
@@ -1001,6 +1017,16 @@ interface ReadonlyUnacknowledgedOps {
1001
1017
  isPossiblyStored(opId: string): boolean;
1002
1018
  }
1003
1019
 
1020
+ type DispatchOptions = {
1021
+ /**
1022
+ * Whether this dispatch should clear the redo stack. Defaults to true when
1023
+ * any forward ops are included (a fresh local mutation), false otherwise.
1024
+ * LiveText uses this to dispatch queued ops after an acknowledgement
1025
+ * (which should not clear redo), and to register fresh local edits that
1026
+ * don't carry wire ops yet (which should).
1027
+ */
1028
+ clearRedoStack?: boolean;
1029
+ };
1004
1030
  /**
1005
1031
  * The managed pool is a namespace registry (i.e. a context) that "owns" all
1006
1032
  * the individual live nodes, ensuring each one has a unique ID, and holding on
@@ -1020,7 +1046,7 @@ interface ManagedPool {
1020
1046
  * - Add reverse operations to the undo/redo stack
1021
1047
  * - Notify room subscribers with updates (in-client, no networking)
1022
1048
  */
1023
- dispatch: (ops: ClientWireOp[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
1049
+ dispatch: (ops: ClientWireOp[], reverseOps: Op[], storageUpdates: Map<string, StorageUpdate>, options?: DispatchOptions) => void;
1024
1050
  /**
1025
1051
  * Ensures storage can be written to else throws an error.
1026
1052
  * This is used to prevent writing to storage when the user does not have
@@ -1045,7 +1071,7 @@ type CreateManagedPoolOptions = {
1045
1071
  /**
1046
1072
  * Will get invoked when any Live structure calls .dispatch() on the pool.
1047
1073
  */
1048
- onDispatch?: (ops: ClientWireOp[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>) => void;
1074
+ onDispatch?: (ops: ClientWireOp[], reverse: Op[], storageUpdates: Map<string, StorageUpdate>, options?: DispatchOptions) => void;
1049
1075
  /**
1050
1076
  * Will get invoked when any Live structure calls .assertStorageIsWritable()
1051
1077
  * on the pool. Defaults to true when not provided. Return false if you want