@squide/firefly 15.0.5 → 16.0.1
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 +25 -0
- package/dist/AppRouter.js.map +1 -1
- package/dist/AppRouterContext.js.map +1 -1
- package/dist/AppRouterReducer.d.ts +3 -4
- package/dist/AppRouterReducer.js +51 -82
- package/dist/AppRouterReducer.js.map +1 -1
- package/dist/AppRouterStore.js.map +1 -1
- package/dist/FireflyPlugin.d.ts +6 -0
- package/dist/FireflyPlugin.js +6 -0
- package/dist/FireflyPlugin.js.map +1 -0
- package/dist/FireflyProvider.js.map +1 -1
- package/dist/FireflyRuntime.d.ts +26 -11
- package/dist/FireflyRuntime.js +61 -45
- package/dist/FireflyRuntime.js.map +1 -1
- package/dist/GlobalDataQueriesError.js.map +1 -1
- package/dist/RootRoute.js.map +1 -1
- package/dist/honeycomb/activeSpan.js.map +1 -1
- package/dist/honeycomb/createTraceContextId.js.map +1 -1
- package/dist/honeycomb/initializeHoneycomb.js.map +1 -1
- package/dist/honeycomb/registerHoneycombInstrumentation.d.ts +8 -0
- package/dist/honeycomb/registerHoneycombInstrumentation.js +19 -136
- package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
- package/dist/honeycomb/tracer.js.map +1 -1
- package/dist/honeycomb/utils.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/initializeFirefly.d.ts +8 -6
- package/dist/initializeFirefly.js +34 -34
- package/dist/initializeFirefly.js.map +1 -1
- package/dist/internal.d.ts +6 -0
- package/dist/internal.js +26 -0
- package/dist/internal.js.map +1 -0
- package/dist/useAppRouterStore.js.map +1 -1
- package/dist/useCanFetchProtectedData.js.map +1 -1
- package/dist/useCanFetchPublicData.js.map +1 -1
- package/dist/useCanRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useCanUpdateDeferredRegistrations.js.map +1 -1
- package/dist/useDeferredRegistrations.d.ts +1 -5
- package/dist/useDeferredRegistrations.js +2 -5
- package/dist/useDeferredRegistrations.js.map +1 -1
- package/dist/useExecuteOnce.js.map +1 -1
- package/dist/useIsActiveRouteProtected.js.map +1 -1
- package/dist/useIsBootstrapping.js.map +1 -1
- package/dist/useNavigationItems.js.map +1 -1
- package/dist/useProtectedDataHandler.js.map +1 -1
- package/dist/useProtectedDataQueries.js.map +1 -1
- package/dist/usePublicDataHandler.js.map +1 -1
- package/dist/usePublicDataQueries.js.map +1 -1
- package/dist/useRegisterDeferredRegistrations.d.ts +1 -4
- package/dist/useRegisterDeferredRegistrations.js +1 -5
- package/dist/useRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useStrictRegistrationMode.js +10 -17
- package/dist/useStrictRegistrationMode.js.map +1 -1
- package/dist/useUpdateDeferredRegistrations.d.ts +3 -4
- package/dist/useUpdateDeferredRegistrations.js +6 -6
- package/dist/useUpdateDeferredRegistrations.js.map +1 -1
- package/package.json +33 -23
- package/src/AppRouterReducer.ts +51 -89
- package/src/FireflyPlugin.ts +11 -0
- package/src/FireflyRuntime.tsx +89 -55
- package/src/honeycomb/registerHoneycombInstrumentation.ts +30 -169
- package/src/index.ts +31 -4
- package/src/initializeFirefly.ts +60 -49
- package/src/internal.ts +22 -0
- package/src/useDeferredRegistrations.ts +3 -12
- package/src/useRegisterDeferredRegistrations.ts +1 -2
- package/src/useStrictRegistrationMode.ts +10 -15
- package/src/useUpdateDeferredRegistrations.ts +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @squide/firefly
|
|
2
2
|
|
|
3
|
+
## 16.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#342](https://github.com/workleap/wl-squide/pull/342) [`3be4070`](https://github.com/workleap/wl-squide/commit/3be4070d2d647804903b5cc01113e20d5d71cb11) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Minor fine tuning following v16 release.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`3be4070`](https://github.com/workleap/wl-squide/commit/3be4070d2d647804903b5cc01113e20d5d71cb11)]:
|
|
10
|
+
- @squide/env-vars@1.4.8
|
|
11
|
+
- @squide/core@6.1.5
|
|
12
|
+
- @squide/msw@4.0.6
|
|
13
|
+
- @squide/react-router@8.1.5
|
|
14
|
+
|
|
15
|
+
## 16.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- [#339](https://github.com/workleap/wl-squide/pull/339) [`de6b333`](https://github.com/workleap/wl-squide/commit/de6b3335f538252bac9545d82c8f1218612eb923) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Moved Module Federation features to a new `@squide/firefly-module-federation` package.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`de6b333`](https://github.com/workleap/wl-squide/commit/de6b3335f538252bac9545d82c8f1218612eb923)]:
|
|
24
|
+
- @squide/react-router@8.1.4
|
|
25
|
+
- @squide/core@6.1.4
|
|
26
|
+
- @squide/msw@4.0.5
|
|
27
|
+
|
|
3
28
|
## 15.0.5
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/AppRouter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouter.js","sources":["
|
|
1
|
+
{"version":3,"file":"AppRouter.js","sources":["../src/AppRouter.tsx"],"sourcesContent":["import { useLogger } from \"@squide/core\";\nimport { useRoutes, type Route } from \"@squide/react-router\";\nimport { useEffect, useMemo, type ReactElement } from \"react\";\nimport type { RouterProviderProps } from \"react-router/dom\";\nimport { AppRouterDispatcherContext, AppRouterStateContext } from \"./AppRouterContext.ts\";\nimport { useAppRouterReducer, type AppRouterState } from \"./AppRouterReducer.ts\";\nimport { RootRoute } from \"./RootRoute.tsx\";\nimport { useStrictRegistrationMode } from \"./useStrictRegistrationMode.ts\";\n\nexport interface AppRouterRenderFunctionArgs {\n routes: Route[];\n}\n\nexport interface RenderRouterProviderFunctionArgs {\n rootRoute: ReactElement;\n registeredRoutes: Route[];\n routerProviderProps: Omit<RouterProviderProps, \"router\">;\n}\n\nexport type RenderRouterProviderFunction = (args: RenderRouterProviderFunctionArgs) => ReactElement;\n\nexport function useCanRenderRouter({ areModulesRegistered, areModulesReady: areModulesReadyValue }: AppRouterState) {\n return (\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 || areModulesReadyValue)\n );\n}\n\nfunction useRenderRouterProvider(state: AppRouterState, renderRouterProvider: RenderRouterProviderFunction) {\n const routes = useRoutes();\n\n // The value is computed outside of the router provider memo to prevent\n // rendering a new router provider everytime the app router state change.\n const canRenderRouter = useCanRenderRouter(state);\n\n return useMemo(() => {\n if (canRenderRouter) {\n return renderRouterProvider({\n rootRoute: <RootRoute />,\n registeredRoutes: routes,\n routerProviderProps: {}\n });\n }\n\n return null;\n }, [canRenderRouter, routes, renderRouterProvider]);\n}\n\nexport interface AppRouterProps {\n waitForPublicData?: boolean;\n waitForProtectedData?: boolean;\n children: RenderRouterProviderFunction;\n}\n\nexport function AppRouter(props: AppRouterProps) {\n const {\n waitForPublicData = false,\n waitForProtectedData = false,\n children: renderRouterProvider\n } = props;\n const [state, dispatch] = useAppRouterReducer(waitForPublicData, waitForProtectedData);\n\n const logger = useLogger();\n\n useStrictRegistrationMode();\n\n useEffect(() => {\n logger\n .withText(\"[squide] AppRouter state updated:\")\n .withObject(state)\n .debug();\n }, [state, logger]);\n\n const routerProvider = useRenderRouterProvider(state, renderRouterProvider);\n\n return (\n <AppRouterDispatcherContext.Provider value={dispatch}>\n <AppRouterStateContext.Provider value={state}>\n {routerProvider}\n </AppRouterStateContext.Provider>\n </AppRouterDispatcherContext.Provider>\n );\n}\n"],"names":["useLogger","useRoutes","useEffect","useMemo","AppRouterDispatcherContext","AppRouterStateContext","useAppRouterReducer","RootRoute","useStrictRegistrationMode","useCanRenderRouter","areModulesRegistered","areModulesReadyValue","useRenderRouterProvider","state","renderRouterProvider","routes","canRenderRouter","AppRouter","props","waitForPublicData","waitForProtectedData","dispatch","logger","routerProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAyC;AACoB;AACC;AAE4B;AACT;AACrC;AAC+B;AAcpE,SAASS,mBAAmB,EAAEC,oBAAoB,EAAE,iBAAiBC,oBAAoB,EAAkB;IAC9G,OACI,qIAAqI;IACrI,iCAAiC;IAChCD,wBAAwBC;AAEjC;AAEA,SAASC,wBAAwBC,KAAqB,EAAEC,oBAAkD;IACtG,MAAMC,SAASd,SAASA;IAExB,uEAAuE;IACvE,yEAAyE;IACzE,MAAMe,kBAAkBP,mBAAmBI;IAE3C,OAAOV,OAAOA,CAAC;QACX,IAAIa,iBAAiB;YACjB,OAAOF,qBAAqB;gBACxB,yBAAW,IAACP,SAASA;gBACrB,kBAAkBQ;gBAClB,qBAAqB,CAAC;YAC1B;QACJ;QAEA,OAAO;IACX,GAAG;QAACC;QAAiBD;QAAQD;KAAqB;AACtD;AAQO,SAASG,UAAUC,KAAqB;IAC3C,MAAM,EACFC,oBAAoB,KAAK,EACzBC,uBAAuB,KAAK,EAC5B,UAAUN,oBAAoB,EACjC,GAAGI;IACJ,MAAM,CAACL,OAAOQ,SAAS,GAAGf,mBAAmBA,CAACa,mBAAmBC;IAEjE,MAAME,SAAStB,SAASA;IAExBQ,yBAAyBA;IAEzBN,SAASA,CAAC;QACNoB,OACK,QAAQ,CAAC,qCACT,UAAU,CAACT,OACX,KAAK;IACd,GAAG;QAACA;QAAOS;KAAO;IAElB,MAAMC,iBAAiBX,wBAAwBC,OAAOC;IAEtD,qBACI,IAACV,mCAAmC;QAAC,OAAOiB;kBACxC,kBAAChB,8BAA8B;YAAC,OAAOQ;sBAClCU;;;AAIjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouterContext.js","sources":["
|
|
1
|
+
{"version":3,"file":"AppRouterContext.js","sources":["../src/AppRouterContext.ts"],"sourcesContent":["import { isNil } from \"@squide/core\";\nimport { createContext, useContext } from \"react\";\nimport type { AppRouterDispatch, AppRouterState } from \"./AppRouterReducer.ts\";\n\nexport const AppRouterStateContext = createContext<AppRouterState | undefined>(undefined);\n\nexport function useAppRouterState() {\n const state = useContext(AppRouterStateContext);\n\n if (isNil(state)) {\n throw new Error(\"[squide] The useAppRouterState hook must be called by a children of the AppRouter component.\");\n }\n\n return state;\n}\n\nexport const AppRouterDispatcherContext = createContext<AppRouterDispatch | undefined>(undefined);\n\nexport function useAppRouterDispatcher() {\n const dispatch = useContext(AppRouterDispatcherContext);\n\n if (isNil(dispatch)) {\n throw new Error(\"[squide] The useAppRouterDispatcher hook must be called by a children of the AppRouter component.\");\n }\n\n return dispatch;\n}\n"],"names":["isNil","createContext","useContext","AppRouterStateContext","undefined","useAppRouterState","state","Error","AppRouterDispatcherContext","useAppRouterDispatcher","dispatch"],"mappings":";;;;;;;;AAAqC;AACa;AAG3C,MAAMG,wBAAwBF,aAAaA,CAA6BG,WAAW;AAEnF,SAASC;IACZ,MAAMC,QAAQJ,UAAUA,CAACC;IAEzB,IAAIH,KAAKA,CAACM,QAAQ;QACd,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX;AAEO,MAAME,6BAA6BP,aAAaA,CAAgCG,WAAW;AAE3F,SAASK;IACZ,MAAMC,WAAWR,UAAUA,CAACM;IAE5B,IAAIR,KAAKA,CAACU,WAAW;QACjB,MAAM,IAAIH,MAAM;IACpB;IAEA,OAAOG;AACX"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Dispatch } from "react";
|
|
2
|
+
import type { FireflyRuntime } from "./FireflyRuntime.tsx";
|
|
2
3
|
export type ActiveRouteVisiblity = "unknown" | "public" | "protected";
|
|
3
4
|
export interface AppRouterWaitState {
|
|
4
5
|
waitForMsw: boolean;
|
|
@@ -34,10 +35,8 @@ export interface AppRouterAction {
|
|
|
34
35
|
payload?: unknown;
|
|
35
36
|
}
|
|
36
37
|
export type AppRouterDispatch = Dispatch<AppRouterAction>;
|
|
37
|
-
export declare function
|
|
38
|
-
export declare function
|
|
39
|
-
export declare function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch): void;
|
|
40
|
-
export declare function useMswStatusDispatcher(isMswReadyValue: boolean, dispatch: AppRouterDispatch): void;
|
|
38
|
+
export declare function useModuleRegistrationStatusDispatcher(runtime: FireflyRuntime, areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch): void;
|
|
39
|
+
export declare function useMswStatusDispatcher(runtime: FireflyRuntime, isMswReadyValue: boolean, dispatch: AppRouterDispatch): void;
|
|
41
40
|
export declare function __setAppReducerDispatchProxyFactory(factory: (reactDispatch: AppRouterDispatch) => AppRouterDispatch): void;
|
|
42
41
|
export declare function __clearAppReducerDispatchProxy(): void;
|
|
43
42
|
export declare function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch];
|
package/dist/AppRouterReducer.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, areModulesRegistered, getRemoteModuleRegistrationStatus, removeRemoteModuleRegistrationStatusChangedListener } from "@squide/module-federation";
|
|
3
|
-
import { addMswStateChangedListener, isMswReady, removeMswStateChangedListener } from "@squide/msw";
|
|
1
|
+
import { useEventBus, useLogger, useRuntime } from "@squide/core";
|
|
4
2
|
import { useCallback, useEffect, useMemo, useReducer } from "react";
|
|
5
3
|
import { useAppRouterStore } from "./useAppRouterStore.js";
|
|
6
4
|
import { useExecuteOnce } from "./useExecuteOnce.js";
|
|
@@ -8,10 +6,6 @@ import { isBootstrapping } from "./useIsBootstrapping.js";
|
|
|
8
6
|
|
|
9
7
|
;// CONCATENATED MODULE: external "@squide/core"
|
|
10
8
|
|
|
11
|
-
;// CONCATENATED MODULE: external "@squide/module-federation"
|
|
12
|
-
|
|
13
|
-
;// CONCATENATED MODULE: external "@squide/msw"
|
|
14
|
-
|
|
15
9
|
;// CONCATENATED MODULE: external "react"
|
|
16
10
|
|
|
17
11
|
;// CONCATENATED MODULE: external "./useAppRouterStore.js"
|
|
@@ -26,8 +20,6 @@ import { isBootstrapping } from "./useIsBootstrapping.js";
|
|
|
26
20
|
|
|
27
21
|
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
23
|
// The followings event const are a concatenation of "squide-" with AppRouterActionType.
|
|
32
24
|
// They are dispatched by the useEnhancedReducerDispatch hook.
|
|
33
25
|
const ModulesRegisteredEvent = "squide-modules-registered";
|
|
@@ -143,66 +135,44 @@ function reducer(state, action) {
|
|
|
143
135
|
}
|
|
144
136
|
return newState;
|
|
145
137
|
}
|
|
146
|
-
function
|
|
147
|
-
const localModuleStatus = getLocalModuleRegistrationStatus();
|
|
148
|
-
const remoteModuleStatus = getRemoteModuleRegistrationStatus();
|
|
149
|
-
return areModulesRegistered(localModuleStatus, remoteModuleStatus);
|
|
150
|
-
}
|
|
151
|
-
function getAreModulesReady() {
|
|
152
|
-
const localModuleStatus = getLocalModuleRegistrationStatus();
|
|
153
|
-
const remoteModuleStatus = getRemoteModuleRegistrationStatus();
|
|
154
|
-
return areModulesReady(localModuleStatus, remoteModuleStatus);
|
|
155
|
-
}
|
|
156
|
-
function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areModulesReadyValue, dispatch) {
|
|
138
|
+
function useModuleRegistrationStatusDispatcher(runtime, areModulesRegisteredValue, areModulesReadyValue, dispatch) {
|
|
157
139
|
const logger = useLogger();
|
|
158
|
-
const dispatchModulesRegistered =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}).information();
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
return false;
|
|
140
|
+
const dispatchModulesRegistered = useCallback(()=>{
|
|
141
|
+
dispatch({
|
|
142
|
+
type: "modules-registered"
|
|
143
|
+
});
|
|
144
|
+
logger.withText("[squide] Modules are registered.", {
|
|
145
|
+
style: {
|
|
146
|
+
color: "green"
|
|
147
|
+
}
|
|
148
|
+
}).information();
|
|
171
149
|
}, [
|
|
172
150
|
dispatch,
|
|
173
151
|
logger
|
|
174
|
-
])
|
|
175
|
-
const dispatchModulesReady =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}).information();
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
return false;
|
|
152
|
+
]);
|
|
153
|
+
const dispatchModulesReady = useCallback(()=>{
|
|
154
|
+
dispatch({
|
|
155
|
+
type: "modules-ready"
|
|
156
|
+
});
|
|
157
|
+
logger.withText("[squide] Modules are ready.", {
|
|
158
|
+
style: {
|
|
159
|
+
color: "green"
|
|
160
|
+
}
|
|
161
|
+
}).information();
|
|
188
162
|
}, [
|
|
189
163
|
dispatch,
|
|
190
164
|
logger
|
|
191
|
-
])
|
|
165
|
+
]);
|
|
192
166
|
return useEffect(()=>{
|
|
193
167
|
if (!areModulesRegisteredValue) {
|
|
194
|
-
|
|
195
|
-
addRemoteModuleRegistrationStatusChangedListener(dispatchModulesRegistered);
|
|
168
|
+
runtime.moduleManager.registerModulesRegisteredListener(dispatchModulesRegistered);
|
|
196
169
|
}
|
|
197
170
|
if (!areModulesReadyValue) {
|
|
198
|
-
|
|
199
|
-
addRemoteModuleRegistrationStatusChangedListener(dispatchModulesReady);
|
|
171
|
+
runtime.moduleManager.registerModulesReadyListener(dispatchModulesReady);
|
|
200
172
|
}
|
|
201
173
|
return ()=>{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
removeLocalModuleRegistrationStatusChangedListener(dispatchModulesReady);
|
|
205
|
-
removeRemoteModuleRegistrationStatusChangedListener(dispatchModulesReady);
|
|
174
|
+
runtime.moduleManager.removeModulesRegisteredListener(dispatchModulesRegistered);
|
|
175
|
+
runtime.moduleManager.removeModulesReadyListener(dispatchModulesReady);
|
|
206
176
|
};
|
|
207
177
|
}, [
|
|
208
178
|
areModulesRegisteredValue,
|
|
@@ -211,33 +181,32 @@ function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areMod
|
|
|
211
181
|
dispatchModulesReady
|
|
212
182
|
]);
|
|
213
183
|
}
|
|
214
|
-
function useMswStatusDispatcher(isMswReadyValue, dispatch) {
|
|
184
|
+
function useMswStatusDispatcher(runtime, isMswReadyValue, dispatch) {
|
|
215
185
|
const logger = useLogger();
|
|
216
|
-
const dispatchMswReady =
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}).information();
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
return false;
|
|
186
|
+
const dispatchMswReady = useCallback(()=>{
|
|
187
|
+
dispatch({
|
|
188
|
+
type: "msw-ready"
|
|
189
|
+
});
|
|
190
|
+
logger.withText("[squide] MSW is ready.", {
|
|
191
|
+
style: {
|
|
192
|
+
color: "green"
|
|
193
|
+
}
|
|
194
|
+
}).information();
|
|
229
195
|
}, [
|
|
230
196
|
dispatch,
|
|
231
197
|
logger
|
|
232
|
-
])
|
|
198
|
+
]);
|
|
233
199
|
useEffect(()=>{
|
|
234
|
-
if (
|
|
235
|
-
|
|
200
|
+
if (runtime.isMswEnabled) {
|
|
201
|
+
if (!isMswReadyValue) {
|
|
202
|
+
runtime.getMswState().addMswReadyListener(dispatchMswReady);
|
|
203
|
+
}
|
|
204
|
+
return ()=>{
|
|
205
|
+
runtime.getMswState().removeMswReadyListener(dispatchMswReady);
|
|
206
|
+
};
|
|
236
207
|
}
|
|
237
|
-
return ()=>{
|
|
238
|
-
removeMswStateChangedListener(dispatchMswReady);
|
|
239
|
-
};
|
|
240
208
|
}, [
|
|
209
|
+
runtime,
|
|
241
210
|
isMswReadyValue,
|
|
242
211
|
dispatchMswReady
|
|
243
212
|
]);
|
|
@@ -300,9 +269,9 @@ function useAppRouterReducer(waitForPublicData, waitForProtectedData) {
|
|
|
300
269
|
const eventBus = useEventBus();
|
|
301
270
|
const appRouterStore = useAppRouterStore();
|
|
302
271
|
const isMswEnabled = runtime.isMswEnabled;
|
|
303
|
-
const areModulesInitiallyRegistered = getAreModulesRegistered();
|
|
304
|
-
const areModulesInitiallyReady = getAreModulesReady();
|
|
305
|
-
const isMswInitiallyReady =
|
|
272
|
+
const areModulesInitiallyRegistered = runtime.moduleManager.getAreModulesRegistered();
|
|
273
|
+
const areModulesInitiallyReady = runtime.moduleManager.getAreModulesReady();
|
|
274
|
+
const isMswInitiallyReady = runtime.isMswEnabled ? runtime.getMswState().isReady : false;
|
|
306
275
|
const waitState = useMemo(()=>({
|
|
307
276
|
waitForMsw: isMswEnabled,
|
|
308
277
|
waitForPublicData,
|
|
@@ -387,8 +356,8 @@ function useAppRouterReducer(waitForPublicData, waitForProtectedData) {
|
|
|
387
356
|
// than mocking the import from React.
|
|
388
357
|
const dispatchProxy = useReducerDispatchProxy(reactDispatch);
|
|
389
358
|
const dispatch = useEnhancedReducerDispatch(waitState, dispatchProxy);
|
|
390
|
-
useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areModulesReadyValue, dispatch);
|
|
391
|
-
useMswStatusDispatcher(isMswReadyValue, dispatch);
|
|
359
|
+
useModuleRegistrationStatusDispatcher(runtime, areModulesRegisteredValue, areModulesReadyValue, dispatch);
|
|
360
|
+
useMswStatusDispatcher(runtime, isMswReadyValue, dispatch);
|
|
392
361
|
useBootstrappingCompletedDispatcher(waitState, state);
|
|
393
362
|
return [
|
|
394
363
|
state,
|
|
@@ -396,6 +365,6 @@ function useAppRouterReducer(waitForPublicData, waitForProtectedData) {
|
|
|
396
365
|
];
|
|
397
366
|
}
|
|
398
367
|
|
|
399
|
-
export { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent, __clearAppReducerDispatchProxy, __setAppReducerDispatchProxyFactory,
|
|
368
|
+
export { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent, __clearAppReducerDispatchProxy, __setAppReducerDispatchProxyFactory, useAppRouterReducer, useModuleRegistrationStatusDispatcher, useMswStatusDispatcher };
|
|
400
369
|
|
|
401
370
|
//# sourceMappingURL=AppRouterReducer.js.map
|
|
@@ -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 { useAppRouterStore } from \"./useAppRouterStore.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\nimport { isBootstrapping } from \"./useIsBootstrapping.ts\";\n\nexport type ActiveRouteVisiblity = \"unknown\" | \"public\" | \"protected\";\n\nexport interface AppRouterWaitState {\n waitForMsw: boolean;\n waitForPublicData: boolean;\n waitForProtectedData: boolean;\n}\n\nexport interface AppRouterState extends AppRouterWaitState {\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 payload?: unknown;\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\n .withText(\"[squide] Modules are registered.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\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\n .withText(\"[squide] Modules are ready.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\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\n .withText(\"[squide] MSW is ready.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\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\nfunction useBootstrappingCompletedDispatcher(waitState: AppRouterWaitState, 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, waitState);\n\n return true;\n }\n\n return false;\n }, [areModulesRegisteredValue, isBoostrapping, waitState, 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(waitState: AppRouterWaitState, reducerDispatch: AppRouterDispatch) {\n const logger = useLogger();\n const appRouterStore = useAppRouterStore();\n const eventBus = useEventBus();\n\n return useCallback((action: AppRouterAction) => {\n logger\n .withText(\"[squide] The following action has been dispatched to the AppRouter reducer:\")\n .withObject(action)\n .debug();\n\n appRouterStore.dispatch({ ...action, payload: waitState });\n eventBus.dispatch(`squide-${action.type}`, waitState);\n\n reducerDispatch(action);\n }, [waitState, 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 isMswEnabled = runtime.isMswEnabled;\n\n const areModulesInitiallyRegistered = getAreModulesRegistered();\n const areModulesInitiallyReady = getAreModulesReady();\n const isMswInitiallyReady = isMswReady();\n\n const waitState = useMemo(() => ({\n waitForMsw: isMswEnabled,\n waitForPublicData,\n waitForProtectedData\n }), [isMswEnabled, waitForPublicData, waitForProtectedData]);\n\n const initialState = useMemo(() => ({\n waitForMsw: waitState.waitForMsw,\n waitForPublicData: waitState.waitForPublicData,\n waitForProtectedData: waitState.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 } satisfies AppRouterState), [waitState, areModulesInitiallyRegistered, areModulesInitiallyReady, isMswInitiallyReady]);\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\", payload: waitState });\n eventBus.dispatch(ModulesRegisteredEvent, waitState);\n }\n\n return true;\n }, [areModulesInitiallyRegistered, appRouterStore, eventBus, waitState]), 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\", payload: waitState });\n eventBus.dispatch(ModulesReadyEvent, waitState);\n }\n\n return true;\n }, [areModulesInitiallyReady, appRouterStore, eventBus, waitState]), 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\", payload: waitState });\n eventBus.dispatch(MswReadyEvent, waitState);\n }\n\n return true;\n }, [isMswInitiallyReady, appRouterStore, eventBus, waitState]), true);\n\n const [state, reactDispatch] = useReducer(reducer, initialState);\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(waitState, dispatchProxy);\n\n useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areModulesReadyValue, dispatch);\n useMswStatusDispatcher(isMswReadyValue, dispatch);\n useBootstrappingCompletedDispatcher(waitState, 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","waitState","eventBus","isBoostrapping","dispatchProxyFactory","__setAppReducerDispatchProxyFactory","factory","__clearAppReducerDispatchProxy","undefined","useReducerDispatchProxy","reactDispatch","useEnhancedReducerDispatch","reducerDispatch","appRouterStore","useAppRouterReducer","waitForPublicData","waitForProtectedData","runtime","isMswEnabled","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","initialState","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAyM;AACmB;AACxH;AACjB;AAExB;AACN;AACK;AAoC1D,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;AASpE,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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AUA,CAACe,SAAS0C;IAEnD,MAAM,EACF,sBAAsB/B,yBAAyB,EAC/C,iBAAiBC,oBAAoB,EACrC,YAAYM,eAAe,EAC9B,GAAGjB;IAEJ,iHAAiH;IACjH,sCAAsC;IACtC,MAAM0C,gBAAgBd,wBAAwBC;IAC9C,MAAMjB,WAAWkB,2BAA2BV,WAAWsB;IAEvDjC,sCAAsCC,2BAA2BC,sBAAsBC;IACvFI,uBAAuBC,iBAAiBL;IACxCO,oCAAoCC,WAAWpB;IAE/C,OAAO;QAACA;QAAOY;KAAS;AAC5B"}
|
|
1
|
+
{"version":3,"file":"AppRouterReducer.js","sources":["../src/AppRouterReducer.ts"],"sourcesContent":["import { useEventBus, useLogger, useRuntime } from \"@squide/core\";\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 AppRouterWaitState {\n waitForMsw: boolean;\n waitForPublicData: boolean;\n waitForProtectedData: boolean;\n}\n\nexport interface AppRouterState extends AppRouterWaitState {\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 payload?: unknown;\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 useModuleRegistrationStatusDispatcher(runtime: FireflyRuntime, areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchModulesRegistered = useCallback(() => {\n dispatch({ type: \"modules-registered\" });\n\n logger\n .withText(\"[squide] Modules are registered.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n const dispatchModulesReady = useCallback(() => {\n dispatch({ type: \"modules-ready\" });\n\n logger\n .withText(\"[squide] Modules are ready.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n return useEffect(() => {\n if (!areModulesRegisteredValue) {\n runtime.moduleManager.registerModulesRegisteredListener(dispatchModulesRegistered);\n }\n\n if (!areModulesReadyValue) {\n runtime.moduleManager.registerModulesReadyListener(dispatchModulesReady);\n }\n\n return () => {\n runtime.moduleManager.removeModulesRegisteredListener(dispatchModulesRegistered);\n runtime.moduleManager.removeModulesReadyListener(dispatchModulesReady);\n };\n }, [areModulesRegisteredValue, areModulesReadyValue, dispatchModulesRegistered, dispatchModulesReady]);\n}\n\nexport function useMswStatusDispatcher(runtime: FireflyRuntime, isMswReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchMswReady = useCallback(() => {\n dispatch({ type: \"msw-ready\" });\n\n logger\n .withText(\"[squide] MSW is ready.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n useEffect(() => {\n if (runtime.isMswEnabled) {\n if (!isMswReadyValue) {\n runtime.getMswState().addMswReadyListener(dispatchMswReady);\n }\n\n return () => {\n runtime.getMswState().removeMswReadyListener(dispatchMswReady);\n };\n }\n }, [runtime, isMswReadyValue, dispatchMswReady]);\n}\n\nfunction useBootstrappingCompletedDispatcher(waitState: AppRouterWaitState, 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, waitState);\n\n return true;\n }\n\n return false;\n }, [areModulesRegisteredValue, isBoostrapping, waitState, 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(waitState: AppRouterWaitState, reducerDispatch: AppRouterDispatch) {\n const logger = useLogger();\n const appRouterStore = useAppRouterStore();\n const eventBus = useEventBus();\n\n return useCallback((action: AppRouterAction) => {\n logger\n .withText(\"[squide] The following action has been dispatched to the AppRouter reducer:\")\n .withObject(action)\n .debug();\n\n appRouterStore.dispatch({ ...action, payload: waitState });\n eventBus.dispatch(`squide-${action.type}`, waitState);\n\n reducerDispatch(action);\n }, [waitState, 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 isMswEnabled = runtime.isMswEnabled;\n const areModulesInitiallyRegistered = runtime.moduleManager.getAreModulesRegistered();\n const areModulesInitiallyReady = runtime.moduleManager.getAreModulesReady();\n const isMswInitiallyReady = runtime.isMswEnabled ? runtime.getMswState().isReady : false;\n\n const waitState = useMemo(() => ({\n waitForMsw: isMswEnabled,\n waitForPublicData,\n waitForProtectedData\n }), [isMswEnabled, waitForPublicData, waitForProtectedData]);\n\n const initialState = useMemo(() => ({\n waitForMsw: waitState.waitForMsw,\n waitForPublicData: waitState.waitForPublicData,\n waitForProtectedData: waitState.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 } satisfies AppRouterState), [waitState, areModulesInitiallyRegistered, areModulesInitiallyReady, isMswInitiallyReady]);\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\", payload: waitState });\n eventBus.dispatch(ModulesRegisteredEvent, waitState);\n }\n\n return true;\n }, [areModulesInitiallyRegistered, appRouterStore, eventBus, waitState]), 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\", payload: waitState });\n eventBus.dispatch(ModulesReadyEvent, waitState);\n }\n\n return true;\n }, [areModulesInitiallyReady, appRouterStore, eventBus, waitState]), 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\", payload: waitState });\n eventBus.dispatch(MswReadyEvent, waitState);\n }\n\n return true;\n }, [isMswInitiallyReady, appRouterStore, eventBus, waitState]), true);\n\n const [state, reactDispatch] = useReducer(reducer, initialState);\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(waitState, dispatchProxy);\n\n useModuleRegistrationStatusDispatcher(runtime, areModulesRegisteredValue, areModulesReadyValue, dispatch);\n useMswStatusDispatcher(runtime, isMswReadyValue, dispatch);\n useBootstrappingCompletedDispatcher(waitState, state);\n\n return [state, dispatch];\n}\n"],"names":["useEventBus","useLogger","useRuntime","useCallback","useEffect","useMemo","useReducer","useAppRouterStore","useExecuteOnce","isBootstrapping","ModulesRegisteredEvent","ModulesReadyEvent","MswReadyEvent","ActiveRouteIsPublicEvent","ActiveRouteIsProtectedEvent","PublicDataReadyEvent","ProtectedDataReadyEvent","PublicDataUpdatedEvent","ProtectedDataUpdatedEvent","DeferredRegistrationsUpdatedEvent","ApplicationBoostrappedEvent","reducer","state","action","newState","Date","Error","useModuleRegistrationStatusDispatcher","runtime","areModulesRegisteredValue","areModulesReadyValue","dispatch","logger","dispatchModulesRegistered","dispatchModulesReady","useMswStatusDispatcher","isMswReadyValue","dispatchMswReady","useBootstrappingCompletedDispatcher","waitState","eventBus","isBoostrapping","dispatchProxyFactory","__setAppReducerDispatchProxyFactory","factory","__clearAppReducerDispatchProxy","undefined","useReducerDispatchProxy","reactDispatch","useEnhancedReducerDispatch","reducerDispatch","appRouterStore","useAppRouterReducer","waitForPublicData","waitForProtectedData","isMswEnabled","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","initialState","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;AAAkE;AACiB;AAExB;AACN;AACK;AAoC1D,wFAAwF;AACxF,8DAA8D;AACvD,MAAMU,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;AASpE,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;oBAC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SAASQ,iBAAiBL;IACjDO,oCAAoCC,WAAWjB;IAE/C,OAAO;QAACA;QAAOS;KAAS;AAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouterStore.js","sources":["
|
|
1
|
+
{"version":3,"file":"AppRouterStore.js","sources":["../src/AppRouterStore.ts"],"sourcesContent":["// This file is a low cost port of the AppRouterReducer to a non-React store. It allows, non-React parts of the library to get\n// access to the state and ease the integration with third-party libraries such as the Platform Widgets.\n// Eventually, AppRouterReducer should be deprecated in favor of this new AppRouterStore.\n\nimport type { Logger } from \"@workleap/logging\";\nimport type { AppRouterAction, AppRouterState } from \"./AppRouterReducer.ts\";\n\nexport type AppRouterStoreState = Omit<AppRouterState, \"waitForMsw\" | \"waitForPublicData\" | \"waitForProtectedData\">;\n\nexport type AppRouterStoreListenerFunction = (store: AppRouterStore, unsuscribe: () => void) => void;\n\nexport class AppRouterStore {\n #state: AppRouterStoreState;\n\n readonly #listeners = new Set<AppRouterStoreListenerFunction>();\n readonly #logger: Logger;\n\n constructor(initialialState: AppRouterStoreState, logger: Logger) {\n this.#state = initialialState;\n this.#logger = logger;\n }\n\n subscribe(listener: AppRouterStoreListenerFunction) {\n this.#listeners.add(listener);\n\n return () => {\n this.unsuscribe(listener);\n };\n }\n\n unsuscribe(listener: AppRouterStoreListenerFunction) {\n this.#listeners.delete(listener);\n }\n\n dispatch(action: AppRouterAction) {\n const newState = this.#reducer({ ...this.#state }, action);\n\n this.#logger\n .withText(\"[squide] The AppRouterStore state has been updated to:\")\n .withObject(newState)\n .debug();\n\n this.#state = newState;\n\n // Creating a copy of the listeners in case some are removed during the looping.\n // To be honest, it might not be necessary, I simply don't know.\n new Set(this.#listeners).forEach(x => {\n x(this, () => {\n this.unsuscribe(x);\n });\n });\n }\n\n #reducer(state: AppRouterStoreState, 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 AppRouterStore state reducer doesn't support action type \"${action.type}\".`);\n }\n }\n\n return newState;\n }\n\n get state() {\n return this.#state;\n }\n}\n\nexport function createAppRouterStore(logger: Logger) {\n const initialState: AppRouterStoreState = {\n areModulesRegistered: false,\n areModulesReady: false,\n isMswReady: false,\n isPublicDataReady: false,\n isProtectedDataReady: false,\n activeRouteVisibility: \"unknown\",\n isUnauthorized: false\n };\n\n return new AppRouterStore(initialState, logger);\n}\n"],"names":["AppRouterStore","Set","initialialState","logger","listener","action","newState","x","state","Date","Error","createAppRouterStore","initialState"],"mappings":";;AAAA,8HAA8H;AAC9H,wGAAwG;AACxG,yFAAyF;AASlF,MAAMA;IACT,MAAM,CAAsB;IAEnB,UAAU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ction, HoneycombTrackingUnmanagedErrorHandler } from "./honeycomb/registerHoneycombInstrumentation.ts";
|
|
4
|
+
export interface FireflyPlugin extends Plugin<FireflyRuntime> {
|
|
5
|
+
registerHoneycombTrackingListeners?: (getBootstrappingSpan: GetSpanFunction, getDeferredRegistrationsUpdateSpan: GetSpanFunction, onUnmanagedError: HoneycombTrackingUnmanagedErrorHandler) => HoneycombTrackingUnmanagedErrorHandler;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FireflyPlugin.js","sources":["../src/FireflyPlugin.ts"],"sourcesContent":["import { Plugin } from \"@squide/core\";\nimport { FireflyRuntime } from \"./FireflyRuntime.tsx\";\nimport { GetSpanFunction, HoneycombTrackingUnmanagedErrorHandler } from \"./honeycomb/registerHoneycombInstrumentation.ts\";\n\nexport interface FireflyPlugin extends Plugin<FireflyRuntime> {\n registerHoneycombTrackingListeners?: (\n getBootstrappingSpan: GetSpanFunction,\n getDeferredRegistrationsUpdateSpan: GetSpanFunction,\n onUnmanagedError: HoneycombTrackingUnmanagedErrorHandler\n ) => HoneycombTrackingUnmanagedErrorHandler;\n}\n"],"names":[],"mappings":";;AAUC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FireflyProvider.js","sources":["
|
|
1
|
+
{"version":3,"file":"FireflyProvider.js","sources":["../src/FireflyProvider.tsx"],"sourcesContent":["import { type Runtime, RuntimeContext } from \"@squide/core\";\nimport type { PropsWithChildren } from \"react\";\n\nexport interface FireflyProviderProps extends PropsWithChildren {\n runtime: Runtime;\n}\n\nexport function FireflyProvider(props: FireflyProviderProps) {\n const {\n runtime,\n children\n } = props;\n\n return (\n <RuntimeContext.Provider value={runtime}>\n {children}\n </RuntimeContext.Provider>\n );\n}\n"],"names":["RuntimeContext","FireflyProvider","props","runtime","children"],"mappings":";;;;;;;;;AAA4D;AAOrD,SAASC,gBAAgBC,KAA2B;IACvD,MAAM,EACFC,OAAO,EACPC,QAAQ,EACX,GAAGF;IAEJ,qBACI,IAACF,uBAAuB;QAAC,OAAOG;kBAC3BC;;AAGb"}
|
package/dist/FireflyRuntime.d.ts
CHANGED
|
@@ -1,39 +1,54 @@
|
|
|
1
1
|
import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from "@squide/core";
|
|
2
|
+
import { EnvironmentVariableKey, EnvironmentVariables, EnvironmentVariableValue } from "@squide/env-vars";
|
|
3
|
+
import { MswState } from "@squide/msw";
|
|
2
4
|
import { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from "@squide/react-router";
|
|
3
5
|
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
4
6
|
import type { Logger } from "@workleap/logging";
|
|
5
7
|
import type { RequestHandler } from "msw";
|
|
6
8
|
import { type AppRouterStore } from "./AppRouterStore.ts";
|
|
7
|
-
export interface FireflyRuntimeOptions extends RuntimeOptions {
|
|
8
|
-
useMsw?: boolean;
|
|
9
|
+
export interface FireflyRuntimeOptions<TRuntime extends FireflyRuntime = FireflyRuntime> extends RuntimeOptions<TRuntime> {
|
|
9
10
|
honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;
|
|
10
11
|
}
|
|
11
12
|
export interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {
|
|
12
13
|
}
|
|
13
14
|
export interface IFireflyRuntime extends IReactRouterRuntime {
|
|
15
|
+
getMswState(): MswState;
|
|
14
16
|
registerRequestHandlers: (handlers: RequestHandler[]) => void;
|
|
15
17
|
get requestHandlers(): RequestHandler[];
|
|
16
|
-
get appRouterStore(): AppRouterStore;
|
|
17
18
|
get isMswEnabled(): boolean;
|
|
19
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;
|
|
20
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
|
|
21
|
+
getEnvironmentVariable(key: EnvironmentVariableKey): EnvironmentVariableValue;
|
|
22
|
+
getEnvironmentVariables(): EnvironmentVariables;
|
|
23
|
+
get appRouterStore(): AppRouterStore;
|
|
18
24
|
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;
|
|
19
25
|
}
|
|
20
|
-
export declare class FireflyRuntime extends ReactRouterRuntime implements IFireflyRuntime {
|
|
26
|
+
export declare class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends ReactRouterRuntime<TRuntime> implements IFireflyRuntime {
|
|
21
27
|
protected _appRouterStore: AppRouterStore;
|
|
22
|
-
protected _useMsw: boolean;
|
|
23
28
|
protected _honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;
|
|
24
|
-
constructor(
|
|
29
|
+
constructor(options?: FireflyRuntimeOptions);
|
|
30
|
+
registerRoute(route: Route, options?: RegisterRouteOptions): void;
|
|
31
|
+
getMswState(): MswState;
|
|
25
32
|
registerRequestHandlers(handlers: RequestHandler[], options?: RegisterRequestHandlersOptions): void;
|
|
26
33
|
get requestHandlers(): RequestHandler[];
|
|
27
|
-
registerRoute(route: Route, options?: RegisterRouteOptions): void;
|
|
28
|
-
get appRouterStore(): AppRouterStore;
|
|
29
34
|
get isMswEnabled(): boolean;
|
|
35
|
+
getEnvironmentVariable(key: EnvironmentVariableKey): never;
|
|
36
|
+
getEnvironmentVariables(): EnvironmentVariables;
|
|
37
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;
|
|
38
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
|
|
39
|
+
get appRouterStore(): AppRouterStore;
|
|
30
40
|
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;
|
|
31
|
-
startScope(logger: Logger):
|
|
41
|
+
startScope(logger: Logger): TRuntime;
|
|
32
42
|
}
|
|
33
43
|
export declare class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntime> extends ReactRouterRuntimeScope<TRuntime> implements IFireflyRuntime {
|
|
44
|
+
getMswState(): MswState;
|
|
34
45
|
registerRequestHandlers(handlers: RequestHandler[], options?: RegisterRequestHandlersOptions): void;
|
|
35
46
|
get requestHandlers(): RequestHandler[];
|
|
36
|
-
get appRouterStore(): AppRouterStore;
|
|
37
47
|
get isMswEnabled(): boolean;
|
|
38
|
-
|
|
48
|
+
getEnvironmentVariables(): EnvironmentVariables;
|
|
49
|
+
getEnvironmentVariable(key: EnvironmentVariableKey): never;
|
|
50
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;
|
|
51
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
|
|
52
|
+
get appRouterStore(): AppRouterStore;
|
|
53
|
+
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient;
|
|
39
54
|
}
|