@liveblocks/react 3.7.0 → 3.7.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});// src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "3.7.0";
3
+ var PKG_VERSION = "3.7.1";
4
4
  var PKG_FORMAT = "cjs";
5
5
 
6
6
  // src/ClientSideSuspense.tsx
@@ -20,4 +20,4 @@ function ClientSideSuspense(props) {
20
20
 
21
21
 
22
22
  exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense;
23
- //# sourceMappingURL=chunk-OXA6JGB4.cjs.map
23
+ //# sourceMappingURL=chunk-MEL5UMNW.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-OXA6JGB4.cjs","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,OAAA;AACvD,IAAM,WAAA,EAAgD,KAAA;ADD7D;AACA;AEJA,8BAA8C;AAkC1C,+CAAA;AAVG,SAAS,kBAAA,CAAmB,KAAA,EAAc;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAE5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAGd,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,CAAC,CAAC,CAAA;AAEL,EAAA,uBACE,6BAAA,eAAC,EAAA,EAAS,QAAA,EAAU,KAAA,CAAM,QAAA,EACvB,QAAA,EAAA,QAAA,EACG,OAAO,KAAA,CAAM,SAAA,IAAa,WAAA,EACxB,KAAA,CAAM,QAAA,CAAS,EAAA,EACf,KAAA,CAAM,SAAA,EACR,KAAA,CAAM,SAAA,CACZ,CAAA;AAEJ;AF5BA;AACA;AACE;AACA;AACA;AACA;AACF,iJAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-OXA6JGB4.cjs","sourcesContent":[null,"declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-MEL5UMNW.cjs","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,OAAA;AACvD,IAAM,WAAA,EAAgD,KAAA;ADD7D;AACA;AEJA,8BAA8C;AAkC1C,+CAAA;AAVG,SAAS,kBAAA,CAAmB,KAAA,EAAc;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAE5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAGd,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,CAAC,CAAC,CAAA;AAEL,EAAA,uBACE,6BAAA,eAAC,EAAA,EAAS,QAAA,EAAU,KAAA,CAAM,QAAA,EACvB,QAAA,EAAA,QAAA,EACG,OAAO,KAAA,CAAM,SAAA,IAAa,WAAA,EACxB,KAAA,CAAM,QAAA,CAAS,EAAA,EACf,KAAA,CAAM,SAAA,EACR,KAAA,CAAM,SAAA,CACZ,CAAA;AAEJ;AF5BA;AACA;AACE;AACA;AACA;AACA;AACF,iJAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-MEL5UMNW.cjs","sourcesContent":[null,"declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"]}
@@ -324,15 +324,12 @@ function autobind(self) {
324
324
  } while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
325
325
  }
326
326
 
327
- // src/ThreadDB.ts
328
- import { batch, MutableSignal as MutableSignal2, SortedList } from "@liveblocks/core";
329
-
330
327
  // src/lib/querying.ts
331
328
  import { isStartsWithOperator } from "@liveblocks/core";
332
329
  function makeThreadsFilter(query) {
333
- return (thread) => matchesQuery(thread, query) && matchesMetadata(thread, query);
330
+ return (thread) => matchesThreadsQuery(thread, query) && matchesMetadata(thread, query);
334
331
  }
335
- function matchesQuery(thread, q) {
332
+ function matchesThreadsQuery(thread, q) {
336
333
  return q.resolved === void 0 || thread.resolved === q.resolved;
337
334
  }
338
335
  function matchesMetadata(thread, q) {
@@ -354,8 +351,15 @@ function matchesOperator(value, op) {
354
351
  return value === op;
355
352
  }
356
353
  }
354
+ function makeInboxNotificationsFilter(query) {
355
+ return (inboxNotification) => matchesInboxNotificationsQuery(inboxNotification, query);
356
+ }
357
+ function matchesInboxNotificationsQuery(inboxNotification, q) {
358
+ return (q.roomId === void 0 || q.roomId === inboxNotification.roomId) && (q.kind === void 0 || q.kind === inboxNotification.kind);
359
+ }
357
360
 
358
361
  // src/ThreadDB.ts
362
+ import { batch, MutableSignal as MutableSignal2, SortedList } from "@liveblocks/core";
359
363
  function sanitizeThread(thread) {
360
364
  if (thread.deletedAt) {
361
365
  if (thread.comments.length > 0) {
@@ -1087,10 +1091,17 @@ var UmbrellaStore = class {
1087
1091
  if (result.isLoading || result.error) {
1088
1092
  return result;
1089
1093
  }
1094
+ const crit = [];
1095
+ if (query !== void 0) {
1096
+ crit.push(makeInboxNotificationsFilter(query));
1097
+ }
1098
+ const inboxNotifications = this.outputs.notifications.get().sortedNotifications.filter(
1099
+ (inboxNotification) => crit.every((pred) => pred(inboxNotification))
1100
+ );
1090
1101
  const page = result.data;
1091
1102
  return {
1092
1103
  isLoading: false,
1093
- inboxNotifications: this.outputs.notifications.get().sortedNotifications,
1104
+ inboxNotifications,
1094
1105
  hasFetchedAll: page.hasFetchedAll,
1095
1106
  isFetchingMore: page.isFetchingMore,
1096
1107
  fetchMoreError: page.fetchMoreError,
@@ -2128,7 +2139,7 @@ function makeLiveblocksContextBundle(client) {
2128
2139
  const bundle = {
2129
2140
  LiveblocksProvider: LiveblocksProvider2,
2130
2141
  useInboxNotifications: (options) => useInboxNotifications_withClient(client, identity2, shallow3, options),
2131
- useUnreadInboxNotificationsCount: () => useUnreadInboxNotificationsCount_withClient(client),
2142
+ useUnreadInboxNotificationsCount: (options) => useUnreadInboxNotificationsCount_withClient(client, options),
2132
2143
  useMarkInboxNotificationAsRead: useMarkInboxNotificationAsRead2,
2133
2144
  useMarkAllInboxNotificationsAsRead: useMarkAllInboxNotificationsAsRead2,
2134
2145
  useDeleteInboxNotification: useDeleteInboxNotification2,
@@ -2147,7 +2158,7 @@ function makeLiveblocksContextBundle(client) {
2147
2158
  suspense: {
2148
2159
  LiveblocksProvider: LiveblocksProvider2,
2149
2160
  useInboxNotifications: (options) => useInboxNotificationsSuspense_withClient(client, options),
2150
- useUnreadInboxNotificationsCount: () => useUnreadInboxNotificationsCountSuspense_withClient(client),
2161
+ useUnreadInboxNotificationsCount: (options) => useUnreadInboxNotificationsCountSuspense_withClient(client, options),
2151
2162
  useMarkInboxNotificationAsRead: useMarkInboxNotificationAsRead2,
2152
2163
  useMarkAllInboxNotificationsAsRead: useMarkAllInboxNotificationsAsRead2,
2153
2164
  useDeleteInboxNotification: useDeleteInboxNotification2,
@@ -2211,21 +2222,22 @@ function useInboxNotificationsSuspense_withClient(client, options) {
2211
2222
  assert(!result.isLoading, "Did not expect loading");
2212
2223
  return result;
2213
2224
  }
2214
- function useUnreadInboxNotificationsCount_withClient(client) {
2225
+ function useUnreadInboxNotificationsCount_withClient(client, options) {
2215
2226
  return useInboxNotifications_withClient(
2216
2227
  client,
2217
2228
  selectorFor_useUnreadInboxNotificationsCount,
2218
- shallow3
2229
+ shallow3,
2230
+ options
2219
2231
  );
2220
2232
  }
2221
- function useUnreadInboxNotificationsCountSuspense_withClient(client) {
2233
+ function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
2222
2234
  ensureNotServerSide();
2223
2235
  const store = getLiveblocksExtrasForClient(client).store;
2224
- const queryKey = makeInboxNotificationsQueryKey(void 0);
2236
+ const queryKey = makeInboxNotificationsQueryKey(options?.query);
2225
2237
  use(
2226
2238
  store.outputs.loadingNotifications.getOrCreate(queryKey).waitUntilLoaded()
2227
2239
  );
2228
- const result = useUnreadInboxNotificationsCount_withClient(client);
2240
+ const result = useUnreadInboxNotificationsCount_withClient(client, options);
2229
2241
  assert(!result.isLoading, "Did not expect loading");
2230
2242
  assert(!result.error, "Did not expect error");
2231
2243
  return result;
@@ -2947,11 +2959,14 @@ function useDeleteAllInboxNotifications() {
2947
2959
  function useDeleteInboxNotification() {
2948
2960
  return useDeleteInboxNotification_withClient(useClient());
2949
2961
  }
2950
- function useUnreadInboxNotificationsCount() {
2951
- return useUnreadInboxNotificationsCount_withClient(useClient());
2962
+ function useUnreadInboxNotificationsCount(options) {
2963
+ return useUnreadInboxNotificationsCount_withClient(useClient(), options);
2952
2964
  }
2953
- function useUnreadInboxNotificationsCountSuspense() {
2954
- return useUnreadInboxNotificationsCountSuspense_withClient(useClient());
2965
+ function useUnreadInboxNotificationsCountSuspense(options) {
2966
+ return useUnreadInboxNotificationsCountSuspense_withClient(
2967
+ useClient(),
2968
+ options
2969
+ );
2955
2970
  }
2956
2971
  function useNotificationSettings() {
2957
2972
  return useNotificationSettings_withClient(useClient());
@@ -4783,4 +4798,4 @@ export {
4783
4798
  _useStorageRoot,
4784
4799
  _useUpdateMyPresence
4785
4800
  };
4786
- //# sourceMappingURL=chunk-WGUV4Z4E.js.map
4801
+ //# sourceMappingURL=chunk-OKYUUXNY.js.map