@squide/firefly 12.0.0 → 12.0.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.
- package/CHANGELOG.md +18 -0
- package/dist/AppRouterReducer.js +27 -6
- package/dist/AppRouterReducer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/useAppRouterStore.d.ts +1 -0
- package/dist/useAppRouterStore.js +14 -0
- package/dist/useAppRouterStore.js.map +1 -0
- package/package.json +23 -21
- package/src/AppRouterReducer.ts +16 -10
- package/src/index.ts +1 -0
- package/src/useAppRouterStore.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @squide/firefly
|
|
2
2
|
|
|
3
|
+
## 12.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#256](https://github.com/workleap/wl-squide/pull/256) [`6c4ee56`](https://github.com/workleap/wl-squide/commit/6c4ee5624141a51d6eefd99dd053e81eb5b08e5c) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Update dependencies versioning to the new Workleap's internal guidelines.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6c4ee56`](https://github.com/workleap/wl-squide/commit/6c4ee5624141a51d6eefd99dd053e81eb5b08e5c)]:
|
|
10
|
+
- @squide/module-federation@6.2.6
|
|
11
|
+
- @squide/react-router@7.0.4
|
|
12
|
+
- @squide/core@5.4.6
|
|
13
|
+
- @squide/msw@3.2.6
|
|
14
|
+
|
|
15
|
+
## 12.0.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#252](https://github.com/workleap/wl-squide/pull/252) [`470252f`](https://github.com/workleap/wl-squide/commit/470252f11efe5d84a40e9c60c3bfc13d9f3bf049) Thanks [@patricklafrance](https://github.com/patricklafrance)! - The bootstrapping store wasn't in sync if the modules were initially either "registered" or "ready".
|
|
20
|
+
|
|
3
21
|
## 12.0.0
|
|
4
22
|
|
|
5
23
|
### Major Changes
|
package/dist/AppRouterReducer.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__ from "@squide/core
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__squide_module_federation_054d2ec6__ from "@squide/module-federation";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__squide_msw_9f7e76df__ from "@squide/msw";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useAppRouterStore_js_9635540d__ from "./useAppRouterStore.js";
|
|
5
6
|
import * as __WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js_e1f8f91b__ from "./useExecuteOnce.js";
|
|
6
7
|
import * as __WEBPACK_EXTERNAL_MODULE__useIsBootstrapping_js_642a9b43__ from "./useIsBootstrapping.js";
|
|
7
8
|
|
|
@@ -13,6 +14,8 @@ import * as __WEBPACK_EXTERNAL_MODULE__useIsBootstrapping_js_642a9b43__ from "./
|
|
|
13
14
|
|
|
14
15
|
;// CONCATENATED MODULE: external "react"
|
|
15
16
|
|
|
17
|
+
;// CONCATENATED MODULE: external "./useAppRouterStore.js"
|
|
18
|
+
|
|
16
19
|
;// CONCATENATED MODULE: external "./useExecuteOnce.js"
|
|
17
20
|
|
|
18
21
|
;// CONCATENATED MODULE: external "./useIsBootstrapping.js"
|
|
@@ -24,6 +27,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__useIsBootstrapping_js_642a9b43__ from "./
|
|
|
24
27
|
|
|
25
28
|
|
|
26
29
|
|
|
30
|
+
|
|
27
31
|
// The followings event const are a concatenation of "squide-" with AppRouterActionType.
|
|
28
32
|
// They are dispatched by the useEnhancedReducerDispatch hook.
|
|
29
33
|
const ModulesRegisteredEvent = "squide-modules-registered";
|
|
@@ -259,54 +263,71 @@ function useReducerDispatchProxy(reactDispatch) {
|
|
|
259
263
|
]);
|
|
260
264
|
}
|
|
261
265
|
function useEnhancedReducerDispatch(reducerDispatch) {
|
|
262
|
-
const
|
|
266
|
+
const logger = (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.useLogger)();
|
|
267
|
+
const appRouterStore = (0,__WEBPACK_EXTERNAL_MODULE__useAppRouterStore_js_9635540d__.useAppRouterStore)();
|
|
268
|
+
const eventBus = (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.useEventBus)();
|
|
263
269
|
return (0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)((action)=>{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
270
|
+
logger.debug("[squide] The following action has been dispatched to the AppRouter reducer:", action);
|
|
271
|
+
appRouterStore.dispatch(action);
|
|
272
|
+
eventBus.dispatch(`squide-${action.type}`);
|
|
267
273
|
reducerDispatch(action);
|
|
268
274
|
}, [
|
|
269
275
|
reducerDispatch,
|
|
270
|
-
|
|
276
|
+
logger,
|
|
277
|
+
appRouterStore,
|
|
278
|
+
eventBus
|
|
271
279
|
]);
|
|
272
280
|
}
|
|
273
281
|
function useAppRouterReducer(waitForPublicData, waitForProtectedData) {
|
|
274
282
|
const runtime = (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.useRuntime)();
|
|
283
|
+
const eventBus = (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.useEventBus)();
|
|
284
|
+
const appRouterStore = (0,__WEBPACK_EXTERNAL_MODULE__useAppRouterStore_js_9635540d__.useAppRouterStore)();
|
|
275
285
|
const areModulesInitiallyRegistered = getAreModulesRegistered();
|
|
276
286
|
const areModulesInitiallyReady = getAreModulesReady();
|
|
277
287
|
const isMswInitiallyReady = (0,__WEBPACK_EXTERNAL_MODULE__squide_msw_9f7e76df__.isMswReady)();
|
|
278
|
-
const eventBus = (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.useEventBus)();
|
|
279
288
|
// When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.
|
|
280
289
|
// To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.
|
|
281
290
|
(0,__WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js_e1f8f91b__.useExecuteOnce)((0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
282
291
|
if (areModulesInitiallyRegistered) {
|
|
292
|
+
appRouterStore.dispatch({
|
|
293
|
+
type: "modules-registered"
|
|
294
|
+
});
|
|
283
295
|
eventBus.dispatch(ModulesRegisteredEvent);
|
|
284
296
|
}
|
|
285
297
|
return true;
|
|
286
298
|
}, [
|
|
287
299
|
areModulesInitiallyRegistered,
|
|
300
|
+
appRouterStore,
|
|
288
301
|
eventBus
|
|
289
302
|
]), true);
|
|
290
303
|
// When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.
|
|
291
304
|
// To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.
|
|
292
305
|
(0,__WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js_e1f8f91b__.useExecuteOnce)((0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
293
306
|
if (areModulesInitiallyReady) {
|
|
307
|
+
appRouterStore.dispatch({
|
|
308
|
+
type: "modules-ready"
|
|
309
|
+
});
|
|
294
310
|
eventBus.dispatch(ModulesReadyEvent);
|
|
295
311
|
}
|
|
296
312
|
return true;
|
|
297
313
|
}, [
|
|
298
314
|
areModulesInitiallyReady,
|
|
315
|
+
appRouterStore,
|
|
299
316
|
eventBus
|
|
300
317
|
]), true);
|
|
301
318
|
// When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.
|
|
302
319
|
// To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.
|
|
303
320
|
(0,__WEBPACK_EXTERNAL_MODULE__useExecuteOnce_js_e1f8f91b__.useExecuteOnce)((0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
304
321
|
if (isMswInitiallyReady) {
|
|
322
|
+
appRouterStore.dispatch({
|
|
323
|
+
type: "msw-ready"
|
|
324
|
+
});
|
|
305
325
|
eventBus.dispatch(MswReadyEvent);
|
|
306
326
|
}
|
|
307
327
|
return true;
|
|
308
328
|
}, [
|
|
309
329
|
isMswInitiallyReady,
|
|
330
|
+
appRouterStore,
|
|
310
331
|
eventBus
|
|
311
332
|
]), true);
|
|
312
333
|
const [state, reactDispatch] = (0,__WEBPACK_EXTERNAL_MODULE_react__.useReducer)(reducer, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouterReducer.js","sources":["webpack://@squide/firefly/./src/AppRouterReducer.ts"],"sourcesContent":["import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useEventBus, useLogger, useRuntime } from \"@squide/core\";\nimport { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, areModulesRegistered, getRemoteModuleRegistrationStatus, removeRemoteModuleRegistrationStatusChangedListener } from \"@squide/module-federation\";\nimport { addMswStateChangedListener, isMswReady, removeMswStateChangedListener } from \"@squide/msw\";\nimport { useCallback, useEffect, useMemo, useReducer, type Dispatch } from \"react\";\nimport type { FireflyRuntime } from \"./FireflyRuntime.tsx\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\nimport { isBootstrapping } from \"./useIsBootstrapping.ts\";\n\nexport type ActiveRouteVisiblity = \"unknown\" | \"public\" | \"protected\";\n\nexport interface AppRouterState {\n waitForMsw: boolean;\n waitForPublicData: boolean;\n waitForProtectedData: boolean;\n areModulesRegistered: boolean;\n areModulesReady: boolean;\n isMswReady: boolean;\n isPublicDataReady: boolean;\n isProtectedDataReady: boolean;\n publicDataUpdatedAt?: number;\n protectedDataUpdatedAt?: number;\n deferredRegistrationsUpdatedAt?: number;\n activeRouteVisibility: ActiveRouteVisiblity;\n isUnauthorized: boolean;\n}\n\nexport type AppRouterActionType =\n| \"modules-registered\"\n| \"modules-ready\"\n| \"msw-ready\"\n| \"public-data-ready\"\n| \"protected-data-ready\"\n| \"public-data-updated\"\n| \"protected-data-updated\"\n| \"deferred-registrations-updated\"\n| \"active-route-is-public\"\n| \"active-route-is-protected\"\n| \"is-unauthorized\";\n\n// The followings event const are a concatenation of \"squide-\" with AppRouterActionType.\n// They are dispatched by the useEnhancedReducerDispatch hook.\nexport const ModulesRegisteredEvent = \"squide-modules-registered\";\nexport const ModulesReadyEvent = \"squide-modules-ready\";\nexport const MswReadyEvent = \"squide-msw-ready\";\nexport const ActiveRouteIsPublicEvent = \"squide-active-route-is-public\";\nexport const ActiveRouteIsProtectedEvent = \"squide-active-route-is-protected\";\nexport const PublicDataReadyEvent = \"squide-public-data-ready\";\nexport const ProtectedDataReadyEvent = \"squide-protected-data-ready\";\nexport const PublicDataUpdatedEvent = \"squide-public-data-updated\";\nexport const ProtectedDataUpdatedEvent = \"squide-protected-data-updated\";\nexport const DeferredRegistrationsUpdatedEvent = \"squide-deferred-registrations-updated\";\nexport const ApplicationBoostrappedEvent = \"squide-app-boostrapped\";\n\nexport interface AppRouterAction {\n type: AppRouterActionType;\n}\n\nexport type AppRouterDispatch = Dispatch<AppRouterAction>;\n\nfunction reducer(state: AppRouterState, action: AppRouterAction) {\n let newState = state;\n\n switch (action.type) {\n case \"modules-registered\": {\n newState = {\n ...newState,\n areModulesRegistered: true\n };\n\n break;\n }\n case \"modules-ready\": {\n newState = {\n ...newState,\n areModulesReady: true,\n // Will be set even if the app is not using deferred registrations.\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"msw-ready\": {\n newState = {\n ...newState,\n isMswReady: true\n };\n\n break;\n }\n case \"public-data-ready\": {\n newState = {\n ...newState,\n isPublicDataReady: true,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-ready\": {\n newState = {\n ...newState,\n isProtectedDataReady: true,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"public-data-updated\": {\n newState = {\n ...newState,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-updated\": {\n newState = {\n ...newState,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"deferred-registrations-updated\": {\n newState = {\n ...newState,\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"active-route-is-public\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"public\"\n };\n\n break;\n }\n case \"active-route-is-protected\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"protected\"\n };\n\n break;\n }\n case \"is-unauthorized\": {\n newState = {\n ...newState,\n isUnauthorized: true\n };\n\n break;\n }\n default: {\n throw new Error(`[squide] The AppRouter component state reducer doesn't support action type \"${action.type}\".`);\n }\n }\n\n return newState;\n}\n\nexport function getAreModulesRegistered() {\n const localModuleStatus = getLocalModuleRegistrationStatus();\n const remoteModuleStatus = getRemoteModuleRegistrationStatus();\n\n return areModulesRegistered(localModuleStatus, remoteModuleStatus);\n}\n\nexport function getAreModulesReady() {\n const localModuleStatus = getLocalModuleRegistrationStatus();\n const remoteModuleStatus = getRemoteModuleRegistrationStatus();\n\n return areModulesReady(localModuleStatus, remoteModuleStatus);\n}\n\nexport function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchModulesRegistered = useExecuteOnce(useCallback(() => {\n if (getAreModulesRegistered()) {\n dispatch({ type: \"modules-registered\" });\n\n logger.debug(\"[squide] %cModules are registered%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n const dispatchModulesReady = useExecuteOnce(useCallback(() => {\n if (getAreModulesReady()) {\n dispatch({ type: \"modules-ready\" });\n\n logger.debug(\"[squide] %cModules are ready%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n return useEffect(() => {\n if (!areModulesRegisteredValue) {\n addLocalModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n addRemoteModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n }\n\n if (!areModulesReadyValue) {\n addLocalModuleRegistrationStatusChangedListener(dispatchModulesReady);\n addRemoteModuleRegistrationStatusChangedListener(dispatchModulesReady);\n }\n\n return () => {\n removeLocalModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n removeRemoteModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n\n removeLocalModuleRegistrationStatusChangedListener(dispatchModulesReady);\n removeRemoteModuleRegistrationStatusChangedListener(dispatchModulesReady);\n };\n }, [areModulesRegisteredValue, areModulesReadyValue, dispatchModulesRegistered, dispatchModulesReady]);\n}\n\nexport function useMswStatusDispatcher(isMswReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchMswReady = useExecuteOnce(useCallback(() => {\n if (isMswReady()) {\n dispatch({ type: \"msw-ready\" });\n\n logger.debug(\"[squide] %cMSW is ready%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n useEffect(() => {\n if (!isMswReadyValue) {\n addMswStateChangedListener(dispatchMswReady);\n }\n\n return () => {\n removeMswStateChangedListener(dispatchMswReady);\n };\n }, [isMswReadyValue, dispatchMswReady]);\n}\n\nexport function useBootstrappingCompletedDispatcher(state: AppRouterState) {\n const eventBus = useEventBus();\n\n const areModulesRegisteredValue = state.areModulesRegistered;\n const isBoostrapping = isBootstrapping(state);\n\n useExecuteOnce(useCallback(() => {\n if (areModulesRegisteredValue && !isBoostrapping) {\n eventBus.dispatch(ApplicationBoostrappedEvent);\n\n return true;\n }\n\n return false;\n }, [areModulesRegisteredValue, isBoostrapping, eventBus]), true);\n}\n\nlet dispatchProxyFactory: ((reactDispatch: AppRouterDispatch) => AppRouterDispatch) | undefined;\n\n// This function should only be used by tests.\nexport function __setAppReducerDispatchProxyFactory(factory: (reactDispatch: AppRouterDispatch) => AppRouterDispatch) {\n dispatchProxyFactory = factory;\n}\n\n// This function should only be used by tests.\nexport function __clearAppReducerDispatchProxy() {\n dispatchProxyFactory = undefined;\n}\n\nfunction useReducerDispatchProxy(reactDispatch: AppRouterDispatch) {\n return useMemo(() => {\n return dispatchProxyFactory ? dispatchProxyFactory(reactDispatch) : reactDispatch;\n }, [reactDispatch]);\n}\n\nfunction useEnhancedReducerDispatch(reducerDispatch: AppRouterDispatch) {\n const runtime = useRuntime() as FireflyRuntime;\n\n return useCallback((action: AppRouterAction) => {\n runtime.logger.debug(\"[squide] The following action has been dispatched to the AppRouter reducer:\", action);\n\n runtime.appRouterStore.dispatch(action);\n runtime.eventBus.dispatch(`squide-${action.type}`);\n\n reducerDispatch(action);\n }, [reducerDispatch, runtime]);\n}\n\nexport function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {\n const runtime = useRuntime() as FireflyRuntime;\n\n const areModulesInitiallyRegistered = getAreModulesRegistered();\n const areModulesInitiallyReady = getAreModulesReady();\n const isMswInitiallyReady = isMswReady();\n\n const eventBus = useEventBus();\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyRegistered) {\n eventBus.dispatch(ModulesRegisteredEvent);\n }\n\n return true;\n }, [areModulesInitiallyRegistered, eventBus]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyReady) {\n eventBus.dispatch(ModulesReadyEvent);\n }\n\n return true;\n }, [areModulesInitiallyReady, eventBus]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (isMswInitiallyReady) {\n eventBus.dispatch(MswReadyEvent);\n }\n\n return true;\n }, [isMswInitiallyReady, eventBus]), true);\n\n const [state, reactDispatch] = useReducer(reducer, {\n waitForMsw: runtime.isMswEnabled,\n waitForPublicData,\n waitForProtectedData,\n // When the modules registration functions are awaited, the event listeners are registered after the modules are registered.\n areModulesRegistered: areModulesInitiallyRegistered,\n areModulesReady: areModulesInitiallyReady,\n isMswReady: isMswInitiallyReady,\n isPublicDataReady: false,\n isProtectedDataReady: false,\n activeRouteVisibility: \"unknown\",\n isUnauthorized: false\n });\n\n const {\n areModulesRegistered: areModulesRegisteredValue,\n areModulesReady: areModulesReadyValue,\n isMswReady: isMswReadyValue\n } = state;\n\n // The dispatch proxy is strictly an utility allowing tests to mock the useReducer dispatch function. It's easier\n // than mocking the import from React.\n const dispatchProxy = useReducerDispatchProxy(reactDispatch);\n const dispatch = useEnhancedReducerDispatch(dispatchProxy);\n\n useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areModulesReadyValue, dispatch);\n useMswStatusDispatcher(isMswReadyValue, dispatch);\n useBootstrappingCompletedDispatcher(state);\n\n return [state, dispatch];\n}\n"],"names":["addLocalModuleRegistrationStatusChangedListener","getLocalModuleRegistrationStatus","removeLocalModuleRegistrationStatusChangedListener","useEventBus","useLogger","useRuntime","addRemoteModuleRegistrationStatusChangedListener","areModulesReady","areModulesRegistered","getRemoteModuleRegistrationStatus","removeRemoteModuleRegistrationStatusChangedListener","addMswStateChangedListener","isMswReady","removeMswStateChangedListener","useCallback","useEffect","useMemo","useReducer","useExecuteOnce","isBootstrapping","ModulesRegisteredEvent","ModulesReadyEvent","MswReadyEvent","ActiveRouteIsPublicEvent","ActiveRouteIsProtectedEvent","PublicDataReadyEvent","ProtectedDataReadyEvent","PublicDataUpdatedEvent","ProtectedDataUpdatedEvent","DeferredRegistrationsUpdatedEvent","ApplicationBoostrappedEvent","reducer","state","action","newState","Date","Error","getAreModulesRegistered","localModuleStatus","remoteModuleStatus","getAreModulesReady","useModuleRegistrationStatusDispatcher","areModulesRegisteredValue","areModulesReadyValue","dispatch","logger","dispatchModulesRegistered","dispatchModulesReady","useMswStatusDispatcher","isMswReadyValue","dispatchMswReady","useBootstrappingCompletedDispatcher","eventBus","isBoostrapping","dispatchProxyFactory","__setAppReducerDispatchProxyFactory","factory","__clearAppReducerDispatchProxy","undefined","useReducerDispatchProxy","reactDispatch","useEnhancedReducerDispatch","reducerDispatch","runtime","useAppRouterReducer","waitForPublicData","waitForProtectedData","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAyM;AACmB;AACxH;AACjB;AAE9B;AACK;AAiC1D,wFAAwF;AACxF,8DAA8D;AACvD,MAAMoB,yBAAyB,4BAA4B;AAC3D,MAAMC,oBAAoB,uBAAuB;AACjD,MAAMC,gBAAgB,mBAAmB;AACzC,MAAMC,2BAA2B,gCAAgC;AACjE,MAAMC,8BAA8B,mCAAmC;AACvE,MAAMC,uBAAuB,2BAA2B;AACxD,MAAMC,0BAA0B,8BAA8B;AAC9D,MAAMC,yBAAyB,6BAA6B;AAC5D,MAAMC,4BAA4B,gCAAgC;AAClE,MAAMC,oCAAoC,wCAAwC;AAClF,MAAMC,8BAA8B,yBAAyB;AAQpE,SAASC,QAAQC,KAAqB,EAAEC,MAAuB;IAC3D,IAAIC,WAAWF;IAEf,OAAQC,OAAO,IAAI;QACf,KAAK;YAAsB;gBACvBC,WAAW;oBACP,GAAGA,QAAQ;oBACX,sBAAsB;gBAC1B;gBAEA;YACJ;QACA,KAAK;YAAiB;gBAClBA,WAAW;oBACP,GAAGA,QAAQ;oBACX,iBAAiB;oBACjB,mEAAmE;oBACnE,gCAAgCC,KAAK,GAAG;gBAC5C;gBAEA;YACJ;QACA,KAAK;YAAa;gBACdD,WAAW;oBACP,GAAGA,QAAQ;oBACX,YAAY;gBAChB;gB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7He,0EAAcA,CAACJ,iDAAWA,CAAC;QACvB,IAAIqD,+BAA+B;YAC/Bf,SAAS,QAAQ,CAAChC;QACtB;QAEA,OAAO;IACX,GAAG;QAAC+C;QAA+Bf;KAAS,GAAG;IAE/C,2IAA2I;IAC3I,6HAA6H;IAC7HlC,0EAAcA,CAACJ,iDAAWA,CAAC;QACvB,IAAIsD,0BAA0B;YAC1BhB,SAAS,QAAQ,CAAC/B;QACtB;QAEA,OAAO;IACX,GAAG;QAAC+C;QAA0BhB;KAAS,GAAG;IAE1C,2IAA2I;IAC3I,6HAA6H;IAC7HlC,0EAAcA,CAACJ,iDAAWA,CAAC;QACvB,IAAIuD,qBAAqB;YACrBjB,SAAS,QAAQ,CAAC9B;QACtB;QAEA,OAAO;IACX,GAAG;QAAC+C;QAAqBjB;KAAS,GAAG;IAErC,MAAM,CAACpB,OAAO4B,cAAc,GAAG3C,gDAAUA,CAACc,SAAS;QAC/C,YAAYgC,QAAQ,YAAY;QAChCE;QACAC;QACA,4HAA4H;QAC5H,sBAAsBC;QACtB,iBAAiBC;QACjB,YAAYC;QACZ,mBAAmB;QACnB,sBAAsB;QACtB,uBAAuB;QACvB,gBAAgB;IACpB;IAEA,MAAM,EACF,sBAAsB3B,yBAAyB,EAC/C,iBAAiBC,oBAAoB,EACrC,YAAYM,eAAe,EAC9B,GAAGjB;IAEJ,iHAAiH;IACjH,sCAAsC;IACtC,MAAMsC,gBAAgBX,wBAAwBC;IAC9C,MAAMhB,WAAWiB,2BAA2BS;IAE5C7B,sCAAsCC,2BAA2BC,sBAAsBC;IACvFI,uBAAuBC,iBAAiBL;IACxCO,oCAAoCnB;IAEpC,OAAO;QAACA;QAAOY;KAAS;AAC5B"}
|
|
1
|
+
{"version":3,"file":"AppRouterReducer.js","sources":["webpack://@squide/firefly/./src/AppRouterReducer.ts"],"sourcesContent":["import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useEventBus, useLogger, useRuntime } from \"@squide/core\";\nimport { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, areModulesRegistered, getRemoteModuleRegistrationStatus, removeRemoteModuleRegistrationStatusChangedListener } from \"@squide/module-federation\";\nimport { addMswStateChangedListener, isMswReady, removeMswStateChangedListener } from \"@squide/msw\";\nimport { useCallback, useEffect, useMemo, useReducer, type Dispatch } from \"react\";\nimport type { FireflyRuntime } from \"./FireflyRuntime.tsx\";\nimport { useAppRouterStore } from \"./useAppRouterStore.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\nimport { isBootstrapping } from \"./useIsBootstrapping.ts\";\n\nexport type ActiveRouteVisiblity = \"unknown\" | \"public\" | \"protected\";\n\nexport interface AppRouterState {\n waitForMsw: boolean;\n waitForPublicData: boolean;\n waitForProtectedData: boolean;\n areModulesRegistered: boolean;\n areModulesReady: boolean;\n isMswReady: boolean;\n isPublicDataReady: boolean;\n isProtectedDataReady: boolean;\n publicDataUpdatedAt?: number;\n protectedDataUpdatedAt?: number;\n deferredRegistrationsUpdatedAt?: number;\n activeRouteVisibility: ActiveRouteVisiblity;\n isUnauthorized: boolean;\n}\n\nexport type AppRouterActionType =\n| \"modules-registered\"\n| \"modules-ready\"\n| \"msw-ready\"\n| \"public-data-ready\"\n| \"protected-data-ready\"\n| \"public-data-updated\"\n| \"protected-data-updated\"\n| \"deferred-registrations-updated\"\n| \"active-route-is-public\"\n| \"active-route-is-protected\"\n| \"is-unauthorized\";\n\n// The followings event const are a concatenation of \"squide-\" with AppRouterActionType.\n// They are dispatched by the useEnhancedReducerDispatch hook.\nexport const ModulesRegisteredEvent = \"squide-modules-registered\";\nexport const ModulesReadyEvent = \"squide-modules-ready\";\nexport const MswReadyEvent = \"squide-msw-ready\";\nexport const ActiveRouteIsPublicEvent = \"squide-active-route-is-public\";\nexport const ActiveRouteIsProtectedEvent = \"squide-active-route-is-protected\";\nexport const PublicDataReadyEvent = \"squide-public-data-ready\";\nexport const ProtectedDataReadyEvent = \"squide-protected-data-ready\";\nexport const PublicDataUpdatedEvent = \"squide-public-data-updated\";\nexport const ProtectedDataUpdatedEvent = \"squide-protected-data-updated\";\nexport const DeferredRegistrationsUpdatedEvent = \"squide-deferred-registrations-updated\";\nexport const ApplicationBoostrappedEvent = \"squide-app-boostrapped\";\n\nexport interface AppRouterAction {\n type: AppRouterActionType;\n}\n\nexport type AppRouterDispatch = Dispatch<AppRouterAction>;\n\nfunction reducer(state: AppRouterState, action: AppRouterAction) {\n let newState = state;\n\n switch (action.type) {\n case \"modules-registered\": {\n newState = {\n ...newState,\n areModulesRegistered: true\n };\n\n break;\n }\n case \"modules-ready\": {\n newState = {\n ...newState,\n areModulesReady: true,\n // Will be set even if the app is not using deferred registrations.\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"msw-ready\": {\n newState = {\n ...newState,\n isMswReady: true\n };\n\n break;\n }\n case \"public-data-ready\": {\n newState = {\n ...newState,\n isPublicDataReady: true,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-ready\": {\n newState = {\n ...newState,\n isProtectedDataReady: true,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"public-data-updated\": {\n newState = {\n ...newState,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-updated\": {\n newState = {\n ...newState,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"deferred-registrations-updated\": {\n newState = {\n ...newState,\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"active-route-is-public\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"public\"\n };\n\n break;\n }\n case \"active-route-is-protected\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"protected\"\n };\n\n break;\n }\n case \"is-unauthorized\": {\n newState = {\n ...newState,\n isUnauthorized: true\n };\n\n break;\n }\n default: {\n throw new Error(`[squide] The AppRouter component state reducer doesn't support action type \"${action.type}\".`);\n }\n }\n\n return newState;\n}\n\nexport function getAreModulesRegistered() {\n const localModuleStatus = getLocalModuleRegistrationStatus();\n const remoteModuleStatus = getRemoteModuleRegistrationStatus();\n\n return areModulesRegistered(localModuleStatus, remoteModuleStatus);\n}\n\nexport function getAreModulesReady() {\n const localModuleStatus = getLocalModuleRegistrationStatus();\n const remoteModuleStatus = getRemoteModuleRegistrationStatus();\n\n return areModulesReady(localModuleStatus, remoteModuleStatus);\n}\n\nexport function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchModulesRegistered = useExecuteOnce(useCallback(() => {\n if (getAreModulesRegistered()) {\n dispatch({ type: \"modules-registered\" });\n\n logger.debug(\"[squide] %cModules are registered%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n const dispatchModulesReady = useExecuteOnce(useCallback(() => {\n if (getAreModulesReady()) {\n dispatch({ type: \"modules-ready\" });\n\n logger.debug(\"[squide] %cModules are ready%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n return useEffect(() => {\n if (!areModulesRegisteredValue) {\n addLocalModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n addRemoteModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n }\n\n if (!areModulesReadyValue) {\n addLocalModuleRegistrationStatusChangedListener(dispatchModulesReady);\n addRemoteModuleRegistrationStatusChangedListener(dispatchModulesReady);\n }\n\n return () => {\n removeLocalModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n removeRemoteModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n\n removeLocalModuleRegistrationStatusChangedListener(dispatchModulesReady);\n removeRemoteModuleRegistrationStatusChangedListener(dispatchModulesReady);\n };\n }, [areModulesRegisteredValue, areModulesReadyValue, dispatchModulesRegistered, dispatchModulesReady]);\n}\n\nexport function useMswStatusDispatcher(isMswReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchMswReady = useExecuteOnce(useCallback(() => {\n if (isMswReady()) {\n dispatch({ type: \"msw-ready\" });\n\n logger.debug(\"[squide] %cMSW is ready%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n useEffect(() => {\n if (!isMswReadyValue) {\n addMswStateChangedListener(dispatchMswReady);\n }\n\n return () => {\n removeMswStateChangedListener(dispatchMswReady);\n };\n }, [isMswReadyValue, dispatchMswReady]);\n}\n\nexport function useBootstrappingCompletedDispatcher(state: AppRouterState) {\n const eventBus = useEventBus();\n\n const areModulesRegisteredValue = state.areModulesRegistered;\n const isBoostrapping = isBootstrapping(state);\n\n useExecuteOnce(useCallback(() => {\n if (areModulesRegisteredValue && !isBoostrapping) {\n eventBus.dispatch(ApplicationBoostrappedEvent);\n\n return true;\n }\n\n return false;\n }, [areModulesRegisteredValue, isBoostrapping, eventBus]), true);\n}\n\nlet dispatchProxyFactory: ((reactDispatch: AppRouterDispatch) => AppRouterDispatch) | undefined;\n\n// This function should only be used by tests.\nexport function __setAppReducerDispatchProxyFactory(factory: (reactDispatch: AppRouterDispatch) => AppRouterDispatch) {\n dispatchProxyFactory = factory;\n}\n\n// This function should only be used by tests.\nexport function __clearAppReducerDispatchProxy() {\n dispatchProxyFactory = undefined;\n}\n\nfunction useReducerDispatchProxy(reactDispatch: AppRouterDispatch) {\n return useMemo(() => {\n return dispatchProxyFactory ? dispatchProxyFactory(reactDispatch) : reactDispatch;\n }, [reactDispatch]);\n}\n\nfunction useEnhancedReducerDispatch(reducerDispatch: AppRouterDispatch) {\n const logger = useLogger();\n const appRouterStore = useAppRouterStore();\n const eventBus = useEventBus();\n\n return useCallback((action: AppRouterAction) => {\n logger.debug(\"[squide] The following action has been dispatched to the AppRouter reducer:\", action);\n\n appRouterStore.dispatch(action);\n eventBus.dispatch(`squide-${action.type}`);\n\n reducerDispatch(action);\n }, [reducerDispatch, logger, appRouterStore, eventBus]);\n}\n\nexport function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {\n const runtime = useRuntime() as FireflyRuntime;\n const eventBus = useEventBus();\n const appRouterStore = useAppRouterStore();\n\n const areModulesInitiallyRegistered = getAreModulesRegistered();\n const areModulesInitiallyReady = getAreModulesReady();\n const isMswInitiallyReady = isMswReady();\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyRegistered) {\n appRouterStore.dispatch({ type: \"modules-registered\" });\n eventBus.dispatch(ModulesRegisteredEvent);\n }\n\n return true;\n }, [areModulesInitiallyRegistered, appRouterStore, eventBus]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyReady) {\n appRouterStore.dispatch({ type: \"modules-ready\" });\n eventBus.dispatch(ModulesReadyEvent);\n }\n\n return true;\n }, [areModulesInitiallyReady, appRouterStore, eventBus]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (isMswInitiallyReady) {\n appRouterStore.dispatch({ type: \"msw-ready\" });\n eventBus.dispatch(MswReadyEvent);\n }\n\n return true;\n }, [isMswInitiallyReady, appRouterStore, eventBus]), true);\n\n const [state, reactDispatch] = useReducer(reducer, {\n waitForMsw: runtime.isMswEnabled,\n waitForPublicData,\n waitForProtectedData,\n // When the modules registration functions are awaited, the event listeners are registered after the modules are registered.\n areModulesRegistered: areModulesInitiallyRegistered,\n areModulesReady: areModulesInitiallyReady,\n isMswReady: isMswInitiallyReady,\n isPublicDataReady: false,\n isProtectedDataReady: false,\n activeRouteVisibility: \"unknown\",\n isUnauthorized: false\n });\n\n const {\n areModulesRegistered: areModulesRegisteredValue,\n areModulesReady: areModulesReadyValue,\n isMswReady: isMswReadyValue\n } = state;\n\n // The dispatch proxy is strictly an utility allowing tests to mock the useReducer dispatch function. It's easier\n // than mocking the import from React.\n const dispatchProxy = useReducerDispatchProxy(reactDispatch);\n const dispatch = useEnhancedReducerDispatch(dispatchProxy);\n\n useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areModulesReadyValue, dispatch);\n useMswStatusDispatcher(isMswReadyValue, dispatch);\n useBootstrappingCompletedDispatcher(state);\n\n return [state, dispatch];\n}\n"],"names":["addLocalModuleRegistrationStatusChangedListener","getLocalModuleRegistrationStatus","removeLocalModuleRegistrationStatusChangedListener","useEventBus","useLogger","useRuntime","addRemoteModuleRegistrationStatusChangedListener","areModulesReady","areModulesRegistered","getRemoteModuleRegistrationStatus","removeRemoteModuleRegistrationStatusChangedListener","addMswStateChangedListener","isMswReady","removeMswStateChangedListener","useCallback","useEffect","useMemo","useReducer","useAppRouterStore","useExecuteOnce","isBootstrapping","ModulesRegisteredEvent","ModulesReadyEvent","MswReadyEvent","ActiveRouteIsPublicEvent","ActiveRouteIsProtectedEvent","PublicDataReadyEvent","ProtectedDataReadyEvent","PublicDataUpdatedEvent","ProtectedDataUpdatedEvent","DeferredRegistrationsUpdatedEvent","ApplicationBoostrappedEvent","reducer","state","action","newState","Date","Error","getAreModulesRegistered","localModuleStatus","remoteModuleStatus","getAreModulesReady","useModuleRegistrationStatusDispatcher","areModulesRegisteredValue","areModulesReadyValue","dispatch","logger","dispatchModulesRegistered","dispatchModulesReady","useMswStatusDispatcher","isMswReadyValue","dispatchMswReady","useBootstrappingCompletedDispatcher","eventBus","isBoostrapping","dispatchProxyFactory","__setAppReducerDispatchProxyFactory","factory","__clearAppReducerDispatchProxy","undefined","useReducerDispatchProxy","reactDispatch","useEnhancedReducerDispatch","reducerDispatch","appRouterStore","useAppRouterReducer","waitForPublicData","waitForProtectedData","runtime","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAyM;AACmB;AACxH;AACjB;AAExB;AACN;AACK;AAiC1D,wFAAwF;AACxF,8DAA8D;AACvD,MAAMqB,yBAAyB,4BAA4B;AAC3D,MAAMC,oBAAoB,uBAAuB;AACjD,MAAMC,gBAAgB,mBAAmB;AACzC,MAAMC,2BAA2B,gCAAgC;AACjE,MAAMC,8BAA8B,mCAAmC;AACvE,MAAMC,uBAAuB,2BAA2B;AACxD,MAAMC,0BAA0B,8BAA8B;AAC9D,MAAMC,yBAAyB,6BAA6B;AAC5D,MAAMC,4BAA4B,gCAAgC;AAClE,MAAMC,oCAAoC,wCAAwC;AAClF,MAAMC,8BAA8B,yBAAyB;AAQpE,SAASC,QAAQC,KAAqB,EAAEC,MAAuB;IAC3D,IAAIC,WAAWF;IAEf,OAAQC,OAAO,IAAI;QACf,KAAK;YAAsB;gBACvBC,WAAW;oBACP,GAAGA,QAAQ;oBACX,sBAAsB;gBAC1B;gBAEA;YACJ;QACA,KAAK;YAAiB;gBAClBA,WAAW;oBACP,GAAGA,QAAQ;oBACX,iBAAiB;oBACjB,mEAAmE;oBACnE,gCAAgCC,KAAK,GAAG;gBAC5C;gBAEA;YACJ;QACA,KAAK;YAAa;gBACdD,WAAW;oBACP,GAAGA,QAAQ;oBACX,YAAY;gBAChB;gBAEA;YACJ;QACA,KAAK;YAAqB;gBACtBA,WAAW;oBACP,GAAGA,QAAQ;oBACX,mBAAmB;oBACnB,qBAAqBC,KAAK,GAAG;gBACjC;gBAEA;YACJ;QACA,KAAK;YAAwB;gBACzBD,WAAW;oBACP,GAAGA,QAAQ;oBACX,sBAAsB;oBACtB,wBAAwBC,KAAK,GAAG;gBACpC;gBAEA;YACJ;QACA,KAAK;YAAuB;gBACxBD,WAAW;oBACP,GAAGA,QAAQ;oBACX,qBAAqBC,KAAK,GAAG;gBACjC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WA,CAAC;QACvB,IAAIwD,0BAA0B;YAC1BN,eAAe,QAAQ,CAAC;gBAAE,MAAM;YAAgB;YAChDX,SAAS,QAAQ,CAAC/B;QACtB;QAEA,OAAO;IACX,GAAG;QAACgD;QAA0BN;QAAgBX;KAAS,GAAG;IAE1D,2IAA2I;IAC3I,6HAA6H;IAC7HlC,0EAAcA,CAACL,iDAAWA,CAAC;QACvB,IAAIyD,qBAAqB;YACrBP,eAAe,QAAQ,CAAC;gBAAE,MAAM;YAAY;YAC5CX,SAAS,QAAQ,CAAC9B;QACtB;QAEA,OAAO;IACX,GAAG;QAACgD;QAAqBP;QAAgBX;KAAS,GAAG;IAErD,MAAM,CAACpB,OAAO4B,cAAc,GAAG5C,gDAAUA,CAACe,SAAS;QAC/C,YAAYoC,QAAQ,YAAY;QAChCF;QACAC;QACA,4HAA4H;QAC5H,sBAAsBE;QACtB,iBAAiBC;QACjB,YAAYC;QACZ,mBAAmB;QACnB,sBAAsB;QACtB,uBAAuB;QACvB,gBAAgB;IACpB;IAEA,MAAM,EACF,sBAAsB5B,yBAAyB,EAC/C,iBAAiBC,oBAAoB,EACrC,YAAYM,eAAe,EAC9B,GAAGjB;IAEJ,iHAAiH;IACjH,sCAAsC;IACtC,MAAMuC,gBAAgBZ,wBAAwBC;IAC9C,MAAMhB,WAAWiB,2BAA2BU;IAE5C9B,sCAAsCC,2BAA2BC,sBAAsBC;IACvFI,uBAAuBC,iBAAiBL;IACxCO,oCAAoCnB;IAEpC,OAAO;QAACA;QAAOY;KAAS;AAC5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./FireflyRuntime.tsx";
|
|
|
7
7
|
export * from "./AppRouter.tsx";
|
|
8
8
|
export * from "./AppRouterContext.ts";
|
|
9
9
|
export * from "./AppRouterReducer.ts";
|
|
10
|
+
export * from "./AppRouterStore.ts";
|
|
10
11
|
export * from "./GlobalDataQueriesError.ts";
|
|
11
12
|
export * from "./useCanFetchProtectedData.ts";
|
|
12
13
|
export * from "./useCanFetchPublicData.ts";
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./FireflyRuntime.js";
|
|
|
7
7
|
export * from "./AppRouter.js";
|
|
8
8
|
export * from "./AppRouterContext.js";
|
|
9
9
|
export * from "./AppRouterReducer.js";
|
|
10
|
+
export * from "./AppRouterStore.js";
|
|
10
11
|
export * from "./GlobalDataQueriesError.js";
|
|
11
12
|
export * from "./useCanFetchProtectedData.js";
|
|
12
13
|
export * from "./useCanFetchPublicData.js";
|
|
@@ -52,6 +53,7 @@ export * from "./initializeFirefly.js";
|
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
|
|
56
|
+
|
|
55
57
|
|
|
56
58
|
|
|
57
59
|
//# sourceMappingURL=index.js.map
|
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 \"./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":"
|
|
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 \"./AppRouterStore.ts\";\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;AAEF;AACQ;AACE;AACH;AACc;AACF;AACT;AACC;AACP;AACA;AACK;AACA;AACH;AACA;AACY;AACP;AACK;AAEb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useAppRouterStore(): import("./AppRouterStore.ts").AppRouterStore;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__ from "@squide/core";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "@squide/core"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useAppRouterStore.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
function useAppRouterStore() {
|
|
8
|
+
const runtime = (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.useRuntime)();
|
|
9
|
+
return runtime.appRouterStore;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { useAppRouterStore };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=useAppRouterStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppRouterStore.js","sources":["webpack://@squide/firefly/./src/useAppRouterStore.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport type { FireflyRuntime } from \"./FireflyRuntime.tsx\";\n\nexport function useAppRouterStore() {\n const runtime = useRuntime() as FireflyRuntime;\n\n return runtime.appRouterStore;\n}\n"],"names":["useRuntime","useAppRouterStore","runtime"],"mappings":";;;;;AAA0C;AAGnC,SAASC;IACZ,MAAMC,UAAUF,gEAAUA;IAE1B,OAAOE,QAAQ,cAAc;AACjC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "12.0.
|
|
4
|
+
"version": "12.0.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": {
|
|
@@ -28,37 +28,39 @@
|
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tanstack/react-query": "
|
|
32
|
-
"
|
|
33
|
-
"react": "
|
|
34
|
-
"
|
|
35
|
-
"react
|
|
31
|
+
"@tanstack/react-query": "^5.71.0",
|
|
32
|
+
"@types/react": "^18.0.0 || ^19.0.0",
|
|
33
|
+
"@types/react-dom": "^18.0.0 || ^19.0.0",
|
|
34
|
+
"msw": "^2.7.3",
|
|
35
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
36
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
37
|
+
"react-router": "^7.4.1"
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@squide/
|
|
41
|
-
"@squide/
|
|
42
|
-
"@squide/react-router": "7.0.3",
|
|
43
|
-
"@squide/msw": "3.2.5"
|
|
40
|
+
"@squide/core": "5.4.6",
|
|
41
|
+
"@squide/module-federation": "6.2.6",
|
|
42
|
+
"@squide/msw": "3.2.6",
|
|
43
|
+
"@squide/react-router": "7.0.4"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@rsbuild/core": "1.
|
|
47
|
-
"@rslib/core": "0.
|
|
46
|
+
"@rsbuild/core": "1.3.0",
|
|
47
|
+
"@rslib/core": "0.6.0",
|
|
48
48
|
"@testing-library/react": "16.2.0",
|
|
49
|
-
"@
|
|
49
|
+
"@types/react": "19.0.12",
|
|
50
|
+
"@types/react-dom": "19.0.4",
|
|
51
|
+
"@typescript-eslint/parser": "8.28.0",
|
|
50
52
|
"@vitejs/plugin-react": "4.3.4",
|
|
51
|
-
"@workleap/eslint-plugin": "3.3.
|
|
52
|
-
"@workleap/rslib-configs": "1.0.
|
|
53
|
+
"@workleap/eslint-plugin": "3.3.1",
|
|
54
|
+
"@workleap/rslib-configs": "1.0.3",
|
|
53
55
|
"@workleap/typescript-configs": "3.0.2",
|
|
54
56
|
"eslint": "8.57.0",
|
|
55
57
|
"happy-dom": "17.4.4",
|
|
56
58
|
"msw": "2.7.3",
|
|
57
|
-
"react": "19.
|
|
58
|
-
"react-dom": "19.
|
|
59
|
-
"react-router": "7.
|
|
59
|
+
"react": "19.1.0",
|
|
60
|
+
"react-dom": "19.1.0",
|
|
61
|
+
"react-router": "7.4.1",
|
|
60
62
|
"typescript": "5.8.2",
|
|
61
|
-
"vitest": "3.0.
|
|
63
|
+
"vitest": "3.0.9"
|
|
62
64
|
},
|
|
63
65
|
"sideEffects": false,
|
|
64
66
|
"engines": {
|
package/src/AppRouterReducer.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, areM
|
|
|
3
3
|
import { addMswStateChangedListener, isMswReady, removeMswStateChangedListener } from "@squide/msw";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useReducer, type Dispatch } from "react";
|
|
5
5
|
import type { FireflyRuntime } from "./FireflyRuntime.tsx";
|
|
6
|
+
import { useAppRouterStore } from "./useAppRouterStore.ts";
|
|
6
7
|
import { useExecuteOnce } from "./useExecuteOnce.ts";
|
|
7
8
|
import { isBootstrapping } from "./useIsBootstrapping.ts";
|
|
8
9
|
|
|
@@ -285,56 +286,61 @@ function useReducerDispatchProxy(reactDispatch: AppRouterDispatch) {
|
|
|
285
286
|
}
|
|
286
287
|
|
|
287
288
|
function useEnhancedReducerDispatch(reducerDispatch: AppRouterDispatch) {
|
|
288
|
-
const
|
|
289
|
+
const logger = useLogger();
|
|
290
|
+
const appRouterStore = useAppRouterStore();
|
|
291
|
+
const eventBus = useEventBus();
|
|
289
292
|
|
|
290
293
|
return useCallback((action: AppRouterAction) => {
|
|
291
|
-
|
|
294
|
+
logger.debug("[squide] The following action has been dispatched to the AppRouter reducer:", action);
|
|
292
295
|
|
|
293
|
-
|
|
294
|
-
|
|
296
|
+
appRouterStore.dispatch(action);
|
|
297
|
+
eventBus.dispatch(`squide-${action.type}`);
|
|
295
298
|
|
|
296
299
|
reducerDispatch(action);
|
|
297
|
-
}, [reducerDispatch,
|
|
300
|
+
}, [reducerDispatch, logger, appRouterStore, eventBus]);
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
export function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {
|
|
301
304
|
const runtime = useRuntime() as FireflyRuntime;
|
|
305
|
+
const eventBus = useEventBus();
|
|
306
|
+
const appRouterStore = useAppRouterStore();
|
|
302
307
|
|
|
303
308
|
const areModulesInitiallyRegistered = getAreModulesRegistered();
|
|
304
309
|
const areModulesInitiallyReady = getAreModulesReady();
|
|
305
310
|
const isMswInitiallyReady = isMswReady();
|
|
306
311
|
|
|
307
|
-
const eventBus = useEventBus();
|
|
308
|
-
|
|
309
312
|
// When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.
|
|
310
313
|
// To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.
|
|
311
314
|
useExecuteOnce(useCallback(() => {
|
|
312
315
|
if (areModulesInitiallyRegistered) {
|
|
316
|
+
appRouterStore.dispatch({ type: "modules-registered" });
|
|
313
317
|
eventBus.dispatch(ModulesRegisteredEvent);
|
|
314
318
|
}
|
|
315
319
|
|
|
316
320
|
return true;
|
|
317
|
-
}, [areModulesInitiallyRegistered, eventBus]), true);
|
|
321
|
+
}, [areModulesInitiallyRegistered, appRouterStore, eventBus]), true);
|
|
318
322
|
|
|
319
323
|
// When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.
|
|
320
324
|
// To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.
|
|
321
325
|
useExecuteOnce(useCallback(() => {
|
|
322
326
|
if (areModulesInitiallyReady) {
|
|
327
|
+
appRouterStore.dispatch({ type: "modules-ready" });
|
|
323
328
|
eventBus.dispatch(ModulesReadyEvent);
|
|
324
329
|
}
|
|
325
330
|
|
|
326
331
|
return true;
|
|
327
|
-
}, [areModulesInitiallyReady, eventBus]), true);
|
|
332
|
+
}, [areModulesInitiallyReady, appRouterStore, eventBus]), true);
|
|
328
333
|
|
|
329
334
|
// When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.
|
|
330
335
|
// To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.
|
|
331
336
|
useExecuteOnce(useCallback(() => {
|
|
332
337
|
if (isMswInitiallyReady) {
|
|
338
|
+
appRouterStore.dispatch({ type: "msw-ready" });
|
|
333
339
|
eventBus.dispatch(MswReadyEvent);
|
|
334
340
|
}
|
|
335
341
|
|
|
336
342
|
return true;
|
|
337
|
-
}, [isMswInitiallyReady, eventBus]), true);
|
|
343
|
+
}, [isMswInitiallyReady, appRouterStore, eventBus]), true);
|
|
338
344
|
|
|
339
345
|
const [state, reactDispatch] = useReducer(reducer, {
|
|
340
346
|
waitForMsw: runtime.isMswEnabled,
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./AppRouter.tsx";
|
|
|
10
10
|
export * from "./AppRouterContext.ts";
|
|
11
11
|
export * from "./AppRouterReducer.ts";
|
|
12
12
|
|
|
13
|
+
export * from "./AppRouterStore.ts";
|
|
13
14
|
export * from "./GlobalDataQueriesError.ts";
|
|
14
15
|
export * from "./useCanFetchProtectedData.ts";
|
|
15
16
|
export * from "./useCanFetchPublicData.ts";
|