@liveblocks/core 1.5.3-test1 → 1.6.0-subdocs1

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 CHANGED
@@ -41,8 +41,7 @@ declare enum OpCode {
41
41
  * only.
42
42
  */
43
43
  declare type Op = AckOp | CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
44
- declare type CreateOp = CreateChildOp;
45
- declare type CreateChildOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
44
+ declare type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
46
45
  declare type UpdateObjectOp = {
47
46
  readonly opId?: string;
48
47
  readonly id: string;
@@ -1000,10 +999,12 @@ declare type FetchStorageClientMsg = {
1000
999
  declare type FetchYDocClientMsg = {
1001
1000
  readonly type: ClientMsgCode.FETCH_YDOC;
1002
1001
  readonly vector: string;
1002
+ readonly guid?: string;
1003
1003
  };
1004
1004
  declare type UpdateYDocClientMsg = {
1005
1005
  readonly type: ClientMsgCode.UPDATE_YDOC;
1006
1006
  readonly update: string;
1007
+ readonly guid?: string;
1007
1008
  };
1008
1009
 
1009
1010
  declare type IdTuple<T> = [id: string, value: T];
@@ -1195,6 +1196,7 @@ declare type YDocUpdateServerMsg = {
1195
1196
  readonly update: string;
1196
1197
  readonly isSync: boolean;
1197
1198
  readonly stateVector: string | null;
1199
+ readonly guid?: string;
1198
1200
  };
1199
1201
  /**
1200
1202
  * Sent by the WebSocket server and broadcasted to all clients to announce that
@@ -1687,11 +1689,11 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1687
1689
  *
1688
1690
  * @param {string} data the doc update to send to the server, base64 encoded uint8array
1689
1691
  */
1690
- updateYDoc(data: string): void;
1692
+ updateYDoc(data: string, guid?: string): void;
1691
1693
  /**
1692
1694
  * Sends a request for the current document from liveblocks server
1693
1695
  */
1694
- fetchYDoc(stateVector: string): void;
1696
+ fetchYDoc(stateVector: string, guid?: string): void;
1695
1697
  /**
1696
1698
  * Broadcasts an event to other users in the room. Event broadcasted to the room can be listened with {@link Room.subscribe}("event").
1697
1699
  * @param {any} event the event to broadcast. Should be serializable to JSON
@@ -2144,6 +2146,10 @@ declare const brand: unique symbol;
2144
2146
  declare type Brand<T, TBrand extends string> = T & {
2145
2147
  [brand]: TBrand;
2146
2148
  };
2149
+ /**
2150
+ * Throw an error, but as an expression instead of a statement.
2151
+ */
2152
+ declare function raise(msg: string): never;
2147
2153
  declare function isPlainObject(blob: unknown): blob is {
2148
2154
  [key: string]: unknown;
2149
2155
  };
@@ -2430,4 +2436,4 @@ declare type EnsureJson<T> = [
2430
2436
  [K in keyof T]: EnsureJson<T[K]>;
2431
2437
  };
2432
2438
 
2433
- export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, 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 };
2439
+ export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, Brand, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, 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, raise, shallow, stringify, throwUsageError, toPlainLson, tryParseJson, withTimeout };
package/dist/index.d.ts CHANGED
@@ -41,8 +41,7 @@ declare enum OpCode {
41
41
  * only.
42
42
  */
43
43
  declare type Op = AckOp | CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
44
- declare type CreateOp = CreateChildOp;
45
- declare type CreateChildOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
44
+ declare type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
46
45
  declare type UpdateObjectOp = {
47
46
  readonly opId?: string;
48
47
  readonly id: string;
@@ -1000,10 +999,12 @@ declare type FetchStorageClientMsg = {
1000
999
  declare type FetchYDocClientMsg = {
1001
1000
  readonly type: ClientMsgCode.FETCH_YDOC;
1002
1001
  readonly vector: string;
1002
+ readonly guid?: string;
1003
1003
  };
1004
1004
  declare type UpdateYDocClientMsg = {
1005
1005
  readonly type: ClientMsgCode.UPDATE_YDOC;
1006
1006
  readonly update: string;
1007
+ readonly guid?: string;
1007
1008
  };
1008
1009
 
1009
1010
  declare type IdTuple<T> = [id: string, value: T];
@@ -1195,6 +1196,7 @@ declare type YDocUpdateServerMsg = {
1195
1196
  readonly update: string;
1196
1197
  readonly isSync: boolean;
1197
1198
  readonly stateVector: string | null;
1199
+ readonly guid?: string;
1198
1200
  };
1199
1201
  /**
1200
1202
  * Sent by the WebSocket server and broadcasted to all clients to announce that
@@ -1687,11 +1689,11 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1687
1689
  *
1688
1690
  * @param {string} data the doc update to send to the server, base64 encoded uint8array
1689
1691
  */
1690
- updateYDoc(data: string): void;
1692
+ updateYDoc(data: string, guid?: string): void;
1691
1693
  /**
1692
1694
  * Sends a request for the current document from liveblocks server
1693
1695
  */
1694
- fetchYDoc(stateVector: string): void;
1696
+ fetchYDoc(stateVector: string, guid?: string): void;
1695
1697
  /**
1696
1698
  * Broadcasts an event to other users in the room. Event broadcasted to the room can be listened with {@link Room.subscribe}("event").
1697
1699
  * @param {any} event the event to broadcast. Should be serializable to JSON
@@ -2144,6 +2146,10 @@ declare const brand: unique symbol;
2144
2146
  declare type Brand<T, TBrand extends string> = T & {
2145
2147
  [brand]: TBrand;
2146
2148
  };
2149
+ /**
2150
+ * Throw an error, but as an expression instead of a statement.
2151
+ */
2152
+ declare function raise(msg: string): never;
2147
2153
  declare function isPlainObject(blob: unknown): blob is {
2148
2154
  [key: string]: unknown;
2149
2155
  };
@@ -2430,4 +2436,4 @@ declare type EnsureJson<T> = [
2430
2436
  [K in keyof T]: EnsureJson<T[K]>;
2431
2437
  };
2432
2438
 
2433
- export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, 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 };
2439
+ export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, Brand, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, 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, raise, shallow, stringify, throwUsageError, toPlainLson, tryParseJson, withTimeout };
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "1.5.3-test1";
9
+ var PKG_VERSION = "1.6.0-subdocs1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -572,6 +572,9 @@ var FSM = class {
572
572
  };
573
573
 
574
574
  // src/lib/utils.ts
575
+ function raise(msg) {
576
+ throw new Error(msg);
577
+ }
575
578
  function isPlainObject(blob) {
576
579
  return blob !== null && typeof blob === "object" && Object.prototype.toString.call(blob) === "[object Object]";
577
580
  }
@@ -5567,10 +5570,11 @@ ${Array.from(traces).join("\n\n")}`
5567
5570
  }
5568
5571
  return messages;
5569
5572
  }
5570
- function updateYDoc(update) {
5573
+ function updateYDoc(update, guid) {
5571
5574
  const clientMsg = {
5572
5575
  type: 301 /* UPDATE_YDOC */,
5573
- update
5576
+ update,
5577
+ guid
5574
5578
  };
5575
5579
  context.buffer.messages.push(clientMsg);
5576
5580
  eventHub.ydoc.notify(clientMsg);
@@ -5633,13 +5637,14 @@ ${Array.from(traces).join("\n\n")}`
5633
5637
  root: nn(context.root)
5634
5638
  };
5635
5639
  }
5636
- function fetchYDoc(vector) {
5640
+ function fetchYDoc(vector, guid) {
5637
5641
  if (!context.buffer.messages.find((m) => {
5638
- return m.type === 300 /* FETCH_YDOC */ && m.vector === vector;
5642
+ return m.type === 300 /* FETCH_YDOC */ && m.vector === vector && m.guid === guid;
5639
5643
  })) {
5640
5644
  context.buffer.messages.push({
5641
5645
  type: 300 /* FETCH_YDOC */,
5642
- vector
5646
+ vector,
5647
+ guid
5643
5648
  });
5644
5649
  }
5645
5650
  flushNowOrSoon();
@@ -6775,5 +6780,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
6775
6780
 
6776
6781
 
6777
6782
 
6778
- exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.createAsyncCache = createAsyncCache; exports.createClient = createClient; exports.createCommentsApi = createCommentsApi; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.nn = nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.shallow = shallow; exports.stringify = stringify; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.withTimeout = withTimeout;
6783
+
6784
+ exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.createAsyncCache = createAsyncCache; exports.createClient = createClient; exports.createCommentsApi = createCommentsApi; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.nn = nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.shallow = shallow; exports.stringify = stringify; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.withTimeout = withTimeout;
6779
6785
  //# sourceMappingURL=index.js.map