@squide/firefly 16.2.0 → 16.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/useCanUpdateDeferredRegistrations.d.ts +1 -1
- package/dist/useCanUpdateDeferredRegistrations.js +15 -4
- package/dist/useCanUpdateDeferredRegistrations.js.map +1 -1
- package/dist/useDeferredRegistrations.js +12 -1
- package/dist/useDeferredRegistrations.js.map +1 -1
- package/package.json +3 -3
- package/src/useCanUpdateDeferredRegistrations.ts +20 -18
- package/src/useDeferredRegistrations.ts +14 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @squide/firefly
|
|
2
2
|
|
|
3
|
+
## 16.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#567](https://github.com/workleap/wl-squide/pull/567) [`5f16979`](https://github.com/workleap/wl-squide/commit/5f16979d9e922590fdca39be76e79dde54211efa) Thanks [@patricklafrance](https://github.com/patricklafrance)! - useDeferredRegistrations will now trigger a deferred registration update whenever the data object reference changes, even if no global data has been fetch or no feature flags changed.
|
|
8
|
+
|
|
3
9
|
## 16.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useCanUpdateDeferredRegistrations(): boolean
|
|
1
|
+
export declare function useCanUpdateDeferredRegistrations(): boolean;
|
|
@@ -5,10 +5,21 @@ import { useAppRouterState } from "./AppRouterContext.js";
|
|
|
5
5
|
;// CONCATENATED MODULE: ./src/useCanUpdateDeferredRegistrations.ts
|
|
6
6
|
|
|
7
7
|
function useCanUpdateDeferredRegistrations() {
|
|
8
|
-
const { areModulesReady
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const { areModulesReady } = useAppRouterState();
|
|
9
|
+
return areModulesReady;
|
|
10
|
+
// return !!(
|
|
11
|
+
// // Do not trigger an update if the deferred registrations has not been registered yet (if there are deferred registrations, once they are
|
|
12
|
+
// // registered, the modules will be marked as ready).
|
|
13
|
+
// areModulesReady
|
|
14
|
+
// // Make sure the apps is actually having deferred registrations.
|
|
15
|
+
// // && deferredRegistrationsUpdatedAt
|
|
16
|
+
// // // If either the public data or the protected data has been updated, update the deferred registrations.
|
|
17
|
+
// // && (
|
|
18
|
+
// // (publicDataUpdatedAt && publicDataUpdatedAt > deferredRegistrationsUpdatedAt) ||
|
|
19
|
+
// // (protectedDataUpdatedAt && protectedDataUpdatedAt > deferredRegistrationsUpdatedAt) ||
|
|
20
|
+
// // (featureFlagsUpdatedAt && featureFlagsUpdatedAt > deferredRegistrationsUpdatedAt)
|
|
21
|
+
// // )
|
|
22
|
+
// );
|
|
12
23
|
}
|
|
13
24
|
|
|
14
25
|
export { useCanUpdateDeferredRegistrations };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCanUpdateDeferredRegistrations.js","sources":["../src/useCanUpdateDeferredRegistrations.ts"],"sourcesContent":["import { useAppRouterState } from \"./AppRouterContext.ts\";\n\nexport function useCanUpdateDeferredRegistrations() {\n const {\n areModulesReady
|
|
1
|
+
{"version":3,"file":"useCanUpdateDeferredRegistrations.js","sources":["../src/useCanUpdateDeferredRegistrations.ts"],"sourcesContent":["import { useAppRouterState } from \"./AppRouterContext.ts\";\n\nexport function useCanUpdateDeferredRegistrations() {\n const {\n areModulesReady\n // publicDataUpdatedAt,\n // protectedDataUpdatedAt,\n // featureFlagsUpdatedAt,\n // deferredRegistrationsUpdatedAt\n } = useAppRouterState();\n\n return areModulesReady;\n\n // return !!(\n // // Do not trigger an update if the deferred registrations has not been registered yet (if there are deferred registrations, once they are\n // // registered, the modules will be marked as ready).\n // areModulesReady\n // // Make sure the apps is actually having deferred registrations.\n // // && deferredRegistrationsUpdatedAt\n // // // If either the public data or the protected data has been updated, update the deferred registrations.\n // // && (\n // // (publicDataUpdatedAt && publicDataUpdatedAt > deferredRegistrationsUpdatedAt) ||\n // // (protectedDataUpdatedAt && protectedDataUpdatedAt > deferredRegistrationsUpdatedAt) ||\n // // (featureFlagsUpdatedAt && featureFlagsUpdatedAt > deferredRegistrationsUpdatedAt)\n // // )\n // );\n}\n"],"names":["useAppRouterState","useCanUpdateDeferredRegistrations","areModulesReady"],"mappings":";;;;;AAA0D;AAEnD,SAASC;IACZ,MAAM,EACFC,eAAe,EAKlB,GAAGF,iBAAiBA;IAErB,OAAOE;AAEP,aAAa;AACb,gJAAgJ;AAChJ,2DAA2D;AAC3D,sBAAsB;AACtB,uEAAuE;AACvE,2CAA2C;AAC3C,iHAAiH;AACjH,cAAc;AACd,8FAA8F;AAC9F,oGAAoG;AACpG,+FAA+F;AAC/F,WAAW;AACX,KAAK;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRuntime } from "@squide/core";
|
|
2
|
-
import { useEffect } from "react";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
3
|
import { useCanRegisterDeferredRegistrations } from "./useCanRegisterDeferredRegistrations.js";
|
|
4
4
|
import { useCanUpdateDeferredRegistrations } from "./useCanUpdateDeferredRegistrations.js";
|
|
5
5
|
import { useRegisterDeferredRegistrations } from "./useRegisterDeferredRegistrations.js";
|
|
@@ -26,6 +26,7 @@ import { useUpdateDeferredRegistrations } from "./useUpdateDeferredRegistrations
|
|
|
26
26
|
|
|
27
27
|
function useDeferredRegistrations(data, { onError } = {}) {
|
|
28
28
|
const runtime = useRuntime();
|
|
29
|
+
// const isExecutedBecauseModulesAreNowReadyRef = useRef(true);
|
|
29
30
|
const canRegisterDeferredRegistrations = useCanRegisterDeferredRegistrations();
|
|
30
31
|
const canUpdateDeferredRegistrations = useCanUpdateDeferredRegistrations();
|
|
31
32
|
const registerDeferredRegistrations = useRegisterDeferredRegistrations();
|
|
@@ -46,8 +47,18 @@ function useDeferredRegistrations(data, { onError } = {}) {
|
|
|
46
47
|
data,
|
|
47
48
|
onError
|
|
48
49
|
]);
|
|
50
|
+
const isInitialUpdateDeferredRegistrationsExecution = useRef(true);
|
|
49
51
|
useEffect(()=>{
|
|
50
52
|
if (canUpdateDeferredRegistrations) {
|
|
53
|
+
// HACK: Skipping the first execution successfully passing the gate because this is due to
|
|
54
|
+
// the modules being ready, and it's most certainly the same data that has been forwarded earlier to the deferred registration.
|
|
55
|
+
// Ideally, instead of this hacky ref, it would be a ref tracking the previous data object, and the deferred registration would
|
|
56
|
+
// only be updated if the current data object != than the previous data object. Sadly, it is not possible because
|
|
57
|
+
// of the feature flags.
|
|
58
|
+
if (isInitialUpdateDeferredRegistrationsExecution.current) {
|
|
59
|
+
isInitialUpdateDeferredRegistrationsExecution.current = false;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
51
62
|
const update = async ()=>{
|
|
52
63
|
const errors = await updateDeferredRegistrations(data);
|
|
53
64
|
if (errors.length > 0 && onError) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeferredRegistrations.js","sources":["../src/useDeferredRegistrations.ts"],"sourcesContent":["import { useRuntime, type ModuleRegistrationError } from \"@squide/core\";\nimport { useEffect } from \"react\";\nimport { FireflyRuntime } from \"./FireflyRuntime.tsx\";\nimport { useCanRegisterDeferredRegistrations } from \"./useCanRegisterDeferredRegistrations.ts\";\nimport { useCanUpdateDeferredRegistrations } from \"./useCanUpdateDeferredRegistrations.ts\";\nimport { useRegisterDeferredRegistrations } from \"./useRegisterDeferredRegistrations.ts\";\nimport { useUpdateDeferredRegistrations } from \"./useUpdateDeferredRegistrations.ts\";\n\nexport type DeferredRegistrationsErrorCallback = (errors: ModuleRegistrationError[]) => void;\n\nexport interface UseDeferredRegistrationsOptions {\n onError?: DeferredRegistrationsErrorCallback;\n}\n\nexport function useDeferredRegistrations(data?: unknown, { onError }: UseDeferredRegistrationsOptions = {}) {\n const runtime = useRuntime() as FireflyRuntime;\n\n const canRegisterDeferredRegistrations = useCanRegisterDeferredRegistrations();\n const canUpdateDeferredRegistrations = useCanUpdateDeferredRegistrations();\n\n const registerDeferredRegistrations = useRegisterDeferredRegistrations();\n const updateDeferredRegistrations = useUpdateDeferredRegistrations();\n\n useEffect(() => {\n if (canRegisterDeferredRegistrations) {\n const register = async () => {\n const errors = await registerDeferredRegistrations(data);\n\n if (errors.length > 0 && onError) {\n onError(errors);\n }\n };\n\n register();\n }\n }, [canRegisterDeferredRegistrations, registerDeferredRegistrations, data, onError]);\n\n useEffect(() => {\n if (canUpdateDeferredRegistrations) {\n const update = async () => {\n const errors = await updateDeferredRegistrations(data);\n\n if (errors.length > 0 && onError) {\n onError(errors);\n }\n };\n\n update();\n }\n }, [\n canUpdateDeferredRegistrations,\n updateDeferredRegistrations,\n data,\n onError,\n // Trigger this closure when the feature flags changed. Using the timestamp because the\n // actual feature flags are not forwarded to the deferred registrations.\n runtime.appRouterStore.state.featureFlagsUpdatedAt\n ]);\n}\n"],"names":["useRuntime","useEffect","useCanRegisterDeferredRegistrations","useCanUpdateDeferredRegistrations","useRegisterDeferredRegistrations","useUpdateDeferredRegistrations","useDeferredRegistrations","data","onError","runtime","canRegisterDeferredRegistrations","canUpdateDeferredRegistrations","registerDeferredRegistrations","updateDeferredRegistrations","register","errors","update"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAwE;
|
|
1
|
+
{"version":3,"file":"useDeferredRegistrations.js","sources":["../src/useDeferredRegistrations.ts"],"sourcesContent":["import { useRuntime, type ModuleRegistrationError } from \"@squide/core\";\nimport { useEffect, useRef } from \"react\";\nimport { FireflyRuntime } from \"./FireflyRuntime.tsx\";\nimport { useCanRegisterDeferredRegistrations } from \"./useCanRegisterDeferredRegistrations.ts\";\nimport { useCanUpdateDeferredRegistrations } from \"./useCanUpdateDeferredRegistrations.ts\";\nimport { useRegisterDeferredRegistrations } from \"./useRegisterDeferredRegistrations.ts\";\nimport { useUpdateDeferredRegistrations } from \"./useUpdateDeferredRegistrations.ts\";\n\nexport type DeferredRegistrationsErrorCallback = (errors: ModuleRegistrationError[]) => void;\n\nexport interface UseDeferredRegistrationsOptions {\n onError?: DeferredRegistrationsErrorCallback;\n}\n\nexport function useDeferredRegistrations(data?: unknown, { onError }: UseDeferredRegistrationsOptions = {}) {\n const runtime = useRuntime() as FireflyRuntime;\n // const isExecutedBecauseModulesAreNowReadyRef = useRef(true);\n\n const canRegisterDeferredRegistrations = useCanRegisterDeferredRegistrations();\n const canUpdateDeferredRegistrations = useCanUpdateDeferredRegistrations();\n\n const registerDeferredRegistrations = useRegisterDeferredRegistrations();\n const updateDeferredRegistrations = useUpdateDeferredRegistrations();\n\n useEffect(() => {\n if (canRegisterDeferredRegistrations) {\n const register = async () => {\n const errors = await registerDeferredRegistrations(data);\n\n if (errors.length > 0 && onError) {\n onError(errors);\n }\n };\n\n register();\n }\n }, [canRegisterDeferredRegistrations, registerDeferredRegistrations, data, onError]);\n\n const isInitialUpdateDeferredRegistrationsExecution = useRef(true);\n\n useEffect(() => {\n if (canUpdateDeferredRegistrations) {\n // HACK: Skipping the first execution successfully passing the gate because this is due to\n // the modules being ready, and it's most certainly the same data that has been forwarded earlier to the deferred registration.\n // Ideally, instead of this hacky ref, it would be a ref tracking the previous data object, and the deferred registration would\n // only be updated if the current data object != than the previous data object. Sadly, it is not possible because\n // of the feature flags.\n if (isInitialUpdateDeferredRegistrationsExecution.current) {\n isInitialUpdateDeferredRegistrationsExecution.current = false;\n return;\n }\n\n const update = async () => {\n const errors = await updateDeferredRegistrations(data);\n\n if (errors.length > 0 && onError) {\n onError(errors);\n }\n };\n\n update();\n }\n }, [\n canUpdateDeferredRegistrations,\n updateDeferredRegistrations,\n data,\n onError,\n // Trigger this closure when the feature flags changed. Using the timestamp because the\n // actual feature flags are not forwarded to the deferred registrations.\n runtime.appRouterStore.state.featureFlagsUpdatedAt\n ]);\n}\n"],"names":["useRuntime","useEffect","useRef","useCanRegisterDeferredRegistrations","useCanUpdateDeferredRegistrations","useRegisterDeferredRegistrations","useUpdateDeferredRegistrations","useDeferredRegistrations","data","onError","runtime","canRegisterDeferredRegistrations","canUpdateDeferredRegistrations","registerDeferredRegistrations","updateDeferredRegistrations","register","errors","isInitialUpdateDeferredRegistrationsExecution","update"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAwE;AAC9B;AAEqD;AACJ;AACF;AACJ;AAQ9E,SAASO,yBAAyBC,IAAc,EAAE,EAAEC,OAAO,EAAmC,GAAG,CAAC,CAAC;IACtG,MAAMC,UAAUV,UAAUA;IAC1B,+DAA+D;IAE/D,MAAMW,mCAAmCR,mCAAmCA;IAC5E,MAAMS,iCAAiCR,iCAAiCA;IAExE,MAAMS,gCAAgCR,gCAAgCA;IACtE,MAAMS,8BAA8BR,8BAA8BA;IAElEL,SAASA,CAAC;QACN,IAAIU,kCAAkC;YAClC,MAAMI,WAAW;gBACb,MAAMC,SAAS,MAAMH,8BAA8BL;gBAEnD,IAAIQ,OAAO,MAAM,GAAG,KAAKP,SAAS;oBAC9BA,QAAQO;gBACZ;YACJ;YAEAD;QACJ;IACJ,GAAG;QAACJ;QAAkCE;QAA+BL;QAAMC;KAAQ;IAEnF,MAAMQ,gDAAgDf,MAAMA,CAAC;IAE7DD,SAASA,CAAC;QACN,IAAIW,gCAAgC;YAChC,0FAA0F;YAC1F,+HAA+H;YAC/H,+HAA+H;YAC/H,iHAAiH;YACjH,wBAAwB;YACxB,IAAIK,8CAA8C,OAAO,EAAE;gBACvDA,8CAA8C,OAAO,GAAG;gBACxD;YACJ;YAEA,MAAMC,SAAS;gBACX,MAAMF,SAAS,MAAMF,4BAA4BN;gBAEjD,IAAIQ,OAAO,MAAM,GAAG,KAAKP,SAAS;oBAC9BA,QAAQO;gBACZ;YACJ;YAEAE;QACJ;IACJ,GAAG;QACCN;QACAE;QACAN;QACAC;QACA,uFAAuF;QACvF,wEAAwE;QACxEC,QAAQ,cAAc,CAAC,KAAK,CAAC,qBAAqB;KACrD;AACL"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "16.2.
|
|
4
|
+
"version": "16.2.1",
|
|
5
5
|
"description": "Squide bundle for the firefly technology stack.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"@workleap-telemetry/core": "^2.0.0",
|
|
50
50
|
"@workleap/logging": "^1.3.6",
|
|
51
51
|
"uuid": "^13.0.0",
|
|
52
|
-
"@squide/core": "^6.1.14",
|
|
53
|
-
"@squide/launch-darkly": "^1.0.10",
|
|
54
52
|
"@squide/env-vars": "^1.4.19",
|
|
53
|
+
"@squide/launch-darkly": "^1.0.10",
|
|
55
54
|
"@squide/msw": "^4.0.17",
|
|
55
|
+
"@squide/core": "^6.1.14",
|
|
56
56
|
"@squide/react-router": "^8.1.17"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
@@ -2,24 +2,26 @@ import { useAppRouterState } from "./AppRouterContext.ts";
|
|
|
2
2
|
|
|
3
3
|
export function useCanUpdateDeferredRegistrations() {
|
|
4
4
|
const {
|
|
5
|
-
areModulesReady
|
|
6
|
-
publicDataUpdatedAt,
|
|
7
|
-
protectedDataUpdatedAt,
|
|
8
|
-
featureFlagsUpdatedAt,
|
|
9
|
-
deferredRegistrationsUpdatedAt
|
|
5
|
+
areModulesReady
|
|
6
|
+
// publicDataUpdatedAt,
|
|
7
|
+
// protectedDataUpdatedAt,
|
|
8
|
+
// featureFlagsUpdatedAt,
|
|
9
|
+
// deferredRegistrationsUpdatedAt
|
|
10
10
|
} = useAppRouterState();
|
|
11
11
|
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
12
|
+
return areModulesReady;
|
|
13
|
+
|
|
14
|
+
// return !!(
|
|
15
|
+
// // Do not trigger an update if the deferred registrations has not been registered yet (if there are deferred registrations, once they are
|
|
16
|
+
// // registered, the modules will be marked as ready).
|
|
17
|
+
// areModulesReady
|
|
18
|
+
// // Make sure the apps is actually having deferred registrations.
|
|
19
|
+
// // && deferredRegistrationsUpdatedAt
|
|
20
|
+
// // // If either the public data or the protected data has been updated, update the deferred registrations.
|
|
21
|
+
// // && (
|
|
22
|
+
// // (publicDataUpdatedAt && publicDataUpdatedAt > deferredRegistrationsUpdatedAt) ||
|
|
23
|
+
// // (protectedDataUpdatedAt && protectedDataUpdatedAt > deferredRegistrationsUpdatedAt) ||
|
|
24
|
+
// // (featureFlagsUpdatedAt && featureFlagsUpdatedAt > deferredRegistrationsUpdatedAt)
|
|
25
|
+
// // )
|
|
26
|
+
// );
|
|
25
27
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRuntime, type ModuleRegistrationError } from "@squide/core";
|
|
2
|
-
import { useEffect } from "react";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
3
|
import { FireflyRuntime } from "./FireflyRuntime.tsx";
|
|
4
4
|
import { useCanRegisterDeferredRegistrations } from "./useCanRegisterDeferredRegistrations.ts";
|
|
5
5
|
import { useCanUpdateDeferredRegistrations } from "./useCanUpdateDeferredRegistrations.ts";
|
|
@@ -14,6 +14,7 @@ export interface UseDeferredRegistrationsOptions {
|
|
|
14
14
|
|
|
15
15
|
export function useDeferredRegistrations(data?: unknown, { onError }: UseDeferredRegistrationsOptions = {}) {
|
|
16
16
|
const runtime = useRuntime() as FireflyRuntime;
|
|
17
|
+
// const isExecutedBecauseModulesAreNowReadyRef = useRef(true);
|
|
17
18
|
|
|
18
19
|
const canRegisterDeferredRegistrations = useCanRegisterDeferredRegistrations();
|
|
19
20
|
const canUpdateDeferredRegistrations = useCanUpdateDeferredRegistrations();
|
|
@@ -35,8 +36,20 @@ export function useDeferredRegistrations(data?: unknown, { onError }: UseDeferre
|
|
|
35
36
|
}
|
|
36
37
|
}, [canRegisterDeferredRegistrations, registerDeferredRegistrations, data, onError]);
|
|
37
38
|
|
|
39
|
+
const isInitialUpdateDeferredRegistrationsExecution = useRef(true);
|
|
40
|
+
|
|
38
41
|
useEffect(() => {
|
|
39
42
|
if (canUpdateDeferredRegistrations) {
|
|
43
|
+
// HACK: Skipping the first execution successfully passing the gate because this is due to
|
|
44
|
+
// the modules being ready, and it's most certainly the same data that has been forwarded earlier to the deferred registration.
|
|
45
|
+
// Ideally, instead of this hacky ref, it would be a ref tracking the previous data object, and the deferred registration would
|
|
46
|
+
// only be updated if the current data object != than the previous data object. Sadly, it is not possible because
|
|
47
|
+
// of the feature flags.
|
|
48
|
+
if (isInitialUpdateDeferredRegistrationsExecution.current) {
|
|
49
|
+
isInitialUpdateDeferredRegistrationsExecution.current = false;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
40
53
|
const update = async () => {
|
|
41
54
|
const errors = await updateDeferredRegistrations(data);
|
|
42
55
|
|