@squide/firefly 9.3.1 → 9.3.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 +7 -0
- package/dist/AppRouter.d.ts +8 -12
- package/dist/AppRouter.js +66 -8
- package/dist/AppRouterContext.d.ts +5 -9
- package/dist/AppRouterContext.js +28 -1
- package/dist/AppRouterReducer.d.ts +23 -26
- package/dist/AppRouterReducer.js +337 -4
- package/dist/FireflyRuntime.d.ts +5 -8
- package/dist/FireflyRuntime.js +64 -5
- package/dist/GlobalDataQueriesError.d.ts +2 -4
- package/dist/GlobalDataQueriesError.js +17 -1
- package/dist/RootRoute.d.ts +1 -5
- package/dist/RootRoute.js +46 -3
- package/dist/boostrap.d.ts +8 -13
- package/dist/boostrap.js +52 -1
- package/dist/index.d.ts +23 -28
- package/dist/index.js +49 -25
- package/dist/useCanFetchProtectedData.d.ts +1 -3
- package/dist/useCanFetchProtectedData.js +15 -2
- package/dist/useCanFetchPublicData.d.ts +1 -3
- package/dist/useCanFetchPublicData.js +15 -2
- package/dist/useCanRegisterDeferredRegistrations.d.ts +1 -3
- package/dist/useCanRegisterDeferredRegistrations.js +12 -2
- package/dist/useCanUpdateDeferredRegistrations.d.ts +1 -3
- package/dist/useCanUpdateDeferredRegistrations.js +14 -2
- package/dist/useDeferredRegistrations.d.ts +5 -8
- package/dist/useDeferredRegistrations.js +72 -6
- package/dist/useExecuteOnce.d.ts +1 -3
- package/dist/useExecuteOnce.js +27 -1
- package/dist/useIsActiveRouteProtected.d.ts +1 -3
- package/dist/useIsActiveRouteProtected.js +21 -1
- package/dist/useIsBootstrapping.d.ts +3 -7
- package/dist/useIsBootstrapping.js +20 -2
- package/dist/useNavigationItems.d.ts +3 -7
- package/dist/useNavigationItems.js +24 -2
- package/dist/useProtectedDataQueries.d.ts +6 -8
- package/dist/useProtectedDataQueries.js +124 -5
- package/dist/usePublicDataQueries.d.ts +5 -7
- package/dist/usePublicDataQueries.js +109 -5
- package/dist/useRegisterDeferredRegistrations.d.ts +4 -9
- package/dist/useRegisterDeferredRegistrations.js +17 -1
- package/dist/useStrictRegistrationMode.d.ts +1 -3
- package/dist/useStrictRegistrationMode.js +38 -1
- package/dist/useUpdateDeferredRegistrations.d.ts +4 -9
- package/dist/useUpdateDeferredRegistrations.js +28 -2
- package/package.json +25 -22
- package/dist/chunk-4RUCDAUT.js +0 -18
- package/dist/chunk-BFHHJOJT.js +0 -41
- package/dist/chunk-CTLPFYLM.js +0 -65
- package/dist/chunk-G32YX2KR.js +0 -22
- package/dist/chunk-GXSW4CZS.js +0 -9
- package/dist/chunk-H2ILEMPE.js +0 -28
- package/dist/chunk-HE5HKFL3.js +0 -16
- package/dist/chunk-IOMSOUAL.js +0 -20
- package/dist/chunk-JFMSLZ74.js +0 -253
- package/dist/chunk-L44KFU57.js +0 -34
- package/dist/chunk-LC233OPR.js +0 -54
- package/dist/chunk-MKTGJHQR.js +0 -71
- package/dist/chunk-N2GOIQ5E.js +0 -14
- package/dist/chunk-PMVN3U47.js +0 -21
- package/dist/chunk-PP3MRMJJ.js +0 -11
- package/dist/chunk-ROE2YHN5.js +0 -44
- package/dist/chunk-TURKCH7J.js +0 -20
- package/dist/chunk-WOPD33CM.js +0 -25
- package/dist/chunk-WVRMJZV6.js +0 -18
- package/dist/chunk-XDWYPVAJ.js +0 -21
- package/dist/chunk-YRWFYWK4.js +0 -11
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
declare class GlobalDataQueriesError extends Error {
|
|
1
|
+
export declare class GlobalDataQueriesError extends Error {
|
|
2
2
|
#private;
|
|
3
3
|
constructor(message: string, errors: Error[]);
|
|
4
4
|
get errors(): Error[];
|
|
5
5
|
}
|
|
6
|
-
declare function isGlobalDataQueriesError(error?: unknown): error is GlobalDataQueriesError;
|
|
7
|
-
|
|
8
|
-
export { GlobalDataQueriesError, isGlobalDataQueriesError };
|
|
6
|
+
export declare function isGlobalDataQueriesError(error?: unknown): error is GlobalDataQueriesError;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
;// CONCATENATED MODULE: ./src/GlobalDataQueriesError.ts?__rslib_entry__
|
|
3
|
+
class GlobalDataQueriesError extends Error {
|
|
4
|
+
#errors;
|
|
5
|
+
constructor(message, errors){
|
|
6
|
+
super(message);
|
|
7
|
+
this.#errors = errors;
|
|
8
|
+
}
|
|
9
|
+
get errors() {
|
|
10
|
+
return this.#errors;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function isGlobalDataQueriesError(error) {
|
|
14
|
+
return error !== undefined && error !== null && error instanceof GlobalDataQueriesError;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { GlobalDataQueriesError, isGlobalDataQueriesError };
|
package/dist/RootRoute.d.ts
CHANGED
package/dist/RootRoute.js
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom__ from "react-router-dom";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useIsActiveRouteProtected_js__ from "./useIsActiveRouteProtected.js";
|
|
6
|
+
|
|
7
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "react"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: external "react-router-dom"
|
|
12
|
+
|
|
13
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
14
|
+
|
|
15
|
+
;// CONCATENATED MODULE: external "./useIsActiveRouteProtected.js"
|
|
16
|
+
|
|
17
|
+
;// CONCATENATED MODULE: ./src/RootRoute.tsx?__rslib_entry__
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function RootRoute() {
|
|
24
|
+
const state = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterState)();
|
|
25
|
+
const isActiveRouteProtected = (0,__WEBPACK_EXTERNAL_MODULE__useIsActiveRouteProtected_js__.useIsActiveRouteProtected)(state.areModulesReady);
|
|
26
|
+
const dispatch = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterDispatcher)();
|
|
27
|
+
(0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
28
|
+
// Dispatching the active route visibility must be done in a route because React Router's useLocation
|
|
29
|
+
// hook throws if it's not called from a child of the router component.
|
|
30
|
+
if (isActiveRouteProtected) {
|
|
31
|
+
dispatch({
|
|
32
|
+
type: "active-route-is-protected"
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
dispatch({
|
|
36
|
+
type: "active-route-is-public"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, [
|
|
40
|
+
isActiveRouteProtected,
|
|
41
|
+
dispatch
|
|
42
|
+
]);
|
|
43
|
+
return /*#__PURE__*/ (0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_router_dom__.Outlet, {});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { RootRoute };
|
package/dist/boostrap.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RemoteDefinition, RemoteModuleRegistrationError } from
|
|
3
|
-
import { FireflyRuntime } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
declare const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
8
|
-
type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;
|
|
9
|
-
interface BootstrapAppOptions<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext> {
|
|
1
|
+
import { type ModuleRegisterFunction, type ModuleRegistrationError, type RegisterModulesOptions } from "@squide/core";
|
|
2
|
+
import { type RemoteDefinition, type RemoteModuleRegistrationError } from "@squide/module-federation";
|
|
3
|
+
import type { FireflyRuntime } from "./FireflyRuntime.tsx";
|
|
4
|
+
export declare const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
5
|
+
export type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;
|
|
6
|
+
export interface BootstrapAppOptions<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext> {
|
|
10
7
|
localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];
|
|
11
8
|
remotes?: RemoteDefinition[];
|
|
12
9
|
startMsw?: StartMswFunction<TRuntime>;
|
|
13
10
|
}
|
|
14
|
-
declare function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options?: BootstrapAppOptions<TRuntime, TContext, TData>): Promise<{
|
|
11
|
+
export declare function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(runtime: TRuntime, options?: BootstrapAppOptions<TRuntime, TContext, TData>): Promise<{
|
|
15
12
|
localModuleErrors: ModuleRegistrationError[];
|
|
16
13
|
remoteModuleErrors: RemoteModuleRegistrationError[];
|
|
17
14
|
}>;
|
|
18
|
-
declare function __resetBootstrapGuard(): void;
|
|
19
|
-
|
|
20
|
-
export { ApplicationBootstrappingStartedEvent, type BootstrapAppOptions, type StartMswFunction, __resetBootstrapGuard, bootstrap };
|
|
15
|
+
export declare function __resetBootstrapGuard(): void;
|
package/dist/boostrap.js
CHANGED
|
@@ -1 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_core__ from "@squide/core";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_module_federation__ from "@squide/module-federation";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_msw__ from "@squide/msw";
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: external "@squide/core"
|
|
6
|
+
|
|
7
|
+
;// CONCATENATED MODULE: external "@squide/module-federation"
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "@squide/msw"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: ./src/boostrap.ts?__rslib_entry__
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
16
|
+
let isBootstrapped = false;
|
|
17
|
+
async function bootstrap(runtime, options = {}) {
|
|
18
|
+
const { localModules = [], remotes = [], context, startMsw } = options;
|
|
19
|
+
if (isBootstrapped) {
|
|
20
|
+
throw new Error("[squide] A squide application can only be bootstrapped once. Did you call the \"bootstrap\" function twice?");
|
|
21
|
+
}
|
|
22
|
+
runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);
|
|
23
|
+
let localModuleErrors = [];
|
|
24
|
+
let remoteModuleErrors = [];
|
|
25
|
+
localModuleErrors = await (0,__WEBPACK_EXTERNAL_MODULE__squide_core__.registerLocalModules)(localModules, runtime, {
|
|
26
|
+
context
|
|
27
|
+
});
|
|
28
|
+
remoteModuleErrors = await (0,__WEBPACK_EXTERNAL_MODULE__squide_module_federation__.registerRemoteModules)(remotes, runtime, {
|
|
29
|
+
context
|
|
30
|
+
});
|
|
31
|
+
if (runtime.isMswEnabled) {
|
|
32
|
+
if (!(0,__WEBPACK_EXTERNAL_MODULE__squide_core__.isFunction)(startMsw)) {
|
|
33
|
+
throw new Error("[squide] When MSW is enabled, the \"startMsw\" function must be provided.");
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await startMsw(runtime);
|
|
37
|
+
(0,__WEBPACK_EXTERNAL_MODULE__squide_msw__.setMswAsReady)();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
runtime.logger.debug("[squide] An error occured while starting MSW.", error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
isBootstrapped = true;
|
|
43
|
+
return {
|
|
44
|
+
localModuleErrors,
|
|
45
|
+
remoteModuleErrors
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function __resetBootstrapGuard() {
|
|
49
|
+
isBootstrapped = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { ApplicationBootstrappingStartedEvent, __resetBootstrapGuard, bootstrap };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
import 'msw';
|
|
25
|
-
import 'react/jsx-runtime';
|
|
26
|
-
import 'react';
|
|
27
|
-
import 'react-router-dom';
|
|
28
|
-
import '@tanstack/react-query';
|
|
1
|
+
export * from "@squide/core";
|
|
2
|
+
export * from "@squide/module-federation";
|
|
3
|
+
export * from "@squide/msw";
|
|
4
|
+
export * from "@squide/react-router";
|
|
5
|
+
export * from "./FireflyRuntime.tsx";
|
|
6
|
+
export * from "./AppRouter.tsx";
|
|
7
|
+
export * from "./AppRouterContext.ts";
|
|
8
|
+
export * from "./AppRouterReducer.ts";
|
|
9
|
+
export * from "./GlobalDataQueriesError.ts";
|
|
10
|
+
export * from "./useCanFetchProtectedData.ts";
|
|
11
|
+
export * from "./useCanFetchPublicData.ts";
|
|
12
|
+
export * from "./useCanRegisterDeferredRegistrations.ts";
|
|
13
|
+
export * from "./useCanUpdateDeferredRegistrations.ts";
|
|
14
|
+
export * from "./useDeferredRegistrations.ts";
|
|
15
|
+
export * from "./useIsActiveRouteProtected.ts";
|
|
16
|
+
export * from "./useIsBootstrapping.ts";
|
|
17
|
+
export * from "./useNavigationItems.ts";
|
|
18
|
+
export * from "./useProtectedDataQueries.ts";
|
|
19
|
+
export * from "./usePublicDataQueries.ts";
|
|
20
|
+
export * from "./useRegisterDeferredRegistrations.ts";
|
|
21
|
+
export * from "./useStrictRegistrationMode.ts";
|
|
22
|
+
export * from "./useUpdateDeferredRegistrations.ts";
|
|
23
|
+
export * from "./boostrap.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,49 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
export * from "@squide/core";
|
|
2
|
+
export * from "@squide/module-federation";
|
|
3
|
+
export * from "@squide/msw";
|
|
4
|
+
export * from "@squide/react-router";
|
|
5
|
+
export * from "./FireflyRuntime.js";
|
|
6
|
+
export * from "./AppRouter.js";
|
|
7
|
+
export * from "./AppRouterContext.js";
|
|
8
|
+
export * from "./AppRouterReducer.js";
|
|
9
|
+
export * from "./GlobalDataQueriesError.js";
|
|
10
|
+
export * from "./useCanFetchProtectedData.js";
|
|
11
|
+
export * from "./useCanFetchPublicData.js";
|
|
12
|
+
export * from "./useCanRegisterDeferredRegistrations.js";
|
|
13
|
+
export * from "./useCanUpdateDeferredRegistrations.js";
|
|
14
|
+
export * from "./useDeferredRegistrations.js";
|
|
15
|
+
export * from "./useIsActiveRouteProtected.js";
|
|
16
|
+
export * from "./useIsBootstrapping.js";
|
|
17
|
+
export * from "./useNavigationItems.js";
|
|
18
|
+
export * from "./useProtectedDataQueries.js";
|
|
19
|
+
export * from "./usePublicDataQueries.js";
|
|
20
|
+
export * from "./useRegisterDeferredRegistrations.js";
|
|
21
|
+
export * from "./useStrictRegistrationMode.js";
|
|
22
|
+
export * from "./useUpdateDeferredRegistrations.js";
|
|
23
|
+
export * from "./boostrap.js";
|
|
24
|
+
|
|
25
|
+
;// CONCATENATED MODULE: ./src/index.ts?__rslib_entry__
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useCanFetchProtectedData.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
function useCanFetchProtectedData() {
|
|
8
|
+
const { waitForMsw, areModulesRegistered, areModulesReady, isMswReady, isProtectedDataReady, activeRouteVisibility } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterState)();
|
|
9
|
+
return(// Always return true when the protected data has already been fetched sucessfully so TanStack Query can update the data in the background.
|
|
10
|
+
isProtectedDataReady || // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered as they will probably
|
|
11
|
+
// depends on the protected data.
|
|
12
|
+
(areModulesRegistered || areModulesReady) && activeRouteVisibility === "protected" && (!waitForMsw || isMswReady));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useCanFetchProtectedData };
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useCanFetchPublicData.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
function useCanFetchPublicData() {
|
|
8
|
+
const { waitForMsw, areModulesRegistered, areModulesReady, isMswReady, isPublicDataReady } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterState)();
|
|
9
|
+
return(// Always return true when the public data has already been fetched sucessfully so TanStack Query can update the data in the background.
|
|
10
|
+
isPublicDataReady || // Wait until the modules has been registered, but do not wait for the deferred registrations to be registered has they will probably
|
|
11
|
+
// depends on the protected data.
|
|
12
|
+
(areModulesRegistered || areModulesReady) && (!waitForMsw || isMswReady));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useCanFetchPublicData };
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useCanRegisterDeferredRegistrations.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
function useCanRegisterDeferredRegistrations() {
|
|
8
|
+
const { waitForPublicData, waitForProtectedData, areModulesReady, areModulesRegistered, isPublicDataReady, isProtectedDataReady, activeRouteVisibility, isUnauthorized } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterState)();
|
|
9
|
+
return !isUnauthorized && areModulesRegistered && !areModulesReady && (!waitForPublicData || isPublicDataReady) && (!waitForProtectedData || activeRouteVisibility === "public" || isProtectedDataReady);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { useCanRegisterDeferredRegistrations };
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useCanUpdateDeferredRegistrations.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
function useCanUpdateDeferredRegistrations() {
|
|
8
|
+
const { areModulesReady, publicDataUpdatedAt, protectedDataUpdatedAt, deferredRegistrationsUpdatedAt } = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterState)();
|
|
9
|
+
return(// Do not trigger an update if the deferred registrations has not been registered yet (if there are deferred registrations, once they are
|
|
10
|
+
// registered, the modules will be marked as ready).
|
|
11
|
+
areModulesReady && deferredRegistrationsUpdatedAt && (publicDataUpdatedAt && publicDataUpdatedAt > deferredRegistrationsUpdatedAt || protectedDataUpdatedAt && protectedDataUpdatedAt > deferredRegistrationsUpdatedAt));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { useCanUpdateDeferredRegistrations };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { ModuleRegistrationError } from
|
|
2
|
-
|
|
3
|
-
interface DeferredRegistrationsErrorsObject {
|
|
1
|
+
import { type ModuleRegistrationError } from "@squide/core";
|
|
2
|
+
export interface DeferredRegistrationsErrorsObject {
|
|
4
3
|
localModuleErrors: ModuleRegistrationError[];
|
|
5
4
|
remoteModuleErrors: ModuleRegistrationError[];
|
|
6
5
|
}
|
|
7
|
-
type DeferredRegistrationsErrorCallback = (errorsObject: DeferredRegistrationsErrorsObject) => void;
|
|
8
|
-
interface UseDeferredRegistrationsOptions {
|
|
6
|
+
export type DeferredRegistrationsErrorCallback = (errorsObject: DeferredRegistrationsErrorsObject) => void;
|
|
7
|
+
export interface UseDeferredRegistrationsOptions {
|
|
9
8
|
onError?: DeferredRegistrationsErrorCallback;
|
|
10
9
|
}
|
|
11
|
-
declare function useDeferredRegistrations(data: unknown, { onError }?: UseDeferredRegistrationsOptions): void;
|
|
12
|
-
|
|
13
|
-
export { type DeferredRegistrationsErrorCallback, type DeferredRegistrationsErrorsObject, type UseDeferredRegistrationsOptions, useDeferredRegistrations };
|
|
10
|
+
export declare function useDeferredRegistrations(data: unknown, { onError }?: UseDeferredRegistrationsOptions): void;
|
|
@@ -1,6 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_core__ from "@squide/core";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useCanRegisterDeferredRegistrations_js__ from "./useCanRegisterDeferredRegistrations.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useCanUpdateDeferredRegistrations_js__ from "./useCanUpdateDeferredRegistrations.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useRegisterDeferredRegistrations_js__ from "./useRegisterDeferredRegistrations.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useUpdateDeferredRegistrations_js__ from "./useUpdateDeferredRegistrations.js";
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "@squide/core"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: external "react"
|
|
11
|
+
|
|
12
|
+
;// CONCATENATED MODULE: external "./useCanRegisterDeferredRegistrations.js"
|
|
13
|
+
|
|
14
|
+
;// CONCATENATED MODULE: external "./useCanUpdateDeferredRegistrations.js"
|
|
15
|
+
|
|
16
|
+
;// CONCATENATED MODULE: external "./useRegisterDeferredRegistrations.js"
|
|
17
|
+
|
|
18
|
+
;// CONCATENATED MODULE: external "./useUpdateDeferredRegistrations.js"
|
|
19
|
+
|
|
20
|
+
;// CONCATENATED MODULE: ./src/useDeferredRegistrations.ts?__rslib_entry__
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
function hasError({ localModuleErrors, remoteModuleErrors }) {
|
|
28
|
+
return localModuleErrors.length > 0 || remoteModuleErrors.length > 0;
|
|
29
|
+
}
|
|
30
|
+
function useDeferredRegistrations(data, { onError } = {}) {
|
|
31
|
+
const runtime = (0,__WEBPACK_EXTERNAL_MODULE__squide_core__.useRuntime)();
|
|
32
|
+
const canRegisterDeferredRegistrations = (0,__WEBPACK_EXTERNAL_MODULE__useCanRegisterDeferredRegistrations_js__.useCanRegisterDeferredRegistrations)();
|
|
33
|
+
const canUpdateDeferredRegistrations = (0,__WEBPACK_EXTERNAL_MODULE__useCanUpdateDeferredRegistrations_js__.useCanUpdateDeferredRegistrations)();
|
|
34
|
+
const registerDeferredRegistrations = (0,__WEBPACK_EXTERNAL_MODULE__useRegisterDeferredRegistrations_js__.useRegisterDeferredRegistrations)();
|
|
35
|
+
const updateDeferredRegistrations = (0,__WEBPACK_EXTERNAL_MODULE__useUpdateDeferredRegistrations_js__.useUpdateDeferredRegistrations)();
|
|
36
|
+
(0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
37
|
+
if (canRegisterDeferredRegistrations) {
|
|
38
|
+
const register = async ()=>{
|
|
39
|
+
const errors = await registerDeferredRegistrations(data, runtime);
|
|
40
|
+
if (hasError(errors) && onError) {
|
|
41
|
+
onError(errors);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
register();
|
|
45
|
+
}
|
|
46
|
+
}, [
|
|
47
|
+
canRegisterDeferredRegistrations,
|
|
48
|
+
registerDeferredRegistrations,
|
|
49
|
+
data,
|
|
50
|
+
onError,
|
|
51
|
+
runtime
|
|
52
|
+
]);
|
|
53
|
+
(0,__WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
54
|
+
if (canUpdateDeferredRegistrations) {
|
|
55
|
+
const update = async ()=>{
|
|
56
|
+
const errors = await updateDeferredRegistrations(data, runtime);
|
|
57
|
+
if (hasError(errors) && onError) {
|
|
58
|
+
onError(errors);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
update();
|
|
62
|
+
}
|
|
63
|
+
}, [
|
|
64
|
+
canUpdateDeferredRegistrations,
|
|
65
|
+
updateDeferredRegistrations,
|
|
66
|
+
data,
|
|
67
|
+
onError,
|
|
68
|
+
runtime
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { useDeferredRegistrations };
|
package/dist/useExecuteOnce.d.ts
CHANGED
package/dist/useExecuteOnce.js
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "react"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useExecuteOnce.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
// Not using useEffect or useLayoutEffect because this utility hook is often used to dispatch events
|
|
8
|
+
// and it messed with the events dispatch order.
|
|
9
|
+
function useExecuteOnce(fct, inline = false) {
|
|
10
|
+
const triggered = (0,__WEBPACK_EXTERNAL_MODULE_react__.useRef)(false);
|
|
11
|
+
const onceFct = (0,__WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
12
|
+
if (!triggered.current) {
|
|
13
|
+
const result = fct();
|
|
14
|
+
if (result) {
|
|
15
|
+
triggered.current = true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}, [
|
|
19
|
+
fct
|
|
20
|
+
]);
|
|
21
|
+
if (inline) {
|
|
22
|
+
onceFct();
|
|
23
|
+
}
|
|
24
|
+
return onceFct;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useExecuteOnce };
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_react_router__ from "@squide/react-router";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom__ from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
;// CONCATENATED MODULE: external "@squide/react-router"
|
|
5
|
+
|
|
6
|
+
;// CONCATENATED MODULE: external "react-router-dom"
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: ./src/useIsActiveRouteProtected.ts?__rslib_entry__
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function useIsActiveRouteProtected(areModulesReady) {
|
|
12
|
+
// Using this hook instead of window.location to retrieve the current location because it triggers a re-render everytime the browser location change.
|
|
13
|
+
const location = (0,__WEBPACK_EXTERNAL_MODULE_react_router_dom__.useLocation)();
|
|
14
|
+
// 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
|
+
const activeRoute = (0,__WEBPACK_EXTERNAL_MODULE__squide_react_router__.useRouteMatch)(location, {
|
|
16
|
+
throwWhenThereIsNoMatch: areModulesReady
|
|
17
|
+
});
|
|
18
|
+
return (0,__WEBPACK_EXTERNAL_MODULE__squide_react_router__.useIsRouteProtected)(activeRoute);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { useIsActiveRouteProtected };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { AppRouterState } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare function useIsBootstrapping(): boolean;
|
|
5
|
-
declare function isApplicationBootstrapping(state: AppRouterState): boolean;
|
|
6
|
-
|
|
7
|
-
export { isApplicationBootstrapping, useIsBootstrapping };
|
|
1
|
+
import type { AppRouterState } from "./AppRouterReducer.ts";
|
|
2
|
+
export declare function useIsBootstrapping(): boolean;
|
|
3
|
+
export declare function isApplicationBootstrapping(state: AppRouterState): boolean;
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__ from "./AppRouterContext.js";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "./AppRouterContext.js"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/useIsBootstrapping.ts?__rslib_entry__
|
|
6
|
+
|
|
7
|
+
function useIsBootstrapping() {
|
|
8
|
+
const state = (0,__WEBPACK_EXTERNAL_MODULE__AppRouterContext_js__.useAppRouterState)();
|
|
9
|
+
return isApplicationBootstrapping(state);
|
|
10
|
+
}
|
|
11
|
+
function isApplicationBootstrapping(state) {
|
|
12
|
+
const { waitForMsw, waitForPublicData, waitForProtectedData, areModulesReady, isMswReady, isPublicDataReady, isProtectedDataReady, activeRouteVisibility, isUnauthorized } = state;
|
|
13
|
+
const isAppReady = !isUnauthorized && areModulesReady && (!waitForMsw || isMswReady) && (!waitForPublicData || isPublicDataReady) && (!waitForProtectedData || activeRouteVisibility === "public" || isProtectedDataReady);
|
|
14
|
+
// When an API request returns a 401, the bootstrapping should be bypassed to render the login page.
|
|
15
|
+
const flush = // Only applicable when there's a unauthorized request while fetching the initial data.
|
|
16
|
+
isUnauthorized && (!waitForMsw || isMswReady) && (!waitForPublicData || isPublicDataReady);
|
|
17
|
+
return !isAppReady && !flush;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { isApplicationBootstrapping, useIsBootstrapping };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type UseNavigationItemsOptions = UseRuntimeNavigationItemsOptions;
|
|
5
|
-
declare function useNavigationItems(options?: UseNavigationItemsOptions): _squide_react_router.RootNavigationItem[];
|
|
6
|
-
|
|
7
|
-
export { type UseNavigationItemsOptions, useNavigationItems };
|
|
1
|
+
import { type UseRuntimeNavigationItemsOptions } from "@squide/react-router";
|
|
2
|
+
export type UseNavigationItemsOptions = UseRuntimeNavigationItemsOptions;
|
|
3
|
+
export declare function useNavigationItems(options?: UseNavigationItemsOptions): import("@squide/react-router").RootNavigationItem[];
|