@carlonicora/nextjs-jsonapi 4.2.2 → 5.0.0

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.
Files changed (42) hide show
  1. package/dist/{BlockNoteEditor-FROUKBVK.mjs → BlockNoteEditor-7BKKGFH3.mjs} +2 -2
  2. package/dist/{BlockNoteEditor-SWO3X5CC.js → BlockNoteEditor-E6HJD4HB.js} +9 -9
  3. package/dist/{BlockNoteEditor-SWO3X5CC.js.map → BlockNoteEditor-E6HJD4HB.js.map} +1 -1
  4. package/dist/billing/index.js +371 -371
  5. package/dist/billing/index.mjs +1 -1
  6. package/dist/{chunk-AICMLKWN.mjs → chunk-MELHUPVN.mjs} +34 -13
  7. package/dist/chunk-MELHUPVN.mjs.map +1 -0
  8. package/dist/{chunk-GYW7LLBQ.js → chunk-TPGXNPGY.js} +208 -187
  9. package/dist/chunk-TPGXNPGY.js.map +1 -0
  10. package/dist/client/index.js +2 -2
  11. package/dist/client/index.mjs +1 -1
  12. package/dist/components/index.js +2 -2
  13. package/dist/components/index.mjs +1 -1
  14. package/dist/contexts/index.js +2 -2
  15. package/dist/contexts/index.mjs +1 -1
  16. package/dist/features/analytics/index.js +88 -88
  17. package/dist/features/analytics/index.mjs +1 -1
  18. package/dist/features/help/index.js +31 -31
  19. package/dist/features/help/index.mjs +1 -1
  20. package/dist/features/tokenusage/index.js +75 -75
  21. package/dist/features/tokenusage/index.mjs +1 -1
  22. package/dist/next-config/index.d.mts +0 -1
  23. package/dist/next-config/index.d.ts +0 -1
  24. package/dist/next-config/index.js +0 -6
  25. package/dist/next-config/index.js.map +1 -1
  26. package/dist/next-config/index.mjs +0 -6
  27. package/dist/next-config/index.mjs.map +1 -1
  28. package/package.json +4 -2
  29. package/pwa/offline.template.html +138 -0
  30. package/pwa/sw.js +175 -0
  31. package/src/components/tables/ContentListTable.tsx +6 -0
  32. package/src/features/notification/components/notifications/PushNotificationProvider.tsx +5 -1
  33. package/src/features/notification/components/notifications/__tests__/PushNotificationProvider.spec.tsx +51 -0
  34. package/src/hooks/__tests__/usePushNotifications.spec.tsx +87 -34
  35. package/src/hooks/usePushNotifications.ts +42 -18
  36. package/src/next-config/__tests__/createNextConfig.spec.ts +7 -5
  37. package/src/next-config/index.ts +1 -8
  38. package/src/pwa/__tests__/offline.template.spec.ts +246 -0
  39. package/src/pwa/__tests__/sw.spec.ts +309 -0
  40. package/dist/chunk-AICMLKWN.mjs.map +0 -1
  41. package/dist/chunk-GYW7LLBQ.js.map +0 -1
  42. /package/dist/{BlockNoteEditor-FROUKBVK.mjs.map → BlockNoteEditor-7BKKGFH3.mjs.map} +0 -0
@@ -65,7 +65,7 @@ import {
65
65
  useCurrentUserContext,
66
66
  useDataListRetriever,
67
67
  usePageUrlGenerator
68
- } from "../chunk-AICMLKWN.mjs";
68
+ } from "../chunk-MELHUPVN.mjs";
69
69
  import {
70
70
  getStripePublishableKey
71
71
  } from "../chunk-MQDR6MEE.mjs";
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  ACTION_TYPES,
3
3
  RbacService,
4
- getAppUrl,
5
4
  getPublicApiUrl,
6
5
  getReferralConfig,
7
6
  getRegistrationMode,
@@ -10684,7 +10683,7 @@ import { useRef as useRef18 } from "react";
10684
10683
  import dynamic from "next/dynamic";
10685
10684
  import React18 from "react";
10686
10685
  import { jsx as jsx90 } from "react/jsx-runtime";
10687
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-FROUKBVK.mjs"), {
10686
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-7BKKGFH3.mjs"), {
10688
10687
  ssr: false
10689
10688
  });
10690
10689
  var BlockNoteEditorContainer = React18.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -15185,16 +15184,16 @@ function urlBase64ToUint8Array(base64String) {
15185
15184
  return outputArray;
15186
15185
  }
15187
15186
  __name(urlBase64ToUint8Array, "urlBase64ToUint8Array");
15188
- function usePushNotifications() {
15189
- const { currentUser, hasRole } = useCurrentUserContext();
15187
+ function usePushNotifications(params) {
15188
+ const { currentUser, canSubscribe } = params;
15189
+ const userId = currentUser?.id;
15190
15190
  useEffect37(() => {
15191
+ if (!userId || !canSubscribe) return;
15191
15192
  const register = /* @__PURE__ */ __name(async () => {
15192
15193
  if ("serviceWorker" in navigator && "PushManager" in window) {
15193
15194
  try {
15194
- const sessionKey = `push_registered_${currentUser?.id}`;
15195
- const lastRegisteredSubscription = sessionStorage.getItem(sessionKey);
15196
- const swUrl = ENV.IS_PRODUCTION ? `${getAppUrl()}/sw.js` : `${getAppUrl()}/sw-dev.js`;
15197
- const registration = await navigator.serviceWorker.register(swUrl);
15195
+ const sessionKey = `push_registered_${userId}`;
15196
+ const registration = await navigator.serviceWorker.register("/sw.js", { updateViaCache: "none" });
15198
15197
  let permission = Notification.permission;
15199
15198
  if (permission === "default") {
15200
15199
  permission = await Notification.requestPermission();
@@ -15221,7 +15220,7 @@ function usePushNotifications() {
15221
15220
  keys: subscription.toJSON().keys
15222
15221
  };
15223
15222
  const subscriptionHash = btoa(JSON.stringify(plainSubscription));
15224
- if (lastRegisteredSubscription !== subscriptionHash) {
15223
+ if (sessionStorage.getItem(sessionKey) !== subscriptionHash) {
15225
15224
  await PushService.register({ data: plainSubscription });
15226
15225
  sessionStorage.setItem(sessionKey, subscriptionHash);
15227
15226
  }
@@ -15230,8 +15229,23 @@ function usePushNotifications() {
15230
15229
  }
15231
15230
  }
15232
15231
  }, "register");
15233
- if (currentUser && !hasRole(getRoleId().Administrator)) register();
15234
- }, [currentUser]);
15232
+ register();
15233
+ }, [userId, canSubscribe]);
15234
+ useEffect37(() => {
15235
+ if (!userId || !canSubscribe) return;
15236
+ if (!("serviceWorker" in navigator)) return;
15237
+ const sessionKey = `push_registered_${userId}`;
15238
+ const onMessage = /* @__PURE__ */ __name((event) => {
15239
+ if (event.data?.type !== "PUSH_RESUBSCRIBED" || !event.data.subscription) return;
15240
+ const subscription = event.data.subscription;
15241
+ const subscriptionHash = btoa(JSON.stringify(subscription));
15242
+ if (sessionStorage.getItem(sessionKey) === subscriptionHash) return;
15243
+ void PushService.register({ data: subscription }).then(() => sessionStorage.setItem(sessionKey, subscriptionHash)).catch((error) => console.error("Error re-registering rotated push subscription:", error));
15244
+ }, "onMessage");
15245
+ const container = navigator.serviceWorker;
15246
+ container.addEventListener("message", onMessage);
15247
+ return () => container.removeEventListener("message", onMessage);
15248
+ }, [userId, canSubscribe]);
15235
15249
  }
15236
15250
  __name(usePushNotifications, "usePushNotifications");
15237
15251
 
@@ -18534,6 +18548,12 @@ var ContentListTable = memo(/* @__PURE__ */ __name(function ContentListTable2(pr
18534
18548
  data: tableData,
18535
18549
  columns: tableColumns,
18536
18550
  getCoreRowModel: getCoreRowModel(),
18551
+ // Pagination is server-side (the data retriever), never TanStack's. Left on,
18552
+ // every core-row-model rebuild queues resetPageIndex -> setState -> re-render,
18553
+ // and the table generators rebuild their columns on every render, so it never
18554
+ // settles: a render loop that starves other updates (the current user never
18555
+ // committed, leaving the sidebar empty).
18556
+ autoResetPageIndex: false,
18537
18557
  ...props.renderExpandedRow && {
18538
18558
  getExpandedRowModel: getExpandedRowModel(),
18539
18559
  // Key rows by record id so an expansion stays with its record when a search or filter reorders the rows.
@@ -25206,7 +25226,8 @@ __name(NotificationModal, "NotificationModal");
25206
25226
  // src/features/notification/components/notifications/PushNotificationProvider.tsx
25207
25227
  import { Fragment as Fragment59, jsx as jsx284 } from "react/jsx-runtime";
25208
25228
  function PushNotificationProvider({ children }) {
25209
- usePushNotifications();
25229
+ const { currentUser, hasRole } = useCurrentUserContext();
25230
+ usePushNotifications({ currentUser: currentUser ?? void 0, canSubscribe: !hasRole(getRoleId().Administrator) });
25210
25231
  return /* @__PURE__ */ jsx284(Fragment59, { children });
25211
25232
  }
25212
25233
  __name(PushNotificationProvider, "PushNotificationProvider");
@@ -28282,4 +28303,4 @@ export {
28282
28303
  useOAuthClients,
28283
28304
  useOAuthClient
28284
28305
  };
28285
- //# sourceMappingURL=chunk-AICMLKWN.mjs.map
28306
+ //# sourceMappingURL=chunk-MELHUPVN.mjs.map