@liveblocks/core 3.19.3 → 3.19.5-rc1

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
@@ -454,40 +454,40 @@ type UpdateObjectOp = {
454
454
  type CreateObjectOp = {
455
455
  readonly opId?: string;
456
456
  readonly id: string;
457
- readonly intent?: "set";
458
- readonly deletedId?: string;
459
457
  readonly type: OpCode.CREATE_OBJECT;
460
458
  readonly parentId: string;
461
459
  readonly parentKey: string;
462
460
  readonly data: JsonObject;
461
+ readonly intent?: "set" | "push";
462
+ readonly deletedId?: string;
463
463
  };
464
464
  type CreateListOp = {
465
465
  readonly opId?: string;
466
466
  readonly id: string;
467
- readonly intent?: "set";
468
- readonly deletedId?: string;
469
467
  readonly type: OpCode.CREATE_LIST;
470
468
  readonly parentId: string;
471
469
  readonly parentKey: string;
470
+ readonly intent?: "set" | "push";
471
+ readonly deletedId?: string;
472
472
  };
473
473
  type CreateMapOp = {
474
474
  readonly opId?: string;
475
475
  readonly id: string;
476
- readonly intent?: "set";
477
- readonly deletedId?: string;
478
476
  readonly type: OpCode.CREATE_MAP;
479
477
  readonly parentId: string;
480
478
  readonly parentKey: string;
479
+ readonly intent?: "set" | "push";
480
+ readonly deletedId?: string;
481
481
  };
482
482
  type CreateRegisterOp = {
483
483
  readonly opId?: string;
484
484
  readonly id: string;
485
- readonly intent?: "set";
486
- readonly deletedId?: string;
487
485
  readonly type: OpCode.CREATE_REGISTER;
488
486
  readonly parentId: string;
489
487
  readonly parentKey: string;
490
488
  readonly data: Json;
489
+ readonly intent?: "set" | "push";
490
+ readonly deletedId?: string;
491
491
  };
492
492
  type DeleteCrdtOp = {
493
493
  readonly opId?: string;
@@ -519,6 +519,7 @@ type HasOpId = {
519
519
  * acknowledge the receipt.
520
520
  */
521
521
  type ClientWireOp = Op & HasOpId;
522
+ type ClientWireCreateOp = CreateOp & HasOpId;
522
523
  /**
523
524
  * ServerWireOp: Ops sent from server → client. Three variants:
524
525
  * 1. ClientWireOp — Full echo back of our own op, confirming it was applied
@@ -864,6 +865,21 @@ type LiveListUpdate = LiveListUpdates<Lson>;
864
865
  */
865
866
  type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
866
867
 
868
+ /**
869
+ * Read-only query surface over {@link UnacknowledgedOps}, handed to CRDTs so
870
+ * they can look up their own still-pending Create ops without being able to
871
+ * mutate the set (only the room adds/acks).
872
+ */
873
+ interface ReadonlyUnacknowledgedOps {
874
+ /** Still-unacknowledged Create ops whose `parentId` is the given one. */
875
+ getByParentId(parentId: string): Iterable<ClientWireCreateOp>;
876
+ /**
877
+ * Still-unacknowledged Create ops whose `parentId` and `parentKey` are both
878
+ * the given ones (i.e. targeting one exact position).
879
+ */
880
+ getByParentIdAndKey(parentId: string, parentKey: string): Iterable<ClientWireCreateOp>;
881
+ }
882
+
867
883
  /**
868
884
  * The managed pool is a namespace registry (i.e. a context) that "owns" all
869
885
  * the individual live nodes, ensuring each one has a unique ID, and holding on
@@ -892,6 +908,11 @@ interface ManagedPool {
892
908
  * @returns {void}
893
909
  */
894
910
  assertStorageIsWritable: () => void;
911
+ /**
912
+ * Read-only view of the client's still-unacknowledged ops (sent or
913
+ * pending-send, not yet confirmed by the server).
914
+ */
915
+ readonly unacknowledgedOps: ReadonlyUnacknowledgedOps;
895
916
  }
896
917
  type CreateManagedPoolOptions = {
897
918
  /**
@@ -911,6 +932,13 @@ type CreateManagedPoolOptions = {
911
932
  * have an effect upstream.
912
933
  */
913
934
  isStorageWritable?: () => boolean;
935
+ /**
936
+ * Read-only view of the client's still-unacknowledged ops. Used by CRDTs
937
+ * (e.g. LiveList) to know which of their optimistic mutations the server
938
+ * hasn't confirmed yet. Defaults to an empty view (e.g. server-side pools
939
+ * that dispatch-and-flush have no optimistic state to track).
940
+ */
941
+ unacknowledgedOps?: ReadonlyUnacknowledgedOps;
914
942
  };
915
943
  /**
916
944
  * @private Private API, never use this API directly.
@@ -5457,6 +5485,13 @@ declare class SortedList<T> {
5457
5485
  reposition(value: T): number;
5458
5486
  at(index: number): T | undefined;
5459
5487
  get length(): number;
5488
+ /**
5489
+ * Whether the given value is present, by identity. O(log n) plus the length
5490
+ * of any run of items that share its sort key (normally 1). Bisects on the
5491
+ * value's own key, so it only finds values sitting at their sorted position,
5492
+ * which is true for any item currently in the list.
5493
+ */
5494
+ includes(value: T): boolean;
5460
5495
  filter(predicate: (value: T) => boolean): IterableIterator<T>;
5461
5496
  findAllRight(predicate: (value: T, index: number) => unknown): IterableIterator<T>;
5462
5497
  [Symbol.iterator](): IterableIterator<T>;
package/dist/index.d.ts CHANGED
@@ -454,40 +454,40 @@ type UpdateObjectOp = {
454
454
  type CreateObjectOp = {
455
455
  readonly opId?: string;
456
456
  readonly id: string;
457
- readonly intent?: "set";
458
- readonly deletedId?: string;
459
457
  readonly type: OpCode.CREATE_OBJECT;
460
458
  readonly parentId: string;
461
459
  readonly parentKey: string;
462
460
  readonly data: JsonObject;
461
+ readonly intent?: "set" | "push";
462
+ readonly deletedId?: string;
463
463
  };
464
464
  type CreateListOp = {
465
465
  readonly opId?: string;
466
466
  readonly id: string;
467
- readonly intent?: "set";
468
- readonly deletedId?: string;
469
467
  readonly type: OpCode.CREATE_LIST;
470
468
  readonly parentId: string;
471
469
  readonly parentKey: string;
470
+ readonly intent?: "set" | "push";
471
+ readonly deletedId?: string;
472
472
  };
473
473
  type CreateMapOp = {
474
474
  readonly opId?: string;
475
475
  readonly id: string;
476
- readonly intent?: "set";
477
- readonly deletedId?: string;
478
476
  readonly type: OpCode.CREATE_MAP;
479
477
  readonly parentId: string;
480
478
  readonly parentKey: string;
479
+ readonly intent?: "set" | "push";
480
+ readonly deletedId?: string;
481
481
  };
482
482
  type CreateRegisterOp = {
483
483
  readonly opId?: string;
484
484
  readonly id: string;
485
- readonly intent?: "set";
486
- readonly deletedId?: string;
487
485
  readonly type: OpCode.CREATE_REGISTER;
488
486
  readonly parentId: string;
489
487
  readonly parentKey: string;
490
488
  readonly data: Json;
489
+ readonly intent?: "set" | "push";
490
+ readonly deletedId?: string;
491
491
  };
492
492
  type DeleteCrdtOp = {
493
493
  readonly opId?: string;
@@ -519,6 +519,7 @@ type HasOpId = {
519
519
  * acknowledge the receipt.
520
520
  */
521
521
  type ClientWireOp = Op & HasOpId;
522
+ type ClientWireCreateOp = CreateOp & HasOpId;
522
523
  /**
523
524
  * ServerWireOp: Ops sent from server → client. Three variants:
524
525
  * 1. ClientWireOp — Full echo back of our own op, confirming it was applied
@@ -864,6 +865,21 @@ type LiveListUpdate = LiveListUpdates<Lson>;
864
865
  */
865
866
  type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
866
867
 
868
+ /**
869
+ * Read-only query surface over {@link UnacknowledgedOps}, handed to CRDTs so
870
+ * they can look up their own still-pending Create ops without being able to
871
+ * mutate the set (only the room adds/acks).
872
+ */
873
+ interface ReadonlyUnacknowledgedOps {
874
+ /** Still-unacknowledged Create ops whose `parentId` is the given one. */
875
+ getByParentId(parentId: string): Iterable<ClientWireCreateOp>;
876
+ /**
877
+ * Still-unacknowledged Create ops whose `parentId` and `parentKey` are both
878
+ * the given ones (i.e. targeting one exact position).
879
+ */
880
+ getByParentIdAndKey(parentId: string, parentKey: string): Iterable<ClientWireCreateOp>;
881
+ }
882
+
867
883
  /**
868
884
  * The managed pool is a namespace registry (i.e. a context) that "owns" all
869
885
  * the individual live nodes, ensuring each one has a unique ID, and holding on
@@ -892,6 +908,11 @@ interface ManagedPool {
892
908
  * @returns {void}
893
909
  */
894
910
  assertStorageIsWritable: () => void;
911
+ /**
912
+ * Read-only view of the client's still-unacknowledged ops (sent or
913
+ * pending-send, not yet confirmed by the server).
914
+ */
915
+ readonly unacknowledgedOps: ReadonlyUnacknowledgedOps;
895
916
  }
896
917
  type CreateManagedPoolOptions = {
897
918
  /**
@@ -911,6 +932,13 @@ type CreateManagedPoolOptions = {
911
932
  * have an effect upstream.
912
933
  */
913
934
  isStorageWritable?: () => boolean;
935
+ /**
936
+ * Read-only view of the client's still-unacknowledged ops. Used by CRDTs
937
+ * (e.g. LiveList) to know which of their optimistic mutations the server
938
+ * hasn't confirmed yet. Defaults to an empty view (e.g. server-side pools
939
+ * that dispatch-and-flush have no optimistic state to track).
940
+ */
941
+ unacknowledgedOps?: ReadonlyUnacknowledgedOps;
914
942
  };
915
943
  /**
916
944
  * @private Private API, never use this API directly.
@@ -5457,6 +5485,13 @@ declare class SortedList<T> {
5457
5485
  reposition(value: T): number;
5458
5486
  at(index: number): T | undefined;
5459
5487
  get length(): number;
5488
+ /**
5489
+ * Whether the given value is present, by identity. O(log n) plus the length
5490
+ * of any run of items that share its sort key (normally 1). Bisects on the
5491
+ * value's own key, so it only finds values sitting at their sorted position,
5492
+ * which is true for any item currently in the list.
5493
+ */
5494
+ includes(value: T): boolean;
5460
5495
  filter(predicate: (value: T) => boolean): IterableIterator<T>;
5461
5496
  findAllRight(predicate: (value: T, index: number) => unknown): IterableIterator<T>;
5462
5497
  [Symbol.iterator](): IterableIterator<T>;