@liveblocks/core 1.3.6 → 1.4.0-test1

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.mjs 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.3.6";
9
+ var PKG_VERSION = "1.4.0-test1";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -1542,9 +1542,18 @@ function startSyncStream(room) {
1542
1542
  room.events.storage.subscribe(() => partialSyncStorage(room)),
1543
1543
  // Any time "me" or "others" updates, send the new values accordingly
1544
1544
  room.events.self.subscribe(() => partialSyncMe(room)),
1545
- room.events.others.subscribe(() => partialSyncOthers(room))
1545
+ room.events.others.subscribe(() => partialSyncOthers(room)),
1546
+ // Any time ydoc is updated, forward the update
1547
+ room.events.ydoc.subscribe((update) => syncYdocUpdate(room, update))
1546
1548
  ]);
1547
1549
  }
1550
+ function syncYdocUpdate(room, update) {
1551
+ sendToPanel({
1552
+ msg: "room::sync::ydoc",
1553
+ roomId: room.id,
1554
+ update
1555
+ });
1556
+ }
1548
1557
  function partialSyncConnection(room) {
1549
1558
  sendToPanel({
1550
1559
  msg: "room::sync::partial",
@@ -1586,6 +1595,7 @@ function fullSync(room) {
1586
1595
  const root = room.getStorageSnapshot();
1587
1596
  const me = room.__internal.getSelf_forDevTools();
1588
1597
  const others = room.__internal.getOthers_forDevTools();
1598
+ room.fetchYDoc("");
1589
1599
  sendToPanel({
1590
1600
  msg: "room::sync::full",
1591
1601
  roomId: room.id,
@@ -1821,13 +1831,47 @@ function createCommentsApi(roomId, getAuthValue, { serverEndpoint }) {
1821
1831
  }
1822
1832
  );
1823
1833
  }
1834
+ function addReaction({
1835
+ threadId,
1836
+ commentId,
1837
+ emoji
1838
+ }) {
1839
+ return fetchJson(
1840
+ `/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
1841
+ commentId
1842
+ )}/reactions`,
1843
+ {
1844
+ method: "POST",
1845
+ headers: {
1846
+ "Content-Type": "application/json"
1847
+ },
1848
+ body: JSON.stringify({ emoji })
1849
+ }
1850
+ );
1851
+ }
1852
+ function removeReaction({
1853
+ threadId,
1854
+ commentId,
1855
+ emoji
1856
+ }) {
1857
+ return fetchJson(
1858
+ `/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
1859
+ commentId
1860
+ )}/reactions/${encodeURIComponent(emoji)}`,
1861
+ {
1862
+ method: "DELETE"
1863
+ }
1864
+ );
1865
+ }
1824
1866
  return {
1825
1867
  getThreads,
1826
1868
  createThread,
1827
1869
  editThreadMetadata,
1828
1870
  createComment,
1829
1871
  editComment,
1830
- deleteComment
1872
+ deleteComment,
1873
+ addReaction,
1874
+ removeReaction
1831
1875
  };
1832
1876
  }
1833
1877
 
@@ -5261,8 +5305,10 @@ function createRoom(options, config) {
5261
5305
  break;
5262
5306
  }
5263
5307
  case 103 /* BROADCASTED_EVENT */: {
5308
+ const others = context.others.current;
5264
5309
  eventHub.customEvent.notify({
5265
5310
  connectionId: message.actor,
5311
+ user: message.actor < 0 ? null : others.find((u) => u.connectionId === message.actor) ?? null,
5266
5312
  event: message.event
5267
5313
  });
5268
5314
  break;
@@ -5405,10 +5451,12 @@ ${Array.from(traces).join("\n\n")}`
5405
5451
  return messages;
5406
5452
  }
5407
5453
  function updateYDoc(update) {
5408
- context.buffer.messages.push({
5454
+ const clientMsg = {
5409
5455
  type: 301 /* UPDATE_YDOC */,
5410
5456
  update
5411
- });
5457
+ };
5458
+ context.buffer.messages.push(clientMsg);
5459
+ eventHub.ydoc.notify(clientMsg);
5412
5460
  flushNowOrSoon();
5413
5461
  }
5414
5462
  function broadcastEvent(event, options2 = {