@liveblocks/core 1.5.0-test1 → 1.5.0-test3
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.mts +46 -15
- package/dist/index.d.ts +46 -15
- package/dist/index.js +230 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +171 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -240,6 +240,7 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
240
240
|
*/
|
|
241
241
|
update(patch: Partial<O>): void;
|
|
242
242
|
toImmutable(): ToImmutable<O>;
|
|
243
|
+
clone(): LiveObject<O>;
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
/**
|
|
@@ -333,6 +334,7 @@ declare class LiveMap<TKey extends string, TValue extends Lson> extends Abstract
|
|
|
333
334
|
*/
|
|
334
335
|
forEach(callback: (value: TValue, key: TKey, map: LiveMap<TKey, TValue>) => void): void;
|
|
335
336
|
toImmutable(): ReadonlyMap<TKey, ToImmutable<TValue>>;
|
|
337
|
+
clone(): LiveMap<TKey, TValue>;
|
|
336
338
|
}
|
|
337
339
|
|
|
338
340
|
declare type StorageCallback = (updates: StorageUpdate[]) => void;
|
|
@@ -352,24 +354,29 @@ declare abstract class AbstractCrdt {
|
|
|
352
354
|
* Return an immutable snapshot of this Live node and its children.
|
|
353
355
|
*/
|
|
354
356
|
toImmutable(): Immutable;
|
|
357
|
+
/**
|
|
358
|
+
* Returns a deep clone of the current LiveStructure, suitable for insertion
|
|
359
|
+
* in the tree elsewhere.
|
|
360
|
+
*/
|
|
361
|
+
abstract clone(): Lson;
|
|
355
362
|
}
|
|
356
363
|
|
|
357
364
|
declare type LiveListUpdateDelta = {
|
|
365
|
+
type: "insert";
|
|
358
366
|
index: number;
|
|
359
367
|
item: Lson;
|
|
360
|
-
type: "insert";
|
|
361
368
|
} | {
|
|
362
|
-
index: number;
|
|
363
369
|
type: "delete";
|
|
370
|
+
index: number;
|
|
364
371
|
} | {
|
|
372
|
+
type: "move";
|
|
365
373
|
index: number;
|
|
366
374
|
previousIndex: number;
|
|
367
375
|
item: Lson;
|
|
368
|
-
type: "move";
|
|
369
376
|
} | {
|
|
377
|
+
type: "set";
|
|
370
378
|
index: number;
|
|
371
379
|
item: Lson;
|
|
372
|
-
type: "set";
|
|
373
380
|
};
|
|
374
381
|
/**
|
|
375
382
|
* A LiveList notification that is sent in-client to any subscribers whenever
|
|
@@ -480,6 +487,7 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
|
480
487
|
some(predicate: (value: TItem, index: number) => unknown): boolean;
|
|
481
488
|
[Symbol.iterator](): IterableIterator<TItem>;
|
|
482
489
|
toImmutable(): readonly ToImmutable<TItem>[];
|
|
490
|
+
clone(): LiveList<TItem>;
|
|
483
491
|
}
|
|
484
492
|
|
|
485
493
|
/**
|
|
@@ -488,6 +496,7 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
|
488
496
|
declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
|
|
489
497
|
constructor(data: TValue);
|
|
490
498
|
get data(): TValue;
|
|
499
|
+
clone(): TValue;
|
|
491
500
|
}
|
|
492
501
|
|
|
493
502
|
declare type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
|
|
@@ -723,7 +732,7 @@ declare type ThreadData<TThreadMetadata extends BaseMetadata = never> = {
|
|
|
723
732
|
};
|
|
724
733
|
|
|
725
734
|
declare type Options = {
|
|
726
|
-
|
|
735
|
+
baseUrl: string;
|
|
727
736
|
};
|
|
728
737
|
declare type PartialNullable<T> = {
|
|
729
738
|
[P in keyof T]?: T[P] | null | undefined;
|
|
@@ -765,7 +774,7 @@ declare type CommentsApi<TThreadMetadata extends BaseMetadata> = {
|
|
|
765
774
|
emoji: string;
|
|
766
775
|
}): Promise<CommentData>;
|
|
767
776
|
};
|
|
768
|
-
declare function createCommentsApi<TThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>,
|
|
777
|
+
declare function createCommentsApi<TThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>, config: Options): CommentsApi<TThreadMetadata>;
|
|
769
778
|
|
|
770
779
|
declare type Callback<T> = (event: T) => void;
|
|
771
780
|
declare type UnsubscribeCallback = () => void;
|
|
@@ -944,6 +953,7 @@ declare type BaseAuthResult = NonNullable<Json>;
|
|
|
944
953
|
declare type Delegates<T extends BaseAuthResult> = {
|
|
945
954
|
authenticate: () => Promise<T>;
|
|
946
955
|
createSocket: (authValue: T) => IWebSocketInstance;
|
|
956
|
+
canZombie: () => boolean;
|
|
947
957
|
};
|
|
948
958
|
|
|
949
959
|
declare enum ClientMsgCode {
|
|
@@ -1312,7 +1322,7 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
|
|
|
1312
1322
|
* @deprecated Use `readonly User<TPresence, TUserMeta>[]` instead of `Others<TPresence, TUserMeta>`.
|
|
1313
1323
|
*/
|
|
1314
1324
|
declare type Others<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = readonly User<TPresence, TUserMeta>[];
|
|
1315
|
-
declare type
|
|
1325
|
+
declare type InternalOthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
|
|
1316
1326
|
type: "leave";
|
|
1317
1327
|
user: User<TPresence, TUserMeta>;
|
|
1318
1328
|
} | {
|
|
@@ -1325,7 +1335,24 @@ declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUse
|
|
|
1325
1335
|
} | {
|
|
1326
1336
|
type: "reset";
|
|
1327
1337
|
};
|
|
1338
|
+
declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = Resolve<InternalOthersEvent<TPresence, TUserMeta> & {
|
|
1339
|
+
others: readonly User<TPresence, TUserMeta>[];
|
|
1340
|
+
}>;
|
|
1328
1341
|
|
|
1342
|
+
declare type LegacyOthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
|
|
1343
|
+
type: "leave";
|
|
1344
|
+
user: User<TPresence, TUserMeta>;
|
|
1345
|
+
} | {
|
|
1346
|
+
type: "enter";
|
|
1347
|
+
user: User<TPresence, TUserMeta>;
|
|
1348
|
+
} | {
|
|
1349
|
+
type: "update";
|
|
1350
|
+
user: User<TPresence, TUserMeta>;
|
|
1351
|
+
updates: Partial<TPresence>;
|
|
1352
|
+
} | {
|
|
1353
|
+
type: "reset";
|
|
1354
|
+
};
|
|
1355
|
+
declare type LegacyOthersEventCallback<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = (others: readonly User<TPresence, TUserMeta>[], event: LegacyOthersEvent<TPresence, TUserMeta>) => void;
|
|
1329
1356
|
declare type RoomEventMessage<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
|
|
1330
1357
|
/**
|
|
1331
1358
|
* The connection ID of the client that sent the event.
|
|
@@ -1458,7 +1485,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
|
|
|
1458
1485
|
* });
|
|
1459
1486
|
*
|
|
1460
1487
|
*/
|
|
1461
|
-
(type: "others", listener:
|
|
1488
|
+
(type: "others", listener: LegacyOthersEventCallback<TPresence, TUserMeta>): () => void;
|
|
1462
1489
|
/**
|
|
1463
1490
|
* Subscribe to events broadcasted by {@link Room.broadcastEvent}
|
|
1464
1491
|
*
|
|
@@ -1708,17 +1735,12 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1708
1735
|
*/
|
|
1709
1736
|
getStorageSnapshot(): LiveObject<TStorage> | null;
|
|
1710
1737
|
readonly events: {
|
|
1711
|
-
/** @deprecated Prefer `status` instead. */
|
|
1712
|
-
readonly connection: Observable<LegacyConnectionStatus>;
|
|
1713
1738
|
readonly status: Observable<Status>;
|
|
1714
1739
|
readonly lostConnection: Observable<LostConnectionEvent>;
|
|
1715
1740
|
readonly customEvent: Observable<RoomEventMessage<TPresence, TUserMeta, TRoomEvent>>;
|
|
1716
1741
|
readonly self: Observable<User<TPresence, TUserMeta>>;
|
|
1717
1742
|
readonly myPresence: Observable<TPresence>;
|
|
1718
|
-
readonly others: Observable<
|
|
1719
|
-
others: readonly User<TPresence, TUserMeta>[];
|
|
1720
|
-
event: OthersEvent<TPresence, TUserMeta>;
|
|
1721
|
-
}>;
|
|
1743
|
+
readonly others: Observable<OthersEvent<TPresence, TUserMeta>>;
|
|
1722
1744
|
readonly error: Observable<Error>;
|
|
1723
1745
|
readonly storage: Observable<StorageUpdate[]>;
|
|
1724
1746
|
readonly history: Observable<HistoryEvent>;
|
|
@@ -1855,6 +1877,13 @@ declare type Client = {
|
|
|
1855
1877
|
* @param roomId The id of the room
|
|
1856
1878
|
*/
|
|
1857
1879
|
leave(roomId: string): void;
|
|
1880
|
+
/**
|
|
1881
|
+
* Purges all cached auth tokens and reconnects all rooms that are still
|
|
1882
|
+
* connected, if any.
|
|
1883
|
+
*
|
|
1884
|
+
* Call this whenever you log out a user in your application.
|
|
1885
|
+
*/
|
|
1886
|
+
logout(): void;
|
|
1858
1887
|
};
|
|
1859
1888
|
declare type AuthEndpoint = string | ((room: string) => Promise<CustomAuthenticationResult>);
|
|
1860
1889
|
/**
|
|
@@ -1864,6 +1893,7 @@ declare type AuthEndpoint = string | ((room: string) => Promise<CustomAuthentica
|
|
|
1864
1893
|
declare type ClientOptions = {
|
|
1865
1894
|
throttle?: number;
|
|
1866
1895
|
lostConnectionTimeout?: number;
|
|
1896
|
+
backgroundKeepAliveTimeout?: number;
|
|
1867
1897
|
polyfills?: Polyfills;
|
|
1868
1898
|
unstable_fallbackToHTTP?: boolean;
|
|
1869
1899
|
/**
|
|
@@ -1923,6 +1953,7 @@ declare type ParentToChildNodeMap = Map<string, // Parent's node ID
|
|
|
1923
1953
|
IdTuple<SerializedChild>[]>;
|
|
1924
1954
|
|
|
1925
1955
|
declare function isLiveNode(value: unknown): value is LiveNode;
|
|
1956
|
+
declare function cloneLson<L extends Lson | undefined>(value: L): L;
|
|
1926
1957
|
|
|
1927
1958
|
declare function lsonToJson(value: Lson): Json;
|
|
1928
1959
|
declare function patchLiveObjectKey<O extends LsonObject, K extends keyof O, V extends Json>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
|
|
@@ -2407,4 +2438,4 @@ declare type EnsureJson<T> = [
|
|
|
2407
2438
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
2408
2439
|
};
|
|
2409
2440
|
|
|
2410
|
-
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EnterOptions, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, stringify, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
|
2441
|
+
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EnterOptions, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, OthersEvent, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, stringify, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -240,6 +240,7 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
240
240
|
*/
|
|
241
241
|
update(patch: Partial<O>): void;
|
|
242
242
|
toImmutable(): ToImmutable<O>;
|
|
243
|
+
clone(): LiveObject<O>;
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
/**
|
|
@@ -333,6 +334,7 @@ declare class LiveMap<TKey extends string, TValue extends Lson> extends Abstract
|
|
|
333
334
|
*/
|
|
334
335
|
forEach(callback: (value: TValue, key: TKey, map: LiveMap<TKey, TValue>) => void): void;
|
|
335
336
|
toImmutable(): ReadonlyMap<TKey, ToImmutable<TValue>>;
|
|
337
|
+
clone(): LiveMap<TKey, TValue>;
|
|
336
338
|
}
|
|
337
339
|
|
|
338
340
|
declare type StorageCallback = (updates: StorageUpdate[]) => void;
|
|
@@ -352,24 +354,29 @@ declare abstract class AbstractCrdt {
|
|
|
352
354
|
* Return an immutable snapshot of this Live node and its children.
|
|
353
355
|
*/
|
|
354
356
|
toImmutable(): Immutable;
|
|
357
|
+
/**
|
|
358
|
+
* Returns a deep clone of the current LiveStructure, suitable for insertion
|
|
359
|
+
* in the tree elsewhere.
|
|
360
|
+
*/
|
|
361
|
+
abstract clone(): Lson;
|
|
355
362
|
}
|
|
356
363
|
|
|
357
364
|
declare type LiveListUpdateDelta = {
|
|
365
|
+
type: "insert";
|
|
358
366
|
index: number;
|
|
359
367
|
item: Lson;
|
|
360
|
-
type: "insert";
|
|
361
368
|
} | {
|
|
362
|
-
index: number;
|
|
363
369
|
type: "delete";
|
|
370
|
+
index: number;
|
|
364
371
|
} | {
|
|
372
|
+
type: "move";
|
|
365
373
|
index: number;
|
|
366
374
|
previousIndex: number;
|
|
367
375
|
item: Lson;
|
|
368
|
-
type: "move";
|
|
369
376
|
} | {
|
|
377
|
+
type: "set";
|
|
370
378
|
index: number;
|
|
371
379
|
item: Lson;
|
|
372
|
-
type: "set";
|
|
373
380
|
};
|
|
374
381
|
/**
|
|
375
382
|
* A LiveList notification that is sent in-client to any subscribers whenever
|
|
@@ -480,6 +487,7 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
|
480
487
|
some(predicate: (value: TItem, index: number) => unknown): boolean;
|
|
481
488
|
[Symbol.iterator](): IterableIterator<TItem>;
|
|
482
489
|
toImmutable(): readonly ToImmutable<TItem>[];
|
|
490
|
+
clone(): LiveList<TItem>;
|
|
483
491
|
}
|
|
484
492
|
|
|
485
493
|
/**
|
|
@@ -488,6 +496,7 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
|
488
496
|
declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
|
|
489
497
|
constructor(data: TValue);
|
|
490
498
|
get data(): TValue;
|
|
499
|
+
clone(): TValue;
|
|
491
500
|
}
|
|
492
501
|
|
|
493
502
|
declare type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
|
|
@@ -723,7 +732,7 @@ declare type ThreadData<TThreadMetadata extends BaseMetadata = never> = {
|
|
|
723
732
|
};
|
|
724
733
|
|
|
725
734
|
declare type Options = {
|
|
726
|
-
|
|
735
|
+
baseUrl: string;
|
|
727
736
|
};
|
|
728
737
|
declare type PartialNullable<T> = {
|
|
729
738
|
[P in keyof T]?: T[P] | null | undefined;
|
|
@@ -765,7 +774,7 @@ declare type CommentsApi<TThreadMetadata extends BaseMetadata> = {
|
|
|
765
774
|
emoji: string;
|
|
766
775
|
}): Promise<CommentData>;
|
|
767
776
|
};
|
|
768
|
-
declare function createCommentsApi<TThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>,
|
|
777
|
+
declare function createCommentsApi<TThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>, config: Options): CommentsApi<TThreadMetadata>;
|
|
769
778
|
|
|
770
779
|
declare type Callback<T> = (event: T) => void;
|
|
771
780
|
declare type UnsubscribeCallback = () => void;
|
|
@@ -944,6 +953,7 @@ declare type BaseAuthResult = NonNullable<Json>;
|
|
|
944
953
|
declare type Delegates<T extends BaseAuthResult> = {
|
|
945
954
|
authenticate: () => Promise<T>;
|
|
946
955
|
createSocket: (authValue: T) => IWebSocketInstance;
|
|
956
|
+
canZombie: () => boolean;
|
|
947
957
|
};
|
|
948
958
|
|
|
949
959
|
declare enum ClientMsgCode {
|
|
@@ -1312,7 +1322,7 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
|
|
|
1312
1322
|
* @deprecated Use `readonly User<TPresence, TUserMeta>[]` instead of `Others<TPresence, TUserMeta>`.
|
|
1313
1323
|
*/
|
|
1314
1324
|
declare type Others<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = readonly User<TPresence, TUserMeta>[];
|
|
1315
|
-
declare type
|
|
1325
|
+
declare type InternalOthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
|
|
1316
1326
|
type: "leave";
|
|
1317
1327
|
user: User<TPresence, TUserMeta>;
|
|
1318
1328
|
} | {
|
|
@@ -1325,7 +1335,24 @@ declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUse
|
|
|
1325
1335
|
} | {
|
|
1326
1336
|
type: "reset";
|
|
1327
1337
|
};
|
|
1338
|
+
declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = Resolve<InternalOthersEvent<TPresence, TUserMeta> & {
|
|
1339
|
+
others: readonly User<TPresence, TUserMeta>[];
|
|
1340
|
+
}>;
|
|
1328
1341
|
|
|
1342
|
+
declare type LegacyOthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
|
|
1343
|
+
type: "leave";
|
|
1344
|
+
user: User<TPresence, TUserMeta>;
|
|
1345
|
+
} | {
|
|
1346
|
+
type: "enter";
|
|
1347
|
+
user: User<TPresence, TUserMeta>;
|
|
1348
|
+
} | {
|
|
1349
|
+
type: "update";
|
|
1350
|
+
user: User<TPresence, TUserMeta>;
|
|
1351
|
+
updates: Partial<TPresence>;
|
|
1352
|
+
} | {
|
|
1353
|
+
type: "reset";
|
|
1354
|
+
};
|
|
1355
|
+
declare type LegacyOthersEventCallback<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = (others: readonly User<TPresence, TUserMeta>[], event: LegacyOthersEvent<TPresence, TUserMeta>) => void;
|
|
1329
1356
|
declare type RoomEventMessage<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
|
|
1330
1357
|
/**
|
|
1331
1358
|
* The connection ID of the client that sent the event.
|
|
@@ -1458,7 +1485,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
|
|
|
1458
1485
|
* });
|
|
1459
1486
|
*
|
|
1460
1487
|
*/
|
|
1461
|
-
(type: "others", listener:
|
|
1488
|
+
(type: "others", listener: LegacyOthersEventCallback<TPresence, TUserMeta>): () => void;
|
|
1462
1489
|
/**
|
|
1463
1490
|
* Subscribe to events broadcasted by {@link Room.broadcastEvent}
|
|
1464
1491
|
*
|
|
@@ -1708,17 +1735,12 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1708
1735
|
*/
|
|
1709
1736
|
getStorageSnapshot(): LiveObject<TStorage> | null;
|
|
1710
1737
|
readonly events: {
|
|
1711
|
-
/** @deprecated Prefer `status` instead. */
|
|
1712
|
-
readonly connection: Observable<LegacyConnectionStatus>;
|
|
1713
1738
|
readonly status: Observable<Status>;
|
|
1714
1739
|
readonly lostConnection: Observable<LostConnectionEvent>;
|
|
1715
1740
|
readonly customEvent: Observable<RoomEventMessage<TPresence, TUserMeta, TRoomEvent>>;
|
|
1716
1741
|
readonly self: Observable<User<TPresence, TUserMeta>>;
|
|
1717
1742
|
readonly myPresence: Observable<TPresence>;
|
|
1718
|
-
readonly others: Observable<
|
|
1719
|
-
others: readonly User<TPresence, TUserMeta>[];
|
|
1720
|
-
event: OthersEvent<TPresence, TUserMeta>;
|
|
1721
|
-
}>;
|
|
1743
|
+
readonly others: Observable<OthersEvent<TPresence, TUserMeta>>;
|
|
1722
1744
|
readonly error: Observable<Error>;
|
|
1723
1745
|
readonly storage: Observable<StorageUpdate[]>;
|
|
1724
1746
|
readonly history: Observable<HistoryEvent>;
|
|
@@ -1855,6 +1877,13 @@ declare type Client = {
|
|
|
1855
1877
|
* @param roomId The id of the room
|
|
1856
1878
|
*/
|
|
1857
1879
|
leave(roomId: string): void;
|
|
1880
|
+
/**
|
|
1881
|
+
* Purges all cached auth tokens and reconnects all rooms that are still
|
|
1882
|
+
* connected, if any.
|
|
1883
|
+
*
|
|
1884
|
+
* Call this whenever you log out a user in your application.
|
|
1885
|
+
*/
|
|
1886
|
+
logout(): void;
|
|
1858
1887
|
};
|
|
1859
1888
|
declare type AuthEndpoint = string | ((room: string) => Promise<CustomAuthenticationResult>);
|
|
1860
1889
|
/**
|
|
@@ -1864,6 +1893,7 @@ declare type AuthEndpoint = string | ((room: string) => Promise<CustomAuthentica
|
|
|
1864
1893
|
declare type ClientOptions = {
|
|
1865
1894
|
throttle?: number;
|
|
1866
1895
|
lostConnectionTimeout?: number;
|
|
1896
|
+
backgroundKeepAliveTimeout?: number;
|
|
1867
1897
|
polyfills?: Polyfills;
|
|
1868
1898
|
unstable_fallbackToHTTP?: boolean;
|
|
1869
1899
|
/**
|
|
@@ -1923,6 +1953,7 @@ declare type ParentToChildNodeMap = Map<string, // Parent's node ID
|
|
|
1923
1953
|
IdTuple<SerializedChild>[]>;
|
|
1924
1954
|
|
|
1925
1955
|
declare function isLiveNode(value: unknown): value is LiveNode;
|
|
1956
|
+
declare function cloneLson<L extends Lson | undefined>(value: L): L;
|
|
1926
1957
|
|
|
1927
1958
|
declare function lsonToJson(value: Lson): Json;
|
|
1928
1959
|
declare function patchLiveObjectKey<O extends LsonObject, K extends keyof O, V extends Json>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
|
|
@@ -2407,4 +2438,4 @@ declare type EnsureJson<T> = [
|
|
|
2407
2438
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
2408
2439
|
};
|
|
2409
2440
|
|
|
2410
|
-
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EnterOptions, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, stringify, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
|
2441
|
+
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EnterOptions, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, OthersEvent, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, cloneLson, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, stringify, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|