@liveblocks/core 1.1.1 → 1.2.0-internal1

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.ts CHANGED
@@ -1052,6 +1052,17 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1052
1052
  */
1053
1053
  addToHistory: boolean;
1054
1054
  }): void;
1055
+ /**
1056
+ *
1057
+ * Sends Yjs document updates to liveblocks server
1058
+ *
1059
+ * @param {string} data the doc update to send to the server, base64 encoded uint8array
1060
+ */
1061
+ updateYDoc(data: string): void;
1062
+ /**
1063
+ * Sends a request for the current document from liveblocks server
1064
+ */
1065
+ fetchYDoc(stateVector: string): void;
1055
1066
  /**
1056
1067
  * Broadcasts an event to other users in the room. Event broadcasted to the room can be listened with {@link Room.subscribe}("event").
1057
1068
  * @param {any} event the event to broadcast. Should be serializable to JSON
@@ -1109,6 +1120,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
1109
1120
  */
1110
1121
  readonly storageDidLoad: Observable<void>;
1111
1122
  readonly storageStatus: Observable<StorageStatus>;
1123
+ readonly ydoc: Observable<string>;
1112
1124
  };
1113
1125
  /**
1114
1126
  * Batches modifications made during the given function.
@@ -1658,6 +1670,16 @@ declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
1658
1670
  scopes: string[];
1659
1671
  };
1660
1672
  };
1673
+ /**
1674
+ * Informs the client what their actor ID is.
1675
+ * @since v1.2 (WS API v7)
1676
+ */
1677
+ readonly actor: number;
1678
+ /**
1679
+ * Informs the client whether their access is read-only.
1680
+ * @since v1.2 (WS API v7)
1681
+ */
1682
+ readonly isReadOnly: boolean;
1661
1683
  };
1662
1684
  /**
1663
1685
  * Sent by the WebSocket server to a single client in response to the client
package/dist/index.js CHANGED
@@ -145,7 +145,7 @@ var onMessageFromPanel = eventSource.observable;
145
145
  // src/devtools/index.ts
146
146
  var VERSION = true ? (
147
147
  /* istanbul ignore next */
148
- "1.1.1"
148
+ "1.2.0-internal1"
149
149
  ) : "dev";
150
150
  var _devtoolsSetupHasRun = false;
151
151
  function setupDevTools(getAllRooms) {
@@ -4402,7 +4402,8 @@ function createRoom(options, config) {
4402
4402
  storage: makeEventSource(),
4403
4403
  history: makeEventSource(),
4404
4404
  storageDidLoad: makeEventSource(),
4405
- storageStatus: makeEventSource()
4405
+ storageStatus: makeEventSource(),
4406
+ ydoc: makeEventSource()
4406
4407
  };
4407
4408
  function sendMessages(messageOrMessages) {
4408
4409
  var _a2, _b2;
@@ -4823,6 +4824,10 @@ function createRoom(options, config) {
4823
4824
  }
4824
4825
  break;
4825
4826
  }
4827
+ case 300 /* UPDATE_YDOC */: {
4828
+ eventHub.ydoc.notify(message.update);
4829
+ break;
4830
+ }
4826
4831
  case 104 /* ROOM_STATE */: {
4827
4832
  updates.others.push(onRoomStateMessage(message));
4828
4833
  break;
@@ -4941,6 +4946,13 @@ ${Array.from(traces).join("\n\n")}`
4941
4946
  }
4942
4947
  return messages;
4943
4948
  }
4949
+ function updateYDoc(update) {
4950
+ context.buffer.messages.push({
4951
+ type: 301 /* UPDATE_YDOC */,
4952
+ update
4953
+ });
4954
+ flushNowOrSoon();
4955
+ }
4944
4956
  function broadcastEvent(event, options2 = {
4945
4957
  shouldQueueEventIfNotReady: false
4946
4958
  }) {
@@ -5000,6 +5012,13 @@ ${Array.from(traces).join("\n\n")}`
5000
5012
  };
5001
5013
  });
5002
5014
  }
5015
+ function fetchYDoc(vector) {
5016
+ context.buffer.messages.push({
5017
+ type: 300 /* FETCH_YDOC */,
5018
+ vector
5019
+ });
5020
+ flushNowOrSoon();
5021
+ }
5003
5022
  function undo() {
5004
5023
  if (context.activeBatch) {
5005
5024
  throw new Error("undo is not allowed during a batch");
@@ -5121,7 +5140,8 @@ ${Array.from(traces).join("\n\n")}`
5121
5140
  storage: eventHub.storage.observable,
5122
5141
  history: eventHub.history.observable,
5123
5142
  storageDidLoad: eventHub.storageDidLoad.observable,
5124
- storageStatus: eventHub.storageStatus.observable
5143
+ storageStatus: eventHub.storageStatus.observable,
5144
+ ydoc: eventHub.ydoc.observable
5125
5145
  };
5126
5146
  return {
5127
5147
  /* NOTE: Exposing __internal here only to allow testing implementation details in unit tests */
@@ -5156,6 +5176,7 @@ ${Array.from(traces).join("\n\n")}`
5156
5176
  destroy: () => managedSocket.destroy(),
5157
5177
  // Presence
5158
5178
  updatePresence,
5179
+ updateYDoc,
5159
5180
  broadcastEvent,
5160
5181
  // Storage
5161
5182
  batch,
@@ -5167,6 +5188,7 @@ ${Array.from(traces).join("\n\n")}`
5167
5188
  pause: pauseHistory,
5168
5189
  resume: resumeHistory
5169
5190
  },
5191
+ fetchYDoc,
5170
5192
  getStorage,
5171
5193
  getStorageSnapshot,
5172
5194
  getStorageStatus,
@@ -5282,7 +5304,7 @@ function makeCreateSocketDelegateForRoom(liveblocksServer, WebSocketPolyfill) {
5282
5304
  // @ts-ignore (__PACKAGE_VERSION__ will be injected by the build script)
5283
5305
  true ? (
5284
5306
  /* istanbul ignore next */
5285
- "1.1.1"
5307
+ "1.2.0-internal1"
5286
5308
  ) : "dev"}`
5287
5309
  );
5288
5310
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/core",
3
- "version": "1.1.1",
3
+ "version": "1.2.0-internal1",
4
4
  "description": "Shared code and foundational internals for Liveblocks",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -27,9 +27,9 @@
27
27
  "test:types": "tsd",
28
28
  "test:watch": "jest --silent --verbose --color=always --watch",
29
29
  "test:e2e": "jest --silent --verbose --color=always --config=./jest.config.e2e.js",
30
- "test:deps": "depcruise src --exclude __tests__ --config",
31
- "showdeps": "depcruise src --include-only '^src' --exclude='__tests__' --config --output-type dot | dot -T svg > /tmp/dependency-graph.svg && open /tmp/dependency-graph.svg",
32
- "showdeps:high-level": "depcruise src --include-only '^src' --exclude='(^src/index.ts|shallow.ts|__tests__)' --collapse='^src/(refs|lib|compat|types|crdts|protocol)' --config --output-type dot | dot -T svg > /tmp/dependency-graph.svg && open /tmp/dependency-graph.svg"
30
+ "test:deps": "depcruise src --exclude __tests__",
31
+ "showdeps": "depcruise src --include-only '^src' --exclude='__tests__' --output-type dot | dot -T svg > /tmp/dependency-graph.svg && open /tmp/dependency-graph.svg",
32
+ "showdeps:high-level": "depcruise src --include-only '^src' --exclude='(^src/index.ts|shallow.ts|__tests__)' --collapse='^src/(refs|lib|compat|types|crdts|protocol)' --output-type dot | dot -T svg > /tmp/dependency-graph.svg && open /tmp/dependency-graph.svg"
33
33
  },
34
34
  "license": "Apache-2.0",
35
35
  "devDependencies": {