@squide/firefly 7.0.0 → 9.0.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 +185 -0
- package/dist/AppRouter.d.ts +13 -26
- package/dist/AppRouter.js +6 -1
- package/dist/AppRouterContext.d.ts +9 -0
- package/dist/AppRouterContext.js +1 -0
- package/dist/AppRouterReducer.d.ts +31 -0
- package/dist/AppRouterReducer.js +1 -0
- package/dist/FireflyRuntime.d.ts +17 -0
- package/dist/FireflyRuntime.js +2 -0
- package/dist/GlobalDataQueriesError.d.ts +8 -0
- package/dist/GlobalDataQueriesError.js +1 -0
- package/dist/RootRoute.d.ts +5 -0
- package/dist/RootRoute.js +3 -0
- package/dist/chunk-2E76JVV7.js +41 -0
- package/dist/chunk-36U4TTNR.js +34 -0
- package/dist/chunk-ENUCXEMN.js +180 -0
- package/dist/chunk-FKQ7XQEU.js +54 -0
- package/dist/chunk-G32YX2KR.js +22 -0
- package/dist/chunk-H6F7HDB3.js +9 -0
- package/dist/chunk-HE5HKFL3.js +16 -0
- package/dist/chunk-I6L3AYOB.js +24 -0
- package/dist/chunk-IOMSOUAL.js +20 -0
- package/dist/chunk-L5BP3WP3.js +21 -0
- package/dist/chunk-MZG2PJJG.js +19 -0
- package/dist/chunk-N2GOIQ5E.js +14 -0
- package/dist/chunk-PP3MRMJJ.js +11 -0
- package/dist/chunk-PU7MASPN.js +18 -0
- package/dist/chunk-RG5N56BQ.js +55 -0
- package/dist/chunk-VUMBZ5BP.js +46 -0
- package/dist/chunk-WOPD33CM.js +25 -0
- package/dist/chunk-WVRMJZV6.js +18 -0
- package/dist/chunk-YRWFYWK4.js +11 -0
- package/dist/index.d.ts +22 -5
- package/dist/index.js +20 -3
- package/dist/useCanFetchProtectedData.d.ts +3 -0
- package/dist/useCanFetchProtectedData.js +2 -0
- package/dist/useCanFetchPublicData.d.ts +3 -0
- package/dist/useCanFetchPublicData.js +2 -0
- package/dist/useCanRegisterDeferredRegistrations.d.ts +3 -0
- package/dist/useCanRegisterDeferredRegistrations.js +2 -0
- package/dist/useCanUpdateDeferredRegistrations.d.ts +3 -0
- package/dist/useCanUpdateDeferredRegistrations.js +2 -0
- package/dist/useDeferredRegistrations.d.ts +13 -0
- package/dist/useDeferredRegistrations.js +6 -0
- package/dist/useIsActiveRouteProtected.d.ts +3 -0
- package/dist/useIsActiveRouteProtected.js +1 -0
- package/dist/useIsBootstrapping.d.ts +3 -0
- package/dist/useIsBootstrapping.js +2 -0
- package/dist/useNavigationItems.d.ts +5 -0
- package/dist/useNavigationItems.js +2 -0
- package/dist/useProtectedDataQueries.d.ts +9 -0
- package/dist/useProtectedDataQueries.js +4 -0
- package/dist/usePublicDataQueries.d.ts +8 -0
- package/dist/usePublicDataQueries.js +4 -0
- package/dist/useRegisterDeferredRegistrations.d.ts +9 -0
- package/dist/useRegisterDeferredRegistrations.js +1 -0
- package/dist/useStrictRegistrationMode.d.ts +3 -0
- package/dist/useStrictRegistrationMode.js +1 -0
- package/dist/useUpdateDeferredRegistrations.d.ts +9 -0
- package/dist/useUpdateDeferredRegistrations.js +2 -0
- package/package.json +23 -23
- package/dist/chunk-JRNDLQBI.js +0 -26
- package/dist/chunk-YPB7BNRJ.js +0 -160
- package/dist/fireflyRuntime.d.ts +0 -13
- package/dist/fireflyRuntime.js +0 -1
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "
|
|
5
|
-
"description": "Helpers to facilitate the creation of
|
|
4
|
+
"version": "9.0.0",
|
|
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": {
|
|
8
8
|
"type": "git",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"type": "module",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
-
"import": "./dist/index.js",
|
|
20
19
|
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
21
|
"default": "./dist/index.js"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -27,40 +27,40 @@
|
|
|
27
27
|
"README.md"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
+
"@tanstack/react-query": "*",
|
|
30
31
|
"msw": "*",
|
|
31
32
|
"react": "*",
|
|
32
33
|
"react-dom": "*",
|
|
33
|
-
"react-error-boundary": "*",
|
|
34
34
|
"react-router-dom": "*"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@swc/core": "1.
|
|
37
|
+
"@swc/core": "1.7.0",
|
|
38
38
|
"@swc/jest": "0.2.36",
|
|
39
|
-
"@testing-library/jest-dom": "6.4.
|
|
40
|
-
"@testing-library/react": "
|
|
39
|
+
"@testing-library/jest-dom": "6.4.6",
|
|
40
|
+
"@testing-library/react": "16.0.0",
|
|
41
41
|
"@types/jest": "29.5.12",
|
|
42
|
-
"@types/react": "18.
|
|
43
|
-
"@types/react-dom": "18.
|
|
44
|
-
"@workleap/eslint-plugin": "3.
|
|
42
|
+
"@types/react": "18.3.3",
|
|
43
|
+
"@types/react-dom": "18.3.0",
|
|
44
|
+
"@workleap/eslint-plugin": "3.2.2",
|
|
45
45
|
"@workleap/swc-configs": "2.2.3",
|
|
46
|
-
"@workleap/tsup-configs": "3.0.
|
|
46
|
+
"@workleap/tsup-configs": "3.0.6",
|
|
47
47
|
"@workleap/typescript-configs": "3.0.2",
|
|
48
|
+
"eslint": "8.57.0",
|
|
48
49
|
"jest": "29.7.0",
|
|
49
50
|
"jest-environment-jsdom": "29.7.0",
|
|
50
|
-
"msw": "2.
|
|
51
|
-
"react": "18.
|
|
52
|
-
"react-dom": "18.
|
|
53
|
-
"react-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"typescript": "5.4.2"
|
|
51
|
+
"msw": "2.3.1",
|
|
52
|
+
"react": "18.3.1",
|
|
53
|
+
"react-dom": "18.3.1",
|
|
54
|
+
"react-router-dom": "6.25.1",
|
|
55
|
+
"ts-jest": "29.2.3",
|
|
56
|
+
"tsup": "8.1.2",
|
|
57
|
+
"typescript": "5.5.3"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@squide/core": "
|
|
61
|
-
"@squide/
|
|
62
|
-
"@squide/
|
|
63
|
-
"@squide/
|
|
60
|
+
"@squide/core": "5.0.0",
|
|
61
|
+
"@squide/module-federation": "6.0.0",
|
|
62
|
+
"@squide/msw": "3.0.0",
|
|
63
|
+
"@squide/react-router": "6.0.0"
|
|
64
64
|
},
|
|
65
65
|
"sideEffects": false,
|
|
66
66
|
"engines": {
|
package/dist/chunk-JRNDLQBI.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { MswPlugin } from '@squide/msw';
|
|
2
|
-
import { ReactRouterRuntime } from '@squide/react-router';
|
|
3
|
-
|
|
4
|
-
// src/fireflyRuntime.tsx
|
|
5
|
-
var FireflyRuntime = class extends ReactRouterRuntime {
|
|
6
|
-
#mswPlugin;
|
|
7
|
-
constructor({ plugins, ...options } = {}) {
|
|
8
|
-
const mswPlugin = new MswPlugin();
|
|
9
|
-
super({
|
|
10
|
-
plugins: [
|
|
11
|
-
...plugins ?? [],
|
|
12
|
-
mswPlugin
|
|
13
|
-
],
|
|
14
|
-
...options
|
|
15
|
-
});
|
|
16
|
-
this.#mswPlugin = mswPlugin;
|
|
17
|
-
}
|
|
18
|
-
registerRequestHandlers(handlers) {
|
|
19
|
-
this.#mswPlugin.registerRequestHandlers(handlers);
|
|
20
|
-
}
|
|
21
|
-
get requestHandlers() {
|
|
22
|
-
return this.#mswPlugin.requestHandlers;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { FireflyRuntime };
|
package/dist/chunk-YPB7BNRJ.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { useLogOnceLogger, isNil } from '@squide/core';
|
|
2
|
-
import { useIsMswStarted } from '@squide/msw';
|
|
3
|
-
import { useRouteMatch, useIsRouteProtected, useRoutes, findRouteByPath } from '@squide/react-router';
|
|
4
|
-
import { useAreModulesRegistered, useAreModulesReady } from '@squide/webpack-module-federation';
|
|
5
|
-
import { useEffect, useCallback, cloneElement, useMemo } from 'react';
|
|
6
|
-
import { ErrorBoundary, useErrorBoundary } from 'react-error-boundary';
|
|
7
|
-
import { useLocation, Outlet } from 'react-router-dom';
|
|
8
|
-
import { jsx } from 'react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
// src/AppRouter.tsx
|
|
11
|
-
function useLoadPublicData(areModulesRegistered, areModulesReady, isMswStarted, isLoaded, onLoadData) {
|
|
12
|
-
const logger = useLogOnceLogger();
|
|
13
|
-
const { showBoundary } = useErrorBoundary();
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (onLoadData && !isLoaded) {
|
|
16
|
-
if ((areModulesRegistered || areModulesReady) && isMswStarted) {
|
|
17
|
-
logger.debugOnce("loading-public-data", "[shell] Loading public data.");
|
|
18
|
-
const abortController = new AbortController();
|
|
19
|
-
const signal = abortController.signal;
|
|
20
|
-
const result = onLoadData(signal);
|
|
21
|
-
if (!isPromise(result)) {
|
|
22
|
-
throw Error("[squide] An AppRouter onLoadPublicData handler must return a promise object.");
|
|
23
|
-
}
|
|
24
|
-
result.then(() => {
|
|
25
|
-
logger.debugOnce("public-data-loaded", "[shell] Public data has been loaded.");
|
|
26
|
-
}).catch((error) => {
|
|
27
|
-
if (!signal.aborted) {
|
|
28
|
-
showBoundary(error);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return () => {
|
|
32
|
-
abortController.abort();
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}, [areModulesRegistered, areModulesReady, isMswStarted, isLoaded, showBoundary, onLoadData, logger]);
|
|
37
|
-
}
|
|
38
|
-
function useLoadProtectedData(areModulesRegistered, areModulesReady, isMswStarted, isActiveRouteProtected, isLoaded, onLoadData) {
|
|
39
|
-
const logger = useLogOnceLogger();
|
|
40
|
-
const { showBoundary } = useErrorBoundary();
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (onLoadData && !isLoaded) {
|
|
43
|
-
if ((areModulesRegistered || areModulesReady) && isMswStarted) {
|
|
44
|
-
if (isActiveRouteProtected) {
|
|
45
|
-
logger.debugOnce("loading-protected-data", `[shell] Loading protected data as "${location.pathname}" is a protected route.`);
|
|
46
|
-
const abortController = new AbortController();
|
|
47
|
-
const signal = abortController.signal;
|
|
48
|
-
const result = onLoadData(signal);
|
|
49
|
-
if (!isPromise(result)) {
|
|
50
|
-
throw Error("[squide] An AppRouter onLoadProtectedData handler must return a promise object.");
|
|
51
|
-
}
|
|
52
|
-
result.then(() => {
|
|
53
|
-
logger.debugOnce("protected-data-loaded", "[shell] Protected data has been loaded.");
|
|
54
|
-
}).catch((error) => {
|
|
55
|
-
if (!signal.aborted) {
|
|
56
|
-
showBoundary(error);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return () => {
|
|
60
|
-
abortController.abort();
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
logger.debugOnce("is-a-public-route", `[shell] Not loading protected data as "${location.pathname}" is a public route.`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, [areModulesRegistered, areModulesReady, isMswStarted, isActiveRouteProtected, isLoaded, showBoundary, onLoadData, logger]);
|
|
68
|
-
}
|
|
69
|
-
function isPromise(value) {
|
|
70
|
-
return !isNil(value) && !isNil(value.then) && !isNil(value.catch);
|
|
71
|
-
}
|
|
72
|
-
function BootstrappingRoute(props) {
|
|
73
|
-
const {
|
|
74
|
-
fallbackElement,
|
|
75
|
-
onLoadPublicData,
|
|
76
|
-
onLoadProtectedData,
|
|
77
|
-
isPublicDataLoaded,
|
|
78
|
-
isProtectedDataLoaded,
|
|
79
|
-
onCompleteRegistrations,
|
|
80
|
-
waitForMsw,
|
|
81
|
-
areModulesRegistered,
|
|
82
|
-
areModulesReady
|
|
83
|
-
} = props;
|
|
84
|
-
const logger = useLogOnceLogger();
|
|
85
|
-
const location2 = useLocation();
|
|
86
|
-
const isMswStarted = useIsMswStarted(waitForMsw);
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
if (waitForMsw) {
|
|
89
|
-
if ((areModulesRegistered || areModulesReady) && !isMswStarted) {
|
|
90
|
-
logger.debugOnce("waiting-for-msw", `[shell] Modules are ${areModulesReady ? "ready" : "registered"}, waiting for MSW to start...`);
|
|
91
|
-
} else if (!areModulesRegistered && !areModulesReady && isMswStarted) {
|
|
92
|
-
logger.debugOnce("waiting-for-modules", "[shell] MSW is started, waiting for the modules...");
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, [logger, areModulesRegistered, areModulesReady, isMswStarted, waitForMsw]);
|
|
96
|
-
useLoadPublicData(areModulesRegistered, areModulesReady, isMswStarted, isPublicDataLoaded, onLoadPublicData);
|
|
97
|
-
const activeRoute = useRouteMatch(location2, { throwWhenThereIsNoMatch: areModulesReady });
|
|
98
|
-
const isActiveRouteProtected = useIsRouteProtected(activeRoute);
|
|
99
|
-
useLoadProtectedData(areModulesRegistered, areModulesReady, isMswStarted, isActiveRouteProtected, isProtectedDataLoaded, onLoadProtectedData);
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (onCompleteRegistrations) {
|
|
102
|
-
if (areModulesRegistered && isMswStarted && isPublicDataLoaded && (!isActiveRouteProtected || isProtectedDataLoaded)) {
|
|
103
|
-
if (!areModulesReady) {
|
|
104
|
-
onCompleteRegistrations();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, [areModulesRegistered, areModulesReady, isMswStarted, isPublicDataLoaded, isProtectedDataLoaded, isActiveRouteProtected, onCompleteRegistrations]);
|
|
109
|
-
if (!areModulesReady || !isMswStarted || !activeRoute || !isPublicDataLoaded || isActiveRouteProtected && !isProtectedDataLoaded) {
|
|
110
|
-
return fallbackElement;
|
|
111
|
-
}
|
|
112
|
-
return /* @__PURE__ */ jsx(Outlet, {});
|
|
113
|
-
}
|
|
114
|
-
function AppRouter(props) {
|
|
115
|
-
const {
|
|
116
|
-
fallbackElement,
|
|
117
|
-
errorElement,
|
|
118
|
-
onLoadPublicData,
|
|
119
|
-
onLoadProtectedData,
|
|
120
|
-
isPublicDataLoaded = true,
|
|
121
|
-
isProtectedDataLoaded = true,
|
|
122
|
-
onCompleteRegistrations,
|
|
123
|
-
waitForMsw,
|
|
124
|
-
children: renderRouterProvider
|
|
125
|
-
} = props;
|
|
126
|
-
const areModulesRegistered = useAreModulesRegistered();
|
|
127
|
-
const areModulesReady = useAreModulesReady();
|
|
128
|
-
const routes = useRoutes();
|
|
129
|
-
const errorRenderer = useCallback(({ error }) => {
|
|
130
|
-
return cloneElement(errorElement, {
|
|
131
|
-
error
|
|
132
|
-
});
|
|
133
|
-
}, [errorElement]);
|
|
134
|
-
return useMemo(() => {
|
|
135
|
-
if (areModulesRegistered && !findRouteByPath(routes, "*")) {
|
|
136
|
-
throw new Error("[squide] For the AppRouter component to work properly, the application must be a define a custom no match router. For additional information, refer to: https://reactrouter.com/en/main/start/tutorial#handling-not-found-errors.");
|
|
137
|
-
}
|
|
138
|
-
return renderRouterProvider([
|
|
139
|
-
{
|
|
140
|
-
element: /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: errorRenderer, children: /* @__PURE__ */ jsx(
|
|
141
|
-
BootstrappingRoute,
|
|
142
|
-
{
|
|
143
|
-
fallbackElement,
|
|
144
|
-
onLoadPublicData,
|
|
145
|
-
onLoadProtectedData,
|
|
146
|
-
isPublicDataLoaded,
|
|
147
|
-
isProtectedDataLoaded,
|
|
148
|
-
onCompleteRegistrations,
|
|
149
|
-
waitForMsw,
|
|
150
|
-
areModulesRegistered,
|
|
151
|
-
areModulesReady
|
|
152
|
-
}
|
|
153
|
-
) }),
|
|
154
|
-
children: routes
|
|
155
|
-
}
|
|
156
|
-
], {});
|
|
157
|
-
}, [areModulesRegistered, areModulesReady, routes, onLoadPublicData, onLoadProtectedData, isPublicDataLoaded, isProtectedDataLoaded, onCompleteRegistrations, waitForMsw, errorRenderer, fallbackElement, renderRouterProvider]);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export { AppRouter, BootstrappingRoute };
|
package/dist/fireflyRuntime.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { RuntimeOptions } from '@squide/core';
|
|
2
|
-
import { ReactRouterRuntime } from '@squide/react-router';
|
|
3
|
-
import { RequestHandler } from 'msw';
|
|
4
|
-
|
|
5
|
-
type FireflyRuntimeOptions = RuntimeOptions;
|
|
6
|
-
declare class FireflyRuntime extends ReactRouterRuntime {
|
|
7
|
-
#private;
|
|
8
|
-
constructor({ plugins, ...options }?: FireflyRuntimeOptions);
|
|
9
|
-
registerRequestHandlers(handlers: RequestHandler[]): void;
|
|
10
|
-
get requestHandlers(): RequestHandler[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { FireflyRuntime, type FireflyRuntimeOptions };
|
package/dist/fireflyRuntime.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { FireflyRuntime } from './chunk-JRNDLQBI.js';
|