@squide/firefly 16.0.1 → 16.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @squide/firefly
2
2
 
3
+ ## 16.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#347](https://github.com/workleap/wl-squide/pull/347) [`6354489`](https://github.com/workleap/wl-squide/commit/6354489117e9826291da71f977daae55a5c5484a) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped package versions.
8
+
9
+ - Updated dependencies [[`6354489`](https://github.com/workleap/wl-squide/commit/6354489117e9826291da71f977daae55a5c5484a)]:
10
+ - @squide/react-router@8.1.6
11
+ - @squide/env-vars@1.4.9
12
+ - @squide/core@6.1.6
13
+ - @squide/msw@4.0.7
14
+
15
+ ## 16.0.2
16
+
17
+ ### Patch Changes
18
+
19
+ - [#345](https://github.com/workleap/wl-squide/pull/345) [`d05a890`](https://github.com/workleap/wl-squide/commit/d05a890517a1a9d9a0b4946690b36c14ea07aa49) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Added a `strictMode` prop to the `AppRouter` component.
20
+
3
21
  ## 16.0.1
4
22
 
5
23
  ### Patch Changes
@@ -15,6 +15,7 @@ export declare function useCanRenderRouter({ areModulesRegistered, areModulesRea
15
15
  export interface AppRouterProps {
16
16
  waitForPublicData?: boolean;
17
17
  waitForProtectedData?: boolean;
18
+ strictMode?: boolean;
18
19
  children: RenderRouterProviderFunction;
19
20
  }
20
21
  export declare function AppRouter(props: AppRouterProps): import("react/jsx-runtime").JSX.Element;
package/dist/AppRouter.js CHANGED
@@ -37,7 +37,7 @@ function useCanRenderRouter({ areModulesRegistered, areModulesReady: areModulesR
37
37
  // depends on the protected data.
38
38
  areModulesRegistered || areModulesReadyValue);
39
39
  }
40
- function useRenderRouterProvider(state, renderRouterProvider) {
40
+ function useRenderRouterProvider(state, renderRouterProvider, strictMode) {
41
41
  const routes = useRoutes();
42
42
  // The value is computed outside of the router provider memo to prevent
43
43
  // rendering a new router provider everytime the app router state change.
@@ -45,7 +45,9 @@ function useRenderRouterProvider(state, renderRouterProvider) {
45
45
  return useMemo(()=>{
46
46
  if (canRenderRouter) {
47
47
  return renderRouterProvider({
48
- rootRoute: /*#__PURE__*/ jsx(RootRoute, {}),
48
+ rootRoute: /*#__PURE__*/ jsx(RootRoute, {
49
+ strictMode: strictMode
50
+ }),
49
51
  registeredRoutes: routes,
50
52
  routerProviderProps: {}
51
53
  });
@@ -54,21 +56,24 @@ function useRenderRouterProvider(state, renderRouterProvider) {
54
56
  }, [
55
57
  canRenderRouter,
56
58
  routes,
57
- renderRouterProvider
59
+ renderRouterProvider,
60
+ strictMode
58
61
  ]);
59
62
  }
60
63
  function AppRouter(props) {
61
- const { waitForPublicData = false, waitForProtectedData = false, children: renderRouterProvider } = props;
64
+ const { waitForPublicData = false, waitForProtectedData = false, strictMode = true, children: renderRouterProvider } = props;
62
65
  const [state, dispatch] = useAppRouterReducer(waitForPublicData, waitForProtectedData);
63
66
  const logger = useLogger();
64
- useStrictRegistrationMode();
67
+ useStrictRegistrationMode({
68
+ isEnabled: strictMode
69
+ });
65
70
  useEffect(()=>{
66
71
  logger.withText("[squide] AppRouter state updated:").withObject(state).debug();
67
72
  }, [
68
73
  state,
69
74
  logger
70
75
  ]);
71
- const routerProvider = useRenderRouterProvider(state, renderRouterProvider);
76
+ const routerProvider = useRenderRouterProvider(state, renderRouterProvider, strictMode);
72
77
  return /*#__PURE__*/ jsx(AppRouterDispatcherContext.Provider, {
73
78
  value: dispatch,
74
79
  children: /*#__PURE__*/ jsx(AppRouterStateContext.Provider, {
@@ -1 +1 @@
1
- {"version":3,"file":"AppRouter.js","sources":["../src/AppRouter.tsx"],"sourcesContent":["import { useLogger } from \"@squide/core\";\nimport { useRoutes, type Route } from \"@squide/react-router\";\nimport { useEffect, useMemo, type ReactElement } from \"react\";\nimport type { RouterProviderProps } from \"react-router/dom\";\nimport { AppRouterDispatcherContext, AppRouterStateContext } from \"./AppRouterContext.ts\";\nimport { useAppRouterReducer, type AppRouterState } from \"./AppRouterReducer.ts\";\nimport { RootRoute } from \"./RootRoute.tsx\";\nimport { useStrictRegistrationMode } from \"./useStrictRegistrationMode.ts\";\n\nexport interface AppRouterRenderFunctionArgs {\n routes: Route[];\n}\n\nexport interface RenderRouterProviderFunctionArgs {\n rootRoute: ReactElement;\n registeredRoutes: Route[];\n routerProviderProps: Omit<RouterProviderProps, \"router\">;\n}\n\nexport type RenderRouterProviderFunction = (args: RenderRouterProviderFunctionArgs) => ReactElement;\n\nexport function useCanRenderRouter({ areModulesRegistered, areModulesReady: areModulesReadyValue }: AppRouterState) {\n return (\n // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered has they will probably\n // depends on the protected data.\n (areModulesRegistered || areModulesReadyValue)\n );\n}\n\nfunction useRenderRouterProvider(state: AppRouterState, renderRouterProvider: RenderRouterProviderFunction) {\n const routes = useRoutes();\n\n // The value is computed outside of the router provider memo to prevent\n // rendering a new router provider everytime the app router state change.\n const canRenderRouter = useCanRenderRouter(state);\n\n return useMemo(() => {\n if (canRenderRouter) {\n return renderRouterProvider({\n rootRoute: <RootRoute />,\n registeredRoutes: routes,\n routerProviderProps: {}\n });\n }\n\n return null;\n }, [canRenderRouter, routes, renderRouterProvider]);\n}\n\nexport interface AppRouterProps {\n waitForPublicData?: boolean;\n waitForProtectedData?: boolean;\n children: RenderRouterProviderFunction;\n}\n\nexport function AppRouter(props: AppRouterProps) {\n const {\n waitForPublicData = false,\n waitForProtectedData = false,\n children: renderRouterProvider\n } = props;\n const [state, dispatch] = useAppRouterReducer(waitForPublicData, waitForProtectedData);\n\n const logger = useLogger();\n\n useStrictRegistrationMode();\n\n useEffect(() => {\n logger\n .withText(\"[squide] AppRouter state updated:\")\n .withObject(state)\n .debug();\n }, [state, logger]);\n\n const routerProvider = useRenderRouterProvider(state, renderRouterProvider);\n\n return (\n <AppRouterDispatcherContext.Provider value={dispatch}>\n <AppRouterStateContext.Provider value={state}>\n {routerProvider}\n </AppRouterStateContext.Provider>\n </AppRouterDispatcherContext.Provider>\n );\n}\n"],"names":["useLogger","useRoutes","useEffect","useMemo","AppRouterDispatcherContext","AppRouterStateContext","useAppRouterReducer","RootRoute","useStrictRegistrationMode","useCanRenderRouter","areModulesRegistered","areModulesReadyValue","useRenderRouterProvider","state","renderRouterProvider","routes","canRenderRouter","AppRouter","props","waitForPublicData","waitForProtectedData","dispatch","logger","routerProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAyC;AACoB;AACC;AAE4B;AACT;AACrC;AAC+B;AAcpE,SAASS,mBAAmB,EAAEC,oBAAoB,EAAE,iBAAiBC,oBAAoB,EAAkB;IAC9G,OACI,qIAAqI;IACrI,iCAAiC;IAChCD,wBAAwBC;AAEjC;AAEA,SAASC,wBAAwBC,KAAqB,EAAEC,oBAAkD;IACtG,MAAMC,SAASd,SAASA;IAExB,uEAAuE;IACvE,yEAAyE;IACzE,MAAMe,kBAAkBP,mBAAmBI;IAE3C,OAAOV,OAAOA,CAAC;QACX,IAAIa,iBAAiB;YACjB,OAAOF,qBAAqB;gBACxB,yBAAW,IAACP,SAASA;gBACrB,kBAAkBQ;gBAClB,qBAAqB,CAAC;YAC1B;QACJ;QAEA,OAAO;IACX,GAAG;QAACC;QAAiBD;QAAQD;KAAqB;AACtD;AAQO,SAASG,UAAUC,KAAqB;IAC3C,MAAM,EACFC,oBAAoB,KAAK,EACzBC,uBAAuB,KAAK,EAC5B,UAAUN,oBAAoB,EACjC,GAAGI;IACJ,MAAM,CAACL,OAAOQ,SAAS,GAAGf,mBAAmBA,CAACa,mBAAmBC;IAEjE,MAAME,SAAStB,SAASA;IAExBQ,yBAAyBA;IAEzBN,SAASA,CAAC;QACNoB,OACK,QAAQ,CAAC,qCACT,UAAU,CAACT,OACX,KAAK;IACd,GAAG;QAACA;QAAOS;KAAO;IAElB,MAAMC,iBAAiBX,wBAAwBC,OAAOC;IAEtD,qBACI,IAACV,mCAAmC;QAAC,OAAOiB;kBACxC,kBAAChB,8BAA8B;YAAC,OAAOQ;sBAClCU;;;AAIjB"}
1
+ {"version":3,"file":"AppRouter.js","sources":["../src/AppRouter.tsx"],"sourcesContent":["import { useLogger } from \"@squide/core\";\nimport { useRoutes, type Route } from \"@squide/react-router\";\nimport { useEffect, useMemo, type ReactElement } from \"react\";\nimport type { RouterProviderProps } from \"react-router/dom\";\nimport { AppRouterDispatcherContext, AppRouterStateContext } from \"./AppRouterContext.ts\";\nimport { useAppRouterReducer, type AppRouterState } from \"./AppRouterReducer.ts\";\nimport { RootRoute } from \"./RootRoute.tsx\";\nimport { useStrictRegistrationMode } from \"./useStrictRegistrationMode.ts\";\n\nexport interface AppRouterRenderFunctionArgs {\n routes: Route[];\n}\n\nexport interface RenderRouterProviderFunctionArgs {\n rootRoute: ReactElement;\n registeredRoutes: Route[];\n routerProviderProps: Omit<RouterProviderProps, \"router\">;\n}\n\nexport type RenderRouterProviderFunction = (args: RenderRouterProviderFunctionArgs) => ReactElement;\n\nexport function useCanRenderRouter({ areModulesRegistered, areModulesReady: areModulesReadyValue }: AppRouterState) {\n return (\n // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered has they will probably\n // depends on the protected data.\n (areModulesRegistered || areModulesReadyValue)\n );\n}\n\nfunction useRenderRouterProvider(state: AppRouterState, renderRouterProvider: RenderRouterProviderFunction, strictMode: boolean) {\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 strictMode={strictMode} />,\n registeredRoutes: routes,\n routerProviderProps: {}\n });\n }\n\n return null;\n }, [canRenderRouter, routes, renderRouterProvider, strictMode]);\n}\n\nexport interface AppRouterProps {\n waitForPublicData?: boolean;\n waitForProtectedData?: boolean;\n strictMode?: boolean;\n children: RenderRouterProviderFunction;\n}\n\nexport function AppRouter(props: AppRouterProps) {\n const {\n waitForPublicData = false,\n waitForProtectedData = false,\n strictMode = true,\n children: renderRouterProvider\n } = props;\n const [state, dispatch] = useAppRouterReducer(waitForPublicData, waitForProtectedData);\n\n const logger = useLogger();\n\n useStrictRegistrationMode({\n isEnabled: strictMode\n });\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, strictMode);\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","strictMode","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,EAAEC,UAAmB;IAC3H,MAAMC,SAASf,SAASA;IAExB,uEAAuE;IACvE,yEAAyE;IACzE,MAAMgB,kBAAkBR,mBAAmBI;IAE3C,OAAOV,OAAOA,CAAC;QACX,IAAIc,iBAAiB;YACjB,OAAOH,qBAAqB;gBACxB,yBAAW,IAACP,SAASA;oBAAC,YAAYQ;;gBAClC,kBAAkBC;gBAClB,qBAAqB,CAAC;YAC1B;QACJ;QAEA,OAAO;IACX,GAAG;QAACC;QAAiBD;QAAQF;QAAsBC;KAAW;AAClE;AASO,SAASG,UAAUC,KAAqB;IAC3C,MAAM,EACFC,oBAAoB,KAAK,EACzBC,uBAAuB,KAAK,EAC5BN,aAAa,IAAI,EACjB,UAAUD,oBAAoB,EACjC,GAAGK;IACJ,MAAM,CAACN,OAAOS,SAAS,GAAGhB,mBAAmBA,CAACc,mBAAmBC;IAEjE,MAAME,SAASvB,SAASA;IAExBQ,yBAAyBA,CAAC;QACtB,WAAWO;IACf;IAEAb,SAASA,CAAC;QACNqB,OACK,QAAQ,CAAC,qCACT,UAAU,CAACV,OACX,KAAK;IACd,GAAG;QAACA;QAAOU;KAAO;IAElB,MAAMC,iBAAiBZ,wBAAwBC,OAAOC,sBAAsBC;IAE5E,qBACI,IAACX,mCAAmC;QAAC,OAAOkB;kBACxC,kBAACjB,8BAA8B;YAAC,OAAOQ;sBAClCW;;;AAIjB"}
@@ -1,6 +1,6 @@
1
- import { type Runtime } from "@squide/core";
2
1
  import type { PropsWithChildren } from "react";
2
+ import { FireflyRuntime } from "./FireflyRuntime.tsx";
3
3
  export interface FireflyProviderProps extends PropsWithChildren {
4
- runtime: Runtime;
4
+ runtime: FireflyRuntime;
5
5
  }
6
6
  export declare function FireflyProvider(props: FireflyProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"FireflyProvider.js","sources":["../src/FireflyProvider.tsx"],"sourcesContent":["import { type Runtime, RuntimeContext } from \"@squide/core\";\nimport type { PropsWithChildren } from \"react\";\n\nexport interface FireflyProviderProps extends PropsWithChildren {\n runtime: Runtime;\n}\n\nexport function FireflyProvider(props: FireflyProviderProps) {\n const {\n runtime,\n children\n } = props;\n\n return (\n <RuntimeContext.Provider value={runtime}>\n {children}\n </RuntimeContext.Provider>\n );\n}\n"],"names":["RuntimeContext","FireflyProvider","props","runtime","children"],"mappings":";;;;;;;;;AAA4D;AAOrD,SAASC,gBAAgBC,KAA2B;IACvD,MAAM,EACFC,OAAO,EACPC,QAAQ,EACX,GAAGF;IAEJ,qBACI,IAACF,uBAAuB;QAAC,OAAOG;kBAC3BC;;AAGb"}
1
+ {"version":3,"file":"FireflyProvider.js","sources":["../src/FireflyProvider.tsx"],"sourcesContent":["import { RuntimeContext } from \"@squide/core\";\nimport type { PropsWithChildren } from \"react\";\nimport { FireflyRuntime } from \"./FireflyRuntime.tsx\";\n\nexport interface FireflyProviderProps extends PropsWithChildren {\n runtime: FireflyRuntime;\n}\n\nexport function FireflyProvider(props: FireflyProviderProps) {\n const {\n runtime,\n children\n } = props;\n\n return (\n <RuntimeContext.Provider value={runtime}>\n {children}\n </RuntimeContext.Provider>\n );\n}\n"],"names":["RuntimeContext","FireflyProvider","props","runtime","children"],"mappings":";;;;;;;;;AAA8C;AAQvC,SAASC,gBAAgBC,KAA2B;IACvD,MAAM,EACFC,OAAO,EACPC,QAAQ,EACX,GAAGF;IAEJ,qBACI,IAACF,uBAAuB;QAAC,OAAOG;kBAC3BC;;AAGb"}
@@ -1 +1,4 @@
1
- export declare function RootRoute(): import("react/jsx-runtime").JSX.Element;
1
+ export interface RootRouteProps {
2
+ strictMode?: boolean;
3
+ }
4
+ export declare function RootRoute(props: RootRouteProps): import("react/jsx-runtime").JSX.Element;
package/dist/RootRoute.js CHANGED
@@ -20,9 +20,12 @@ import { useIsActiveRouteProtected } from "./useIsActiveRouteProtected.js";
20
20
 
21
21
 
22
22
 
23
- function RootRoute() {
23
+ function RootRoute(props) {
24
+ const { strictMode = true } = props;
24
25
  const state = useAppRouterState();
25
- const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady);
26
+ const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady, {
27
+ throwWhenThereIsNoMatch: strictMode
28
+ });
26
29
  const dispatch = useAppRouterDispatcher();
27
30
  useEffect(()=>{
28
31
  // Dispatching the active route visibility must be done in a route because React Router's useLocation
@@ -1 +1 @@
1
- {"version":3,"file":"RootRoute.js","sources":["../src/RootRoute.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { Outlet } from \"react-router\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { useIsActiveRouteProtected } from \"./useIsActiveRouteProtected.ts\";\n\nexport function RootRoute() {\n const state = useAppRouterState();\n const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady);\n\n const dispatch = useAppRouterDispatcher();\n\n useEffect(() => {\n // Dispatching the active route visibility must be done in a route because React Router's useLocation\n // hook throws if it's not called from a child of the router component.\n if (isActiveRouteProtected) {\n dispatch({ type: \"active-route-is-protected\" });\n } else {\n dispatch({ type: \"active-route-is-public\" });\n }\n }, [isActiveRouteProtected, dispatch]);\n\n return (\n <Outlet />\n );\n}\n"],"names":["useEffect","Outlet","useAppRouterDispatcher","useAppRouterState","useIsActiveRouteProtected","RootRoute","state","isActiveRouteProtected","dispatch"],"mappings":";;;;;;;;;;;;;;;;;;AAAkC;AACI;AAC4C;AACP;AAEpE,SAASK;IACZ,MAAMC,QAAQH,iBAAiBA;IAC/B,MAAMI,yBAAyBH,yBAAyBA,CAACE,MAAM,eAAe;IAE9E,MAAME,WAAWN,sBAAsBA;IAEvCF,SAASA,CAAC;QACN,qGAAqG;QACrG,uEAAuE;QACvE,IAAIO,wBAAwB;YACxBC,SAAS;gBAAE,MAAM;YAA4B;QACjD,OAAO;YACHA,SAAS;gBAAE,MAAM;YAAyB;QAC9C;IACJ,GAAG;QAACD;QAAwBC;KAAS;IAErC,qBACI,IAACP,MAAMA;AAEf"}
1
+ {"version":3,"file":"RootRoute.js","sources":["../src/RootRoute.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { Outlet } from \"react-router\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { useIsActiveRouteProtected } from \"./useIsActiveRouteProtected.ts\";\n\nexport interface RootRouteProps {\n strictMode?: boolean;\n}\n\nexport function RootRoute(props: RootRouteProps) {\n const {\n strictMode = true\n } = props;\n\n const state = useAppRouterState();\n\n const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady, {\n throwWhenThereIsNoMatch: strictMode\n });\n\n const dispatch = useAppRouterDispatcher();\n\n useEffect(() => {\n // Dispatching the active route visibility must be done in a route because React Router's useLocation\n // hook throws if it's not called from a child of the router component.\n if (isActiveRouteProtected) {\n dispatch({ type: \"active-route-is-protected\" });\n } else {\n dispatch({ type: \"active-route-is-public\" });\n }\n }, [isActiveRouteProtected, dispatch]);\n\n return (\n <Outlet />\n );\n}\n"],"names":["useEffect","Outlet","useAppRouterDispatcher","useAppRouterState","useIsActiveRouteProtected","RootRoute","props","strictMode","state","isActiveRouteProtected","dispatch"],"mappings":";;;;;;;;;;;;;;;;;;AAAkC;AACI;AAC4C;AACP;AAMpE,SAASK,UAAUC,KAAqB;IAC3C,MAAM,EACFC,aAAa,IAAI,EACpB,GAAGD;IAEJ,MAAME,QAAQL,iBAAiBA;IAE/B,MAAMM,yBAAyBL,yBAAyBA,CAACI,MAAM,eAAe,EAAE;QAC5E,yBAAyBD;IAC7B;IAEA,MAAMG,WAAWR,sBAAsBA;IAEvCF,SAASA,CAAC;QACN,qGAAqG;QACrG,uEAAuE;QACvE,IAAIS,wBAAwB;YACxBC,SAAS;gBAAE,MAAM;YAA4B;QACjD,OAAO;YACHA,SAAS;gBAAE,MAAM;YAAyB;QAC9C;IACJ,GAAG;QAACD;QAAwBC;KAAS;IAErC,qBACI,IAACT,MAAMA;AAEf"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from "@squide/core";
2
- export { EnvironmentVariablesPlugin, useEnvironmentVariable, useEnvironmentVariables, type EnvironmentVariableKey, type EnvironmentVariables, type EnvironmentVariablesPluginOptions, type EnvironmentVariableValue } from "@squide/env-vars";
3
- export { MswPlugin, MswState, type MswPluginOptions, type MswPluginRegisterRequestHandlersOptions, type MswReadyListener, type MswStateOptions } from "@squide/msw";
2
+ export { EnvironmentVariablesPlugin, EnvironmentVariablesPluginName, getEnvironmentVariablesPlugin, useEnvironmentVariable, useEnvironmentVariables, type EnvironmentVariableKey, type EnvironmentVariables, type EnvironmentVariablesPluginOptions, type EnvironmentVariableValue } from "@squide/env-vars";
3
+ export { getMswPlugin, MswPlugin, MswPluginName, MswState, type MswPluginOptions, type MswPluginRegisterRequestHandlersOptions, type MswReadyListener, type MswStateOptions } from "@squide/msw";
4
4
  export * from "@squide/react-router";
5
5
  export type { FireflyPlugin } from "./FireflyPlugin.ts";
6
6
  export * from "./FireflyProvider.tsx";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { EnvironmentVariablesPlugin, useEnvironmentVariable, useEnvironmentVariables } from "@squide/env-vars";
2
- import { MswPlugin, MswState } from "@squide/msw";
1
+ import { EnvironmentVariablesPlugin, EnvironmentVariablesPluginName, getEnvironmentVariablesPlugin, useEnvironmentVariable, useEnvironmentVariables } from "@squide/env-vars";
2
+ import { MswPlugin, MswPluginName, MswState, getMswPlugin } from "@squide/msw";
3
3
  import { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent } from "./AppRouterReducer.js";
4
4
  export * from "@squide/core";
5
5
  export * from "@squide/react-router";
@@ -59,6 +59,6 @@ export * from "./initializeFirefly.js";
59
59
 
60
60
 
61
61
 
62
- export { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, EnvironmentVariablesPlugin, ModulesReadyEvent, ModulesRegisteredEvent, MswPlugin, MswReadyEvent, MswState, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent, useEnvironmentVariable, useEnvironmentVariables };
62
+ export { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, EnvironmentVariablesPlugin, EnvironmentVariablesPluginName, ModulesReadyEvent, ModulesRegisteredEvent, MswPlugin, MswPluginName, MswReadyEvent, MswState, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent, getEnvironmentVariablesPlugin, getMswPlugin, useEnvironmentVariable, useEnvironmentVariables };
63
63
 
64
64
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"@squide/core\";\nexport {\n EnvironmentVariablesPlugin,\n useEnvironmentVariable,\n useEnvironmentVariables,\n type EnvironmentVariableKey,\n type EnvironmentVariables,\n type EnvironmentVariablesPluginOptions,\n type EnvironmentVariableValue\n} from \"@squide/env-vars\";\nexport {\n MswPlugin,\n MswState,\n type MswPluginOptions,\n type MswPluginRegisterRequestHandlersOptions,\n type MswReadyListener,\n type MswStateOptions\n} from \"@squide/msw\";\nexport * from \"@squide/react-router\";\n\nexport type { FireflyPlugin } from \"./FireflyPlugin.ts\";\nexport * from \"./FireflyProvider.tsx\";\nexport * from \"./FireflyRuntime.tsx\";\n\nexport * from \"./AppRouter.tsx\";\nexport {\n ActiveRouteIsProtectedEvent,\n ActiveRouteIsPublicEvent,\n ApplicationBoostrappedEvent,\n DeferredRegistrationsUpdatedEvent,\n ModulesReadyEvent,\n ModulesRegisteredEvent,\n MswReadyEvent,\n ProtectedDataReadyEvent,\n ProtectedDataUpdatedEvent,\n PublicDataReadyEvent,\n PublicDataUpdatedEvent\n} from \"./AppRouterReducer.ts\";\n\nexport * from \"./AppRouterStore.ts\";\nexport * from \"./GlobalDataQueriesError.ts\";\nexport * from \"./useCanFetchProtectedData.ts\";\nexport * from \"./useCanFetchPublicData.ts\";\nexport * from \"./useCanRegisterDeferredRegistrations.ts\";\nexport * from \"./useCanUpdateDeferredRegistrations.ts\";\nexport * from \"./useDeferredRegistrations.ts\";\nexport * from \"./useIsActiveRouteProtected.ts\";\nexport * from \"./useIsBootstrapping.ts\";\nexport * from \"./useNavigationItems.ts\";\nexport * from \"./useProtectedDataHandler.ts\";\nexport * from \"./useProtectedDataQueries.ts\";\nexport * from \"./usePublicDataHandler.ts\";\nexport * from \"./usePublicDataQueries.ts\";\nexport * from \"./useRegisterDeferredRegistrations.ts\";\nexport * from \"./useStrictRegistrationMode.ts\";\nexport * from \"./useUpdateDeferredRegistrations.ts\";\n\nexport * from \"./initializeFirefly.ts\";\n\n"],"names":["EnvironmentVariablesPlugin","useEnvironmentVariable","useEnvironmentVariables","MswPlugin","MswState","ActiveRouteIsProtectedEvent","ActiveRouteIsPublicEvent","ApplicationBoostrappedEvent","DeferredRegistrationsUpdatedEvent","ModulesReadyEvent","ModulesRegisteredEvent","MswReadyEvent","ProtectedDataReadyEvent","ProtectedDataUpdatedEvent","PublicDataReadyEvent","PublicDataUpdatedEvent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA6B;AASH;AAQL;AACgB;AAGC;AACD;AAEL;AAaD;AAEK;AACQ;AACE;AACH;AACc;AACF;AACT;AACC;AACP;AACA;AACK;AACA;AACH;AACA;AACY;AACP;AACK;AAEb"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"@squide/core\";\nexport {\n EnvironmentVariablesPlugin,\n EnvironmentVariablesPluginName,\n getEnvironmentVariablesPlugin,\n useEnvironmentVariable,\n useEnvironmentVariables,\n type EnvironmentVariableKey,\n type EnvironmentVariables,\n type EnvironmentVariablesPluginOptions,\n type EnvironmentVariableValue\n} from \"@squide/env-vars\";\nexport {\n getMswPlugin,\n MswPlugin,\n MswPluginName,\n MswState,\n type MswPluginOptions,\n type MswPluginRegisterRequestHandlersOptions,\n type MswReadyListener,\n type MswStateOptions\n} from \"@squide/msw\";\nexport * from \"@squide/react-router\";\n\nexport type { FireflyPlugin } from \"./FireflyPlugin.ts\";\nexport * from \"./FireflyProvider.tsx\";\nexport * from \"./FireflyRuntime.tsx\";\n\nexport * from \"./AppRouter.tsx\";\nexport {\n ActiveRouteIsProtectedEvent,\n ActiveRouteIsPublicEvent,\n ApplicationBoostrappedEvent,\n DeferredRegistrationsUpdatedEvent,\n ModulesReadyEvent,\n ModulesRegisteredEvent,\n MswReadyEvent,\n ProtectedDataReadyEvent,\n ProtectedDataUpdatedEvent,\n PublicDataReadyEvent,\n PublicDataUpdatedEvent\n} from \"./AppRouterReducer.ts\";\n\nexport * from \"./AppRouterStore.ts\";\nexport * from \"./GlobalDataQueriesError.ts\";\nexport * from \"./useCanFetchProtectedData.ts\";\nexport * from \"./useCanFetchPublicData.ts\";\nexport * from \"./useCanRegisterDeferredRegistrations.ts\";\nexport * from \"./useCanUpdateDeferredRegistrations.ts\";\nexport * from \"./useDeferredRegistrations.ts\";\nexport * from \"./useIsActiveRouteProtected.ts\";\nexport * from \"./useIsBootstrapping.ts\";\nexport * from \"./useNavigationItems.ts\";\nexport * from \"./useProtectedDataHandler.ts\";\nexport * from \"./useProtectedDataQueries.ts\";\nexport * from \"./usePublicDataHandler.ts\";\nexport * from \"./usePublicDataQueries.ts\";\nexport * from \"./useRegisterDeferredRegistrations.ts\";\nexport * from \"./useStrictRegistrationMode.ts\";\nexport * from \"./useUpdateDeferredRegistrations.ts\";\n\nexport * from \"./initializeFirefly.ts\";\n\n"],"names":["EnvironmentVariablesPlugin","EnvironmentVariablesPluginName","getEnvironmentVariablesPlugin","useEnvironmentVariable","useEnvironmentVariables","getMswPlugin","MswPlugin","MswPluginName","MswState","ActiveRouteIsProtectedEvent","ActiveRouteIsPublicEvent","ApplicationBoostrappedEvent","DeferredRegistrationsUpdatedEvent","ModulesReadyEvent","ModulesRegisteredEvent","MswReadyEvent","ProtectedDataReadyEvent","ProtectedDataUpdatedEvent","PublicDataReadyEvent","PublicDataUpdatedEvent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA6B;AAWH;AAUL;AACgB;AAGC;AACD;AAEL;AAaD;AAEK;AACQ;AACE;AACH;AACc;AACF;AACT;AACC;AACP;AACA;AACK;AACA;AACH;AACA;AACY;AACP;AACK;AAEb"}
@@ -1 +1,4 @@
1
- export declare function useIsActiveRouteProtected(areModulesReady: boolean): boolean;
1
+ export interface UseIsActiveRouteProtectedOptions {
2
+ throwWhenThereIsNoMatch?: boolean;
3
+ }
4
+ export declare function useIsActiveRouteProtected(areModulesReady: boolean, options?: UseIsActiveRouteProtectedOptions): boolean;
@@ -8,12 +8,13 @@ import { useLocation } from "react-router";
8
8
  ;// CONCATENATED MODULE: ./src/useIsActiveRouteProtected.ts
9
9
 
10
10
 
11
- function useIsActiveRouteProtected(areModulesReady) {
11
+ function useIsActiveRouteProtected(areModulesReady, options = {}) {
12
+ const { throwWhenThereIsNoMatch = true } = options;
12
13
  // Using this hook instead of window.location to retrieve the current location because it triggers a re-render everytime the browser location change.
13
14
  const location = useLocation();
14
15
  // Only throw when there's no match if the modules are ready, otherwise it's expected that no route will be found since they are not all registered yet.
15
16
  const activeRoute = useRouteMatch(location, {
16
- throwWhenThereIsNoMatch: areModulesReady
17
+ throwWhenThereIsNoMatch: throwWhenThereIsNoMatch && areModulesReady
17
18
  });
18
19
  return useIsRouteProtected(activeRoute);
19
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useIsActiveRouteProtected.js","sources":["../src/useIsActiveRouteProtected.ts"],"sourcesContent":["import { useIsRouteProtected, useRouteMatch } from \"@squide/react-router\";\nimport { useLocation } from \"react-router\";\n\nexport function useIsActiveRouteProtected(areModulesReady: boolean) {\n // Using this hook instead of window.location to retrieve the current location because it triggers a re-render everytime the browser location change.\n const location = useLocation();\n\n // Only throw when there's no match if the modules are ready, otherwise it's expected that no route will be found since they are not all registered yet.\n const activeRoute = useRouteMatch(location, { throwWhenThereIsNoMatch: areModulesReady });\n\n return useIsRouteProtected(activeRoute);\n}\n"],"names":["useIsRouteProtected","useRouteMatch","useLocation","useIsActiveRouteProtected","areModulesReady","location","activeRoute"],"mappings":";;;;;;;;AAA0E;AAC/B;AAEpC,SAASG,0BAA0BC,eAAwB;IAC9D,qJAAqJ;IACrJ,MAAMC,WAAWH,WAAWA;IAE5B,wJAAwJ;IACxJ,MAAMI,cAAcL,aAAaA,CAACI,UAAU;QAAE,yBAAyBD;IAAgB;IAEvF,OAAOJ,mBAAmBA,CAACM;AAC/B"}
1
+ {"version":3,"file":"useIsActiveRouteProtected.js","sources":["../src/useIsActiveRouteProtected.ts"],"sourcesContent":["import { useIsRouteProtected, useRouteMatch } from \"@squide/react-router\";\nimport { useLocation } from \"react-router\";\n\nexport interface UseIsActiveRouteProtectedOptions {\n throwWhenThereIsNoMatch?: boolean;\n}\n\nexport function useIsActiveRouteProtected(areModulesReady: boolean, options: UseIsActiveRouteProtectedOptions = {}) {\n const {\n throwWhenThereIsNoMatch = true\n } = options;\n\n // Using this hook instead of window.location to retrieve the current location because it triggers a re-render everytime the browser location change.\n const location = useLocation();\n\n // Only throw when there's no match if the modules are ready, otherwise it's expected that no route will be found since they are not all registered yet.\n const activeRoute = useRouteMatch(location, { throwWhenThereIsNoMatch: throwWhenThereIsNoMatch && areModulesReady });\n\n return useIsRouteProtected(activeRoute);\n}\n"],"names":["useIsRouteProtected","useRouteMatch","useLocation","useIsActiveRouteProtected","areModulesReady","options","throwWhenThereIsNoMatch","location","activeRoute"],"mappings":";;;;;;;;AAA0E;AAC/B;AAMpC,SAASG,0BAA0BC,eAAwB,EAAEC,UAA4C,CAAC,CAAC;IAC9G,MAAM,EACFC,0BAA0B,IAAI,EACjC,GAAGD;IAEJ,qJAAqJ;IACrJ,MAAME,WAAWL,WAAWA;IAE5B,wJAAwJ;IACxJ,MAAMM,cAAcP,aAAaA,CAACM,UAAU;QAAE,yBAAyBD,2BAA2BF;IAAgB;IAElH,OAAOJ,mBAAmBA,CAACQ;AAC/B"}
@@ -1 +1,4 @@
1
- export declare function useStrictRegistrationMode(): void;
1
+ export interface UseStrictRegistrationModeOptions {
2
+ isEnabled?: boolean;
3
+ }
4
+ export declare function useStrictRegistrationMode(options?: UseStrictRegistrationModeOptions): void;
@@ -14,17 +14,19 @@ function subscribeToModulesReady(runtime) {
14
14
  return ()=>runtime.moduleManager.removeModulesReadyListener(callback);
15
15
  };
16
16
  }
17
- function useStrictRegistrationMode() {
17
+ function useStrictRegistrationMode(options = {}) {
18
+ const { isEnabled = true } = options;
18
19
  const runtime = useRuntime();
19
20
  // This listener is only executed if the modules are ready.
20
21
  const areModulesReady = useSyncExternalStore(subscribeToModulesReady(runtime), ()=>runtime.moduleManager.getAreModulesReady());
21
22
  useEffect(()=>{
22
- if (areModulesReady) {
23
+ if (areModulesReady && isEnabled) {
23
24
  runtime._validateRegistrations();
24
25
  }
25
26
  }, [
26
27
  runtime,
27
- areModulesReady
28
+ areModulesReady,
29
+ isEnabled
28
30
  ]);
29
31
  }
30
32
 
@@ -1 +1 @@
1
- {"version":3,"file":"useStrictRegistrationMode.js","sources":["../src/useStrictRegistrationMode.ts"],"sourcesContent":["import { Runtime, useRuntime } from \"@squide/core\";\nimport { useEffect, useSyncExternalStore } from \"react\";\n\nfunction subscribeToModulesReady(runtime: Runtime) {\n return (callback: () => void) => {\n runtime.moduleManager.registerModulesReadyListener(callback);\n\n return () => runtime.moduleManager.removeModulesReadyListener(callback);\n };\n}\n\nexport function useStrictRegistrationMode() {\n const runtime = useRuntime();\n\n // This listener is only executed if the modules are ready.\n const areModulesReady = useSyncExternalStore(subscribeToModulesReady(runtime), () => runtime.moduleManager.getAreModulesReady());\n\n useEffect(() => {\n if (areModulesReady) {\n runtime._validateRegistrations();\n }\n }, [runtime, areModulesReady]);\n}\n"],"names":["useRuntime","useEffect","useSyncExternalStore","subscribeToModulesReady","runtime","callback","useStrictRegistrationMode","areModulesReady"],"mappings":";;;;;;;;AAAmD;AACK;AAExD,SAASG,wBAAwBC,OAAgB;IAC7C,OAAO,CAACC;QACJD,QAAQ,aAAa,CAAC,4BAA4B,CAACC;QAEnD,OAAO,IAAMD,QAAQ,aAAa,CAAC,0BAA0B,CAACC;IAClE;AACJ;AAEO,SAASC;IACZ,MAAMF,UAAUJ,UAAUA;IAE1B,2DAA2D;IAC3D,MAAMO,kBAAkBL,oBAAoBA,CAACC,wBAAwBC,UAAU,IAAMA,QAAQ,aAAa,CAAC,kBAAkB;IAE7HH,SAASA,CAAC;QACN,IAAIM,iBAAiB;YACjBH,QAAQ,sBAAsB;QAClC;IACJ,GAAG;QAACA;QAASG;KAAgB;AACjC"}
1
+ {"version":3,"file":"useStrictRegistrationMode.js","sources":["../src/useStrictRegistrationMode.ts"],"sourcesContent":["import { Runtime, useRuntime } from \"@squide/core\";\nimport { useEffect, useSyncExternalStore } from \"react\";\n\nfunction subscribeToModulesReady(runtime: Runtime) {\n return (callback: () => void) => {\n runtime.moduleManager.registerModulesReadyListener(callback);\n\n return () => runtime.moduleManager.removeModulesReadyListener(callback);\n };\n}\n\nexport interface UseStrictRegistrationModeOptions {\n isEnabled?: boolean;\n}\n\nexport function useStrictRegistrationMode(options: UseStrictRegistrationModeOptions = {}) {\n const {\n isEnabled = true\n } = options;\n\n const runtime = useRuntime();\n\n // This listener is only executed if the modules are ready.\n const areModulesReady = useSyncExternalStore(subscribeToModulesReady(runtime), () => runtime.moduleManager.getAreModulesReady());\n\n useEffect(() => {\n if (areModulesReady && isEnabled) {\n runtime._validateRegistrations();\n }\n }, [runtime, areModulesReady, isEnabled]);\n}\n"],"names":["useRuntime","useEffect","useSyncExternalStore","subscribeToModulesReady","runtime","callback","useStrictRegistrationMode","options","isEnabled","areModulesReady"],"mappings":";;;;;;;;AAAmD;AACK;AAExD,SAASG,wBAAwBC,OAAgB;IAC7C,OAAO,CAACC;QACJD,QAAQ,aAAa,CAAC,4BAA4B,CAACC;QAEnD,OAAO,IAAMD,QAAQ,aAAa,CAAC,0BAA0B,CAACC;IAClE;AACJ;AAMO,SAASC,0BAA0BC,UAA4C,CAAC,CAAC;IACpF,MAAM,EACFC,YAAY,IAAI,EACnB,GAAGD;IAEJ,MAAMH,UAAUJ,UAAUA;IAE1B,2DAA2D;IAC3D,MAAMS,kBAAkBP,oBAAoBA,CAACC,wBAAwBC,UAAU,IAAMA,QAAQ,aAAa,CAAC,kBAAkB;IAE7HH,SAASA,CAAC;QACN,IAAIQ,mBAAmBD,WAAW;YAC9BJ,QAAQ,sBAAsB;QAClC;IACJ,GAAG;QAACA;QAASK;QAAiBD;KAAU;AAC5C"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "16.0.1",
5
- "description": "Helpers to facilitate the creation of an application with the Squide firefly technology stack.",
4
+ "version": "16.0.3",
5
+ "description": "Squide bundle for the firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "peerDependencies": {
35
35
  "@opentelemetry/api": "^1.9.0",
36
- "@tanstack/react-query": "^5.90.10",
37
- "msw": "^2.12.2",
36
+ "@tanstack/react-query": "^5.90.11",
37
+ "msw": "^2.12.3",
38
38
  "react": "^18.0.0 || ^19.0.0",
39
39
  "react-dom": "^18.0.0 || ^19.0.0",
40
40
  "react-router": "^7.9.6"
@@ -48,19 +48,19 @@
48
48
  "@workleap-telemetry/core": "^1.0.4",
49
49
  "@workleap/logging": "^1.3.2",
50
50
  "uuid": "^13.0.0",
51
- "@squide/env-vars": "1.4.8",
52
- "@squide/msw": "4.0.6",
53
- "@squide/react-router": "8.1.5",
54
- "@squide/core": "6.1.5"
51
+ "@squide/core": "6.1.6",
52
+ "@squide/env-vars": "1.4.9",
53
+ "@squide/msw": "4.0.7",
54
+ "@squide/react-router": "8.1.6"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@eslint/js": "9.39.1",
58
- "@rsbuild/core": "1.6.7",
59
- "@rslib/core": "0.18.0",
58
+ "@rsbuild/core": "1.6.9",
59
+ "@rslib/core": "0.18.2",
60
60
  "@testing-library/react": "16.3.0",
61
- "@types/react": "19.2.6",
61
+ "@types/react": "19.2.7",
62
62
  "@types/react-dom": "19.2.3",
63
- "@typescript-eslint/parser": "8.47.0",
63
+ "@typescript-eslint/parser": "8.48.0",
64
64
  "@vitejs/plugin-react": "5.1.1",
65
65
  "@workleap/eslint-configs": "1.1.5",
66
66
  "@workleap/rslib-configs": "1.1.3",
@@ -68,8 +68,8 @@
68
68
  "eslint": "9.39.1",
69
69
  "happy-dom": "20.0.10",
70
70
  "typescript": "5.9.3",
71
- "typescript-eslint": "8.47.0",
72
- "vitest": "4.0.10"
71
+ "typescript-eslint": "8.48.0",
72
+ "vitest": "4.0.14"
73
73
  },
74
74
  "sideEffects": false,
75
75
  "scripts": {
package/src/AppRouter.tsx CHANGED
@@ -27,7 +27,7 @@ export function useCanRenderRouter({ areModulesRegistered, areModulesReady: areM
27
27
  );
28
28
  }
29
29
 
30
- function useRenderRouterProvider(state: AppRouterState, renderRouterProvider: RenderRouterProviderFunction) {
30
+ function useRenderRouterProvider(state: AppRouterState, renderRouterProvider: RenderRouterProviderFunction, strictMode: boolean) {
31
31
  const routes = useRoutes();
32
32
 
33
33
  // The value is computed outside of the router provider memo to prevent
@@ -37,19 +37,20 @@ function useRenderRouterProvider(state: AppRouterState, renderRouterProvider: Re
37
37
  return useMemo(() => {
38
38
  if (canRenderRouter) {
39
39
  return renderRouterProvider({
40
- rootRoute: <RootRoute />,
40
+ rootRoute: <RootRoute strictMode={strictMode} />,
41
41
  registeredRoutes: routes,
42
42
  routerProviderProps: {}
43
43
  });
44
44
  }
45
45
 
46
46
  return null;
47
- }, [canRenderRouter, routes, renderRouterProvider]);
47
+ }, [canRenderRouter, routes, renderRouterProvider, strictMode]);
48
48
  }
49
49
 
50
50
  export interface AppRouterProps {
51
51
  waitForPublicData?: boolean;
52
52
  waitForProtectedData?: boolean;
53
+ strictMode?: boolean;
53
54
  children: RenderRouterProviderFunction;
54
55
  }
55
56
 
@@ -57,13 +58,16 @@ export function AppRouter(props: AppRouterProps) {
57
58
  const {
58
59
  waitForPublicData = false,
59
60
  waitForProtectedData = false,
61
+ strictMode = true,
60
62
  children: renderRouterProvider
61
63
  } = props;
62
64
  const [state, dispatch] = useAppRouterReducer(waitForPublicData, waitForProtectedData);
63
65
 
64
66
  const logger = useLogger();
65
67
 
66
- useStrictRegistrationMode();
68
+ useStrictRegistrationMode({
69
+ isEnabled: strictMode
70
+ });
67
71
 
68
72
  useEffect(() => {
69
73
  logger
@@ -72,7 +76,7 @@ export function AppRouter(props: AppRouterProps) {
72
76
  .debug();
73
77
  }, [state, logger]);
74
78
 
75
- const routerProvider = useRenderRouterProvider(state, renderRouterProvider);
79
+ const routerProvider = useRenderRouterProvider(state, renderRouterProvider, strictMode);
76
80
 
77
81
  return (
78
82
  <AppRouterDispatcherContext.Provider value={dispatch}>
@@ -1,8 +1,9 @@
1
- import { type Runtime, RuntimeContext } from "@squide/core";
1
+ import { RuntimeContext } from "@squide/core";
2
2
  import type { PropsWithChildren } from "react";
3
+ import { FireflyRuntime } from "./FireflyRuntime.tsx";
3
4
 
4
5
  export interface FireflyProviderProps extends PropsWithChildren {
5
- runtime: Runtime;
6
+ runtime: FireflyRuntime;
6
7
  }
7
8
 
8
9
  export function FireflyProvider(props: FireflyProviderProps) {
package/src/RootRoute.tsx CHANGED
@@ -3,9 +3,20 @@ import { Outlet } from "react-router";
3
3
  import { useAppRouterDispatcher, useAppRouterState } from "./AppRouterContext.ts";
4
4
  import { useIsActiveRouteProtected } from "./useIsActiveRouteProtected.ts";
5
5
 
6
- export function RootRoute() {
6
+ export interface RootRouteProps {
7
+ strictMode?: boolean;
8
+ }
9
+
10
+ export function RootRoute(props: RootRouteProps) {
11
+ const {
12
+ strictMode = true
13
+ } = props;
14
+
7
15
  const state = useAppRouterState();
8
- const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady);
16
+
17
+ const isActiveRouteProtected = useIsActiveRouteProtected(state.areModulesReady, {
18
+ throwWhenThereIsNoMatch: strictMode
19
+ });
9
20
 
10
21
  const dispatch = useAppRouterDispatcher();
11
22
 
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from "@squide/core";
2
2
  export {
3
3
  EnvironmentVariablesPlugin,
4
+ EnvironmentVariablesPluginName,
5
+ getEnvironmentVariablesPlugin,
4
6
  useEnvironmentVariable,
5
7
  useEnvironmentVariables,
6
8
  type EnvironmentVariableKey,
@@ -9,7 +11,9 @@ export {
9
11
  type EnvironmentVariableValue
10
12
  } from "@squide/env-vars";
11
13
  export {
14
+ getMswPlugin,
12
15
  MswPlugin,
16
+ MswPluginName,
13
17
  MswState,
14
18
  type MswPluginOptions,
15
19
  type MswPluginRegisterRequestHandlersOptions,
@@ -1,12 +1,20 @@
1
1
  import { useIsRouteProtected, useRouteMatch } from "@squide/react-router";
2
2
  import { useLocation } from "react-router";
3
3
 
4
- export function useIsActiveRouteProtected(areModulesReady: boolean) {
4
+ export interface UseIsActiveRouteProtectedOptions {
5
+ throwWhenThereIsNoMatch?: boolean;
6
+ }
7
+
8
+ export function useIsActiveRouteProtected(areModulesReady: boolean, options: UseIsActiveRouteProtectedOptions = {}) {
9
+ const {
10
+ throwWhenThereIsNoMatch = true
11
+ } = options;
12
+
5
13
  // Using this hook instead of window.location to retrieve the current location because it triggers a re-render everytime the browser location change.
6
14
  const location = useLocation();
7
15
 
8
16
  // Only throw when there's no match if the modules are ready, otherwise it's expected that no route will be found since they are not all registered yet.
9
- const activeRoute = useRouteMatch(location, { throwWhenThereIsNoMatch: areModulesReady });
17
+ const activeRoute = useRouteMatch(location, { throwWhenThereIsNoMatch: throwWhenThereIsNoMatch && areModulesReady });
10
18
 
11
19
  return useIsRouteProtected(activeRoute);
12
20
  }
@@ -9,15 +9,23 @@ function subscribeToModulesReady(runtime: Runtime) {
9
9
  };
10
10
  }
11
11
 
12
- export function useStrictRegistrationMode() {
12
+ export interface UseStrictRegistrationModeOptions {
13
+ isEnabled?: boolean;
14
+ }
15
+
16
+ export function useStrictRegistrationMode(options: UseStrictRegistrationModeOptions = {}) {
17
+ const {
18
+ isEnabled = true
19
+ } = options;
20
+
13
21
  const runtime = useRuntime();
14
22
 
15
23
  // This listener is only executed if the modules are ready.
16
24
  const areModulesReady = useSyncExternalStore(subscribeToModulesReady(runtime), () => runtime.moduleManager.getAreModulesReady());
17
25
 
18
26
  useEffect(() => {
19
- if (areModulesReady) {
27
+ if (areModulesReady && isEnabled) {
20
28
  runtime._validateRegistrations();
21
29
  }
22
- }, [runtime, areModulesReady]);
30
+ }, [runtime, areModulesReady, isEnabled]);
23
31
  }