@squide/firefly 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @squide/firefly
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`58097a2`](https://github.com/gsoft-inc/wl-squide/commit/58097a2fbaa7e5942cbe6f9b765fe471d52758d8)]:
8
+ - @squide/msw@2.0.3
9
+
3
10
  ## 1.0.0
4
11
 
5
12
  ### Major Changes
@@ -2,14 +2,14 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactElement } from 'react';
3
3
  import { RouterProviderProps } from 'react-router-dom';
4
4
 
5
- type OnLoadPublicDataFunction = (signal: AbortSignal) => Promise<unknown>;
6
- type OnLoadProtectedDataFunction = (signal: AbortSignal) => Promise<unknown>;
7
- type OnCompleteRegistrationFunction = () => Promise<unknown>;
5
+ type OnLoadPublicDataFunction = () => Promise<unknown>;
6
+ type OnLoadProtectedDataFunction = () => Promise<unknown>;
7
+ type OnCompleteRegistrationsFunction = () => Promise<unknown>;
8
8
  interface BootstrappingRouteProps {
9
9
  fallbackElement: ReactElement;
10
10
  onLoadPublicData?: OnLoadPublicDataFunction;
11
11
  onLoadProtectedData?: OnLoadProtectedDataFunction;
12
- onCompleteRegistration?: OnCompleteRegistrationFunction;
12
+ onCompleteRegistrations?: OnCompleteRegistrationsFunction;
13
13
  waitForMsw: boolean;
14
14
  areModulesRegistered: boolean;
15
15
  areModulesReady: boolean;
@@ -20,10 +20,10 @@ interface AppRouterProps {
20
20
  errorElement: ReactElement;
21
21
  onLoadPublicData?: OnLoadPublicDataFunction;
22
22
  onLoadProtectedData?: OnLoadProtectedDataFunction;
23
- onCompleteRegistration?: OnCompleteRegistrationFunction;
23
+ onCompleteRegistrations?: OnCompleteRegistrationsFunction;
24
24
  waitForMsw: boolean;
25
25
  routerProvidersProps?: RouterProviderProps;
26
26
  }
27
27
  declare function AppRouter(props: AppRouterProps): react_jsx_runtime.JSX.Element;
28
28
 
29
- export { AppRouter, AppRouterProps, BootstrappingRoute, OnCompleteRegistrationFunction, OnLoadProtectedDataFunction, OnLoadPublicDataFunction };
29
+ export { AppRouter, AppRouterProps, BootstrappingRoute, OnCompleteRegistrationsFunction, OnLoadProtectedDataFunction, OnLoadPublicDataFunction };
package/dist/AppRouter.js CHANGED
@@ -1 +1 @@
1
- export { AppRouter, BootstrappingRoute } from './chunk-4UQRHMJC.js';
1
+ export { AppRouter, BootstrappingRoute } from './chunk-KR6KTAOB.js';
@@ -12,7 +12,7 @@ function BootstrappingRoute(props) {
12
12
  fallbackElement,
13
13
  onLoadPublicData,
14
14
  onLoadProtectedData,
15
- onCompleteRegistration,
15
+ onCompleteRegistrations,
16
16
  waitForMsw,
17
17
  areModulesRegistered,
18
18
  areModulesReady
@@ -37,37 +37,29 @@ function BootstrappingRoute(props) {
37
37
  if ((areModulesRegistered || areModulesReady) && isMswStarted) {
38
38
  if (!isPublicDataLoaded) {
39
39
  logger.debug("[shell] Loading public data.");
40
- const abordController = new AbortController();
41
- onLoadPublicData(abordController.signal).then(() => {
40
+ onLoadPublicData().then(() => {
42
41
  setIsPublicDataLoaded(true);
43
42
  logger.debug("[shell] Public data has been loaded.");
44
43
  }).catch((error) => {
45
44
  showBoundary(error);
46
45
  });
47
- return () => {
48
- abordController.abort();
49
- };
50
46
  }
51
47
  }
52
48
  }
53
49
  }, [logger, areModulesRegistered, areModulesReady, isMswStarted, isPublicDataLoaded, onLoadPublicData]);
54
- const isActiveRouteProtected = useIsRouteMatchProtected(location);
50
+ const isActiveRouteProtected = useIsRouteMatchProtected(location, { throwWhenThereIsNoMatch: areModulesReady });
55
51
  useEffect(() => {
56
52
  if (onLoadProtectedData) {
57
53
  if ((areModulesRegistered || areModulesReady) && isMswStarted) {
58
54
  if (isActiveRouteProtected) {
59
55
  if (!isProtectedDataLoaded) {
60
56
  logger.debug(`[shell] Loading protected data as "${location.pathname}" is a protected route.`);
61
- const abordController = new AbortController();
62
- onLoadProtectedData(abordController.signal).then(() => {
57
+ onLoadProtectedData().then(() => {
63
58
  setIsProtectedDataLoaded(true);
64
59
  logger.debug("[shell] Protected data has been loaded.");
65
60
  }).catch((error) => {
66
61
  showBoundary(error);
67
62
  });
68
- return () => {
69
- abordController.abort();
70
- };
71
63
  }
72
64
  } else {
73
65
  logger.debug(`[shell] Not loading protected data as "${location.pathname}" is a public route.`);
@@ -76,14 +68,14 @@ function BootstrappingRoute(props) {
76
68
  }
77
69
  }, [logger, location, areModulesRegistered, areModulesReady, isMswStarted, isActiveRouteProtected, isProtectedDataLoaded, onLoadProtectedData]);
78
70
  useEffect(() => {
79
- if (onCompleteRegistration) {
71
+ if (onCompleteRegistrations) {
80
72
  if (areModulesRegistered && isMswStarted && isPublicDataLoaded) {
81
73
  if (!areModulesReady) {
82
- onCompleteRegistration();
74
+ onCompleteRegistrations();
83
75
  }
84
76
  }
85
77
  }
86
- }, [areModulesRegistered, areModulesReady, isMswStarted, isPublicDataLoaded, onCompleteRegistration]);
78
+ }, [areModulesRegistered, areModulesReady, isMswStarted, isPublicDataLoaded, onCompleteRegistrations]);
87
79
  if (!areModulesReady || !isMswStarted || !isPublicDataLoaded || isActiveRouteProtected && !isProtectedDataLoaded) {
88
80
  return fallbackElement;
89
81
  }
@@ -95,7 +87,7 @@ function AppRouter(props) {
95
87
  errorElement,
96
88
  onLoadPublicData,
97
89
  onLoadProtectedData,
98
- onCompleteRegistration,
90
+ onCompleteRegistrations,
99
91
  waitForMsw,
100
92
  routerProvidersProps = {}
101
93
  } = props;
@@ -116,7 +108,7 @@ function AppRouter(props) {
116
108
  fallbackElement,
117
109
  onLoadPublicData,
118
110
  onLoadProtectedData,
119
- onCompleteRegistration,
111
+ onCompleteRegistrations,
120
112
  waitForMsw,
121
113
  areModulesRegistered,
122
114
  areModulesReady
@@ -125,7 +117,7 @@ function AppRouter(props) {
125
117
  children: routes
126
118
  }
127
119
  ]);
128
- }, [areModulesRegistered, areModulesReady, routes, onLoadPublicData, onLoadProtectedData, onCompleteRegistration, waitForMsw]);
120
+ }, [areModulesRegistered, areModulesReady, routes, onLoadPublicData, onLoadProtectedData, onCompleteRegistrations, waitForMsw]);
129
121
  return /* @__PURE__ */ jsx(RouterProvider, { ...routerProvidersProps, router });
130
122
  }
131
123
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { AppRouter, AppRouterProps, BootstrappingRoute, OnCompleteRegistrationFunction, OnLoadProtectedDataFunction, OnLoadPublicDataFunction } from './AppRouter.js';
1
+ export { AppRouter, AppRouterProps, BootstrappingRoute, OnCompleteRegistrationsFunction, OnLoadProtectedDataFunction, OnLoadPublicDataFunction } from './AppRouter.js';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
4
4
  import 'react-router-dom';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { AppRouter, BootstrappingRoute } from './chunk-4UQRHMJC.js';
1
+ export { AppRouter, BootstrappingRoute } from './chunk-KR6KTAOB.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
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": {
@@ -39,12 +39,13 @@
39
39
  }
40
40
  },
41
41
  "devDependencies": {
42
- "@swc/core": "1.3.95",
42
+ "@swc/core": "1.3.96",
43
43
  "@swc/helpers": "0.5.3",
44
44
  "@swc/jest": "0.2.29",
45
+ "@testing-library/jest-dom": "6.1.4",
45
46
  "@testing-library/react": "14.0.0",
46
- "@types/jest": "29.5.6",
47
- "@types/react": "18.2.33",
47
+ "@types/jest": "29.5.7",
48
+ "@types/react": "18.2.36",
48
49
  "@types/react-dom": "18.2.14",
49
50
  "@workleap/eslint-plugin": "3.0.0",
50
51
  "@workleap/swc-configs": "2.1.2",
@@ -52,17 +53,17 @@
52
53
  "@workleap/typescript-configs": "3.0.2",
53
54
  "jest": "29.7.0",
54
55
  "jest-environment-jsdom": "29.7.0",
55
- "msw": "1.3.2",
56
+ "msw": "2.0.3",
56
57
  "react": "18.2.0",
57
58
  "react-dom": "18.2.0",
58
59
  "react-error-boundary": "4.0.11",
59
- "react-router-dom": "6.17.0",
60
+ "react-router-dom": "6.18.0",
60
61
  "ts-jest": "29.1.1",
61
62
  "tsup": "7.2.0",
62
63
  "typescript": "5.2.2"
63
64
  },
64
65
  "dependencies": {
65
- "@squide/msw": "2.0.2",
66
+ "@squide/msw": "2.0.3",
66
67
  "@squide/react-router": "2.0.2",
67
68
  "@squide/webpack-module-federation": "2.2.0"
68
69
  },