@squide/firefly 9.3.1 → 9.3.3
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 +19 -0
- package/dist/AppRouter.d.ts +8 -12
- package/dist/AppRouter.js +68 -8
- package/dist/AppRouter.js.map +1 -0
- package/dist/AppRouterContext.d.ts +5 -9
- package/dist/AppRouterContext.js +30 -1
- package/dist/AppRouterContext.js.map +1 -0
- package/dist/AppRouterReducer.d.ts +23 -26
- package/dist/AppRouterReducer.js +339 -4
- package/dist/AppRouterReducer.js.map +1 -0
- package/dist/FireflyRuntime.d.ts +5 -8
- package/dist/FireflyRuntime.js +66 -5
- package/dist/FireflyRuntime.js.map +1 -0
- package/dist/GlobalDataQueriesError.d.ts +2 -4
- package/dist/GlobalDataQueriesError.js +19 -1
- package/dist/GlobalDataQueriesError.js.map +1 -0
- package/dist/RootRoute.d.ts +1 -5
- package/dist/RootRoute.js +48 -3
- package/dist/RootRoute.js.map +1 -0
- package/dist/boostrap.d.ts +8 -13
- package/dist/boostrap.js +54 -1
- package/dist/boostrap.js.map +1 -0
- package/dist/index.d.ts +23 -28
- package/dist/index.js +51 -25
- package/dist/index.js.map +1 -0
- package/dist/useCanFetchProtectedData.d.ts +1 -3
- package/dist/useCanFetchProtectedData.js +17 -2
- package/dist/useCanFetchProtectedData.js.map +1 -0
- package/dist/useCanFetchPublicData.d.ts +1 -3
- package/dist/useCanFetchPublicData.js +17 -2
- package/dist/useCanFetchPublicData.js.map +1 -0
- package/dist/useCanRegisterDeferredRegistrations.d.ts +1 -3
- package/dist/useCanRegisterDeferredRegistrations.js +14 -2
- package/dist/useCanRegisterDeferredRegistrations.js.map +1 -0
- package/dist/useCanUpdateDeferredRegistrations.d.ts +1 -3
- package/dist/useCanUpdateDeferredRegistrations.js +16 -2
- package/dist/useCanUpdateDeferredRegistrations.js.map +1 -0
- package/dist/useDeferredRegistrations.d.ts +5 -8
- package/dist/useDeferredRegistrations.js +74 -6
- package/dist/useDeferredRegistrations.js.map +1 -0
- package/dist/useExecuteOnce.d.ts +1 -3
- package/dist/useExecuteOnce.js +29 -1
- package/dist/useExecuteOnce.js.map +1 -0
- package/dist/useIsActiveRouteProtected.d.ts +1 -3
- package/dist/useIsActiveRouteProtected.js +23 -1
- package/dist/useIsActiveRouteProtected.js.map +1 -0
- package/dist/useIsBootstrapping.d.ts +3 -7
- package/dist/useIsBootstrapping.js +22 -2
- package/dist/useIsBootstrapping.js.map +1 -0
- package/dist/useNavigationItems.d.ts +3 -7
- package/dist/useNavigationItems.js +26 -2
- package/dist/useNavigationItems.js.map +1 -0
- package/dist/useProtectedDataQueries.d.ts +6 -8
- package/dist/useProtectedDataQueries.js +126 -5
- package/dist/useProtectedDataQueries.js.map +1 -0
- package/dist/usePublicDataQueries.d.ts +5 -7
- package/dist/usePublicDataQueries.js +111 -5
- package/dist/usePublicDataQueries.js.map +1 -0
- package/dist/useRegisterDeferredRegistrations.d.ts +4 -9
- package/dist/useRegisterDeferredRegistrations.js +19 -1
- package/dist/useRegisterDeferredRegistrations.js.map +1 -0
- package/dist/useStrictRegistrationMode.d.ts +1 -3
- package/dist/useStrictRegistrationMode.js +40 -1
- package/dist/useStrictRegistrationMode.js.map +1 -0
- package/dist/useUpdateDeferredRegistrations.d.ts +4 -9
- package/dist/useUpdateDeferredRegistrations.js +30 -2
- package/dist/useUpdateDeferredRegistrations.js.map +1 -0
- package/package.json +29 -24
- package/src/AppRouter.tsx +63 -0
- package/src/AppRouterContext.ts +27 -0
- package/src/AppRouterReducer.ts +363 -0
- package/src/FireflyRuntime.tsx +71 -0
- package/src/GlobalDataQueriesError.ts +17 -0
- package/src/RootRoute.tsx +25 -0
- package/src/boostrap.ts +62 -0
- package/src/index.ts +28 -0
- package/src/useCanFetchProtectedData.ts +26 -0
- package/src/useCanFetchPublicData.ts +23 -0
- package/src/useCanRegisterDeferredRegistrations.ts +24 -0
- package/src/useCanUpdateDeferredRegistrations.ts +23 -0
- package/src/useDeferredRegistrations.ts +59 -0
- package/src/useExecuteOnce.ts +23 -0
- package/src/useIsActiveRouteProtected.ts +12 -0
- package/src/useIsBootstrapping.ts +45 -0
- package/src/useNavigationItems.ts +18 -0
- package/src/useProtectedDataQueries.ts +101 -0
- package/src/usePublicDataQueries.ts +88 -0
- package/src/useRegisterDeferredRegistrations.ts +9 -0
- package/src/useStrictRegistrationMode.ts +28 -0
- package/src/useUpdateDeferredRegistrations.ts +16 -0
- package/dist/chunk-4RUCDAUT.js +0 -18
- package/dist/chunk-BFHHJOJT.js +0 -41
- package/dist/chunk-CTLPFYLM.js +0 -65
- package/dist/chunk-G32YX2KR.js +0 -22
- package/dist/chunk-GXSW4CZS.js +0 -9
- package/dist/chunk-H2ILEMPE.js +0 -28
- package/dist/chunk-HE5HKFL3.js +0 -16
- package/dist/chunk-IOMSOUAL.js +0 -20
- package/dist/chunk-JFMSLZ74.js +0 -253
- package/dist/chunk-L44KFU57.js +0 -34
- package/dist/chunk-LC233OPR.js +0 -54
- package/dist/chunk-MKTGJHQR.js +0 -71
- package/dist/chunk-N2GOIQ5E.js +0 -14
- package/dist/chunk-PMVN3U47.js +0 -21
- package/dist/chunk-PP3MRMJJ.js +0 -11
- package/dist/chunk-ROE2YHN5.js +0 -44
- package/dist/chunk-TURKCH7J.js +0 -20
- package/dist/chunk-WOPD33CM.js +0 -25
- package/dist/chunk-WVRMJZV6.js +0 -18
- package/dist/chunk-XDWYPVAJ.js +0 -21
- package/dist/chunk-YRWFYWK4.js +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppRouterReducer.js","sources":["webpack://@squide/firefly/./src/AppRouterReducer.ts"],"sourcesContent":["import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useEventBus, useLogger } 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 { useExecuteOnce } from \"./useExecuteOnce.ts\";\nimport { isApplicationBootstrapping } 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 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 = isApplicationBootstrapping(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 eventBus = useEventBus();\n\n return useCallback((action: AppRouterAction) => {\n logger.debug(\"[squide] The following action has been dispatched to the AppRouter reducer:\", action);\n eventBus.dispatch(`squide-${action.type}`);\n\n reducerDispatch(action);\n }, [reducerDispatch, logger, eventBus]);\n}\n\nexport function useAppRouterReducer(waitForMsw: boolean, waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {\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,\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","addRemoteModuleRegistrationStatusChangedListener","areModulesReady","areModulesRegistered","getRemoteModuleRegistrationStatus","removeRemoteModuleRegistrationStatusChangedListener","addMswStateChangedListener","isMswReady","removeMswStateChangedListener","useCallback","useEffect","useMemo","useReducer","useExecuteOnce","isApplicationBootstrapping","ModulesRegisteredEvent","ModulesReadyEvent","MswReadyEvent","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","useAppRouterReducer","waitForMsw","waitForPublicData","waitForProtectedData","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;AAA6L;AAC+B;AACxH;AACjB;AAC9B;AACgB;AAiCrE,wFAAwF;AACxF,8DAA8D;AACvD,MAAMmB,yBAAyB,4BAA4B;AAC3D,MAAMC,oBAAoB,uBAAuB;AACjD,MAAMC,gBAAgB,mBAAmB;AACzC,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;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CAAoCnB;IAEpC,OAAO;QAACA;QAAOY;KAAS;AAC5B"}
|
package/dist/FireflyRuntime.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReactRouterRuntime, Route } from
|
|
3
|
-
import { RequestHandler } from
|
|
4
|
-
|
|
5
|
-
interface FireflyRuntimeOptions extends RuntimeOptions {
|
|
1
|
+
import type { RegisterRouteOptions, RuntimeOptions } from "@squide/core";
|
|
2
|
+
import { ReactRouterRuntime, type Route } from "@squide/react-router";
|
|
3
|
+
import type { RequestHandler } from "msw";
|
|
4
|
+
export interface FireflyRuntimeOptions extends RuntimeOptions {
|
|
6
5
|
useMsw?: boolean;
|
|
7
6
|
}
|
|
8
|
-
declare class FireflyRuntime extends ReactRouterRuntime {
|
|
7
|
+
export declare class FireflyRuntime extends ReactRouterRuntime {
|
|
9
8
|
#private;
|
|
10
9
|
constructor({ plugins, useMsw, ...options }?: FireflyRuntimeOptions);
|
|
11
10
|
registerRequestHandlers(handlers: RequestHandler[]): void;
|
|
@@ -13,5 +12,3 @@ declare class FireflyRuntime extends ReactRouterRuntime {
|
|
|
13
12
|
registerRoute(route: Route, options?: RegisterRouteOptions): void;
|
|
14
13
|
get isMswEnabled(): boolean;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
export { FireflyRuntime, type FireflyRuntimeOptions };
|
package/dist/FireflyRuntime.js
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__msw_src_index_js_df8c7d83__ from "../../msw/src/index.js";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__react_router_src_index_js_ff6a88b1__ from "../../react-router/src/index.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterReducer_js_6fa81ecc__ from "./AppRouterReducer.js";
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: external "../../msw/src/index.js"
|
|
6
|
+
|
|
7
|
+
;// CONCATENATED MODULE: external "../../react-router/src/index.js"
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "./AppRouterReducer.js"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: ./src/FireflyRuntime.tsx?__rslib_entry__
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FireflyRuntime extends __WEBPACK_EXTERNAL_MODULE__react_router_src_index_js_ff6a88b1__.ReactRouterRuntime {
|
|
16
|
+
#useMsw;
|
|
17
|
+
constructor({ plugins, useMsw, ...options } = {}){
|
|
18
|
+
if (useMsw) {
|
|
19
|
+
super({
|
|
20
|
+
plugins: [
|
|
21
|
+
...plugins ?? [],
|
|
22
|
+
(runtime)=>new __WEBPACK_EXTERNAL_MODULE__msw_src_index_js_df8c7d83__.MswPlugin(runtime)
|
|
23
|
+
],
|
|
24
|
+
...options
|
|
25
|
+
});
|
|
26
|
+
this.#useMsw = true;
|
|
27
|
+
} else {
|
|
28
|
+
super({
|
|
29
|
+
plugins,
|
|
30
|
+
...options
|
|
31
|
+
});
|
|
32
|
+
this.#useMsw = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
registerRequestHandlers(handlers) {
|
|
36
|
+
const mswPlugin = this.getPlugin(__WEBPACK_EXTERNAL_MODULE__msw_src_index_js_df8c7d83__.MswPluginName);
|
|
37
|
+
if (!mswPlugin) {
|
|
38
|
+
throw new Error("[squide] Cannot register the provided MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \"useMsw\" option?");
|
|
39
|
+
}
|
|
40
|
+
if ((0,__WEBPACK_EXTERNAL_MODULE__AppRouterReducer_js_6fa81ecc__.getAreModulesRegistered)()) {
|
|
41
|
+
throw new Error("[squide] Cannot register an MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
|
|
42
|
+
}
|
|
43
|
+
mswPlugin.registerRequestHandlers(handlers);
|
|
44
|
+
}
|
|
45
|
+
// Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
|
|
46
|
+
get requestHandlers() {
|
|
47
|
+
const mswPlugin = this.getPlugin(__WEBPACK_EXTERNAL_MODULE__msw_src_index_js_df8c7d83__.MswPluginName);
|
|
48
|
+
if (!mswPlugin) {
|
|
49
|
+
throw new Error("[squide] Cannot retrieve MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \"useMsw\" option?");
|
|
50
|
+
}
|
|
51
|
+
return mswPlugin.requestHandlers;
|
|
52
|
+
}
|
|
53
|
+
registerRoute(route, options = {}) {
|
|
54
|
+
if ((0,__WEBPACK_EXTERNAL_MODULE__AppRouterReducer_js_6fa81ecc__.getAreModulesRegistered)()) {
|
|
55
|
+
throw new Error("[squide] Cannot register a route once the modules are registered. Are you trying to register a route in a deferred registration function? Only navigation items can be registered in a deferred registration function.");
|
|
56
|
+
}
|
|
57
|
+
super.registerRoute(route, options);
|
|
58
|
+
}
|
|
59
|
+
get isMswEnabled() {
|
|
60
|
+
return this.#useMsw;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { FireflyRuntime };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=FireflyRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FireflyRuntime.js","sources":["webpack://@squide/firefly/./src/FireflyRuntime.tsx"],"sourcesContent":["import type { RegisterRouteOptions, RuntimeOptions } from \"@squide/core\";\nimport { MswPlugin, MswPluginName } from \"@squide/msw\";\nimport { ReactRouterRuntime, type Route } from \"@squide/react-router\";\nimport type { RequestHandler } from \"msw\";\nimport { getAreModulesRegistered } from \"./AppRouterReducer.ts\";\n\nexport interface FireflyRuntimeOptions extends RuntimeOptions {\n useMsw?: boolean;\n}\n\nexport class FireflyRuntime extends ReactRouterRuntime {\n readonly #useMsw: boolean;\n\n constructor({ plugins, useMsw, ...options }: FireflyRuntimeOptions = {}) {\n if (useMsw) {\n super({\n plugins: [\n ...(plugins ?? []),\n runtime => new MswPlugin(runtime)\n ],\n ...options\n });\n\n this.#useMsw = true;\n } else {\n super({\n plugins,\n ...options\n });\n\n this.#useMsw = false;\n }\n }\n\n registerRequestHandlers(handlers: RequestHandler[]) {\n const mswPlugin = this.getPlugin(MswPluginName) as MswPlugin;\n\n if (!mswPlugin) {\n throw new Error(\"[squide] Cannot register the provided MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \\\"useMsw\\\" option?\");\n }\n\n if (getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register an MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n mswPlugin.registerRequestHandlers(handlers);\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n const mswPlugin = this.getPlugin(MswPluginName) as MswPlugin;\n\n if (!mswPlugin) {\n throw new Error(\"[squide] Cannot retrieve MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \\\"useMsw\\\" option?\");\n }\n\n return mswPlugin.requestHandlers;\n }\n\n registerRoute(route: Route, options: RegisterRouteOptions = {}) {\n if (getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register a route once the modules are registered. Are you trying to register a route in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n super.registerRoute(route, options);\n }\n\n get isMswEnabled() {\n return this.#useMsw;\n }\n}\n"],"names":["MswPlugin","MswPluginName","ReactRouterRuntime","getAreModulesRegistered","FireflyRuntime","plugins","useMsw","options","runtime","handlers","mswPlugin","Error","route"],"mappings":";;;;;;;;;;;AACuD;AACe;AAEN;AAMzD,MAAMI,uBAAuBF,kFAAkBA;IACzC,OAAO,CAAU;IAE1B,YAAY,EAAEG,OAAO,EAAEC,MAAM,EAAE,GAAGC,SAAgC,GAAG,CAAC,CAAC,CAAE;QACrE,IAAID,QAAQ;YACR,KAAK,CAAC;gBACF,SAAS;uBACDD,WAAW,EAAE;oBACjBG,CAAAA,UAAW,IAAIR,gEAASA,CAACQ;iBAC5B;gBACD,GAAGD,OAAO;YACd;YAEA,IAAI,CAAC,OAAO,GAAG;QACnB,OAAO;YACH,KAAK,CAAC;gBACFF;gBACA,GAAGE,OAAO;YACd;YAEA,IAAI,CAAC,OAAO,GAAG;QACnB;IACJ;IAEA,wBAAwBE,QAA0B,EAAE;QAChD,MAAMC,YAAY,IAAI,CAAC,SAAS,CAACT,oEAAaA;QAE9C,IAAI,CAACS,WAAW;YACZ,MAAM,IAAIC,MAAM;QACpB;QAEA,IAAIR,qFAAuBA,IAAI;YAC3B,MAAM,IAAIQ,MAAM;QACpB;QAEAD,UAAU,uBAAuB,CAACD;IACtC;IAEA,8HAA8H;IAC9H,IAAI,kBAAoC;QACpC,MAAMC,YAAY,IAAI,CAAC,SAAS,CAACT,oEAAaA;QAE9C,IAAI,CAACS,WAAW;YACZ,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAOD,UAAU,eAAe;IACpC;IAEA,cAAcE,KAAY,EAAEL,UAAgC,CAAC,CAAC,EAAE;QAC5D,IAAIJ,qFAAuBA,IAAI;YAC3B,MAAM,IAAIQ,MAAM;QACpB;QAEA,KAAK,CAAC,cAAcC,OAAOL;IAC/B;IAEA,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,OAAO;IACvB;AACJ"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
declare class GlobalDataQueriesError extends Error {
|
|
1
|
+
export declare class GlobalDataQueriesError extends Error {
|
|
2
2
|
#private;
|
|
3
3
|
constructor(message: string, errors: Error[]);
|
|
4
4
|
get errors(): Error[];
|
|
5
5
|
}
|
|
6
|
-
declare function isGlobalDataQueriesError(error?: unknown): error is GlobalDataQueriesError;
|
|
7
|
-
|
|
8
|
-
export { GlobalDataQueriesError, isGlobalDataQueriesError };
|
|
6
|
+
export declare function isGlobalDataQueriesError(error?: unknown): error is GlobalDataQueriesError;
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
;// CONCATENATED MODULE: ./src/GlobalDataQueriesError.ts?__rslib_entry__
|
|
3
|
+
class GlobalDataQueriesError extends Error {
|
|
4
|
+
#errors;
|
|
5
|
+
constructor(message, errors){
|
|
6
|
+
super(message);
|
|
7
|
+
this.#errors = errors;
|
|
8
|
+
}
|
|
9
|
+
get errors() {
|
|
10
|
+
return this.#errors;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function isGlobalDataQueriesError(error) {
|
|
14
|
+
return error !== undefined && error !== null && error instanceof GlobalDataQueriesError;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { GlobalDataQueriesError, isGlobalDataQueriesError };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=GlobalDataQueriesError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalDataQueriesError.js","sources":["webpack://@squide/firefly/./src/GlobalDataQueriesError.ts"],"sourcesContent":["export class GlobalDataQueriesError extends Error {\n readonly #errors: Error[];\n\n constructor(message: string, errors: Error[]) {\n super(message);\n\n this.#errors = errors;\n }\n\n get errors() {\n return this.#errors;\n }\n}\n\nexport function isGlobalDataQueriesError(error?: unknown): error is GlobalDataQueriesError {\n return error !== undefined && error !== null && error instanceof GlobalDataQueriesError;\n}\n"],"names":["GlobalDataQueriesError","Error","message","errors","isGlobalDataQueriesError","error","undefined"],"mappings":";;AAAO,MAAMA,+BAA+BC;IAC/B,OAAO,CAAU;IAE1B,YAAYC,OAAe,EAAEC,MAAe,CAAE;QAC1C,KAAK,CAACD;QAEN,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,OAAO;IACvB;AACJ;AAEO,SAASC,yBAAyBC,KAAe;IACpD,OAAOA,UAAUC,aAAaD,UAAU,QAAQA,iBAAiBL;AACrE"}
|
package/dist/RootRoute.d.ts
CHANGED
package/dist/RootRoute.js
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__ from "react-router-dom";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__ from "./AppRouterContext.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useIsActiveRouteProtected_js_d94f4832__ from "./useIsActiveRouteProtected.js";
|
|
6
|
+
|
|
7
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "react"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: external "react-router-dom"
|
|
12
|
+
|
|
13
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
14
|
+
|
|
15
|
+
;// CONCATENATED MODULE: external "./useIsActiveRouteProtected.js"
|
|
16
|
+
|
|
17
|
+
;// CONCATENATED MODULE: ./src/RootRoute.tsx?__rslib_entry__
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function RootRoute() {
|
|
24
|
+
const state = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterState)();
|
|
25
|
+
const isActiveRouteProtected = (0,__WEBPACK_EXTERNAL_MODULE__useIsActiveRouteProtected_js_d94f4832__.useIsActiveRouteProtected)(state.areModulesReady);
|
|
26
|
+
const dispatch = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterDispatcher)();
|
|
27
|
+
(0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
28
|
+
// Dispatching the active route visibility must be done in a route because React Router's useLocation
|
|
29
|
+
// hook throws if it's not called from a child of the router component.
|
|
30
|
+
if (isActiveRouteProtected) {
|
|
31
|
+
dispatch({
|
|
32
|
+
type: "active-route-is-protected"
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
dispatch({
|
|
36
|
+
type: "active-route-is-public"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, [
|
|
40
|
+
isActiveRouteProtected,
|
|
41
|
+
dispatch
|
|
42
|
+
]);
|
|
43
|
+
return /*#__PURE__*/ (0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.Outlet, {});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { RootRoute };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=RootRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootRoute.js","sources":["webpack://@squide/firefly/./src/RootRoute.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { Outlet } from \"react-router-dom\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { useIsActiveRouteProtected } from \"./useIsActiveRouteProtected.ts\";\n\nexport function RootRoute() {\n const state = useAppRouterState();\n const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady);\n\n const dispatch = useAppRouterDispatcher();\n\n useEffect(() => {\n // Dispatching the active route visibility must be done in a route because React Router's useLocation\n // hook throws if it's not called from a child of the router component.\n if (isActiveRouteProtected) {\n dispatch({ type: \"active-route-is-protected\" });\n } else {\n dispatch({ type: \"active-route-is-public\" });\n }\n }, [isActiveRouteProtected, dispatch]);\n\n return (\n <Outlet />\n );\n}\n"],"names":["useEffect","Outlet","useAppRouterDispatcher","useAppRouterState","useIsActiveRouteProtected","RootRoute","state","isActiveRouteProtected","dispatch"],"mappings":";;;;;;;;;;;;;;;;;;AAAkC;AACQ;AACwC;AACP;AAEpE,SAASK;IACZ,MAAMC,QAAQH,+EAAiBA;IAC/B,MAAMI,yBAAyBH,gGAAyBA,CAACE,MAAM,eAAe;IAE9E,MAAME,WAAWN,oFAAsBA;IAEvCF,+CAASA,CAAC;QACN,qGAAqG;QACrG,uEAAuE;QACvE,IAAIO,wBAAwB;YACxBC,SAAS;gBAAE,MAAM;YAA4B;QACjD,OAAO;YACHA,SAAS;gBAAE,MAAM;YAAyB;QAC9C;IACJ,GAAG;QAACD;QAAwBC;KAAS;IAErC,qBACI,+DAACP,4DAAMA;AAEf"}
|
package/dist/boostrap.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RemoteDefinition, RemoteModuleRegistrationError } from
|
|
3
|
-
import { FireflyRuntime } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
declare const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
8
|
-
type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;
|
|
9
|
-
interface BootstrapAppOptions<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext> {
|
|
1
|
+
import { type ModuleRegisterFunction, type ModuleRegistrationError, type RegisterModulesOptions } from "@squide/core";
|
|
2
|
+
import { type RemoteDefinition, type RemoteModuleRegistrationError } from "@squide/module-federation";
|
|
3
|
+
import type { FireflyRuntime } from "./FireflyRuntime.tsx";
|
|
4
|
+
export declare const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
5
|
+
export type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;
|
|
6
|
+
export interface BootstrapAppOptions<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext> {
|
|
10
7
|
localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];
|
|
11
8
|
remotes?: RemoteDefinition[];
|
|
12
9
|
startMsw?: StartMswFunction<TRuntime>;
|
|
13
10
|
}
|
|
14
|
-
declare function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options?: BootstrapAppOptions<TRuntime, TContext, TData>): Promise<{
|
|
11
|
+
export declare function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options?: BootstrapAppOptions<TRuntime, TContext, TData>): Promise<{
|
|
15
12
|
localModuleErrors: ModuleRegistrationError[];
|
|
16
13
|
remoteModuleErrors: RemoteModuleRegistrationError[];
|
|
17
14
|
}>;
|
|
18
|
-
declare function __resetBootstrapGuard(): void;
|
|
19
|
-
|
|
20
|
-
export { ApplicationBootstrappingStartedEvent, type BootstrapAppOptions, type StartMswFunction, __resetBootstrapGuard, bootstrap };
|
|
15
|
+
export declare function __resetBootstrapGuard(): void;
|
package/dist/boostrap.js
CHANGED
|
@@ -1 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__core_src_index_js_d19dd8a6__ from "../../core/src/index.js";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__module_federation_src_index_js_e113b625__ from "../../module-federation/src/index.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__msw_src_index_js_df8c7d83__ from "../../msw/src/index.js";
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: external "../../core/src/index.js"
|
|
6
|
+
|
|
7
|
+
;// CONCATENATED MODULE: external "../../module-federation/src/index.js"
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "../../msw/src/index.js"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: ./src/boostrap.ts?__rslib_entry__
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
16
|
+
let isBootstrapped = false;
|
|
17
|
+
async function bootstrap(runtime, options = {}) {
|
|
18
|
+
const { localModules = [], remotes = [], context, startMsw } = options;
|
|
19
|
+
if (isBootstrapped) {
|
|
20
|
+
throw new Error("[squide] A squide application can only be bootstrapped once. Did you call the \"bootstrap\" function twice?");
|
|
21
|
+
}
|
|
22
|
+
runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);
|
|
23
|
+
let localModuleErrors = [];
|
|
24
|
+
let remoteModuleErrors = [];
|
|
25
|
+
localModuleErrors = await (0,__WEBPACK_EXTERNAL_MODULE__core_src_index_js_d19dd8a6__.registerLocalModules)(localModules, runtime, {
|
|
26
|
+
context
|
|
27
|
+
});
|
|
28
|
+
remoteModuleErrors = await (0,__WEBPACK_EXTERNAL_MODULE__module_federation_src_index_js_e113b625__.registerRemoteModules)(remotes, runtime, {
|
|
29
|
+
context
|
|
30
|
+
});
|
|
31
|
+
if (runtime.isMswEnabled) {
|
|
32
|
+
if (!(0,__WEBPACK_EXTERNAL_MODULE__core_src_index_js_d19dd8a6__.isFunction)(startMsw)) {
|
|
33
|
+
throw new Error("[squide] When MSW is enabled, the \"startMsw\" function must be provided.");
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await startMsw(runtime);
|
|
37
|
+
(0,__WEBPACK_EXTERNAL_MODULE__msw_src_index_js_df8c7d83__.setMswAsReady)();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
runtime.logger.debug("[squide] An error occured while starting MSW.", error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
isBootstrapped = true;
|
|
43
|
+
return {
|
|
44
|
+
localModuleErrors,
|
|
45
|
+
remoteModuleErrors
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function __resetBootstrapGuard() {
|
|
49
|
+
isBootstrapped = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { ApplicationBootstrappingStartedEvent, __resetBootstrapGuard, bootstrap };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=boostrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boostrap.js","sources":["webpack://@squide/firefly/./src/boostrap.ts"],"sourcesContent":["import { isFunction, registerLocalModules, type ModuleRegisterFunction, type ModuleRegistrationError, type RegisterModulesOptions } from \"@squide/core\";\nimport { registerRemoteModules, type RemoteDefinition, type RemoteModuleRegistrationError } from \"@squide/module-federation\";\nimport { setMswAsReady } from \"@squide/msw\";\nimport type { FireflyRuntime } from \"./FireflyRuntime.tsx\";\n\nexport const ApplicationBootstrappingStartedEvent = \"squide-app-bootstrapping-started\";\n\nlet isBootstrapped = false;\n\nexport type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;\n\nexport interface BootstrapAppOptions<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext> {\n localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];\n remotes?: RemoteDefinition[];\n startMsw?: StartMswFunction<TRuntime>;\n}\n\nexport async function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options: BootstrapAppOptions<TRuntime, TContext, TData> = {}) {\n const {\n localModules = [],\n remotes = [],\n context,\n startMsw\n } = options;\n\n if (isBootstrapped) {\n throw new Error(\"[squide] A squide application can only be bootstrapped once. Did you call the \\\"bootstrap\\\" function twice?\");\n }\n\n runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);\n\n let localModuleErrors: ModuleRegistrationError[] = [];\n let remoteModuleErrors: RemoteModuleRegistrationError[] = [];\n\n localModuleErrors = await registerLocalModules<TRuntime, TContext, TData>(localModules, runtime, { context });\n remoteModuleErrors = await registerRemoteModules(remotes, runtime, { context });\n\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 try {\n await startMsw(runtime);\n\n setMswAsReady();\n } catch (error: unknown) {\n runtime.logger.debug(\"[squide] An error occured while starting MSW.\", error);\n }\n }\n\n isBootstrapped = true;\n\n return {\n localModuleErrors,\n remoteModuleErrors\n };\n}\n\nexport function __resetBootstrapGuard() {\n isBootstrapped = false;\n}\n"],"names":["isFunction","registerLocalModules","registerRemoteModules","setMswAsReady","ApplicationBootstrappingStartedEvent","isBootstrapped","bootstrap","runtime","options","localModules","remotes","context","startMsw","Error","localModuleErrors","remoteModuleErrors","error","__resetBootstrapGuard"],"mappings":";;;;;;;;;;;AAAwJ;AAC3B;AACjF;AAGrC,MAAMI,uCAAuC,mCAAmC;AAEvF,IAAIC,iBAAiB;AAUd,eAAeC,UAAiGC,OAAiB,EAAEC,UAA0D,CAAC,CAAC;IAClM,MAAM,EACFC,eAAe,EAAE,EACjBC,UAAU,EAAE,EACZC,OAAO,EACPC,QAAQ,EACX,GAAGJ;IAEJ,IAAIH,gBAAgB;QAChB,MAAM,IAAIQ,MAAM;IACpB;IAEAN,QAAQ,QAAQ,CAAC,QAAQ,CAACH;IAE1B,IAAIU,oBAA+C,EAAE;IACrD,IAAIC,qBAAsD,EAAE;IAE5DD,oBAAoB,MAAMb,gFAAoBA,CAA4BQ,cAAcF,SAAS;QAAEI;IAAQ;IAC3GI,qBAAqB,MAAMb,8FAAqBA,CAACQ,SAASH,SAAS;QAAEI;IAAQ;IAE7E,IAAIJ,QAAQ,YAAY,EAAE;QACtB,IAAI,CAACP,sEAAUA,CAACY,WAAW;YACvB,MAAM,IAAIC,MAAM;QACpB;QAEA,IAAI;YACA,MAAMD,SAASL;YAEfJ,wEAAaA;QACjB,EAAE,OAAOa,OAAgB;YACrBT,QAAQ,MAAM,CAAC,KAAK,CAAC,iDAAiDS;QAC1E;IACJ;IAEAX,iBAAiB;IAEjB,OAAO;QACHS;QACAC;IACJ;AACJ;AAEO,SAASE;IACZZ,iBAAiB;AACrB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
import 'msw';
|
|
25
|
-
import 'react/jsx-runtime';
|
|
26
|
-
import 'react';
|
|
27
|
-
import 'react-router-dom';
|
|
28
|
-
import '@tanstack/react-query';
|
|
1
|
+
export * from "@squide/core";
|
|
2
|
+
export * from "@squide/module-federation";
|
|
3
|
+
export * from "@squide/msw";
|
|
4
|
+
export * from "@squide/react-router";
|
|
5
|
+
export * from "./FireflyRuntime.tsx";
|
|
6
|
+
export * from "./AppRouter.tsx";
|
|
7
|
+
export * from "./AppRouterContext.ts";
|
|
8
|
+
export * from "./AppRouterReducer.ts";
|
|
9
|
+
export * from "./GlobalDataQueriesError.ts";
|
|
10
|
+
export * from "./useCanFetchProtectedData.ts";
|
|
11
|
+
export * from "./useCanFetchPublicData.ts";
|
|
12
|
+
export * from "./useCanRegisterDeferredRegistrations.ts";
|
|
13
|
+
export * from "./useCanUpdateDeferredRegistrations.ts";
|
|
14
|
+
export * from "./useDeferredRegistrations.ts";
|
|
15
|
+
export * from "./useIsActiveRouteProtected.ts";
|
|
16
|
+
export * from "./useIsBootstrapping.ts";
|
|
17
|
+
export * from "./useNavigationItems.ts";
|
|
18
|
+
export * from "./useProtectedDataQueries.ts";
|
|
19
|
+
export * from "./usePublicDataQueries.ts";
|
|
20
|
+
export * from "./useRegisterDeferredRegistrations.ts";
|
|
21
|
+
export * from "./useStrictRegistrationMode.ts";
|
|
22
|
+
export * from "./useUpdateDeferredRegistrations.ts";
|
|
23
|
+
export * from "./boostrap.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,51 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
export * from "../../core/src/index.js";
|
|
2
|
+
export * from "../../module-federation/src/index.js";
|
|
3
|
+
export * from "../../msw/src/index.js";
|
|
4
|
+
export * from "../../react-router/src/index.js";
|
|
5
|
+
export * from "./FireflyRuntime.js";
|
|
6
|
+
export * from "./AppRouter.js";
|
|
7
|
+
export * from "./AppRouterContext.js";
|
|
8
|
+
export * from "./AppRouterReducer.js";
|
|
9
|
+
export * from "./GlobalDataQueriesError.js";
|
|
10
|
+
export * from "./useCanFetchProtectedData.js";
|
|
11
|
+
export * from "./useCanFetchPublicData.js";
|
|
12
|
+
export * from "./useCanRegisterDeferredRegistrations.js";
|
|
13
|
+
export * from "./useCanUpdateDeferredRegistrations.js";
|
|
14
|
+
export * from "./useDeferredRegistrations.js";
|
|
15
|
+
export * from "./useIsActiveRouteProtected.js";
|
|
16
|
+
export * from "./useIsBootstrapping.js";
|
|
17
|
+
export * from "./useNavigationItems.js";
|
|
18
|
+
export * from "./useProtectedDataQueries.js";
|
|
19
|
+
export * from "./usePublicDataQueries.js";
|
|
20
|
+
export * from "./useRegisterDeferredRegistrations.js";
|
|
21
|
+
export * from "./useStrictRegistrationMode.js";
|
|
22
|
+
export * from "./useUpdateDeferredRegistrations.js";
|
|
23
|
+
export * from "./boostrap.js";
|
|
24
|
+
|
|
25
|
+
;// CONCATENATED MODULE: ./src/index.ts?__rslib_entry__
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__ from "./AppRouterContext.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useCanFetchProtectedData.ts?__rslib_entry__
|
|
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
|
|
11
|
+
// depends on the protected data.
|
|
12
|
+
(areModulesRegistered || areModulesReady) && activeRouteVisibility === "protected" && (!waitForMsw || isMswReady));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useCanFetchProtectedData };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=useCanFetchProtectedData.js.map
|
|
@@ -0,0 +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,2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__ from "./AppRouterContext.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useCanFetchPublicData.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
function useCanFetchPublicData() {
|
|
8
|
+
const { waitForMsw, areModulesRegistered, areModulesReady, isMswReady, isPublicDataReady } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterState)();
|
|
9
|
+
return(// Always return true when the public data has already been fetched sucessfully so TanStack Query can update the data in the background.
|
|
10
|
+
isPublicDataReady || // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered has they will probably
|
|
11
|
+
// depends on the protected data.
|
|
12
|
+
(areModulesRegistered || areModulesReady) && (!waitForMsw || isMswReady));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useCanFetchPublicData };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=useCanFetchPublicData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCanFetchPublicData.js","sources":["webpack://@squide/firefly/./src/useCanFetchPublicData.ts"],"sourcesContent":["import { useAppRouterState } from \"./AppRouterContext.ts\";\n\nexport function useCanFetchPublicData() {\n const {\n waitForMsw,\n areModulesRegistered,\n areModulesReady,\n isMswReady,\n isPublicDataReady\n } = useAppRouterState();\n\n return (\n // Always return true when the public data has already been fetched sucessfully so TanStack Query can update the data in the background.\n isPublicDataReady\n || (\n // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered has they will probably\n // depends on the protected data.\n (areModulesRegistered || areModulesReady)\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","useCanFetchPublicData","waitForMsw","areModulesRegistered","areModulesReady","isMswReady","isPublicDataReady"],"mappings":";;;;;AAA0D;AAEnD,SAASC;IACZ,MAAM,EACFC,UAAU,EACVC,oBAAoB,EACpBC,eAAe,EACfC,UAAU,EACVC,iBAAiB,EACpB,GAAGN,+EAAiBA;IAErB,OACI,wIAAwI;IACxIM,qBAEI,qIAAqI;IACrI,iCAAiC;IAChCH,CAAAA,wBAAwBC,eAAc,KAEnC,EAACF,cAAcG,UAAS;AAGxC"}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__ from "./AppRouterContext.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useCanRegisterDeferredRegistrations.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
function useCanRegisterDeferredRegistrations() {
|
|
8
|
+
const { waitForPublicData, waitForProtectedData, areModulesReady, areModulesRegistered, isPublicDataReady, isProtectedDataReady, activeRouteVisibility, isUnauthorized } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__.useAppRouterState)();
|
|
9
|
+
return !isUnauthorized && areModulesRegistered && !areModulesReady && (!waitForPublicData || isPublicDataReady) && (!waitForProtectedData || activeRouteVisibility === "public" || isProtectedDataReady);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { useCanRegisterDeferredRegistrations };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=useCanRegisterDeferredRegistrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCanRegisterDeferredRegistrations.js","sources":["webpack://@squide/firefly/./src/useCanRegisterDeferredRegistrations.ts"],"sourcesContent":["import { useAppRouterState } from \"./AppRouterContext.ts\";\n\nexport function useCanRegisterDeferredRegistrations() {\n const {\n waitForPublicData,\n waitForProtectedData,\n areModulesReady,\n areModulesRegistered,\n isPublicDataReady,\n isProtectedDataReady,\n activeRouteVisibility,\n isUnauthorized\n } = useAppRouterState();\n\n return (\n !isUnauthorized\n // Wait for the modules to be registered but make sure the deferred registrations has not been registered yet (updates are handled by another hook).\n && areModulesRegistered && !areModulesReady\n // && (!waitForMsw || isMswReady)\n // Wait for the initial data to be ready since the deferred registrations will probably need that data.\n && (!waitForPublicData || isPublicDataReady)\n && (!waitForProtectedData || activeRouteVisibility === \"public\" || isProtectedDataReady)\n );\n}\n"],"names":["useAppRouterState","useCanRegisterDeferredRegistrations","waitForPublicData","waitForProtectedData","areModulesReady","areModulesRegistered","isPublicDataReady","isProtectedDataReady","activeRouteVisibility","isUnauthorized"],"mappings":";;;;;AAA0D;AAEnD,SAASC;IACZ,MAAM,EACFC,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,oBAAoB,EACpBC,iBAAiB,EACjBC,oBAAoB,EACpBC,qBAAqB,EACrBC,cAAc,EACjB,GAAGT,+EAAiBA;IAErB,OACI,CAACS,kBAEEJ,wBAAwB,CAACD,mBAGxB,EAACF,qBAAqBI,iBAAgB,KACtC,EAACH,wBAAwBK,0BAA0B,YAAYD,oBAAmB;AAE9F"}
|