@squide/firefly 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @squide/firefly
2
2
 
3
+ ## 4.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#135](https://github.com/gsoft-inc/wl-squide/pull/135) [`8e73083`](https://github.com/gsoft-inc/wl-squide/commit/8e73083bb90a6f23495ac6a8dca0245862ee2c9a) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Fixing a remaining issue with deferred registrations that depends on protected data.
8
+
9
+ - Updated dependencies [[`8e73083`](https://github.com/gsoft-inc/wl-squide/commit/8e73083bb90a6f23495ac6a8dca0245862ee2c9a)]:
10
+ - @squide/react-router@4.0.2
11
+
12
+ ## 4.0.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#133](https://github.com/gsoft-inc/wl-squide/pull/133) [`1cda1be`](https://github.com/gsoft-inc/wl-squide/commit/1cda1be30779d1a1d5d2e21eac043baff20c0f7e) Thanks [@patricklafrance](https://github.com/patricklafrance)! - - To prevent the consumer from always handling the AbortSignal error, a default catch has been added to the `AppRouter` component. The consumer can still handler the AbortSignal error if he needs to.
17
+
18
+ - When a user makes a direct hit to a deferred route that depends on protected data, the protected data was undefined. The reason was that by default, an unregistered route was considered as a public route. The code has been updated to consider an uregistered route as a protected route. The upside is that deferred routes can now depends on protected data. The downside is that a public deferred route will trigger the loading of the protected data. As we don't expect to have public deferred route at the moment it doesn't seems like an issue.
19
+
20
+ - Updated dependencies [[`1cda1be`](https://github.com/gsoft-inc/wl-squide/commit/1cda1be30779d1a1d5d2e21eac043baff20c0f7e), [`1cda1be`](https://github.com/gsoft-inc/wl-squide/commit/1cda1be30779d1a1d5d2e21eac043baff20c0f7e), [`1cda1be`](https://github.com/gsoft-inc/wl-squide/commit/1cda1be30779d1a1d5d2e21eac043baff20c0f7e)]:
21
+ - @squide/webpack-module-federation@3.0.4
22
+ - @squide/react-router@4.0.1
23
+ - @squide/core@3.2.1
24
+ - @squide/webpack-configs@1.1.3
25
+ - @squide/msw@2.0.9
26
+
3
27
  ## 4.0.0
4
28
 
5
29
  ### Major Changes
package/dist/AppRouter.js CHANGED
@@ -1 +1 @@
1
- export { AppRouter, BootstrappingRoute } from './chunk-QZACR5NK.js';
1
+ export { AppRouter, BootstrappingRoute } from './chunk-M533VVCI.js';
@@ -0,0 +1,6 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare function NoMatchRouteFallback(): react_jsx_runtime.JSX.Element;
4
+ declare const Component: typeof NoMatchRouteFallback;
5
+
6
+ export { Component, NoMatchRouteFallback };
@@ -0,0 +1 @@
1
+ export { Component, NoMatchRouteFallback } from './chunk-MCU5TIOP.js';
@@ -1,6 +1,6 @@
1
1
  import { useLogOnceLogger, isNil } from '@squide/core';
2
2
  import { useIsMswStarted } from '@squide/msw';
3
- import { useIsRouteMatchProtected, useRoutes } from '@squide/react-router';
3
+ import { useRouteMatch, useIsRouteProtected, useRoutes } from '@squide/react-router';
4
4
  import { useAreModulesRegistered, useAreModulesReady } from '@squide/webpack-module-federation';
5
5
  import { useEffect, useCallback, cloneElement, useMemo } from 'react';
6
6
  import { ErrorBoundary, useErrorBoundary } from 'react-error-boundary';
@@ -16,14 +16,17 @@ function useLoadPublicData(areModulesRegistered, areModulesReady, isMswStarted,
16
16
  if ((areModulesRegistered || areModulesReady) && isMswStarted) {
17
17
  logger.debugOnce("loading-public-data", "[shell] Loading public data.");
18
18
  const abortController = new AbortController();
19
- const result = onLoadData(abortController.signal);
19
+ const signal = abortController.signal;
20
+ const result = onLoadData(signal);
20
21
  if (!isPromise(result)) {
21
22
  throw Error("[squide] An AppRouter onLoadPublicData handler must return a promise object.");
22
23
  }
23
24
  result.then(() => {
24
25
  logger.debugOnce("public-data-loaded", "[shell] Public data has been loaded.");
25
26
  }).catch((error) => {
26
- showBoundary(error);
27
+ if (!signal.aborted) {
28
+ showBoundary(error);
29
+ }
27
30
  });
28
31
  return () => {
29
32
  abortController.abort();
@@ -41,14 +44,17 @@ function useLoadProtectedData(areModulesRegistered, areModulesReady, isMswStarte
41
44
  if (isActiveRouteProtected) {
42
45
  logger.debugOnce("loading-protected-data", `[shell] Loading protected data as "${location.pathname}" is a protected route.`);
43
46
  const abortController = new AbortController();
44
- const result = onLoadData(abortController.signal);
47
+ const signal = abortController.signal;
48
+ const result = onLoadData(signal);
45
49
  if (!isPromise(result)) {
46
50
  throw Error("[squide] An AppRouter onLoadProtectedData handler must return a promise object.");
47
51
  }
48
52
  result.then(() => {
49
53
  logger.debugOnce("protected-data-loaded", "[shell] Protected data has been loaded.");
50
54
  }).catch((error) => {
51
- showBoundary(error);
55
+ if (!signal.aborted) {
56
+ showBoundary(error);
57
+ }
52
58
  });
53
59
  return () => {
54
60
  abortController.abort();
@@ -88,7 +94,8 @@ function BootstrappingRoute(props) {
88
94
  }
89
95
  }, [logger, areModulesRegistered, areModulesReady, isMswStarted, waitForMsw]);
90
96
  useLoadPublicData(areModulesRegistered, areModulesReady, isMswStarted, isPublicDataLoaded, onLoadPublicData);
91
- const isActiveRouteProtected = useIsRouteMatchProtected(location2, { throwWhenThereIsNoMatch: areModulesReady });
97
+ const activeRoute = useRouteMatch(location2, { throwWhenThereIsNoMatch: areModulesReady });
98
+ const isActiveRouteProtected = useIsRouteProtected(activeRoute);
92
99
  useLoadProtectedData(areModulesRegistered, areModulesReady, isMswStarted, isActiveRouteProtected, isProtectedDataLoaded, onLoadProtectedData);
93
100
  useEffect(() => {
94
101
  if (onCompleteRegistrations) {
@@ -99,7 +106,7 @@ function BootstrappingRoute(props) {
99
106
  }
100
107
  }
101
108
  }, [areModulesRegistered, areModulesReady, isMswStarted, isPublicDataLoaded, isProtectedDataLoaded, isActiveRouteProtected, onCompleteRegistrations]);
102
- if (!areModulesReady || !isMswStarted || !isPublicDataLoaded || isActiveRouteProtected && !isProtectedDataLoaded) {
109
+ if (!areModulesReady || !isMswStarted || !activeRoute || !isPublicDataLoaded || isActiveRouteProtected && !isProtectedDataLoaded) {
103
110
  return fallbackElement;
104
111
  }
105
112
  return /* @__PURE__ */ jsx(Outlet, {});
@@ -125,6 +132,12 @@ function AppRouter(props) {
125
132
  });
126
133
  }, [errorElement]);
127
134
  return useMemo(() => {
135
+ if (!routes.some((x) => x.path === "*")) {
136
+ routes.push({
137
+ path: "*",
138
+ lazy: () => import('./NoMatchRouteFallback.js')
139
+ });
140
+ }
128
141
  return renderRouterProvider([
129
142
  {
130
143
  element: /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: errorRenderer, children: /* @__PURE__ */ jsx(
@@ -0,0 +1,27 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+
3
+ // src/NoMatchRouteFallback.tsx
4
+ function NoMatchRouteFallback() {
5
+ return /* @__PURE__ */ jsxs("div", { children: [
6
+ /* @__PURE__ */ jsx("h1", { children: "404 not found" }),
7
+ /* @__PURE__ */ jsxs("p", { children: [
8
+ "This page has been dynamically added by Squide to fix an issue with the ",
9
+ /* @__PURE__ */ jsx("code", { children: "AppRouter" }),
10
+ " component. ",
11
+ /* @__PURE__ */ jsxs("strong", { children: [
12
+ "Please replace this page in your application by a ",
13
+ /* @__PURE__ */ jsx("a", { href: "https://reactrouter.com/en/main/start/tutorial#handling-not-found-errors", children: "custom match page" }),
14
+ "."
15
+ ] })
16
+ ] }),
17
+ /* @__PURE__ */ jsx("p", { children: "The code should be like the following:" }),
18
+ /* @__PURE__ */ jsx("pre", { style: { backgroundColor: "rgb(243, 245, 249)", color: "rgb(21, 25, 40)", padding: "4px 10px", border: "1px solid rgb(225, 229, 239)" }, children: `runtime.registerRoute({
19
+ $visibility: "public",
20
+ path: "*",
21
+ lazy: import("./NoMatchPage.tsx")
22
+ });` })
23
+ ] });
24
+ }
25
+ var Component = NoMatchRouteFallback;
26
+
27
+ export { Component, NoMatchRouteFallback };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from '@squide/msw';
3
3
  export * from '@squide/react-router';
4
4
  export * from '@squide/webpack-module-federation';
5
5
  export { AppRouter, AppRouterProps, BootstrappingRoute, OnCompleteRegistrationsFunction, OnLoadProtectedDataFunction, OnLoadPublicDataFunction, RenderRouterProviderFunction } from './AppRouter.js';
6
+ export { Component, NoMatchRouteFallback } from './NoMatchRouteFallback.js';
6
7
  export { FireflyRuntime } from './fireflyRuntime.js';
7
8
  import 'react';
8
9
  import 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- export { AppRouter, BootstrappingRoute } from './chunk-QZACR5NK.js';
1
+ export { AppRouter, BootstrappingRoute } from './chunk-M533VVCI.js';
2
+ export { Component, NoMatchRouteFallback } from './chunk-MCU5TIOP.js';
2
3
  export { FireflyRuntime } from './chunk-6R4K3V6F.js';
3
4
  export * from '@squide/core';
4
5
  export * from '@squide/msw';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "4.0.0",
4
+ "version": "4.0.2",
5
5
  "description": "Helpers to facilitate the creation of a shell package with Squide firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -88,13 +88,13 @@
88
88
  "tsup": "8.0.1",
89
89
  "typescript": "5.2.2",
90
90
  "webpack": "5.89.0",
91
- "@squide/webpack-configs": "1.1.2"
91
+ "@squide/webpack-configs": "1.1.3"
92
92
  },
93
93
  "dependencies": {
94
- "@squide/core": "3.2.0",
95
- "@squide/msw": "2.0.8",
96
- "@squide/react-router": "4.0.0",
97
- "@squide/webpack-module-federation": "3.0.3"
94
+ "@squide/core": "3.2.1",
95
+ "@squide/react-router": "4.0.2",
96
+ "@squide/webpack-module-federation": "3.0.4",
97
+ "@squide/msw": "2.0.9"
98
98
  },
99
99
  "sideEffects": false,
100
100
  "engines": {