@squide/firefly 13.1.0 → 13.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @squide/firefly
2
2
 
3
+ ## 13.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#300](https://github.com/workleap/wl-squide/pull/300) [`8d3eae2`](https://github.com/workleap/wl-squide/commit/8d3eae2ee4dc0331f83047e3ef313c6abb15dc3f) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Improved the logging API.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`8d3eae2`](https://github.com/workleap/wl-squide/commit/8d3eae2ee4dc0331f83047e3ef313c6abb15dc3f)]:
12
+ - @squide/module-federation@6.4.0
13
+ - @squide/react-router@7.2.0
14
+ - @squide/core@5.6.0
15
+ - @squide/msw@3.4.0
16
+
17
+ ## 13.1.1
18
+
19
+ ### Patch Changes
20
+
21
+ - [#298](https://github.com/workleap/wl-squide/pull/298) [`6a81ee3`](https://github.com/workleap/wl-squide/commit/6a81ee3fdf73726fb0bf050d960e4f16f807b4a7) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Fix Honeycomb integration. Previously `globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK` was exposed by `@workleap/honeycomb` instead of `globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__`.
22
+
23
+ This PR support both until every application migrate to a new version of this package and `@workleap/honeycomb`.
24
+
3
25
  ## 13.1.0
4
26
 
5
27
  ### Minor Changes
package/dist/AppRouter.js CHANGED
@@ -63,7 +63,7 @@ function AppRouter(props) {
63
63
  const logger = useLogger();
64
64
  useStrictRegistrationMode();
65
65
  useEffect(()=>{
66
- logger.debug("[squide] AppRouter state updated:", state);
66
+ logger.withText("[squide] AppRouter state updated:").withObject(state).debug();
67
67
  }, [
68
68
  state,
69
69
  logger
@@ -1 +1 @@
1
- {"version":3,"file":"AppRouter.js","sources":["webpack://@squide/firefly/./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.debug(\"[squide] AppRouter state updated:\", state);\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,OAAO,KAAK,CAAC,qCAAqCT;IACtD,GAAG;QAACA;QAAOS;KAAO;IAElB,MAAMC,iBAAiBX,wBAAwBC,OAAOC;IAEtD,qBACI,IAACV,mCAAmC;QAAC,OAAOiB;kBACxC,kBAAChB,8BAA8B;YAAC,OAAOQ;sBAClCU;;;AAIjB"}
1
+ {"version":3,"file":"AppRouter.js","sources":["webpack://@squide/firefly/./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"}
@@ -160,7 +160,14 @@ function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areMod
160
160
  dispatch({
161
161
  type: "modules-registered"
162
162
  });
163
- logger.debug("[squide] %cModules are registered%c.", "color: white; background-color: green;", "");
163
+ logger.withText("[squide]").withText("Modules are registered", {
164
+ style: {
165
+ color: "white",
166
+ backgroundColor: "green"
167
+ }
168
+ }).withText(".", {
169
+ leadingSpace: false
170
+ }).information();
164
171
  return true;
165
172
  }
166
173
  return false;
@@ -173,7 +180,14 @@ function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areMod
173
180
  dispatch({
174
181
  type: "modules-ready"
175
182
  });
176
- logger.debug("[squide] %cModules are ready%c.", "color: white; background-color: green;", "");
183
+ logger.withText("[squide]").withText("Modules are ready", {
184
+ style: {
185
+ color: "white",
186
+ backgroundColor: "green"
187
+ }
188
+ }).withText(".", {
189
+ leadingSpace: false
190
+ }).information();
177
191
  return true;
178
192
  }
179
193
  return false;
@@ -210,7 +224,14 @@ function useMswStatusDispatcher(isMswReadyValue, dispatch) {
210
224
  dispatch({
211
225
  type: "msw-ready"
212
226
  });
213
- logger.debug("[squide] %cMSW is ready%c.", "color: white; background-color: green;", "");
227
+ logger.withText("[squide]").withText("MSW is ready", {
228
+ style: {
229
+ color: "white",
230
+ backgroundColor: "green"
231
+ }
232
+ }).withText(".", {
233
+ leadingSpace: false
234
+ }).information();
214
235
  return true;
215
236
  }
216
237
  return false;
@@ -267,7 +288,7 @@ function useEnhancedReducerDispatch(reducerDispatch) {
267
288
  const appRouterStore = useAppRouterStore();
268
289
  const eventBus = useEventBus();
269
290
  return useCallback((action)=>{
270
- logger.debug("[squide] The following action has been dispatched to the AppRouter reducer:", action);
291
+ logger.withText("[squide] The following action has been dispatched to the AppRouter reducer:").withObject(action).debug();
271
292
  appRouterStore.dispatch(action);
272
293
  eventBus.dispatch(`squide-${action.type}`);
273
294
  reducerDispatch(action);
@@ -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 AppRouterState {\n waitForMsw: boolean;\n waitForPublicData: boolean;\n waitForProtectedData: boolean;\n areModulesRegistered: boolean;\n areModulesReady: boolean;\n isMswReady: boolean;\n isPublicDataReady: boolean;\n isProtectedDataReady: boolean;\n publicDataUpdatedAt?: number;\n protectedDataUpdatedAt?: number;\n deferredRegistrationsUpdatedAt?: number;\n activeRouteVisibility: ActiveRouteVisiblity;\n isUnauthorized: boolean;\n}\n\nexport type AppRouterActionType =\n| \"modules-registered\"\n| \"modules-ready\"\n| \"msw-ready\"\n| \"public-data-ready\"\n| \"protected-data-ready\"\n| \"public-data-updated\"\n| \"protected-data-updated\"\n| \"deferred-registrations-updated\"\n| \"active-route-is-public\"\n| \"active-route-is-protected\"\n| \"is-unauthorized\";\n\n// The followings event const are a concatenation of \"squide-\" with AppRouterActionType.\n// They are dispatched by the useEnhancedReducerDispatch hook.\nexport const ModulesRegisteredEvent = \"squide-modules-registered\";\nexport const ModulesReadyEvent = \"squide-modules-ready\";\nexport const MswReadyEvent = \"squide-msw-ready\";\nexport const ActiveRouteIsPublicEvent = \"squide-active-route-is-public\";\nexport const ActiveRouteIsProtectedEvent = \"squide-active-route-is-protected\";\nexport const PublicDataReadyEvent = \"squide-public-data-ready\";\nexport const ProtectedDataReadyEvent = \"squide-protected-data-ready\";\nexport const PublicDataUpdatedEvent = \"squide-public-data-updated\";\nexport const ProtectedDataUpdatedEvent = \"squide-protected-data-updated\";\nexport const DeferredRegistrationsUpdatedEvent = \"squide-deferred-registrations-updated\";\nexport const ApplicationBoostrappedEvent = \"squide-app-boostrapped\";\n\nexport interface AppRouterAction {\n type: AppRouterActionType;\n}\n\nexport type AppRouterDispatch = Dispatch<AppRouterAction>;\n\nfunction reducer(state: AppRouterState, action: AppRouterAction) {\n let newState = state;\n\n switch (action.type) {\n case \"modules-registered\": {\n newState = {\n ...newState,\n areModulesRegistered: true\n };\n\n break;\n }\n case \"modules-ready\": {\n newState = {\n ...newState,\n areModulesReady: true,\n // Will be set even if the app is not using deferred registrations.\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"msw-ready\": {\n newState = {\n ...newState,\n isMswReady: true\n };\n\n break;\n }\n case \"public-data-ready\": {\n newState = {\n ...newState,\n isPublicDataReady: true,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-ready\": {\n newState = {\n ...newState,\n isProtectedDataReady: true,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"public-data-updated\": {\n newState = {\n ...newState,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-updated\": {\n newState = {\n ...newState,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"deferred-registrations-updated\": {\n newState = {\n ...newState,\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"active-route-is-public\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"public\"\n };\n\n break;\n }\n case \"active-route-is-protected\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"protected\"\n };\n\n break;\n }\n case \"is-unauthorized\": {\n newState = {\n ...newState,\n isUnauthorized: true\n };\n\n break;\n }\n default: {\n throw new Error(`[squide] The AppRouter component state reducer doesn't support action type \"${action.type}\".`);\n }\n }\n\n return newState;\n}\n\nexport function getAreModulesRegistered() {\n const localModuleStatus = getLocalModuleRegistrationStatus();\n const remoteModuleStatus = getRemoteModuleRegistrationStatus();\n\n return areModulesRegistered(localModuleStatus, remoteModuleStatus);\n}\n\nexport function getAreModulesReady() {\n const localModuleStatus = getLocalModuleRegistrationStatus();\n const remoteModuleStatus = getRemoteModuleRegistrationStatus();\n\n return areModulesReady(localModuleStatus, remoteModuleStatus);\n}\n\nexport function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchModulesRegistered = useExecuteOnce(useCallback(() => {\n if (getAreModulesRegistered()) {\n dispatch({ type: \"modules-registered\" });\n\n logger.debug(\"[squide] %cModules are registered%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n const dispatchModulesReady = useExecuteOnce(useCallback(() => {\n if (getAreModulesReady()) {\n dispatch({ type: \"modules-ready\" });\n\n logger.debug(\"[squide] %cModules are ready%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n return useEffect(() => {\n if (!areModulesRegisteredValue) {\n addLocalModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n addRemoteModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n }\n\n if (!areModulesReadyValue) {\n addLocalModuleRegistrationStatusChangedListener(dispatchModulesReady);\n addRemoteModuleRegistrationStatusChangedListener(dispatchModulesReady);\n }\n\n return () => {\n removeLocalModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n removeRemoteModuleRegistrationStatusChangedListener(dispatchModulesRegistered);\n\n removeLocalModuleRegistrationStatusChangedListener(dispatchModulesReady);\n removeRemoteModuleRegistrationStatusChangedListener(dispatchModulesReady);\n };\n }, [areModulesRegisteredValue, areModulesReadyValue, dispatchModulesRegistered, dispatchModulesReady]);\n}\n\nexport function useMswStatusDispatcher(isMswReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchMswReady = useExecuteOnce(useCallback(() => {\n if (isMswReady()) {\n dispatch({ type: \"msw-ready\" });\n\n logger.debug(\"[squide] %cMSW is ready%c.\", \"color: white; background-color: green;\", \"\");\n\n return true;\n }\n\n return false;\n }, [dispatch, logger]));\n\n useEffect(() => {\n if (!isMswReadyValue) {\n addMswStateChangedListener(dispatchMswReady);\n }\n\n return () => {\n removeMswStateChangedListener(dispatchMswReady);\n };\n }, [isMswReadyValue, dispatchMswReady]);\n}\n\nexport function useBootstrappingCompletedDispatcher(state: AppRouterState) {\n const eventBus = useEventBus();\n\n const areModulesRegisteredValue = state.areModulesRegistered;\n const isBoostrapping = isBootstrapping(state);\n\n useExecuteOnce(useCallback(() => {\n if (areModulesRegisteredValue && !isBoostrapping) {\n eventBus.dispatch(ApplicationBoostrappedEvent);\n\n return true;\n }\n\n return false;\n }, [areModulesRegisteredValue, isBoostrapping, eventBus]), true);\n}\n\nlet dispatchProxyFactory: ((reactDispatch: AppRouterDispatch) => AppRouterDispatch) | undefined;\n\n// This function should only be used by tests.\nexport function __setAppReducerDispatchProxyFactory(factory: (reactDispatch: AppRouterDispatch) => AppRouterDispatch) {\n dispatchProxyFactory = factory;\n}\n\n// This function should only be used by tests.\nexport function __clearAppReducerDispatchProxy() {\n dispatchProxyFactory = undefined;\n}\n\nfunction useReducerDispatchProxy(reactDispatch: AppRouterDispatch) {\n return useMemo(() => {\n return dispatchProxyFactory ? dispatchProxyFactory(reactDispatch) : reactDispatch;\n }, [reactDispatch]);\n}\n\nfunction useEnhancedReducerDispatch(reducerDispatch: AppRouterDispatch) {\n const logger = useLogger();\n const appRouterStore = useAppRouterStore();\n const eventBus = useEventBus();\n\n return useCallback((action: AppRouterAction) => {\n logger.debug(\"[squide] The following action has been dispatched to the AppRouter reducer:\", action);\n\n appRouterStore.dispatch(action);\n eventBus.dispatch(`squide-${action.type}`);\n\n reducerDispatch(action);\n }, [reducerDispatch, logger, appRouterStore, eventBus]);\n}\n\nexport function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {\n const runtime = useRuntime() as FireflyRuntime;\n const eventBus = useEventBus();\n const appRouterStore = useAppRouterStore();\n\n const areModulesInitiallyRegistered = getAreModulesRegistered();\n const areModulesInitiallyReady = getAreModulesReady();\n const isMswInitiallyReady = isMswReady();\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyRegistered) {\n appRouterStore.dispatch({ type: \"modules-registered\" });\n eventBus.dispatch(ModulesRegisteredEvent);\n }\n\n return true;\n }, [areModulesInitiallyRegistered, appRouterStore, eventBus]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyReady) {\n appRouterStore.dispatch({ type: \"modules-ready\" });\n eventBus.dispatch(ModulesReadyEvent);\n }\n\n return true;\n }, [areModulesInitiallyReady, appRouterStore, eventBus]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (isMswInitiallyReady) {\n appRouterStore.dispatch({ type: \"msw-ready\" });\n eventBus.dispatch(MswReadyEvent);\n }\n\n return true;\n }, [isMswInitiallyReady, appRouterStore, eventBus]), true);\n\n const [state, reactDispatch] = useReducer(reducer, {\n waitForMsw: runtime.isMswEnabled,\n waitForPublicData,\n waitForProtectedData,\n // When the modules registration functions are awaited, the event listeners are registered after the modules are registered.\n areModulesRegistered: areModulesInitiallyRegistered,\n areModulesReady: areModulesInitiallyReady,\n isMswReady: isMswInitiallyReady,\n isPublicDataReady: false,\n isProtectedDataReady: false,\n activeRouteVisibility: \"unknown\",\n isUnauthorized: false\n });\n\n const {\n areModulesRegistered: areModulesRegisteredValue,\n areModulesReady: areModulesReadyValue,\n isMswReady: isMswReadyValue\n } = state;\n\n // The dispatch proxy is strictly an utility allowing tests to mock the useReducer dispatch function. It's easier\n // than mocking the import from React.\n const dispatchProxy = useReducerDispatchProxy(reactDispatch);\n const dispatch = useEnhancedReducerDispatch(dispatchProxy);\n\n useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areModulesReadyValue, dispatch);\n useMswStatusDispatcher(isMswReadyValue, dispatch);\n useBootstrappingCompletedDispatcher(state);\n\n return [state, dispatch];\n}\n"],"names":["addLocalModuleRegistrationStatusChangedListener","getLocalModuleRegistrationStatus","removeLocalModuleRegistrationStatusChangedListener","useEventBus","useLogger","useRuntime","addRemoteModuleRegistrationStatusChangedListener","areModulesReady","areModulesRegistered","getRemoteModuleRegistrationStatus","removeRemoteModuleRegistrationStatusChangedListener","addMswStateChangedListener","isMswReady","removeMswStateChangedListener","useCallback","useEffect","useMemo","useReducer","useAppRouterStore","useExecuteOnce","isBootstrapping","ModulesRegisteredEvent","ModulesReadyEvent","MswReadyEvent","ActiveRouteIsPublicEvent","ActiveRouteIsProtectedEvent","PublicDataReadyEvent","ProtectedDataReadyEvent","PublicDataUpdatedEvent","ProtectedDataUpdatedEvent","DeferredRegistrationsUpdatedEvent","ApplicationBoostrappedEvent","reducer","state","action","newState","Date","Error","getAreModulesRegistered","localModuleStatus","remoteModuleStatus","getAreModulesReady","useModuleRegistrationStatusDispatcher","areModulesRegisteredValue","areModulesReadyValue","dispatch","logger","dispatchModulesRegistered","dispatchModulesReady","useMswStatusDispatcher","isMswReadyValue","dispatchMswReady","useBootstrappingCompletedDispatcher","eventBus","isBoostrapping","dispatchProxyFactory","__setAppReducerDispatchProxyFactory","factory","__clearAppReducerDispatchProxy","undefined","useReducerDispatchProxy","reactDispatch","useEnhancedReducerDispatch","reducerDispatch","appRouterStore","useAppRouterReducer","waitForPublicData","waitForProtectedData","runtime","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAyM;AACmB;AACxH;AACjB;AAExB;AACN;AACK;AAiC1D,wFAAwF;AACxF,8DAA8D;AACvD,MAAMqB,yBAAyB,4BAA4B;AAC3D,MAAMC,oBAAoB,uBAAuB;AACjD,MAAMC,gBAAgB,mBAAmB;AACzC,MAAMC,2BAA2B,gCAAgC;AACjE,MAAMC,8BAA8B,mCAAmC;AACvE,MAAMC,uBAAuB,2BAA2B;AACxD,MAAMC,0BAA0B,8BAA8B;AAC9D,MAAMC,yBAAyB,6BAA6B;AAC5D,MAAMC,4BAA4B,gCAAgC;AAClE,MAAMC,oCAAoC,wCAAwC;AAClF,MAAMC,8BAA8B,yBAAyB;AAQp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QACjB,YAAYC;QACZ,mBAAmB;QACnB,sBAAsB;QACtB,uBAAuB;QACvB,gBAAgB;IACpB;IAEA,MAAM,EACF,sBAAsB5B,yBAAyB,EAC/C,iBAAiBC,oBAAoB,EACrC,YAAYM,eAAe,EAC9B,GAAGjB;IAEJ,iHAAiH;IACjH,sCAAsC;IACtC,MAAMuC,gBAAgBZ,wBAAwBC;IAC9C,MAAMhB,WAAWiB,2BAA2BU;IAE5C9B,sCAAsCC,2BAA2BC,sBAAsBC;IACvFI,uBAAuBC,iBAAiBL;IACxCO,oCAAoCnB;IAEpC,OAAO;QAACA;QAAOY;KAAS;AAC5B"}
1
+ {"version":3,"file":"AppRouterReducer.js","sources":["webpack://@squide/firefly/./src/AppRouterReducer.ts"],"sourcesContent":["import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useEventBus, useLogger, useRuntime } from \"@squide/core\";\nimport { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, areModulesRegistered, getRemoteModuleRegistrationStatus, removeRemoteModuleRegistrationStatusChangedListener } from \"@squide/module-federation\";\nimport { addMswStateChangedListener, isMswReady, removeMswStateChangedListener } from \"@squide/msw\";\nimport { useCallback, useEffect, useMemo, useReducer, type Dispatch } from \"react\";\nimport type { FireflyRuntime } from \"./FireflyRuntime.tsx\";\nimport { useAppRouterStore } from \"./useAppRouterStore.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\nimport { isBootstrapping } from \"./useIsBootstrapping.ts\";\n\nexport type ActiveRouteVisiblity = \"unknown\" | \"public\" | \"protected\";\n\nexport interface AppRouterState {\n waitForMsw: boolean;\n waitForPublicData: boolean;\n waitForProtectedData: boolean;\n areModulesRegistered: boolean;\n areModulesReady: boolean;\n isMswReady: boolean;\n isPublicDataReady: boolean;\n isProtectedDataReady: boolean;\n publicDataUpdatedAt?: number;\n protectedDataUpdatedAt?: number;\n deferredRegistrationsUpdatedAt?: number;\n activeRouteVisibility: ActiveRouteVisiblity;\n isUnauthorized: boolean;\n}\n\nexport type AppRouterActionType =\n| \"modules-registered\"\n| \"modules-ready\"\n| \"msw-ready\"\n| \"public-data-ready\"\n| \"protected-data-ready\"\n| \"public-data-updated\"\n| \"protected-data-updated\"\n| \"deferred-registrations-updated\"\n| \"active-route-is-public\"\n| \"active-route-is-protected\"\n| \"is-unauthorized\";\n\n// The followings event const are a concatenation of \"squide-\" with AppRouterActionType.\n// They are dispatched by the useEnhancedReducerDispatch hook.\nexport const ModulesRegisteredEvent = \"squide-modules-registered\";\nexport const ModulesReadyEvent = \"squide-modules-ready\";\nexport const MswReadyEvent = \"squide-msw-ready\";\nexport const ActiveRouteIsPublicEvent = \"squide-active-route-is-public\";\nexport const ActiveRouteIsProtectedEvent = \"squide-active-route-is-protected\";\nexport const PublicDataReadyEvent = \"squide-public-data-ready\";\nexport const ProtectedDataReadyEvent = \"squide-protected-data-ready\";\nexport const PublicDataUpdatedEvent = \"squide-public-data-updated\";\nexport const ProtectedDataUpdatedEvent = \"squide-protected-data-updated\";\nexport const DeferredRegistrationsUpdatedEvent = \"squide-deferred-registrations-updated\";\nexport const ApplicationBoostrappedEvent = \"squide-app-boostrapped\";\n\nexport interface AppRouterAction {\n type: AppRouterActionType;\n}\n\nexport type AppRouterDispatch = Dispatch<AppRouterAction>;\n\nfunction reducer(state: AppRouterState, action: AppRouterAction) {\n let newState = state;\n\n switch (action.type) {\n case \"modules-registered\": {\n newState = {\n ...newState,\n areModulesRegistered: true\n };\n\n break;\n }\n case \"modules-ready\": {\n newState = {\n ...newState,\n areModulesReady: true,\n // Will be set even if the app is not using deferred registrations.\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"msw-ready\": {\n newState = {\n ...newState,\n isMswReady: true\n };\n\n break;\n }\n case \"public-data-ready\": {\n newState = {\n ...newState,\n isPublicDataReady: true,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-ready\": {\n newState = {\n ...newState,\n isProtectedDataReady: true,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"public-data-updated\": {\n newState = {\n ...newState,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-updated\": {\n newState = {\n ...newState,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"deferred-registrations-updated\": {\n newState = {\n ...newState,\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"active-route-is-public\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"public\"\n };\n\n break;\n }\n case \"active-route-is-protected\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"protected\"\n };\n\n break;\n }\n case \"is-unauthorized\": {\n newState = {\n ...newState,\n isUnauthorized: true\n };\n\n break;\n }\n default: {\n throw new Error(`[squide] The AppRouter component state reducer doesn't support action type \"${action.type}\".`);\n }\n }\n\n return newState;\n}\n\nexport function getAreModulesRegistered() {\n const localModuleStatus = getLocalModuleRegistrationStatus();\n const remoteModuleStatus = getRemoteModuleRegistrationStatus();\n\n return areModulesRegistered(localModuleStatus, remoteModuleStatus);\n}\n\nexport function getAreModulesReady() {\n const localModuleStatus = getLocalModuleRegistrationStatus();\n const remoteModuleStatus = getRemoteModuleRegistrationStatus();\n\n return areModulesReady(localModuleStatus, remoteModuleStatus);\n}\n\nexport function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchModulesRegistered = useExecuteOnce(useCallback(() => {\n if (getAreModulesRegistered()) {\n dispatch({ type: \"modules-registered\" });\n\n logger\n .withText(\"[squide]\")\n .withText(\"Modules are registered\", {\n style: {\n color: \"white\",\n backgroundColor: \"green\"\n }\n })\n .withText(\".\", {\n leadingSpace: false\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]\")\n .withText(\"Modules are ready\", {\n style: {\n color: \"white\",\n backgroundColor: \"green\"\n }\n })\n .withText(\".\", {\n leadingSpace: false\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]\")\n .withText(\"MSW is ready\", {\n style: {\n color: \"white\",\n backgroundColor: \"green\"\n }\n })\n .withText(\".\", {\n leadingSpace: false\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\nexport function useBootstrappingCompletedDispatcher(state: AppRouterState) {\n const eventBus = useEventBus();\n\n const areModulesRegisteredValue = state.areModulesRegistered;\n const isBoostrapping = isBootstrapping(state);\n\n useExecuteOnce(useCallback(() => {\n if (areModulesRegisteredValue && !isBoostrapping) {\n eventBus.dispatch(ApplicationBoostrappedEvent);\n\n return true;\n }\n\n return false;\n }, [areModulesRegisteredValue, isBoostrapping, eventBus]), true);\n}\n\nlet dispatchProxyFactory: ((reactDispatch: AppRouterDispatch) => AppRouterDispatch) | undefined;\n\n// This function should only be used by tests.\nexport function __setAppReducerDispatchProxyFactory(factory: (reactDispatch: AppRouterDispatch) => AppRouterDispatch) {\n dispatchProxyFactory = factory;\n}\n\n// This function should only be used by tests.\nexport function __clearAppReducerDispatchProxy() {\n dispatchProxyFactory = undefined;\n}\n\nfunction useReducerDispatchProxy(reactDispatch: AppRouterDispatch) {\n return useMemo(() => {\n return dispatchProxyFactory ? dispatchProxyFactory(reactDispatch) : reactDispatch;\n }, [reactDispatch]);\n}\n\nfunction useEnhancedReducerDispatch(reducerDispatch: AppRouterDispatch) {\n const logger = useLogger();\n const appRouterStore = useAppRouterStore();\n const eventBus = useEventBus();\n\n return useCallback((action: AppRouterAction) => {\n logger\n .withText(\"[squide] The following action has been dispatched to the AppRouter reducer:\")\n .withObject(action)\n .debug();\n\n appRouterStore.dispatch(action);\n eventBus.dispatch(`squide-${action.type}`);\n\n reducerDispatch(action);\n }, [reducerDispatch, logger, appRouterStore, eventBus]);\n}\n\nexport function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {\n const runtime = useRuntime() as FireflyRuntime;\n const eventBus = useEventBus();\n const appRouterStore = useAppRouterStore();\n\n const areModulesInitiallyRegistered = getAreModulesRegistered();\n const areModulesInitiallyReady = getAreModulesReady();\n const isMswInitiallyReady = isMswReady();\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyRegistered) {\n appRouterStore.dispatch({ type: \"modules-registered\" });\n eventBus.dispatch(ModulesRegisteredEvent);\n }\n\n return true;\n }, [areModulesInitiallyRegistered, appRouterStore, eventBus]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyReady) {\n appRouterStore.dispatch({ type: \"modules-ready\" });\n eventBus.dispatch(ModulesReadyEvent);\n }\n\n return true;\n }, [areModulesInitiallyReady, appRouterStore, eventBus]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (isMswInitiallyReady) {\n appRouterStore.dispatch({ type: \"msw-ready\" });\n eventBus.dispatch(MswReadyEvent);\n }\n\n return true;\n }, [isMswInitiallyReady, appRouterStore, eventBus]), true);\n\n const [state, reactDispatch] = useReducer(reducer, {\n waitForMsw: runtime.isMswEnabled,\n waitForPublicData,\n waitForProtectedData,\n // When the modules registration functions are awaited, the event listeners are registered after the modules are registered.\n areModulesRegistered: areModulesInitiallyRegistered,\n areModulesReady: areModulesInitiallyReady,\n isMswReady: isMswInitiallyReady,\n isPublicDataReady: false,\n isProtectedDataReady: false,\n activeRouteVisibility: \"unknown\",\n isUnauthorized: false\n });\n\n const {\n areModulesRegistered: areModulesRegisteredValue,\n areModulesReady: areModulesReadyValue,\n isMswReady: isMswReadyValue\n } = state;\n\n // The dispatch proxy is strictly an utility allowing tests to mock the useReducer dispatch function. It's easier\n // than mocking the import from React.\n const dispatchProxy = useReducerDispatchProxy(reactDispatch);\n const dispatch = useEnhancedReducerDispatch(dispatchProxy);\n\n useModuleRegistrationStatusDispatcher(areModulesRegisteredValue, areModulesReadyValue, dispatch);\n useMswStatusDispatcher(isMswReadyValue, dispatch);\n useBootstrappingCompletedDispatcher(state);\n\n return [state, dispatch];\n}\n"],"names":["addLocalModuleRegistrationStatusChangedListener","getLocalModuleRegistrationStatus","removeLocalModuleRegistrationStatusChangedListener","useEventBus","useLogger","useRuntime","addRemoteModuleRegistrationStatusChangedListener","areModulesReady","areModulesRegistered","getRemoteModuleRegistrationStatus","removeRemoteModuleRegistrationStatusChangedListener","addMswStateChangedListener","isMswReady","removeMswStateChangedListener","useCallback","useEffect","useMemo","useReducer","useAppRouterStore","useExecuteOnce","isBootstrapping","ModulesRegisteredEvent","ModulesReadyEvent","MswReadyEvent","ActiveRouteIsPublicEvent","ActiveRouteIsProtectedEvent","PublicDataReadyEvent","ProtectedDataReadyEvent","PublicDataUpdatedEvent","ProtectedDataUpdatedEvent","DeferredRegistrationsUpdatedEvent","ApplicationBoostrappedEvent","reducer","state","action","newState","Date","Error","getAreModulesRegistered","localModuleStatus","remoteModuleStatus","getAreModulesReady","useModuleRegistrationStatusDispatcher","areModulesRegisteredValue","areModulesReadyValue","dispatch","logger","dispatchModulesRegistered","dispatchModulesReady","useMswStatusDispatcher","isMswReadyValue","dispatchMswReady","useBootstrappingCompletedDispatcher","eventBus","isBoostrapping","dispatchProxyFactory","__setAppReducerDispatchProxyFactory","factory","__clearAppReducerDispatchProxy","undefined","useReducerDispatchProxy","reactDispatch","useEnhancedReducerDispatch","reducerDispatch","appRouterStore","useAppRouterReducer","waitForPublicData","waitForProtectedData","runtime","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAyM;AACmB;AACxH;AACjB;AAExB;AACN;AACK;AAiC1D,wFAAwF;AACxF,8DAA8D;AACvD,MAAMqB,yBAAyB,4BAA4B;AAC3D,MAAMC,oBAAoB,uBAAuB;AACjD,MAAMC,gBAAgB,mBAAmB;AACzC,MAAMC,2BAA2B,gCAAgC;AACjE,MAAMC,8BAA8B,mCAAmC;AACvE,MAAMC,uBAAuB,2BAA2B;AACxD,MAAMC,0BAA0B,8BAA8B;AAC9D,MAAMC,yBAAyB,6BAA6B;AAC5D,MAAMC,4BAA4B,gCAAgC;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AAO;IACX,GAAG;QAACgD;QAA0BN;QAAgBX;KAAS,GAAG;IAE1D,2IAA2I;IAC3I,6HAA6H;IAC7HlC,cAAcA,CAACL,WAAWA,CAAC;QACvB,IAAIyD,qBAAqB;YACrBP,eAAe,QAAQ,CAAC;gBAAE,MAAM;YAAY;YAC5CX,SAAS,QAAQ,CAAC9B;QACtB;QAEA,OAAO;IACX,GAAG;QAACgD;QAAqBP;QAAgBX;KAAS,GAAG;IAErD,MAAM,CAACpB,OAAO4B,cAAc,GAAG5C,UAAUA,CAACe,SAAS;QAC/C,YAAYoC,QAAQ,YAAY;QAChCF;QACAC;QACA,4HAA4H;QAC5H,sBAAsBE;QACtB,iBAAiBC;QACjB,YAAYC;QACZ,mBAAmB;QACnB,sBAAsB;QACtB,uBAAuB;QACvB,gBAAgB;IACpB;IAEA,MAAM,EACF,sBAAsB5B,yBAAyB,EAC/C,iBAAiBC,oBAAoB,EACrC,YAAYM,eAAe,EAC9B,GAAGjB;IAEJ,iHAAiH;IACjH,sCAAsC;IACtC,MAAMuC,gBAAgBZ,wBAAwBC;IAC9C,MAAMhB,WAAWiB,2BAA2BU;IAE5C9B,sCAAsCC,2BAA2BC,sBAAsBC;IACvFI,uBAAuBC,iBAAiBL;IACxCO,oCAAoCnB;IAEpC,OAAO;QAACA;QAAOY;KAAS;AAC5B"}
@@ -1,13 +1,13 @@
1
- import type { RuntimeLogger } from "@squide/core";
1
+ import type { RootLogger } from "@workleap/logging";
2
2
  import type { AppRouterAction, AppRouterState } from "./AppRouterReducer.ts";
3
3
  export type AppRouterStoreState = Omit<AppRouterState, "waitForMsw" | "waitForPublicData" | "waitForProtectedData">;
4
4
  export type AppRouterStoreListenerFunction = (store: AppRouterStore, unsuscribe: () => void) => void;
5
5
  export declare class AppRouterStore {
6
6
  #private;
7
- constructor(initialialState: AppRouterStoreState, logger: RuntimeLogger);
7
+ constructor(initialialState: AppRouterStoreState, logger: RootLogger);
8
8
  subscribe(listener: AppRouterStoreListenerFunction): () => void;
9
9
  unsuscribe(listener: AppRouterStoreListenerFunction): void;
10
10
  dispatch(action: AppRouterAction): void;
11
11
  get state(): AppRouterStoreState;
12
12
  }
13
- export declare function createAppRouterStore(logger: RuntimeLogger): AppRouterStore;
13
+ export declare function createAppRouterStore(logger: RootLogger): AppRouterStore;
@@ -24,7 +24,7 @@ class AppRouterStore {
24
24
  const newState = this.#reducer({
25
25
  ...this.#state
26
26
  }, action);
27
- this.#logger?.debug("[squide] The AppRouterStore state has been updated to:", newState);
27
+ this.#logger.withText("[squide] The AppRouterStore state has been updated to:").withObject(newState).debug();
28
28
  this.#state = newState;
29
29
  // Creating a copy of the listeners in case some are removed during the looping.
30
30
  // To be honest, it might not be necessary, I simply don't know.
@@ -1 +1 @@
1
- {"version":3,"file":"AppRouterStore.js","sources":["webpack://@squide/firefly/./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 { RuntimeLogger } from \"@squide/core\";\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?: RuntimeLogger;\n\n constructor(initialialState: AppRouterStoreState, logger: RuntimeLogger) {\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?.debug(\"[squide] The AppRouterStore state has been updated to:\", newState);\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: RuntimeLogger) {\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,GAAG,IAAIC,MAAsC;IACvD,OAAO,CAAiB;IAEjC,YAAYC,eAAoC,EAAEC,MAAqB,CAAE;QACrE,IAAI,CAAC,MAAM,GAAGD;QACd,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,UAAUC,QAAwC,EAAE;QAChD,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA;QAEpB,OAAO;YACH,IAAI,CAAC,UAAU,CAACA;QACpB;IACJ;IAEA,WAAWA,QAAwC,EAAE;QACjD,IAAI,CAAC,UAAU,CAAC,MAAM,CAACA;IAC3B;IAEA,SAASC,MAAuB,EAAE;QAC9B,MAAMC,WAAW,IAAI,CAAC,QAAQ,CAAC;YAAE,GAAG,IAAI,CAAC,MAAM;QAAC,GAAGD;QAEnD,IAAI,CAAC,OAAO,EAAE,MAAM,0DAA0DC;QAC9E,IAAI,CAAC,MAAM,GAAGA;QAEd,gFAAgF;QAChF,gEAAgE;QAChE,IAAIL,IAAI,IAAI,CAAC,UAAU,EAAE,OAAO,CAACM,CAAAA;YAC7BA,EAAE,IAAI,EAAE;gBACJ,IAAI,CAAC,UAAU,CAACA;YACpB;QACJ;IACJ;IAEA,QAAQ,CAACC,KAA0B,EAAEH,MAAuB;QACxD,IAAIC,WAAWE;QAEf,OAAQH,OAAO,IAAI;YACf,KAAK;gBAAsB;oBACvBC,WAAW;wBACP,GAAGA,QAAQ;wBACX,sBAAsB;oBAC1B;oBAEA;gBACJ;YACA,KAAK;gBAAiB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MAAqB;IACtD,MAAMS,eAAoC;QACtC,sBAAsB;QACtB,iBAAiB;QACjB,YAAY;QACZ,mBAAmB;QACnB,sBAAsB;QACtB,uBAAuB;QACvB,gBAAgB;IACpB;IAEA,OAAO,IAAIZ,eAAeY,cAAcT;AAC5C"}
1
+ {"version":3,"file":"AppRouterStore.js","sources":["webpack://@squide/firefly/./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 { RootLogger } 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: RootLogger;\n\n constructor(initialialState: AppRouterStoreState, logger: RootLogger) {\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: RootLogger) {\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,yFAAy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 import type { RootLogger } from "@workleap/logging";
3
3
  export type ActiveSpanId = string;
4
4
  export interface ActiveSpan {
5
5
  id: ActiveSpanId;
@@ -9,4 +9,4 @@ export interface ActiveSpan {
9
9
  export declare function registerActiveSpanStack(): void;
10
10
  export declare function setActiveSpan(name: string, span: Span): ActiveSpan;
11
11
  export declare function popActiveSpan(span: ActiveSpan): void;
12
- export declare function createOverrideFetchRequestSpanWithActiveSpanContext(logger: RuntimeLogger): (span: Span, request: Request | RequestInit) => true | undefined;
12
+ export declare function createOverrideFetchRequestSpanWithActiveSpanContext(logger: RootLogger): (span: Span, request: Request | RequestInit) => true | undefined;
@@ -84,7 +84,7 @@ function createOverrideFetchRequestSpanWithActiveSpanContext(logger) {
84
84
  const activeSpanContext = activeSpan.instance.spanContext();
85
85
  const requestSpanContext = span.spanContext();
86
86
  if (activeSpanContext) {
87
- logger.debug("[squide] Found a Honeycomb active context to apply to the following fetch request: \r\n", "Request span context: ", requestSpanContext, "\r\n", "Active span context: ", activeSpanContext, "\r\n", "Request: ", request, "\r\n");
87
+ logger.withText("[squide] Found a Honeycomb active context to apply to the following fetch request:").withLineChange().withText("Request span context:").withObject(requestSpanContext).withLineChange().withText("Active span context:").withObject(activeSpanContext).withLineChange().withText("Request:").withObject(request).debug();
88
88
  span.setAttribute("trace.trace_id", activeSpanContext.traceId);
89
89
  span.setAttribute("trace.parent_id", activeSpanContext.spanId);
90
90
  const traceParent = createTraceContextId(activeSpanContext.traceId, requestSpanContext.spanId, requestSpanContext.traceFlags);
@@ -1 +1 @@
1
- {"version":3,"file":"honeycomb/activeSpan.js","sources":["webpack://@squide/firefly/./src/honeycomb/activeSpan.ts"],"sourcesContent":["import type { Span } from \"@opentelemetry/api\";\nimport { isPlainObject, type RuntimeLogger } from \"@squide/core\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { createTraceContextId } from \"./createTraceContextId.ts\";\n\nexport type ActiveSpanId = string;\n\nexport interface ActiveSpan {\n id: ActiveSpanId;\n name: string;\n instance: Span;\n}\n\n// Using a stack because we want a Last In First Out implementation for this.\n// https://github.com/open-telemetry/opentelemetry-js/issues/5084\n// https://github.com/open-telemetry/opentelemetry-js/issues/3558#issuecomment-1760680244\nclass ActiveSpanStack {\n readonly #stack: ActiveSpan[] = [];\n\n push(span: ActiveSpan) {\n this.#stack.push(span);\n }\n\n pop(span: ActiveSpan) {\n const head = this.#stack.pop();\n\n if (!head) {\n throw new Error(\"[squide] Unexpected pop, the active Honeycomb span stack is empty.\");\n }\n\n if (head.id !== span.id) {\n throw new Error(`[squide] The active Honeycomb span is not the expected span. Expected to pop span with name and id \"${span.name} / ${span.id}\" but found \"${head.name} / ${head.id}\". Did you forget to end an active span?`);\n }\n\n return head;\n }\n\n peek() {\n if (this.#stack.length === 0) {\n return undefined;\n }\n\n return this.#stack[this.#stack.length - 1];\n }\n}\n\nconst GlobalActiveSpanStackVariableName = \"__SQUIDE_HONEYCOMB_ACTIVE_SPAN_STACK__\";\n\nexport function registerActiveSpanStack() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (globalThis[GlobalActiveSpanStackVariableName]) {\n throw new Error(`[squide] An ActiveSpanStack instance has already been registered to globalThis.${GlobalActiveSpanStackVariableName}. Did you register the Honeycomb instrumentation twice?`);\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[GlobalActiveSpanStackVariableName] = new ActiveSpanStack();\n}\n\nfunction getActiveSpanStack() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis[GlobalActiveSpanStackVariableName] as ActiveSpanStack;\n}\n\nfunction getActiveSpan() {\n const stack = getActiveSpanStack();\n\n if (stack) {\n return stack.peek();\n }\n}\n\nexport function setActiveSpan(name: string, span: Span) {\n const activeSpan: ActiveSpan = {\n id: uuidv4(),\n name: name,\n instance: span\n };\n\n const stack = getActiveSpanStack();\n\n if (stack) {\n stack.push(activeSpan);\n }\n\n return activeSpan;\n}\n\nexport function popActiveSpan(span: ActiveSpan) {\n const stack = getActiveSpanStack();\n\n if (stack) {\n stack.pop(span);\n }\n}\n\nexport function createOverrideFetchRequestSpanWithActiveSpanContext(logger: RuntimeLogger) {\n return (span: Span, request: Request | RequestInit) => {\n const activeSpan = getActiveSpan();\n\n if (activeSpan) {\n const activeSpanContext = activeSpan.instance.spanContext();\n const requestSpanContext = span.spanContext();\n\n if (activeSpanContext) {\n logger.debug(\n \"[squide] Found a Honeycomb active context to apply to the following fetch request: \\r\\n\",\n \"Request span context: \", requestSpanContext, \"\\r\\n\",\n \"Active span context: \", activeSpanContext, \"\\r\\n\",\n \"Request: \", request, \"\\r\\n\"\n );\n\n span.setAttribute(\"trace.trace_id\", activeSpanContext.traceId);\n span.setAttribute(\"trace.parent_id\", activeSpanContext.spanId);\n\n const traceParent = createTraceContextId(activeSpanContext.traceId, requestSpanContext.spanId, requestSpanContext.traceFlags);\n\n if (request instanceof Request) {\n request.headers.set(\"traceparent\", traceParent);\n } else if (isPlainObject(request.headers)) {\n request.headers[\"traceparent\"] = traceParent;\n }\n\n // Indicates to not propagate the requests to the subsequent hooks.\n return true;\n }\n }\n };\n}\n"],"names":["isPlainObject","v4","uuidv4","createTraceContextId","ActiveSpanStack","span","head","Error","undefined","GlobalActiveSpanStackVariableName","registerActiveSpanStack","globalThis","getActiveSpanStack","getActiveSpan","stack","setActiveSpan","name","activeSpan","popActiveSpan","createOverrideFetchRequestSpanWithActiveSpanContext","logger","request","activeSpanContext","requestSpanContext","traceParent","Request"],"mappings":";;;;;;;;;;;AACiE;AAC7B;AAC6B;AAUjE,6EAA6E;AAC7E,iEAAiE;AACjE,yFAAyF;AACzF,MAAMI;IACO,MAAM,GAAiB,EAAE,CAAC;IAEnC,KAAKC,IAAgB,EAAE;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAACA;IACrB;IAEA,IAAIA,IAAgB,EAAE;QAClB,MAAMC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG;QAE5B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,MAAYgB;QAChB,MAAMJ,aAAaJ;QAEnB,IAAII,YAAY;YACZ,MAAMK,oBAAoBL,WAAW,QAAQ,CAAC,WAAW;YACzD,MAAMM,qBAAqBlB,KAAK,WAAW;YAE3C,IAAIiB,mBAAmB;gBACnBF,OAAO,KAAK,CACR,2FACA,0BAA0BG,oBAAoB,QAC9C,yBAAyBD,mBAAmB,QAC5C,aAAaD,SAAS;gBAG1BhB,KAAK,YAAY,CAAC,kBAAkBiB,kBAAkB,OAAO;gBAC7DjB,KAAK,YAAY,CAAC,mBAAmBiB,kBAAkB,MAAM;gBAE7D,MAAME,cAAcrB,oBAAoBA,CAACmB,kBAAkB,OAAO,EAAEC,mBAAmB,MAAM,EAAEA,mBAAmB,UAAU;gBAE5H,IAAIF,mBAAmBI,SAAS;oBAC5BJ,QAAQ,OAAO,CAAC,GAAG,CAAC,eAAeG;gBACvC,OAAO,IAAIxB,aAAaA,CAACqB,QAAQ,OAAO,GAAG;oBACvCA,QAAQ,OAAO,CAAC,cAAc,GAAGG;gBACrC;gBAEA,mEAAmE;gBACnE,OAAO;YACX;QACJ;IACJ;AACJ"}
1
+ {"version":3,"file":"honeycomb/activeSpan.js","sources":["webpack://@squide/firefly/./src/honeycomb/activeSpan.ts"],"sourcesContent":["import type { Span } from \"@opentelemetry/api\";\nimport { isPlainObject } from \"@squide/core\";\nimport type { RootLogger } from \"@workleap/logging\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { createTraceContextId } from \"./createTraceContextId.ts\";\n\nexport type ActiveSpanId = string;\n\nexport interface ActiveSpan {\n id: ActiveSpanId;\n name: string;\n instance: Span;\n}\n\n// Using a stack because we want a Last In First Out implementation for this.\n// https://github.com/open-telemetry/opentelemetry-js/issues/5084\n// https://github.com/open-telemetry/opentelemetry-js/issues/3558#issuecomment-1760680244\nclass ActiveSpanStack {\n readonly #stack: ActiveSpan[] = [];\n\n push(span: ActiveSpan) {\n this.#stack.push(span);\n }\n\n pop(span: ActiveSpan) {\n const head = this.#stack.pop();\n\n if (!head) {\n throw new Error(\"[squide] Unexpected pop, the active Honeycomb span stack is empty.\");\n }\n\n if (head.id !== span.id) {\n throw new Error(`[squide] The active Honeycomb span is not the expected span. Expected to pop span with name and id \"${span.name} / ${span.id}\" but found \"${head.name} / ${head.id}\". Did you forget to end an active span?`);\n }\n\n return head;\n }\n\n peek() {\n if (this.#stack.length === 0) {\n return undefined;\n }\n\n return this.#stack[this.#stack.length - 1];\n }\n}\n\nconst GlobalActiveSpanStackVariableName = \"__SQUIDE_HONEYCOMB_ACTIVE_SPAN_STACK__\";\n\nexport function registerActiveSpanStack() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (globalThis[GlobalActiveSpanStackVariableName]) {\n throw new Error(`[squide] An ActiveSpanStack instance has already been registered to globalThis.${GlobalActiveSpanStackVariableName}. Did you register the Honeycomb instrumentation twice?`);\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[GlobalActiveSpanStackVariableName] = new ActiveSpanStack();\n}\n\nfunction getActiveSpanStack() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis[GlobalActiveSpanStackVariableName] as ActiveSpanStack;\n}\n\nfunction getActiveSpan() {\n const stack = getActiveSpanStack();\n\n if (stack) {\n return stack.peek();\n }\n}\n\nexport function setActiveSpan(name: string, span: Span) {\n const activeSpan: ActiveSpan = {\n id: uuidv4(),\n name: name,\n instance: span\n };\n\n const stack = getActiveSpanStack();\n\n if (stack) {\n stack.push(activeSpan);\n }\n\n return activeSpan;\n}\n\nexport function popActiveSpan(span: ActiveSpan) {\n const stack = getActiveSpanStack();\n\n if (stack) {\n stack.pop(span);\n }\n}\n\nexport function createOverrideFetchRequestSpanWithActiveSpanContext(logger: RootLogger) {\n return (span: Span, request: Request | RequestInit) => {\n const activeSpan = getActiveSpan();\n\n if (activeSpan) {\n const activeSpanContext = activeSpan.instance.spanContext();\n const requestSpanContext = span.spanContext();\n\n if (activeSpanContext) {\n logger\n .withText(\"[squide] Found a Honeycomb active context to apply to the following fetch request:\")\n .withLineChange()\n .withText(\"Request span context:\")\n .withObject(requestSpanContext)\n .withLineChange()\n .withText(\"Active span context:\")\n .withObject(activeSpanContext)\n .withLineChange()\n .withText(\"Request:\")\n .withObject(request)\n .debug();\n\n span.setAttribute(\"trace.trace_id\", activeSpanContext.traceId);\n span.setAttribute(\"trace.parent_id\", activeSpanContext.spanId);\n\n const traceParent = createTraceContextId(activeSpanContext.traceId, requestSpanContext.spanId, requestSpanContext.traceFlags);\n\n if (request instanceof Request) {\n request.headers.set(\"traceparent\", traceParent);\n } else if (isPlainObject(request.headers)) {\n request.headers[\"traceparent\"] = traceParent;\n }\n\n // Indicates to not propagate the requests to the subsequent hooks.\n return true;\n }\n }\n };\n}\n"],"names":["isPlainObject","v4","uuidv4","createTraceContextId","ActiveSpanStack","span","head","Error","undefined","GlobalActiveSpanStackVariableName","registerActiveSpanStack","globalThis","getActiveSpanStack","getActiveSpan","stack","setActiveSpan","name","activeSpan","popActiveSpan","createOverrideFetchRequestSpanWithActiveSpanContext","logger","request","activeSpanContext","requestSpanContext","traceParent","Request"],"mappings":";;;;;;;;;;;AAC6C;AAET;AAC6B;AAUjE,6EAA6E;AAC7E,iEAAiE;AACjE,yFAAyF;AACzF,MAAMI;IACO,MAAM,GAAiB,EAAE,CAAC;IAEnC,KAAKC,IAAgB,EAAE;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAACA;IACrB;IAEA,IAAIA,IAAgB,EAAE;QAClB,MAAMC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG;QAE5B,IAAI,CAACA,MAAM;YACP,MAAM,IAAIC,MAAM;QACpB;QAEA,IAAID,KAAK,EAAE,KAAKD,KAAK,EAAE,EAAE;YACrB,MAAM,IAAIE,MAAM,CAAC,oGAAoG,EAAEF,KAAK,IAAI,CAAC,GAAG,EAAEA,KAAK,EAAE,CAAC,aAAa,EAAEC,K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,CAAC,yBACT,UAAU,CAACG,oBACX,cAAc,GACd,QAAQ,CAAC,wBACT,UAAU,CAACD,mBACX,cAAc,GACd,QAAQ,CAAC,YACT,UAAU,CAACD,SACX,KAAK;gBAEVhB,KAAK,YAAY,CAAC,kBAAkBiB,kBAAkB,OAAO;gBAC7DjB,KAAK,YAAY,CAAC,mBAAmBiB,kBAAkB,MAAM;gBAE7D,MAAME,cAAcrB,oBAAoBA,CAACmB,kBAAkB,OAAO,EAAEC,mBAAmB,MAAM,EAAEA,mBAAmB,UAAU;gBAE5H,IAAIF,mBAAmBI,SAAS;oBAC5BJ,QAAQ,OAAO,CAAC,GAAG,CAAC,eAAeG;gBACvC,OAAO,IAAIxB,aAAaA,CAACqB,QAAQ,OAAO,GAAG;oBACvCA,QAAQ,OAAO,CAAC,cAAc,GAAGG;gBACrC;gBAEA,mEAAmE;gBACnE,OAAO;YACX;QACJ;IACJ;AACJ"}
@@ -1,9 +1,10 @@
1
1
 
2
2
  ;// CONCATENATED MODULE: ./src/honeycomb/canRegisterHoneycombInstrumentation.ts
3
3
  function canRegisterHoneycombInstrumentation() {
4
+ // The second one is due to an error. Will be able to remove soon.
4
5
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
6
  // @ts-ignore
6
- return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true;
7
+ return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true || globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED === true;
7
8
  }
8
9
 
9
10
  export { canRegisterHoneycombInstrumentation };
@@ -1 +1 @@
1
- {"version":3,"file":"honeycomb/canRegisterHoneycombInstrumentation.js","sources":["webpack://@squide/firefly/./src/honeycomb/canRegisterHoneycombInstrumentation.ts"],"sourcesContent":["export function canRegisterHoneycombInstrumentation() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true;\n}\n"],"names":["canRegisterHoneycombInstrumentation","globalThis"],"mappings":";;AAAO,SAASA;IACZ,6DAA6D;IAC7D,aAAa;IACb,OAAOC,WAAW,+CAA+C,KAAK;AAC1E"}
1
+ {"version":3,"file":"honeycomb/canRegisterHoneycombInstrumentation.js","sources":["webpack://@squide/firefly/./src/honeycomb/canRegisterHoneycombInstrumentation.ts"],"sourcesContent":["export function canRegisterHoneycombInstrumentation() {\n // The second one is due to an error. Will be able to remove soon.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true || globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED === true;\n}\n"],"names":["canRegisterHoneycombInstrumentation","globalThis"],"mappings":";;AAAO,SAASA;IACZ,kEAAkE;IAClE,6DAA6D;IAC7D,aAAa;IACb,OAAOC,WAAW,+CAA+C,KAAK,QAAQA,WAAW,6CAA6C,KAAK;AAC/I"}
@@ -16,7 +16,7 @@ async function initializeHoneycomb(runtime) {
16
16
  throw error;
17
17
  }
18
18
  } else {
19
- runtime.logger.debug("[squide] Cannot register Honeycomb instrumentation because the host application is not using the \"@workleap/honeycomb\" package.");
19
+ runtime.logger.information("[squide] Cannot register Honeycomb instrumentation because the host application is not using the \"@workleap/honeycomb\" package.");
20
20
  }
21
21
  }
22
22
 
@@ -1 +1 @@
1
- {"version":3,"file":"honeycomb/initializeHoneycomb.js","sources":["webpack://@squide/firefly/./src/honeycomb/initializeHoneycomb.ts"],"sourcesContent":["import type { FireflyRuntime } from \"../FireflyRuntime.tsx\";\nimport { canRegisterHoneycombInstrumentation } from \"./canRegisterHoneycombInstrumentation.ts\";\n\nexport async function initializeHoneycomb(runtime: FireflyRuntime) {\n if (canRegisterHoneycombInstrumentation()) {\n try {\n // Dynamically import the Honeycomb instrumentation to prevent loading all the Honeycomb libraries\n // if Honeycomb instrumentation is not registered by the hosting application.\n const mod = await import(\"./registerHoneycombInstrumentation.ts\");\n\n mod.registerHoneycombInstrumentation(runtime);\n } catch (error: unknown) {\n runtime.logger.error(\"[squide] Failed to register Honeycomb instrumentation. The \\\"./registerHoneycombInstrumentation.ts\\\" cannot be imported.\");\n\n throw error;\n }\n } else {\n runtime.logger.debug(\"[squide] Cannot register Honeycomb instrumentation because the host application is not using the \\\"@workleap/honeycomb\\\" package.\");\n }\n}\n\n\n"],"names":["canRegisterHoneycombInstrumentation","initializeHoneycomb","runtime","mod","error"],"mappings":";;;;;AAC+F;AAExF,eAAeC,oBAAoBC,OAAuB;IAC7D,IAAIF,mCAAmCA,IAAI;QACvC,IAAI;YACA,kGAAkG;YAClG,6EAA6E;YAC7E,MAAMG,MAAM,MAAM,+CAA+C;YAEjEA,IAAI,gCAAgC,CAACD;QACzC,EAAE,OAAOE,OAAgB;YACrBF,QAAQ,MAAM,CAAC,KAAK,CAAC;YAErB,MAAME;QACV;IACJ,OAAO;QACHF,QAAQ,MAAM,CAAC,KAAK,CAAC;IACzB;AACJ"}
1
+ {"version":3,"file":"honeycomb/initializeHoneycomb.js","sources":["webpack://@squide/firefly/./src/honeycomb/initializeHoneycomb.ts"],"sourcesContent":["import type { FireflyRuntime } from \"../FireflyRuntime.tsx\";\nimport { canRegisterHoneycombInstrumentation } from \"./canRegisterHoneycombInstrumentation.ts\";\n\nexport async function initializeHoneycomb(runtime: FireflyRuntime) {\n if (canRegisterHoneycombInstrumentation()) {\n try {\n // Dynamically import the Honeycomb instrumentation to prevent loading all the Honeycomb libraries\n // if Honeycomb instrumentation is not registered by the hosting application.\n const mod = await import(\"./registerHoneycombInstrumentation.ts\");\n\n mod.registerHoneycombInstrumentation(runtime);\n } catch (error: unknown) {\n runtime.logger.error(\"[squide] Failed to register Honeycomb instrumentation. The \\\"./registerHoneycombInstrumentation.ts\\\" cannot be imported.\");\n\n throw error;\n }\n } else {\n runtime.logger.information(\"[squide] Cannot register Honeycomb instrumentation because the host application is not using the \\\"@workleap/honeycomb\\\" package.\");\n }\n}\n\n\n"],"names":["canRegisterHoneycombInstrumentation","initializeHoneycomb","runtime","mod","error"],"mappings":";;;;;AAC+F;AAExF,eAAeC,oBAAoBC,OAAuB;IAC7D,IAAIF,mCAAmCA,IAAI;QACvC,IAAI;YACA,kGAAkG;YAClG,6EAA6E;YAC7E,MAAMG,MAAM,MAAM,+CAA+C;YAEjEA,IAAI,gCAAgC,CAACD;QACzC,EAAE,OAAOE,OAAgB;YACrBF,QAAQ,MAAM,CAAC,KAAK,CAAC;YAErB,MAAME;QACV;IACJ,OAAO;QACHF,QAAQ,MAAM,CAAC,WAAW,CAAC;IAC/B;AACJ"}
@@ -406,6 +406,14 @@ function registerTrackingListeners(runtime) {
406
406
  });
407
407
  }
408
408
  function getRegisterFetchRequestHookFunction() {
409
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
410
+ // @ts-ignore
411
+ if (globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__) {
412
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
413
+ // @ts-ignore
414
+ return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__;
415
+ }
416
+ // Fallback to fix an error. Will remove soon.
409
417
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
410
418
  // @ts-ignore
411
419
  return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK;
@@ -419,7 +427,7 @@ function registerHoneycombInstrumentation(runtime) {
419
427
  // of squide bootstrapping under the appropriate Honeycomb span.
420
428
  registerFetchRequestHookFunction(activeSpanOverrideFunction);
421
429
  } else {
422
- runtime.logger.warning("[squide] Cannot register Honeycomb fetch request hook because \"globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK\" is not available. Honeycomb instrumentation is still functional but in degraded mode.");
430
+ runtime.logger.warning("[squide] Cannot register Honeycomb fetch request hook because \"globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__\" is not available. Honeycomb instrumentation is still functional but in degraded mode.");
423
431
  }
424
432
  registerTrackingListeners(runtime);
425
433
  }
@@ -1 +1 @@
1
- {"version":3,"file":"honeycomb/registerHoneycombInstrumentation.js","sources":["webpack://@squide/firefly/./src/honeycomb/registerHoneycombInstrumentation.ts"],"sourcesContent":["import type { Span } from \"@opentelemetry/api\";\nimport {\n LocalModuleDeferredRegistrationFailedEvent,\n LocalModuleDeferredRegistrationUpdateFailedEvent,\n LocalModuleRegistrationFailedEvent,\n LocalModulesDeferredRegistrationCompletedEvent,\n type LocalModulesDeferredRegistrationCompletedEventPayload,\n LocalModulesDeferredRegistrationStartedEvent,\n type LocalModulesDeferredRegistrationStartedEventPayload,\n LocalModulesDeferredRegistrationsUpdateCompletedEvent,\n type LocalModulesDeferredRegistrationsUpdateCompletedEventPayload,\n LocalModulesDeferredRegistrationsUpdateStartedEvent,\n type LocalModulesDeferredRegistrationsUpdateStartedEventPayload,\n LocalModulesRegistrationCompletedEvent,\n type LocalModulesRegistrationCompletedEventPayload,\n LocalModulesRegistrationStartedEvent,\n type LocalModulesRegistrationStartedEventPayload,\n type ModuleRegistrationError\n} from \"@squide/core\";\nimport {\n DeferredRegistrationsUpdateCompletedEvent,\n DeferredRegistrationsUpdateStartedEvent,\n RemoteModuleDeferredRegistrationFailedEvent,\n RemoteModuleDeferredRegistrationUpdateFailedEvent,\n type RemoteModuleRegistrationError,\n RemoteModuleRegistrationFailedEvent,\n RemoteModulesDeferredRegistrationCompletedEvent,\n type RemoteModulesDeferredRegistrationCompletedEventPayload,\n RemoteModulesDeferredRegistrationStartedEvent,\n type RemoteModulesDeferredRegistrationStartedEventPayload,\n RemoteModulesDeferredRegistrationsUpdateCompletedEvent,\n type RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload,\n RemoteModulesDeferredRegistrationsUpdateStartedEvent,\n type RemoteModulesDeferredRegistrationsUpdateStartedEventPayload,\n RemoteModulesRegistrationCompletedEvent,\n type RemoteModulesRegistrationCompletedEventPayload,\n RemoteModulesRegistrationStartedEvent,\n type RemoteModulesRegistrationStartedEventPayload\n} from \"@squide/module-federation\";\nimport { ApplicationBoostrappedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, PublicDataReadyEvent } from \"../AppRouterReducer.ts\";\nimport type { FireflyRuntime } from \"../FireflyRuntime.tsx\";\nimport { ApplicationBootstrappingStartedEvent } from \"../initializeFirefly.ts\";\nimport { ProtectedDataFetchFailedEvent, ProtectedDataFetchStartedEvent } from \"../useProtectedDataQueries.ts\";\nimport { PublicDataFetchFailedEvent, PublicDataFetchStartedEvent } from \"../usePublicDataQueries.ts\";\nimport { type ActiveSpan, createOverrideFetchRequestSpanWithActiveSpanContext, registerActiveSpanStack } from \"./activeSpan.ts\";\nimport { getTracer } from \"./tracer.ts\";\nimport { endActiveSpan, startActiveChildSpan, startChildSpan, startSpan, traceError } from \"./utils.ts\";\n\n// TIPS:\n// To query those traces in Honeycomb, use the following query filter: \"root.name = squide-bootstrapping\".\n\ntype DataFetchState = \"none\" | \"fetching-data\" | \"public-data-ready\" | \"protected-data-ready\" | \"data-ready\" | \"data-fetch-failed\";\n\nexport function reduceDataFetchEvents(\n runtime: FireflyRuntime,\n onDataFetchStarted: () => void,\n onDataReady: () => void,\n onPublicDataFetchStarted: () => void,\n onPublicDataReady: () => void,\n onProtectedDataFetchStarted: () => void,\n onProtectedDataReady: () => void,\n onDataFetchFailed: (queriesErrors: Error[]) => void\n) {\n let dataFetchState: DataFetchState = \"none\";\n\n runtime.eventBus.addListener(PublicDataFetchStartedEvent, () => {\n if (dataFetchState === \"none\") {\n dataFetchState = \"fetching-data\";\n onDataFetchStarted();\n }\n\n onPublicDataFetchStarted();\n }, { once: true });\n\n runtime.eventBus.addListener(PublicDataReadyEvent, () => {\n onPublicDataReady();\n\n if (dataFetchState === \"fetching-data\") {\n dataFetchState = \"public-data-ready\";\n } else if (dataFetchState === \"protected-data-ready\") {\n dataFetchState = \"data-ready\";\n onDataReady();\n }\n }, { once: true });\n\n runtime.eventBus.addListener(ProtectedDataFetchStartedEvent, () => {\n if (dataFetchState === \"none\") {\n dataFetchState = \"fetching-data\";\n onDataFetchStarted();\n }\n\n onProtectedDataFetchStarted();\n }, { once: true });\n\n runtime.eventBus.addListener(ProtectedDataReadyEvent, () => {\n onProtectedDataReady();\n\n if (dataFetchState === \"fetching-data\") {\n dataFetchState = \"protected-data-ready\";\n } else if (dataFetchState === \"public-data-ready\") {\n dataFetchState = \"data-ready\";\n onDataReady();\n }\n }, { once: true });\n\n const handleDataFetchFailed = (payload: unknown) => {\n if (dataFetchState !== \"data-fetch-failed\") {\n dataFetchState = \"data-fetch-failed\";\n\n onDataFetchFailed(payload as Error[]);\n }\n };\n\n runtime.eventBus.addListener(PublicDataFetchFailedEvent, handleDataFetchFailed, { once: true });\n runtime.eventBus.addListener(ProtectedDataFetchFailedEvent, handleDataFetchFailed, { once: true });\n}\n\nfunction registerTrackingListeners(runtime: FireflyRuntime) {\n let bootstrappingSpan: Span;\n let localModuleRegistrationSpan: Span;\n let localModuleDeferredRegistrationSpan: Span;\n let remoteModuleRegistrationSpan: Span;\n let remoteModuleDeferredRegistrationSpan: Span;\n let dataFetchSpan: ActiveSpan;\n let deferredRegistrationsUpdateSpan: Span;\n let localModuleDeferredRegistrationsUpdateSpan: ActiveSpan;\n let remoteModuleDeferredRegistrationsUpdateSpan: ActiveSpan;\n\n runtime.eventBus.addListener(ApplicationBootstrappingStartedEvent, () => {\n bootstrappingSpan = startSpan((options, context) => getTracer().startSpan(\"squide-bootstrapping\", options, context));\n }, { once: true });\n\n runtime.eventBus.addListener(ApplicationBoostrappedEvent, () => {\n if (bootstrappingSpan) {\n bootstrappingSpan.end();\n }\n }, { once: true });\n\n runtime.eventBus.addListener(MswReadyEvent, () => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"msw-ready\");\n }\n }, { once: true });\n\n runtime.eventBus.addListener(LocalModulesRegistrationStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.module_count\": (payload as LocalModulesRegistrationStartedEventPayload).moduleCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"local-module-registration-started\", attributes);\n }\n\n localModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"local-module-registration\", { ...options, attributes }, context);\n });\n }, { once: true });\n\n runtime.eventBus.addListener(LocalModulesRegistrationCompletedEvent, (payload: unknown) => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"local-module-registration-completed\", {\n \"app.squide.module_count\": (payload as LocalModulesRegistrationCompletedEventPayload).moduleCount\n });\n }\n\n if (localModuleRegistrationSpan) {\n localModuleRegistrationSpan.end();\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModuleRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as ModuleRegistrationError;\n\n if (localModuleRegistrationSpan) {\n traceError(localModuleRegistrationSpan, registrationError);\n }\n });\n\n runtime.eventBus.addListener(LocalModulesDeferredRegistrationStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.registration_count\": (payload as LocalModulesDeferredRegistrationStartedEventPayload).registrationCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"local-module-deferred-registration-started\", attributes);\n }\n\n localModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"local-module-deferred-registration\", { ...options, attributes }, context);\n });\n }, { once: true });\n\n runtime.eventBus.addListener(LocalModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"local-module-deferred-registration-completed\", {\n \"app.squide.registration_count\": (payload as LocalModulesDeferredRegistrationCompletedEventPayload).registrationCount\n });\n }\n\n if (localModuleDeferredRegistrationSpan) {\n localModuleDeferredRegistrationSpan.end();\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModuleDeferredRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as ModuleRegistrationError;\n\n if (localModuleDeferredRegistrationSpan) {\n traceError(localModuleRegistrationSpan, registrationError);\n }\n });\n\n runtime.eventBus.addListener(RemoteModulesRegistrationStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationStartedEventPayload).remoteCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-started\", attributes);\n }\n\n remoteModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-registration\", { ...options, attributes }, context);\n });\n }, { once: true });\n\n runtime.eventBus.addListener(RemoteModulesRegistrationCompletedEvent, (payload: unknown) => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-completed\", {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationCompletedEventPayload).remoteCount\n });\n }\n\n if (remoteModuleRegistrationSpan) {\n remoteModuleRegistrationSpan.end();\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModuleRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleRegistrationSpan) {\n traceError(remoteModuleRegistrationSpan, registrationError);\n }\n });\n\n runtime.eventBus.addListener(RemoteModulesDeferredRegistrationStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationStartedEventPayload).registrationCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-deferred-registration\", { ...options, attributes }, context);\n });\n }, { once: true });\n\n runtime.eventBus.addListener(RemoteModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationSpan) {\n remoteModuleDeferredRegistrationSpan.end();\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModuleDeferredRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationSpan) {\n traceError(remoteModuleDeferredRegistrationSpan, registrationError);\n }\n });\n\n const handleFetchDataStarted = () => {\n dataFetchSpan = startActiveChildSpan(bootstrappingSpan, (options, context) => {\n const name = \"data-fetch\";\n const span = getTracer().startSpan(name, options, context);\n\n return {\n name,\n span\n };\n });\n };\n\n const handleDataReady = () => {\n if (dataFetchSpan) {\n endActiveSpan(dataFetchSpan);\n }\n };\n\n const handlePublicDataFetchStarted = () => {\n if (dataFetchSpan) {\n dataFetchSpan.instance.addEvent(\"public-data-fetch-started\");\n }\n };\n\n const handlePublicDataReady = () => {\n if (dataFetchSpan) {\n dataFetchSpan.instance.addEvent(\"public-data-ready\");\n }\n };\n\n const handleProtectedDataFetchStarted = () => {\n if (dataFetchSpan) {\n dataFetchSpan.instance.addEvent(\"protected-data-fetch-started\");\n }\n };\n\n const handleProtectedDataReady = () => {\n if (dataFetchSpan) {\n dataFetchSpan.instance.addEvent(\"protected-data-ready\");\n }\n };\n\n const handleDataFetchFailed = (queriesErrors: Error[]) => {\n if (dataFetchSpan) {\n queriesErrors.forEach(x => {\n traceError(dataFetchSpan.instance, x);\n });\n\n dataFetchSpan.instance.end();\n }\n };\n\n reduceDataFetchEvents(\n runtime,\n handleFetchDataStarted,\n handleDataReady,\n handlePublicDataFetchStarted,\n handlePublicDataReady,\n handleProtectedDataFetchStarted,\n handleProtectedDataReady,\n handleDataFetchFailed\n );\n\n runtime.eventBus.addListener(ModulesRegisteredEvent, () => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"modules-registered\");\n }\n }, { once: true });\n\n runtime.eventBus.addListener(ModulesReadyEvent, () => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"modules-ready\");\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(DeferredRegistrationsUpdateStartedEvent, () => {\n deferredRegistrationsUpdateSpan = startSpan((options, context) => getTracer().startSpan(\"squide-deferred-registrations-update\", options, context));\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(DeferredRegistrationsUpdateCompletedEvent, () => {\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.end();\n }\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.registration_count\": (payload as LocalModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount\n };\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"local-module-deferred-registrations-update-started\", attributes);\n }\n\n localModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context) => {\n const name = \"local-module-deferred-registrations-update\";\n\n const span = getTracer().startSpan(name, {\n attributes,\n ...options\n }, context);\n\n return {\n name,\n span\n };\n });\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"local-module-deferred-registrations-update-completed\", {\n \"app.squide.registration_count\": (payload as LocalModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount\n });\n }\n\n if (localModuleDeferredRegistrationsUpdateSpan) {\n endActiveSpan(localModuleDeferredRegistrationsUpdateSpan);\n }\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {\n const registrationError = payload as ModuleRegistrationError;\n\n if (localModuleDeferredRegistrationsUpdateSpan) {\n traceError(localModuleDeferredRegistrationsUpdateSpan.instance, registrationError);\n }\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount\n };\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context) => {\n const name = \"remote-module-deferred-registrations-update\";\n\n const span = getTracer().startSpan(name, {\n attributes,\n ...options\n }, context);\n\n return {\n name,\n span\n };\n });\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n endActiveSpan(remoteModuleDeferredRegistrationsUpdateSpan);\n }\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);\n }\n });\n}\n\nfunction getRegisterFetchRequestHookFunction() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK;\n}\n\nexport function registerHoneycombInstrumentation(runtime: FireflyRuntime) {\n const registerFetchRequestHookFunction = getRegisterFetchRequestHookFunction();\n\n if (registerFetchRequestHookFunction) {\n registerActiveSpanStack();\n\n const activeSpanOverrideFunction = createOverrideFetchRequestSpanWithActiveSpanContext(runtime.logger);\n\n // Dynamically registering this request hook function to nest the HTTP requests\n // of squide bootstrapping under the appropriate Honeycomb span.\n registerFetchRequestHookFunction(activeSpanOverrideFunction);\n } else {\n runtime.logger.warning(\"[squide] Cannot register Honeycomb fetch request hook because \\\"globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK\\\" is not available. Honeycomb instrumentation is still functional but in degraded mode.\");\n }\n\n registerTrackingListeners(runtime);\n}\n"],"names":["LocalModuleDeferredRegistrationFailedEvent","LocalModuleDeferredRegistrationUpdateFailedEvent","LocalModuleRegistrationFailedEvent","LocalModulesDeferredRegistrationCompletedEvent","LocalModulesDeferredRegistrationStartedEvent","LocalModulesDeferredRegistrationsUpdateCompletedEvent","LocalModulesDeferredRegistrationsUpdateStartedEvent","LocalModulesRegistrationCompletedEvent","LocalModulesRegistrationStartedEvent","DeferredRegistrationsUpdateCompletedEvent","DeferredRegistrationsUpdateStartedEvent","RemoteModuleDeferredRegistrationFailedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteModuleRegistrationFailedEvent","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModulesRegistrationStartedEvent","ApplicationBoostrappedEvent","ModulesReadyEvent","ModulesRegisteredEvent","MswReadyEvent","ProtectedDataReadyEvent","PublicDataReadyEvent","ApplicationBootstrappingStartedEvent","ProtectedDataFetchFailedEvent","ProtectedDataFetchStartedEvent","PublicDataFetchFailedEvent","PublicDataFetchStartedEvent","createOverrideFetchRequestSpanWithActiveSpanContext","registerActiveSpanStack","getTracer","endActiveSpan","startActiveChildSpan","startChildSpan","startSpan","traceError","reduceDataFetchEvents","runtime","onDataFetchStarted","onDataReady","onPublicDataFetchStarted","onPublicDataReady","onProtectedDataFetchStarted","onProtectedDataReady","onDataFetchFailed","dataFetchState","handleDataFetchFailed","payload","registerTrackingListeners","bootstrappingSpan","localModuleRegistrationSpan","localModuleDeferredRegistrationSpan","remoteModuleRegistrationSpan","remoteModuleDeferredRegistrationSpan","dataFetchSpan","deferredRegistrationsUpdateSpan","localModuleDeferredRegistrationsUpdateSpan","remoteModuleDeferredRegistrationsUpdateSpan","options","context","attributes","registrationError","handleFetchDataStarted","name","span","handleDataReady","handlePublicDataFetchStarted","handlePublicDataReady","handleProtectedDataFetchStarted","handleProtectedDataReady","queriesErrors","x","getRegisterFetchRequestHookFunction","globalThis","registerHoneycombInstrumentation","registerFetchRequestHookFunction","activeSpanOverrideFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBsB;AAoBa;AAC2I;AAE/F;AAC+B;AACT;AAC2B;AACxF;AACgE;AAOjG,SAASuC,sBACZC,OAAuB,EACvBC,kBAA8B,EAC9BC,WAAuB,EACvBC,wBAAoC,EACpCC,iBAA6B,EAC7BC,2BAAuC,EACvCC,oBAAgC,EAChCC,iBAAmD;IAEnD,IAAIC,iBAAiC;IAErCR,QAAQ,QAAQ,CAAC,WAAW,CAACV,2BAA2BA,EAAE;QACtD,IAAIkB,mBAAmB,QAAQ;YAC3BA,iBAAiB;YACjBP;QACJ;QAEAE;IACJ,GAAG;QAAE,MAAM;IAAK;IAEhBH,QAAQ,QAAQ,CAAC,WAAW,CAACf,oBAAoBA,EAAE;QAC/CmB;QAEA,IAAII,mBAAmB,iBAAiB;YACpCA,iBAAiB;QACrB,OAAO,IAAIA,mBAAmB,wBAAwB;YAClDA,iBAAiB;YACjBN;QACJ;IACJ,GAAG;QAAE,MAAM;IAAK;IAEhBF,QAAQ,Q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1B,aAAaA,CAAC0B;QAClB;IACJ;IAEA,4BAA4B;IAC5BpB,QAAQ,QAAQ,CAAC,WAAW,CAAC5B,iDAAiDA,EAAE,CAACsC;QAC7E,MAAMc,oBAAoBd;QAE1B,IAAIU,6CAA6C;YAC7CtB,UAAUA,CAACsB,4CAA4C,QAAQ,EAAEI;QACrE;IACJ;AACJ;AAEA,SAASW;IACL,6DAA6D;IAC7D,aAAa;IACb,OAAOC,WAAW,mDAAmD;AACzE;AAEO,SAASC,iCAAiCrC,OAAuB;IACpE,MAAMsC,mCAAmCH;IAEzC,IAAIG,kCAAkC;QAClC9C,uBAAuBA;QAEvB,MAAM+C,6BAA6BhD,mDAAmDA,CAACS,QAAQ,MAAM;QAErG,+EAA+E;QAC/E,gEAAgE;QAChEsC,iCAAiCC;IACrC,OAAO;QACHvC,QAAQ,MAAM,CAAC,OAAO,CAAC;IAC3B;IAEAW,0BAA0BX;AAC9B"}
1
+ {"version":3,"file":"honeycomb/registerHoneycombInstrumentation.js","sources":["webpack://@squide/firefly/./src/honeycomb/registerHoneycombInstrumentation.ts"],"sourcesContent":["import type { Span } from \"@opentelemetry/api\";\nimport {\n LocalModuleDeferredRegistrationFailedEvent,\n LocalModuleDeferredRegistrationUpdateFailedEvent,\n LocalModuleRegistrationFailedEvent,\n LocalModulesDeferredRegistrationCompletedEvent,\n type LocalModulesDeferredRegistrationCompletedEventPayload,\n LocalModulesDeferredRegistrationStartedEvent,\n type LocalModulesDeferredRegistrationStartedEventPayload,\n LocalModulesDeferredRegistrationsUpdateCompletedEvent,\n type LocalModulesDeferredRegistrationsUpdateCompletedEventPayload,\n LocalModulesDeferredRegistrationsUpdateStartedEvent,\n type LocalModulesDeferredRegistrationsUpdateStartedEventPayload,\n LocalModulesRegistrationCompletedEvent,\n type LocalModulesRegistrationCompletedEventPayload,\n LocalModulesRegistrationStartedEvent,\n type LocalModulesRegistrationStartedEventPayload,\n type ModuleRegistrationError\n} from \"@squide/core\";\nimport {\n DeferredRegistrationsUpdateCompletedEvent,\n DeferredRegistrationsUpdateStartedEvent,\n RemoteModuleDeferredRegistrationFailedEvent,\n RemoteModuleDeferredRegistrationUpdateFailedEvent,\n type RemoteModuleRegistrationError,\n RemoteModuleRegistrationFailedEvent,\n RemoteModulesDeferredRegistrationCompletedEvent,\n type RemoteModulesDeferredRegistrationCompletedEventPayload,\n RemoteModulesDeferredRegistrationStartedEvent,\n type RemoteModulesDeferredRegistrationStartedEventPayload,\n RemoteModulesDeferredRegistrationsUpdateCompletedEvent,\n type RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload,\n RemoteModulesDeferredRegistrationsUpdateStartedEvent,\n type RemoteModulesDeferredRegistrationsUpdateStartedEventPayload,\n RemoteModulesRegistrationCompletedEvent,\n type RemoteModulesRegistrationCompletedEventPayload,\n RemoteModulesRegistrationStartedEvent,\n type RemoteModulesRegistrationStartedEventPayload\n} from \"@squide/module-federation\";\nimport { ApplicationBoostrappedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, PublicDataReadyEvent } from \"../AppRouterReducer.ts\";\nimport type { FireflyRuntime } from \"../FireflyRuntime.tsx\";\nimport { ApplicationBootstrappingStartedEvent } from \"../initializeFirefly.ts\";\nimport { ProtectedDataFetchFailedEvent, ProtectedDataFetchStartedEvent } from \"../useProtectedDataQueries.ts\";\nimport { PublicDataFetchFailedEvent, PublicDataFetchStartedEvent } from \"../usePublicDataQueries.ts\";\nimport { type ActiveSpan, createOverrideFetchRequestSpanWithActiveSpanContext, registerActiveSpanStack } from \"./activeSpan.ts\";\nimport { getTracer } from \"./tracer.ts\";\nimport { endActiveSpan, startActiveChildSpan, startChildSpan, startSpan, traceError } from \"./utils.ts\";\n\n// TIPS:\n// To query those traces in Honeycomb, use the following query filter: \"root.name = squide-bootstrapping\".\n\ntype DataFetchState = \"none\" | \"fetching-data\" | \"public-data-ready\" | \"protected-data-ready\" | \"data-ready\" | \"data-fetch-failed\";\n\nexport function reduceDataFetchEvents(\n runtime: FireflyRuntime,\n onDataFetchStarted: () => void,\n onDataReady: () => void,\n onPublicDataFetchStarted: () => void,\n onPublicDataReady: () => void,\n onProtectedDataFetchStarted: () => void,\n onProtectedDataReady: () => void,\n onDataFetchFailed: (queriesErrors: Error[]) => void\n) {\n let dataFetchState: DataFetchState = \"none\";\n\n runtime.eventBus.addListener(PublicDataFetchStartedEvent, () => {\n if (dataFetchState === \"none\") {\n dataFetchState = \"fetching-data\";\n onDataFetchStarted();\n }\n\n onPublicDataFetchStarted();\n }, { once: true });\n\n runtime.eventBus.addListener(PublicDataReadyEvent, () => {\n onPublicDataReady();\n\n if (dataFetchState === \"fetching-data\") {\n dataFetchState = \"public-data-ready\";\n } else if (dataFetchState === \"protected-data-ready\") {\n dataFetchState = \"data-ready\";\n onDataReady();\n }\n }, { once: true });\n\n runtime.eventBus.addListener(ProtectedDataFetchStartedEvent, () => {\n if (dataFetchState === \"none\") {\n dataFetchState = \"fetching-data\";\n onDataFetchStarted();\n }\n\n onProtectedDataFetchStarted();\n }, { once: true });\n\n runtime.eventBus.addListener(ProtectedDataReadyEvent, () => {\n onProtectedDataReady();\n\n if (dataFetchState === \"fetching-data\") {\n dataFetchState = \"protected-data-ready\";\n } else if (dataFetchState === \"public-data-ready\") {\n dataFetchState = \"data-ready\";\n onDataReady();\n }\n }, { once: true });\n\n const handleDataFetchFailed = (payload: unknown) => {\n if (dataFetchState !== \"data-fetch-failed\") {\n dataFetchState = \"data-fetch-failed\";\n\n onDataFetchFailed(payload as Error[]);\n }\n };\n\n runtime.eventBus.addListener(PublicDataFetchFailedEvent, handleDataFetchFailed, { once: true });\n runtime.eventBus.addListener(ProtectedDataFetchFailedEvent, handleDataFetchFailed, { once: true });\n}\n\nfunction registerTrackingListeners(runtime: FireflyRuntime) {\n let bootstrappingSpan: Span;\n let localModuleRegistrationSpan: Span;\n let localModuleDeferredRegistrationSpan: Span;\n let remoteModuleRegistrationSpan: Span;\n let remoteModuleDeferredRegistrationSpan: Span;\n let dataFetchSpan: ActiveSpan;\n let deferredRegistrationsUpdateSpan: Span;\n let localModuleDeferredRegistrationsUpdateSpan: ActiveSpan;\n let remoteModuleDeferredRegistrationsUpdateSpan: ActiveSpan;\n\n runtime.eventBus.addListener(ApplicationBootstrappingStartedEvent, () => {\n bootstrappingSpan = startSpan((options, context) => getTracer().startSpan(\"squide-bootstrapping\", options, context));\n }, { once: true });\n\n runtime.eventBus.addListener(ApplicationBoostrappedEvent, () => {\n if (bootstrappingSpan) {\n bootstrappingSpan.end();\n }\n }, { once: true });\n\n runtime.eventBus.addListener(MswReadyEvent, () => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"msw-ready\");\n }\n }, { once: true });\n\n runtime.eventBus.addListener(LocalModulesRegistrationStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.module_count\": (payload as LocalModulesRegistrationStartedEventPayload).moduleCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"local-module-registration-started\", attributes);\n }\n\n localModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"local-module-registration\", { ...options, attributes }, context);\n });\n }, { once: true });\n\n runtime.eventBus.addListener(LocalModulesRegistrationCompletedEvent, (payload: unknown) => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"local-module-registration-completed\", {\n \"app.squide.module_count\": (payload as LocalModulesRegistrationCompletedEventPayload).moduleCount\n });\n }\n\n if (localModuleRegistrationSpan) {\n localModuleRegistrationSpan.end();\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModuleRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as ModuleRegistrationError;\n\n if (localModuleRegistrationSpan) {\n traceError(localModuleRegistrationSpan, registrationError);\n }\n });\n\n runtime.eventBus.addListener(LocalModulesDeferredRegistrationStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.registration_count\": (payload as LocalModulesDeferredRegistrationStartedEventPayload).registrationCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"local-module-deferred-registration-started\", attributes);\n }\n\n localModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"local-module-deferred-registration\", { ...options, attributes }, context);\n });\n }, { once: true });\n\n runtime.eventBus.addListener(LocalModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"local-module-deferred-registration-completed\", {\n \"app.squide.registration_count\": (payload as LocalModulesDeferredRegistrationCompletedEventPayload).registrationCount\n });\n }\n\n if (localModuleDeferredRegistrationSpan) {\n localModuleDeferredRegistrationSpan.end();\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModuleDeferredRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as ModuleRegistrationError;\n\n if (localModuleDeferredRegistrationSpan) {\n traceError(localModuleRegistrationSpan, registrationError);\n }\n });\n\n runtime.eventBus.addListener(RemoteModulesRegistrationStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationStartedEventPayload).remoteCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-started\", attributes);\n }\n\n remoteModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-registration\", { ...options, attributes }, context);\n });\n }, { once: true });\n\n runtime.eventBus.addListener(RemoteModulesRegistrationCompletedEvent, (payload: unknown) => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-completed\", {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationCompletedEventPayload).remoteCount\n });\n }\n\n if (remoteModuleRegistrationSpan) {\n remoteModuleRegistrationSpan.end();\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModuleRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleRegistrationSpan) {\n traceError(remoteModuleRegistrationSpan, registrationError);\n }\n });\n\n runtime.eventBus.addListener(RemoteModulesDeferredRegistrationStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationStartedEventPayload).registrationCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-deferred-registration\", { ...options, attributes }, context);\n });\n }, { once: true });\n\n runtime.eventBus.addListener(RemoteModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationSpan) {\n remoteModuleDeferredRegistrationSpan.end();\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModuleDeferredRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationSpan) {\n traceError(remoteModuleDeferredRegistrationSpan, registrationError);\n }\n });\n\n const handleFetchDataStarted = () => {\n dataFetchSpan = startActiveChildSpan(bootstrappingSpan, (options, context) => {\n const name = \"data-fetch\";\n const span = getTracer().startSpan(name, options, context);\n\n return {\n name,\n span\n };\n });\n };\n\n const handleDataReady = () => {\n if (dataFetchSpan) {\n endActiveSpan(dataFetchSpan);\n }\n };\n\n const handlePublicDataFetchStarted = () => {\n if (dataFetchSpan) {\n dataFetchSpan.instance.addEvent(\"public-data-fetch-started\");\n }\n };\n\n const handlePublicDataReady = () => {\n if (dataFetchSpan) {\n dataFetchSpan.instance.addEvent(\"public-data-ready\");\n }\n };\n\n const handleProtectedDataFetchStarted = () => {\n if (dataFetchSpan) {\n dataFetchSpan.instance.addEvent(\"protected-data-fetch-started\");\n }\n };\n\n const handleProtectedDataReady = () => {\n if (dataFetchSpan) {\n dataFetchSpan.instance.addEvent(\"protected-data-ready\");\n }\n };\n\n const handleDataFetchFailed = (queriesErrors: Error[]) => {\n if (dataFetchSpan) {\n queriesErrors.forEach(x => {\n traceError(dataFetchSpan.instance, x);\n });\n\n dataFetchSpan.instance.end();\n }\n };\n\n reduceDataFetchEvents(\n runtime,\n handleFetchDataStarted,\n handleDataReady,\n handlePublicDataFetchStarted,\n handlePublicDataReady,\n handleProtectedDataFetchStarted,\n handleProtectedDataReady,\n handleDataFetchFailed\n );\n\n runtime.eventBus.addListener(ModulesRegisteredEvent, () => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"modules-registered\");\n }\n }, { once: true });\n\n runtime.eventBus.addListener(ModulesReadyEvent, () => {\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"modules-ready\");\n }\n }, { once: true });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(DeferredRegistrationsUpdateStartedEvent, () => {\n deferredRegistrationsUpdateSpan = startSpan((options, context) => getTracer().startSpan(\"squide-deferred-registrations-update\", options, context));\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(DeferredRegistrationsUpdateCompletedEvent, () => {\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.end();\n }\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.registration_count\": (payload as LocalModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount\n };\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"local-module-deferred-registrations-update-started\", attributes);\n }\n\n localModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context) => {\n const name = \"local-module-deferred-registrations-update\";\n\n const span = getTracer().startSpan(name, {\n attributes,\n ...options\n }, context);\n\n return {\n name,\n span\n };\n });\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"local-module-deferred-registrations-update-completed\", {\n \"app.squide.registration_count\": (payload as LocalModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount\n });\n }\n\n if (localModuleDeferredRegistrationsUpdateSpan) {\n endActiveSpan(localModuleDeferredRegistrationsUpdateSpan);\n }\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(LocalModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {\n const registrationError = payload as ModuleRegistrationError;\n\n if (localModuleDeferredRegistrationsUpdateSpan) {\n traceError(localModuleDeferredRegistrationsUpdateSpan.instance, registrationError);\n }\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount\n };\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context) => {\n const name = \"remote-module-deferred-registrations-update\";\n\n const span = getTracer().startSpan(name, {\n attributes,\n ...options\n }, context);\n\n return {\n name,\n span\n };\n });\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n endActiveSpan(remoteModuleDeferredRegistrationsUpdateSpan);\n }\n });\n\n // Can occur multiple times.\n runtime.eventBus.addListener(RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);\n }\n });\n}\n\nfunction getRegisterFetchRequestHookFunction() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__;\n }\n\n // Fallback to fix an error. Will remove soon.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK;\n}\n\nexport function registerHoneycombInstrumentation(runtime: FireflyRuntime) {\n const registerFetchRequestHookFunction = getRegisterFetchRequestHookFunction();\n\n if (registerFetchRequestHookFunction) {\n registerActiveSpanStack();\n\n const activeSpanOverrideFunction = createOverrideFetchRequestSpanWithActiveSpanContext(runtime.logger);\n\n // Dynamically registering this request hook function to nest the HTTP requests\n // of squide bootstrapping under the appropriate Honeycomb span.\n registerFetchRequestHookFunction(activeSpanOverrideFunction);\n } else {\n runtime.logger.warning(\"[squide] Cannot register Honeycomb fetch request hook because \\\"globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__\\\" is not available. Honeycomb instrumentation is still functional but in degraded mode.\");\n }\n\n registerTrackingListeners(runtime);\n}\n"],"names":["LocalModuleDeferredRegistrationFailedEvent","LocalModuleDeferredRegistrationUpdateFailedEvent","LocalModuleRegistrationFailedEvent","LocalModulesDeferredRegistrationCompletedEvent","LocalModulesDeferredRegistrationStartedEvent","LocalModulesDeferredRegistrationsUpdateCompletedEvent","LocalModulesDeferredRegistrationsUpdateStartedEvent","LocalModulesRegistrationCompletedEvent","LocalModulesRegistrationStartedEvent","DeferredRegistrationsUpdateCompletedEvent","DeferredRegistrationsUpdateStartedEvent","RemoteModuleDeferredRegistrationFailedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteModuleRegistrationFailedEvent","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModulesRegistrationStartedEvent","ApplicationBoostrappedEvent","ModulesReadyEvent","ModulesRegisteredEvent","MswReadyEvent","ProtectedDataReadyEvent","PublicDataReadyEvent","ApplicationBootstrappingStartedEvent","ProtectedDataFetchFailedEvent","ProtectedDataFetchStartedEvent","PublicDataFetchFailedEvent","PublicDataFetchStartedEvent","createOverrideFetchRequestSpanWithActiveSpanContext","registerActiveSpanStack","getTracer","endActiveSpan","startActiveChildSpan","startChildSpan","startSpan","traceError","reduceDataFetchEvents","runtime","onDataFetchStarted","onDataReady","onPublicDataFetchStarted","onPublicDataReady","onProtectedDataFetchStarted","onProtectedDataReady","onDataFetchFailed","dataFetchState","handleDataFetchFailed","payload","registerTrackingListeners","bootstrappingSpan","localModuleRegistrationSpan","localModuleDeferredRegistrationSpan","remoteModuleRegistrationSpan","remoteModuleDeferredRegistrationSpan","dataFetchSpan","deferredRegistrationsUpdateSpan","localModuleDeferredRegistrationsUpdateSpan","remoteModuleDeferredRegistrationsUpdateSpan","options","context","attributes","registrationError","handleFetchDataStarted","name","span","handleDataReady","handlePublicDataFetchStarted","handlePublicDataReady","handleProtectedDataFetchStarted","handleProtectedDataReady","queriesErrors","x","getRegisterFetchRequestHookFunction","global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AM+C,6BAA6BhD,mDAAmDA,CAACS,QAAQ,MAAM;QAErG,+EAA+E;QAC/E,gEAAgE;QAChEsC,iCAAiCC;IACrC,OAAO;QACHvC,QAAQ,MAAM,CAAC,OAAO,CAAC;IAC3B;IAEAW,0BAA0BX;AAC9B"}
@@ -48,7 +48,7 @@ function bootstrap(runtime, options = {}) {
48
48
  startMsw(runtime).then(()=>{
49
49
  setMswAsReady();
50
50
  }).catch((error)=>{
51
- runtime.logger.debug("[squide] An error occured while starting MSW.", error);
51
+ runtime.logger.withText("[squide] An error occured while starting MSW.").withError(error).error();
52
52
  });
53
53
  }
54
54
  if (onError) {
@@ -1 +1 @@
1
- {"version":3,"file":"initializeFirefly.js","sources":["webpack://@squide/firefly/./src/initializeFirefly.ts"],"sourcesContent":["import { isFunction, registerLocalModules, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { registerRemoteModules, type RemoteDefinition } from \"@squide/module-federation\";\nimport { setMswAsReady } from \"@squide/msw\";\nimport { FireflyRuntime, type FireflyRuntimeOptions } from \"./FireflyRuntime.tsx\";\nimport { initializeHoneycomb } from \"./honeycomb/initializeHoneycomb.ts\";\n\nexport const ApplicationBootstrappingStartedEvent = \"squide-app-bootstrapping-started\";\n\nexport type OnInitializationErrorFunction = (error: unknown) => void;\n\nexport type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {\n localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];\n remotes?: RemoteDefinition[];\n startMsw?: StartMswFunction<FireflyRuntime>;\n onError?: OnInitializationErrorFunction;\n}\n\nfunction propagateRegistrationErrors(results: PromiseSettledResult<unknown[]>, onError: OnInitializationErrorFunction) {\n if (results) {\n if (results.status === \"fulfilled\") {\n results.value.forEach(x => {\n onError(x);\n });\n }\n }\n}\n\nexport function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options: InitializeFireflyOptions<TRuntime, TContext, TData> = {}) {\n const {\n localModules = [],\n remotes = [],\n startMsw,\n onError,\n context\n } = options;\n\n runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);\n\n Promise.allSettled([\n registerLocalModules<TRuntime, TContext, TData>(localModules, runtime, { context }),\n registerRemoteModules(remotes, runtime, { context })\n ]).then(results => {\n if (runtime.isMswEnabled) {\n if (!isFunction(startMsw)) {\n throw new Error(\"[squide] When MSW is enabled, the \\\"startMsw\\\" function must be provided.\");\n }\n\n startMsw(runtime)\n .then(() => {\n setMswAsReady();\n })\n .catch((error: unknown) => {\n runtime.logger.debug(\"[squide] An error occured while starting MSW.\", error);\n });\n }\n\n if (onError) {\n propagateRegistrationErrors(results[0], onError);\n propagateRegistrationErrors(results[1], onError);\n }\n });\n}\n\nlet hasExecuted = false;\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n mode,\n useMsw,\n loggers,\n plugins,\n onError\n } = options;\n\n if (hasExecuted) {\n throw new Error(\"[squide] A squide application can only be initialized once. Did you call the \\\"initializeSquide\\\" function twice?\");\n }\n\n hasExecuted = true;\n\n const runtime = new FireflyRuntime({\n mode,\n useMsw,\n loggers,\n plugins\n });\n\n initializeHoneycomb(runtime)\n .catch((error: unknown) => {\n if (onError) {\n onError(error);\n }\n })\n .finally(() => {\n bootstrap(runtime, options);\n });\n\n return runtime;\n}\n\nexport function __resetHasExecuteGuard() {\n hasExecuted = false;\n}\n"],"names":["isFunction","registerLocalModules","registerRemoteModules","setMswAsReady","FireflyRuntime","initializeHoneycomb","ApplicationBootstrappingStartedEvent","propagateRegistrationErrors","results","onError","x","bootstrap","runtime","options","localModules","remotes","startMsw","context","Promise","Error","error","hasExecuted","initializeFirefly","mode","useMsw","loggers","plugins","__resetHasExecuteGuard"],"mappings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A,CAAC;QAC/BmB;QACAC;QACAC;QACAC;IACJ;IAEArB,mBAAmBA,CAACO,SACf,KAAK,CAAC,CAACQ;QACJ,IAAIX,SAAS;YACTA,QAAQW;QACZ;IACJ,GACC,OAAO,CAAC;QACLT,UAAUC,SAASC;IACvB;IAEJ,OAAOD;AACX;AAEO,SAASe;IACZN,cAAc;AAClB"}
1
+ {"version":3,"file":"initializeFirefly.js","sources":["webpack://@squide/firefly/./src/initializeFirefly.ts"],"sourcesContent":["import { isFunction, registerLocalModules, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { registerRemoteModules, type RemoteDefinition } from \"@squide/module-federation\";\nimport { setMswAsReady } from \"@squide/msw\";\nimport { FireflyRuntime, type FireflyRuntimeOptions } from \"./FireflyRuntime.tsx\";\nimport { initializeHoneycomb } from \"./honeycomb/initializeHoneycomb.ts\";\n\nexport const ApplicationBootstrappingStartedEvent = \"squide-app-bootstrapping-started\";\n\nexport type OnInitializationErrorFunction = (error: unknown) => void;\n\nexport type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {\n localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];\n remotes?: RemoteDefinition[];\n startMsw?: StartMswFunction<FireflyRuntime>;\n onError?: OnInitializationErrorFunction;\n}\n\nfunction propagateRegistrationErrors(results: PromiseSettledResult<unknown[]>, onError: OnInitializationErrorFunction) {\n if (results) {\n if (results.status === \"fulfilled\") {\n results.value.forEach(x => {\n onError(x);\n });\n }\n }\n}\n\nexport function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options: InitializeFireflyOptions<TRuntime, TContext, TData> = {}) {\n const {\n localModules = [],\n remotes = [],\n startMsw,\n onError,\n context\n } = options;\n\n runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);\n\n Promise.allSettled([\n registerLocalModules<TRuntime, TContext, TData>(localModules, runtime, { context }),\n registerRemoteModules(remotes, runtime, { context })\n ]).then(results => {\n if (runtime.isMswEnabled) {\n if (!isFunction(startMsw)) {\n throw new Error(\"[squide] When MSW is enabled, the \\\"startMsw\\\" function must be provided.\");\n }\n\n startMsw(runtime)\n .then(() => {\n setMswAsReady();\n })\n .catch((error: unknown) => {\n runtime.logger\n .withText(\"[squide] An error occured while starting MSW.\")\n .withError(error as Error)\n .error();\n });\n }\n\n if (onError) {\n propagateRegistrationErrors(results[0], onError);\n propagateRegistrationErrors(results[1], onError);\n }\n });\n}\n\nlet hasExecuted = false;\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n mode,\n useMsw,\n loggers,\n plugins,\n onError\n } = options;\n\n if (hasExecuted) {\n throw new Error(\"[squide] A squide application can only be initialized once. Did you call the \\\"initializeSquide\\\" function twice?\");\n }\n\n hasExecuted = true;\n\n const runtime = new FireflyRuntime({\n mode,\n useMsw,\n loggers,\n plugins\n });\n\n initializeHoneycomb(runtime)\n .catch((error: unknown) => {\n if (onError) {\n onError(error);\n }\n })\n .finally(() => {\n bootstrap(runtime, options);\n });\n\n return runtime;\n}\n\nexport function __resetHasExecuteGuard() {\n hasExecuted = false;\n}\n"],"names":["isFunction","registerLocalModules","registerRemoteModules","setMswAsReady","FireflyRuntime","initializeHoneycomb","ApplicationBootstrappingStartedEvent","propagateRegistrationErrors","results","onError","x","bootstrap","runtime","options","localModules","remotes","startMsw","context","Promise","Error","error","hasExecuted","initializeFirefly","mode","useMsw","loggers","plugins","__resetHasExecuteGuard"],"mappings":";;;;;;;;;;;;;;;;;AAA0H;AACjC;AAC7C;AACsC;AACT;AAElE,MAAMM,uCAAuC,mCAAmC;AAavF,SAASC,4BAA4BC,OAAwC,EAAEC,OAAsC;IACjH,IAAID,SAAS;QACT,IAAIA,QAAQ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AAC;QACLT,UAAUC,SAASC;IACvB;IAEJ,OAAOD;AACX;AAEO,SAASe;IACZN,cAAc;AAClB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "13.1.0",
4
+ "version": "13.2.0",
5
5
  "description": "Helpers to facilitate the creation of an application with the Squide firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -36,11 +36,12 @@
36
36
  "react-router": "^7.7.0"
37
37
  },
38
38
  "dependencies": {
39
+ "@workleap/logging": "^1.2.5",
39
40
  "uuid": "^11.1.0",
40
- "@squide/core": "5.5.0",
41
- "@squide/module-federation": "6.3.0",
42
- "@squide/msw": "3.3.0",
43
- "@squide/react-router": "7.1.0"
41
+ "@squide/core": "5.6.0",
42
+ "@squide/module-federation": "6.4.0",
43
+ "@squide/msw": "3.4.0",
44
+ "@squide/react-router": "7.2.0"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@rsbuild/core": "1.4.7",
package/src/AppRouter.tsx CHANGED
@@ -66,7 +66,10 @@ export function AppRouter(props: AppRouterProps) {
66
66
  useStrictRegistrationMode();
67
67
 
68
68
  useEffect(() => {
69
- logger.debug("[squide] AppRouter state updated:", state);
69
+ logger
70
+ .withText("[squide] AppRouter state updated:")
71
+ .withObject(state)
72
+ .debug();
70
73
  }, [state, logger]);
71
74
 
72
75
  const routerProvider = useRenderRouterProvider(state, renderRouterProvider);
@@ -183,7 +183,18 @@ export function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue:
183
183
  if (getAreModulesRegistered()) {
184
184
  dispatch({ type: "modules-registered" });
185
185
 
186
- logger.debug("[squide] %cModules are registered%c.", "color: white; background-color: green;", "");
186
+ logger
187
+ .withText("[squide]")
188
+ .withText("Modules are registered", {
189
+ style: {
190
+ color: "white",
191
+ backgroundColor: "green"
192
+ }
193
+ })
194
+ .withText(".", {
195
+ leadingSpace: false
196
+ })
197
+ .information();
187
198
 
188
199
  return true;
189
200
  }
@@ -195,7 +206,18 @@ export function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue:
195
206
  if (getAreModulesReady()) {
196
207
  dispatch({ type: "modules-ready" });
197
208
 
198
- logger.debug("[squide] %cModules are ready%c.", "color: white; background-color: green;", "");
209
+ logger
210
+ .withText("[squide]")
211
+ .withText("Modules are ready", {
212
+ style: {
213
+ color: "white",
214
+ backgroundColor: "green"
215
+ }
216
+ })
217
+ .withText(".", {
218
+ leadingSpace: false
219
+ })
220
+ .information();
199
221
 
200
222
  return true;
201
223
  }
@@ -231,7 +253,18 @@ export function useMswStatusDispatcher(isMswReadyValue: boolean, dispatch: AppRo
231
253
  if (isMswReady()) {
232
254
  dispatch({ type: "msw-ready" });
233
255
 
234
- logger.debug("[squide] %cMSW is ready%c.", "color: white; background-color: green;", "");
256
+ logger
257
+ .withText("[squide]")
258
+ .withText("MSW is ready", {
259
+ style: {
260
+ color: "white",
261
+ backgroundColor: "green"
262
+ }
263
+ })
264
+ .withText(".", {
265
+ leadingSpace: false
266
+ })
267
+ .information();
235
268
 
236
269
  return true;
237
270
  }
@@ -291,7 +324,10 @@ function useEnhancedReducerDispatch(reducerDispatch: AppRouterDispatch) {
291
324
  const eventBus = useEventBus();
292
325
 
293
326
  return useCallback((action: AppRouterAction) => {
294
- logger.debug("[squide] The following action has been dispatched to the AppRouter reducer:", action);
327
+ logger
328
+ .withText("[squide] The following action has been dispatched to the AppRouter reducer:")
329
+ .withObject(action)
330
+ .debug();
295
331
 
296
332
  appRouterStore.dispatch(action);
297
333
  eventBus.dispatch(`squide-${action.type}`);
@@ -2,7 +2,7 @@
2
2
  // access to the state and ease the integration with third-party libraries such as the Platform Widgets.
3
3
  // Eventually, AppRouterReducer should be deprecated in favor of this new AppRouterStore.
4
4
 
5
- import type { RuntimeLogger } from "@squide/core";
5
+ import type { RootLogger } from "@workleap/logging";
6
6
  import type { AppRouterAction, AppRouterState } from "./AppRouterReducer.ts";
7
7
 
8
8
  export type AppRouterStoreState = Omit<AppRouterState, "waitForMsw" | "waitForPublicData" | "waitForProtectedData">;
@@ -13,9 +13,9 @@ export class AppRouterStore {
13
13
  #state: AppRouterStoreState;
14
14
 
15
15
  readonly #listeners = new Set<AppRouterStoreListenerFunction>();
16
- readonly #logger?: RuntimeLogger;
16
+ readonly #logger: RootLogger;
17
17
 
18
- constructor(initialialState: AppRouterStoreState, logger: RuntimeLogger) {
18
+ constructor(initialialState: AppRouterStoreState, logger: RootLogger) {
19
19
  this.#state = initialialState;
20
20
  this.#logger = logger;
21
21
  }
@@ -35,7 +35,11 @@ export class AppRouterStore {
35
35
  dispatch(action: AppRouterAction) {
36
36
  const newState = this.#reducer({ ...this.#state }, action);
37
37
 
38
- this.#logger?.debug("[squide] The AppRouterStore state has been updated to:", newState);
38
+ this.#logger
39
+ .withText("[squide] The AppRouterStore state has been updated to:")
40
+ .withObject(newState)
41
+ .debug();
42
+
39
43
  this.#state = newState;
40
44
 
41
45
  // Creating a copy of the listeners in case some are removed during the looping.
@@ -156,7 +160,7 @@ export class AppRouterStore {
156
160
  }
157
161
  }
158
162
 
159
- export function createAppRouterStore(logger: RuntimeLogger) {
163
+ export function createAppRouterStore(logger: RootLogger) {
160
164
  const initialState: AppRouterStoreState = {
161
165
  areModulesRegistered: false,
162
166
  areModulesReady: false,
@@ -1,5 +1,6 @@
1
1
  import type { Span } from "@opentelemetry/api";
2
- import { isPlainObject, type RuntimeLogger } from "@squide/core";
2
+ import { isPlainObject } from "@squide/core";
3
+ import type { RootLogger } from "@workleap/logging";
3
4
  import { v4 as uuidv4 } from "uuid";
4
5
  import { createTraceContextId } from "./createTraceContextId.ts";
5
6
 
@@ -96,7 +97,7 @@ export function popActiveSpan(span: ActiveSpan) {
96
97
  }
97
98
  }
98
99
 
99
- export function createOverrideFetchRequestSpanWithActiveSpanContext(logger: RuntimeLogger) {
100
+ export function createOverrideFetchRequestSpanWithActiveSpanContext(logger: RootLogger) {
100
101
  return (span: Span, request: Request | RequestInit) => {
101
102
  const activeSpan = getActiveSpan();
102
103
 
@@ -105,12 +106,18 @@ export function createOverrideFetchRequestSpanWithActiveSpanContext(logger: Runt
105
106
  const requestSpanContext = span.spanContext();
106
107
 
107
108
  if (activeSpanContext) {
108
- logger.debug(
109
- "[squide] Found a Honeycomb active context to apply to the following fetch request: \r\n",
110
- "Request span context: ", requestSpanContext, "\r\n",
111
- "Active span context: ", activeSpanContext, "\r\n",
112
- "Request: ", request, "\r\n"
113
- );
109
+ logger
110
+ .withText("[squide] Found a Honeycomb active context to apply to the following fetch request:")
111
+ .withLineChange()
112
+ .withText("Request span context:")
113
+ .withObject(requestSpanContext)
114
+ .withLineChange()
115
+ .withText("Active span context:")
116
+ .withObject(activeSpanContext)
117
+ .withLineChange()
118
+ .withText("Request:")
119
+ .withObject(request)
120
+ .debug();
114
121
 
115
122
  span.setAttribute("trace.trace_id", activeSpanContext.traceId);
116
123
  span.setAttribute("trace.parent_id", activeSpanContext.spanId);
@@ -1,5 +1,6 @@
1
1
  export function canRegisterHoneycombInstrumentation() {
2
+ // The second one is due to an error. Will be able to remove soon.
2
3
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
4
  // @ts-ignore
4
- return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true;
5
+ return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true || globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED === true;
5
6
  }
@@ -15,7 +15,7 @@ export async function initializeHoneycomb(runtime: FireflyRuntime) {
15
15
  throw error;
16
16
  }
17
17
  } else {
18
- runtime.logger.debug("[squide] Cannot register Honeycomb instrumentation because the host application is not using the \"@workleap/honeycomb\" package.");
18
+ runtime.logger.information("[squide] Cannot register Honeycomb instrumentation because the host application is not using the \"@workleap/honeycomb\" package.");
19
19
  }
20
20
  }
21
21
 
@@ -465,6 +465,15 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
465
465
  }
466
466
 
467
467
  function getRegisterFetchRequestHookFunction() {
468
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
469
+ // @ts-ignore
470
+ if (globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__) {
471
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
472
+ // @ts-ignore
473
+ return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__;
474
+ }
475
+
476
+ // Fallback to fix an error. Will remove soon.
468
477
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
469
478
  // @ts-ignore
470
479
  return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK;
@@ -482,7 +491,7 @@ export function registerHoneycombInstrumentation(runtime: FireflyRuntime) {
482
491
  // of squide bootstrapping under the appropriate Honeycomb span.
483
492
  registerFetchRequestHookFunction(activeSpanOverrideFunction);
484
493
  } else {
485
- runtime.logger.warning("[squide] Cannot register Honeycomb fetch request hook because \"globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK\" is not available. Honeycomb instrumentation is still functional but in degraded mode.");
494
+ runtime.logger.warning("[squide] Cannot register Honeycomb fetch request hook because \"globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__\" is not available. Honeycomb instrumentation is still functional but in degraded mode.");
486
495
  }
487
496
 
488
497
  registerTrackingListeners(runtime);
@@ -52,7 +52,10 @@ export function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TCon
52
52
  setMswAsReady();
53
53
  })
54
54
  .catch((error: unknown) => {
55
- runtime.logger.debug("[squide] An error occured while starting MSW.", error);
55
+ runtime.logger
56
+ .withText("[squide] An error occured while starting MSW.")
57
+ .withError(error as Error)
58
+ .error();
56
59
  });
57
60
  }
58
61