@liveblocks/core 2.14.0 → 2.15.0-debug1

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/README.md CHANGED
@@ -9,4 +9,4 @@ not import anything directly from this package**.
9
9
  - At the `packages/liveblocks-core` root level, add a file `.env`
10
10
  - In this file, add the environment variable:
11
11
  `LIVEBLOCKS_PUBLIC_KEY="pk_YOUR_PUBLIC_API_KEY"`
12
- - Run `npm run test:e2e`
12
+ - Run `turbo run test:e2e`
package/dist/index.d.mts CHANGED
@@ -104,21 +104,22 @@ declare type EventSource<T> = Observable<T> & {
104
104
  * Returns the number of active subscribers.
105
105
  */
106
106
  count(): number;
107
- /**
108
- * Pauses event delivery until unpaused. Any .notify() calls made while
109
- * paused will get buffered into memory and emitted later.
110
- */
111
- pause(): void;
112
- /**
113
- * Emits all in-memory buffered events, and unpauses. Any .notify() calls
114
- * made after this will be synchronously delivered again.
115
- */
116
- unpause(): void;
117
107
  /**
118
108
  * Observable instance, which can be used to subscribe to this event source
119
109
  * in a readonly fashion. Safe to publicly expose.
120
110
  */
121
111
  observable: Observable<T>;
112
+ /**
113
+ * Disposes of this event source.
114
+ *
115
+ * Will clears all registered event listeners. None of the registered
116
+ * functions will ever get called again.
117
+ *
118
+ * WARNING!
119
+ * Be careful when using this API, because the subscribers may not have any
120
+ * idea they won't be notified anymore.
121
+ */
122
+ [Symbol.dispose](): void;
122
123
  };
123
124
  /**
124
125
  * makeEventSource allows you to generate a subscribe/notify pair of functions
@@ -473,6 +474,7 @@ declare type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
473
474
  * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
474
475
  */
475
476
  declare class LiveMap<TKey extends string, TValue extends Lson> extends AbstractCrdt {
477
+ #private;
476
478
  constructor(entries?: readonly (readonly [TKey, TValue])[] | undefined);
477
479
  /**
478
480
  * Returns a specified element from the LiveMap.
@@ -538,6 +540,7 @@ declare type LiveListUpdate = LiveListUpdates<Lson>;
538
540
  declare type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
539
541
 
540
542
  declare abstract class AbstractCrdt {
543
+ #private;
541
544
  get roomId(): string | null;
542
545
  /**
543
546
  * Return an immutable snapshot of this Live node and its children.
@@ -581,6 +584,7 @@ declare type LiveListUpdates<TItem extends Lson> = {
581
584
  * The LiveList class represents an ordered collection of items that is synchronized across clients.
582
585
  */
583
586
  declare class LiveList<TItem extends Lson> extends AbstractCrdt {
587
+ #private;
584
588
  constructor(items: TItem[]);
585
589
  /**
586
590
  * Returns the number of elements.
@@ -684,6 +688,7 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
684
688
  * INTERNAL
685
689
  */
686
690
  declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
691
+ #private;
687
692
  constructor(data: TValue);
688
693
  get data(): TValue;
689
694
  clone(): TValue;
@@ -750,6 +755,7 @@ declare type LiveObjectUpdates<TData extends LsonObject> = {
750
755
  * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
751
756
  */
752
757
  declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
758
+ #private;
753
759
  constructor(obj?: O);
754
760
  /**
755
761
  * Transform the LiveObject into a javascript object
@@ -2578,24 +2584,93 @@ interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, Noti
2578
2584
  }
2579
2585
 
2580
2586
  /**
2581
- * A Store is just a mini Zustand store.
2587
+ * Back-port of TypeScript 5.4's built-in NoInfer utility type.
2588
+ * See https://stackoverflow.com/a/56688073/148872
2582
2589
  */
2583
- declare type Store<T> = {
2584
- get: () => Readonly<T>;
2585
- set: (callback: (currentState: Readonly<T>) => Readonly<T>) => void;
2586
- subscribe: (callback: () => void) => () => void;
2587
- batch: (callback: () => void) => void;
2588
- };
2590
+ declare type NoInfr<A> = [A][A extends any ? 0 : never];
2591
+
2592
+ declare const kTrigger: unique symbol;
2589
2593
  /**
2590
- * Create a store for an immutable state. Close to Zustand's vanilla store conceptually but with less features.
2594
+ * Runs a callback function that is allowed to change multiple signals. At the
2595
+ * end of the batch, all changed signals will be notified (at most once).
2596
+ *
2597
+ * Nesting batches is supported.
2591
2598
  */
2592
- declare function createStore<T>(initialState: T): Store<T>;
2593
-
2599
+ declare function batch(callback: Callback<void>): void;
2600
+ declare type SignalType<S extends ISignal<any>> = S extends ISignal<infer T> ? T : never;
2601
+ interface ISignal<T> {
2602
+ get(): T;
2603
+ subscribe(callback: Callback<void>): UnsubscribeCallback;
2604
+ addSink(sink: DerivedSignal<unknown>): void;
2605
+ removeSink(sink: DerivedSignal<unknown>): void;
2606
+ }
2594
2607
  /**
2595
- * Back-port of TypeScript 5.4's built-in NoInfer utility type.
2596
- * See https://stackoverflow.com/a/56688073/148872
2608
+ * Base functionality every Signal implementation needs.
2609
+ */
2610
+ declare abstract class AbstractSignal<T> implements ISignal<T>, Observable<void> {
2611
+ #private;
2612
+ constructor(equals?: (a: T, b: T) => boolean);
2613
+ [Symbol.dispose](): void;
2614
+ abstract get(): T;
2615
+ get hasWatchers(): boolean;
2616
+ [kTrigger](): void;
2617
+ subscribe(callback: Callback<void>): UnsubscribeCallback;
2618
+ subscribeOnce(callback: Callback<void>): UnsubscribeCallback;
2619
+ waitUntil(): never;
2620
+ markSinksDirty(): void;
2621
+ addSink(sink: DerivedSignal<unknown>): void;
2622
+ removeSink(sink: DerivedSignal<unknown>): void;
2623
+ }
2624
+ declare class Signal<T> extends AbstractSignal<T> {
2625
+ #private;
2626
+ constructor(value: T, equals?: (a: T, b: T) => boolean);
2627
+ [Symbol.dispose](): void;
2628
+ get(): T;
2629
+ set(newValue: T | ((oldValue: T) => T)): void;
2630
+ }
2631
+ declare class DerivedSignal<T> extends AbstractSignal<T> {
2632
+ #private;
2633
+ static from<Ts extends [unknown, ...unknown[]], V>(...args: [...signals: {
2634
+ [K in keyof Ts]: ISignal<Ts[K]>;
2635
+ }, transform: (...values: Ts) => V]): DerivedSignal<V>;
2636
+ static from<Ts extends [unknown, ...unknown[]], V>(...args: [...signals: {
2637
+ [K in keyof Ts]: ISignal<Ts[K]>;
2638
+ }, transform: (...values: Ts) => V, equals: (a: V, b: V) => boolean]): DerivedSignal<V>;
2639
+ private constructor();
2640
+ [Symbol.dispose](): void;
2641
+ get isDirty(): boolean;
2642
+ markDirty(): void;
2643
+ get(): T;
2644
+ /**
2645
+ * Called by the Signal system if one or more of the dependent signals have
2646
+ * changed. In the case of a DerivedSignal, we'll only want to re-evaluate
2647
+ * the actual value if it's being watched, or any of their sinks are being
2648
+ * watched actively.
2649
+ */
2650
+ [kTrigger](): void;
2651
+ }
2652
+ /**
2653
+ * A MutableSignal is a bit like Signal, except its state is managed by
2654
+ * a single value whose reference does not change but is mutated.
2655
+ *
2656
+ * Similar to how useSyncExternalState() works in React, there is a way to read
2657
+ * the current state at any point in time synchronously, and a way to update
2658
+ * its reference.
2597
2659
  */
2598
- declare type NoInfr<A> = [A][A extends any ? 0 : never];
2660
+ declare class MutableSignal<T extends object> extends AbstractSignal<T> {
2661
+ #private;
2662
+ constructor(initialState: T);
2663
+ [Symbol.dispose](): void;
2664
+ get(): T;
2665
+ /**
2666
+ * Invokes a callback function that is allowed to mutate the given state
2667
+ * value. Do not change the value outside of the callback.
2668
+ *
2669
+ * If the callback explicitly returns `false`, it's assumed that the state
2670
+ * was not changed.
2671
+ */
2672
+ mutate(callback?: (state: T) => unknown): void;
2673
+ }
2599
2674
 
2600
2675
  declare type OptionalPromise<T> = T | Promise<T>;
2601
2676
 
@@ -2630,15 +2705,6 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
2630
2705
  * the authentication endpoint or connect via WebSocket.
2631
2706
  */
2632
2707
  autoConnect?: boolean;
2633
- /**
2634
- * Only necessary when you’re using Liveblocks with React v17 or lower.
2635
- *
2636
- * If so, pass in a reference to `ReactDOM.unstable_batchedUpdates` here.
2637
- * This will allow Liveblocks to circumvent the so-called "zombie child
2638
- * problem". To learn more, see
2639
- * https://liveblocks.io/docs/guides/troubleshooting#stale-props-zombie-child
2640
- */
2641
- unstable_batchedUpdates?: (cb: () => void) => void;
2642
2708
  } & PartialUnless<P, {
2643
2709
  /**
2644
2710
  * The initial Presence to use and announce when you enter the Room. The
@@ -2668,7 +2734,7 @@ declare type InternalSyncStatus = SyncStatus | "has-local-changes";
2668
2734
  * will probably happen if you do.
2669
2735
  */
2670
2736
  declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
2671
- readonly currentUserIdStore: Store<string | undefined>;
2737
+ readonly currentUserId: Signal<string | undefined>;
2672
2738
  readonly mentionSuggestionsCache: Map<string, string[]>;
2673
2739
  readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
2674
2740
  readonly usersStore: BatchStore<U["info"] | undefined, string>;
@@ -3027,8 +3093,7 @@ declare function getMentionedIdsFromCommentBody(body: CommentBody): string[];
3027
3093
  declare function resolveUsersInCommentBody<U extends BaseUserMeta>(body: CommentBody, resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>): Promise<Map<string, U["info"]>>;
3028
3094
  declare function htmlSafe(value: string): HtmlSafeString;
3029
3095
  declare class HtmlSafeString {
3030
- private _strings;
3031
- private _values;
3096
+ #private;
3032
3097
  constructor(strings: readonly string[], values: readonly (string | string[] | HtmlSafeString | HtmlSafeString[])[]);
3033
3098
  toString(): string;
3034
3099
  }
@@ -3463,8 +3528,7 @@ declare function shallow(a: unknown, b: unknown): boolean;
3463
3528
  * [{ id: 1 }, { id: 4 }, { id: 5 }, { id: 9 }])
3464
3529
  */
3465
3530
  declare class SortedList<T> {
3466
- private _data;
3467
- private _lt;
3531
+ #private;
3468
3532
  private constructor();
3469
3533
  static from<T>(arr: T[], lt: (a: T, b: T) => boolean): SortedList<T>;
3470
3534
  static fromAlreadySorted<T>(alreadySorted: T[], lt: (a: T, b: T) => boolean): SortedList<T>;
@@ -3647,4 +3711,4 @@ declare const CommentsApiError: typeof HttpError;
3647
3711
  /** @deprecated Use HttpError instead. */
3648
3712
  declare const NotificationsApiError: typeof HttpError;
3649
3713
 
3650
- export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, SortedList, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
3714
+ export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
package/dist/index.d.ts CHANGED
@@ -104,21 +104,22 @@ declare type EventSource<T> = Observable<T> & {
104
104
  * Returns the number of active subscribers.
105
105
  */
106
106
  count(): number;
107
- /**
108
- * Pauses event delivery until unpaused. Any .notify() calls made while
109
- * paused will get buffered into memory and emitted later.
110
- */
111
- pause(): void;
112
- /**
113
- * Emits all in-memory buffered events, and unpauses. Any .notify() calls
114
- * made after this will be synchronously delivered again.
115
- */
116
- unpause(): void;
117
107
  /**
118
108
  * Observable instance, which can be used to subscribe to this event source
119
109
  * in a readonly fashion. Safe to publicly expose.
120
110
  */
121
111
  observable: Observable<T>;
112
+ /**
113
+ * Disposes of this event source.
114
+ *
115
+ * Will clears all registered event listeners. None of the registered
116
+ * functions will ever get called again.
117
+ *
118
+ * WARNING!
119
+ * Be careful when using this API, because the subscribers may not have any
120
+ * idea they won't be notified anymore.
121
+ */
122
+ [Symbol.dispose](): void;
122
123
  };
123
124
  /**
124
125
  * makeEventSource allows you to generate a subscribe/notify pair of functions
@@ -473,6 +474,7 @@ declare type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
473
474
  * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
474
475
  */
475
476
  declare class LiveMap<TKey extends string, TValue extends Lson> extends AbstractCrdt {
477
+ #private;
476
478
  constructor(entries?: readonly (readonly [TKey, TValue])[] | undefined);
477
479
  /**
478
480
  * Returns a specified element from the LiveMap.
@@ -538,6 +540,7 @@ declare type LiveListUpdate = LiveListUpdates<Lson>;
538
540
  declare type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
539
541
 
540
542
  declare abstract class AbstractCrdt {
543
+ #private;
541
544
  get roomId(): string | null;
542
545
  /**
543
546
  * Return an immutable snapshot of this Live node and its children.
@@ -581,6 +584,7 @@ declare type LiveListUpdates<TItem extends Lson> = {
581
584
  * The LiveList class represents an ordered collection of items that is synchronized across clients.
582
585
  */
583
586
  declare class LiveList<TItem extends Lson> extends AbstractCrdt {
587
+ #private;
584
588
  constructor(items: TItem[]);
585
589
  /**
586
590
  * Returns the number of elements.
@@ -684,6 +688,7 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
684
688
  * INTERNAL
685
689
  */
686
690
  declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
691
+ #private;
687
692
  constructor(data: TValue);
688
693
  get data(): TValue;
689
694
  clone(): TValue;
@@ -750,6 +755,7 @@ declare type LiveObjectUpdates<TData extends LsonObject> = {
750
755
  * If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
751
756
  */
752
757
  declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
758
+ #private;
753
759
  constructor(obj?: O);
754
760
  /**
755
761
  * Transform the LiveObject into a javascript object
@@ -2578,24 +2584,93 @@ interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, Noti
2578
2584
  }
2579
2585
 
2580
2586
  /**
2581
- * A Store is just a mini Zustand store.
2587
+ * Back-port of TypeScript 5.4's built-in NoInfer utility type.
2588
+ * See https://stackoverflow.com/a/56688073/148872
2582
2589
  */
2583
- declare type Store<T> = {
2584
- get: () => Readonly<T>;
2585
- set: (callback: (currentState: Readonly<T>) => Readonly<T>) => void;
2586
- subscribe: (callback: () => void) => () => void;
2587
- batch: (callback: () => void) => void;
2588
- };
2590
+ declare type NoInfr<A> = [A][A extends any ? 0 : never];
2591
+
2592
+ declare const kTrigger: unique symbol;
2589
2593
  /**
2590
- * Create a store for an immutable state. Close to Zustand's vanilla store conceptually but with less features.
2594
+ * Runs a callback function that is allowed to change multiple signals. At the
2595
+ * end of the batch, all changed signals will be notified (at most once).
2596
+ *
2597
+ * Nesting batches is supported.
2591
2598
  */
2592
- declare function createStore<T>(initialState: T): Store<T>;
2593
-
2599
+ declare function batch(callback: Callback<void>): void;
2600
+ declare type SignalType<S extends ISignal<any>> = S extends ISignal<infer T> ? T : never;
2601
+ interface ISignal<T> {
2602
+ get(): T;
2603
+ subscribe(callback: Callback<void>): UnsubscribeCallback;
2604
+ addSink(sink: DerivedSignal<unknown>): void;
2605
+ removeSink(sink: DerivedSignal<unknown>): void;
2606
+ }
2594
2607
  /**
2595
- * Back-port of TypeScript 5.4's built-in NoInfer utility type.
2596
- * See https://stackoverflow.com/a/56688073/148872
2608
+ * Base functionality every Signal implementation needs.
2609
+ */
2610
+ declare abstract class AbstractSignal<T> implements ISignal<T>, Observable<void> {
2611
+ #private;
2612
+ constructor(equals?: (a: T, b: T) => boolean);
2613
+ [Symbol.dispose](): void;
2614
+ abstract get(): T;
2615
+ get hasWatchers(): boolean;
2616
+ [kTrigger](): void;
2617
+ subscribe(callback: Callback<void>): UnsubscribeCallback;
2618
+ subscribeOnce(callback: Callback<void>): UnsubscribeCallback;
2619
+ waitUntil(): never;
2620
+ markSinksDirty(): void;
2621
+ addSink(sink: DerivedSignal<unknown>): void;
2622
+ removeSink(sink: DerivedSignal<unknown>): void;
2623
+ }
2624
+ declare class Signal<T> extends AbstractSignal<T> {
2625
+ #private;
2626
+ constructor(value: T, equals?: (a: T, b: T) => boolean);
2627
+ [Symbol.dispose](): void;
2628
+ get(): T;
2629
+ set(newValue: T | ((oldValue: T) => T)): void;
2630
+ }
2631
+ declare class DerivedSignal<T> extends AbstractSignal<T> {
2632
+ #private;
2633
+ static from<Ts extends [unknown, ...unknown[]], V>(...args: [...signals: {
2634
+ [K in keyof Ts]: ISignal<Ts[K]>;
2635
+ }, transform: (...values: Ts) => V]): DerivedSignal<V>;
2636
+ static from<Ts extends [unknown, ...unknown[]], V>(...args: [...signals: {
2637
+ [K in keyof Ts]: ISignal<Ts[K]>;
2638
+ }, transform: (...values: Ts) => V, equals: (a: V, b: V) => boolean]): DerivedSignal<V>;
2639
+ private constructor();
2640
+ [Symbol.dispose](): void;
2641
+ get isDirty(): boolean;
2642
+ markDirty(): void;
2643
+ get(): T;
2644
+ /**
2645
+ * Called by the Signal system if one or more of the dependent signals have
2646
+ * changed. In the case of a DerivedSignal, we'll only want to re-evaluate
2647
+ * the actual value if it's being watched, or any of their sinks are being
2648
+ * watched actively.
2649
+ */
2650
+ [kTrigger](): void;
2651
+ }
2652
+ /**
2653
+ * A MutableSignal is a bit like Signal, except its state is managed by
2654
+ * a single value whose reference does not change but is mutated.
2655
+ *
2656
+ * Similar to how useSyncExternalState() works in React, there is a way to read
2657
+ * the current state at any point in time synchronously, and a way to update
2658
+ * its reference.
2597
2659
  */
2598
- declare type NoInfr<A> = [A][A extends any ? 0 : never];
2660
+ declare class MutableSignal<T extends object> extends AbstractSignal<T> {
2661
+ #private;
2662
+ constructor(initialState: T);
2663
+ [Symbol.dispose](): void;
2664
+ get(): T;
2665
+ /**
2666
+ * Invokes a callback function that is allowed to mutate the given state
2667
+ * value. Do not change the value outside of the callback.
2668
+ *
2669
+ * If the callback explicitly returns `false`, it's assumed that the state
2670
+ * was not changed.
2671
+ */
2672
+ mutate(callback?: (state: T) => unknown): void;
2673
+ }
2599
2674
 
2600
2675
  declare type OptionalPromise<T> = T | Promise<T>;
2601
2676
 
@@ -2630,15 +2705,6 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
2630
2705
  * the authentication endpoint or connect via WebSocket.
2631
2706
  */
2632
2707
  autoConnect?: boolean;
2633
- /**
2634
- * Only necessary when you’re using Liveblocks with React v17 or lower.
2635
- *
2636
- * If so, pass in a reference to `ReactDOM.unstable_batchedUpdates` here.
2637
- * This will allow Liveblocks to circumvent the so-called "zombie child
2638
- * problem". To learn more, see
2639
- * https://liveblocks.io/docs/guides/troubleshooting#stale-props-zombie-child
2640
- */
2641
- unstable_batchedUpdates?: (cb: () => void) => void;
2642
2708
  } & PartialUnless<P, {
2643
2709
  /**
2644
2710
  * The initial Presence to use and announce when you enter the Room. The
@@ -2668,7 +2734,7 @@ declare type InternalSyncStatus = SyncStatus | "has-local-changes";
2668
2734
  * will probably happen if you do.
2669
2735
  */
2670
2736
  declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
2671
- readonly currentUserIdStore: Store<string | undefined>;
2737
+ readonly currentUserId: Signal<string | undefined>;
2672
2738
  readonly mentionSuggestionsCache: Map<string, string[]>;
2673
2739
  readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
2674
2740
  readonly usersStore: BatchStore<U["info"] | undefined, string>;
@@ -3027,8 +3093,7 @@ declare function getMentionedIdsFromCommentBody(body: CommentBody): string[];
3027
3093
  declare function resolveUsersInCommentBody<U extends BaseUserMeta>(body: CommentBody, resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>): Promise<Map<string, U["info"]>>;
3028
3094
  declare function htmlSafe(value: string): HtmlSafeString;
3029
3095
  declare class HtmlSafeString {
3030
- private _strings;
3031
- private _values;
3096
+ #private;
3032
3097
  constructor(strings: readonly string[], values: readonly (string | string[] | HtmlSafeString | HtmlSafeString[])[]);
3033
3098
  toString(): string;
3034
3099
  }
@@ -3463,8 +3528,7 @@ declare function shallow(a: unknown, b: unknown): boolean;
3463
3528
  * [{ id: 1 }, { id: 4 }, { id: 5 }, { id: 9 }])
3464
3529
  */
3465
3530
  declare class SortedList<T> {
3466
- private _data;
3467
- private _lt;
3531
+ #private;
3468
3532
  private constructor();
3469
3533
  static from<T>(arr: T[], lt: (a: T, b: T) => boolean): SortedList<T>;
3470
3534
  static fromAlreadySorted<T>(alreadySorted: T[], lt: (a: T, b: T) => boolean): SortedList<T>;
@@ -3647,4 +3711,4 @@ declare const CommentsApiError: typeof HttpError;
3647
3711
  /** @deprecated Use HttpError instead. */
3648
3712
  declare const NotificationsApiError: typeof HttpError;
3649
3713
 
3650
- export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, SortedList, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
3714
+ export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };