@squide/firefly 16.1.5 → 16.1.7
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 +26 -0
- package/dist/AppRouterReducer.js +4 -1
- package/dist/AppRouterReducer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/useExecuteOnce.js +1 -0
- package/dist/useExecuteOnce.js.map +1 -1
- package/package.json +19 -18
- package/src/AppRouterReducer.ts +5 -4
- package/src/index.ts +10 -1
- package/src/useExecuteOnce.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @squide/firefly
|
|
2
2
|
|
|
3
|
+
## 16.1.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#392](https://github.com/workleap/wl-squide/pull/392) [`4001ae7`](https://github.com/workleap/wl-squide/commit/4001ae75f7aea8ee124ce831f69a1f55a342cef5) Thanks [@patricklafrance](https://github.com/patricklafrance)! - `initializeFireflyForStorybook` now accept a `useMsw` option to opt-out of MSW and will now render as expected if no local modules are provided.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`4001ae7`](https://github.com/workleap/wl-squide/commit/4001ae75f7aea8ee124ce831f69a1f55a342cef5)]:
|
|
10
|
+
- @squide/core@6.1.12
|
|
11
|
+
- @squide/env-vars@1.4.15
|
|
12
|
+
- @squide/launch-darkly@1.0.6
|
|
13
|
+
- @squide/msw@4.0.13
|
|
14
|
+
- @squide/react-router@8.1.12
|
|
15
|
+
|
|
16
|
+
## 16.1.6
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#373](https://github.com/workleap/wl-squide/pull/373) [`f9138cc`](https://github.com/workleap/wl-squide/commit/f9138cc4bd0a1d175ad4bd7e695d1edd7fbe4c1c) Thanks [@alexasselin008](https://github.com/alexasselin008)! - Bumped dependencies
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`f9138cc`](https://github.com/workleap/wl-squide/commit/f9138cc4bd0a1d175ad4bd7e695d1edd7fbe4c1c), [`f9138cc`](https://github.com/workleap/wl-squide/commit/f9138cc4bd0a1d175ad4bd7e695d1edd7fbe4c1c)]:
|
|
23
|
+
- @squide/launch-darkly@1.0.5
|
|
24
|
+
- @squide/react-router@8.1.11
|
|
25
|
+
- @squide/env-vars@1.4.14
|
|
26
|
+
- @squide/core@6.1.11
|
|
27
|
+
- @squide/msw@4.0.12
|
|
28
|
+
|
|
3
29
|
## 16.1.5
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/AppRouterReducer.js
CHANGED
|
@@ -48,6 +48,7 @@ function reducer(state, action) {
|
|
|
48
48
|
{
|
|
49
49
|
newState = {
|
|
50
50
|
...newState,
|
|
51
|
+
areModulesRegistered: true,
|
|
51
52
|
areModulesReady: true,
|
|
52
53
|
// Will be set even if the app is not using deferred registrations.
|
|
53
54
|
deferredRegistrationsUpdatedAt: Date.now()
|
|
@@ -183,6 +184,7 @@ function useModuleRegistrationStatusDispatcher(runtime, areModulesRegisteredValu
|
|
|
183
184
|
runtime.moduleManager.removeModulesReadyListener(dispatchModulesReady);
|
|
184
185
|
};
|
|
185
186
|
}, [
|
|
187
|
+
runtime,
|
|
186
188
|
areModulesRegisteredValue,
|
|
187
189
|
areModulesReadyValue,
|
|
188
190
|
dispatchModulesRegistered,
|
|
@@ -238,7 +240,8 @@ function useFeatureFlagsUpdatedDispatcher(runtime, dispatch) {
|
|
|
238
240
|
};
|
|
239
241
|
}
|
|
240
242
|
}, [
|
|
241
|
-
runtime
|
|
243
|
+
runtime,
|
|
244
|
+
dispatchFeatureFlagsUpdated
|
|
242
245
|
]);
|
|
243
246
|
}
|
|
244
247
|
function useBootstrappingCompletedDispatcher(waitState, state) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouterReducer.js","sources":["../src/AppRouterReducer.ts"],"sourcesContent":["import { useEventBus, useLogger, useRuntime } from \"@squide/core\";\nimport type { FeatureFlagSetSnapshotChangedListener } from \"@squide/launch-darkly\";\nimport { useCallback, useEffect, useMemo, useReducer, type Dispatch } from \"react\";\nimport type { FireflyRuntime } from \"./FireflyRuntime.tsx\";\nimport { useAppRouterStore } from \"./useAppRouterStore.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\nimport { isBootstrapping } from \"./useIsBootstrapping.ts\";\n\nexport type ActiveRouteVisiblity = \"unknown\" | \"public\" | \"protected\";\n\nexport interface AppRouterWaitState {\n waitForMsw: boolean;\n waitForPublicData: boolean;\n waitForProtectedData: boolean;\n}\n\nexport interface AppRouterState extends AppRouterWaitState {\n areModulesRegistered: boolean;\n areModulesReady: boolean;\n isMswReady: boolean;\n isPublicDataReady: boolean;\n isProtectedDataReady: boolean;\n publicDataUpdatedAt?: number;\n protectedDataUpdatedAt?: number;\n featureFlagsUpdatedAt?: number;\n deferredRegistrationsUpdatedAt?: number;\n activeRouteVisibility: ActiveRouteVisiblity;\n isUnauthorized: boolean;\n}\n\nexport type AppRouterActionType =\n | \"modules-registered\"\n | \"modules-ready\"\n | \"msw-ready\"\n | \"public-data-ready\"\n | \"protected-data-ready\"\n | \"public-data-updated\"\n | \"protected-data-updated\"\n | \"feature-flags-updated\"\n | \"deferred-registrations-updated\"\n | \"active-route-is-public\"\n | \"active-route-is-protected\"\n | \"is-unauthorized\";\n\n// The followings event const are a concatenation of \"squide-\" with AppRouterActionType.\n// They are dispatched by the useEnhancedReducerDispatch hook.\nexport const ModulesRegisteredEvent = \"squide-modules-registered\";\nexport const ModulesReadyEvent = \"squide-modules-ready\";\nexport const MswReadyEvent = \"squide-msw-ready\";\nexport const ActiveRouteIsPublicEvent = \"squide-active-route-is-public\";\nexport const ActiveRouteIsProtectedEvent = \"squide-active-route-is-protected\";\nexport const PublicDataReadyEvent = \"squide-public-data-ready\";\nexport const ProtectedDataReadyEvent = \"squide-protected-data-ready\";\nexport const PublicDataUpdatedEvent = \"squide-public-data-updated\";\nexport const ProtectedDataUpdatedEvent = \"squide-protected-data-updated\";\nexport const DeferredRegistrationsUpdatedEvent = \"squide-deferred-registrations-updated\";\nexport const ApplicationBoostrappedEvent = \"squide-app-boostrapped\";\n\nexport interface AppRouterAction {\n type: AppRouterActionType;\n payload?: unknown;\n}\n\nexport type AppRouterDispatch = Dispatch<AppRouterAction>;\n\nfunction reducer(state: AppRouterState, action: AppRouterAction) {\n let newState = state;\n\n switch (action.type) {\n case \"modules-registered\": {\n newState = {\n ...newState,\n areModulesRegistered: true\n };\n\n break;\n }\n case \"modules-ready\": {\n newState = {\n ...newState,\n areModulesReady: true,\n // Will be set even if the app is not using deferred registrations.\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"msw-ready\": {\n newState = {\n ...newState,\n isMswReady: true\n };\n\n break;\n }\n case \"public-data-ready\": {\n newState = {\n ...newState,\n isPublicDataReady: true,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-ready\": {\n newState = {\n ...newState,\n isProtectedDataReady: true,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"public-data-updated\": {\n newState = {\n ...newState,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-updated\": {\n newState = {\n ...newState,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"feature-flags-updated\": {\n newState = {\n ...newState,\n featureFlagsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"deferred-registrations-updated\": {\n newState = {\n ...newState,\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"active-route-is-public\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"public\"\n };\n\n break;\n }\n case \"active-route-is-protected\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"protected\"\n };\n\n break;\n }\n case \"is-unauthorized\": {\n newState = {\n ...newState,\n isUnauthorized: true\n };\n\n break;\n }\n default: {\n throw new Error(`[squide] The AppRouter component state reducer doesn't support action type \"${action.type}\".`);\n }\n }\n\n return newState;\n}\n\nexport function useModuleRegistrationStatusDispatcher(runtime: FireflyRuntime, areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchModulesRegistered = useCallback(() => {\n dispatch({ type: \"modules-registered\" });\n\n logger\n .withText(\"[squide] Modules are registered.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n const dispatchModulesReady = useCallback(() => {\n dispatch({ type: \"modules-ready\" });\n\n logger\n .withText(\"[squide] Modules are ready.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n return useEffect(() => {\n if (!areModulesRegisteredValue) {\n runtime.moduleManager.registerModulesRegisteredListener(dispatchModulesRegistered);\n }\n\n if (!areModulesReadyValue) {\n runtime.moduleManager.registerModulesReadyListener(dispatchModulesReady);\n }\n\n return () => {\n runtime.moduleManager.removeModulesRegisteredListener(dispatchModulesRegistered);\n runtime.moduleManager.removeModulesReadyListener(dispatchModulesReady);\n };\n }, [areModulesRegisteredValue, areModulesReadyValue, dispatchModulesRegistered, dispatchModulesReady]);\n}\n\nexport function useMswStatusDispatcher(runtime: FireflyRuntime, isMswReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchMswReady = useCallback(() => {\n dispatch({ type: \"msw-ready\" });\n\n logger\n .withText(\"[squide] MSW is ready.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n useEffect(() => {\n if (runtime.isMswEnabled) {\n if (!isMswReadyValue) {\n runtime.mswState.addMswReadyListener(dispatchMswReady);\n }\n\n return () => {\n runtime.mswState.removeMswReadyListener(dispatchMswReady);\n };\n }\n }, [runtime, isMswReadyValue, dispatchMswReady]);\n}\n\nexport function useFeatureFlagsUpdatedDispatcher(runtime: FireflyRuntime, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchFeatureFlagsUpdated = useCallback((changes => {\n dispatch({ type: \"feature-flags-updated\" });\n\n logger\n .withText(\"[squide] Feature flags has been updated to:\")\n .withObject(changes)\n .debug();\n }) satisfies FeatureFlagSetSnapshotChangedListener, [dispatch, logger]);\n\n useEffect(() => {\n if (runtime.isLaunchDarklyEnabled) {\n runtime.featureFlagSetSnapshot.addSnapshotChangedListener(dispatchFeatureFlagsUpdated);\n\n return () => {\n runtime.featureFlagSetSnapshot.removeSnapshotChangedListener(dispatchFeatureFlagsUpdated);\n };\n }\n }, [runtime]);\n}\n\nfunction useBootstrappingCompletedDispatcher(waitState: AppRouterWaitState, state: AppRouterState) {\n const eventBus = useEventBus();\n\n const areModulesRegisteredValue = state.areModulesRegistered;\n const isBoostrapping = isBootstrapping(state);\n\n useExecuteOnce(useCallback(() => {\n if (areModulesRegisteredValue && !isBoostrapping) {\n eventBus.dispatch(ApplicationBoostrappedEvent, waitState);\n\n return true;\n }\n\n return false;\n }, [areModulesRegisteredValue, isBoostrapping, waitState, eventBus]), true);\n}\n\nlet dispatchProxyFactory: ((reactDispatch: AppRouterDispatch) => AppRouterDispatch) | undefined;\n\n// This function should only be used by tests.\nexport function __setAppReducerDispatchProxyFactory(factory: (reactDispatch: AppRouterDispatch) => AppRouterDispatch) {\n dispatchProxyFactory = factory;\n}\n\n// This function should only be used by tests.\nexport function __clearAppReducerDispatchProxy() {\n dispatchProxyFactory = undefined;\n}\n\nfunction useReducerDispatchProxy(reactDispatch: AppRouterDispatch) {\n return useMemo(() => {\n return dispatchProxyFactory ? dispatchProxyFactory(reactDispatch) : reactDispatch;\n }, [reactDispatch]);\n}\n\nfunction useEnhancedReducerDispatch(waitState: AppRouterWaitState, reducerDispatch: AppRouterDispatch) {\n const logger = useLogger();\n const appRouterStore = useAppRouterStore();\n const eventBus = useEventBus();\n\n return useCallback((action: AppRouterAction) => {\n logger\n .withText(\"[squide] The following action has been dispatched to the AppRouter reducer:\")\n .withObject(action)\n .debug();\n\n appRouterStore.dispatch({ ...action, payload: waitState });\n eventBus.dispatch(`squide-${action.type}`, waitState);\n\n reducerDispatch(action);\n }, [waitState, reducerDispatch, logger, appRouterStore, eventBus]);\n}\n\nexport function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {\n const runtime = useRuntime() as FireflyRuntime;\n const eventBus = useEventBus();\n const appRouterStore = useAppRouterStore();\n\n const isMswEnabled = runtime.isMswEnabled;\n const areModulesInitiallyRegistered = runtime.moduleManager.getAreModulesRegistered();\n const areModulesInitiallyReady = runtime.moduleManager.getAreModulesReady();\n const isMswInitiallyReady = runtime.isMswEnabled ? runtime.mswState.isReady : false;\n\n const waitState = useMemo(() => ({\n waitForMsw: isMswEnabled,\n waitForPublicData,\n waitForProtectedData\n }), [isMswEnabled, waitForPublicData, waitForProtectedData]);\n\n const initialState = useMemo(() => ({\n waitForMsw: waitState.waitForMsw,\n waitForPublicData: waitState.waitForPublicData,\n waitForProtectedData: waitState.waitForProtectedData,\n // When the modules registration functions are awaited, the event listeners are registered after the modules are registered.\n areModulesRegistered: areModulesInitiallyRegistered,\n areModulesReady: areModulesInitiallyReady,\n isMswReady: isMswInitiallyReady,\n isPublicDataReady: false,\n isProtectedDataReady: false,\n activeRouteVisibility: \"unknown\",\n isUnauthorized: false\n } satisfies AppRouterState), [waitState, areModulesInitiallyRegistered, areModulesInitiallyReady, isMswInitiallyReady]);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyRegistered) {\n appRouterStore.dispatch({ type: \"modules-registered\", payload: waitState });\n eventBus.dispatch(ModulesRegisteredEvent, waitState);\n }\n\n return true;\n }, [areModulesInitiallyRegistered, appRouterStore, eventBus, waitState]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyReady) {\n appRouterStore.dispatch({ type: \"modules-ready\", payload: waitState });\n eventBus.dispatch(ModulesReadyEvent, waitState);\n }\n\n return true;\n }, [areModulesInitiallyReady, appRouterStore, eventBus, waitState]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (isMswInitiallyReady) {\n appRouterStore.dispatch({ type: \"msw-ready\", payload: waitState });\n eventBus.dispatch(MswReadyEvent, waitState);\n }\n\n return true;\n }, [isMswInitiallyReady, appRouterStore, eventBus, waitState]), true);\n\n const [state, reactDispatch] = useReducer(reducer, initialState);\n\n const {\n areModulesRegistered: areModulesRegisteredValue,\n areModulesReady: areModulesReadyValue,\n isMswReady: isMswReadyValue\n } = state;\n\n // The dispatch proxy is strictly an utility allowing tests to mock the useReducer dispatch function. It's easier\n // than mocking the import from React.\n const dispatchProxy = useReducerDispatchProxy(reactDispatch);\n const dispatch = useEnhancedReducerDispatch(waitState, dispatchProxy);\n\n useModuleRegistrationStatusDispatcher(runtime, areModulesRegisteredValue, areModulesReadyValue, dispatch);\n useMswStatusDispatcher(runtime, isMswReadyValue, dispatch);\n useFeatureFlagsUpdatedDispatcher(runtime, dispatch);\n useBootstrappingCompletedDispatcher(waitState, state);\n\n return [state, dispatch];\n}\n"],"names":["useEventBus","useLogger","useRuntime","useCallback","useEffect","useMemo","useReducer","useAppRouterStore","useExecuteOnce","isBootstrapping","ModulesRegisteredEvent","ModulesReadyEvent","MswReadyEvent","ActiveRouteIsPublicEvent","ActiveRouteIsProtectedEvent","PublicDataReadyEvent","ProtectedDataReadyEvent","PublicDataUpdatedEvent","ProtectedDataUpdatedEvent","DeferredRegistrationsUpdatedEvent","ApplicationBoostrappedEvent","reducer","state","action","newState","Date","Error","useModuleRegistrationStatusDispatcher","runtime","areModulesRegisteredValue","areModulesReadyValue","dispatch","logger","dispatchModulesRegistered","dispatchModulesReady","useMswStatusDispatcher","isMswReadyValue","dispatchMswReady","useFeatureFlagsUpdatedDispatcher","dispatchFeatureFlagsUpdated","changes","useBootstrappingCompletedDispatcher","waitState","eventBus","isBoostrapping","dispatchProxyFactory","__setAppReducerDispatchProxyFactory","factory","__clearAppReducerDispatchProxy","undefined","useReducerDispatchProxy","reactDispatch","useEnhancedReducerDispatch","reducerDispatch","appRouterStore","useAppRouterReducer","waitForPublicData","waitForProtectedData","isMswEnabled","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","initialState","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;AAAkE;AAEiB;AAExB;AACN;AACK;AAsC1D,wFAAwF;AACxF,8DAA8D;AACvD,MAAMU,yBAAyB,4BAA4B;AAC3D,MAAMC,oBAAoB,uBAAuB;AACjD,MAAMC,gBAAgB,mBAAmB;AACzC,MAAMC,2BAA2B,gCAAgC;AACjE,MAAMC,8BAA8B,mCAAmC;AACvE,MAAMC,uBAAuB,2BAA2B;AACxD,MAAMC,0BAA0B,8BAA8B;AAC9D,MAAMC,yBAAyB,6BAA6B;AAC5D,MAAMC,4BAA4B,gCAAgC;AAClE,MAAMC,oCAAoC,wCAAwC;AAClF,MAAMC,8BAA8B,yBAAyB;AASpE,SAASC,QAAQC,KAAqB,EAAEC,MAAuB;IAC3D,IAAIC,WAAWF;IAEf,OAAQC,OAAO,IAAI;QACf,KAAK;YAAsB;gBACvBC,WAAW;oBACP,GAAGA,QAAQ;oBACX,sBAAsB;gBAC1B;gBAEA;YACJ;QACA,KAAK;YAAiB;gBAClBA,WAAW;oBACP,GAAGA,QAAQ;oBACX,iBAAiB;oBACjB,mEAAmE;oBACnE,gCAAgCC,KAAK,GAAG;gBAC5C;gBAEA;YACJ;QACA,KAAK;YAAa;gBACdD,WAAW;oBACP,GAAGA,QAAQ;oBACX,YAAY;gBAChB;gB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HAA6H;IAC7HlC,cAAcA,CAACL,WAAWA,CAAC;QACvB,IAAIyD,0BAA0B;YAC1BN,eAAe,QAAQ,CAAC;gBAAE,MAAM;gBAAiB,SAASZ;YAAU;YACpEC,SAAS,QAAQ,CAAChC,mBAAmB+B;QACzC;QAEA,OAAO;IACX,GAAG;QAACkB;QAA0BN;QAAgBX;QAAUD;KAAU,GAAG;IAErE,2IAA2I;IAC3I,6HAA6H;IAC7HlC,cAAcA,CAACL,WAAWA,CAAC;QACvB,IAAI0D,qBAAqB;YACrBP,eAAe,QAAQ,CAAC;gBAAE,MAAM;gBAAa,SAASZ;YAAU;YAChEC,SAAS,QAAQ,CAAC/B,eAAe8B;QACrC;QAEA,OAAO;IACX,GAAG;QAACmB;QAAqBP;QAAgBX;QAAUD;KAAU,GAAG;IAEhE,MAAM,CAACpB,OAAO6B,cAAc,GAAG7C,UAAUA,CAACe,SAASyC;IAEnD,MAAM,EACF,sBAAsBjC,yBAAyB,EAC/C,iBAAiBC,oBAAoB,EACrC,YAAYM,eAAe,EAC9B,GAAGd;IAEJ,iHAAiH;IACjH,sCAAsC;IACtC,MAAMyC,gBAAgBb,wBAAwBC;IAC9C,MAAMpB,WAAWqB,2BAA2BV,WAAWqB;IAEvDpC,sCAAsCC,SAASC,2BAA2BC,sBAAsBC;IAChGI,uBAAuBP,SAASQ,iBAAiBL;IACjDO,iCAAiCV,SAASG;IAC1CU,oCAAoCC,WAAWpB;IAE/C,OAAO;QAACA;QAAOS;KAAS;AAC5B"}
|
|
1
|
+
{"version":3,"file":"AppRouterReducer.js","sources":["../src/AppRouterReducer.ts"],"sourcesContent":["import { useEventBus, useLogger, useRuntime } from \"@squide/core\";\nimport type { FeatureFlagSetSnapshotChangedListener } from \"@squide/launch-darkly\";\nimport { useCallback, useEffect, useMemo, useReducer, type Dispatch } from \"react\";\nimport type { FireflyRuntime } from \"./FireflyRuntime.tsx\";\nimport { useAppRouterStore } from \"./useAppRouterStore.ts\";\nimport { useExecuteOnce } from \"./useExecuteOnce.ts\";\nimport { isBootstrapping } from \"./useIsBootstrapping.ts\";\n\nexport type ActiveRouteVisiblity = \"unknown\" | \"public\" | \"protected\";\n\nexport interface AppRouterWaitState {\n waitForMsw: boolean;\n waitForPublicData: boolean;\n waitForProtectedData: boolean;\n}\n\nexport interface AppRouterState extends AppRouterWaitState {\n areModulesRegistered: boolean;\n areModulesReady: boolean;\n isMswReady: boolean;\n isPublicDataReady: boolean;\n isProtectedDataReady: boolean;\n publicDataUpdatedAt?: number;\n protectedDataUpdatedAt?: number;\n featureFlagsUpdatedAt?: number;\n deferredRegistrationsUpdatedAt?: number;\n activeRouteVisibility: ActiveRouteVisiblity;\n isUnauthorized: boolean;\n}\n\nexport type AppRouterActionType =\n | \"modules-registered\"\n | \"modules-ready\"\n | \"msw-ready\"\n | \"public-data-ready\"\n | \"protected-data-ready\"\n | \"public-data-updated\"\n | \"protected-data-updated\"\n | \"feature-flags-updated\"\n | \"deferred-registrations-updated\"\n | \"active-route-is-public\"\n | \"active-route-is-protected\"\n | \"is-unauthorized\";\n\n// The followings event const are a concatenation of \"squide-\" with AppRouterActionType.\n// They are dispatched by the useEnhancedReducerDispatch hook.\nexport const ModulesRegisteredEvent = \"squide-modules-registered\";\nexport const ModulesReadyEvent = \"squide-modules-ready\";\nexport const MswReadyEvent = \"squide-msw-ready\";\nexport const ActiveRouteIsPublicEvent = \"squide-active-route-is-public\";\nexport const ActiveRouteIsProtectedEvent = \"squide-active-route-is-protected\";\nexport const PublicDataReadyEvent = \"squide-public-data-ready\";\nexport const ProtectedDataReadyEvent = \"squide-protected-data-ready\";\nexport const PublicDataUpdatedEvent = \"squide-public-data-updated\";\nexport const ProtectedDataUpdatedEvent = \"squide-protected-data-updated\";\nexport const DeferredRegistrationsUpdatedEvent = \"squide-deferred-registrations-updated\";\nexport const ApplicationBoostrappedEvent = \"squide-app-boostrapped\";\n\nexport interface AppRouterAction {\n type: AppRouterActionType;\n payload?: unknown;\n}\n\nexport type AppRouterDispatch = Dispatch<AppRouterAction>;\n\nfunction reducer(state: AppRouterState, action: AppRouterAction) {\n let newState = state;\n\n switch (action.type) {\n case \"modules-registered\": {\n newState = {\n ...newState,\n areModulesRegistered: true\n };\n\n break;\n }\n case \"modules-ready\": {\n newState = {\n ...newState,\n areModulesRegistered: true,\n areModulesReady: true,\n // Will be set even if the app is not using deferred registrations.\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"msw-ready\": {\n newState = {\n ...newState,\n isMswReady: true\n };\n\n break;\n }\n case \"public-data-ready\": {\n newState = {\n ...newState,\n isPublicDataReady: true,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-ready\": {\n newState = {\n ...newState,\n isProtectedDataReady: true,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"public-data-updated\": {\n newState = {\n ...newState,\n publicDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"protected-data-updated\": {\n newState = {\n ...newState,\n protectedDataUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"feature-flags-updated\": {\n newState = {\n ...newState,\n featureFlagsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"deferred-registrations-updated\": {\n newState = {\n ...newState,\n deferredRegistrationsUpdatedAt: Date.now()\n };\n\n break;\n }\n case \"active-route-is-public\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"public\"\n };\n\n break;\n }\n case \"active-route-is-protected\": {\n newState = {\n ...newState,\n activeRouteVisibility: \"protected\"\n };\n\n break;\n }\n case \"is-unauthorized\": {\n newState = {\n ...newState,\n isUnauthorized: true\n };\n\n break;\n }\n default: {\n throw new Error(`[squide] The AppRouter component state reducer doesn't support action type \"${action.type}\".`);\n }\n }\n\n return newState;\n}\n\nexport function useModuleRegistrationStatusDispatcher(runtime: FireflyRuntime, areModulesRegisteredValue: boolean, areModulesReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchModulesRegistered = useCallback(() => {\n dispatch({ type: \"modules-registered\" });\n\n logger\n .withText(\"[squide] Modules are registered.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n const dispatchModulesReady = useCallback(() => {\n dispatch({ type: \"modules-ready\" });\n\n logger\n .withText(\"[squide] Modules are ready.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n return useEffect(() => {\n if (!areModulesRegisteredValue) {\n runtime.moduleManager.registerModulesRegisteredListener(dispatchModulesRegistered);\n }\n\n if (!areModulesReadyValue) {\n runtime.moduleManager.registerModulesReadyListener(dispatchModulesReady);\n }\n\n return () => {\n runtime.moduleManager.removeModulesRegisteredListener(dispatchModulesRegistered);\n runtime.moduleManager.removeModulesReadyListener(dispatchModulesReady);\n };\n }, [runtime, areModulesRegisteredValue, areModulesReadyValue, dispatchModulesRegistered, dispatchModulesReady]);\n}\n\nexport function useMswStatusDispatcher(runtime: FireflyRuntime, isMswReadyValue: boolean, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchMswReady = useCallback(() => {\n dispatch({ type: \"msw-ready\" });\n\n logger\n .withText(\"[squide] MSW is ready.\", {\n style: {\n color: \"green\"\n }\n })\n .information();\n }, [dispatch, logger]);\n\n useEffect(() => {\n if (runtime.isMswEnabled) {\n if (!isMswReadyValue) {\n runtime.mswState.addMswReadyListener(dispatchMswReady);\n }\n\n return () => {\n runtime.mswState.removeMswReadyListener(dispatchMswReady);\n };\n }\n }, [runtime, isMswReadyValue, dispatchMswReady]);\n}\n\nexport function useFeatureFlagsUpdatedDispatcher(runtime: FireflyRuntime, dispatch: AppRouterDispatch) {\n const logger = useLogger();\n\n const dispatchFeatureFlagsUpdated = useCallback<FeatureFlagSetSnapshotChangedListener>(changes => {\n dispatch({ type: \"feature-flags-updated\" });\n\n logger\n .withText(\"[squide] Feature flags has been updated to:\")\n .withObject(changes)\n .debug();\n }, [dispatch, logger]);\n\n useEffect(() => {\n if (runtime.isLaunchDarklyEnabled) {\n runtime.featureFlagSetSnapshot.addSnapshotChangedListener(dispatchFeatureFlagsUpdated);\n\n return () => {\n runtime.featureFlagSetSnapshot.removeSnapshotChangedListener(dispatchFeatureFlagsUpdated);\n };\n }\n }, [runtime, dispatchFeatureFlagsUpdated]);\n}\n\nfunction useBootstrappingCompletedDispatcher(waitState: AppRouterWaitState, state: AppRouterState) {\n const eventBus = useEventBus();\n\n const areModulesRegisteredValue = state.areModulesRegistered;\n const isBoostrapping = isBootstrapping(state);\n\n useExecuteOnce(useCallback(() => {\n if (areModulesRegisteredValue && !isBoostrapping) {\n eventBus.dispatch(ApplicationBoostrappedEvent, waitState);\n\n return true;\n }\n\n return false;\n }, [areModulesRegisteredValue, isBoostrapping, waitState, eventBus]), true);\n}\n\nlet dispatchProxyFactory: ((reactDispatch: AppRouterDispatch) => AppRouterDispatch) | undefined;\n\n// This function should only be used by tests.\nexport function __setAppReducerDispatchProxyFactory(factory: (reactDispatch: AppRouterDispatch) => AppRouterDispatch) {\n dispatchProxyFactory = factory;\n}\n\n// This function should only be used by tests.\nexport function __clearAppReducerDispatchProxy() {\n dispatchProxyFactory = undefined;\n}\n\nfunction useReducerDispatchProxy(reactDispatch: AppRouterDispatch) {\n return useMemo(() => {\n return dispatchProxyFactory ? dispatchProxyFactory(reactDispatch) : reactDispatch;\n }, [reactDispatch]);\n}\n\nfunction useEnhancedReducerDispatch(waitState: AppRouterWaitState, reducerDispatch: AppRouterDispatch) {\n const logger = useLogger();\n const appRouterStore = useAppRouterStore();\n const eventBus = useEventBus();\n\n return useCallback((action: AppRouterAction) => {\n logger\n .withText(\"[squide] The following action has been dispatched to the AppRouter reducer:\")\n .withObject(action)\n .debug();\n\n appRouterStore.dispatch({ ...action, payload: waitState });\n eventBus.dispatch(`squide-${action.type}`, waitState);\n\n reducerDispatch(action);\n }, [waitState, reducerDispatch, logger, appRouterStore, eventBus]);\n}\n\nexport function useAppRouterReducer(waitForPublicData: boolean, waitForProtectedData: boolean): [AppRouterState, AppRouterDispatch] {\n const runtime = useRuntime() as FireflyRuntime;\n const eventBus = useEventBus();\n const appRouterStore = useAppRouterStore();\n\n const isMswEnabled = runtime.isMswEnabled;\n const areModulesInitiallyRegistered = runtime.moduleManager.getAreModulesRegistered();\n const areModulesInitiallyReady = runtime.moduleManager.getAreModulesReady();\n const isMswInitiallyReady = runtime.isMswEnabled ? runtime.mswState.isReady : false;\n\n const waitState = useMemo(() => ({\n waitForMsw: isMswEnabled,\n waitForPublicData,\n waitForProtectedData\n }), [isMswEnabled, waitForPublicData, waitForProtectedData]);\n\n const initialState = useMemo(() => ({\n waitForMsw: waitState.waitForMsw,\n waitForPublicData: waitState.waitForPublicData,\n waitForProtectedData: waitState.waitForProtectedData,\n // When the modules registration functions are awaited, the event listeners are registered after the modules are registered.\n areModulesRegistered: areModulesInitiallyRegistered,\n areModulesReady: areModulesInitiallyReady,\n isMswReady: isMswInitiallyReady,\n isPublicDataReady: false,\n isProtectedDataReady: false,\n activeRouteVisibility: \"unknown\",\n isUnauthorized: false\n } satisfies AppRouterState), [waitState, areModulesInitiallyRegistered, areModulesInitiallyReady, isMswInitiallyReady]);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyRegistered) {\n appRouterStore.dispatch({ type: \"modules-registered\", payload: waitState });\n eventBus.dispatch(ModulesRegisteredEvent, waitState);\n }\n\n return true;\n }, [areModulesInitiallyRegistered, appRouterStore, eventBus, waitState]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (areModulesInitiallyReady) {\n appRouterStore.dispatch({ type: \"modules-ready\", payload: waitState });\n eventBus.dispatch(ModulesReadyEvent, waitState);\n }\n\n return true;\n }, [areModulesInitiallyReady, appRouterStore, eventBus, waitState]), true);\n\n // When modules are initially registered, the reducer action will never be dispatched, therefore the event would not be dispatched as well.\n // To ensure the bootstrapping events sequencing, the event is manually dispatched when the modules are initially registered.\n useExecuteOnce(useCallback(() => {\n if (isMswInitiallyReady) {\n appRouterStore.dispatch({ type: \"msw-ready\", payload: waitState });\n eventBus.dispatch(MswReadyEvent, waitState);\n }\n\n return true;\n }, [isMswInitiallyReady, appRouterStore, eventBus, waitState]), true);\n\n const [state, reactDispatch] = useReducer(reducer, initialState);\n\n const {\n areModulesRegistered: areModulesRegisteredValue,\n areModulesReady: areModulesReadyValue,\n isMswReady: isMswReadyValue\n } = state;\n\n // The dispatch proxy is strictly an utility allowing tests to mock the useReducer dispatch function. It's easier\n // than mocking the import from React.\n const dispatchProxy = useReducerDispatchProxy(reactDispatch);\n const dispatch = useEnhancedReducerDispatch(waitState, dispatchProxy);\n\n useModuleRegistrationStatusDispatcher(runtime, areModulesRegisteredValue, areModulesReadyValue, dispatch);\n useMswStatusDispatcher(runtime, isMswReadyValue, dispatch);\n useFeatureFlagsUpdatedDispatcher(runtime, dispatch);\n useBootstrappingCompletedDispatcher(waitState, state);\n\n return [state, dispatch];\n}\n"],"names":["useEventBus","useLogger","useRuntime","useCallback","useEffect","useMemo","useReducer","useAppRouterStore","useExecuteOnce","isBootstrapping","ModulesRegisteredEvent","ModulesReadyEvent","MswReadyEvent","ActiveRouteIsPublicEvent","ActiveRouteIsProtectedEvent","PublicDataReadyEvent","ProtectedDataReadyEvent","PublicDataUpdatedEvent","ProtectedDataUpdatedEvent","DeferredRegistrationsUpdatedEvent","ApplicationBoostrappedEvent","reducer","state","action","newState","Date","Error","useModuleRegistrationStatusDispatcher","runtime","areModulesRegisteredValue","areModulesReadyValue","dispatch","logger","dispatchModulesRegistered","dispatchModulesReady","useMswStatusDispatcher","isMswReadyValue","dispatchMswReady","useFeatureFlagsUpdatedDispatcher","dispatchFeatureFlagsUpdated","changes","useBootstrappingCompletedDispatcher","waitState","eventBus","isBoostrapping","dispatchProxyFactory","__setAppReducerDispatchProxyFactory","factory","__clearAppReducerDispatchProxy","undefined","useReducerDispatchProxy","reactDispatch","useEnhancedReducerDispatch","reducerDispatch","appRouterStore","useAppRouterReducer","waitForPublicData","waitForProtectedData","isMswEnabled","areModulesInitiallyRegistered","areModulesInitiallyReady","isMswInitiallyReady","initialState","dispatchProxy"],"mappings":";;;;;;;;;;;;;;;;;AAAkE;AAEiB;AAExB;AACN;AACK;AAsC1D,wFAAwF;AACxF,8DAA8D;AACvD,MAAMU,yBAAyB,4BAA4B;AAC3D,MAAMC,oBAAoB,uBAAuB;AACjD,MAAMC,gBAAgB,mBAAmB;AACzC,MAAMC,2BAA2B,gCAAgC;AACjE,MAAMC,8BAA8B,mCAAmC;AACvE,MAAMC,uBAAuB,2BAA2B;AACxD,MAAMC,0BAA0B,8BAA8B;AAC9D,MAAMC,yBAAyB,6BAA6B;AAC5D,MAAMC,4BAA4B,gCAAgC;AAClE,MAAMC,oCAAoC,wCAAwC;AAClF,MAAMC,8BAA8B,yBAAyB;AASpE,SAASC,QAAQC,KAAqB,EAAEC,MAAuB;IAC3D,IAAIC,WAAWF;IAEf,OAAQC,OAAO,IAAI;QACf,KAAK;YAAsB;gBACvBC,WAAW;oBACP,GAAGA,QAAQ;oBACX,sBAAsB;gBAC1B;gBAEA;YACJ;QACA,KAAK;YAAiB;gBAClBA,WAAW;oBACP,GAAGA,QAAQ;oBACX,sBAAsB;oBACtB,iBAAiB;oBACjB,mEAAmE;oBACnE,gCAAgCC,KAAK,GAAG;gBAC5C;gBAEA;YACJ;QACA,KAAK;YAAa;gBACdD,WAAW;oBACP,GAAGA,QAAQ;oBACX,YAAY;gBAChB;gBAEA;YACJ;QACA,KAAK;YAAqB;gBACtBA,WAAW;oBACP,GAAGA,QAAQ;oBACX,mBAAmB;oBACnB,qBAAqBC,KAAK,GAAG;gBACjC;gBAEA;YACJ;QACA,KAAK;YAAwB;gBACzBD,WAAW;oBACP,GAAGA,QAAQ;oBACX,sBAAsB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O;IACX,GAAG;QAACkB;QAA0BN;QAAgBX;QAAUD;KAAU,GAAG;IAErE,2IAA2I;IAC3I,6HAA6H;IAC7HlC,cAAcA,CAACL,WAAWA,CAAC;QACvB,IAAI0D,qBAAqB;YACrBP,eAAe,QAAQ,CAAC;gBAAE,MAAM;gBAAa,SAASZ;YAAU;YAChEC,SAAS,QAAQ,CAAC/B,eAAe8B;QACrC;QAEA,OAAO;IACX,GAAG;QAACmB;QAAqBP;QAAgBX;QAAUD;KAAU,GAAG;IAEhE,MAAM,CAACpB,OAAO6B,cAAc,GAAG7C,UAAUA,CAACe,SAASyC;IAEnD,MAAM,EACF,sBAAsBjC,yBAAyB,EAC/C,iBAAiBC,oBAAoB,EACrC,YAAYM,eAAe,EAC9B,GAAGd;IAEJ,iHAAiH;IACjH,sCAAsC;IACtC,MAAMyC,gBAAgBb,wBAAwBC;IAC9C,MAAMpB,WAAWqB,2BAA2BV,WAAWqB;IAEvDpC,sCAAsCC,SAASC,2BAA2BC,sBAAsBC;IAChGI,uBAAuBP,SAASQ,iBAAiBL;IACjDO,iCAAiCV,SAASG;IAC1CU,oCAAoCC,WAAWpB;IAE/C,OAAO;QAACA;QAAOS;KAAS;AAC5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "@squide/core";
|
|
2
2
|
export { EnvironmentVariablesPlugin, EnvironmentVariablesPluginName, getEnvironmentVariablesPlugin, useEnvironmentVariable, useEnvironmentVariables, type EnvironmentVariableKey, type EnvironmentVariables, type EnvironmentVariablesPluginOptions } from "@squide/env-vars";
|
|
3
|
-
export { FeatureFlagSetSnapshot, getFeatureFlag, getLaunchDarklyPlugin, InMemoryLaunchDarklyClient, LaunchDarklyClientNotifier, LaunchDarklyPlugin, LaunchDarklyPluginName, useFeatureFlag, useFeatureFlags, useLaunchDarklyClient, type FeatureFlagKey, type FeatureFlags, type FeatureFlagSetSnapshotChangedListener, type InMemoryLaunchDarklyClientOptions, type LaunchDarklyClientListener } from "@squide/launch-darkly";
|
|
3
|
+
export { createLocalStorageLaunchDarklyClient, FeatureFlagSetSnapshot, getFeatureFlag, getLaunchDarklyPlugin, InMemoryLaunchDarklyClient, isEditableLaunchDarklyClient, LaunchDarklyClientNotifier, LaunchDarklyClientTransaction, LaunchDarklyPlugin, LaunchDarklyPluginName, LocalStorageLaunchDarklyClient, useFeatureFlag, useFeatureFlags, useLaunchDarklyClient, type CommitTransactionFunction, type EditableLaunchDarklyClient, type FeatureFlagKey, type FeatureFlags, type FeatureFlagSetSnapshotChangedListener, type InMemoryLaunchDarklyClientOptions, type LaunchDarklyClientListener, type LocalStorageLaunchDarklyClientOptions, type SetFeatureFlagOptions, type UndoTransactionFunction } from "@squide/launch-darkly";
|
|
4
4
|
export { getMswPlugin, MswPlugin, MswPluginName, MswState, type MswPluginOptions, type MswPluginRegisterRequestHandlersOptions, type MswReadyListener, type MswStateOptions } from "@squide/msw";
|
|
5
5
|
export * from "@squide/react-router";
|
|
6
6
|
export type { FireflyPlugin } from "./FireflyPlugin.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnvironmentVariablesPlugin, EnvironmentVariablesPluginName, getEnvironmentVariablesPlugin, useEnvironmentVariable, useEnvironmentVariables } from "@squide/env-vars";
|
|
2
|
-
import { FeatureFlagSetSnapshot, InMemoryLaunchDarklyClient, LaunchDarklyClientNotifier, LaunchDarklyPlugin, LaunchDarklyPluginName, getFeatureFlag, getLaunchDarklyPlugin, useFeatureFlag, useFeatureFlags, useLaunchDarklyClient } from "@squide/launch-darkly";
|
|
2
|
+
import { FeatureFlagSetSnapshot, InMemoryLaunchDarklyClient, LaunchDarklyClientNotifier, LaunchDarklyClientTransaction, LaunchDarklyPlugin, LaunchDarklyPluginName, LocalStorageLaunchDarklyClient, createLocalStorageLaunchDarklyClient, getFeatureFlag, getLaunchDarklyPlugin, isEditableLaunchDarklyClient, useFeatureFlag, useFeatureFlags, useLaunchDarklyClient } from "@squide/launch-darkly";
|
|
3
3
|
import { MswPlugin, MswPluginName, MswState, getMswPlugin } from "@squide/msw";
|
|
4
4
|
import { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent } from "./AppRouterReducer.js";
|
|
5
5
|
export * from "@squide/core";
|
|
@@ -63,6 +63,6 @@ export * from "./initializeFirefly.js";
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
export { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, EnvironmentVariablesPlugin, EnvironmentVariablesPluginName, FeatureFlagSetSnapshot, InMemoryLaunchDarklyClient, LaunchDarklyClientNotifier, LaunchDarklyPlugin, LaunchDarklyPluginName, ModulesReadyEvent, ModulesRegisteredEvent, MswPlugin, MswPluginName, MswReadyEvent, MswState, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent, getEnvironmentVariablesPlugin, getFeatureFlag, getLaunchDarklyPlugin, getMswPlugin, useEnvironmentVariable, useEnvironmentVariables, useFeatureFlag, useFeatureFlags, useLaunchDarklyClient };
|
|
66
|
+
export { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, EnvironmentVariablesPlugin, EnvironmentVariablesPluginName, FeatureFlagSetSnapshot, InMemoryLaunchDarklyClient, LaunchDarklyClientNotifier, LaunchDarklyClientTransaction, LaunchDarklyPlugin, LaunchDarklyPluginName, LocalStorageLaunchDarklyClient, ModulesReadyEvent, ModulesRegisteredEvent, MswPlugin, MswPluginName, MswReadyEvent, MswState, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent, createLocalStorageLaunchDarklyClient, getEnvironmentVariablesPlugin, getFeatureFlag, getLaunchDarklyPlugin, getMswPlugin, isEditableLaunchDarklyClient, useEnvironmentVariable, useEnvironmentVariables, useFeatureFlag, useFeatureFlags, useLaunchDarklyClient };
|
|
67
67
|
|
|
68
68
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"@squide/core\";\nexport {\n EnvironmentVariablesPlugin,\n EnvironmentVariablesPluginName,\n getEnvironmentVariablesPlugin,\n useEnvironmentVariable,\n useEnvironmentVariables,\n type EnvironmentVariableKey,\n type EnvironmentVariables,\n type EnvironmentVariablesPluginOptions\n} from \"@squide/env-vars\";\nexport {\n FeatureFlagSetSnapshot,\n getFeatureFlag,\n getLaunchDarklyPlugin,\n InMemoryLaunchDarklyClient,\n LaunchDarklyClientNotifier,\n LaunchDarklyPlugin,\n LaunchDarklyPluginName,\n useFeatureFlag,\n useFeatureFlags,\n useLaunchDarklyClient,\n type FeatureFlagKey,\n type FeatureFlags,\n type FeatureFlagSetSnapshotChangedListener,\n type InMemoryLaunchDarklyClientOptions,\n type LaunchDarklyClientListener\n} from \"@squide/launch-darkly\";\nexport {\n getMswPlugin,\n MswPlugin,\n MswPluginName,\n MswState,\n type MswPluginOptions,\n type MswPluginRegisterRequestHandlersOptions,\n type MswReadyListener,\n type MswStateOptions\n} from \"@squide/msw\";\nexport * from \"@squide/react-router\";\n\nexport type { FireflyPlugin } from \"./FireflyPlugin.ts\";\nexport * from \"./FireflyProvider.tsx\";\nexport * from \"./FireflyRuntime.tsx\";\n\nexport * from \"./AppRouter.tsx\";\nexport {\n ActiveRouteIsProtectedEvent,\n ActiveRouteIsPublicEvent,\n ApplicationBoostrappedEvent,\n DeferredRegistrationsUpdatedEvent,\n ModulesReadyEvent,\n ModulesRegisteredEvent,\n MswReadyEvent,\n ProtectedDataReadyEvent,\n ProtectedDataUpdatedEvent,\n PublicDataReadyEvent,\n PublicDataUpdatedEvent\n} from \"./AppRouterReducer.ts\";\n\nexport * from \"./AppRouterStore.ts\";\nexport * from \"./GlobalDataQueriesError.ts\";\nexport * from \"./useCanFetchProtectedData.ts\";\nexport * from \"./useCanFetchPublicData.ts\";\nexport * from \"./useCanRegisterDeferredRegistrations.ts\";\nexport * from \"./useCanUpdateDeferredRegistrations.ts\";\nexport * from \"./useDeferredRegistrations.ts\";\nexport * from \"./useIsActiveRouteProtected.ts\";\nexport * from \"./useIsBootstrapping.ts\";\nexport * from \"./useNavigationItems.ts\";\nexport * from \"./useProtectedDataHandler.ts\";\nexport * from \"./useProtectedDataQueries.ts\";\nexport * from \"./usePublicDataHandler.ts\";\nexport * from \"./usePublicDataQueries.ts\";\nexport * from \"./useRegisterDeferredRegistrations.ts\";\nexport * from \"./useStrictRegistrationMode.ts\";\nexport * from \"./useUpdateDeferredRegistrations.ts\";\n\nexport * from \"./initializeFirefly.ts\";\n\n"],"names":["EnvironmentVariablesPlugin","EnvironmentVariablesPluginName","getEnvironmentVariablesPlugin","useEnvironmentVariable","useEnvironmentVariables","FeatureFlagSetSnapshot","getFeatureFlag","getLaunchDarklyPlugin","InMemoryLaunchDarklyClient","LaunchDarklyClientNotifier","LaunchDarklyPlugin","LaunchDarklyPluginName","useFeatureFlag","useFeatureFlags","useLaunchDarklyClient","getMswPlugin","MswPlugin","MswPluginName","MswState","ActiveRouteIsProtectedEvent","ActiveRouteIsPublicEvent","ApplicationBoostrappedEvent","DeferredRegistrationsUpdatedEvent","ModulesReadyEvent","ModulesRegisteredEvent","MswReadyEvent","ProtectedDataReadyEvent","ProtectedDataUpdatedEvent","PublicDataReadyEvent","PublicDataUpdatedEvent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA6B;AAUH;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"@squide/core\";\nexport {\n EnvironmentVariablesPlugin,\n EnvironmentVariablesPluginName,\n getEnvironmentVariablesPlugin,\n useEnvironmentVariable,\n useEnvironmentVariables,\n type EnvironmentVariableKey,\n type EnvironmentVariables,\n type EnvironmentVariablesPluginOptions\n} from \"@squide/env-vars\";\nexport {\n createLocalStorageLaunchDarklyClient,\n FeatureFlagSetSnapshot,\n getFeatureFlag,\n getLaunchDarklyPlugin,\n InMemoryLaunchDarklyClient,\n isEditableLaunchDarklyClient,\n LaunchDarklyClientNotifier,\n LaunchDarklyClientTransaction,\n LaunchDarklyPlugin,\n LaunchDarklyPluginName,\n LocalStorageLaunchDarklyClient,\n useFeatureFlag,\n useFeatureFlags,\n useLaunchDarklyClient,\n type CommitTransactionFunction,\n type EditableLaunchDarklyClient,\n type FeatureFlagKey,\n type FeatureFlags,\n type FeatureFlagSetSnapshotChangedListener,\n type InMemoryLaunchDarklyClientOptions,\n type LaunchDarklyClientListener,\n type LocalStorageLaunchDarklyClientOptions,\n type SetFeatureFlagOptions,\n type UndoTransactionFunction\n} from \"@squide/launch-darkly\";\nexport {\n getMswPlugin,\n MswPlugin,\n MswPluginName,\n MswState,\n type MswPluginOptions,\n type MswPluginRegisterRequestHandlersOptions,\n type MswReadyListener,\n type MswStateOptions\n} from \"@squide/msw\";\nexport * from \"@squide/react-router\";\n\nexport type { FireflyPlugin } from \"./FireflyPlugin.ts\";\nexport * from \"./FireflyProvider.tsx\";\nexport * from \"./FireflyRuntime.tsx\";\n\nexport * from \"./AppRouter.tsx\";\nexport {\n ActiveRouteIsProtectedEvent,\n ActiveRouteIsPublicEvent,\n ApplicationBoostrappedEvent,\n DeferredRegistrationsUpdatedEvent,\n ModulesReadyEvent,\n ModulesRegisteredEvent,\n MswReadyEvent,\n ProtectedDataReadyEvent,\n ProtectedDataUpdatedEvent,\n PublicDataReadyEvent,\n PublicDataUpdatedEvent\n} from \"./AppRouterReducer.ts\";\n\nexport * from \"./AppRouterStore.ts\";\nexport * from \"./GlobalDataQueriesError.ts\";\nexport * from \"./useCanFetchProtectedData.ts\";\nexport * from \"./useCanFetchPublicData.ts\";\nexport * from \"./useCanRegisterDeferredRegistrations.ts\";\nexport * from \"./useCanUpdateDeferredRegistrations.ts\";\nexport * from \"./useDeferredRegistrations.ts\";\nexport * from \"./useIsActiveRouteProtected.ts\";\nexport * from \"./useIsBootstrapping.ts\";\nexport * from \"./useNavigationItems.ts\";\nexport * from \"./useProtectedDataHandler.ts\";\nexport * from \"./useProtectedDataQueries.ts\";\nexport * from \"./usePublicDataHandler.ts\";\nexport * from \"./usePublicDataQueries.ts\";\nexport * from \"./useRegisterDeferredRegistrations.ts\";\nexport * from \"./useStrictRegistrationMode.ts\";\nexport * from \"./useUpdateDeferredRegistrations.ts\";\n\nexport * from \"./initializeFirefly.ts\";\n\n"],"names":["EnvironmentVariablesPlugin","EnvironmentVariablesPluginName","getEnvironmentVariablesPlugin","useEnvironmentVariable","useEnvironmentVariables","createLocalStorageLaunchDarklyClient","FeatureFlagSetSnapshot","getFeatureFlag","getLaunchDarklyPlugin","InMemoryLaunchDarklyClient","isEditableLaunchDarklyClient","LaunchDarklyClientNotifier","LaunchDarklyClientTransaction","LaunchDarklyPlugin","LaunchDarklyPluginName","LocalStorageLaunchDarklyClient","useFeatureFlag","useFeatureFlags","useLaunchDarklyClient","getMswPlugin","MswPlugin","MswPluginName","MswState","ActiveRouteIsProtectedEvent","ActiveRouteIsPublicEvent","ApplicationBoostrappedEvent","DeferredRegistrationsUpdatedEvent","ModulesReadyEvent","ModulesRegisteredEvent","MswReadyEvent","ProtectedDataReadyEvent","ProtectedDataUpdatedEvent","PublicDataReadyEvent","PublicDataUpdatedEvent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA6B;AAUH;AA0BK;AAUV;AACgB;AAGC;AACD;AAEL;AAaD;AAEK;AACQ;AACE;AACH;AACc;AACF;AACT;AACC;AACP;AACA;AACK;AACA;AACH;AACA;AACY;AACP;AACK;AAEb"}
|
package/dist/useExecuteOnce.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExecuteOnce.js","sources":["../src/useExecuteOnce.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\n\n// Not using useEffect or useLayoutEffect because this utility hook is often used to dispatch events\n// and it messed with the events dispatch order.\nexport function useExecuteOnce(fct: () => boolean, inline: boolean = false) {\n const triggered = useRef(false);\n\n const onceFct = useCallback(() => {\n if (!triggered.current) {\n const result = fct();\n\n if (result) {\n triggered.current = true;\n }\n }\n }, [fct]);\n\n if (inline) {\n onceFct();\n }\n\n return onceFct;\n}\n"],"names":["useCallback","useRef","useExecuteOnce","fct","inline","triggered","onceFct","result"],"mappings":";;;;;AAA4C;AAE5C,oGAAoG;AACpG,gDAAgD;AACzC,SAASE,eAAeC,GAAkB,EAAEC,SAAkB,KAAK;IACtE,MAAMC,YAAYJ,MAAMA,CAAC;IAEzB,MAAMK,UAAUN,WAAWA,CAAC;QACxB,IAAI,CAACK,UAAU,OAAO,EAAE;YACpB,MAAME,SAASJ;YAEf,IAAII,QAAQ;gBACRF,UAAU,OAAO,GAAG;YACxB;QACJ;IACJ,GAAG;QAACF;KAAI;IAER,IAAIC,QAAQ;
|
|
1
|
+
{"version":3,"file":"useExecuteOnce.js","sources":["../src/useExecuteOnce.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\n\n// Not using useEffect or useLayoutEffect because this utility hook is often used to dispatch events\n// and it messed with the events dispatch order.\nexport function useExecuteOnce(fct: () => boolean, inline: boolean = false) {\n const triggered = useRef(false);\n\n const onceFct = useCallback(() => {\n if (!triggered.current) {\n const result = fct();\n\n if (result) {\n triggered.current = true;\n }\n }\n }, [fct]);\n\n if (inline) {\n // eslint-disable-next-line react-hooks/refs\n onceFct();\n }\n\n return onceFct;\n}\n"],"names":["useCallback","useRef","useExecuteOnce","fct","inline","triggered","onceFct","result"],"mappings":";;;;;AAA4C;AAE5C,oGAAoG;AACpG,gDAAgD;AACzC,SAASE,eAAeC,GAAkB,EAAEC,SAAkB,KAAK;IACtE,MAAMC,YAAYJ,MAAMA,CAAC;IAEzB,MAAMK,UAAUN,WAAWA,CAAC;QACxB,IAAI,CAACK,UAAU,OAAO,EAAE;YACpB,MAAME,SAASJ;YAEf,IAAII,QAAQ;gBACRF,UAAU,OAAO,GAAG;YACxB;QACJ;IACJ,GAAG;QAACF;KAAI;IAER,IAAIC,QAAQ;QACR,4CAA4C;QAC5CE;IACJ;IAEA,OAAOA;AACX"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "16.1.
|
|
4
|
+
"version": "16.1.7",
|
|
5
5
|
"description": "Squide bundle for the firefly technology stack.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
],
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@opentelemetry/api": "^1.9.0",
|
|
36
|
-
"@tanstack/react-query": "^5.90.
|
|
36
|
+
"@tanstack/react-query": "^5.90.20",
|
|
37
37
|
"launchdarkly-js-client-sdk": "^3.9.0",
|
|
38
38
|
"msw": "^2.12.7",
|
|
39
39
|
"react": "^18.0.0 || ^19.0.0",
|
|
40
40
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
41
|
-
"react-router": "^7.
|
|
41
|
+
"react-router": "^7.13.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"@opentelemetry/api": {
|
|
@@ -49,35 +49,36 @@
|
|
|
49
49
|
"@workleap-telemetry/core": "^1.0.7",
|
|
50
50
|
"@workleap/logging": "^1.3.4",
|
|
51
51
|
"uuid": "^13.0.0",
|
|
52
|
-
"@squide/core": "6.1.
|
|
53
|
-
"@squide/env-vars": "1.4.
|
|
54
|
-
"@squide/launch-darkly": "1.0.
|
|
55
|
-
"@squide/msw": "4.0.
|
|
56
|
-
"@squide/react-router": "8.1.
|
|
52
|
+
"@squide/core": "6.1.12",
|
|
53
|
+
"@squide/env-vars": "1.4.15",
|
|
54
|
+
"@squide/launch-darkly": "1.0.6",
|
|
55
|
+
"@squide/msw": "4.0.13",
|
|
56
|
+
"@squide/react-router": "8.1.12"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@eslint/js": "9.39.2",
|
|
60
60
|
"@rsbuild/core": "1.7.2",
|
|
61
|
-
"@rslib/core": "0.19.
|
|
62
|
-
"@testing-library/react": "16.3.
|
|
63
|
-
"@types/react": "19.2.
|
|
61
|
+
"@rslib/core": "0.19.3",
|
|
62
|
+
"@testing-library/react": "16.3.2",
|
|
63
|
+
"@types/react": "19.2.10",
|
|
64
64
|
"@types/react-dom": "19.2.3",
|
|
65
|
-
"@typescript-eslint/parser": "8.
|
|
65
|
+
"@typescript-eslint/parser": "8.54.0",
|
|
66
|
+
"@typescript/native-preview": "7.0.0-dev.20260128.1",
|
|
66
67
|
"@vitejs/plugin-react": "5.1.2",
|
|
67
|
-
"@workleap/eslint-configs": "1.1.
|
|
68
|
-
"@workleap/rslib-configs": "1.1.
|
|
68
|
+
"@workleap/eslint-configs": "1.1.11",
|
|
69
|
+
"@workleap/rslib-configs": "1.1.6",
|
|
69
70
|
"@workleap/typescript-configs": "3.0.7",
|
|
70
71
|
"eslint": "9.39.2",
|
|
71
|
-
"happy-dom": "20.3.
|
|
72
|
+
"happy-dom": "20.3.9",
|
|
72
73
|
"typescript": "5.9.3",
|
|
73
|
-
"typescript-eslint": "8.
|
|
74
|
-
"vitest": "4.0.
|
|
74
|
+
"typescript-eslint": "8.54.0",
|
|
75
|
+
"vitest": "4.0.18"
|
|
75
76
|
},
|
|
76
77
|
"sideEffects": false,
|
|
77
78
|
"scripts": {
|
|
78
79
|
"build": "rslib build --config ./rslib.build.ts",
|
|
79
80
|
"eslint": "eslint . --max-warnings=0 --cache --cache-location node_modules/.cache/eslint",
|
|
80
|
-
"typecheck": "
|
|
81
|
+
"typecheck": "tsgo",
|
|
81
82
|
"test": "vitest --config vitest.config.ts --no-watch"
|
|
82
83
|
}
|
|
83
84
|
}
|
package/src/AppRouterReducer.ts
CHANGED
|
@@ -78,6 +78,7 @@ function reducer(state: AppRouterState, action: AppRouterAction) {
|
|
|
78
78
|
case "modules-ready": {
|
|
79
79
|
newState = {
|
|
80
80
|
...newState,
|
|
81
|
+
areModulesRegistered: true,
|
|
81
82
|
areModulesReady: true,
|
|
82
83
|
// Will be set even if the app is not using deferred registrations.
|
|
83
84
|
deferredRegistrationsUpdatedAt: Date.now()
|
|
@@ -215,7 +216,7 @@ export function useModuleRegistrationStatusDispatcher(runtime: FireflyRuntime, a
|
|
|
215
216
|
runtime.moduleManager.removeModulesRegisteredListener(dispatchModulesRegistered);
|
|
216
217
|
runtime.moduleManager.removeModulesReadyListener(dispatchModulesReady);
|
|
217
218
|
};
|
|
218
|
-
}, [areModulesRegisteredValue, areModulesReadyValue, dispatchModulesRegistered, dispatchModulesReady]);
|
|
219
|
+
}, [runtime, areModulesRegisteredValue, areModulesReadyValue, dispatchModulesRegistered, dispatchModulesReady]);
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
export function useMswStatusDispatcher(runtime: FireflyRuntime, isMswReadyValue: boolean, dispatch: AppRouterDispatch) {
|
|
@@ -249,14 +250,14 @@ export function useMswStatusDispatcher(runtime: FireflyRuntime, isMswReadyValue:
|
|
|
249
250
|
export function useFeatureFlagsUpdatedDispatcher(runtime: FireflyRuntime, dispatch: AppRouterDispatch) {
|
|
250
251
|
const logger = useLogger();
|
|
251
252
|
|
|
252
|
-
const dispatchFeatureFlagsUpdated = useCallback(
|
|
253
|
+
const dispatchFeatureFlagsUpdated = useCallback<FeatureFlagSetSnapshotChangedListener>(changes => {
|
|
253
254
|
dispatch({ type: "feature-flags-updated" });
|
|
254
255
|
|
|
255
256
|
logger
|
|
256
257
|
.withText("[squide] Feature flags has been updated to:")
|
|
257
258
|
.withObject(changes)
|
|
258
259
|
.debug();
|
|
259
|
-
}
|
|
260
|
+
}, [dispatch, logger]);
|
|
260
261
|
|
|
261
262
|
useEffect(() => {
|
|
262
263
|
if (runtime.isLaunchDarklyEnabled) {
|
|
@@ -266,7 +267,7 @@ export function useFeatureFlagsUpdatedDispatcher(runtime: FireflyRuntime, dispat
|
|
|
266
267
|
runtime.featureFlagSetSnapshot.removeSnapshotChangedListener(dispatchFeatureFlagsUpdated);
|
|
267
268
|
};
|
|
268
269
|
}
|
|
269
|
-
}, [runtime]);
|
|
270
|
+
}, [runtime, dispatchFeatureFlagsUpdated]);
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
function useBootstrappingCompletedDispatcher(waitState: AppRouterWaitState, state: AppRouterState) {
|
package/src/index.ts
CHANGED
|
@@ -10,21 +10,30 @@ export {
|
|
|
10
10
|
type EnvironmentVariablesPluginOptions
|
|
11
11
|
} from "@squide/env-vars";
|
|
12
12
|
export {
|
|
13
|
+
createLocalStorageLaunchDarklyClient,
|
|
13
14
|
FeatureFlagSetSnapshot,
|
|
14
15
|
getFeatureFlag,
|
|
15
16
|
getLaunchDarklyPlugin,
|
|
16
17
|
InMemoryLaunchDarklyClient,
|
|
18
|
+
isEditableLaunchDarklyClient,
|
|
17
19
|
LaunchDarklyClientNotifier,
|
|
20
|
+
LaunchDarklyClientTransaction,
|
|
18
21
|
LaunchDarklyPlugin,
|
|
19
22
|
LaunchDarklyPluginName,
|
|
23
|
+
LocalStorageLaunchDarklyClient,
|
|
20
24
|
useFeatureFlag,
|
|
21
25
|
useFeatureFlags,
|
|
22
26
|
useLaunchDarklyClient,
|
|
27
|
+
type CommitTransactionFunction,
|
|
28
|
+
type EditableLaunchDarklyClient,
|
|
23
29
|
type FeatureFlagKey,
|
|
24
30
|
type FeatureFlags,
|
|
25
31
|
type FeatureFlagSetSnapshotChangedListener,
|
|
26
32
|
type InMemoryLaunchDarklyClientOptions,
|
|
27
|
-
type LaunchDarklyClientListener
|
|
33
|
+
type LaunchDarklyClientListener,
|
|
34
|
+
type LocalStorageLaunchDarklyClientOptions,
|
|
35
|
+
type SetFeatureFlagOptions,
|
|
36
|
+
type UndoTransactionFunction
|
|
28
37
|
} from "@squide/launch-darkly";
|
|
29
38
|
export {
|
|
30
39
|
getMswPlugin,
|