@liveblocks/react 2.9.0 → 2.9.1

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "2.9.0";
3
+ var PKG_VERSION = "2.9.1";
4
4
  var PKG_FORMAT = "cjs";
5
5
 
6
6
  // src/ClientSideSuspense.tsx
@@ -64,7 +64,7 @@ function isMoreRecentlyUpdated(a, b) {
64
64
  return byMostRecentlyUpdated(a, b) < 0;
65
65
  }
66
66
  function byMostRecentlyUpdated(a, b) {
67
- return (_nullishCoalesce(b.updatedAt, () => ( b.createdAt))).getTime() - (_nullishCoalesce(a.updatedAt, () => ( a.createdAt))).getTime();
67
+ return b.updatedAt.getTime() - a.updatedAt.getTime();
68
68
  }
69
69
 
70
70
  // src/lib/guards.ts
@@ -87,8 +87,11 @@ function matchesMetadata(thread, q) {
87
87
  const metadata = thread.metadata;
88
88
  return q.metadata === void 0 || Object.entries(q.metadata).every(
89
89
  ([key, op]) => (
90
- // Boolean logic: op? => value matches the operator
91
- op === void 0 || matchesOperator(metadata[key], op)
90
+ // NOTE: `op` can be explicitly-`undefined` here, which ideally would not
91
+ // mean "filter for absence" like it does now, as this does not match the
92
+ // backend behavior at the moment. For an in-depth discussion, see
93
+ // https://liveblocks.slack.com/archives/C02PZL7QAAW/p1728546988505989
94
+ matchesOperator(metadata[key], op)
92
95
  )
93
96
  );
94
97
  }
@@ -595,7 +598,7 @@ var UmbrellaStore = class {
595
598
  if (existing.deletedAt !== void 0) {
596
599
  return cache;
597
600
  }
598
- if (!!updatedAt && !!existing.updatedAt && existing.updatedAt > updatedAt) {
601
+ if (!!updatedAt && existing.updatedAt > updatedAt) {
599
602
  return cache;
600
603
  }
601
604
  return { ...cache, [threadId]: callback(existing) };
@@ -780,7 +783,6 @@ var UmbrellaStore = class {
780
783
  async fetchNotificationsDeltaUpdate() {
781
784
  const lastRequestedAt = this._notificationsLastRequestedAt;
782
785
  if (lastRequestedAt === null) {
783
- _core.console.warn("Notifications polled before first page loaded");
784
786
  return;
785
787
  }
786
788
  const client = _core.nn.call(void 0,
@@ -844,7 +846,6 @@ var UmbrellaStore = class {
844
846
  async fetchRoomThreadsDeltaUpdate(roomId) {
845
847
  const lastRequestedAt = this._roomThreadsLastRequestedAtByRoom.get(roomId);
846
848
  if (lastRequestedAt === void 0) {
847
- _core.console.warn("Room threads polled before first page loaded");
848
849
  return;
849
850
  }
850
851
  const client = _core.nn.call(void 0,
@@ -907,7 +908,6 @@ var UmbrellaStore = class {
907
908
  async fetchUserThreadsDeltaUpdate() {
908
909
  const lastRequestedAt = this._userThreadsLastRequestedAt;
909
910
  if (lastRequestedAt === null) {
910
- _core.console.warn("User threads polled before first page loaded");
911
911
  return;
912
912
  }
913
913
  const client = _core.nn.call(void 0,
@@ -948,7 +948,7 @@ function internalToExternalState(state) {
948
948
  if (thread.deletedAt !== void 0) {
949
949
  break;
950
950
  }
951
- if (thread.updatedAt !== void 0 && thread.updatedAt > optimisticUpdate.updatedAt) {
951
+ if (thread.updatedAt > optimisticUpdate.updatedAt) {
952
952
  break;
953
953
  }
954
954
  computed.threadsById[thread.id] = {
@@ -1211,7 +1211,7 @@ function applyUpsertComment(thread, comment) {
1211
1211
  );
1212
1212
  if (existingComment === void 0) {
1213
1213
  const updatedAt = new Date(
1214
- Math.max(_optionalChain([thread, 'access', _7 => _7.updatedAt, 'optionalAccess', _8 => _8.getTime, 'call', _9 => _9()]) || 0, comment.createdAt.getTime())
1214
+ Math.max(thread.updatedAt.getTime(), comment.createdAt.getTime())
1215
1215
  );
1216
1216
  const updatedThread = {
1217
1217
  ...thread,
@@ -1231,8 +1231,8 @@ function applyUpsertComment(thread, comment) {
1231
1231
  ...thread,
1232
1232
  updatedAt: new Date(
1233
1233
  Math.max(
1234
- _optionalChain([thread, 'access', _10 => _10.updatedAt, 'optionalAccess', _11 => _11.getTime, 'call', _12 => _12()]) || 0,
1235
- _optionalChain([comment, 'access', _13 => _13.editedAt, 'optionalAccess', _14 => _14.getTime, 'call', _15 => _15()]) || comment.createdAt.getTime()
1234
+ thread.updatedAt.getTime(),
1235
+ _optionalChain([comment, 'access', _7 => _7.editedAt, 'optionalAccess', _8 => _8.getTime, 'call', _9 => _9()]) || comment.createdAt.getTime()
1236
1236
  )
1237
1237
  ),
1238
1238
  comments: updatedComments
@@ -1298,7 +1298,7 @@ function applyAddReaction(thread, commentId, reaction) {
1298
1298
  return {
1299
1299
  ...thread,
1300
1300
  updatedAt: new Date(
1301
- Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _16 => _16.updatedAt, 'optionalAccess', _17 => _17.getTime, 'call', _18 => _18()]) || 0)
1301
+ Math.max(reaction.createdAt.getTime(), thread.updatedAt.getTime())
1302
1302
  ),
1303
1303
  comments: updatedComments
1304
1304
  };
@@ -1331,7 +1331,7 @@ function applyRemoveReaction(thread, commentId, emoji, userId, removedAt) {
1331
1331
  return {
1332
1332
  ...thread,
1333
1333
  updatedAt: new Date(
1334
- Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _19 => _19.updatedAt, 'optionalAccess', _20 => _20.getTime, 'call', _21 => _21()]) || 0)
1334
+ Math.max(removedAt.getTime(), thread.updatedAt.getTime())
1335
1335
  ),
1336
1336
  comments: updatedComments
1337
1337
  };
@@ -1488,7 +1488,7 @@ function selectorFor_useUnreadInboxNotificationsCount(result) {
1488
1488
  };
1489
1489
  }
1490
1490
  function selectorFor_useUser(state, userId) {
1491
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _22 => _22.isLoading])) {
1491
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _10 => _10.isLoading])) {
1492
1492
  return _nullishCoalesce(state, () => ( { isLoading: true }));
1493
1493
  }
1494
1494
  if (state.error) {
@@ -1506,7 +1506,7 @@ function selectorFor_useUser(state, userId) {
1506
1506
  };
1507
1507
  }
1508
1508
  function selectorFor_useRoomInfo(state, roomId) {
1509
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _23 => _23.isLoading])) {
1509
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _11 => _11.isLoading])) {
1510
1510
  return _nullishCoalesce(state, () => ( { isLoading: true }));
1511
1511
  }
1512
1512
  if (state.error) {
@@ -1920,7 +1920,7 @@ function createSharedContext(client) {
1920
1920
  }
1921
1921
  function useEnsureNoLiveblocksProvider(options) {
1922
1922
  const existing = useClientOrNull();
1923
- if (!_optionalChain([options, 'optionalAccess', _24 => _24.allowNesting]) && existing !== null) {
1923
+ if (!_optionalChain([options, 'optionalAccess', _12 => _12.allowNesting]) && existing !== null) {
1924
1924
  throw new Error(
1925
1925
  "You cannot nest multiple LiveblocksProvider instances in the same React tree."
1926
1926
  );
@@ -2292,7 +2292,7 @@ function getCurrentUserId(room) {
2292
2292
  }
2293
2293
  function handleApiError(err) {
2294
2294
  const message = `Request failed with status ${err.status}: ${err.message}`;
2295
- if (_optionalChain([err, 'access', _25 => _25.details, 'optionalAccess', _26 => _26.error]) === "FORBIDDEN") {
2295
+ if (_optionalChain([err, 'access', _13 => _13.details, 'optionalAccess', _14 => _14.error]) === "FORBIDDEN") {
2296
2296
  const detailedMessage = [message, err.details.suggestion, err.details.docs].filter(Boolean).join("\n");
2297
2297
  _core.console.error(detailedMessage);
2298
2298
  }
@@ -2661,7 +2661,7 @@ function useStatus() {
2661
2661
  return useSyncExternalStore2(subscribe, getSnapshot, getServerSnapshot);
2662
2662
  }
2663
2663
  function useStorageStatus(options) {
2664
- const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.smooth]), () => ( false)));
2664
+ const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _15 => _15.smooth]), () => ( false)));
2665
2665
  if (smooth) {
2666
2666
  return useStorageStatusSmooth();
2667
2667
  } else {
@@ -2997,7 +2997,7 @@ function useCreateThread() {
2997
2997
  thread: newThread,
2998
2998
  roomId: room.id
2999
2999
  });
3000
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _28 => _28.map, 'call', _29 => _29((attachment) => attachment.id)]);
3000
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _16 => _16.map, 'call', _17 => _17((attachment) => attachment.id)]);
3001
3001
  room.createThread({ threadId, commentId, body, metadata, attachmentIds }).then(
3002
3002
  (thread) => {
3003
3003
  store.createThread(optimisticUpdateId, thread);
@@ -3027,7 +3027,7 @@ function useDeleteThread() {
3027
3027
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
3028
3028
  const thread = store.getFullState().threadsById[threadId];
3029
3029
  const userId = getCurrentUserId(room);
3030
- if (_optionalChain([thread, 'optionalAccess', _30 => _30.comments, 'optionalAccess', _31 => _31[0], 'optionalAccess', _32 => _32.userId]) !== userId) {
3030
+ if (_optionalChain([thread, 'optionalAccess', _18 => _18.comments, 'optionalAccess', _19 => _19[0], 'optionalAccess', _20 => _20.userId]) !== userId) {
3031
3031
  throw new Error("Only the thread creator can delete the thread");
3032
3032
  }
3033
3033
  const optimisticUpdateId = store.addOptimisticUpdate({
@@ -3115,7 +3115,7 @@ function useCreateComment() {
3115
3115
  type: "create-comment",
3116
3116
  comment
3117
3117
  });
3118
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _33 => _33.map, 'call', _34 => _34((attachment) => attachment.id)]);
3118
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _21 => _21.map, 'call', _22 => _22((attachment) => attachment.id)]);
3119
3119
  room.createComment({ threadId, commentId, body, attachmentIds }).then(
3120
3120
  (newComment) => {
3121
3121
  store.createComment(newComment, optimisticUpdateId);
@@ -3168,7 +3168,7 @@ function useEditComment() {
3168
3168
  attachments: _nullishCoalesce(attachments, () => ( []))
3169
3169
  }
3170
3170
  });
3171
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _35 => _35.map, 'call', _36 => _36((attachment) => attachment.id)]);
3171
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _23 => _23.map, 'call', _24 => _24((attachment) => attachment.id)]);
3172
3172
  room.editComment({ threadId, commentId, body, attachmentIds }).then(
3173
3173
  (editedComment) => {
3174
3174
  store.editComment(threadId, optimisticUpdateId, editedComment);
@@ -3667,7 +3667,7 @@ function useThreadsSuspense(options = {
3667
3667
  return result;
3668
3668
  }
3669
3669
  function selectorFor_useAttachmentUrl(state) {
3670
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _37 => _37.isLoading])) {
3670
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _25 => _25.isLoading])) {
3671
3671
  return _nullishCoalesce(state, () => ( { isLoading: true }));
3672
3672
  }
3673
3673
  if (state.error) {
@@ -3850,4 +3850,4 @@ var _useUpdateMyPresence = useUpdateMyPresence;
3850
3850
 
3851
3851
 
3852
3852
  exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense; exports.RoomContext = RoomContext; exports.selectThreads = selectThreads; exports.ClientContext = ClientContext; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useClient = useClient; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports.CreateThreadError = CreateThreadError; exports.useStatus = useStatus; exports.useStorageStatus = useStorageStatus; exports.useBatch = useBatch; exports.useLostConnectionListener = useLostConnectionListener; exports.useErrorListener = useErrorListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCommentsErrorListener = useCommentsErrorListener; exports.useCreateComment = useCreateComment; exports.useEditComment = useEditComment; exports.useDeleteComment = useDeleteComment; exports.useRemoveReaction = useRemoveReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useRoomNotificationSettings = useRoomNotificationSettings; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; exports.useAttachmentUrl = useAttachmentUrl; exports.useAttachmentUrlSuspense = useAttachmentUrlSuspense; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence;
3853
- //# sourceMappingURL=chunk-T6ILO2YI.js.map
3853
+ //# sourceMappingURL=chunk-B4ZHLBDS.js.map