@squide/firefly 13.0.0 → 13.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 +18 -0
- package/dist/AppRouter.js +17 -17
- package/dist/AppRouter.js.map +1 -1
- package/dist/AppRouterContext.js +8 -8
- package/dist/AppRouterContext.js.map +1 -1
- package/dist/AppRouterReducer.js +47 -47
- package/dist/AppRouterReducer.js.map +1 -1
- package/dist/FireflyProvider.js +3 -3
- package/dist/FireflyProvider.js.map +1 -1
- package/dist/FireflyRuntime.js +11 -11
- package/dist/FireflyRuntime.js.map +1 -1
- package/dist/RootRoute.js +10 -10
- package/dist/RootRoute.js.map +1 -1
- package/dist/honeycomb/activeSpan.js +6 -6
- package/dist/honeycomb/activeSpan.js.map +1 -1
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.d.ts +1 -0
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.js +11 -0
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.js.map +1 -0
- package/dist/honeycomb/initializeHoneycomb.d.ts +2 -0
- package/dist/honeycomb/initializeHoneycomb.js +25 -0
- package/dist/honeycomb/initializeHoneycomb.js.map +1 -0
- package/dist/honeycomb/registerHoneycombInstrumentation.d.ts +1 -2
- package/dist/honeycomb/registerHoneycombInstrumentation.js +104 -99
- package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
- package/dist/honeycomb/tracer.js +2 -2
- package/dist/honeycomb/tracer.js.map +1 -1
- package/dist/honeycomb/utils.js +12 -12
- package/dist/honeycomb/utils.js.map +1 -1
- package/dist/initializeFirefly.js +19 -18
- package/dist/initializeFirefly.js.map +1 -1
- package/dist/useAppRouterStore.js +2 -2
- package/dist/useAppRouterStore.js.map +1 -1
- package/dist/useCanFetchProtectedData.js +2 -2
- package/dist/useCanFetchProtectedData.js.map +1 -1
- package/dist/useCanFetchPublicData.js +2 -2
- package/dist/useCanFetchPublicData.js.map +1 -1
- package/dist/useCanRegisterDeferredRegistrations.js +2 -2
- package/dist/useCanRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useCanUpdateDeferredRegistrations.js +2 -2
- package/dist/useCanUpdateDeferredRegistrations.js.map +1 -1
- package/dist/useDeferredRegistrations.js +13 -13
- package/dist/useDeferredRegistrations.js.map +1 -1
- package/dist/useExecuteOnce.js +3 -3
- package/dist/useExecuteOnce.js.map +1 -1
- package/dist/useIsActiveRouteProtected.js +5 -5
- package/dist/useIsActiveRouteProtected.js.map +1 -1
- package/dist/useIsBootstrapping.js +2 -2
- package/dist/useIsBootstrapping.js.map +1 -1
- package/dist/useNavigationItems.js +4 -4
- package/dist/useNavigationItems.js.map +1 -1
- package/dist/useProtectedDataHandler.js +4 -4
- package/dist/useProtectedDataHandler.js.map +1 -1
- package/dist/useProtectedDataQueries.js +20 -20
- package/dist/useProtectedDataQueries.js.map +1 -1
- package/dist/usePublicDataHandler.js +4 -4
- package/dist/usePublicDataHandler.js.map +1 -1
- package/dist/usePublicDataQueries.js +19 -19
- package/dist/usePublicDataQueries.js.map +1 -1
- package/dist/useRegisterDeferredRegistrations.js +4 -4
- package/dist/useRegisterDeferredRegistrations.js.map +1 -1
- package/dist/useStrictRegistrationMode.js +12 -12
- package/dist/useStrictRegistrationMode.js.map +1 -1
- package/dist/useUpdateDeferredRegistrations.js +6 -6
- package/dist/useUpdateDeferredRegistrations.js.map +1 -1
- package/package.json +16 -21
- package/src/honeycomb/canRegisterHoneycombInstrumentation.ts +5 -0
- package/src/honeycomb/initializeHoneycomb.ts +22 -0
- package/src/honeycomb/registerHoneycombInstrumentation.ts +43 -50
- package/src/initializeFirefly.ts +12 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { useEventBus } from "@squide/core";
|
|
2
|
+
import { useQueries } from "@tanstack/react-query";
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { useAppRouterDispatcher, useAppRouterState } from "./AppRouterContext.js";
|
|
5
|
+
import { GlobalDataQueriesError } from "./GlobalDataQueriesError.js";
|
|
6
|
+
import { useCanFetchProtectedData } from "./useCanFetchProtectedData.js";
|
|
7
|
+
import { useExecuteOnce } from "./useExecuteOnce.js";
|
|
8
8
|
|
|
9
9
|
;// CONCATENATED MODULE: external "@squide/core"
|
|
10
10
|
|
|
@@ -32,10 +32,10 @@ const ProtectedDataFetchStartedEvent = "squide-protected-data-fetch-started";
|
|
|
32
32
|
const ProtectedDataFetchFailedEvent = "squide-protected-data-fetch-failed";
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
34
|
function useProtectedDataQueries(queries, isUnauthorizedError) {
|
|
35
|
-
const canFetchProtectedData =
|
|
36
|
-
const eventBus =
|
|
37
|
-
const dispatch =
|
|
38
|
-
const combineResults =
|
|
35
|
+
const canFetchProtectedData = useCanFetchProtectedData();
|
|
36
|
+
const eventBus = useEventBus();
|
|
37
|
+
const dispatch = useAppRouterDispatcher();
|
|
38
|
+
const combineResults = useCallback((results)=>{
|
|
39
39
|
const errors = results.filter((x)=>x.error).map((x)=>x.error);
|
|
40
40
|
const hasErrors = errors.length > 0;
|
|
41
41
|
return {
|
|
@@ -45,15 +45,15 @@ function useProtectedDataQueries(queries, isUnauthorizedError) {
|
|
|
45
45
|
isReady: !hasErrors && !results.some((x)=>x.isPending)
|
|
46
46
|
};
|
|
47
47
|
}, []);
|
|
48
|
-
const { data, errors: queriesErrors, hasErrors, isReady } =
|
|
48
|
+
const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({
|
|
49
49
|
queries: queries.map((x)=>({
|
|
50
50
|
enabled: canFetchProtectedData,
|
|
51
51
|
...x
|
|
52
52
|
})),
|
|
53
53
|
combine: combineResults
|
|
54
54
|
});
|
|
55
|
-
const { isProtectedDataReady, isUnauthorized } =
|
|
56
|
-
|
|
55
|
+
const { isProtectedDataReady, isUnauthorized } = useAppRouterState();
|
|
56
|
+
useExecuteOnce(useCallback(()=>{
|
|
57
57
|
if (canFetchProtectedData) {
|
|
58
58
|
eventBus.dispatch(ProtectedDataFetchStartedEvent);
|
|
59
59
|
return true;
|
|
@@ -64,8 +64,8 @@ function useProtectedDataQueries(queries, isUnauthorizedError) {
|
|
|
64
64
|
eventBus
|
|
65
65
|
]), true);
|
|
66
66
|
// Using a ref seems to be the only way to prevent starting two deferred registrations scope.
|
|
67
|
-
const isReadyRef =
|
|
68
|
-
const dispatchReady =
|
|
67
|
+
const isReadyRef = useRef(false);
|
|
68
|
+
const dispatchReady = useExecuteOnce(useCallback(()=>{
|
|
69
69
|
if (isReady) {
|
|
70
70
|
isReadyRef.current = true;
|
|
71
71
|
dispatch({
|
|
@@ -78,13 +78,13 @@ function useProtectedDataQueries(queries, isUnauthorizedError) {
|
|
|
78
78
|
isReady,
|
|
79
79
|
dispatch
|
|
80
80
|
]));
|
|
81
|
-
|
|
81
|
+
useEffect(()=>{
|
|
82
82
|
// State update must be executed in useEffect.
|
|
83
83
|
dispatchReady();
|
|
84
84
|
}, [
|
|
85
85
|
dispatchReady
|
|
86
86
|
]);
|
|
87
|
-
|
|
87
|
+
useEffect(()=>{
|
|
88
88
|
if (isReadyRef.current && data) {
|
|
89
89
|
dispatch({
|
|
90
90
|
type: "protected-data-updated"
|
|
@@ -94,7 +94,7 @@ function useProtectedDataQueries(queries, isUnauthorizedError) {
|
|
|
94
94
|
data,
|
|
95
95
|
dispatch
|
|
96
96
|
]);
|
|
97
|
-
|
|
97
|
+
useEffect(()=>{
|
|
98
98
|
if (hasErrors) {
|
|
99
99
|
if (!isProtectedDataReady && !isUnauthorized && queriesErrors.some((x)=>isUnauthorizedError(x))) {
|
|
100
100
|
// Will transition the state to allow the routes to render even if the bootstrapping is not complete, because otherwise
|
|
@@ -106,7 +106,7 @@ function useProtectedDataQueries(queries, isUnauthorizedError) {
|
|
|
106
106
|
// Otherwise, when a user is logged off, a refetch might throws a 401.
|
|
107
107
|
if (!queriesErrors.every((x)=>isUnauthorizedError(x))) {
|
|
108
108
|
eventBus.dispatch(ProtectedDataFetchFailedEvent, queriesErrors);
|
|
109
|
-
throw new
|
|
109
|
+
throw new GlobalDataQueriesError("[squide] Global protected data queries failed.", queriesErrors);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProtectedDataQueries.js","sources":["webpack://@squide/firefly/./src/useProtectedDataQueries.ts"],"sourcesContent":["import { useEventBus } from \"@squide/core\";\nimport { useQueries, type QueriesOptions, type QueriesResults, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { GlobalDataQueriesError } from \"./GlobalDataQueriesError.ts\";\nimport { useCanFetchProtectedData } from \"./useCanFetchProtectedData.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\n\nexport const ProtectedDataFetchStartedEvent = \"squide-protected-data-fetch-started\";\nexport const ProtectedDataFetchFailedEvent = \"squide-protected-data-fetch-failed\";\n\nexport type IsUnauthorizedErrorCallback = (error: unknown) => boolean;\n\n// This converts an array of UseQueryResult to an array of the data type of each query result.\n// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.\ntype MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useProtectedDataQueries<T extends Array<any>>(queries: QueriesOptions<T>, isUnauthorizedError: IsUnauthorizedErrorCallback): MapUseQueryResultToData<QueriesResults<T>> {\n const canFetchProtectedData = useCanFetchProtectedData();\n const eventBus = useEventBus();\n\n const dispatch = useAppRouterDispatcher();\n\n const combineResults = useCallback((results: UseQueryResult<unknown, unknown>[]) => {\n const errors = results.filter(x => x.error).map(x => x.error) as Error[];\n const hasErrors = errors.length > 0;\n\n return {\n data: results.map(x => x.data) as MapUseQueryResultToData<QueriesResults<T>>,\n errors,\n hasErrors,\n isReady: !hasErrors && !results.some(x => x.isPending)\n };\n }, []);\n\n const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({\n queries: queries.map(x => ({\n enabled: canFetchProtectedData,\n ...x\n })),\n combine: combineResults\n });\n\n const { isProtectedDataReady, isUnauthorized } = useAppRouterState();\n\n useExecuteOnce(useCallback(() => {\n if (canFetchProtectedData) {\n eventBus.dispatch(ProtectedDataFetchStartedEvent);\n\n return true;\n }\n\n return false;\n }, [canFetchProtectedData, eventBus]), true);\n\n // Using a ref seems to be the only way to prevent starting two deferred registrations scope.\n const isReadyRef = useRef(false);\n\n const dispatchReady = useExecuteOnce(useCallback(() => {\n if (isReady) {\n isReadyRef.current = true;\n\n dispatch({ type: \"protected-data-ready\" });\n\n return true;\n }\n\n return false;\n }, [isReady, dispatch]));\n\n useEffect(() => {\n // State update must be executed in useEffect.\n dispatchReady();\n }, [dispatchReady]);\n\n useEffect(() => {\n if (isReadyRef.current && data) {\n dispatch({ type: \"protected-data-updated\" });\n }\n }, [data, dispatch]);\n\n useEffect(() => {\n if (hasErrors) {\n if (!isProtectedDataReady && !isUnauthorized && queriesErrors.some(x => isUnauthorizedError(x))) {\n // Will transition the state to allow the routes to render even if the bootstrapping is not complete, because otherwise\n // a login page for example could not be rendered.\n dispatch({ type: \"is-unauthorized\" });\n }\n\n // Otherwise, when a user is logged off, a refetch might throws a 401.\n if (!queriesErrors.every(x => isUnauthorizedError(x))) {\n eventBus.dispatch(ProtectedDataFetchFailedEvent, queriesErrors);\n\n throw new GlobalDataQueriesError(\"[squide] Global protected data queries failed.\", queriesErrors);\n }\n }\n }, [hasErrors, queriesErrors, isProtectedDataReady, isUnauthorized, isUnauthorizedError, dispatch, eventBus]);\n\n return data;\n}\n"],"names":["useEventBus","useQueries","useCallback","useEffect","useRef","useAppRouterDispatcher","useAppRouterState","GlobalDataQueriesError","useCanFetchProtectedData","useExecuteOnce","ProtectedDataFetchStartedEvent","ProtectedDataFetchFailedEvent","useProtectedDataQueries","queries","isUnauthorizedError","canFetchProtectedData","eventBus","dispatch","combineResults","results","errors","x","hasErrors","data","queriesErrors","isReady","isProtectedDataReady","isUnauthorized","isReadyRef","dispatchReady"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA2C;AACuE;AAC3D;AAC2B;AACb;AACI;AACpB;AAE9C,MAAMU,iCAAiC,sCAAsC;AAC7E,MAAMC,gCAAgC,qCAAqC;AAQlF,8DAA8D;AACvD,SAASC,wBAA8CC,OAA0B,EAAEC,mBAAgD;IACtI,MAAMC,wBAAwBP,
|
|
1
|
+
{"version":3,"file":"useProtectedDataQueries.js","sources":["webpack://@squide/firefly/./src/useProtectedDataQueries.ts"],"sourcesContent":["import { useEventBus } from \"@squide/core\";\nimport { useQueries, type QueriesOptions, type QueriesResults, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { useAppRouterDispatcher, useAppRouterState } from \"./AppRouterContext.ts\";\nimport { GlobalDataQueriesError } from \"./GlobalDataQueriesError.ts\";\nimport { useCanFetchProtectedData } from \"./useCanFetchProtectedData.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\n\nexport const ProtectedDataFetchStartedEvent = \"squide-protected-data-fetch-started\";\nexport const ProtectedDataFetchFailedEvent = \"squide-protected-data-fetch-failed\";\n\nexport type IsUnauthorizedErrorCallback = (error: unknown) => boolean;\n\n// This converts an array of UseQueryResult to an array of the data type of each query result.\n// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.\ntype MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useProtectedDataQueries<T extends Array<any>>(queries: QueriesOptions<T>, isUnauthorizedError: IsUnauthorizedErrorCallback): MapUseQueryResultToData<QueriesResults<T>> {\n const canFetchProtectedData = useCanFetchProtectedData();\n const eventBus = useEventBus();\n\n const dispatch = useAppRouterDispatcher();\n\n const combineResults = useCallback((results: UseQueryResult<unknown, unknown>[]) => {\n const errors = results.filter(x => x.error).map(x => x.error) as Error[];\n const hasErrors = errors.length > 0;\n\n return {\n data: results.map(x => x.data) as MapUseQueryResultToData<QueriesResults<T>>,\n errors,\n hasErrors,\n isReady: !hasErrors && !results.some(x => x.isPending)\n };\n }, []);\n\n const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({\n queries: queries.map(x => ({\n enabled: canFetchProtectedData,\n ...x\n })),\n combine: combineResults\n });\n\n const { isProtectedDataReady, isUnauthorized } = useAppRouterState();\n\n useExecuteOnce(useCallback(() => {\n if (canFetchProtectedData) {\n eventBus.dispatch(ProtectedDataFetchStartedEvent);\n\n return true;\n }\n\n return false;\n }, [canFetchProtectedData, eventBus]), true);\n\n // Using a ref seems to be the only way to prevent starting two deferred registrations scope.\n const isReadyRef = useRef(false);\n\n const dispatchReady = useExecuteOnce(useCallback(() => {\n if (isReady) {\n isReadyRef.current = true;\n\n dispatch({ type: \"protected-data-ready\" });\n\n return true;\n }\n\n return false;\n }, [isReady, dispatch]));\n\n useEffect(() => {\n // State update must be executed in useEffect.\n dispatchReady();\n }, [dispatchReady]);\n\n useEffect(() => {\n if (isReadyRef.current && data) {\n dispatch({ type: \"protected-data-updated\" });\n }\n }, [data, dispatch]);\n\n useEffect(() => {\n if (hasErrors) {\n if (!isProtectedDataReady && !isUnauthorized && queriesErrors.some(x => isUnauthorizedError(x))) {\n // Will transition the state to allow the routes to render even if the bootstrapping is not complete, because otherwise\n // a login page for example could not be rendered.\n dispatch({ type: \"is-unauthorized\" });\n }\n\n // Otherwise, when a user is logged off, a refetch might throws a 401.\n if (!queriesErrors.every(x => isUnauthorizedError(x))) {\n eventBus.dispatch(ProtectedDataFetchFailedEvent, queriesErrors);\n\n throw new GlobalDataQueriesError(\"[squide] Global protected data queries failed.\", queriesErrors);\n }\n }\n }, [hasErrors, queriesErrors, isProtectedDataReady, isUnauthorized, isUnauthorizedError, dispatch, eventBus]);\n\n return data;\n}\n"],"names":["useEventBus","useQueries","useCallback","useEffect","useRef","useAppRouterDispatcher","useAppRouterState","GlobalDataQueriesError","useCanFetchProtectedData","useExecuteOnce","ProtectedDataFetchStartedEvent","ProtectedDataFetchFailedEvent","useProtectedDataQueries","queries","isUnauthorizedError","canFetchProtectedData","eventBus","dispatch","combineResults","results","errors","x","hasErrors","data","queriesErrors","isReady","isProtectedDataReady","isUnauthorized","isReadyRef","dispatchReady"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA2C;AACuE;AAC3D;AAC2B;AACb;AACI;AACpB;AAE9C,MAAMU,iCAAiC,sCAAsC;AAC7E,MAAMC,gCAAgC,qCAAqC;AAQlF,8DAA8D;AACvD,SAASC,wBAA8CC,OAA0B,EAAEC,mBAAgD;IACtI,MAAMC,wBAAwBP,wBAAwBA;IACtD,MAAMQ,WAAWhB,WAAWA;IAE5B,MAAMiB,WAAWZ,sBAAsBA;IAEvC,MAAMa,iBAAiBhB,WAAWA,CAAC,CAACiB;QAChC,MAAMC,SAASD,QAAQ,MAAM,CAACE,CAAAA,IAAKA,EAAE,KAAK,EAAE,GAAG,CAACA,CAAAA,IAAKA,EAAE,KAAK;QAC5D,MAAMC,YAAYF,OAAO,MAAM,GAAG;QAElC,OAAO;YACH,MAAMD,QAAQ,GAAG,CAACE,CAAAA,IAAKA,EAAE,IAAI;YAC7BD;YACAE;YACA,SAAS,CAACA,aAAa,CAACH,QAAQ,IAAI,CAACE,CAAAA,IAAKA,EAAE,SAAS;QACzD;IACJ,GAAG,EAAE;IAEL,MAAM,EAAEE,IAAI,EAAE,QAAQC,aAAa,EAAEF,SAAS,EAAEG,OAAO,EAAE,GAAGxB,UAAUA,CAAC;QACnE,SAASY,QAAQ,GAAG,CAACQ,CAAAA,IAAM;gBACvB,SAASN;gBACT,GAAGM,CAAC;YACR;QACA,SAASH;IACb;IAEA,MAAM,EAAEQ,oBAAoB,EAAEC,cAAc,EAAE,GAAGrB,iBAAiBA;IAElEG,cAAcA,CAACP,WAAWA,CAAC;QACvB,IAAIa,uBAAuB;YACvBC,SAAS,QAAQ,CAACN;YAElB,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACK;QAAuBC;KAAS,GAAG;IAEvC,6FAA6F;IAC7F,MAAMY,aAAaxB,MAAMA,CAAC;IAE1B,MAAMyB,gBAAgBpB,cAAcA,CAACP,WAAWA,CAAC;QAC7C,IAAIuB,SAAS;YACTG,WAAW,OAAO,GAAG;YAErBX,SAAS;gBAAE,MAAM;YAAuB;YAExC,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACQ;QAASR;KAAS;IAEtBd,SAASA,CAAC;QACN,8CAA8C;QAC9C0B;IACJ,GAAG;QAACA;KAAc;IAElB1B,SAASA,CAAC;QACN,IAAIyB,WAAW,OAAO,IAAIL,MAAM;YAC5BN,SAAS;gBAAE,MAAM;YAAyB;QAC9C;IACJ,GAAG;QAACM;QAAMN;KAAS;IAEnBd,SAASA,CAAC;QACN,IAAImB,WAAW;YACX,IAAI,CAACI,wBAAwB,CAACC,kBAAkBH,cAAc,IAAI,CAACH,CAAAA,IAAKP,oBAAoBO,KAAK;gBAC7F,uHAAuH;gBACvH,kDAAkD;gBAClDJ,SAAS;oBAAE,MAAM;gBAAkB;YACvC;YAEA,sEAAsE;YACtE,IAAI,CAACO,cAAc,KAAK,CAACH,CAAAA,IAAKP,oBAAoBO,KAAK;gBACnDL,SAAS,QAAQ,CAACL,+BAA+Ba;gBAEjD,MAAM,IAAIjB,sBAAsBA,CAAC,kDAAkDiB;YACvF;QACJ;IACJ,GAAG;QAACF;QAAWE;QAAeE;QAAsBC;QAAgBb;QAAqBG;QAAUD;KAAS;IAE5G,OAAOO;AACX"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useCanFetchPublicData } from "./useCanFetchPublicData.js";
|
|
3
3
|
|
|
4
4
|
;// CONCATENATED MODULE: external "react"
|
|
5
5
|
|
|
@@ -9,8 +9,8 @@ import * as __WEBPACK_EXTERNAL_MODULE__useCanFetchPublicData_js_b8d90132__ from
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
function usePublicDataHandler(handler) {
|
|
12
|
-
const canFetchPublicData =
|
|
13
|
-
|
|
12
|
+
const canFetchPublicData = useCanFetchPublicData();
|
|
13
|
+
useEffect(()=>{
|
|
14
14
|
if (canFetchPublicData) {
|
|
15
15
|
handler();
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePublicDataHandler.js","sources":["webpack://@squide/firefly/./src/usePublicDataHandler.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCanFetchPublicData } from \"./useCanFetchPublicData.ts\";\n\nexport function usePublicDataHandler(handler: () => void) {\n const canFetchPublicData = useCanFetchPublicData();\n\n useEffect(() => {\n if (canFetchPublicData) {\n handler();\n }\n }, [canFetchPublicData, handler]);\n}\n"],"names":["useEffect","useCanFetchPublicData","usePublicDataHandler","handler","canFetchPublicData"],"mappings":";;;;;;;;AAAkC;AACiC;AAE5D,SAASE,qBAAqBC,OAAmB;IACpD,MAAMC,qBAAqBH,
|
|
1
|
+
{"version":3,"file":"usePublicDataHandler.js","sources":["webpack://@squide/firefly/./src/usePublicDataHandler.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useCanFetchPublicData } from \"./useCanFetchPublicData.ts\";\n\nexport function usePublicDataHandler(handler: () => void) {\n const canFetchPublicData = useCanFetchPublicData();\n\n useEffect(() => {\n if (canFetchPublicData) {\n handler();\n }\n }, [canFetchPublicData, handler]);\n}\n"],"names":["useEffect","useCanFetchPublicData","usePublicDataHandler","handler","canFetchPublicData"],"mappings":";;;;;;;;AAAkC;AACiC;AAE5D,SAASE,qBAAqBC,OAAmB;IACpD,MAAMC,qBAAqBH,qBAAqBA;IAEhDD,SAASA,CAAC;QACN,IAAII,oBAAoB;YACpBD;QACJ;IACJ,GAAG;QAACC;QAAoBD;KAAQ;AACpC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { useEventBus } from "@squide/core";
|
|
2
|
+
import { useQueries } from "@tanstack/react-query";
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { useAppRouterDispatcher } from "./AppRouterContext.js";
|
|
5
|
+
import { GlobalDataQueriesError } from "./GlobalDataQueriesError.js";
|
|
6
|
+
import { useCanFetchPublicData } from "./useCanFetchPublicData.js";
|
|
7
|
+
import { useExecuteOnce } from "./useExecuteOnce.js";
|
|
8
8
|
|
|
9
9
|
;// CONCATENATED MODULE: external "@squide/core"
|
|
10
10
|
|
|
@@ -32,10 +32,10 @@ const PublicDataFetchStartedEvent = "squide-public-data-fetch-started";
|
|
|
32
32
|
const PublicDataFetchFailedEvent = "squide-public-data-fetch-failed";
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
34
|
function usePublicDataQueries(queries) {
|
|
35
|
-
const canFetchPublicData =
|
|
36
|
-
const eventBus =
|
|
37
|
-
const dispatch =
|
|
38
|
-
const combineResults =
|
|
35
|
+
const canFetchPublicData = useCanFetchPublicData();
|
|
36
|
+
const eventBus = useEventBus();
|
|
37
|
+
const dispatch = useAppRouterDispatcher();
|
|
38
|
+
const combineResults = useCallback((results)=>{
|
|
39
39
|
const errors = results.filter((x)=>x.error).map((x)=>x.error);
|
|
40
40
|
const hasErrors = errors.length > 0;
|
|
41
41
|
return {
|
|
@@ -45,14 +45,14 @@ function usePublicDataQueries(queries) {
|
|
|
45
45
|
isReady: !hasErrors && !results.some((x)=>x.isPending)
|
|
46
46
|
};
|
|
47
47
|
}, []);
|
|
48
|
-
const { data, errors: queriesErrors, hasErrors, isReady } =
|
|
48
|
+
const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({
|
|
49
49
|
queries: queries.map((x)=>({
|
|
50
50
|
enabled: canFetchPublicData,
|
|
51
51
|
...x
|
|
52
52
|
})),
|
|
53
53
|
combine: combineResults
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
useExecuteOnce(useCallback(()=>{
|
|
56
56
|
if (canFetchPublicData) {
|
|
57
57
|
eventBus.dispatch(PublicDataFetchStartedEvent);
|
|
58
58
|
return true;
|
|
@@ -63,8 +63,8 @@ function usePublicDataQueries(queries) {
|
|
|
63
63
|
eventBus
|
|
64
64
|
]), true);
|
|
65
65
|
// Using a ref seems to be the only way to prevent starting two deferred registrations scope.
|
|
66
|
-
const isReadyRef =
|
|
67
|
-
const dispatchReady =
|
|
66
|
+
const isReadyRef = useRef(false);
|
|
67
|
+
const dispatchReady = useExecuteOnce(useCallback(()=>{
|
|
68
68
|
if (isReady) {
|
|
69
69
|
isReadyRef.current = true;
|
|
70
70
|
dispatch({
|
|
@@ -77,13 +77,13 @@ function usePublicDataQueries(queries) {
|
|
|
77
77
|
isReady,
|
|
78
78
|
dispatch
|
|
79
79
|
]));
|
|
80
|
-
|
|
80
|
+
useEffect(()=>{
|
|
81
81
|
// State update must be executed in useEffect.
|
|
82
82
|
dispatchReady();
|
|
83
83
|
}, [
|
|
84
84
|
dispatchReady
|
|
85
85
|
]);
|
|
86
|
-
|
|
86
|
+
useEffect(()=>{
|
|
87
87
|
if (isReadyRef.current && data) {
|
|
88
88
|
dispatch({
|
|
89
89
|
type: "public-data-updated"
|
|
@@ -93,10 +93,10 @@ function usePublicDataQueries(queries) {
|
|
|
93
93
|
data,
|
|
94
94
|
dispatch
|
|
95
95
|
]);
|
|
96
|
-
|
|
96
|
+
useEffect(()=>{
|
|
97
97
|
if (hasErrors) {
|
|
98
98
|
eventBus.dispatch(PublicDataFetchFailedEvent, queriesErrors);
|
|
99
|
-
throw new
|
|
99
|
+
throw new GlobalDataQueriesError("[squide] Global public data queries failed.", queriesErrors);
|
|
100
100
|
}
|
|
101
101
|
}, [
|
|
102
102
|
hasErrors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePublicDataQueries.js","sources":["webpack://@squide/firefly/./src/usePublicDataQueries.ts"],"sourcesContent":["import { useEventBus } from \"@squide/core\";\nimport { useQueries, type QueriesOptions, type QueriesResults, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { useAppRouterDispatcher } from \"./AppRouterContext.ts\";\nimport { GlobalDataQueriesError } from \"./GlobalDataQueriesError.ts\";\nimport { useCanFetchPublicData } from \"./useCanFetchPublicData.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\n\nexport const PublicDataFetchStartedEvent = \"squide-public-data-fetch-started\";\nexport const PublicDataFetchFailedEvent = \"squide-public-data-fetch-failed\";\n\n// This converts an array of UseQueryResult to an array of the data type of each query result.\n// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.\ntype MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function usePublicDataQueries<T extends Array<any>>(queries: QueriesOptions<T>): MapUseQueryResultToData<QueriesResults<T>> {\n const canFetchPublicData = useCanFetchPublicData();\n const eventBus = useEventBus();\n\n const dispatch = useAppRouterDispatcher();\n\n const combineResults = useCallback((results: UseQueryResult<unknown, unknown>[]) => {\n const errors = results.filter(x => x.error).map(x => x.error) as Error[];\n const hasErrors = errors.length > 0;\n\n return {\n data: results.map(x => x.data) as MapUseQueryResultToData<QueriesResults<T>>,\n errors,\n hasErrors,\n isReady: !hasErrors && !results.some(x => x.isPending)\n };\n }, []);\n\n const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({\n queries: queries.map(x => ({\n enabled: canFetchPublicData,\n ...x\n })),\n combine: combineResults\n });\n\n useExecuteOnce(useCallback(() => {\n if (canFetchPublicData) {\n eventBus.dispatch(PublicDataFetchStartedEvent);\n\n return true;\n }\n\n return false;\n }, [canFetchPublicData, eventBus]), true);\n\n // Using a ref seems to be the only way to prevent starting two deferred registrations scope.\n const isReadyRef = useRef(false);\n\n const dispatchReady = useExecuteOnce(useCallback(() => {\n if (isReady) {\n isReadyRef.current = true;\n\n dispatch({ type: \"public-data-ready\" });\n\n return true;\n }\n\n return false;\n }, [isReady, dispatch]));\n\n useEffect(() => {\n // State update must be executed in useEffect.\n dispatchReady();\n }, [dispatchReady]);\n\n useEffect(() => {\n if (isReadyRef.current && data) {\n dispatch({ type: \"public-data-updated\" });\n }\n }, [data, dispatch]);\n\n useEffect(() => {\n if (hasErrors) {\n eventBus.dispatch(PublicDataFetchFailedEvent, queriesErrors);\n\n throw new GlobalDataQueriesError(\"[squide] Global public data queries failed.\", queriesErrors);\n }\n }, [hasErrors, queriesErrors, eventBus]);\n\n return data;\n}\n"],"names":["useEventBus","useQueries","useCallback","useEffect","useRef","useAppRouterDispatcher","GlobalDataQueriesError","useCanFetchPublicData","useExecuteOnce","PublicDataFetchStartedEvent","PublicDataFetchFailedEvent","usePublicDataQueries","queries","canFetchPublicData","eventBus","dispatch","combineResults","results","errors","x","hasErrors","data","queriesErrors","isReady","isReadyRef","dispatchReady"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA2C;AACuE;AAC3D;AACQ;AACM;AACF;AACd;AAE9C,MAAMS,8BAA8B,mCAAmC;AACvE,MAAMC,6BAA6B,kCAAkC;AAM5E,8DAA8D;AACvD,SAASC,qBAA2CC,OAA0B;IACjF,MAAMC,qBAAqBN,
|
|
1
|
+
{"version":3,"file":"usePublicDataQueries.js","sources":["webpack://@squide/firefly/./src/usePublicDataQueries.ts"],"sourcesContent":["import { useEventBus } from \"@squide/core\";\nimport { useQueries, type QueriesOptions, type QueriesResults, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { useAppRouterDispatcher } from \"./AppRouterContext.ts\";\nimport { GlobalDataQueriesError } from \"./GlobalDataQueriesError.ts\";\nimport { useCanFetchPublicData } from \"./useCanFetchPublicData.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\n\nexport const PublicDataFetchStartedEvent = \"squide-public-data-fetch-started\";\nexport const PublicDataFetchFailedEvent = \"squide-public-data-fetch-failed\";\n\n// This converts an array of UseQueryResult to an array of the data type of each query result.\n// For more information, view: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#mapped-types-on-tuples-and-arrays.\ntype MapUseQueryResultToData<T> = { [K in keyof T]: T[K] extends UseQueryResult<infer U> ? U : never };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function usePublicDataQueries<T extends Array<any>>(queries: QueriesOptions<T>): MapUseQueryResultToData<QueriesResults<T>> {\n const canFetchPublicData = useCanFetchPublicData();\n const eventBus = useEventBus();\n\n const dispatch = useAppRouterDispatcher();\n\n const combineResults = useCallback((results: UseQueryResult<unknown, unknown>[]) => {\n const errors = results.filter(x => x.error).map(x => x.error) as Error[];\n const hasErrors = errors.length > 0;\n\n return {\n data: results.map(x => x.data) as MapUseQueryResultToData<QueriesResults<T>>,\n errors,\n hasErrors,\n isReady: !hasErrors && !results.some(x => x.isPending)\n };\n }, []);\n\n const { data, errors: queriesErrors, hasErrors, isReady } = useQueries({\n queries: queries.map(x => ({\n enabled: canFetchPublicData,\n ...x\n })),\n combine: combineResults\n });\n\n useExecuteOnce(useCallback(() => {\n if (canFetchPublicData) {\n eventBus.dispatch(PublicDataFetchStartedEvent);\n\n return true;\n }\n\n return false;\n }, [canFetchPublicData, eventBus]), true);\n\n // Using a ref seems to be the only way to prevent starting two deferred registrations scope.\n const isReadyRef = useRef(false);\n\n const dispatchReady = useExecuteOnce(useCallback(() => {\n if (isReady) {\n isReadyRef.current = true;\n\n dispatch({ type: \"public-data-ready\" });\n\n return true;\n }\n\n return false;\n }, [isReady, dispatch]));\n\n useEffect(() => {\n // State update must be executed in useEffect.\n dispatchReady();\n }, [dispatchReady]);\n\n useEffect(() => {\n if (isReadyRef.current && data) {\n dispatch({ type: \"public-data-updated\" });\n }\n }, [data, dispatch]);\n\n useEffect(() => {\n if (hasErrors) {\n eventBus.dispatch(PublicDataFetchFailedEvent, queriesErrors);\n\n throw new GlobalDataQueriesError(\"[squide] Global public data queries failed.\", queriesErrors);\n }\n }, [hasErrors, queriesErrors, eventBus]);\n\n return data;\n}\n"],"names":["useEventBus","useQueries","useCallback","useEffect","useRef","useAppRouterDispatcher","GlobalDataQueriesError","useCanFetchPublicData","useExecuteOnce","PublicDataFetchStartedEvent","PublicDataFetchFailedEvent","usePublicDataQueries","queries","canFetchPublicData","eventBus","dispatch","combineResults","results","errors","x","hasErrors","data","queriesErrors","isReady","isReadyRef","dispatchReady"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA2C;AACuE;AAC3D;AACQ;AACM;AACF;AACd;AAE9C,MAAMS,8BAA8B,mCAAmC;AACvE,MAAMC,6BAA6B,kCAAkC;AAM5E,8DAA8D;AACvD,SAASC,qBAA2CC,OAA0B;IACjF,MAAMC,qBAAqBN,qBAAqBA;IAChD,MAAMO,WAAWd,WAAWA;IAE5B,MAAMe,WAAWV,sBAAsBA;IAEvC,MAAMW,iBAAiBd,WAAWA,CAAC,CAACe;QAChC,MAAMC,SAASD,QAAQ,MAAM,CAACE,CAAAA,IAAKA,EAAE,KAAK,EAAE,GAAG,CAACA,CAAAA,IAAKA,EAAE,KAAK;QAC5D,MAAMC,YAAYF,OAAO,MAAM,GAAG;QAElC,OAAO;YACH,MAAMD,QAAQ,GAAG,CAACE,CAAAA,IAAKA,EAAE,IAAI;YAC7BD;YACAE;YACA,SAAS,CAACA,aAAa,CAACH,QAAQ,IAAI,CAACE,CAAAA,IAAKA,EAAE,SAAS;QACzD;IACJ,GAAG,EAAE;IAEL,MAAM,EAAEE,IAAI,EAAE,QAAQC,aAAa,EAAEF,SAAS,EAAEG,OAAO,EAAE,GAAGtB,UAAUA,CAAC;QACnE,SAASW,QAAQ,GAAG,CAACO,CAAAA,IAAM;gBACvB,SAASN;gBACT,GAAGM,CAAC;YACR;QACA,SAASH;IACb;IAEAR,cAAcA,CAACN,WAAWA,CAAC;QACvB,IAAIW,oBAAoB;YACpBC,SAAS,QAAQ,CAACL;YAElB,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACI;QAAoBC;KAAS,GAAG;IAEpC,6FAA6F;IAC7F,MAAMU,aAAapB,MAAMA,CAAC;IAE1B,MAAMqB,gBAAgBjB,cAAcA,CAACN,WAAWA,CAAC;QAC7C,IAAIqB,SAAS;YACTC,WAAW,OAAO,GAAG;YAErBT,SAAS;gBAAE,MAAM;YAAoB;YAErC,OAAO;QACX;QAEA,OAAO;IACX,GAAG;QAACQ;QAASR;KAAS;IAEtBZ,SAASA,CAAC;QACN,8CAA8C;QAC9CsB;IACJ,GAAG;QAACA;KAAc;IAElBtB,SAASA,CAAC;QACN,IAAIqB,WAAW,OAAO,IAAIH,MAAM;YAC5BN,SAAS;gBAAE,MAAM;YAAsB;QAC3C;IACJ,GAAG;QAACM;QAAMN;KAAS;IAEnBZ,SAASA,CAAC;QACN,IAAIiB,WAAW;YACXN,SAAS,QAAQ,CAACJ,4BAA4BY;YAE9C,MAAM,IAAIhB,sBAAsBA,CAAC,+CAA+CgB;QACpF;IACJ,GAAG;QAACF;QAAWE;QAAeR;KAAS;IAEvC,OAAOO;AACX"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { registerDeferredRegistrations } from "@squide/module-federation";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
3
|
|
|
4
4
|
;// CONCATENATED MODULE: external "@squide/module-federation"
|
|
5
5
|
|
|
@@ -9,8 +9,8 @@ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
function useRegisterDeferredRegistrations() {
|
|
12
|
-
return
|
|
13
|
-
return
|
|
12
|
+
return useCallback((data, runtime)=>{
|
|
13
|
+
return registerDeferredRegistrations(data, runtime);
|
|
14
14
|
}, []);
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRegisterDeferredRegistrations.js","sources":["webpack://@squide/firefly/./src/useRegisterDeferredRegistrations.ts"],"sourcesContent":["import type { Runtime } from \"@squide/core\";\nimport { registerDeferredRegistrations } from \"@squide/module-federation\";\nimport { useCallback } from \"react\";\n\nexport function useRegisterDeferredRegistrations() {\n return useCallback(<TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime) => {\n return registerDeferredRegistrations(data, runtime);\n }, []);\n}\n"],"names":["registerDeferredRegistrations","useCallback","useRegisterDeferredRegistrations","data","runtime"],"mappings":";;;;;;;;AAC0E;AACtC;AAE7B,SAASE;IACZ,OAAOD,
|
|
1
|
+
{"version":3,"file":"useRegisterDeferredRegistrations.js","sources":["webpack://@squide/firefly/./src/useRegisterDeferredRegistrations.ts"],"sourcesContent":["import type { Runtime } from \"@squide/core\";\nimport { registerDeferredRegistrations } from \"@squide/module-federation\";\nimport { useCallback } from \"react\";\n\nexport function useRegisterDeferredRegistrations() {\n return useCallback(<TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime) => {\n return registerDeferredRegistrations(data, runtime);\n }, []);\n}\n"],"names":["registerDeferredRegistrations","useCallback","useRegisterDeferredRegistrations","data","runtime"],"mappings":";;;;;;;;AAC0E;AACtC;AAE7B,SAASE;IACZ,OAAOD,WAAWA,CAAC,CAAsDE,MAAaC;QAClF,OAAOJ,6BAA6BA,CAACG,MAAMC;IAC/C,GAAG,EAAE;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useRuntime } from "@squide/core";
|
|
2
|
+
import { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, getRemoteModuleRegistrationStatus, removeRemoteModuleRegistrationStatusChangedListener } from "@squide/module-federation";
|
|
3
|
+
import { useEffect, useSyncExternalStore } from "react";
|
|
4
4
|
|
|
5
5
|
;// CONCATENATED MODULE: external "@squide/core"
|
|
6
6
|
|
|
@@ -13,19 +13,19 @@ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
function subscribeToLocalModuleRegistrationStatusChanged(callback) {
|
|
16
|
-
|
|
17
|
-
return ()=>
|
|
16
|
+
addLocalModuleRegistrationStatusChangedListener(callback);
|
|
17
|
+
return ()=>removeLocalModuleRegistrationStatusChangedListener(callback);
|
|
18
18
|
}
|
|
19
19
|
function subscribeToRemoteModuleRegistrationStatusChanged(callback) {
|
|
20
|
-
|
|
21
|
-
return ()=>
|
|
20
|
+
addRemoteModuleRegistrationStatusChangedListener(callback);
|
|
21
|
+
return ()=>removeRemoteModuleRegistrationStatusChangedListener(callback);
|
|
22
22
|
}
|
|
23
23
|
function useStrictRegistrationMode() {
|
|
24
|
-
const runtime =
|
|
25
|
-
const localModuleStatus =
|
|
26
|
-
const remoteModuleStatus =
|
|
27
|
-
|
|
28
|
-
if (
|
|
24
|
+
const runtime = useRuntime();
|
|
25
|
+
const localModuleStatus = useSyncExternalStore(subscribeToLocalModuleRegistrationStatusChanged, getLocalModuleRegistrationStatus);
|
|
26
|
+
const remoteModuleStatus = useSyncExternalStore(subscribeToRemoteModuleRegistrationStatusChanged, getRemoteModuleRegistrationStatus);
|
|
27
|
+
useEffect(()=>{
|
|
28
|
+
if (areModulesReady(localModuleStatus, remoteModuleStatus)) {
|
|
29
29
|
runtime._validateRegistrations();
|
|
30
30
|
}
|
|
31
31
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStrictRegistrationMode.js","sources":["webpack://@squide/firefly/./src/useStrictRegistrationMode.ts"],"sourcesContent":["import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useRuntime } from \"@squide/core\";\nimport { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, getRemoteModuleRegistrationStatus, removeRemoteModuleRegistrationStatusChangedListener } from \"@squide/module-federation\";\nimport { useEffect, useSyncExternalStore } from \"react\";\n\nfunction subscribeToLocalModuleRegistrationStatusChanged(callback: () => void) {\n addLocalModuleRegistrationStatusChangedListener(callback);\n\n return () => removeLocalModuleRegistrationStatusChangedListener(callback);\n}\n\nfunction subscribeToRemoteModuleRegistrationStatusChanged(callback: () => void) {\n addRemoteModuleRegistrationStatusChangedListener(callback);\n\n return () => removeRemoteModuleRegistrationStatusChangedListener(callback);\n}\n\nexport function useStrictRegistrationMode() {\n const runtime = useRuntime();\n\n const localModuleStatus = useSyncExternalStore(subscribeToLocalModuleRegistrationStatusChanged, getLocalModuleRegistrationStatus);\n const remoteModuleStatus = useSyncExternalStore(subscribeToRemoteModuleRegistrationStatusChanged, getRemoteModuleRegistrationStatus);\n\n useEffect(() => {\n if (areModulesReady(localModuleStatus, remoteModuleStatus)) {\n runtime._validateRegistrations();\n }\n }, [runtime, localModuleStatus, remoteModuleStatus]);\n}\n"],"names":["addLocalModuleRegistrationStatusChangedListener","getLocalModuleRegistrationStatus","removeLocalModuleRegistrationStatusChangedListener","useRuntime","addRemoteModuleRegistrationStatusChangedListener","areModulesReady","getRemoteModuleRegistrationStatus","removeRemoteModuleRegistrationStatusChangedListener","useEffect","useSyncExternalStore","subscribeToLocalModuleRegistrationStatusChanged","callback","subscribeToRemoteModuleRegistrationStatusChanged","useStrictRegistrationMode","runtime","localModuleStatus","remoteModuleStatus"],"mappings":";;;;;;;;;;;AAAiL;AACqB;AAC9I;AAExD,SAASU,gDAAgDC,QAAoB;IACzEX
|
|
1
|
+
{"version":3,"file":"useStrictRegistrationMode.js","sources":["webpack://@squide/firefly/./src/useStrictRegistrationMode.ts"],"sourcesContent":["import { addLocalModuleRegistrationStatusChangedListener, getLocalModuleRegistrationStatus, removeLocalModuleRegistrationStatusChangedListener, useRuntime } from \"@squide/core\";\nimport { addRemoteModuleRegistrationStatusChangedListener, areModulesReady, getRemoteModuleRegistrationStatus, removeRemoteModuleRegistrationStatusChangedListener } from \"@squide/module-federation\";\nimport { useEffect, useSyncExternalStore } from \"react\";\n\nfunction subscribeToLocalModuleRegistrationStatusChanged(callback: () => void) {\n addLocalModuleRegistrationStatusChangedListener(callback);\n\n return () => removeLocalModuleRegistrationStatusChangedListener(callback);\n}\n\nfunction subscribeToRemoteModuleRegistrationStatusChanged(callback: () => void) {\n addRemoteModuleRegistrationStatusChangedListener(callback);\n\n return () => removeRemoteModuleRegistrationStatusChangedListener(callback);\n}\n\nexport function useStrictRegistrationMode() {\n const runtime = useRuntime();\n\n const localModuleStatus = useSyncExternalStore(subscribeToLocalModuleRegistrationStatusChanged, getLocalModuleRegistrationStatus);\n const remoteModuleStatus = useSyncExternalStore(subscribeToRemoteModuleRegistrationStatusChanged, getRemoteModuleRegistrationStatus);\n\n useEffect(() => {\n if (areModulesReady(localModuleStatus, remoteModuleStatus)) {\n runtime._validateRegistrations();\n }\n }, [runtime, localModuleStatus, remoteModuleStatus]);\n}\n"],"names":["addLocalModuleRegistrationStatusChangedListener","getLocalModuleRegistrationStatus","removeLocalModuleRegistrationStatusChangedListener","useRuntime","addRemoteModuleRegistrationStatusChangedListener","areModulesReady","getRemoteModuleRegistrationStatus","removeRemoteModuleRegistrationStatusChangedListener","useEffect","useSyncExternalStore","subscribeToLocalModuleRegistrationStatusChanged","callback","subscribeToRemoteModuleRegistrationStatusChanged","useStrictRegistrationMode","runtime","localModuleStatus","remoteModuleStatus"],"mappings":";;;;;;;;;;;AAAiL;AACqB;AAC9I;AAExD,SAASU,gDAAgDC,QAAoB;IACzEX,+CAA+CA,CAACW;IAEhD,OAAO,IAAMT,kDAAkDA,CAACS;AACpE;AAEA,SAASC,iDAAiDD,QAAoB;IAC1EP,gDAAgDA,CAACO;IAEjD,OAAO,IAAMJ,mDAAmDA,CAACI;AACrE;AAEO,SAASE;IACZ,MAAMC,UAAUX,UAAUA;IAE1B,MAAMY,oBAAoBN,oBAAoBA,CAACC,iDAAiDT,gCAAgCA;IAChI,MAAMe,qBAAqBP,oBAAoBA,CAACG,kDAAkDN,iCAAiCA;IAEnIE,SAASA,CAAC;QACN,IAAIH,eAAeA,CAACU,mBAAmBC,qBAAqB;YACxDF,QAAQ,sBAAsB;QAClC;IACJ,GAAG;QAACA;QAASC;QAAmBC;KAAmB;AACvD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { updateDeferredRegistrations } from "@squide/module-federation";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useAppRouterDispatcher } from "./AppRouterContext.js";
|
|
4
4
|
|
|
5
5
|
;// CONCATENATED MODULE: external "@squide/module-federation"
|
|
6
6
|
|
|
@@ -13,9 +13,9 @@ import * as __WEBPACK_EXTERNAL_MODULE__AppRouterContext_js_3c4a3c33__ from "./Ap
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
function useUpdateDeferredRegistrations() {
|
|
16
|
-
const dispatch =
|
|
17
|
-
return
|
|
18
|
-
const errors = await
|
|
16
|
+
const dispatch = useAppRouterDispatcher();
|
|
17
|
+
return useCallback(async (data, runtime)=>{
|
|
18
|
+
const errors = await updateDeferredRegistrations(data, runtime);
|
|
19
19
|
dispatch({
|
|
20
20
|
type: "deferred-registrations-updated"
|
|
21
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUpdateDeferredRegistrations.js","sources":["webpack://@squide/firefly/./src/useUpdateDeferredRegistrations.ts"],"sourcesContent":["import type { Runtime } from \"@squide/core\";\nimport { updateDeferredRegistrations } from \"@squide/module-federation\";\nimport { useCallback } from \"react\";\nimport { useAppRouterDispatcher } from \"./AppRouterContext.ts\";\n\nexport function useUpdateDeferredRegistrations() {\n const dispatch = useAppRouterDispatcher();\n\n return useCallback(async <TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime) => {\n const errors = await updateDeferredRegistrations(data, runtime);\n\n dispatch({ type: \"deferred-registrations-updated\" });\n\n return errors;\n }, [dispatch]);\n}\n"],"names":["updateDeferredRegistrations","useCallback","useAppRouterDispatcher","useUpdateDeferredRegistrations","dispatch","data","runtime","errors"],"mappings":";;;;;;;;;;;AACwE;AACpC;AAC2B;AAExD,SAASG;IACZ,MAAMC,WAAWF,
|
|
1
|
+
{"version":3,"file":"useUpdateDeferredRegistrations.js","sources":["webpack://@squide/firefly/./src/useUpdateDeferredRegistrations.ts"],"sourcesContent":["import type { Runtime } from \"@squide/core\";\nimport { updateDeferredRegistrations } from \"@squide/module-federation\";\nimport { useCallback } from \"react\";\nimport { useAppRouterDispatcher } from \"./AppRouterContext.ts\";\n\nexport function useUpdateDeferredRegistrations() {\n const dispatch = useAppRouterDispatcher();\n\n return useCallback(async <TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime) => {\n const errors = await updateDeferredRegistrations(data, runtime);\n\n dispatch({ type: \"deferred-registrations-updated\" });\n\n return errors;\n }, [dispatch]);\n}\n"],"names":["updateDeferredRegistrations","useCallback","useAppRouterDispatcher","useUpdateDeferredRegistrations","dispatch","data","runtime","errors"],"mappings":";;;;;;;;;;;AACwE;AACpC;AAC2B;AAExD,SAASG;IACZ,MAAMC,WAAWF,sBAAsBA;IAEvC,OAAOD,WAAWA,CAAC,OAA4DI,MAAaC;QACxF,MAAMC,SAAS,MAAMP,2BAA2BA,CAACK,MAAMC;QAEvDF,SAAS;YAAE,MAAM;QAAiC;QAElD,OAAOG;IACX,GAAG;QAACH;KAAS;AACjB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "13.0.
|
|
4
|
+
"version": "13.0.2",
|
|
5
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": {
|
|
@@ -29,39 +29,34 @@
|
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@opentelemetry/api": "^1.9.0",
|
|
32
|
-
"@tanstack/react-query": "^5.
|
|
33
|
-
"msw": "^2.
|
|
32
|
+
"@tanstack/react-query": "^5.81.2",
|
|
33
|
+
"msw": "^2.10.2",
|
|
34
34
|
"react": "^18.0.0 || ^19.0.0",
|
|
35
35
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
36
|
-
"react-router": "^7.6.
|
|
37
|
-
},
|
|
38
|
-
"peerDependenciesMeta": {
|
|
39
|
-
"@opentelemetry/api": {
|
|
40
|
-
"optional": true
|
|
41
|
-
}
|
|
36
|
+
"react-router": "^7.6.2"
|
|
42
37
|
},
|
|
43
38
|
"dependencies": {
|
|
44
39
|
"uuid": "^11.1.0",
|
|
45
|
-
"@squide/core": "5.4.
|
|
46
|
-
"@squide/
|
|
47
|
-
"@squide/
|
|
48
|
-
"@squide/
|
|
40
|
+
"@squide/core": "5.4.9",
|
|
41
|
+
"@squide/module-federation": "6.2.9",
|
|
42
|
+
"@squide/msw": "3.2.9",
|
|
43
|
+
"@squide/react-router": "7.0.7"
|
|
49
44
|
},
|
|
50
45
|
"devDependencies": {
|
|
51
|
-
"@rsbuild/core": "1.
|
|
52
|
-
"@rslib/core": "0.
|
|
46
|
+
"@rsbuild/core": "1.4.0",
|
|
47
|
+
"@rslib/core": "0.10.3",
|
|
53
48
|
"@testing-library/react": "16.3.0",
|
|
54
|
-
"@types/react": "19.1.
|
|
55
|
-
"@types/react-dom": "19.1.
|
|
56
|
-
"@typescript-eslint/parser": "8.
|
|
57
|
-
"@vitejs/plugin-react": "4.
|
|
49
|
+
"@types/react": "19.1.8",
|
|
50
|
+
"@types/react-dom": "19.1.6",
|
|
51
|
+
"@typescript-eslint/parser": "8.35.0",
|
|
52
|
+
"@vitejs/plugin-react": "4.6.0",
|
|
58
53
|
"@workleap/eslint-plugin": "3.4.2",
|
|
59
54
|
"@workleap/rslib-configs": "1.0.6",
|
|
60
55
|
"@workleap/typescript-configs": "3.0.4",
|
|
61
56
|
"eslint": "8.57.0",
|
|
62
|
-
"happy-dom": "
|
|
57
|
+
"happy-dom": "18.0.1",
|
|
63
58
|
"typescript": "5.8.3",
|
|
64
|
-
"vitest": "3.
|
|
59
|
+
"vitest": "3.2.4"
|
|
65
60
|
},
|
|
66
61
|
"sideEffects": false,
|
|
67
62
|
"engines": {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FireflyRuntime } from "../FireflyRuntime.tsx";
|
|
2
|
+
import { canRegisterHoneycombInstrumentation } from "./canRegisterHoneycombInstrumentation.ts";
|
|
3
|
+
|
|
4
|
+
export async function initializeHoneycomb(runtime: FireflyRuntime) {
|
|
5
|
+
if (canRegisterHoneycombInstrumentation()) {
|
|
6
|
+
try {
|
|
7
|
+
// Dynamically import the Honeycomb instrumentation to prevent loading all the Honeycomb libraries
|
|
8
|
+
// if Honeycomb instrumentation is not registered by the hosting application.
|
|
9
|
+
const mod = await import("./registerHoneycombInstrumentation.ts");
|
|
10
|
+
|
|
11
|
+
mod.registerHoneycombInstrumentation(runtime);
|
|
12
|
+
} catch (error: unknown) {
|
|
13
|
+
runtime.logger.error("[squide] Failed to register Honeycomb instrumentation. The \"./registerHoneycombInstrumentation.ts\" cannot be imported.");
|
|
14
|
+
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
runtime.logger.debug("[squide] Cannot register Honeycomb instrumentation because the host application is not using the \"@workleap/honeycomb\" package.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|