@squide/firefly 10.0.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/AppRouter.d.ts +2 -1
  3. package/dist/AppRouter.js +29 -14
  4. package/dist/AppRouter.js.map +1 -1
  5. package/dist/AppRouterReducer.d.ts +3 -1
  6. package/dist/AppRouterReducer.js +12 -10
  7. package/dist/AppRouterReducer.js.map +1 -1
  8. package/dist/AppRouterStore.d.ts +13 -0
  9. package/dist/AppRouterStore.js +158 -0
  10. package/dist/AppRouterStore.js.map +1 -0
  11. package/dist/FireflyProvider.d.ts +6 -0
  12. package/dist/FireflyProvider.js +21 -0
  13. package/dist/FireflyProvider.js.map +1 -0
  14. package/dist/FireflyRuntime.d.ts +2 -0
  15. package/dist/FireflyRuntime.js +9 -0
  16. package/dist/FireflyRuntime.js.map +1 -1
  17. package/dist/index.d.ts +4 -1
  18. package/dist/index.js +7 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/initializeFirefly.d.ts +15 -0
  21. package/dist/initializeFirefly.js +78 -0
  22. package/dist/initializeFirefly.js.map +1 -0
  23. package/dist/useCanFetchProtectedData.d.ts +2 -0
  24. package/dist/useCanFetchProtectedData.js +10 -5
  25. package/dist/useCanFetchProtectedData.js.map +1 -1
  26. package/dist/useIsBootstrapping.d.ts +1 -1
  27. package/dist/useIsBootstrapping.js +3 -3
  28. package/dist/useIsBootstrapping.js.map +1 -1
  29. package/dist/useProtectedDataHandler.d.ts +1 -0
  30. package/dist/useProtectedDataHandler.js +25 -0
  31. package/dist/useProtectedDataHandler.js.map +1 -0
  32. package/dist/usePublicDataHandler.d.ts +1 -0
  33. package/dist/usePublicDataHandler.js +25 -0
  34. package/dist/usePublicDataHandler.js.map +1 -0
  35. package/package.json +5 -5
  36. package/src/AppRouter.tsx +31 -13
  37. package/src/AppRouterReducer.ts +16 -10
  38. package/src/AppRouterStore.ts +171 -0
  39. package/src/FireflyProvider.tsx +19 -0
  40. package/src/FireflyRuntime.tsx +8 -0
  41. package/src/index.ts +4 -1
  42. package/src/initializeFirefly.ts +95 -0
  43. package/src/useCanFetchProtectedData.ts +28 -12
  44. package/src/useIsBootstrapping.ts +2 -2
  45. package/src/useProtectedDataHandler.ts +12 -0
  46. package/src/usePublicDataHandler.ts +12 -0
  47. package/dist/boostrap.d.ts +0 -15
  48. package/dist/boostrap.js +0 -54
  49. package/dist/boostrap.js.map +0 -1
  50. package/src/boostrap.ts +0 -62
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "@squide/core";
2
2
  export * from "@squide/module-federation";
3
3
  export * from "@squide/msw";
4
4
  export * from "@squide/react-router";
5
+ export * from "./FireflyProvider.tsx";
5
6
  export * from "./FireflyRuntime.tsx";
6
7
  export * from "./AppRouter.tsx";
7
8
  export * from "./AppRouterContext.ts";
@@ -15,9 +16,11 @@ export * from "./useDeferredRegistrations.ts";
15
16
  export * from "./useIsActiveRouteProtected.ts";
16
17
  export * from "./useIsBootstrapping.ts";
17
18
  export * from "./useNavigationItems.ts";
19
+ export * from "./useProtectedDataHandler.ts";
18
20
  export * from "./useProtectedDataQueries.ts";
21
+ export * from "./usePublicDataHandler.ts";
19
22
  export * from "./usePublicDataQueries.ts";
20
23
  export * from "./useRegisterDeferredRegistrations.ts";
21
24
  export * from "./useStrictRegistrationMode.ts";
22
25
  export * from "./useUpdateDeferredRegistrations.ts";
23
- export * from "./boostrap.ts";
26
+ export * from "./initializeFirefly.ts";
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ export * from "@squide/core";
2
2
  export * from "@squide/module-federation";
3
3
  export * from "@squide/msw";
4
4
  export * from "@squide/react-router";
5
+ export * from "./FireflyProvider.js";
5
6
  export * from "./FireflyRuntime.js";
6
7
  export * from "./AppRouter.js";
7
8
  export * from "./AppRouterContext.js";
@@ -15,12 +16,14 @@ export * from "./useDeferredRegistrations.js";
15
16
  export * from "./useIsActiveRouteProtected.js";
16
17
  export * from "./useIsBootstrapping.js";
17
18
  export * from "./useNavigationItems.js";
19
+ export * from "./useProtectedDataHandler.js";
18
20
  export * from "./useProtectedDataQueries.js";
21
+ export * from "./usePublicDataHandler.js";
19
22
  export * from "./usePublicDataQueries.js";
20
23
  export * from "./useRegisterDeferredRegistrations.js";
21
24
  export * from "./useStrictRegistrationMode.js";
22
25
  export * from "./useUpdateDeferredRegistrations.js";
23
- export * from "./boostrap.js";
26
+ export * from "./initializeFirefly.js";
24
27
 
25
28
  ;// CONCATENATED MODULE: ./src/index.ts?__rslib_entry__
26
29
 
@@ -44,6 +47,9 @@ export * from "./boostrap.js";
44
47
 
45
48
 
46
49
 
50
+
51
+
52
+
47
53
 
48
54
 
49
55
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["webpack://@squide/firefly/./src/index.ts"],"sourcesContent":["export * from \"@squide/core\";\nexport * from \"@squide/module-federation\";\nexport * from \"@squide/msw\";\nexport * from \"@squide/react-router\";\n\nexport * from \"./FireflyRuntime.tsx\";\n\nexport * from \"./AppRouter.tsx\";\nexport * from \"./AppRouterContext.ts\";\nexport * from \"./AppRouterReducer.ts\";\n\nexport * from \"./GlobalDataQueriesError.ts\";\nexport * from \"./useCanFetchProtectedData.ts\";\nexport * from \"./useCanFetchPublicData.ts\";\nexport * from \"./useCanRegisterDeferredRegistrations.ts\";\nexport * from \"./useCanUpdateDeferredRegistrations.ts\";\nexport * from \"./useDeferredRegistrations.ts\";\nexport * from \"./useIsActiveRouteProtected.ts\";\nexport * from \"./useIsBootstrapping.ts\";\nexport * from \"./useNavigationItems.ts\";\nexport * from \"./useProtectedDataQueries.ts\";\nexport * from \"./usePublicDataQueries.ts\";\nexport * from \"./useRegisterDeferredRegistrations.ts\";\nexport * from \"./useStrictRegistrationMode.ts\";\nexport * from \"./useUpdateDeferredRegistrations.ts\";\n\nexport * from \"./boostrap.ts\";\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAA6B;AACa;AACd;AACS;AAEA;AAEL;AACM;AACA;AAEM;AACE;AACH;AACc;AACF;AACT;AACC;AACP;AACA;AACK;AACH;AACY;AACP;AACK;AAEtB"}
1
+ {"version":3,"file":"index.js","sources":["webpack://@squide/firefly/./src/index.ts"],"sourcesContent":["export * from \"@squide/core\";\nexport * from \"@squide/module-federation\";\nexport * from \"@squide/msw\";\nexport * from \"@squide/react-router\";\n\nexport * from \"./FireflyProvider.tsx\";\nexport * from \"./FireflyRuntime.tsx\";\n\nexport * from \"./AppRouter.tsx\";\nexport * from \"./AppRouterContext.ts\";\nexport * from \"./AppRouterReducer.ts\";\n\nexport * from \"./GlobalDataQueriesError.ts\";\nexport * from \"./useCanFetchProtectedData.ts\";\nexport * from \"./useCanFetchPublicData.ts\";\nexport * from \"./useCanRegisterDeferredRegistrations.ts\";\nexport * from \"./useCanUpdateDeferredRegistrations.ts\";\nexport * from \"./useDeferredRegistrations.ts\";\nexport * from \"./useIsActiveRouteProtected.ts\";\nexport * from \"./useIsBootstrapping.ts\";\nexport * from \"./useNavigationItems.ts\";\nexport * from \"./useProtectedDataHandler.ts\";\nexport * from \"./useProtectedDataQueries.ts\";\nexport * from \"./usePublicDataHandler.ts\";\nexport * from \"./usePublicDataQueries.ts\";\nexport * from \"./useRegisterDeferredRegistrations.ts\";\nexport * from \"./useStrictRegistrationMode.ts\";\nexport * from \"./useUpdateDeferredRegistrations.ts\";\n\nexport * from \"./initializeFirefly.ts\";\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA6B;AACa;AACd;AACS;AAEC;AACD;AAEL;AACM;AACA;AAEM;AACE;AACH;AACc;AACF;AACT;AACC;AACP;AACA;AACK;AACA;AACH;AACA;AACY;AACP;AACK;AAEb"}
@@ -0,0 +1,15 @@
1
+ import { type ModuleRegisterFunction, type RegisterModulesOptions } from "@squide/core";
2
+ import { type RemoteDefinition } from "@squide/module-federation";
3
+ import { FireflyRuntime, type FireflyRuntimeOptions } from "./FireflyRuntime.tsx";
4
+ export declare const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
5
+ export type OnInitializationErrorFunction = (error: unknown) => void;
6
+ export type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;
7
+ export interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {
8
+ localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];
9
+ remotes?: RemoteDefinition[];
10
+ startMsw?: StartMswFunction<FireflyRuntime>;
11
+ onError?: OnInitializationErrorFunction;
12
+ }
13
+ export declare function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options?: InitializeFireflyOptions<TRuntime, TContext, TData>): void;
14
+ export declare function initializeFirefly<TContext = unknown, TData = unknown>(options?: InitializeFireflyOptions<FireflyRuntime, TContext, TData>): FireflyRuntime;
15
+ export declare function __resetHasExecuteGuard(): void;
@@ -0,0 +1,78 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__ from "@squide/core";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_module_federation_054d2ec6__ from "@squide/module-federation";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__squide_msw_9f7e76df__ from "@squide/msw";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__FireflyRuntime_js_318ddfd4__ from "./FireflyRuntime.js";
5
+
6
+ ;// CONCATENATED MODULE: external "@squide/core"
7
+
8
+ ;// CONCATENATED MODULE: external "@squide/module-federation"
9
+
10
+ ;// CONCATENATED MODULE: external "@squide/msw"
11
+
12
+ ;// CONCATENATED MODULE: external "./FireflyRuntime.js"
13
+
14
+ ;// CONCATENATED MODULE: ./src/initializeFirefly.ts?__rslib_entry__
15
+
16
+
17
+
18
+
19
+ const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
20
+ function propagateRegistrationErrors(results, onError) {
21
+ if (results) {
22
+ if (results.status === "fulfilled") {
23
+ results.value.forEach((x)=>{
24
+ onError(x);
25
+ });
26
+ }
27
+ }
28
+ }
29
+ function bootstrap(runtime, options = {}) {
30
+ const { localModules = [], remotes = [], startMsw, onError, context } = options;
31
+ runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);
32
+ Promise.allSettled([
33
+ (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.registerLocalModules)(localModules, runtime, {
34
+ context
35
+ }),
36
+ (0,__WEBPACK_EXTERNAL_MODULE__squide_module_federation_054d2ec6__.registerRemoteModules)(remotes, runtime, {
37
+ context
38
+ })
39
+ ]).then((results)=>{
40
+ if (runtime.isMswEnabled) {
41
+ if (!(0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.isFunction)(startMsw)) {
42
+ throw new Error("[squide] When MSW is enabled, the \"startMsw\" function must be provided.");
43
+ }
44
+ startMsw(runtime).then(()=>{
45
+ (0,__WEBPACK_EXTERNAL_MODULE__squide_msw_9f7e76df__.setMswAsReady)();
46
+ }).catch((error)=>{
47
+ runtime.logger.debug("[squide] An error occured while starting MSW.", error);
48
+ });
49
+ }
50
+ if (onError) {
51
+ propagateRegistrationErrors(results[0], onError);
52
+ propagateRegistrationErrors(results[1], onError);
53
+ }
54
+ });
55
+ }
56
+ let hasExecuted = false;
57
+ function initializeFirefly(options = {}) {
58
+ const { mode, useMsw, loggers, plugins } = options;
59
+ if (hasExecuted) {
60
+ throw new Error("[squide] A squide application can only be initialized once. Did you call the \"initializeSquide\" function twice?");
61
+ }
62
+ hasExecuted = true;
63
+ const runtime = new __WEBPACK_EXTERNAL_MODULE__FireflyRuntime_js_318ddfd4__.FireflyRuntime({
64
+ mode,
65
+ useMsw,
66
+ loggers,
67
+ plugins
68
+ });
69
+ bootstrap(runtime, options);
70
+ return runtime;
71
+ }
72
+ function __resetHasExecuteGuard() {
73
+ hasExecuted = false;
74
+ }
75
+
76
+ export { ApplicationBootstrappingStartedEvent, __resetHasExecuteGuard, bootstrap, initializeFirefly };
77
+
78
+ //# sourceMappingURL=initializeFirefly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initializeFirefly.js","sources":["webpack://@squide/firefly/./src/initializeFirefly.ts"],"sourcesContent":["import { isFunction, registerLocalModules, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { registerRemoteModules, type RemoteDefinition } from \"@squide/module-federation\";\nimport { setMswAsReady } from \"@squide/msw\";\nimport { FireflyRuntime, type FireflyRuntimeOptions } from \"./FireflyRuntime.tsx\";\n\nexport const ApplicationBootstrappingStartedEvent = \"squide-app-bootstrapping-started\";\n\nexport type OnInitializationErrorFunction = (error: unknown) => void;\n\nexport type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {\n localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];\n remotes?: RemoteDefinition[];\n startMsw?: StartMswFunction<FireflyRuntime>;\n onError?: OnInitializationErrorFunction;\n}\n\nfunction propagateRegistrationErrors(results: PromiseSettledResult<unknown[]>, onError: OnInitializationErrorFunction) {\n if (results) {\n if (results.status === \"fulfilled\") {\n results.value.forEach(x => {\n onError(x);\n });\n }\n }\n}\n\nexport function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options: InitializeFireflyOptions<TRuntime, TContext, TData> = {}) {\n const {\n localModules = [],\n remotes = [],\n startMsw,\n onError,\n context\n } = options;\n\n runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);\n\n Promise.allSettled([\n registerLocalModules<TRuntime, TContext, TData>(localModules, runtime, { context }),\n registerRemoteModules(remotes, runtime, { context })\n ]).then(results => {\n if (runtime.isMswEnabled) {\n if (!isFunction(startMsw)) {\n throw new Error(\"[squide] When MSW is enabled, the \\\"startMsw\\\" function must be provided.\");\n }\n\n startMsw(runtime)\n .then(() => {\n setMswAsReady();\n })\n .catch((error: unknown) => {\n runtime.logger.debug(\"[squide] An error occured while starting MSW.\", error);\n });\n }\n\n if (onError) {\n propagateRegistrationErrors(results[0], onError);\n propagateRegistrationErrors(results[1], onError);\n }\n });\n}\n\nlet hasExecuted = false;\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n mode,\n useMsw,\n loggers,\n plugins\n } = options;\n\n if (hasExecuted) {\n throw new Error(\"[squide] A squide application can only be initialized once. Did you call the \\\"initializeSquide\\\" function twice?\");\n }\n\n hasExecuted = true;\n\n const runtime = new FireflyRuntime({\n mode,\n useMsw,\n loggers,\n plugins\n });\n\n bootstrap(runtime, options);\n\n return runtime;\n}\n\nexport function __resetHasExecuteGuard() {\n hasExecuted = false;\n}\n"],"names":["isFunction","registerLocalModules","registerRemoteModules","setMswAsReady","FireflyRuntime","ApplicationBootstrappingStartedEvent","propagateRegistrationErrors","results","onError","x","bootstrap","runtime","options","localModules","remotes","startMsw","context","Promise","Error","error","hasExecuted","initializeFirefly","mode","useMsw","loggers","plugins","__resetHasExecuteGuard"],"mappings":";;;;;;;;;;;;;;AAA0H;AACjC;AAC7C;AACsC;AAE3E,MAAMK,uCAAuC,mCAAmC;AAavF,SAASC,4BAA4BC,OAAwC,EAAEC,OAAsC;IACjH,IAAID,SAAS;QACT,IAAIA,QAAQ,MAAM,KAAK,aAAa;YAChCA,QAAQ,KAAK,CAAC,OAAO,CAACE,CAAAA;gBAClBD,QAAQC;YACZ;QACJ;IACJ;AACJ;AAEO,SAASC,UAAiGC,OAAiB,EAAEC,UAA+D,CAAC,CAAC;IACjM,MAAM,EACFC,eAAe,EAAE,EACjBC,UAAU,EAAE,EACZC,QAAQ,EACRP,OAAO,EACPQ,OAAO,EACV,GAAGJ;IAEJD,QAAQ,QAAQ,CAAC,QAAQ,CAACN;IAE1BY,QAAQ,UAAU,CAAC;QACfhB,0EAAoBA,CAA4BY,cAAcF,SAAS;YAAEK;QAAQ;QACjFd,wFAAqBA,CAACY,SAASH,SAAS;YAAEK;QAAQ;KACrD,EAAE,IAAI,CAACT,CAAAA;QACJ,IAAII,QAAQ,YAAY,EAAE;YACtB,IAAI,CAACX,gEAAUA,CAACe,WAAW;gBACvB,MAAM,IAAIG,MAAM;YACpB;YAEAH,SAASJ,SACJ,IAAI,CAAC;gBACFR,kEAAaA;YACjB,GACC,KAAK,CAAC,CAACgB;gBACJR,QAAQ,MAAM,CAAC,KAAK,CAAC,iDAAiDQ;YAC1E;QACR;QAEA,IAAIX,SAAS;YACTF,4BAA4BC,OAAO,CAAC,EAAE,EAAEC;YACxCF,4BAA4BC,OAAO,CAAC,EAAE,EAAEC;QAC5C;IACJ;AACJ;AAEA,IAAIY,cAAc;AAEX,SAASC,kBAAuDT,UAAqE,CAAC,CAAC;IAC1I,MAAM,EACFU,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,OAAO,EACV,GAAGb;IAEJ,IAAIQ,aAAa;QACb,MAAM,IAAIF,MAAM;IACpB;IAEAE,cAAc;IAEd,MAAMT,UAAU,IAAIP,sEAAcA,CAAC;QAC/BkB;QACAC;QACAC;QACAC;IACJ;IAEAf,UAAUC,SAASC;IAEnB,OAAOD;AACX;AAEO,SAASe;IACZN,cAAc;AAClB"}
@@ -1 +1,3 @@
1
+ import type { ActiveRouteVisiblity } from "./AppRouterReducer.ts";
2
+ export declare function canFetchProtectedData(waitForMsw: boolean, areModulesRegistered: boolean, areModulesReady: boolean, activeRouteVisibility: ActiveRouteVisiblity, isMswReady: boolean): boolean;
1
3
  export declare function useCanFetchProtectedData(): boolean;
@@ -4,14 +4,19 @@ import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__ from "./Ap
4
4
 
5
5
  ;// CONCATENATED MODULE: ./src/useCanFetchProtectedData.ts?__rslib_entry__
6
6
 
7
- function useCanFetchProtectedData() {
8
- const { waitForMsw, areModulesRegistered, areModulesReady, isMswReady, isProtectedDataReady, activeRouteVisibility } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterState)();
9
- return(// Always return true when the protected data has already been fetched sucessfully so TanStack Query can update the data in the background.
10
- isProtectedDataReady || // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered as they will probably
7
+ // This function is exported for external integration, like the integration
8
+ // with the Platform Widgets. Do not remove.
9
+ function canFetchProtectedData(waitForMsw, areModulesRegistered, areModulesReady, activeRouteVisibility, isMswReady) {
10
+ return(// Wait until the modules has been registered, but do not wait for the deferred registrations to be registered as they will probably
11
11
  // depends on the protected data.
12
12
  (areModulesRegistered || areModulesReady) && activeRouteVisibility === "protected" && (!waitForMsw || isMswReady));
13
13
  }
14
+ function useCanFetchProtectedData() {
15
+ const { waitForMsw, areModulesRegistered, areModulesReady, isMswReady, isProtectedDataReady, activeRouteVisibility } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterState)();
16
+ // Always return true when the protected data has already been fetched sucessfully so TanStack Query can update the data in the background.
17
+ return isProtectedDataReady || canFetchProtectedData(waitForMsw, areModulesRegistered, areModulesReady, activeRouteVisibility, isMswReady);
18
+ }
14
19
 
15
- export { useCanFetchProtectedData };
20
+ export { canFetchProtectedData, useCanFetchProtectedData };
16
21
 
17
22
  //# sourceMappingURL=useCanFetchProtectedData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCanFetchProtectedData.js","sources":["webpack://@squide/firefly/./src/useCanFetchProtectedData.ts"],"sourcesContent":["import { useAppRouterState } from \"./AppRouterContext.ts\";\n\nexport function useCanFetchProtectedData() {\n const {\n waitForMsw,\n areModulesRegistered,\n areModulesReady,\n isMswReady,\n isProtectedDataReady,\n activeRouteVisibility\n } = useAppRouterState();\n\n return (\n // Always return true when the protected data has already been fetched sucessfully so TanStack Query can update the data in the background.\n isProtectedDataReady\n || (\n // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered as they will probably\n // depends on the protected data.\n (areModulesRegistered || areModulesReady)\n // Only fetch the protected data for protected routes, aka do not fetch the protected data for public routes.\n && activeRouteVisibility === \"protected\"\n // Wait for MSW since the endpoints for the protected data might be an MSW endpoint when in development.\n && (!waitForMsw || isMswReady)\n )\n );\n}\n"],"names":["useAppRouterState","useCanFetchProtectedData","waitForMsw","areModulesRegistered","areModulesReady","isMswReady","isProtectedDataReady","activeRouteVisibility"],"mappings":";;;;;AAA0D;AAEnD,SAASC;IACZ,MAAM,EACFC,UAAU,EACVC,oBAAoB,EACpBC,eAAe,EACfC,UAAU,EACVC,oBAAoB,EACpBC,qBAAqB,EACxB,GAAGP,+EAAiBA;IAErB,OACI,2IAA2I;IAC3IM,wBAEI,oIAAoI;IACpI,iCAAiC;IAChCH,CAAAA,wBAAwBC,eAAc,KAEpCG,0BAA0B,eAEzB,EAACL,cAAcG,UAAS;AAGxC"}
1
+ {"version":3,"file":"useCanFetchProtectedData.js","sources":["webpack://@squide/firefly/./src/useCanFetchProtectedData.ts"],"sourcesContent":["import { useAppRouterState } from \"./AppRouterContext.ts\";\nimport type { ActiveRouteVisiblity } from \"./AppRouterReducer.ts\";\n\n// This function is exported for external integration, like the integration\n// with the Platform Widgets. Do not remove.\nexport function canFetchProtectedData(\n waitForMsw: boolean,\n areModulesRegistered: boolean,\n areModulesReady: boolean,\n activeRouteVisibility: ActiveRouteVisiblity,\n isMswReady: boolean\n) {\n return (\n // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered as they will probably\n // depends on the protected data.\n (areModulesRegistered || areModulesReady)\n // Only fetch the protected data for protected routes, aka do not fetch the protected data for public routes.\n && activeRouteVisibility === \"protected\"\n // Wait for MSW since the endpoints for the protected data might be an MSW endpoint when in development.\n && (!waitForMsw || isMswReady)\n );\n}\n\nexport function useCanFetchProtectedData() {\n const {\n waitForMsw,\n areModulesRegistered,\n areModulesReady,\n isMswReady,\n isProtectedDataReady,\n activeRouteVisibility\n } = useAppRouterState();\n\n // Always return true when the protected data has already been fetched sucessfully so TanStack Query can update the data in the background.\n return isProtectedDataReady || canFetchProtectedData(\n waitForMsw,\n areModulesRegistered,\n areModulesReady,\n activeRouteVisibility,\n isMswReady\n );\n}\n"],"names":["useAppRouterState","canFetchProtectedData","waitForMsw","areModulesRegistered","areModulesReady","activeRouteVisibility","isMswReady","useCanFetchProtectedData","isProtectedDataReady"],"mappings":";;;;;AAA0D;AAG1D,2EAA2E;AAC3E,4CAA4C;AACrC,SAASC,sBACZC,UAAmB,EACnBC,oBAA6B,EAC7BC,eAAwB,EACxBC,qBAA2C,EAC3CC,UAAmB;IAEnB,OACI,oIAAoI;IACpI,iCAAiC;IAChCH,CAAAA,wBAAwBC,eAAc,KAEpCC,0BAA0B,eAEzB,EAACH,cAAcI,UAAS;AAEpC;AAEO,SAASC;IACZ,MAAM,EACFL,UAAU,EACVC,oBAAoB,EACpBC,eAAe,EACfE,UAAU,EACVE,oBAAoB,EACpBH,qBAAqB,EACxB,GAAGL,+EAAiBA;IAErB,2IAA2I;IAC3I,OAAOQ,wBAAwBP,sBAC3BC,YACAC,sBACAC,iBACAC,uBACAC;AAER"}
@@ -1,3 +1,3 @@
1
1
  import type { AppRouterState } from "./AppRouterReducer.ts";
2
2
  export declare function useIsBootstrapping(): boolean;
3
- export declare function isApplicationBootstrapping(state: AppRouterState): boolean;
3
+ export declare function isBootstrapping(state: AppRouterState): boolean;
@@ -6,9 +6,9 @@ import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__ from "./Ap
6
6
 
7
7
  function useIsBootstrapping() {
8
8
  const state = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterState)();
9
- return isApplicationBootstrapping(state);
9
+ return isBootstrapping(state);
10
10
  }
11
- function isApplicationBootstrapping(state) {
11
+ function isBootstrapping(state) {
12
12
  const { waitForMsw, waitForPublicData, waitForProtectedData, areModulesReady, isMswReady, isPublicDataReady, isProtectedDataReady, activeRouteVisibility, isUnauthorized } = state;
13
13
  const isAppReady = !isUnauthorized && areModulesReady && (!waitForMsw || isMswReady) && (!waitForPublicData || isPublicDataReady) && (!waitForProtectedData || activeRouteVisibility === "public" || isProtectedDataReady);
14
14
  // When an API request returns a 401, the bootstrapping should be bypassed to render the login page.
@@ -17,6 +17,6 @@ function isApplicationBootstrapping(state) {
17
17
  return !isAppReady && !flush;
18
18
  }
19
19
 
20
- export { isApplicationBootstrapping, useIsBootstrapping };
20
+ export { isBootstrapping, useIsBootstrapping };
21
21
 
22
22
  //# sourceMappingURL=useIsBootstrapping.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIsBootstrapping.js","sources":["webpack://@squide/firefly/./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 isApplicationBootstrapping(state);\n}\n\nexport function isApplicationBootstrapping(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","isApplicationBootstrapping","waitForMsw","waitForPublicData","waitForProtectedData","areModulesReady","isMswReady","isPublicDataReady","isProtectedDataReady","activeRouteVisibility","isUnauthorized","isAppReady","flush"],"mappings":";;;;;AAA0D;AAGnD,SAASC;IACZ,MAAMC,QAAQF,+EAAiBA;IAE/B,OAAOG,2BAA2BD;AACtC;AAEO,SAASC,2BAA2BD,KAAqB;IAC5D,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":["webpack://@squide/firefly/./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,+EAAiBA;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"}
@@ -0,0 +1 @@
1
+ export declare function useProtectedDataHandler(handler: () => void): void;
@@ -0,0 +1,25 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__useCanFetchProtectedData_js_52158d16__ from "./useCanFetchProtectedData.js";
3
+
4
+ ;// CONCATENATED MODULE: external "react"
5
+
6
+ ;// CONCATENATED MODULE: external "./useCanFetchProtectedData.js"
7
+
8
+ ;// CONCATENATED MODULE: ./src/useProtectedDataHandler.ts?__rslib_entry__
9
+
10
+
11
+ function useProtectedDataHandler(handler) {
12
+ const canFetchProtectedData = (0,__WEBPACK_EXTERNAL_MODULE__useCanFetchProtectedData_js_52158d16__.useCanFetchProtectedData)();
13
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
14
+ if (canFetchProtectedData) {
15
+ handler();
16
+ }
17
+ }, [
18
+ canFetchProtectedData,
19
+ handler
20
+ ]);
21
+ }
22
+
23
+ export { useProtectedDataHandler };
24
+
25
+ //# sourceMappingURL=useProtectedDataHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProtectedDataHandler.js","sources":["webpack://@squide/firefly/./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,8FAAwBA;IAEtDD,+CAASA,CAAC;QACN,IAAII,uBAAuB;YACvBD;QACJ;IACJ,GAAG;QAACC;QAAuBD;KAAQ;AACvC"}
@@ -0,0 +1 @@
1
+ export declare function usePublicDataHandler(handler: () => void): void;
@@ -0,0 +1,25 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__useCanFetchPublicData_js_b8d90132__ from "./useCanFetchPublicData.js";
3
+
4
+ ;// CONCATENATED MODULE: external "react"
5
+
6
+ ;// CONCATENATED MODULE: external "./useCanFetchPublicData.js"
7
+
8
+ ;// CONCATENATED MODULE: ./src/usePublicDataHandler.ts?__rslib_entry__
9
+
10
+
11
+ function usePublicDataHandler(handler) {
12
+ const canFetchPublicData = (0,__WEBPACK_EXTERNAL_MODULE__useCanFetchPublicData_js_b8d90132__.useCanFetchPublicData)();
13
+ (0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
14
+ if (canFetchPublicData) {
15
+ handler();
16
+ }
17
+ }, [
18
+ canFetchPublicData,
19
+ handler
20
+ ]);
21
+ }
22
+
23
+ export { usePublicDataHandler };
24
+
25
+ //# sourceMappingURL=usePublicDataHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePublicDataHandler.js","sources":["webpack://@squide/firefly/./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,wFAAqBA;IAEhDD,+CAASA,CAAC;QACN,IAAII,oBAAoB;YACpBD;QACJ;IACJ,GAAG;QAACC;QAAoBD;KAAQ;AACpC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "10.0.1",
4
+ "version": "12.0.0",
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": {
@@ -37,10 +37,10 @@
37
37
  "dependencies": {
38
38
  "@types/react": "19.0.10",
39
39
  "@types/react-dom": "19.0.4",
40
- "@squide/core": "5.4.3",
41
- "@squide/module-federation": "6.2.3",
42
- "@squide/msw": "3.2.3",
43
- "@squide/react-router": "7.0.1"
40
+ "@squide/core": "5.4.5",
41
+ "@squide/module-federation": "6.2.5",
42
+ "@squide/react-router": "7.0.3",
43
+ "@squide/msw": "3.2.5"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@rsbuild/core": "1.2.19",
package/src/AppRouter.tsx CHANGED
@@ -3,7 +3,7 @@ import { useRoutes, type Route } from "@squide/react-router";
3
3
  import { useEffect, useMemo, type ReactElement } from "react";
4
4
  import type { RouterProviderProps } from "react-router/dom";
5
5
  import { AppRouterDispatcherContext, AppRouterStateContext } from "./AppRouterContext.ts";
6
- import { useAppRouterReducer } from "./AppRouterReducer.ts";
6
+ import { useAppRouterReducer, type AppRouterState } from "./AppRouterReducer.ts";
7
7
  import { RootRoute } from "./RootRoute.tsx";
8
8
  import { useStrictRegistrationMode } from "./useStrictRegistrationMode.ts";
9
9
 
@@ -19,8 +19,35 @@ export interface RenderRouterProviderFunctionArgs {
19
19
 
20
20
  export type RenderRouterProviderFunction = (args: RenderRouterProviderFunctionArgs) => ReactElement;
21
21
 
22
+ export function useCanRenderRouter({ areModulesRegistered, areModulesReady: areModulesReadyValue }: AppRouterState) {
23
+ return (
24
+ // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered has they will probably
25
+ // depends on the protected data.
26
+ (areModulesRegistered || areModulesReadyValue)
27
+ );
28
+ }
29
+
30
+ function useRenderRouterProvider(state: AppRouterState, renderRouterProvider: RenderRouterProviderFunction) {
31
+ const routes = useRoutes();
32
+
33
+ // The value is computed outside of the router provider memo to prevent
34
+ // rendering a new router provider everytime the app router state change.
35
+ const canRenderRouter = useCanRenderRouter(state);
36
+
37
+ return useMemo(() => {
38
+ if (canRenderRouter) {
39
+ return renderRouterProvider({
40
+ rootRoute: <RootRoute />,
41
+ registeredRoutes: routes,
42
+ routerProviderProps: {}
43
+ });
44
+ }
45
+
46
+ return null;
47
+ }, [canRenderRouter, routes, renderRouterProvider]);
48
+ }
49
+
22
50
  export interface AppRouterProps {
23
- waitForMsw: boolean;
24
51
  waitForPublicData?: boolean;
25
52
  waitForProtectedData?: boolean;
26
53
  children: RenderRouterProviderFunction;
@@ -28,16 +55,13 @@ export interface AppRouterProps {
28
55
 
29
56
  export function AppRouter(props: AppRouterProps) {
30
57
  const {
31
- waitForMsw,
32
58
  waitForPublicData = false,
33
59
  waitForProtectedData = false,
34
60
  children: renderRouterProvider
35
61
  } = props;
36
-
37
- const [state, dispatch] = useAppRouterReducer(waitForMsw, waitForPublicData, waitForProtectedData);
62
+ const [state, dispatch] = useAppRouterReducer(waitForPublicData, waitForProtectedData);
38
63
 
39
64
  const logger = useLogger();
40
- const routes = useRoutes();
41
65
 
42
66
  useStrictRegistrationMode();
43
67
 
@@ -45,13 +69,7 @@ export function AppRouter(props: AppRouterProps) {
45
69
  logger.debug("[squide] AppRouter state updated:", state);
46
70
  }, [state, logger]);
47
71
 
48
- const routerProvider = useMemo(() => {
49
- return renderRouterProvider({
50
- rootRoute: <RootRoute />,
51
- registeredRoutes: routes,
52
- routerProviderProps: {}
53
- });
54
- }, [routes, renderRouterProvider]);
72
+ const routerProvider = useRenderRouterProvider(state, renderRouterProvider);
55
73
 
56
74
  return (
57
75
  <AppRouterDispatcherContext.Provider value={dispatch}>
@@ -1,9 +1,10 @@
1
- import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useEventBus, useLogger } from "@squide/core";
1
+ import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useEventBus, useLogger, useRuntime } from "@squide/core";
2
2
  import { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, areModulesRegistered, getRemoteModuleRegistrationStatus, removeRemoteModuleRegistrationStatusChangedListener } from "@squide/module-federation";
3
3
  import { addMswStateChangedListener, isMswReady, removeMswStateChangedListener } from "@squide/msw";
4
4
  import { useCallback, useEffect, useMemo, useReducer, type Dispatch } from "react";
5
+ import type { FireflyRuntime } from "./FireflyRuntime.tsx";
5
6
  import { useExecuteOnce } from "./useExecuteOnce.ts";
6
- import { isApplicationBootstrapping } from "./useIsBootstrapping.ts";
7
+ import { isBootstrapping } from "./useIsBootstrapping.ts";
7
8
 
8
9
  export type ActiveRouteVisiblity = "unknown" | "public" | "protected";
9
10
 
@@ -41,6 +42,8 @@ export type AppRouterActionType =
41
42
  export const ModulesRegisteredEvent = "squide-modules-registered";
42
43
  export const ModulesReadyEvent = "squide-modules-ready";
43
44
  export const MswReadyEvent = "squide-msw-ready";
45
+ export const ActiveRouteIsPublicEvent = "squide-active-route-is-public";
46
+ export const ActiveRouteIsProtectedEvent = "squide-active-route-is-protected";
44
47
  export const PublicDataReadyEvent = "squide-public-data-ready";
45
48
  export const ProtectedDataReadyEvent = "squide-protected-data-ready";
46
49
  export const PublicDataUpdatedEvent = "squide-public-data-updated";
@@ -250,7 +253,7 @@ export function useBootstrappingCompletedDispatcher(state: AppRouterState) {
250
253
  const eventBus = useEventBus();
251
254
 
252
255
  const areModulesRegisteredValue = state.areModulesRegistered;
253
- const isBoostrapping = isApplicationBootstrapping(state);
256
+ const isBoostrapping = isBootstrapping(state);
254
257
 
255
258
  useExecuteOnce(useCallback(() => {
256
259
  if (areModulesRegisteredValue && !isBoostrapping) {
@@ -282,18 +285,21 @@ function useReducerDispatchProxy(reactDispatch: AppRouterDispatch) {
282
285
  }
283
286
 
284
287
  function useEnhancedReducerDispatch(reducerDispatch: AppRouterDispatch) {
285
- const logger = useLogger();
286
- const eventBus = useEventBus();
288
+ const runtime = useRuntime() as FireflyRuntime;
287
289
 
288
290
  return useCallback((action: AppRouterAction) => {
289
- logger.debug("[squide] The following action has been dispatched to the AppRouter reducer:", action);
290
- eventBus.dispatch(`squide-${action.type}`);
291
+ runtime.logger.debug("[squide] The following action has been dispatched to the AppRouter reducer:", action);
292
+
293
+ runtime.appRouterStore.dispatch(action);
294
+ runtime.eventBus.dispatch(`squide-${action.type}`);
291
295
 
292
296
  reducerDispatch(action);
293
- }, [reducerDispatch, logger, eventBus]);
297
+ }, [reducerDispatch, runtime]);
294
298
  }
295
299
 
296
- export function useAppRouterReducer(waitForMsw: boolean, waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {
300
+ export function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {
301
+ const runtime = useRuntime() as FireflyRuntime;
302
+
297
303
  const areModulesInitiallyRegistered = getAreModulesRegistered();
298
304
  const areModulesInitiallyReady = getAreModulesReady();
299
305
  const isMswInitiallyReady = isMswReady();
@@ -331,7 +337,7 @@ export function useAppRouterReducer(waitForMsw: boolean, waitForPublicData: bool
331
337
  }, [isMswInitiallyReady, eventBus]), true);
332
338
 
333
339
  const [state, reactDispatch] = useReducer(reducer, {
334
- waitForMsw,
340
+ waitForMsw: runtime.isMswEnabled,
335
341
  waitForPublicData,
336
342
  waitForProtectedData,
337
343
  // When the modules registration functions are awaited, the event listeners are registered after the modules are registered.