@liveblocks/core 1.1.1-internal1 → 1.1.1-yjs1

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
+ getYDoc(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 docUpdated: Observable<string>;
1112
1124
  };
1113
1125
  /**
1114
1126
  * Batches modifications made during the given function.
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-internal1"
148
+ "1.1.1-yjs1"
149
149
  ) : "dev";
150
150
  var _devtoolsSetupHasRun = false;
151
151
  function setupDevTools(getAllRooms) {
@@ -4394,7 +4394,8 @@ function createRoom(options, config) {
4394
4394
  storage: makeEventSource(),
4395
4395
  history: makeEventSource(),
4396
4396
  storageDidLoad: makeEventSource(),
4397
- storageStatus: makeEventSource()
4397
+ storageStatus: makeEventSource(),
4398
+ docUpdated: makeEventSource()
4398
4399
  };
4399
4400
  function sendMessages(messageOrMessages) {
4400
4401
  var _a2, _b2;
@@ -4815,6 +4816,10 @@ function createRoom(options, config) {
4815
4816
  }
4816
4817
  break;
4817
4818
  }
4819
+ case 300 /* UPDATE_YDOC */: {
4820
+ eventHub.docUpdated.notify(message.update);
4821
+ break;
4822
+ }
4818
4823
  case 104 /* ROOM_STATE */: {
4819
4824
  updates.others.push(onRoomStateMessage(message));
4820
4825
  break;
@@ -4933,6 +4938,13 @@ ${Array.from(traces).join("\n\n")}`
4933
4938
  }
4934
4939
  return messages;
4935
4940
  }
4941
+ function updateYDoc(update) {
4942
+ context.buffer.messages.push({
4943
+ type: 301 /* UPDATE_YDOC */,
4944
+ update
4945
+ });
4946
+ flushNowOrSoon();
4947
+ }
4936
4948
  function broadcastEvent(event, options2 = {
4937
4949
  shouldQueueEventIfNotReady: false
4938
4950
  }) {
@@ -4992,6 +5004,13 @@ ${Array.from(traces).join("\n\n")}`
4992
5004
  };
4993
5005
  });
4994
5006
  }
5007
+ function getYDoc(vector) {
5008
+ context.buffer.messages.push({
5009
+ type: 300 /* FETCH_YDOC */,
5010
+ vector
5011
+ });
5012
+ flushNowOrSoon();
5013
+ }
4995
5014
  function undo() {
4996
5015
  if (context.activeBatch) {
4997
5016
  throw new Error("undo is not allowed during a batch");
@@ -5113,7 +5132,8 @@ ${Array.from(traces).join("\n\n")}`
5113
5132
  storage: eventHub.storage.observable,
5114
5133
  history: eventHub.history.observable,
5115
5134
  storageDidLoad: eventHub.storageDidLoad.observable,
5116
- storageStatus: eventHub.storageStatus.observable
5135
+ storageStatus: eventHub.storageStatus.observable,
5136
+ docUpdated: eventHub.docUpdated.observable
5117
5137
  };
5118
5138
  return {
5119
5139
  /* NOTE: Exposing __internal here only to allow testing implementation details in unit tests */
@@ -5148,6 +5168,7 @@ ${Array.from(traces).join("\n\n")}`
5148
5168
  destroy: () => managedSocket.destroy(),
5149
5169
  // Presence
5150
5170
  updatePresence,
5171
+ updateYDoc,
5151
5172
  broadcastEvent,
5152
5173
  // Storage
5153
5174
  batch,
@@ -5159,6 +5180,7 @@ ${Array.from(traces).join("\n\n")}`
5159
5180
  pause: pauseHistory,
5160
5181
  resume: resumeHistory
5161
5182
  },
5183
+ getYDoc,
5162
5184
  getStorage,
5163
5185
  getStorageSnapshot,
5164
5186
  getStorageStatus,
@@ -5274,7 +5296,7 @@ function makeCreateSocketDelegateForRoom(liveblocksServer, WebSocketPolyfill) {
5274
5296
  // @ts-ignore (__PACKAGE_VERSION__ will be injected by the build script)
5275
5297
  true ? (
5276
5298
  /* istanbul ignore next */
5277
- "1.1.1-internal1"
5299
+ "1.1.1-yjs1"
5278
5300
  ) : "dev"}`
5279
5301
  );
5280
5302
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/core",
3
- "version": "1.1.1-internal1",
3
+ "version": "1.1.1-yjs1",
4
4
  "description": "Shared code and foundational internals for Liveblocks",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",