@squide/firefly 16.2.0 → 16.2.2

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 (75) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/AppRouter.js +0 -9
  3. package/dist/AppRouter.js.map +1 -1
  4. package/dist/AppRouterContext.js +0 -3
  5. package/dist/AppRouterContext.js.map +1 -1
  6. package/dist/AppRouterReducer.js +0 -6
  7. package/dist/AppRouterReducer.js.map +1 -1
  8. package/dist/AppRouterStore.js +0 -2
  9. package/dist/AppRouterStore.js.map +1 -1
  10. package/dist/FireflyPlugin.js +0 -2
  11. package/dist/FireflyPlugin.js.map +1 -1
  12. package/dist/FireflyProvider.js +0 -3
  13. package/dist/FireflyProvider.js.map +1 -1
  14. package/dist/FireflyRuntime.js +0 -6
  15. package/dist/FireflyRuntime.js.map +1 -1
  16. package/dist/GlobalDataQueriesError.js +0 -2
  17. package/dist/GlobalDataQueriesError.js.map +1 -1
  18. package/dist/RootRoute.js +0 -6
  19. package/dist/RootRoute.js.map +1 -1
  20. package/dist/honeycomb/activeSpan.js +0 -4
  21. package/dist/honeycomb/activeSpan.js.map +1 -1
  22. package/dist/honeycomb/createTraceContextId.js +0 -2
  23. package/dist/honeycomb/createTraceContextId.js.map +1 -1
  24. package/dist/honeycomb/initializeHoneycomb.js +0 -2
  25. package/dist/honeycomb/initializeHoneycomb.js.map +1 -1
  26. package/dist/honeycomb/registerHoneycombInstrumentation.js +0 -10
  27. package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
  28. package/dist/honeycomb/tracer.js +0 -2
  29. package/dist/honeycomb/tracer.js.map +1 -1
  30. package/dist/honeycomb/utils.js +0 -3
  31. package/dist/honeycomb/utils.js.map +1 -1
  32. package/dist/index.js +4 -11
  33. package/dist/index.js.map +1 -1
  34. package/dist/initializeFirefly.js +0 -8
  35. package/dist/initializeFirefly.js.map +1 -1
  36. package/dist/internal.js +5 -13
  37. package/dist/internal.js.map +1 -1
  38. package/dist/useAppRouterStore.js +0 -2
  39. package/dist/useAppRouterStore.js.map +1 -1
  40. package/dist/useCanFetchProtectedData.js +0 -2
  41. package/dist/useCanFetchProtectedData.js.map +1 -1
  42. package/dist/useCanFetchPublicData.js +0 -2
  43. package/dist/useCanFetchPublicData.js.map +1 -1
  44. package/dist/useCanRegisterDeferredRegistrations.js +0 -2
  45. package/dist/useCanRegisterDeferredRegistrations.js.map +1 -1
  46. package/dist/useCanUpdateDeferredRegistrations.d.ts +1 -1
  47. package/dist/useCanUpdateDeferredRegistrations.js +15 -6
  48. package/dist/useCanUpdateDeferredRegistrations.js.map +1 -1
  49. package/dist/useDeferredRegistrations.js +12 -8
  50. package/dist/useDeferredRegistrations.js.map +1 -1
  51. package/dist/useExecuteOnce.js +0 -2
  52. package/dist/useExecuteOnce.js.map +1 -1
  53. package/dist/useIsActiveRouteProtected.js +0 -3
  54. package/dist/useIsActiveRouteProtected.js.map +1 -1
  55. package/dist/useIsBootstrapping.js +0 -2
  56. package/dist/useIsBootstrapping.js.map +1 -1
  57. package/dist/useNavigationItems.js +0 -3
  58. package/dist/useNavigationItems.js.map +1 -1
  59. package/dist/useProtectedDataHandler.js +0 -3
  60. package/dist/useProtectedDataHandler.js.map +1 -1
  61. package/dist/useProtectedDataQueries.js +0 -8
  62. package/dist/useProtectedDataQueries.js.map +1 -1
  63. package/dist/usePublicDataHandler.js +0 -3
  64. package/dist/usePublicDataHandler.js.map +1 -1
  65. package/dist/usePublicDataQueries.js +0 -8
  66. package/dist/usePublicDataQueries.js.map +1 -1
  67. package/dist/useRegisterDeferredRegistrations.js +0 -3
  68. package/dist/useRegisterDeferredRegistrations.js.map +1 -1
  69. package/dist/useStrictRegistrationMode.js +0 -3
  70. package/dist/useStrictRegistrationMode.js.map +1 -1
  71. package/dist/useUpdateDeferredRegistrations.js +0 -4
  72. package/dist/useUpdateDeferredRegistrations.js.map +1 -1
  73. package/package.json +24 -23
  74. package/src/useCanUpdateDeferredRegistrations.ts +20 -18
  75. package/src/useDeferredRegistrations.ts +14 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useExecuteOnce.js","sources":["../src/useExecuteOnce.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\n\n// Not using useEffect or useLayoutEffect because this utility hook is often used to dispatch events\n// and it messed with the events dispatch order.\nexport function useExecuteOnce(fct: () => boolean, inline: boolean = false) {\n const triggered = useRef(false);\n\n const onceFct = useCallback(() => {\n if (!triggered.current) {\n const result = fct();\n\n if (result) {\n triggered.current = true;\n }\n }\n }, [fct]);\n\n if (inline) {\n // eslint-disable-next-line react-hooks/refs\n onceFct();\n }\n\n return onceFct;\n}\n"],"names":["useCallback","useRef","useExecuteOnce","fct","inline","triggered","onceFct","result"],"mappings":";;;;;AAA4C;AAE5C,oGAAoG;AACpG,gDAAgD;AACzC,SAASE,eAAeC,GAAkB,EAAEC,SAAkB,KAAK;IACtE,MAAMC,YAAYJ,MAAMA,CAAC;IAEzB,MAAMK,UAAUN,WAAWA,CAAC;QACxB,IAAI,CAACK,UAAU,OAAO,EAAE;YACpB,MAAME,SAASJ;YAEf,IAAII,QAAQ;gBACRF,UAAU,OAAO,GAAG;YACxB;QACJ;IACJ,GAAG;QAACF;KAAI;IAER,IAAIC,QAAQ;QACR,4CAA4C;QAC5CE;IACJ;IAEA,OAAOA;AACX"}
1
+ {"version":3,"file":"useExecuteOnce.js","sources":["../src/useExecuteOnce.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\n\n// Not using useEffect or useLayoutEffect because this utility hook is often used to dispatch events\n// and it messed with the events dispatch order.\nexport function useExecuteOnce(fct: () => boolean, inline: boolean = false) {\n const triggered = useRef(false);\n\n const onceFct = useCallback(() => {\n if (!triggered.current) {\n const result = fct();\n\n if (result) {\n triggered.current = true;\n }\n }\n }, [fct]);\n\n if (inline) {\n // eslint-disable-next-line react-hooks/refs\n onceFct();\n }\n\n return onceFct;\n}\n"],"names":["useCallback","useRef","useExecuteOnce","fct","inline","triggered","onceFct","result"],"mappings":";;;AAA4C;AAE5C,oGAAoG;AACpG,gDAAgD;AACzC,SAASE,cAAcA,CAACC,GAAkB,EAAEC,SAAkB,KAAK;IACtE,MAAMC,YAAYJ,MAAMA,CAAC;IAEzB,MAAMK,UAAUN,WAAWA,CAAC;QACxB,IAAI,CAACK,UAAU,OAAO,EAAE;YACpB,MAAME,SAASJ;YAEf,IAAII,QAAQ;gBACRF,UAAU,OAAO,GAAG;YACxB;QACJ;IACJ,GAAG;QAACF;KAAI;IAER,IAAIC,QAAQ;QACR,4CAA4C;QAC5CE;IACJ;IAEA,OAAOA;AACX"}
@@ -1,11 +1,8 @@
1
1
  import { useIsRouteProtected, useRouteMatch } from "@squide/react-router";
2
2
  import { useLocation } from "react-router";
3
3
 
4
- ;// CONCATENATED MODULE: external "@squide/react-router"
5
4
 
6
- ;// CONCATENATED MODULE: external "react-router"
7
5
 
8
- ;// CONCATENATED MODULE: ./src/useIsActiveRouteProtected.ts
9
6
 
10
7
 
11
8
  function useIsActiveRouteProtected(areModulesReady, options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"useIsActiveRouteProtected.js","sources":["../src/useIsActiveRouteProtected.ts"],"sourcesContent":["import { useIsRouteProtected, useRouteMatch } from \"@squide/react-router\";\nimport { useLocation } from \"react-router\";\n\nexport interface UseIsActiveRouteProtectedOptions {\n throwWhenThereIsNoMatch?: boolean;\n}\n\nexport function useIsActiveRouteProtected(areModulesReady: boolean, options: UseIsActiveRouteProtectedOptions = {}) {\n const {\n throwWhenThereIsNoMatch = true\n } = options;\n\n // Using this hook instead of window.location to retrieve the current location because it triggers a re-render everytime the browser location change.\n const location = useLocation();\n\n // Only throw when there's no match if the modules are ready, otherwise it's expected that no route will be found since they are not all registered yet.\n const activeRoute = useRouteMatch(location, { throwWhenThereIsNoMatch: throwWhenThereIsNoMatch && areModulesReady });\n\n return useIsRouteProtected(activeRoute);\n}\n"],"names":["useIsRouteProtected","useRouteMatch","useLocation","useIsActiveRouteProtected","areModulesReady","options","throwWhenThereIsNoMatch","location","activeRoute"],"mappings":";;;;;;;;AAA0E;AAC/B;AAMpC,SAASG,0BAA0BC,eAAwB,EAAEC,UAA4C,CAAC,CAAC;IAC9G,MAAM,EACFC,0BAA0B,IAAI,EACjC,GAAGD;IAEJ,qJAAqJ;IACrJ,MAAME,WAAWL,WAAWA;IAE5B,wJAAwJ;IACxJ,MAAMM,cAAcP,aAAaA,CAACM,UAAU;QAAE,yBAAyBD,2BAA2BF;IAAgB;IAElH,OAAOJ,mBAAmBA,CAACQ;AAC/B"}
1
+ {"version":3,"file":"useIsActiveRouteProtected.js","sources":["../src/useIsActiveRouteProtected.ts"],"sourcesContent":["import { useIsRouteProtected, useRouteMatch } from \"@squide/react-router\";\nimport { useLocation } from \"react-router\";\n\nexport interface UseIsActiveRouteProtectedOptions {\n throwWhenThereIsNoMatch?: boolean;\n}\n\nexport function useIsActiveRouteProtected(areModulesReady: boolean, options: UseIsActiveRouteProtectedOptions = {}) {\n const {\n throwWhenThereIsNoMatch = true\n } = options;\n\n // Using this hook instead of window.location to retrieve the current location because it triggers a re-render everytime the browser location change.\n const location = useLocation();\n\n // Only throw when there's no match if the modules are ready, otherwise it's expected that no route will be found since they are not all registered yet.\n const activeRoute = useRouteMatch(location, { throwWhenThereIsNoMatch: throwWhenThereIsNoMatch && areModulesReady });\n\n return useIsRouteProtected(activeRoute);\n}\n"],"names":["useIsRouteProtected","useRouteMatch","useLocation","useIsActiveRouteProtected","areModulesReady","options","throwWhenThereIsNoMatch","location","activeRoute"],"mappings":";;;;;AAA0E;AAC/B;AAMpC,SAASG,yBAAyBA,CAACC,eAAwB,EAAEC,UAA4C,CAAC,CAAC;IAC9G,MAAM,EACFC,0BAA0B,IAAI,EACjC,GAAGD;IAEJ,qJAAqJ;IACrJ,MAAME,WAAWL,WAAWA;IAE5B,wJAAwJ;IACxJ,MAAMM,cAAcP,aAAaA,CAACM,UAAU;QAAE,yBAAyBD,2BAA2BF;IAAgB;IAElH,OAAOJ,mBAAmBA,CAACQ;AAC/B"}
@@ -1,8 +1,6 @@
1
1
  import { useAppRouterState } from "./AppRouterContext.js";
2
2
 
3
- ;// CONCATENATED MODULE: external "./AppRouterContext.js"
4
3
 
5
- ;// CONCATENATED MODULE: ./src/useIsBootstrapping.ts
6
4
 
7
5
  function useIsBootstrapping() {
8
6
  const state = useAppRouterState();
@@ -1 +1 @@
1
- {"version":3,"file":"useIsBootstrapping.js","sources":["../src/useIsBootstrapping.ts"],"sourcesContent":["import { useAppRouterState } from \"./AppRouterContext.ts\";\nimport type { AppRouterState } from \"./AppRouterReducer.ts\";\n\nexport function useIsBootstrapping() {\n const state = useAppRouterState();\n\n return isBootstrapping(state);\n}\n\nexport function isBootstrapping(state: AppRouterState) {\n const {\n waitForMsw,\n waitForPublicData,\n waitForProtectedData,\n areModulesReady,\n isMswReady,\n isPublicDataReady,\n isProtectedDataReady,\n activeRouteVisibility,\n isUnauthorized\n } = state;\n\n const isAppReady = (\n !isUnauthorized\n // Wait until the modules has been registered and the deferred registrations has been registered if any.\n && areModulesReady\n // Not required but can sometimes prevent a re-render when the state value is somehow updated after the initial data is ready.\n && (!waitForMsw || isMswReady)\n // Wait for the initial data to be ready.\n && (!waitForPublicData || isPublicDataReady)\n && (!waitForProtectedData || activeRouteVisibility === \"public\" || isProtectedDataReady)\n );\n\n // When an API request returns a 401, the bootstrapping should be bypassed to render the login page.\n const flush = (\n // Only applicable when there's a unauthorized request while fetching the initial data.\n isUnauthorized\n // Not required but can sometimes prevent a re-render when the state value is somehow updated after the public data is ready.\n && (!waitForMsw || isMswReady)\n // If the application is loading public data, we want to wait for this data to be ready to prevent a re-render.\n && (!waitForPublicData || isPublicDataReady)\n );\n\n return !isAppReady && !flush;\n}\n"],"names":["useAppRouterState","useIsBootstrapping","state","isBootstrapping","waitForMsw","waitForPublicData","waitForProtectedData","areModulesReady","isMswReady","isPublicDataReady","isProtectedDataReady","activeRouteVisibility","isUnauthorized","isAppReady","flush"],"mappings":";;;;;AAA0D;AAGnD,SAASC;IACZ,MAAMC,QAAQF,iBAAiBA;IAE/B,OAAOG,gBAAgBD;AAC3B;AAEO,SAASC,gBAAgBD,KAAqB;IACjD,MAAM,EACFE,UAAU,EACVC,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,UAAU,EACVC,iBAAiB,EACjBC,oBAAoB,EACpBC,qBAAqB,EACrBC,cAAc,EACjB,GAAGV;IAEJ,MAAMW,aACF,CAACD,kBAEEL,mBAEC,EAACH,cAAcI,UAAS,KAExB,EAACH,qBAAqBI,iBAAgB,KACtC,EAACH,wBAAwBK,0BAA0B,YAAYD,oBAAmB;IAG1F,oGAAoG;IACpG,MAAMI,QACF,uFAAuF;IACvFF,kBAEI,EAACR,cAAcI,UAAS,KAExB,EAACH,qBAAqBI,iBAAgB;IAG9C,OAAO,CAACI,cAAc,CAACC;AAC3B"}
1
+ {"version":3,"file":"useIsBootstrapping.js","sources":["../src/useIsBootstrapping.ts"],"sourcesContent":["import { useAppRouterState } from \"./AppRouterContext.ts\";\nimport type { AppRouterState } from \"./AppRouterReducer.ts\";\n\nexport function useIsBootstrapping() {\n const state = useAppRouterState();\n\n return isBootstrapping(state);\n}\n\nexport function isBootstrapping(state: AppRouterState) {\n const {\n waitForMsw,\n waitForPublicData,\n waitForProtectedData,\n areModulesReady,\n isMswReady,\n isPublicDataReady,\n isProtectedDataReady,\n activeRouteVisibility,\n isUnauthorized\n } = state;\n\n const isAppReady = (\n !isUnauthorized\n // Wait until the modules has been registered and the deferred registrations has been registered if any.\n && areModulesReady\n // Not required but can sometimes prevent a re-render when the state value is somehow updated after the initial data is ready.\n && (!waitForMsw || isMswReady)\n // Wait for the initial data to be ready.\n && (!waitForPublicData || isPublicDataReady)\n && (!waitForProtectedData || activeRouteVisibility === \"public\" || isProtectedDataReady)\n );\n\n // When an API request returns a 401, the bootstrapping should be bypassed to render the login page.\n const flush = (\n // Only applicable when there's a unauthorized request while fetching the initial data.\n isUnauthorized\n // Not required but can sometimes prevent a re-render when the state value is somehow updated after the public data is ready.\n && (!waitForMsw || isMswReady)\n // If the application is loading public data, we want to wait for this data to be ready to prevent a re-render.\n && (!waitForPublicData || isPublicDataReady)\n );\n\n return !isAppReady && !flush;\n}\n"],"names":["useAppRouterState","useIsBootstrapping","state","isBootstrapping","waitForMsw","waitForPublicData","waitForProtectedData","areModulesReady","isMswReady","isPublicDataReady","isProtectedDataReady","activeRouteVisibility","isUnauthorized","isAppReady","flush"],"mappings":";;;AAA0D;AAGnD,SAASC,kBAAkBA;IAC9B,MAAMC,QAAQF,iBAAiBA;IAE/B,OAAOG,eAAeA,CAACD;AAC3B;AAEO,SAASC,eAAeA,CAACD,KAAqB;IACjD,MAAM,EACFE,UAAU,EACVC,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,UAAU,EACVC,iBAAiB,EACjBC,oBAAoB,EACpBC,qBAAqB,EACrBC,cAAc,EACjB,GAAGV;IAEJ,MAAMW,aACF,CAACD,kBAEEL,mBAEC,EAACH,cAAcI,UAAS,KAExB,EAACH,qBAAqBI,iBAAgB,KACtC,EAACH,wBAAwBK,0BAA0B,YAAYD,oBAAmB;IAG1F,oGAAoG;IACpG,MAAMI,QACF,uFAAuF;IACvFF,kBAEI,EAACR,cAAcI,UAAS,KAExB,EAACH,qBAAqBI,iBAAgB;IAG9C,OAAO,CAACI,cAAc,CAACC;AAC3B"}
@@ -1,11 +1,8 @@
1
1
  import { useRuntimeNavigationItems } from "@squide/react-router";
2
2
  import { useAppRouterState } from "./AppRouterContext.js";
3
3
 
4
- ;// CONCATENATED MODULE: external "@squide/react-router"
5
4
 
6
- ;// CONCATENATED MODULE: external "./AppRouterContext.js"
7
5
 
8
- ;// CONCATENATED MODULE: ./src/useNavigationItems.ts
9
6
 
10
7
 
11
8
  function useNavigationItems(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigationItems.js","sources":["../src/useNavigationItems.ts"],"sourcesContent":["import { useRuntimeNavigationItems, type UseRuntimeNavigationItemsOptions } from \"@squide/react-router\";\nimport { useAppRouterState } from \"./AppRouterContext.ts\";\n\nexport type UseNavigationItemsOptions = UseRuntimeNavigationItemsOptions;\n\nexport function useNavigationItems(options?: UseNavigationItemsOptions) {\n // This is not the most sophisticated strategy but it seems to be good enough for now.\n // The idea is that when deferred registrations are used by the consumer applications, the deferred registrations could\n // be updated when the global data is updated. If the deferred registrations are updated, it means that the registered\n // navigation items might have been updated and a re-render must happens to display the new navigation items.\n // Since the \"deferredRegistrationsUpdatedAt\" state value of the AppRouterReducer is updated everytime the deferred registrations\n // are updated, subscribing to the state with useAppRouterState ensure that the navigation items will be re-rendered.\n // A more sophisticated strategy could be implemented later on if needed, something involving a subscription to the \"runtime\" changes, or\n // even introducing new module states.\n useAppRouterState();\n\n return useRuntimeNavigationItems(options);\n}\n"],"names":["useRuntimeNavigationItems","useAppRouterState","useNavigationItems","options"],"mappings":";;;;;;;;AAAwG;AAC9C;AAInD,SAASE,mBAAmBC,OAAmC;IAClE,sFAAsF;IACtF,uHAAuH;IACvH,sHAAsH;IACtH,6GAA6G;IAC7G,iIAAiI;IACjI,qHAAqH;IACrH,yIAAyI;IACzI,sCAAsC;IACtCF,iBAAiBA;IAEjB,OAAOD,yBAAyBA,CAACG;AACrC"}
1
+ {"version":3,"file":"useNavigationItems.js","sources":["../src/useNavigationItems.ts"],"sourcesContent":["import { useRuntimeNavigationItems, type UseRuntimeNavigationItemsOptions } from \"@squide/react-router\";\nimport { useAppRouterState } from \"./AppRouterContext.ts\";\n\nexport type UseNavigationItemsOptions = UseRuntimeNavigationItemsOptions;\n\nexport function useNavigationItems(options?: UseNavigationItemsOptions) {\n // This is not the most sophisticated strategy but it seems to be good enough for now.\n // The idea is that when deferred registrations are used by the consumer applications, the deferred registrations could\n // be updated when the global data is updated. If the deferred registrations are updated, it means that the registered\n // navigation items might have been updated and a re-render must happens to display the new navigation items.\n // Since the \"deferredRegistrationsUpdatedAt\" state value of the AppRouterReducer is updated everytime the deferred registrations\n // are updated, subscribing to the state with useAppRouterState ensure that the navigation items will be re-rendered.\n // A more sophisticated strategy could be implemented later on if needed, something involving a subscription to the \"runtime\" changes, or\n // even introducing new module states.\n useAppRouterState();\n\n return useRuntimeNavigationItems(options);\n}\n"],"names":["useRuntimeNavigationItems","useAppRouterState","useNavigationItems","options"],"mappings":";;;;;AAAwG;AAC9C;AAInD,SAASE,kBAAkBA,CAACC,OAAmC;IAClE,sFAAsF;IACtF,uHAAuH;IACvH,sHAAsH;IACtH,6GAA6G;IAC7G,iIAAiI;IACjI,qHAAqH;IACrH,yIAAyI;IACzI,sCAAsC;IACtCF,iBAAiBA;IAEjB,OAAOD,yBAAyBA,CAACG;AACrC"}
@@ -1,11 +1,8 @@
1
1
  import { useEffect } from "react";
2
2
  import { useCanFetchProtectedData } from "./useCanFetchProtectedData.js";
3
3
 
4
- ;// CONCATENATED MODULE: external "react"
5
4
 
6
- ;// CONCATENATED MODULE: external "./useCanFetchProtectedData.js"
7
5
 
8
- ;// CONCATENATED MODULE: ./src/useProtectedDataHandler.ts
9
6
 
10
7
 
11
8
  function useProtectedDataHandler(handler) {
@@ -1 +1 @@
1
- {"version":3,"file":"useProtectedDataHandler.js","sources":["../src/useProtectedDataHandler.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCanFetchProtectedData } from \"./useCanFetchProtectedData.ts\";\n\nexport function useProtectedDataHandler(handler: () => void) {\n const canFetchProtectedData = useCanFetchProtectedData();\n\n useEffect(() => {\n if (canFetchProtectedData) {\n handler();\n }\n }, [canFetchProtectedData, handler]);\n}\n"],"names":["useEffect","useCanFetchProtectedData","useProtectedDataHandler","handler","canFetchProtectedData"],"mappings":";;;;;;;;AAAkC;AACuC;AAElE,SAASE,wBAAwBC,OAAmB;IACvD,MAAMC,wBAAwBH,wBAAwBA;IAEtDD,SAASA,CAAC;QACN,IAAII,uBAAuB;YACvBD;QACJ;IACJ,GAAG;QAACC;QAAuBD;KAAQ;AACvC"}
1
+ {"version":3,"file":"useProtectedDataHandler.js","sources":["../src/useProtectedDataHandler.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCanFetchProtectedData } from \"./useCanFetchProtectedData.ts\";\n\nexport function useProtectedDataHandler(handler: () => void) {\n const canFetchProtectedData = useCanFetchProtectedData();\n\n useEffect(() => {\n if (canFetchProtectedData) {\n handler();\n }\n }, [canFetchProtectedData, handler]);\n}\n"],"names":["useEffect","useCanFetchProtectedData","useProtectedDataHandler","handler","canFetchProtectedData"],"mappings":";;;;;AAAkC;AACuC;AAElE,SAASE,uBAAuBA,CAACC,OAAmB;IACvD,MAAMC,wBAAwBH,wBAAwBA;IAEtDD,SAASA,CAAC;QACN,IAAII,uBAAuB;YACvBD;QACJ;IACJ,GAAG;QAACC;QAAuBD;KAAQ;AACvC"}
@@ -6,21 +6,13 @@ import { GlobalDataQueriesError } from "./GlobalDataQueriesError.js";
6
6
  import { useCanFetchProtectedData } from "./useCanFetchProtectedData.js";
7
7
  import { useExecuteOnce } from "./useExecuteOnce.js";
8
8
 
9
- ;// CONCATENATED MODULE: external "@squide/core"
10
9
 
11
- ;// CONCATENATED MODULE: external "@tanstack/react-query"
12
10
 
13
- ;// CONCATENATED MODULE: external "react"
14
11
 
15
- ;// CONCATENATED MODULE: external "./AppRouterContext.js"
16
12
 
17
- ;// CONCATENATED MODULE: external "./GlobalDataQueriesError.js"
18
13
 
19
- ;// CONCATENATED MODULE: external "./useCanFetchProtectedData.js"
20
14
 
21
- ;// CONCATENATED MODULE: external "./useExecuteOnce.js"
22
15
 
23
- ;// CONCATENATED MODULE: ./src/useProtectedDataQueries.ts
24
16
 
25
17
 
26
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"useProtectedDataQueries.js","sources":["../src/useProtectedDataQueries.ts"],"sourcesContent":["import { useEventBus } from \"@squide/core\";\nimport { useQueries, type QueriesOptions, type QueriesResults, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { GlobalDataQueriesError } from \"./GlobalDataQueriesError.ts\";\nimport { useCanFetchProtectedData } from \"./useCanFetchProtectedData.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\n\nexport const ProtectedDataFetchStartedEvent = \"squide-protected-data-fetch-started\";\nexport const ProtectedDataFetchFailedEvent = \"squide-protected-data-fetch-failed\";\n\nexport type IsUnauthorizedErrorCallback = (error: unknown) => boolean;\n\n// This converts an array of UseQueryResult to an array of the data type of each query result.\n// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.\ntype MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useProtectedDataQueries<T extends Array<any>>(queries: QueriesOptions<T>, isUnauthorizedError: IsUnauthorizedErrorCallback): MapUseQueryResultToData<QueriesResults<T>> {\n const canFetchProtectedData = useCanFetchProtectedData();\n const eventBus = useEventBus();\n\n const dispatch = useAppRouterDispatcher();\n\n const combineResults = useCallback((results: UseQueryResult<unknown, unknown>[]) => {\n const errors = results.filter(x => x.error).map(x => x.error) as Error[];\n const hasErrors = errors.length > 0;\n\n return {\n data: results.map(x => x.data) as MapUseQueryResultToData<QueriesResults<T>>,\n errors,\n hasErrors,\n isReady: !hasErrors && !results.some(x => x.isPending)\n };\n }, []);\n\n const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({\n queries: queries.map(x => ({\n enabled: canFetchProtectedData,\n ...x\n })),\n combine: combineResults\n });\n\n const { isProtectedDataReady, isUnauthorized } = useAppRouterState();\n\n useExecuteOnce(useCallback(() => {\n if (canFetchProtectedData) {\n eventBus.dispatch(ProtectedDataFetchStartedEvent);\n\n return true;\n }\n\n return false;\n }, [canFetchProtectedData, eventBus]), true);\n\n // Using a ref seems to be the only way to prevent starting two deferred registrations scope.\n const isReadyRef = useRef(false);\n\n const dispatchReady = useExecuteOnce(useCallback(() => {\n if (isReady) {\n isReadyRef.current = true;\n\n dispatch({ type: \"protected-data-ready\" });\n\n return true;\n }\n\n return false;\n }, [isReady, dispatch]));\n\n useEffect(() => {\n // State update must be executed in useEffect.\n dispatchReady();\n }, [dispatchReady]);\n\n useEffect(() => {\n if (isReadyRef.current && data) {\n dispatch({ type: \"protected-data-updated\" });\n }\n }, [data, dispatch]);\n\n useEffect(() => {\n if (hasErrors) {\n if (!isProtectedDataReady && !isUnauthorized && queriesErrors.some(x => isUnauthorizedError(x))) {\n // Will transition the state to allow the routes to render even if the bootstrapping is not complete, because otherwise\n // a login page for example could not be rendered.\n dispatch({ type: \"is-unauthorized\" });\n }\n\n // Otherwise, when a user is logged off, a refetch might throws a 401.\n if (!queriesErrors.every(x => isUnauthorizedError(x))) {\n eventBus.dispatch(ProtectedDataFetchFailedEvent, queriesErrors);\n\n throw new GlobalDataQueriesError(\"[squide] Global protected data queries failed.\", queriesErrors);\n }\n }\n }, [hasErrors, queriesErrors, isProtectedDataReady, isUnauthorized, isUnauthorizedError, dispatch, eventBus]);\n\n return data;\n}\n"],"names":["useEventBus","useQueries","useCallback","useEffect","useRef","useAppRouterDispatcher","useAppRouterState","GlobalDataQueriesError","useCanFetchProtectedData","useExecuteOnce","ProtectedDataFetchStartedEvent","ProtectedDataFetchFailedEvent","useProtectedDataQueries","queries","isUnauthorizedError","canFetchProtectedData","eventBus","dispatch","combineResults","results","errors","x","hasErrors","data","queriesErrors","isReady","isProtectedDataReady","isUnauthorized","isReadyRef","dispatchReady"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA2C;AACuE;AAC3D;AAC2B;AACb;AACI;AACpB;AAE9C,MAAMU,iCAAiC,sCAAsC;AAC7E,MAAMC,gCAAgC,qCAAqC;AAQlF,8DAA8D;AACvD,SAASC,wBAA8CC,OAA0B,EAAEC,mBAAgD;IACtI,MAAMC,wBAAwBP,wBAAwBA;IACtD,MAAMQ,WAAWhB,WAAWA;IAE5B,MAAMiB,WAAWZ,sBAAsBA;IAEvC,MAAMa,iBAAiBhB,WAAWA,CAAC,CAACiB;QAChC,MAAMC,SAASD,QAAQ,MAAM,CAACE,CAAAA,IAAKA,EAAE,KAAK,EAAE,GAAG,CAACA,CAAAA,IAAKA,EAAE,KAAK;QAC5D,MAAMC,YAAYF,OAAO,MAAM,GAAG;QAElC,OAAO;YACH,MAAMD,QAAQ,GAAG,CAACE,CAAAA,IAAKA,EAAE,IAAI;YAC7BD;YACAE;YACA,SAAS,CAACA,aAAa,CAACH,QAAQ,IAAI,CAACE,CAAAA,IAAKA,EAAE,SAAS;QACzD;IACJ,GAAG,EAAE;IAEL,MAAM,EAAEE,IAAI,EAAE,QAAQC,aAAa,EAAEF,SAAS,EAAEG,OAAO,EAAE,GAAGxB,UAAUA,CAAC;QACnE,SAASY,QAAQ,GAAG,CAACQ,CAAAA,IAAM;gBACvB,SAASN;gBACT,GAAGM,CAAC;YACR;QACA,SAASH;IACb;IAEA,MAAM,EAAEQ,oBAAoB,EAAEC,cAAc,EAAE,GAAGrB,iBAAiBA;IAElEG,cAAcA,CAACP,WAAWA,CAAC;QACvB,IAAIa,uBAAuB;YACvBC,SAAS,QAAQ,CAACN;YAElB,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACK;QAAuBC;KAAS,GAAG;IAEvC,6FAA6F;IAC7F,MAAMY,aAAaxB,MAAMA,CAAC;IAE1B,MAAMyB,gBAAgBpB,cAAcA,CAACP,WAAWA,CAAC;QAC7C,IAAIuB,SAAS;YACTG,WAAW,OAAO,GAAG;YAErBX,SAAS;gBAAE,MAAM;YAAuB;YAExC,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACQ;QAASR;KAAS;IAEtBd,SAASA,CAAC;QACN,8CAA8C;QAC9C0B;IACJ,GAAG;QAACA;KAAc;IAElB1B,SAASA,CAAC;QACN,IAAIyB,WAAW,OAAO,IAAIL,MAAM;YAC5BN,SAAS;gBAAE,MAAM;YAAyB;QAC9C;IACJ,GAAG;QAACM;QAAMN;KAAS;IAEnBd,SAASA,CAAC;QACN,IAAImB,WAAW;YACX,IAAI,CAACI,wBAAwB,CAACC,kBAAkBH,cAAc,IAAI,CAACH,CAAAA,IAAKP,oBAAoBO,KAAK;gBAC7F,uHAAuH;gBACvH,kDAAkD;gBAClDJ,SAAS;oBAAE,MAAM;gBAAkB;YACvC;YAEA,sEAAsE;YACtE,IAAI,CAACO,cAAc,KAAK,CAACH,CAAAA,IAAKP,oBAAoBO,KAAK;gBACnDL,SAAS,QAAQ,CAACL,+BAA+Ba;gBAEjD,MAAM,IAAIjB,sBAAsBA,CAAC,kDAAkDiB;YACvF;QACJ;IACJ,GAAG;QAACF;QAAWE;QAAeE;QAAsBC;QAAgBb;QAAqBG;QAAUD;KAAS;IAE5G,OAAOO;AACX"}
1
+ {"version":3,"file":"useProtectedDataQueries.js","sources":["../src/useProtectedDataQueries.ts"],"sourcesContent":["import { useEventBus } from \"@squide/core\";\nimport { useQueries, type QueriesOptions, type QueriesResults, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { GlobalDataQueriesError } from \"./GlobalDataQueriesError.ts\";\nimport { useCanFetchProtectedData } from \"./useCanFetchProtectedData.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\n\nexport const ProtectedDataFetchStartedEvent = \"squide-protected-data-fetch-started\";\nexport const ProtectedDataFetchFailedEvent = \"squide-protected-data-fetch-failed\";\n\nexport type IsUnauthorizedErrorCallback = (error: unknown) => boolean;\n\n// This converts an array of UseQueryResult to an array of the data type of each query result.\n// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.\ntype MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useProtectedDataQueries<T extends Array<any>>(queries: QueriesOptions<T>, isUnauthorizedError: IsUnauthorizedErrorCallback): MapUseQueryResultToData<QueriesResults<T>> {\n const canFetchProtectedData = useCanFetchProtectedData();\n const eventBus = useEventBus();\n\n const dispatch = useAppRouterDispatcher();\n\n const combineResults = useCallback((results: UseQueryResult<unknown, unknown>[]) => {\n const errors = results.filter(x => x.error).map(x => x.error) as Error[];\n const hasErrors = errors.length > 0;\n\n return {\n data: results.map(x => x.data) as MapUseQueryResultToData<QueriesResults<T>>,\n errors,\n hasErrors,\n isReady: !hasErrors && !results.some(x => x.isPending)\n };\n }, []);\n\n const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({\n queries: queries.map(x => ({\n enabled: canFetchProtectedData,\n ...x\n })),\n combine: combineResults\n });\n\n const { isProtectedDataReady, isUnauthorized } = useAppRouterState();\n\n useExecuteOnce(useCallback(() => {\n if (canFetchProtectedData) {\n eventBus.dispatch(ProtectedDataFetchStartedEvent);\n\n return true;\n }\n\n return false;\n }, [canFetchProtectedData, eventBus]), true);\n\n // Using a ref seems to be the only way to prevent starting two deferred registrations scope.\n const isReadyRef = useRef(false);\n\n const dispatchReady = useExecuteOnce(useCallback(() => {\n if (isReady) {\n isReadyRef.current = true;\n\n dispatch({ type: \"protected-data-ready\" });\n\n return true;\n }\n\n return false;\n }, [isReady, dispatch]));\n\n useEffect(() => {\n // State update must be executed in useEffect.\n dispatchReady();\n }, [dispatchReady]);\n\n useEffect(() => {\n if (isReadyRef.current && data) {\n dispatch({ type: \"protected-data-updated\" });\n }\n }, [data, dispatch]);\n\n useEffect(() => {\n if (hasErrors) {\n if (!isProtectedDataReady && !isUnauthorized && queriesErrors.some(x => isUnauthorizedError(x))) {\n // Will transition the state to allow the routes to render even if the bootstrapping is not complete, because otherwise\n // a login page for example could not be rendered.\n dispatch({ type: \"is-unauthorized\" });\n }\n\n // Otherwise, when a user is logged off, a refetch might throws a 401.\n if (!queriesErrors.every(x => isUnauthorizedError(x))) {\n eventBus.dispatch(ProtectedDataFetchFailedEvent, queriesErrors);\n\n throw new GlobalDataQueriesError(\"[squide] Global protected data queries failed.\", queriesErrors);\n }\n }\n }, [hasErrors, queriesErrors, isProtectedDataReady, isUnauthorized, isUnauthorizedError, dispatch, eventBus]);\n\n return data;\n}\n"],"names":["useEventBus","useQueries","useCallback","useEffect","useRef","useAppRouterDispatcher","useAppRouterState","GlobalDataQueriesError","useCanFetchProtectedData","useExecuteOnce","ProtectedDataFetchStartedEvent","ProtectedDataFetchFailedEvent","useProtectedDataQueries","queries","isUnauthorizedError","canFetchProtectedData","eventBus","dispatch","combineResults","results","errors","x","hasErrors","data","queriesErrors","isReady","isProtectedDataReady","isUnauthorized","isReadyRef","dispatchReady"],"mappings":";;;;;;;;;;;;;;;AAA2C;AACuE;AAC3D;AAC2B;AACb;AACI;AACpB;AAE9C,MAAMU,8BAA8BA,GAAG,sCAAsC;AAC7E,MAAMC,6BAA6BA,GAAG,qCAAqC;AAQlF,8DAA8D;AACvD,SAASC,uBAAuBA,CAAuBC,OAA0B,EAAEC,mBAAgD;IACtI,MAAMC,wBAAwBP,wBAAwBA;IACtD,MAAMQ,WAAWhB,WAAWA;IAE5B,MAAMiB,WAAWZ,sBAAsBA;IAEvC,MAAMa,iBAAiBhB,WAAWA,CAAC,CAACiB;QAChC,MAAMC,SAASD,QAAQ,MAAM,CAACE,CAAAA,IAAKA,EAAE,KAAK,EAAE,GAAG,CAACA,CAAAA,IAAKA,EAAE,KAAK;QAC5D,MAAMC,YAAYF,OAAO,MAAM,GAAG;QAElC,OAAO;YACH,MAAMD,QAAQ,GAAG,CAACE,CAAAA,IAAKA,EAAE,IAAI;YAC7BD;YACAE;YACA,SAAS,CAACA,aAAa,CAACH,QAAQ,IAAI,CAACE,CAAAA,IAAKA,EAAE,SAAS;QACzD;IACJ,GAAG,EAAE;IAEL,MAAM,EAAEE,IAAI,EAAE,QAAQC,aAAa,EAAEF,SAAS,EAAEG,OAAO,EAAE,GAAGxB,UAAUA,CAAC;QACnE,SAASY,QAAQ,GAAG,CAACQ,CAAAA,IAAM;gBACvB,SAASN;gBACT,GAAGM,CAAC;YACR;QACA,SAASH;IACb;IAEA,MAAM,EAAEQ,oBAAoB,EAAEC,cAAc,EAAE,GAAGrB,iBAAiBA;IAElEG,cAAcA,CAACP,WAAWA,CAAC;QACvB,IAAIa,uBAAuB;YACvBC,SAAS,QAAQ,CAACN,8BAA8BA;YAEhD,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACK;QAAuBC;KAAS,GAAG;IAEvC,6FAA6F;IAC7F,MAAMY,aAAaxB,MAAMA,CAAC;IAE1B,MAAMyB,gBAAgBpB,cAAcA,CAACP,WAAWA,CAAC;QAC7C,IAAIuB,SAAS;YACTG,WAAW,OAAO,GAAG;YAErBX,SAAS;gBAAE,MAAM;YAAuB;YAExC,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACQ;QAASR;KAAS;IAEtBd,SAASA,CAAC;QACN,8CAA8C;QAC9C0B;IACJ,GAAG;QAACA;KAAc;IAElB1B,SAASA,CAAC;QACN,IAAIyB,WAAW,OAAO,IAAIL,MAAM;YAC5BN,SAAS;gBAAE,MAAM;YAAyB;QAC9C;IACJ,GAAG;QAACM;QAAMN;KAAS;IAEnBd,SAASA,CAAC;QACN,IAAImB,WAAW;YACX,IAAI,CAACI,wBAAwB,CAACC,kBAAkBH,cAAc,IAAI,CAACH,CAAAA,IAAKP,oBAAoBO,KAAK;gBAC7F,uHAAuH;gBACvH,kDAAkD;gBAClDJ,SAAS;oBAAE,MAAM;gBAAkB;YACvC;YAEA,sEAAsE;YACtE,IAAI,CAACO,cAAc,KAAK,CAACH,CAAAA,IAAKP,oBAAoBO,KAAK;gBACnDL,SAAS,QAAQ,CAACL,6BAA6BA,EAAEa;gBAEjD,MAAM,IAAIjB,sBAAsBA,CAAC,kDAAkDiB;YACvF;QACJ;IACJ,GAAG;QAACF;QAAWE;QAAeE;QAAsBC;QAAgBb;QAAqBG;QAAUD;KAAS;IAE5G,OAAOO;AACX"}
@@ -1,11 +1,8 @@
1
1
  import { useEffect } from "react";
2
2
  import { useCanFetchPublicData } from "./useCanFetchPublicData.js";
3
3
 
4
- ;// CONCATENATED MODULE: external "react"
5
4
 
6
- ;// CONCATENATED MODULE: external "./useCanFetchPublicData.js"
7
5
 
8
- ;// CONCATENATED MODULE: ./src/usePublicDataHandler.ts
9
6
 
10
7
 
11
8
  function usePublicDataHandler(handler) {
@@ -1 +1 @@
1
- {"version":3,"file":"usePublicDataHandler.js","sources":["../src/usePublicDataHandler.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCanFetchPublicData } from \"./useCanFetchPublicData.ts\";\n\nexport function usePublicDataHandler(handler: () => void) {\n const canFetchPublicData = useCanFetchPublicData();\n\n useEffect(() => {\n if (canFetchPublicData) {\n handler();\n }\n }, [canFetchPublicData, handler]);\n}\n"],"names":["useEffect","useCanFetchPublicData","usePublicDataHandler","handler","canFetchPublicData"],"mappings":";;;;;;;;AAAkC;AACiC;AAE5D,SAASE,qBAAqBC,OAAmB;IACpD,MAAMC,qBAAqBH,qBAAqBA;IAEhDD,SAASA,CAAC;QACN,IAAII,oBAAoB;YACpBD;QACJ;IACJ,GAAG;QAACC;QAAoBD;KAAQ;AACpC"}
1
+ {"version":3,"file":"usePublicDataHandler.js","sources":["../src/usePublicDataHandler.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCanFetchPublicData } from \"./useCanFetchPublicData.ts\";\n\nexport function usePublicDataHandler(handler: () => void) {\n const canFetchPublicData = useCanFetchPublicData();\n\n useEffect(() => {\n if (canFetchPublicData) {\n handler();\n }\n }, [canFetchPublicData, handler]);\n}\n"],"names":["useEffect","useCanFetchPublicData","usePublicDataHandler","handler","canFetchPublicData"],"mappings":";;;;;AAAkC;AACiC;AAE5D,SAASE,oBAAoBA,CAACC,OAAmB;IACpD,MAAMC,qBAAqBH,qBAAqBA;IAEhDD,SAASA,CAAC;QACN,IAAII,oBAAoB;YACpBD;QACJ;IACJ,GAAG;QAACC;QAAoBD;KAAQ;AACpC"}
@@ -6,21 +6,13 @@ import { GlobalDataQueriesError } from "./GlobalDataQueriesError.js";
6
6
  import { useCanFetchPublicData } from "./useCanFetchPublicData.js";
7
7
  import { useExecuteOnce } from "./useExecuteOnce.js";
8
8
 
9
- ;// CONCATENATED MODULE: external "@squide/core"
10
9
 
11
- ;// CONCATENATED MODULE: external "@tanstack/react-query"
12
10
 
13
- ;// CONCATENATED MODULE: external "react"
14
11
 
15
- ;// CONCATENATED MODULE: external "./AppRouterContext.js"
16
12
 
17
- ;// CONCATENATED MODULE: external "./GlobalDataQueriesError.js"
18
13
 
19
- ;// CONCATENATED MODULE: external "./useCanFetchPublicData.js"
20
14
 
21
- ;// CONCATENATED MODULE: external "./useExecuteOnce.js"
22
15
 
23
- ;// CONCATENATED MODULE: ./src/usePublicDataQueries.ts
24
16
 
25
17
 
26
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"usePublicDataQueries.js","sources":["../src/usePublicDataQueries.ts"],"sourcesContent":["import { useEventBus } from \"@squide/core\";\nimport { useQueries, type QueriesOptions, type QueriesResults, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { useAppRouterDispatcher } from \"./AppRouterContext.ts\";\nimport { GlobalDataQueriesError } from \"./GlobalDataQueriesError.ts\";\nimport { useCanFetchPublicData } from \"./useCanFetchPublicData.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\n\nexport const PublicDataFetchStartedEvent = \"squide-public-data-fetch-started\";\nexport const PublicDataFetchFailedEvent = \"squide-public-data-fetch-failed\";\n\n// This converts an array of UseQueryResult to an array of the data type of each query result.\n// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.\ntype MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function usePublicDataQueries<T extends Array<any>>(queries: QueriesOptions<T>): MapUseQueryResultToData<QueriesResults<T>> {\n const canFetchPublicData = useCanFetchPublicData();\n const eventBus = useEventBus();\n\n const dispatch = useAppRouterDispatcher();\n\n const combineResults = useCallback((results: UseQueryResult<unknown, unknown>[]) => {\n const errors = results.filter(x => x.error).map(x => x.error) as Error[];\n const hasErrors = errors.length > 0;\n\n return {\n data: results.map(x => x.data) as MapUseQueryResultToData<QueriesResults<T>>,\n errors,\n hasErrors,\n isReady: !hasErrors && !results.some(x => x.isPending)\n };\n }, []);\n\n const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({\n queries: queries.map(x => ({\n enabled: canFetchPublicData,\n ...x\n })),\n combine: combineResults\n });\n\n useExecuteOnce(useCallback(() => {\n if (canFetchPublicData) {\n eventBus.dispatch(PublicDataFetchStartedEvent);\n\n return true;\n }\n\n return false;\n }, [canFetchPublicData, eventBus]), true);\n\n // Using a ref seems to be the only way to prevent starting two deferred registrations scope.\n const isReadyRef = useRef(false);\n\n const dispatchReady = useExecuteOnce(useCallback(() => {\n if (isReady) {\n isReadyRef.current = true;\n\n dispatch({ type: \"public-data-ready\" });\n\n return true;\n }\n\n return false;\n }, [isReady, dispatch]));\n\n useEffect(() => {\n // State update must be executed in useEffect.\n dispatchReady();\n }, [dispatchReady]);\n\n useEffect(() => {\n if (isReadyRef.current && data) {\n dispatch({ type: \"public-data-updated\" });\n }\n }, [data, dispatch]);\n\n useEffect(() => {\n if (hasErrors) {\n eventBus.dispatch(PublicDataFetchFailedEvent, queriesErrors);\n\n throw new GlobalDataQueriesError(\"[squide] Global public data queries failed.\", queriesErrors);\n }\n }, [hasErrors, queriesErrors, eventBus]);\n\n return data;\n}\n"],"names":["useEventBus","useQueries","useCallback","useEffect","useRef","useAppRouterDispatcher","GlobalDataQueriesError","useCanFetchPublicData","useExecuteOnce","PublicDataFetchStartedEvent","PublicDataFetchFailedEvent","usePublicDataQueries","queries","canFetchPublicData","eventBus","dispatch","combineResults","results","errors","x","hasErrors","data","queriesErrors","isReady","isReadyRef","dispatchReady"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA2C;AACuE;AAC3D;AACQ;AACM;AACF;AACd;AAE9C,MAAMS,8BAA8B,mCAAmC;AACvE,MAAMC,6BAA6B,kCAAkC;AAM5E,8DAA8D;AACvD,SAASC,qBAA2CC,OAA0B;IACjF,MAAMC,qBAAqBN,qBAAqBA;IAChD,MAAMO,WAAWd,WAAWA;IAE5B,MAAMe,WAAWV,sBAAsBA;IAEvC,MAAMW,iBAAiBd,WAAWA,CAAC,CAACe;QAChC,MAAMC,SAASD,QAAQ,MAAM,CAACE,CAAAA,IAAKA,EAAE,KAAK,EAAE,GAAG,CAACA,CAAAA,IAAKA,EAAE,KAAK;QAC5D,MAAMC,YAAYF,OAAO,MAAM,GAAG;QAElC,OAAO;YACH,MAAMD,QAAQ,GAAG,CAACE,CAAAA,IAAKA,EAAE,IAAI;YAC7BD;YACAE;YACA,SAAS,CAACA,aAAa,CAACH,QAAQ,IAAI,CAACE,CAAAA,IAAKA,EAAE,SAAS;QACzD;IACJ,GAAG,EAAE;IAEL,MAAM,EAAEE,IAAI,EAAE,QAAQC,aAAa,EAAEF,SAAS,EAAEG,OAAO,EAAE,GAAGtB,UAAUA,CAAC;QACnE,SAASW,QAAQ,GAAG,CAACO,CAAAA,IAAM;gBACvB,SAASN;gBACT,GAAGM,CAAC;YACR;QACA,SAASH;IACb;IAEAR,cAAcA,CAACN,WAAWA,CAAC;QACvB,IAAIW,oBAAoB;YACpBC,SAAS,QAAQ,CAACL;YAElB,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACI;QAAoBC;KAAS,GAAG;IAEpC,6FAA6F;IAC7F,MAAMU,aAAapB,MAAMA,CAAC;IAE1B,MAAMqB,gBAAgBjB,cAAcA,CAACN,WAAWA,CAAC;QAC7C,IAAIqB,SAAS;YACTC,WAAW,OAAO,GAAG;YAErBT,SAAS;gBAAE,MAAM;YAAoB;YAErC,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACQ;QAASR;KAAS;IAEtBZ,SAASA,CAAC;QACN,8CAA8C;QAC9CsB;IACJ,GAAG;QAACA;KAAc;IAElBtB,SAASA,CAAC;QACN,IAAIqB,WAAW,OAAO,IAAIH,MAAM;YAC5BN,SAAS;gBAAE,MAAM;YAAsB;QAC3C;IACJ,GAAG;QAACM;QAAMN;KAAS;IAEnBZ,SAASA,CAAC;QACN,IAAIiB,WAAW;YACXN,SAAS,QAAQ,CAACJ,4BAA4BY;YAE9C,MAAM,IAAIhB,sBAAsBA,CAAC,+CAA+CgB;QACpF;IACJ,GAAG;QAACF;QAAWE;QAAeR;KAAS;IAEvC,OAAOO;AACX"}
1
+ {"version":3,"file":"usePublicDataQueries.js","sources":["../src/usePublicDataQueries.ts"],"sourcesContent":["import { useEventBus } from \"@squide/core\";\nimport { useQueries, type QueriesOptions, type QueriesResults, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { useAppRouterDispatcher } from \"./AppRouterContext.ts\";\nimport { GlobalDataQueriesError } from \"./GlobalDataQueriesError.ts\";\nimport { useCanFetchPublicData } from \"./useCanFetchPublicData.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\n\nexport const PublicDataFetchStartedEvent = \"squide-public-data-fetch-started\";\nexport const PublicDataFetchFailedEvent = \"squide-public-data-fetch-failed\";\n\n// This converts an array of UseQueryResult to an array of the data type of each query result.\n// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.\ntype MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function usePublicDataQueries<T extends Array<any>>(queries: QueriesOptions<T>): MapUseQueryResultToData<QueriesResults<T>> {\n const canFetchPublicData = useCanFetchPublicData();\n const eventBus = useEventBus();\n\n const dispatch = useAppRouterDispatcher();\n\n const combineResults = useCallback((results: UseQueryResult<unknown, unknown>[]) => {\n const errors = results.filter(x => x.error).map(x => x.error) as Error[];\n const hasErrors = errors.length > 0;\n\n return {\n data: results.map(x => x.data) as MapUseQueryResultToData<QueriesResults<T>>,\n errors,\n hasErrors,\n isReady: !hasErrors && !results.some(x => x.isPending)\n };\n }, []);\n\n const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({\n queries: queries.map(x => ({\n enabled: canFetchPublicData,\n ...x\n })),\n combine: combineResults\n });\n\n useExecuteOnce(useCallback(() => {\n if (canFetchPublicData) {\n eventBus.dispatch(PublicDataFetchStartedEvent);\n\n return true;\n }\n\n return false;\n }, [canFetchPublicData, eventBus]), true);\n\n // Using a ref seems to be the only way to prevent starting two deferred registrations scope.\n const isReadyRef = useRef(false);\n\n const dispatchReady = useExecuteOnce(useCallback(() => {\n if (isReady) {\n isReadyRef.current = true;\n\n dispatch({ type: \"public-data-ready\" });\n\n return true;\n }\n\n return false;\n }, [isReady, dispatch]));\n\n useEffect(() => {\n // State update must be executed in useEffect.\n dispatchReady();\n }, [dispatchReady]);\n\n useEffect(() => {\n if (isReadyRef.current && data) {\n dispatch({ type: \"public-data-updated\" });\n }\n }, [data, dispatch]);\n\n useEffect(() => {\n if (hasErrors) {\n eventBus.dispatch(PublicDataFetchFailedEvent, queriesErrors);\n\n throw new GlobalDataQueriesError(\"[squide] Global public data queries failed.\", queriesErrors);\n }\n }, [hasErrors, queriesErrors, eventBus]);\n\n return data;\n}\n"],"names":["useEventBus","useQueries","useCallback","useEffect","useRef","useAppRouterDispatcher","GlobalDataQueriesError","useCanFetchPublicData","useExecuteOnce","PublicDataFetchStartedEvent","PublicDataFetchFailedEvent","usePublicDataQueries","queries","canFetchPublicData","eventBus","dispatch","combineResults","results","errors","x","hasErrors","data","queriesErrors","isReady","isReadyRef","dispatchReady"],"mappings":";;;;;;;;;;;;;;;AAA2C;AACuE;AAC3D;AACQ;AACM;AACF;AACd;AAE9C,MAAMS,2BAA2BA,GAAG,mCAAmC;AACvE,MAAMC,0BAA0BA,GAAG,kCAAkC;AAM5E,8DAA8D;AACvD,SAASC,oBAAoBA,CAAuBC,OAA0B;IACjF,MAAMC,qBAAqBN,qBAAqBA;IAChD,MAAMO,WAAWd,WAAWA;IAE5B,MAAMe,WAAWV,sBAAsBA;IAEvC,MAAMW,iBAAiBd,WAAWA,CAAC,CAACe;QAChC,MAAMC,SAASD,QAAQ,MAAM,CAACE,CAAAA,IAAKA,EAAE,KAAK,EAAE,GAAG,CAACA,CAAAA,IAAKA,EAAE,KAAK;QAC5D,MAAMC,YAAYF,OAAO,MAAM,GAAG;QAElC,OAAO;YACH,MAAMD,QAAQ,GAAG,CAACE,CAAAA,IAAKA,EAAE,IAAI;YAC7BD;YACAE;YACA,SAAS,CAACA,aAAa,CAACH,QAAQ,IAAI,CAACE,CAAAA,IAAKA,EAAE,SAAS;QACzD;IACJ,GAAG,EAAE;IAEL,MAAM,EAAEE,IAAI,EAAE,QAAQC,aAAa,EAAEF,SAAS,EAAEG,OAAO,EAAE,GAAGtB,UAAUA,CAAC;QACnE,SAASW,QAAQ,GAAG,CAACO,CAAAA,IAAM;gBACvB,SAASN;gBACT,GAAGM,CAAC;YACR;QACA,SAASH;IACb;IAEAR,cAAcA,CAACN,WAAWA,CAAC;QACvB,IAAIW,oBAAoB;YACpBC,SAAS,QAAQ,CAACL,2BAA2BA;YAE7C,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACI;QAAoBC;KAAS,GAAG;IAEpC,6FAA6F;IAC7F,MAAMU,aAAapB,MAAMA,CAAC;IAE1B,MAAMqB,gBAAgBjB,cAAcA,CAACN,WAAWA,CAAC;QAC7C,IAAIqB,SAAS;YACTC,WAAW,OAAO,GAAG;YAErBT,SAAS;gBAAE,MAAM;YAAoB;YAErC,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACQ;QAASR;KAAS;IAEtBZ,SAASA,CAAC;QACN,8CAA8C;QAC9CsB;IACJ,GAAG;QAACA;KAAc;IAElBtB,SAASA,CAAC;QACN,IAAIqB,WAAW,OAAO,IAAIH,MAAM;YAC5BN,SAAS;gBAAE,MAAM;YAAsB;QAC3C;IACJ,GAAG;QAACM;QAAMN;KAAS;IAEnBZ,SAASA,CAAC;QACN,IAAIiB,WAAW;YACXN,SAAS,QAAQ,CAACJ,0BAA0BA,EAAEY;YAE9C,MAAM,IAAIhB,sBAAsBA,CAAC,+CAA+CgB;QACpF;IACJ,GAAG;QAACF;QAAWE;QAAeR;KAAS;IAEvC,OAAOO;AACX"}
@@ -1,11 +1,8 @@
1
1
  import { useRuntime } from "@squide/core";
2
2
  import { useCallback } from "react";
3
3
 
4
- ;// CONCATENATED MODULE: external "@squide/core"
5
4
 
6
- ;// CONCATENATED MODULE: external "react"
7
5
 
8
- ;// CONCATENATED MODULE: ./src/useRegisterDeferredRegistrations.ts
9
6
 
10
7
 
11
8
  function useRegisterDeferredRegistrations() {
@@ -1 +1 @@
1
- {"version":3,"file":"useRegisterDeferredRegistrations.js","sources":["../src/useRegisterDeferredRegistrations.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport { useCallback } from \"react\";\n\nexport function useRegisterDeferredRegistrations() {\n const runtime = useRuntime();\n\n return useCallback(<TData = unknown>(data?: TData) => {\n return runtime.moduleManager.registerDeferredRegistrations(data);\n }, [runtime]);\n}\n"],"names":["useRuntime","useCallback","useRegisterDeferredRegistrations","runtime","data"],"mappings":";;;;;;;;AAA0C;AACN;AAE7B,SAASE;IACZ,MAAMC,UAAUH,UAAUA;IAE1B,OAAOC,WAAWA,CAAC,CAAkBG;QACjC,OAAOD,QAAQ,aAAa,CAAC,6BAA6B,CAACC;IAC/D,GAAG;QAACD;KAAQ;AAChB"}
1
+ {"version":3,"file":"useRegisterDeferredRegistrations.js","sources":["../src/useRegisterDeferredRegistrations.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport { useCallback } from \"react\";\n\nexport function useRegisterDeferredRegistrations() {\n const runtime = useRuntime();\n\n return useCallback(<TData = unknown>(data?: TData) => {\n return runtime.moduleManager.registerDeferredRegistrations(data);\n }, [runtime]);\n}\n"],"names":["useRuntime","useCallback","useRegisterDeferredRegistrations","runtime","data"],"mappings":";;;;;AAA0C;AACN;AAE7B,SAASE,gCAAgCA;IAC5C,MAAMC,UAAUH,UAAUA;IAE1B,OAAOC,WAAWA,CAAC,CAAkBG;QACjC,OAAOD,QAAQ,aAAa,CAAC,6BAA6B,CAACC;IAC/D,GAAG;QAACD;KAAQ;AAChB"}
@@ -1,11 +1,8 @@
1
1
  import { useRuntime } from "@squide/core";
2
2
  import { useCallback, useEffect, useSyncExternalStore } from "react";
3
3
 
4
- ;// CONCATENATED MODULE: external "@squide/core"
5
4
 
6
- ;// CONCATENATED MODULE: external "react"
7
5
 
8
- ;// CONCATENATED MODULE: ./src/useStrictRegistrationMode.ts
9
6
 
10
7
 
11
8
  function useStrictRegistrationMode(options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"useStrictRegistrationMode.js","sources":["../src/useStrictRegistrationMode.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport { useCallback, useEffect, useSyncExternalStore } from \"react\";\n\nexport interface UseStrictRegistrationModeOptions {\n isEnabled?: boolean;\n}\n\nexport function useStrictRegistrationMode(options: UseStrictRegistrationModeOptions = {}) {\n const {\n isEnabled = true\n } = options;\n\n const runtime = useRuntime();\n\n const subscribe = useCallback((callback: () => void) => {\n runtime.moduleManager.registerModulesReadyListener(callback);\n\n return () => {\n runtime.moduleManager.removeModulesReadyListener(callback);\n };\n }, [runtime]);\n\n // This listener is only executed if the modules are ready.\n const areModulesReady = useSyncExternalStore(subscribe, () => runtime.moduleManager.getAreModulesReady());\n\n useEffect(() => {\n if (areModulesReady && isEnabled) {\n runtime._validateRegistrations();\n }\n }, [runtime, areModulesReady, isEnabled]);\n}\n"],"names":["useRuntime","useCallback","useEffect","useSyncExternalStore","useStrictRegistrationMode","options","isEnabled","runtime","subscribe","callback","areModulesReady"],"mappings":";;;;;;;;AAA0C;AAC2B;AAM9D,SAASI,0BAA0BC,UAA4C,CAAC,CAAC;IACpF,MAAM,EACFC,YAAY,IAAI,EACnB,GAAGD;IAEJ,MAAME,UAAUP,UAAUA;IAE1B,MAAMQ,YAAYP,WAAWA,CAAC,CAACQ;QAC3BF,QAAQ,aAAa,CAAC,4BAA4B,CAACE;QAEnD,OAAO;YACHF,QAAQ,aAAa,CAAC,0BAA0B,CAACE;QACrD;IACJ,GAAG;QAACF;KAAQ;IAEZ,2DAA2D;IAC3D,MAAMG,kBAAkBP,oBAAoBA,CAACK,WAAW,IAAMD,QAAQ,aAAa,CAAC,kBAAkB;IAEtGL,SAASA,CAAC;QACN,IAAIQ,mBAAmBJ,WAAW;YAC9BC,QAAQ,sBAAsB;QAClC;IACJ,GAAG;QAACA;QAASG;QAAiBJ;KAAU;AAC5C"}
1
+ {"version":3,"file":"useStrictRegistrationMode.js","sources":["../src/useStrictRegistrationMode.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport { useCallback, useEffect, useSyncExternalStore } from \"react\";\n\nexport interface UseStrictRegistrationModeOptions {\n isEnabled?: boolean;\n}\n\nexport function useStrictRegistrationMode(options: UseStrictRegistrationModeOptions = {}) {\n const {\n isEnabled = true\n } = options;\n\n const runtime = useRuntime();\n\n const subscribe = useCallback((callback: () => void) => {\n runtime.moduleManager.registerModulesReadyListener(callback);\n\n return () => {\n runtime.moduleManager.removeModulesReadyListener(callback);\n };\n }, [runtime]);\n\n // This listener is only executed if the modules are ready.\n const areModulesReady = useSyncExternalStore(subscribe, () => runtime.moduleManager.getAreModulesReady());\n\n useEffect(() => {\n if (areModulesReady && isEnabled) {\n runtime._validateRegistrations();\n }\n }, [runtime, areModulesReady, isEnabled]);\n}\n"],"names":["useRuntime","useCallback","useEffect","useSyncExternalStore","useStrictRegistrationMode","options","isEnabled","runtime","subscribe","callback","areModulesReady"],"mappings":";;;;;AAA0C;AAC2B;AAM9D,SAASI,yBAAyBA,CAACC,UAA4C,CAAC,CAAC;IACpF,MAAM,EACFC,YAAY,IAAI,EACnB,GAAGD;IAEJ,MAAME,UAAUP,UAAUA;IAE1B,MAAMQ,YAAYP,WAAWA,CAAC,CAACQ;QAC3BF,QAAQ,aAAa,CAAC,4BAA4B,CAACE;QAEnD,OAAO;YACHF,QAAQ,aAAa,CAAC,0BAA0B,CAACE;QACrD;IACJ,GAAG;QAACF;KAAQ;IAEZ,2DAA2D;IAC3D,MAAMG,kBAAkBP,oBAAoBA,CAACK,WAAW,IAAMD,QAAQ,aAAa,CAAC,kBAAkB;IAEtGL,SAASA,CAAC;QACN,IAAIQ,mBAAmBJ,WAAW;YAC9BC,QAAQ,sBAAsB;QAClC;IACJ,GAAG;QAACA;QAASG;QAAiBJ;KAAU;AAC5C"}
@@ -2,13 +2,9 @@ import { useRuntime } from "@squide/core";
2
2
  import { useCallback } from "react";
3
3
  import { useAppRouterDispatcher } from "./AppRouterContext.js";
4
4
 
5
- ;// CONCATENATED MODULE: external "@squide/core"
6
5
 
7
- ;// CONCATENATED MODULE: external "react"
8
6
 
9
- ;// CONCATENATED MODULE: external "./AppRouterContext.js"
10
7
 
11
- ;// CONCATENATED MODULE: ./src/useUpdateDeferredRegistrations.ts
12
8
 
13
9
 
14
10
 
@@ -1 +1 @@
1
- {"version":3,"file":"useUpdateDeferredRegistrations.js","sources":["../src/useUpdateDeferredRegistrations.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport { useCallback } from \"react\";\nimport { useAppRouterDispatcher } from \"./AppRouterContext.ts\";\n\nexport const DeferredRegistrationsUpdateStartedEvent = \"squide-deferred-registrations-update-started\";\nexport const DeferredRegistrationsUpdateCompletedEvent = \"squide-deferred-registrations-update-completed-started\";\n\nexport function useUpdateDeferredRegistrations() {\n const runtime = useRuntime();\n const dispatch = useAppRouterDispatcher();\n\n return useCallback(async <TData = unknown>(data?: TData) => {\n runtime.eventBus.dispatch(DeferredRegistrationsUpdateStartedEvent);\n\n const errors = await runtime.moduleManager.updateDeferredRegistrations(data);\n\n dispatch({ type: \"deferred-registrations-updated\" });\n\n runtime.eventBus.dispatch(DeferredRegistrationsUpdateCompletedEvent);\n\n return errors;\n }, [runtime, dispatch]);\n}\n"],"names":["useRuntime","useCallback","useAppRouterDispatcher","DeferredRegistrationsUpdateStartedEvent","DeferredRegistrationsUpdateCompletedEvent","useUpdateDeferredRegistrations","runtime","dispatch","data","errors"],"mappings":";;;;;;;;;;;AAA0C;AACN;AAC2B;AAExD,MAAMG,0CAA0C,+CAA+C;AAC/F,MAAMC,4CAA4C,yDAAyD;AAE3G,SAASC;IACZ,MAAMC,UAAUN,UAAUA;IAC1B,MAAMO,WAAWL,sBAAsBA;IAEvC,OAAOD,WAAWA,CAAC,OAAwBO;QACvCF,QAAQ,QAAQ,CAAC,QAAQ,CAACH;QAE1B,MAAMM,SAAS,MAAMH,QAAQ,aAAa,CAAC,2BAA2B,CAACE;QAEvED,SAAS;YAAE,MAAM;QAAiC;QAElDD,QAAQ,QAAQ,CAAC,QAAQ,CAACF;QAE1B,OAAOK;IACX,GAAG;QAACH;QAASC;KAAS;AAC1B"}
1
+ {"version":3,"file":"useUpdateDeferredRegistrations.js","sources":["../src/useUpdateDeferredRegistrations.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport { useCallback } from \"react\";\nimport { useAppRouterDispatcher } from \"./AppRouterContext.ts\";\n\nexport const DeferredRegistrationsUpdateStartedEvent = \"squide-deferred-registrations-update-started\";\nexport const DeferredRegistrationsUpdateCompletedEvent = \"squide-deferred-registrations-update-completed-started\";\n\nexport function useUpdateDeferredRegistrations() {\n const runtime = useRuntime();\n const dispatch = useAppRouterDispatcher();\n\n return useCallback(async <TData = unknown>(data?: TData) => {\n runtime.eventBus.dispatch(DeferredRegistrationsUpdateStartedEvent);\n\n const errors = await runtime.moduleManager.updateDeferredRegistrations(data);\n\n dispatch({ type: \"deferred-registrations-updated\" });\n\n runtime.eventBus.dispatch(DeferredRegistrationsUpdateCompletedEvent);\n\n return errors;\n }, [runtime, dispatch]);\n}\n"],"names":["useRuntime","useCallback","useAppRouterDispatcher","DeferredRegistrationsUpdateStartedEvent","DeferredRegistrationsUpdateCompletedEvent","useUpdateDeferredRegistrations","runtime","dispatch","data","errors"],"mappings":";;;;;;;AAA0C;AACN;AAC2B;AAExD,MAAMG,uCAAuCA,GAAG,+CAA+C;AAC/F,MAAMC,yCAAyCA,GAAG,yDAAyD;AAE3G,SAASC,8BAA8BA;IAC1C,MAAMC,UAAUN,UAAUA;IAC1B,MAAMO,WAAWL,sBAAsBA;IAEvC,OAAOD,WAAWA,CAAC,OAAwBO;QACvCF,QAAQ,QAAQ,CAAC,QAAQ,CAACH,uCAAuCA;QAEjE,MAAMM,SAAS,MAAMH,QAAQ,aAAa,CAAC,2BAA2B,CAACE;QAEvED,SAAS;YAAE,MAAM;QAAiC;QAElDD,QAAQ,QAAQ,CAAC,QAAQ,CAACF,yCAAyCA;QAEnE,OAAOK;IACX,GAAG;QAACH;QAASC;KAAS;AAC1B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "16.2.0",
4
+ "version": "16.2.2",
5
5
  "description": "Squide bundle for the firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -32,13 +32,13 @@
32
32
  "CHANGELOG.md"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@opentelemetry/api": "^1.9.0",
36
- "@tanstack/react-query": "^5.90.21",
35
+ "@opentelemetry/api": "^1.9.1",
36
+ "@tanstack/react-query": "^5.96.0",
37
37
  "launchdarkly-js-client-sdk": "^3.9.0",
38
- "msw": "^2.12.10",
38
+ "msw": "^2.12.14",
39
39
  "react": "^18.0.0 || ^19.0.0",
40
40
  "react-dom": "^18.0.0 || ^19.0.0",
41
- "react-router": "^7.13.1"
41
+ "react-router": "^7.13.2"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "@opentelemetry/api": {
@@ -46,33 +46,34 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "@workleap-telemetry/core": "^2.0.0",
50
- "@workleap/logging": "^1.3.6",
49
+ "@workleap-telemetry/core": "^2.0.1",
50
+ "@workleap/logging": "^1.3.7",
51
51
  "uuid": "^13.0.0",
52
- "@squide/core": "^6.1.14",
53
- "@squide/launch-darkly": "^1.0.10",
54
- "@squide/env-vars": "^1.4.19",
55
- "@squide/msw": "^4.0.17",
56
- "@squide/react-router": "^8.1.17"
52
+ "@squide/core": "^6.1.15",
53
+ "@squide/env-vars": "^1.4.20",
54
+ "@squide/launch-darkly": "^1.0.11",
55
+ "@squide/msw": "^4.0.18",
56
+ "@squide/react-router": "^8.1.18"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint/js": "9.39.2",
60
- "@rsbuild/core": "1.7.3",
61
- "@rslib/core": "0.19.6",
60
+ "@rsbuild/core": "1.7.5",
61
+ "@rslib/core": "0.20.2",
62
62
  "@testing-library/react": "16.3.2",
63
+ "@types/node": "25.5.0",
63
64
  "@types/react": "19.2.14",
64
65
  "@types/react-dom": "19.2.3",
65
- "@typescript-eslint/parser": "8.56.1",
66
- "@typescript/native-preview": "7.0.0-dev.20260303.1",
67
- "@vitejs/plugin-react": "5.1.4",
68
- "@workleap/eslint-configs": "1.1.13",
69
- "@workleap/rslib-configs": "1.1.7",
70
- "@workleap/typescript-configs": "3.0.7",
66
+ "@typescript-eslint/parser": "8.58.0",
67
+ "@typescript/native-preview": "7.0.0-dev.20260331.1",
68
+ "@vitejs/plugin-react": "6.0.1",
69
+ "@workleap/eslint-configs": "2.0.1",
70
+ "@workleap/rslib-configs": "1.1.11",
71
+ "@workleap/typescript-configs": "4.0.0",
71
72
  "eslint": "9.39.2",
72
- "happy-dom": "20.8.3",
73
- "typescript": "5.9.3",
73
+ "happy-dom": "20.8.9",
74
+ "typescript": "6.0.2",
74
75
  "typescript-eslint": "8.54.0",
75
- "vitest": "4.0.18"
76
+ "vitest": "4.1.2"
76
77
  },
77
78
  "sideEffects": false,
78
79
  "scripts": {
@@ -2,24 +2,26 @@ import { useAppRouterState } from "./AppRouterContext.ts";
2
2
 
3
3
  export function useCanUpdateDeferredRegistrations() {
4
4
  const {
5
- areModulesReady,
6
- publicDataUpdatedAt,
7
- protectedDataUpdatedAt,
8
- featureFlagsUpdatedAt,
9
- deferredRegistrationsUpdatedAt
5
+ areModulesReady
6
+ // publicDataUpdatedAt,
7
+ // protectedDataUpdatedAt,
8
+ // featureFlagsUpdatedAt,
9
+ // deferredRegistrationsUpdatedAt
10
10
  } = useAppRouterState();
11
11
 
12
- return (
13
- // Do not trigger an update if the deferred registrations has not been registered yet (if there are deferred registrations, once they are
14
- // registered, the modules will be marked as ready).
15
- areModulesReady
16
- // Make sure the apps is actually having deferred registrations.
17
- && deferredRegistrationsUpdatedAt
18
- // If either the public data or the protected data has been updated, update the deferred registrations.
19
- && (
20
- (publicDataUpdatedAt && publicDataUpdatedAt > deferredRegistrationsUpdatedAt) ||
21
- (protectedDataUpdatedAt && protectedDataUpdatedAt > deferredRegistrationsUpdatedAt) ||
22
- (featureFlagsUpdatedAt && featureFlagsUpdatedAt > deferredRegistrationsUpdatedAt)
23
- )
24
- );
12
+ return areModulesReady;
13
+
14
+ // return !!(
15
+ // // Do not trigger an update if the deferred registrations has not been registered yet (if there are deferred registrations, once they are
16
+ // // registered, the modules will be marked as ready).
17
+ // areModulesReady
18
+ // // Make sure the apps is actually having deferred registrations.
19
+ // // && deferredRegistrationsUpdatedAt
20
+ // // // If either the public data or the protected data has been updated, update the deferred registrations.
21
+ // // && (
22
+ // // (publicDataUpdatedAt && publicDataUpdatedAt > deferredRegistrationsUpdatedAt) ||
23
+ // // (protectedDataUpdatedAt && protectedDataUpdatedAt > deferredRegistrationsUpdatedAt) ||
24
+ // // (featureFlagsUpdatedAt && featureFlagsUpdatedAt > deferredRegistrationsUpdatedAt)
25
+ // // )
26
+ // );
25
27
  }
@@ -1,5 +1,5 @@
1
1
  import { useRuntime, type ModuleRegistrationError } from "@squide/core";
2
- import { useEffect } from "react";
2
+ import { useEffect, useRef } from "react";
3
3
  import { FireflyRuntime } from "./FireflyRuntime.tsx";
4
4
  import { useCanRegisterDeferredRegistrations } from "./useCanRegisterDeferredRegistrations.ts";
5
5
  import { useCanUpdateDeferredRegistrations } from "./useCanUpdateDeferredRegistrations.ts";
@@ -14,6 +14,7 @@ export interface UseDeferredRegistrationsOptions {
14
14
 
15
15
  export function useDeferredRegistrations(data?: unknown, { onError }: UseDeferredRegistrationsOptions = {}) {
16
16
  const runtime = useRuntime() as FireflyRuntime;
17
+ // const isExecutedBecauseModulesAreNowReadyRef = useRef(true);
17
18
 
18
19
  const canRegisterDeferredRegistrations = useCanRegisterDeferredRegistrations();
19
20
  const canUpdateDeferredRegistrations = useCanUpdateDeferredRegistrations();
@@ -35,8 +36,20 @@ export function useDeferredRegistrations(data?: unknown, { onError }: UseDeferre
35
36
  }
36
37
  }, [canRegisterDeferredRegistrations, registerDeferredRegistrations, data, onError]);
37
38
 
39
+ const isInitialUpdateDeferredRegistrationsExecution = useRef(true);
40
+
38
41
  useEffect(() => {
39
42
  if (canUpdateDeferredRegistrations) {
43
+ // HACK: Skipping the first execution successfully passing the gate because this is due to
44
+ // the modules being ready, and it's most certainly the same data that has been forwarded earlier to the deferred registration.
45
+ // Ideally, instead of this hacky ref, it would be a ref tracking the previous data object, and the deferred registration would
46
+ // only be updated if the current data object != than the previous data object. Sadly, it is not possible because
47
+ // of the feature flags.
48
+ if (isInitialUpdateDeferredRegistrationsExecution.current) {
49
+ isInitialUpdateDeferredRegistrationsExecution.current = false;
50
+ return;
51
+ }
52
+
40
53
  const update = async () => {
41
54
  const errors = await updateDeferredRegistrations(data);
42
55