@squide/firefly 9.3.1 → 9.3.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 (67) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/AppRouter.d.ts +8 -12
  3. package/dist/AppRouter.js +66 -8
  4. package/dist/AppRouterContext.d.ts +5 -9
  5. package/dist/AppRouterContext.js +28 -1
  6. package/dist/AppRouterReducer.d.ts +23 -26
  7. package/dist/AppRouterReducer.js +337 -4
  8. package/dist/FireflyRuntime.d.ts +5 -8
  9. package/dist/FireflyRuntime.js +64 -5
  10. package/dist/GlobalDataQueriesError.d.ts +2 -4
  11. package/dist/GlobalDataQueriesError.js +17 -1
  12. package/dist/RootRoute.d.ts +1 -5
  13. package/dist/RootRoute.js +46 -3
  14. package/dist/boostrap.d.ts +8 -13
  15. package/dist/boostrap.js +52 -1
  16. package/dist/index.d.ts +23 -28
  17. package/dist/index.js +49 -25
  18. package/dist/useCanFetchProtectedData.d.ts +1 -3
  19. package/dist/useCanFetchProtectedData.js +15 -2
  20. package/dist/useCanFetchPublicData.d.ts +1 -3
  21. package/dist/useCanFetchPublicData.js +15 -2
  22. package/dist/useCanRegisterDeferredRegistrations.d.ts +1 -3
  23. package/dist/useCanRegisterDeferredRegistrations.js +12 -2
  24. package/dist/useCanUpdateDeferredRegistrations.d.ts +1 -3
  25. package/dist/useCanUpdateDeferredRegistrations.js +14 -2
  26. package/dist/useDeferredRegistrations.d.ts +5 -8
  27. package/dist/useDeferredRegistrations.js +72 -6
  28. package/dist/useExecuteOnce.d.ts +1 -3
  29. package/dist/useExecuteOnce.js +27 -1
  30. package/dist/useIsActiveRouteProtected.d.ts +1 -3
  31. package/dist/useIsActiveRouteProtected.js +21 -1
  32. package/dist/useIsBootstrapping.d.ts +3 -7
  33. package/dist/useIsBootstrapping.js +20 -2
  34. package/dist/useNavigationItems.d.ts +3 -7
  35. package/dist/useNavigationItems.js +24 -2
  36. package/dist/useProtectedDataQueries.d.ts +6 -8
  37. package/dist/useProtectedDataQueries.js +124 -5
  38. package/dist/usePublicDataQueries.d.ts +5 -7
  39. package/dist/usePublicDataQueries.js +109 -5
  40. package/dist/useRegisterDeferredRegistrations.d.ts +4 -9
  41. package/dist/useRegisterDeferredRegistrations.js +17 -1
  42. package/dist/useStrictRegistrationMode.d.ts +1 -3
  43. package/dist/useStrictRegistrationMode.js +38 -1
  44. package/dist/useUpdateDeferredRegistrations.d.ts +4 -9
  45. package/dist/useUpdateDeferredRegistrations.js +28 -2
  46. package/package.json +25 -22
  47. package/dist/chunk-4RUCDAUT.js +0 -18
  48. package/dist/chunk-BFHHJOJT.js +0 -41
  49. package/dist/chunk-CTLPFYLM.js +0 -65
  50. package/dist/chunk-G32YX2KR.js +0 -22
  51. package/dist/chunk-GXSW4CZS.js +0 -9
  52. package/dist/chunk-H2ILEMPE.js +0 -28
  53. package/dist/chunk-HE5HKFL3.js +0 -16
  54. package/dist/chunk-IOMSOUAL.js +0 -20
  55. package/dist/chunk-JFMSLZ74.js +0 -253
  56. package/dist/chunk-L44KFU57.js +0 -34
  57. package/dist/chunk-LC233OPR.js +0 -54
  58. package/dist/chunk-MKTGJHQR.js +0 -71
  59. package/dist/chunk-N2GOIQ5E.js +0 -14
  60. package/dist/chunk-PMVN3U47.js +0 -21
  61. package/dist/chunk-PP3MRMJJ.js +0 -11
  62. package/dist/chunk-ROE2YHN5.js +0 -44
  63. package/dist/chunk-TURKCH7J.js +0 -20
  64. package/dist/chunk-WOPD33CM.js +0 -25
  65. package/dist/chunk-WVRMJZV6.js +0 -18
  66. package/dist/chunk-XDWYPVAJ.js +0 -21
  67. package/dist/chunk-YRWFYWK4.js +0 -11
@@ -1,2 +1,24 @@
1
- export { useNavigationItems } from './chunk-GXSW4CZS.js';
2
- import './chunk-G32YX2KR.js';
1
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_react_router__ from "@squide/react-router";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
3
+
4
+ ;// CONCATENATED MODULE: external "@squide/react-router"
5
+
6
+ ;// CONCATENATED MODULE: external "./AppRouterContext.js"
7
+
8
+ ;// CONCATENATED MODULE: ./src/useNavigationItems.ts?__rslib_entry__
9
+
10
+
11
+ function useNavigationItems(options) {
12
+ // This is not the most sophisticated strategy but it seems to be good enough for now.
13
+ // The idea is that when deferred registrations are used by the consumer applications, the deferred registrations could
14
+ // be updated when the global data is updated. If the deferred registrations are updated, it means that the registered
15
+ // navigation items might have been updated and a re-render must happens to display the new navigation items.
16
+ // Since the "deferredRegistrationsUpdatedAt" state value of the AppRouterReducer is updated everytime the deferred registrations
17
+ // are updated, subscribing to the state with useAppRouterState ensure that the navigation items will be re-rendered.
18
+ // A more sophisticated strategy could be implemented later on if needed, something involving a subscription to the "runtime" changes, or
19
+ // even introducing new module states.
20
+ (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterState)();
21
+ return (0,__WEBPACK_EXTERNAL_MODULE__squide_react_router__.useRuntimeNavigationItems)(options);
22
+ }
23
+
24
+ export { useNavigationItems };
@@ -1,11 +1,9 @@
1
- import { QueriesOptions, QueriesResults, UseQueryResult } from '@tanstack/react-query';
2
-
3
- declare const ProtectedDataFetchStartedEvent = "squide-protected-data-fetch-started";
4
- declare const ProtectedDataFetchFailedEvent = "squide-protected-data-fetch-failed";
5
- type IsUnauthorizedErrorCallback = (error: unknown) => boolean;
1
+ import { type QueriesOptions, type QueriesResults, type UseQueryResult } from "@tanstack/react-query";
2
+ export declare const ProtectedDataFetchStartedEvent = "squide-protected-data-fetch-started";
3
+ export declare const ProtectedDataFetchFailedEvent = "squide-protected-data-fetch-failed";
4
+ export type IsUnauthorizedErrorCallback = (error: unknown) => boolean;
6
5
  type MapUseQueryResultToData<T> = {
7
6
  [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never;
8
7
  };
9
- declare function useProtectedDataQueries<T extends Array<any>>(queries: QueriesOptions<T>, isUnauthorizedError: IsUnauthorizedErrorCallback): MapUseQueryResultToData<QueriesResults<T>>;
10
-
11
- export { type IsUnauthorizedErrorCallback, ProtectedDataFetchFailedEvent, ProtectedDataFetchStartedEvent, useProtectedDataQueries };
8
+ export declare function useProtectedDataQueries<T extends Array<any>>(queries: QueriesOptions<T>, isUnauthorizedError: IsUnauthorizedErrorCallback): MapUseQueryResultToData<QueriesResults<T>>;
9
+ export {};
@@ -1,5 +1,124 @@
1
- export { ProtectedDataFetchFailedEvent, ProtectedDataFetchStartedEvent, useProtectedDataQueries } from './chunk-MKTGJHQR.js';
2
- import './chunk-XDWYPVAJ.js';
3
- import './chunk-TURKCH7J.js';
4
- import './chunk-HE5HKFL3.js';
5
- import './chunk-G32YX2KR.js';
1
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_core__ from "@squide/core";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__tanstack_react_query__ from "@tanstack/react-query";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__GlobalDataQueriesError_js__ from "./GlobalDataQueriesError.js";
6
+ import * as __WEBPACK_EXTERNAL_MODULE__useCanFetchProtectedData_js__ from "./useCanFetchProtectedData.js";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js__ from "./useExecuteOnce.js";
8
+
9
+ ;// CONCATENATED MODULE: external "@squide/core"
10
+
11
+ ;// CONCATENATED MODULE: external "@tanstack/react-query"
12
+
13
+ ;// CONCATENATED MODULE: external "react"
14
+
15
+ ;// CONCATENATED MODULE: external "./AppRouterContext.js"
16
+
17
+ ;// CONCATENATED MODULE: external "./GlobalDataQueriesError.js"
18
+
19
+ ;// CONCATENATED MODULE: external "./useCanFetchProtectedData.js"
20
+
21
+ ;// CONCATENATED MODULE: external "./useExecuteOnce.js"
22
+
23
+ ;// CONCATENATED MODULE: ./src/useProtectedDataQueries.ts?__rslib_entry__
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ const ProtectedDataFetchStartedEvent = "squide-protected-data-fetch-started";
32
+ const ProtectedDataFetchFailedEvent = "squide-protected-data-fetch-failed";
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ function useProtectedDataQueries(queries, isUnauthorizedError) {
35
+ const canFetchProtectedData = (0,__WEBPACK_EXTERNAL_MODULE__useCanFetchProtectedData_js__.useCanFetchProtectedData)();
36
+ const eventBus = (0,__WEBPACK_EXTERNAL_MODULE__squide_core__.useEventBus)();
37
+ const dispatch = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterDispatcher)();
38
+ const combineResults = (0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)((results)=>{
39
+ const errors = results.filter((x)=>x.error).map((x)=>x.error);
40
+ const hasErrors = errors.length > 0;
41
+ return {
42
+ data: results.map((x)=>x.data),
43
+ errors,
44
+ hasErrors,
45
+ isReady: !hasErrors && !results.some((x)=>x.isPending)
46
+ };
47
+ }, []);
48
+ const { data, errors: queriesErrors, hasErrors, isReady } = (0,__WEBPACK_EXTERNAL_MODULE__tanstack_react_query__.useQueries)({
49
+ queries: queries.map((x)=>({
50
+ enabled: canFetchProtectedData,
51
+ ...x
52
+ })),
53
+ combine: combineResults
54
+ });
55
+ const { isProtectedDataReady, isUnauthorized } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterState)();
56
+ (0,__WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js__.useExecuteOnce)((0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
57
+ if (canFetchProtectedData) {
58
+ eventBus.dispatch(ProtectedDataFetchStartedEvent);
59
+ return true;
60
+ }
61
+ return false;
62
+ }, [
63
+ canFetchProtectedData,
64
+ eventBus
65
+ ]), true);
66
+ // Using a ref seems to be the only way to prevent starting two deferred registrations scope.
67
+ const isReadyRef = (0,__WEBPACK_EXTERNAL_MODULE_react__.useRef)(false);
68
+ const dispatchReady = (0,__WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js__.useExecuteOnce)((0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
69
+ if (isReady) {
70
+ isReadyRef.current = true;
71
+ dispatch({
72
+ type: "protected-data-ready"
73
+ });
74
+ return true;
75
+ }
76
+ return false;
77
+ }, [
78
+ isReady,
79
+ dispatch
80
+ ]));
81
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
82
+ // State update must be executed in useEffect.
83
+ dispatchReady();
84
+ }, [
85
+ dispatchReady
86
+ ]);
87
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
88
+ if (isReadyRef.current && data) {
89
+ dispatch({
90
+ type: "protected-data-updated"
91
+ });
92
+ }
93
+ }, [
94
+ data,
95
+ dispatch
96
+ ]);
97
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
98
+ if (hasErrors) {
99
+ if (!isProtectedDataReady && !isUnauthorized && queriesErrors.some((x)=>isUnauthorizedError(x))) {
100
+ // Will transition the state to allow the routes to render even if the bootstrapping is not complete, because otherwise
101
+ // a login page for example could not be rendered.
102
+ dispatch({
103
+ type: "is-unauthorized"
104
+ });
105
+ }
106
+ // Otherwise, when a user is logged off, a refetch might throws a 401.
107
+ if (!queriesErrors.every((x)=>isUnauthorizedError(x))) {
108
+ eventBus.dispatch(ProtectedDataFetchFailedEvent, queriesErrors);
109
+ throw new __WEBPACK_EXTERNAL_MODULE__GlobalDataQueriesError_js__.GlobalDataQueriesError("[squide] Global protected data queries failed.", queriesErrors);
110
+ }
111
+ }
112
+ }, [
113
+ hasErrors,
114
+ queriesErrors,
115
+ isProtectedDataReady,
116
+ isUnauthorized,
117
+ isUnauthorizedError,
118
+ dispatch,
119
+ eventBus
120
+ ]);
121
+ return data;
122
+ }
123
+
124
+ export { ProtectedDataFetchFailedEvent, ProtectedDataFetchStartedEvent, useProtectedDataQueries };
@@ -1,10 +1,8 @@
1
- import { QueriesOptions, QueriesResults, UseQueryResult } from '@tanstack/react-query';
2
-
3
- declare const PublicDataFetchStartedEvent = "squide-public-data-fetch-started";
4
- declare const PublicDataFetchFailedEvent = "squide-public-data-fetch-failed";
1
+ import { type QueriesOptions, type QueriesResults, type UseQueryResult } from "@tanstack/react-query";
2
+ export declare const PublicDataFetchStartedEvent = "squide-public-data-fetch-started";
3
+ export declare const PublicDataFetchFailedEvent = "squide-public-data-fetch-failed";
5
4
  type MapUseQueryResultToData<T> = {
6
5
  [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never;
7
6
  };
8
- declare function usePublicDataQueries<T extends Array<any>>(queries: QueriesOptions<T>): MapUseQueryResultToData<QueriesResults<T>>;
9
-
10
- export { PublicDataFetchFailedEvent, PublicDataFetchStartedEvent, usePublicDataQueries };
7
+ export declare function usePublicDataQueries<T extends Array<any>>(queries: QueriesOptions<T>): MapUseQueryResultToData<QueriesResults<T>>;
8
+ export {};
@@ -1,5 +1,109 @@
1
- export { PublicDataFetchFailedEvent, PublicDataFetchStartedEvent, usePublicDataQueries } from './chunk-CTLPFYLM.js';
2
- import './chunk-IOMSOUAL.js';
3
- import './chunk-TURKCH7J.js';
4
- import './chunk-HE5HKFL3.js';
5
- import './chunk-G32YX2KR.js';
1
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_core__ from "@squide/core";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__tanstack_react_query__ from "@tanstack/react-query";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__GlobalDataQueriesError_js__ from "./GlobalDataQueriesError.js";
6
+ import * as __WEBPACK_EXTERNAL_MODULE__useCanFetchPublicData_js__ from "./useCanFetchPublicData.js";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js__ from "./useExecuteOnce.js";
8
+
9
+ ;// CONCATENATED MODULE: external "@squide/core"
10
+
11
+ ;// CONCATENATED MODULE: external "@tanstack/react-query"
12
+
13
+ ;// CONCATENATED MODULE: external "react"
14
+
15
+ ;// CONCATENATED MODULE: external "./AppRouterContext.js"
16
+
17
+ ;// CONCATENATED MODULE: external "./GlobalDataQueriesError.js"
18
+
19
+ ;// CONCATENATED MODULE: external "./useCanFetchPublicData.js"
20
+
21
+ ;// CONCATENATED MODULE: external "./useExecuteOnce.js"
22
+
23
+ ;// CONCATENATED MODULE: ./src/usePublicDataQueries.ts?__rslib_entry__
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ const PublicDataFetchStartedEvent = "squide-public-data-fetch-started";
32
+ const PublicDataFetchFailedEvent = "squide-public-data-fetch-failed";
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ function usePublicDataQueries(queries) {
35
+ const canFetchPublicData = (0,__WEBPACK_EXTERNAL_MODULE__useCanFetchPublicData_js__.useCanFetchPublicData)();
36
+ const eventBus = (0,__WEBPACK_EXTERNAL_MODULE__squide_core__.useEventBus)();
37
+ const dispatch = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterDispatcher)();
38
+ const combineResults = (0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)((results)=>{
39
+ const errors = results.filter((x)=>x.error).map((x)=>x.error);
40
+ const hasErrors = errors.length > 0;
41
+ return {
42
+ data: results.map((x)=>x.data),
43
+ errors,
44
+ hasErrors,
45
+ isReady: !hasErrors && !results.some((x)=>x.isPending)
46
+ };
47
+ }, []);
48
+ const { data, errors: queriesErrors, hasErrors, isReady } = (0,__WEBPACK_EXTERNAL_MODULE__tanstack_react_query__.useQueries)({
49
+ queries: queries.map((x)=>({
50
+ enabled: canFetchPublicData,
51
+ ...x
52
+ })),
53
+ combine: combineResults
54
+ });
55
+ (0,__WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js__.useExecuteOnce)((0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
56
+ if (canFetchPublicData) {
57
+ eventBus.dispatch(PublicDataFetchStartedEvent);
58
+ return true;
59
+ }
60
+ return false;
61
+ }, [
62
+ canFetchPublicData,
63
+ eventBus
64
+ ]), true);
65
+ // Using a ref seems to be the only way to prevent starting two deferred registrations scope.
66
+ const isReadyRef = (0,__WEBPACK_EXTERNAL_MODULE_react__.useRef)(false);
67
+ const dispatchReady = (0,__WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js__.useExecuteOnce)((0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
68
+ if (isReady) {
69
+ isReadyRef.current = true;
70
+ dispatch({
71
+ type: "public-data-ready"
72
+ });
73
+ return true;
74
+ }
75
+ return false;
76
+ }, [
77
+ isReady,
78
+ dispatch
79
+ ]));
80
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
81
+ // State update must be executed in useEffect.
82
+ dispatchReady();
83
+ }, [
84
+ dispatchReady
85
+ ]);
86
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
87
+ if (isReadyRef.current && data) {
88
+ dispatch({
89
+ type: "public-data-updated"
90
+ });
91
+ }
92
+ }, [
93
+ data,
94
+ dispatch
95
+ ]);
96
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
97
+ if (hasErrors) {
98
+ eventBus.dispatch(PublicDataFetchFailedEvent, queriesErrors);
99
+ throw new __WEBPACK_EXTERNAL_MODULE__GlobalDataQueriesError_js__.GlobalDataQueriesError("[squide] Global public data queries failed.", queriesErrors);
100
+ }
101
+ }, [
102
+ hasErrors,
103
+ queriesErrors,
104
+ eventBus
105
+ ]);
106
+ return data;
107
+ }
108
+
109
+ export { PublicDataFetchFailedEvent, PublicDataFetchStartedEvent, usePublicDataQueries };
@@ -1,10 +1,5 @@
1
- import * as _squide_module_federation from '@squide/module-federation';
2
- import * as _squide_core from '@squide/core';
3
- import { Runtime } from '@squide/core';
4
-
5
- declare function useRegisterDeferredRegistrations(): <TData = unknown, TRuntime extends Runtime = Runtime<unknown, unknown>>(data: TData, runtime: TRuntime) => Promise<{
6
- localModuleErrors: _squide_core.ModuleRegistrationError[];
7
- remoteModuleErrors: _squide_module_federation.RemoteModuleRegistrationError[];
1
+ import type { Runtime } from "@squide/core";
2
+ export declare function useRegisterDeferredRegistrations(): <TData = unknown, TRuntime extends Runtime = Runtime<unknown, unknown>>(data: TData, runtime: TRuntime) => Promise<{
3
+ localModuleErrors: import("@squide/core").ModuleRegistrationError[];
4
+ remoteModuleErrors: import("@squide/module-federation").RemoteModuleRegistrationError[];
8
5
  }>;
9
-
10
- export { useRegisterDeferredRegistrations };
@@ -1 +1,17 @@
1
- export { useRegisterDeferredRegistrations } from './chunk-YRWFYWK4.js';
1
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_module_federation__ from "@squide/module-federation";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
3
+
4
+ ;// CONCATENATED MODULE: external "@squide/module-federation"
5
+
6
+ ;// CONCATENATED MODULE: external "react"
7
+
8
+ ;// CONCATENATED MODULE: ./src/useRegisterDeferredRegistrations.ts?__rslib_entry__
9
+
10
+
11
+ function useRegisterDeferredRegistrations() {
12
+ return (0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)((data, runtime)=>{
13
+ return (0,__WEBPACK_EXTERNAL_MODULE__squide_module_federation__.registerDeferredRegistrations)(data, runtime);
14
+ }, []);
15
+ }
16
+
17
+ export { useRegisterDeferredRegistrations };
@@ -1,3 +1 @@
1
- declare function useStrictRegistrationMode(): void;
2
-
3
- export { useStrictRegistrationMode };
1
+ export declare function useStrictRegistrationMode(): void;
@@ -1 +1,38 @@
1
- export { useStrictRegistrationMode } from './chunk-WOPD33CM.js';
1
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_core__ from "@squide/core";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_module_federation__ from "@squide/module-federation";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
4
+
5
+ ;// CONCATENATED MODULE: external "@squide/core"
6
+
7
+ ;// CONCATENATED MODULE: external "@squide/module-federation"
8
+
9
+ ;// CONCATENATED MODULE: external "react"
10
+
11
+ ;// CONCATENATED MODULE: ./src/useStrictRegistrationMode.ts?__rslib_entry__
12
+
13
+
14
+
15
+ function subscribeToLocalModuleRegistrationStatusChanged(callback) {
16
+ (0,__WEBPACK_EXTERNAL_MODULE__squide_core__.addLocalModuleRegistrationStatusChangedListener)(callback);
17
+ return ()=>(0,__WEBPACK_EXTERNAL_MODULE__squide_core__.removeLocalModuleRegistrationStatusChangedListener)(callback);
18
+ }
19
+ function subscribeToRemoteModuleRegistrationStatusChanged(callback) {
20
+ (0,__WEBPACK_EXTERNAL_MODULE__squide_module_federation__.addRemoteModuleRegistrationStatusChangedListener)(callback);
21
+ return ()=>(0,__WEBPACK_EXTERNAL_MODULE__squide_module_federation__.removeRemoteModuleRegistrationStatusChangedListener)(callback);
22
+ }
23
+ function useStrictRegistrationMode() {
24
+ const runtime = (0,__WEBPACK_EXTERNAL_MODULE__squide_core__.useRuntime)();
25
+ const localModuleStatus = (0,__WEBPACK_EXTERNAL_MODULE_react__.useSyncExternalStore)(subscribeToLocalModuleRegistrationStatusChanged, __WEBPACK_EXTERNAL_MODULE__squide_core__.getLocalModuleRegistrationStatus);
26
+ const remoteModuleStatus = (0,__WEBPACK_EXTERNAL_MODULE_react__.useSyncExternalStore)(subscribeToRemoteModuleRegistrationStatusChanged, __WEBPACK_EXTERNAL_MODULE__squide_module_federation__.getRemoteModuleRegistrationStatus);
27
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
28
+ if ((0,__WEBPACK_EXTERNAL_MODULE__squide_module_federation__.areModulesReady)(localModuleStatus, remoteModuleStatus)) {
29
+ runtime._validateRegistrations();
30
+ }
31
+ }, [
32
+ runtime,
33
+ localModuleStatus,
34
+ remoteModuleStatus
35
+ ]);
36
+ }
37
+
38
+ export { useStrictRegistrationMode };
@@ -1,10 +1,5 @@
1
- import * as _squide_module_federation from '@squide/module-federation';
2
- import * as _squide_core from '@squide/core';
3
- import { Runtime } from '@squide/core';
4
-
5
- declare function useUpdateDeferredRegistrations(): <TData = unknown, TRuntime extends Runtime = Runtime<unknown, unknown>>(data: TData, runtime: TRuntime) => Promise<{
6
- localModuleErrors: _squide_core.ModuleRegistrationError[];
7
- remoteModuleErrors: _squide_module_federation.RemoteModuleRegistrationError[];
1
+ import type { Runtime } from "@squide/core";
2
+ export declare function useUpdateDeferredRegistrations(): <TData = unknown, TRuntime extends Runtime = Runtime<unknown, unknown>>(data: TData, runtime: TRuntime) => Promise<{
3
+ localModuleErrors: import("@squide/core").ModuleRegistrationError[];
4
+ remoteModuleErrors: import("@squide/module-federation").RemoteModuleRegistrationError[];
8
5
  }>;
9
-
10
- export { useUpdateDeferredRegistrations };
@@ -1,2 +1,28 @@
1
- export { useUpdateDeferredRegistrations } from './chunk-N2GOIQ5E.js';
2
- import './chunk-G32YX2KR.js';
1
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_module_federation__ from "@squide/module-federation";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
4
+
5
+ ;// CONCATENATED MODULE: external "@squide/module-federation"
6
+
7
+ ;// CONCATENATED MODULE: external "react"
8
+
9
+ ;// CONCATENATED MODULE: external "./AppRouterContext.js"
10
+
11
+ ;// CONCATENATED MODULE: ./src/useUpdateDeferredRegistrations.ts?__rslib_entry__
12
+
13
+
14
+
15
+ function useUpdateDeferredRegistrations() {
16
+ const dispatch = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterDispatcher)();
17
+ return (0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(async (data, runtime)=>{
18
+ const errors = await (0,__WEBPACK_EXTERNAL_MODULE__squide_module_federation__.updateDeferredRegistrations)(data, runtime);
19
+ dispatch({
20
+ type: "deferred-registrations-updated"
21
+ });
22
+ return errors;
23
+ }, [
24
+ dispatch
25
+ ]);
26
+ }
27
+
28
+ export { useUpdateDeferredRegistrations };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "9.3.1",
4
+ "version": "9.3.2",
5
5
  "description": "Helpers to facilitate the creation of an application with the Squide firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -9,11 +9,11 @@
9
9
  "url": "git+https://github.com/gsoft-inc/wl-squide.git",
10
10
  "directory": "packages/firefly"
11
11
  },
12
+ "type": "module",
12
13
  "publishConfig": {
13
14
  "access": "public",
14
15
  "provenance": true
15
16
  },
16
- "type": "module",
17
17
  "exports": {
18
18
  ".": {
19
19
  "types": "./dist/index.d.ts",
@@ -33,41 +33,44 @@
33
33
  "react-dom": "*",
34
34
  "react-router-dom": "*"
35
35
  },
36
+ "dependencies": {
37
+ "@types/react": "19.0.1",
38
+ "@types/react-dom": "19.0.2",
39
+ "@squide/core": "5.4.1",
40
+ "@squide/module-federation": "6.2.1",
41
+ "@squide/msw": "3.2.1",
42
+ "@squide/react-router": "6.4.2"
43
+ },
36
44
  "devDependencies": {
37
- "@swc/core": "1.8.0",
45
+ "@rsbuild/plugin-react": "1.1.0",
46
+ "@rslib/core": "0.1.4",
47
+ "@swc/core": "1.10.1",
38
48
  "@swc/jest": "0.2.37",
39
49
  "@testing-library/jest-dom": "6.6.3",
40
- "@testing-library/react": "16.0.1",
50
+ "@testing-library/react": "16.1.0",
41
51
  "@types/jest": "29.5.14",
42
- "@types/react": "18.3.12",
43
- "@types/react-dom": "18.3.1",
44
- "@workleap/eslint-plugin": "3.2.3",
52
+ "@typescript-eslint/parser": "8.18.0",
53
+ "@workleap/eslint-plugin": "3.2.5",
45
54
  "@workleap/swc-configs": "2.2.3",
46
- "@workleap/tsup-configs": "3.0.6",
47
55
  "@workleap/typescript-configs": "3.0.2",
48
56
  "eslint": "8.57.0",
49
57
  "jest": "29.7.0",
50
58
  "jest-environment-jsdom": "29.7.0",
51
- "msw": "2.5.2",
52
- "react": "18.3.1",
53
- "react-dom": "18.3.1",
59
+ "msw": "2.6.9",
60
+ "react": "19.0.0",
61
+ "react-dom": "19.0.0",
54
62
  "react-router-dom": "6.27.0",
55
- "ts-jest": "29.2.5",
56
- "tsup": "8.3.5",
63
+ "ts-node": "10.9.2",
57
64
  "typescript": "5.5.4"
58
65
  },
59
- "dependencies": {
60
- "@squide/core": "5.4.1",
61
- "@squide/module-federation": "6.2.1",
62
- "@squide/msw": "3.2.1",
63
- "@squide/react-router": "6.4.1"
64
- },
65
66
  "sideEffects": false,
66
67
  "engines": {
67
- "node": ">=20.0.0"
68
+ "node": ">=21.1.0"
68
69
  },
69
70
  "scripts": {
70
- "dev": "tsup --config ./tsup.dev.ts",
71
- "build": "tsup --config ./tsup.build.ts"
71
+ "build": "rslib build --config ./rslib.build.ts",
72
+ "eslint": "eslint . --max-warnings=-0 --cache --cache-location node_modules/.cache/eslint",
73
+ "typecheck": "tsc",
74
+ "test": "jest"
72
75
  }
73
76
  }
@@ -1,18 +0,0 @@
1
- import { useAppRouterState } from './chunk-G32YX2KR.js';
2
-
3
- // src/useCanRegisterDeferredRegistrations.ts
4
- function useCanRegisterDeferredRegistrations() {
5
- const {
6
- waitForPublicData,
7
- waitForProtectedData,
8
- areModulesReady,
9
- areModulesRegistered,
10
- isPublicDataReady,
11
- isProtectedDataReady,
12
- activeRouteVisibility,
13
- isUnauthorized
14
- } = useAppRouterState();
15
- return !isUnauthorized && areModulesRegistered && !areModulesReady && (!waitForPublicData || isPublicDataReady) && (!waitForProtectedData || activeRouteVisibility === "public" || isProtectedDataReady);
16
- }
17
-
18
- export { useCanRegisterDeferredRegistrations };
@@ -1,41 +0,0 @@
1
- import { useRegisterDeferredRegistrations } from './chunk-YRWFYWK4.js';
2
- import { useUpdateDeferredRegistrations } from './chunk-N2GOIQ5E.js';
3
- import { useCanRegisterDeferredRegistrations } from './chunk-4RUCDAUT.js';
4
- import { useCanUpdateDeferredRegistrations } from './chunk-WVRMJZV6.js';
5
- import { useRuntime } from '@squide/core';
6
- import { useEffect } from 'react';
7
-
8
- function hasError({ localModuleErrors, remoteModuleErrors }) {
9
- return localModuleErrors.length > 0 || remoteModuleErrors.length > 0;
10
- }
11
- function useDeferredRegistrations(data, { onError } = {}) {
12
- const runtime = useRuntime();
13
- const canRegisterDeferredRegistrations = useCanRegisterDeferredRegistrations();
14
- const canUpdateDeferredRegistrations = useCanUpdateDeferredRegistrations();
15
- const registerDeferredRegistrations = useRegisterDeferredRegistrations();
16
- const updateDeferredRegistrations = useUpdateDeferredRegistrations();
17
- useEffect(() => {
18
- if (canRegisterDeferredRegistrations) {
19
- const register = async () => {
20
- const errors = await registerDeferredRegistrations(data, runtime);
21
- if (hasError(errors) && onError) {
22
- onError(errors);
23
- }
24
- };
25
- register();
26
- }
27
- }, [canRegisterDeferredRegistrations, registerDeferredRegistrations, data, onError, runtime]);
28
- useEffect(() => {
29
- if (canUpdateDeferredRegistrations) {
30
- const update = async () => {
31
- const errors = await updateDeferredRegistrations(data, runtime);
32
- if (hasError(errors) && onError) {
33
- onError(errors);
34
- }
35
- };
36
- update();
37
- }
38
- }, [canUpdateDeferredRegistrations, updateDeferredRegistrations, data, onError, runtime]);
39
- }
40
-
41
- export { useDeferredRegistrations };
@@ -1,65 +0,0 @@
1
- import { useCanFetchPublicData } from './chunk-IOMSOUAL.js';
2
- import { useExecuteOnce } from './chunk-TURKCH7J.js';
3
- import { GlobalDataQueriesError } from './chunk-HE5HKFL3.js';
4
- import { useAppRouterDispatcher } from './chunk-G32YX2KR.js';
5
- import { useEventBus } from '@squide/core';
6
- import { useQueries } from '@tanstack/react-query';
7
- import { useCallback, useRef, useEffect } from 'react';
8
-
9
- var PublicDataFetchStartedEvent = "squide-public-data-fetch-started";
10
- var PublicDataFetchFailedEvent = "squide-public-data-fetch-failed";
11
- function usePublicDataQueries(queries) {
12
- const canFetchPublicData = useCanFetchPublicData();
13
- const eventBus = useEventBus();
14
- const dispatch = useAppRouterDispatcher();
15
- const combineResults = useCallback((results) => {
16
- const errors = results.filter((x) => x.error).map((x) => x.error);
17
- const hasErrors2 = errors.length > 0;
18
- return {
19
- data: results.map((x) => x.data),
20
- errors,
21
- hasErrors: hasErrors2,
22
- isReady: !hasErrors2 && !results.some((x) => x.isPending)
23
- };
24
- }, []);
25
- const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({
26
- queries: queries.map((x) => ({
27
- enabled: canFetchPublicData,
28
- ...x
29
- })),
30
- combine: combineResults
31
- });
32
- useExecuteOnce(useCallback(() => {
33
- if (canFetchPublicData) {
34
- eventBus.dispatch(PublicDataFetchStartedEvent);
35
- return true;
36
- }
37
- return false;
38
- }, [canFetchPublicData, eventBus]), true);
39
- const isReadyRef = useRef(false);
40
- const dispatchReady = useExecuteOnce(useCallback(() => {
41
- if (isReady) {
42
- isReadyRef.current = true;
43
- dispatch({ type: "public-data-ready" });
44
- return true;
45
- }
46
- return false;
47
- }, [isReady, dispatch]));
48
- useEffect(() => {
49
- dispatchReady();
50
- }, [dispatchReady]);
51
- useEffect(() => {
52
- if (isReadyRef.current && data) {
53
- dispatch({ type: "public-data-updated" });
54
- }
55
- }, [data, dispatch]);
56
- useEffect(() => {
57
- if (hasErrors) {
58
- eventBus.dispatch(PublicDataFetchFailedEvent, queriesErrors);
59
- throw new GlobalDataQueriesError("[squide] Global public data queries failed.", queriesErrors);
60
- }
61
- }, [hasErrors, queriesErrors, eventBus]);
62
- return data;
63
- }
64
-
65
- export { PublicDataFetchFailedEvent, PublicDataFetchStartedEvent, usePublicDataQueries };