@flipdish/ui-library 0.11.11 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useClipboard/index.cjs +10 -7
- package/dist/hooks/useClipboard/index.cjs.map +1 -1
- package/dist/hooks/useClipboard/index.d.ts.map +1 -1
- package/dist/hooks/useClipboard/index.js +10 -7
- package/dist/hooks/useClipboard/index.js.map +1 -1
- package/dist/utilities/localStorageUtils/index.cjs +7 -1
- package/dist/utilities/localStorageUtils/index.cjs.map +1 -1
- package/dist/utilities/localStorageUtils/index.d.ts.map +1 -1
- package/dist/utilities/localStorageUtils/index.js +7 -1
- package/dist/utilities/localStorageUtils/index.js.map +1 -1
- package/dist/utilities/renderUtils/importWithRetry.utils.cjs +37 -0
- package/dist/utilities/renderUtils/importWithRetry.utils.cjs.map +1 -0
- package/dist/utilities/renderUtils/importWithRetry.utils.d.ts +8 -0
- package/dist/utilities/renderUtils/importWithRetry.utils.d.ts.map +1 -0
- package/dist/utilities/renderUtils/importWithRetry.utils.js +35 -0
- package/dist/utilities/renderUtils/importWithRetry.utils.js.map +1 -0
- package/dist/utilities/renderUtils/index.cjs +2 -20
- package/dist/utilities/renderUtils/index.cjs.map +1 -1
- package/dist/utilities/renderUtils/index.d.ts.map +1 -1
- package/dist/utilities/renderUtils/index.js +2 -20
- package/dist/utilities/renderUtils/index.js.map +1 -1
- package/dist/utilities/sessionStorageUtils/index.cjs +132 -0
- package/dist/utilities/sessionStorageUtils/index.cjs.map +1 -0
- package/dist/utilities/sessionStorageUtils/index.d.ts +44 -0
- package/dist/utilities/sessionStorageUtils/index.d.ts.map +1 -0
- package/dist/utilities/sessionStorageUtils/index.js +128 -0
- package/dist/utilities/sessionStorageUtils/index.js.map +1 -0
- package/dist/utilities/sessionStorageUtils/sessionStorageUtils.constants.cjs +15 -0
- package/dist/utilities/sessionStorageUtils/sessionStorageUtils.constants.cjs.map +1 -0
- package/dist/utilities/sessionStorageUtils/sessionStorageUtils.constants.d.ts +11 -0
- package/dist/utilities/sessionStorageUtils/sessionStorageUtils.constants.d.ts.map +1 -0
- package/dist/utilities/sessionStorageUtils/sessionStorageUtils.constants.js +13 -0
- package/dist/utilities/sessionStorageUtils/sessionStorageUtils.constants.js.map +1 -0
- package/package.json +1 -1
|
@@ -24,16 +24,15 @@ const useClipboard = () => {
|
|
|
24
24
|
}, []);
|
|
25
25
|
// Fallback function for older browsers
|
|
26
26
|
const fallback = (text, id) => {
|
|
27
|
+
// Textarea to copy the text to the clipboard
|
|
28
|
+
const textArea = document.createElement('textarea');
|
|
29
|
+
textArea.value = text;
|
|
30
|
+
textArea.style.position = 'absolute';
|
|
31
|
+
textArea.style.left = '-99999px';
|
|
32
|
+
document.body.appendChild(textArea);
|
|
27
33
|
try {
|
|
28
|
-
// Textarea to copy the text to the clipboard
|
|
29
|
-
const textArea = document.createElement('textarea');
|
|
30
|
-
textArea.value = text;
|
|
31
|
-
textArea.style.position = 'absolute';
|
|
32
|
-
textArea.style.left = '-99999px';
|
|
33
|
-
document.body.appendChild(textArea);
|
|
34
34
|
textArea.select();
|
|
35
35
|
const success = document.execCommand('copy');
|
|
36
|
-
textArea.remove();
|
|
37
36
|
if (success) {
|
|
38
37
|
setCopied(id || true);
|
|
39
38
|
scheduleReset();
|
|
@@ -46,6 +45,10 @@ const useClipboard = () => {
|
|
|
46
45
|
error: err instanceof Error ? err : new Error('Fallback copy failed'),
|
|
47
46
|
};
|
|
48
47
|
}
|
|
48
|
+
finally {
|
|
49
|
+
// Always remove the textarea, even when execCommand throws, so a failed copy doesn't leak it into the DOM.
|
|
50
|
+
textArea.remove();
|
|
51
|
+
}
|
|
49
52
|
};
|
|
50
53
|
// biome-ignore lint/correctness/useExhaustiveDependencies: We need to return the copied state and the copy function
|
|
51
54
|
const copy = React.useCallback(async (text, id) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useClipboard/index.ts"],"sourcesContent":[null],"names":["useState","useRef","useEffect","useCallback"],"mappings":";;;;AAIA,MAAM,eAAe,GAAG,IAAI;AAqB5B;;;;AAIG;AACI,MAAM,YAAY,GAAG,MAA6B;IACvD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAmB,KAAK,CAAC;AAC7D,IAAA,MAAM,aAAa,GAAGC,YAAM,CAAuC,IAAI,CAAC;IAExE,MAAM,aAAa,GAAG,MAAK;QACzB,IAAI,aAAa,CAAC,OAAO;AAAE,YAAA,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC;AAC9D,QAAA,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;AAC7E,IAAA,CAAC;IAEDC,eAAS,CAAC,MAAK;AACb,QAAA,OAAO,MAAK;YACV,IAAI,aAAa,CAAC,OAAO;AAAE,gBAAA,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC;AAChE,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;;AAGN,IAAA,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAW,KAAI
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useClipboard/index.ts"],"sourcesContent":[null],"names":["useState","useRef","useEffect","useCallback"],"mappings":";;;;AAIA,MAAM,eAAe,GAAG,IAAI;AAqB5B;;;;AAIG;AACI,MAAM,YAAY,GAAG,MAA6B;IACvD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAmB,KAAK,CAAC;AAC7D,IAAA,MAAM,aAAa,GAAGC,YAAM,CAAuC,IAAI,CAAC;IAExE,MAAM,aAAa,GAAG,MAAK;QACzB,IAAI,aAAa,CAAC,OAAO;AAAE,YAAA,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC;AAC9D,QAAA,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,SAAS,CAAC,KAAK,CAA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AAI,SAAS,CAAC,SAAS,IAAI,MAAM,CAAC,eAAe,EAAE;AACjD,YAAA,IAAI;gBACF,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;AAEzC,gBAAA,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC;AACrB,gBAAA,aAAa,EAAE;AAEf,gBAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;YAC1B;YAAE,OAAO,IAAI,EAAE;;AAEb,gBAAA,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YAC3B;QACF;AACA,QAAA,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;IAC3B,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;AACzB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useClipboard/index.ts"],"names":[],"mappings":"AAMA,KAAK,sBAAsB,GAAG;IAC5B;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB;;;;;;;;;OASG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;CACnF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useClipboard/index.ts"],"names":[],"mappings":"AAMA,KAAK,sBAAsB,GAAG;IAC5B;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB;;;;;;;;;OASG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;CACnF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,sBAkE/B,CAAC"}
|
|
@@ -22,16 +22,15 @@ const useClipboard = () => {
|
|
|
22
22
|
}, []);
|
|
23
23
|
// Fallback function for older browsers
|
|
24
24
|
const fallback = (text, id) => {
|
|
25
|
+
// Textarea to copy the text to the clipboard
|
|
26
|
+
const textArea = document.createElement('textarea');
|
|
27
|
+
textArea.value = text;
|
|
28
|
+
textArea.style.position = 'absolute';
|
|
29
|
+
textArea.style.left = '-99999px';
|
|
30
|
+
document.body.appendChild(textArea);
|
|
25
31
|
try {
|
|
26
|
-
// Textarea to copy the text to the clipboard
|
|
27
|
-
const textArea = document.createElement('textarea');
|
|
28
|
-
textArea.value = text;
|
|
29
|
-
textArea.style.position = 'absolute';
|
|
30
|
-
textArea.style.left = '-99999px';
|
|
31
|
-
document.body.appendChild(textArea);
|
|
32
32
|
textArea.select();
|
|
33
33
|
const success = document.execCommand('copy');
|
|
34
|
-
textArea.remove();
|
|
35
34
|
if (success) {
|
|
36
35
|
setCopied(id || true);
|
|
37
36
|
scheduleReset();
|
|
@@ -44,6 +43,10 @@ const useClipboard = () => {
|
|
|
44
43
|
error: err instanceof Error ? err : new Error('Fallback copy failed'),
|
|
45
44
|
};
|
|
46
45
|
}
|
|
46
|
+
finally {
|
|
47
|
+
// Always remove the textarea, even when execCommand throws, so a failed copy doesn't leak it into the DOM.
|
|
48
|
+
textArea.remove();
|
|
49
|
+
}
|
|
47
50
|
};
|
|
48
51
|
// biome-ignore lint/correctness/useExhaustiveDependencies: We need to return the copied state and the copy function
|
|
49
52
|
const copy = useCallback(async (text, id) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/hooks/useClipboard/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA,MAAM,eAAe,GAA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AS,CAAC,IAAI,CAAC;AAEzC,gBAAA,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC;AACrB,gBAAA,aAAa,EAAE;AAEf,gBAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;YAC1B;YAAE,OAAO,IAAI,EAAE;;AAEb,gBAAA,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YAC3B;QACF;AACA,QAAA,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;IAC3B,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;AACzB;;;;"}
|
|
@@ -97,7 +97,13 @@ const createLocalStorageItem = (key, options = {}) => {
|
|
|
97
97
|
},
|
|
98
98
|
set(value) {
|
|
99
99
|
try {
|
|
100
|
-
|
|
100
|
+
const serialized = serialize(value);
|
|
101
|
+
// JSON.stringify (and a custom serializer) can return `undefined` for a
|
|
102
|
+
// top-level `undefined`, function, or symbol — treat that as a failed
|
|
103
|
+
// serialization rather than writing the literal string "undefined".
|
|
104
|
+
if (typeof serialized !== 'string')
|
|
105
|
+
return;
|
|
106
|
+
safeLocalSet(key, serialized);
|
|
101
107
|
}
|
|
102
108
|
catch {
|
|
103
109
|
// serialize() can throw (e.g. circular refs); matches the documented
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":["LOCAL_STORAGE_KEYS"],"mappings":";;;;AAAA;;;;;;;;;AASG;AAMH,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW;AAE/C;;;;;AAKG;AAEH;AACA,MAAM,YAAY,GAAG,CAAC,GAAW,KAAmB;AAClD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,IAAI;QACF,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC;IACzC;AAAE,IAAA,MAAM;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;AAAE,gBAAA,OAAO,IAAI;AAC5B,YAAA,IAAI;AACF,gBAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;AAC9B,gBAAA,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,oBAAA,OAAO,IAAI;AAC7C,gBAAA,OAAO,KAAK;YACd;AAAE,YAAA,MAAM;AACN,gBAAA,OAAO,IAAI;YACb;QACF,CAAC;AACD,QAAA,GAAG,CAAC,KAAK,EAAA;AACP,YAAA,IAAI;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":["LOCAL_STORAGE_KEYS"],"mappings":";;;;AAAA;;;;;;;;;AASG;AAMH,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW;AAE/C;;;;;AAKG;AAEH;AACA,MAAM,YAAY,GAAG,CAAC,GAAW,KAAmB;AAClD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,IAAI;QACF,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC;IACzC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED;AACA,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,KAAa,KAAa;AAC3D,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK;AAC5B,IAAA,IAAI;QACF,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AACvC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED;AACA,MAAM,eAAe,GAAG,CAAC,GAAW,KAAa;AAC/C,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK;AAC5B,IAAA,IAAI;AACF,QAAA,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,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
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/localStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2C9B,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,gFAAgF;IAChF,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChB,wEAAwE;IACxE,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,mDAAmD;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,CAAC;IACjC,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC3C;AAkBD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,UAAS,uBAAuB,CAAC,CAAC,CAAM,KAAG,gBAAgB,CAAC,CAAC,CAgCnH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,2BAIlC,CAAC"}
|
|
@@ -95,7 +95,13 @@ const createLocalStorageItem = (key, options = {}) => {
|
|
|
95
95
|
},
|
|
96
96
|
set(value) {
|
|
97
97
|
try {
|
|
98
|
-
|
|
98
|
+
const serialized = serialize(value);
|
|
99
|
+
// JSON.stringify (and a custom serializer) can return `undefined` for a
|
|
100
|
+
// top-level `undefined`, function, or symbol — treat that as a failed
|
|
101
|
+
// serialization rather than writing the literal string "undefined".
|
|
102
|
+
if (typeof serialized !== 'string')
|
|
103
|
+
return;
|
|
104
|
+
safeLocalSet(key, serialized);
|
|
99
105
|
}
|
|
100
106
|
catch {
|
|
101
107
|
// serialize() can throw (e.g. circular refs); matches the documented
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;AASG;AAMH,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW;AAE/C;;;;;AAKG;AAEH;AACA,MAAM,YAAY,GAAG,CAAC,GAAW,KAAmB;AAClD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,IAAI;QACF,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC;IACzC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED;AACA,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,KAAa,KAAa;AAC3D,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK;AAC5B,IAAA,IAAI;QACF,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AACvC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED;AACA,MAAM,eAAe,GAAG,CAAC,GAAW,KAAa;AAC/C,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK;AAC5B,IAAA,IAAI;AACF,QAAA,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;AACnC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAoBD;;AAEG;AACH,MAAM,SAAS,GAAG,CAAC,KAAc,KAAuB,OAAO,KAAK,KAAK,SAAS;AAElF;;;;AAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,YAA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AO,IAAI;AAC5B,YAAA,IAAI;AACF,gBAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;AAC9B,gBAAA,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,oBAAA,OAAO,IAAI;AAC7C,gBAAA,OAAO,KAAK;YACd;AAAE,YAAA,MAAM;AACN,gBAAA,OAAO,IAAI;YACb;QACF,CAAC;AACD,QAAA,GAAG,CAAC,KAAK,EAAA;AACP,YAAA,IAAI;AACF,gBAAA,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;;;;gBAInC,IAAI,OAAO,UAAU,KAAK,QAAQ;oBAAE;AACpC,gBAAA,YAAY,CAAC,GAAG,EAAE,UAAU,CAAC;YAC/B;AAAE,YAAA,MAAM;;;YAGR;QACF,CAAC;QACD,KAAK,GAAA;YACH,eAAe,CAAC,GAAG,CAAC;QACtB,CAAC;KACF;AACH;AAEA;;;AAGG;MACU,uBAAuB,GAAG,sBAAsB,CAAU,kBAAkB,CAAC,gBAAgB,EAAE;AAC1G,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAK,kBAAkB,CAAC,GAAG,EAAE,iCAAiC,CAAC;AAChF,IAAA,QAAQ,EAAE,SAAS;AACpB,CAAA;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sessionStorageUtils = require('@flipdish/ui-library/utilities/sessionStorageUtils');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Retry-once-then-crash import logic behind `lazyWithRetry`. Kept as a private
|
|
7
|
+
* sibling module (not re-exported from `index.ts`) so it's directly unit-testable
|
|
8
|
+
* without reaching into `React.lazy()` internals, while staying internal glue —
|
|
9
|
+
* see the atomic-design rule's "Public API vs private sub-components".
|
|
10
|
+
*/
|
|
11
|
+
// biome-ignore lint/suspicious/noExplicitAny: dynamic import factory shape isn't expressible without `any`; preserved from portal-library implementation
|
|
12
|
+
const importWithRetry = async (componentImport) => {
|
|
13
|
+
const pageHasAlreadyBeenForceRefreshed = sessionStorageUtils.pageForceRefreshedStorage.get() === true;
|
|
14
|
+
let component;
|
|
15
|
+
try {
|
|
16
|
+
component = await componentImport();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (!pageHasAlreadyBeenForceRefreshed) {
|
|
20
|
+
// Assuming that the user is not on the latest version of the application.
|
|
21
|
+
// Let's refresh the page immediately.
|
|
22
|
+
sessionStorageUtils.pageForceRefreshedStorage.set(true);
|
|
23
|
+
return window.location.reload();
|
|
24
|
+
}
|
|
25
|
+
// The page has already been reloaded
|
|
26
|
+
// Assuming that user is already using the latest version of the application.
|
|
27
|
+
// Let's let the application crash and raise the error.
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
// Outside the import's try/catch so a storage write failure here can never be
|
|
31
|
+
// mistaken for an import failure (which would otherwise wrongly trigger a reload).
|
|
32
|
+
sessionStorageUtils.pageForceRefreshedStorage.set(false);
|
|
33
|
+
return component;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.importWithRetry = importWithRetry;
|
|
37
|
+
//# sourceMappingURL=importWithRetry.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importWithRetry.utils.cjs","sources":["../../../src/utilities/renderUtils/importWithRetry.utils.ts"],"sourcesContent":[null],"names":["pageForceRefreshedStorage"],"mappings":";;;;AAEA;;;;;AAKG;AACH;MACa,eAAe,GAAG,OAAO,eAA0B,KAAI;IAClE,MAAM,gCAAgC,GAAGA,6CAAyB,CAAC,GAAG,EAAE,KAAK,IAAI;AAEjF,IAAA,IAAI,SAAsD;AAC1D,IAAA,IAAI;AACF,QAAA,SAAS,GAAG,MAAM,eAAe,EAAE;IACrC;IAAE,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,gCAAgC,EAAE;;;AAGrC,YAAAA,6CAAyB,CAAC,GAAG,CAAC,IAAI,CAAC;AACnC,YAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;QACjC;;;;AAKA,QAAA,MAAM,KAAK;IACb;;;AAIA,IAAAA,6CAAyB,CAAC,GAAG,CAAC,KAAK,CAAC;AACpC,IAAA,OAAO,SAAS;AAClB;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry-once-then-crash import logic behind `lazyWithRetry`. Kept as a private
|
|
3
|
+
* sibling module (not re-exported from `index.ts`) so it's directly unit-testable
|
|
4
|
+
* without reaching into `React.lazy()` internals, while staying internal glue —
|
|
5
|
+
* see the atomic-design rule's "Public API vs private sub-components".
|
|
6
|
+
*/
|
|
7
|
+
export declare const importWithRetry: (componentImport: () => any) => Promise<any>;
|
|
8
|
+
//# sourceMappingURL=importWithRetry.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importWithRetry.utils.d.ts","sourceRoot":"","sources":["../../../src/utilities/renderUtils/importWithRetry.utils.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,eAAO,MAAM,eAAe,GAAU,iBAAiB,MAAM,GAAG,iBAwB/D,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { pageForceRefreshedStorage } from '@flipdish/ui-library/utilities/sessionStorageUtils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retry-once-then-crash import logic behind `lazyWithRetry`. Kept as a private
|
|
5
|
+
* sibling module (not re-exported from `index.ts`) so it's directly unit-testable
|
|
6
|
+
* without reaching into `React.lazy()` internals, while staying internal glue —
|
|
7
|
+
* see the atomic-design rule's "Public API vs private sub-components".
|
|
8
|
+
*/
|
|
9
|
+
// biome-ignore lint/suspicious/noExplicitAny: dynamic import factory shape isn't expressible without `any`; preserved from portal-library implementation
|
|
10
|
+
const importWithRetry = async (componentImport) => {
|
|
11
|
+
const pageHasAlreadyBeenForceRefreshed = pageForceRefreshedStorage.get() === true;
|
|
12
|
+
let component;
|
|
13
|
+
try {
|
|
14
|
+
component = await componentImport();
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (!pageHasAlreadyBeenForceRefreshed) {
|
|
18
|
+
// Assuming that the user is not on the latest version of the application.
|
|
19
|
+
// Let's refresh the page immediately.
|
|
20
|
+
pageForceRefreshedStorage.set(true);
|
|
21
|
+
return window.location.reload();
|
|
22
|
+
}
|
|
23
|
+
// The page has already been reloaded
|
|
24
|
+
// Assuming that user is already using the latest version of the application.
|
|
25
|
+
// Let's let the application crash and raise the error.
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
// Outside the import's try/catch so a storage write failure here can never be
|
|
29
|
+
// mistaken for an import failure (which would otherwise wrongly trigger a reload).
|
|
30
|
+
pageForceRefreshedStorage.set(false);
|
|
31
|
+
return component;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { importWithRetry };
|
|
35
|
+
//# sourceMappingURL=importWithRetry.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importWithRetry.utils.js","sources":["../../../src/utilities/renderUtils/importWithRetry.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;AAKG;AACH;MACa,eAAe,GAAG,OAAO,eAA0B,KAAI;IAClE,MAAM,gCAAgC,GAAG,yBAAyB,CAAC,GAAG,EAAE,KAAK,IAAI;AAEjF,IAAA,IAAI,SAAsD;AAC1D,IAAA,IAAI;AACF,QAAA,SAAS,GAAG,MAAM,eAAe,EAAE;IACrC;IAAE,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,gCAAgC,EAAE;;;AAGrC,YAAA,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC;AACnC,YAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;QACjC;;;;AAKA,QAAA,MAAM,KAAK;IACb;;;AAIA,IAAA,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC;AACpC,IAAA,OAAO,SAAS;AAClB;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
+
var importWithRetry_utils = require('./importWithRetry.utils.cjs');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Retrieves an environment variable.
|
|
@@ -91,26 +92,7 @@ const getIsFlipdishStaff = () => {
|
|
|
91
92
|
return stringValue?.toString() === 'true';
|
|
92
93
|
};
|
|
93
94
|
// biome-ignore lint/suspicious/noExplicitAny: dynamic import factory shape isn't expressible without `any`; preserved from portal-library implementation
|
|
94
|
-
const lazyWithRetry = (componentImport) => React.lazy(
|
|
95
|
-
const pageHasAlreadyBeenForceRefreshed = JSON.parse(window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false');
|
|
96
|
-
try {
|
|
97
|
-
const component = await componentImport();
|
|
98
|
-
window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');
|
|
99
|
-
return component;
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
if (!pageHasAlreadyBeenForceRefreshed) {
|
|
103
|
-
// Assuming that the user is not on the latest version of the application.
|
|
104
|
-
// Let's refresh the page immediately.
|
|
105
|
-
window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');
|
|
106
|
-
return window.location.reload();
|
|
107
|
-
}
|
|
108
|
-
// The page has already been reloaded
|
|
109
|
-
// Assuming that user is already using the latest version of the application.
|
|
110
|
-
// Let's let the application crash and raise the error.
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
95
|
+
const lazyWithRetry = (componentImport) => React.lazy(() => importWithRetry_utils.importWithRetry(componentImport));
|
|
114
96
|
|
|
115
97
|
exports.getAppId = getAppId;
|
|
116
98
|
exports.getBrandId = getBrandId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":["lazy"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":["lazy","importWithRetry"],"mappings":";;;;;AAIA;;;;;AAKG;AACI,MAAM,sBAAsB,GAAG,CAAC,GAAW,KAAY;;AAE5D,IAAA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;AACzF,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAW;IACnC;;;;;AAKA,IAAA,IAAI;;QAEF,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,GAAqD;AAC1F,QAAA,OAAO,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE;IAC7B;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,EAAE;IACX;AACF;AAEA;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,GAAW,KAAY;AAC/D,IAAA,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACnC,QAAA,OAAO,EAAE;IACX;IACA,MAAM,gBAAgB,GAAG,QAAQ,CAAC,cAAc,CAAC,yBAAyB,CAAC;IAC3E,OAAO,gBAAgB,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE;AAClD;AAEA;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG,MAAa;AACnC,IAAA,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,IAAI,yBAAyB,CAAC,aAAa,CAAC,IAAI,yBAAyB,CAAC,YAAY,CAAC;AAC7I;AAEA;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG,MAAa;AACnC,IAAA,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,IAAI,yBAAyB,CAAC,aAAa,CAAC,IAAI,yBAAyB,CAAC,YAAY,CAAC;AAC7I;AAEA;;;;;;;;AAQG;AACI,MAAM,UAAU,GAAG,MAAa;AACrC,IAAA,OAAO,sBAAsB,CAAC,uBAAuB,CAAC,IAAI,yBAAyB,CAAC,eAAe,CAAC,IAAI,yBAAyB,CAAC,cAAc,CAAC;AACnJ;AAEA;;;;;;;;AAQG;AACI,MAAM,kBAAkB,GAAG,MAAc;AAC9C,IAAA,MAAM,WAAW,GACf,sBAAsB,CAAC,8BAA8B,CAAC;QACtD,yBAAyB,CAAC,wBAAwB,CAAC;QACnD,yBAAyB,CAAC,sBAAsB,CAAC;AACnD,IAAA,OAAO,WAAW,EAAE,QAAQ,EAAE,KAAK,MAAM;AAC3C;AAEA;AACO,MAAM,aAAa,GAAG,CAAC,eAA0B,KAAKA,UAAI,CAAC,MAAMC,qCAAe,CAAC,eAAe,CAAC;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/renderUtils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/renderUtils/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,KAAG,MAgBpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,KAAK,MAAM,KAAG,MAMvD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,QAAO,MAE3B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,QAAO,MAE3B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,QAAO,OAMrC,CAAC;AAGF,eAAO,MAAM,aAAa,GAAI,iBAAiB,MAAM,GAAG,4EAAiD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { lazy } from 'react';
|
|
2
|
+
import { importWithRetry } from './importWithRetry.utils.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Retrieves an environment variable.
|
|
@@ -89,26 +90,7 @@ const getIsFlipdishStaff = () => {
|
|
|
89
90
|
return stringValue?.toString() === 'true';
|
|
90
91
|
};
|
|
91
92
|
// biome-ignore lint/suspicious/noExplicitAny: dynamic import factory shape isn't expressible without `any`; preserved from portal-library implementation
|
|
92
|
-
const lazyWithRetry = (componentImport) => lazy(
|
|
93
|
-
const pageHasAlreadyBeenForceRefreshed = JSON.parse(window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false');
|
|
94
|
-
try {
|
|
95
|
-
const component = await componentImport();
|
|
96
|
-
window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');
|
|
97
|
-
return component;
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
if (!pageHasAlreadyBeenForceRefreshed) {
|
|
101
|
-
// Assuming that the user is not on the latest version of the application.
|
|
102
|
-
// Let's refresh the page immediately.
|
|
103
|
-
window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');
|
|
104
|
-
return window.location.reload();
|
|
105
|
-
}
|
|
106
|
-
// The page has already been reloaded
|
|
107
|
-
// Assuming that user is already using the latest version of the application.
|
|
108
|
-
// Let's let the application crash and raise the error.
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
93
|
+
const lazyWithRetry = (componentImport) => lazy(() => importWithRetry(componentImport));
|
|
112
94
|
|
|
113
95
|
export { getAppId, getBrandId, getEnvironmentVariable, getIsFlipdishStaff, getMicroFrontendAttribute, getOrgId, lazyWithRetry };
|
|
114
96
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA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AAEA;;;;;;;;AAQG;AACI,MAAM,kBAAkB,GAAG,MAAc;AAC9C,IAAA,MAAM,WAAW,GACf,sBAAsB,CAAC,8BAA8B,CAAC;QACtD,yBAAyB,CAAC,wBAAwB,CAAC;QACnD,yBAAyB,CAAC,sBAAsB,CAAC;AACnD,IAAA,OAAO,WAAW,EAAE,QAAQ,EAAE,KAAK,MAAM;AAC3C;AAEA;AACO,MAAM,aAAa,GAAG,CAAC,eAA0B,KAAK,IAAI,CAAC,MAAM,eAAe,CAAC,eAAe,CAAC;;;;"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sessionStorageUtils_constants = require('./sessionStorageUtils.constants.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Web-only, typed `sessionStorage` persistence. DOM access (`window.sessionStorage`)
|
|
7
|
+
* lives here rather than in components, so component code stays free of `window.*`
|
|
8
|
+
* and keeps React Native parity — this is the `sessionStorage` counterpart of
|
|
9
|
+
* `localStorageUtils` (same isolation pattern). Every helper no-ops / returns
|
|
10
|
+
* `null` when `sessionStorage` is unavailable (SSR, React Native, private mode,
|
|
11
|
+
* quota errors).
|
|
12
|
+
*
|
|
13
|
+
* Every key this package persists is registered in `sessionStorageUtils.constants.ts`
|
|
14
|
+
* — check there for the full list before adding a new one.
|
|
15
|
+
*/
|
|
16
|
+
const isBrowser = typeof window !== 'undefined';
|
|
17
|
+
/**
|
|
18
|
+
* Internal `sessionStorage` primitives backing `createSessionStorageItem`. Not
|
|
19
|
+
* exported — everything a consumer needs goes through `createSessionStorageItem`,
|
|
20
|
+
* which adds typed serialization/validation on top. Add a raw string export
|
|
21
|
+
* here only once a real caller needs plain-string storage without JSON typing.
|
|
22
|
+
*/
|
|
23
|
+
/** Read a raw string value, or `null` when unset/unavailable. */
|
|
24
|
+
const safeSessionGet = (key) => {
|
|
25
|
+
if (!isBrowser)
|
|
26
|
+
return null;
|
|
27
|
+
try {
|
|
28
|
+
return window.sessionStorage.getItem(key);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/** Persist a raw string value; returns whether the write succeeded. */
|
|
35
|
+
const safeSessionSet = (key, value) => {
|
|
36
|
+
if (!isBrowser)
|
|
37
|
+
return false;
|
|
38
|
+
try {
|
|
39
|
+
window.sessionStorage.setItem(key, value);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/** Remove a value; returns whether the removal succeeded. */
|
|
47
|
+
const safeSessionRemove = (key) => {
|
|
48
|
+
if (!isBrowser)
|
|
49
|
+
return false;
|
|
50
|
+
try {
|
|
51
|
+
window.sessionStorage.removeItem(key);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Reusable `validate` guard for a `createSessionStorageItem<boolean>` item.
|
|
60
|
+
*/
|
|
61
|
+
const isBoolean = (value) => typeof value === 'boolean';
|
|
62
|
+
/**
|
|
63
|
+
* Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
|
|
64
|
+
* `errorMessage` for anything else so `createSessionStorageItem.get()` treats it
|
|
65
|
+
* as invalid data and returns `null`.
|
|
66
|
+
*/
|
|
67
|
+
const parseBooleanString = (raw, errorMessage) => {
|
|
68
|
+
if (raw === 'true')
|
|
69
|
+
return true;
|
|
70
|
+
if (raw === 'false')
|
|
71
|
+
return false;
|
|
72
|
+
throw new Error(errorMessage);
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Build a typed, failure-safe accessor for a single `sessionStorage` key.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const draft = createSessionStorageItem<Draft>('fd-draft');
|
|
79
|
+
* draft.set({ title: 'Hi' });
|
|
80
|
+
* const value = draft.get(); // Draft | null
|
|
81
|
+
*/
|
|
82
|
+
const createSessionStorageItem = (key, options = {}) => {
|
|
83
|
+
const { serialize = JSON.stringify, deserialize = JSON.parse, validate } = options;
|
|
84
|
+
return {
|
|
85
|
+
get() {
|
|
86
|
+
const raw = safeSessionGet(key);
|
|
87
|
+
if (raw == null)
|
|
88
|
+
return null;
|
|
89
|
+
try {
|
|
90
|
+
const value = deserialize(raw);
|
|
91
|
+
if (validate && !validate(value))
|
|
92
|
+
return null;
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
set(value) {
|
|
100
|
+
try {
|
|
101
|
+
const serialized = serialize(value);
|
|
102
|
+
// JSON.stringify (and a custom serializer) can return `undefined` for a
|
|
103
|
+
// top-level `undefined`, function, or symbol — treat that as a failed
|
|
104
|
+
// serialization rather than writing the literal string "undefined".
|
|
105
|
+
if (typeof serialized !== 'string')
|
|
106
|
+
return;
|
|
107
|
+
safeSessionSet(key, serialized);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// serialize() can throw (e.g. circular refs); matches the documented
|
|
111
|
+
// failure-safe contract — silently ignore, same as a write failure.
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
clear() {
|
|
115
|
+
safeSessionRemove(key);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Persistence for `lazyWithRetry`'s force-refresh-once marker. Stored as the
|
|
121
|
+
* plain strings `'true'` / `'false'` to preserve the original portal-library format.
|
|
122
|
+
*/
|
|
123
|
+
const pageForceRefreshedStorage = createSessionStorageItem(sessionStorageUtils_constants.SESSION_STORAGE_KEYS.pageHasBeenForceRefreshed, {
|
|
124
|
+
serialize: String,
|
|
125
|
+
deserialize: (raw) => parseBooleanString(raw, 'Invalid page-force-refreshed value'),
|
|
126
|
+
validate: isBoolean,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
exports.SESSION_STORAGE_KEYS = sessionStorageUtils_constants.SESSION_STORAGE_KEYS;
|
|
130
|
+
exports.createSessionStorageItem = createSessionStorageItem;
|
|
131
|
+
exports.pageForceRefreshedStorage = pageForceRefreshedStorage;
|
|
132
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"sourcesContent":[null],"names":["SESSION_STORAGE_KEYS"],"mappings":";;;;AAAA;;;;;;;;;;AAUG;AAMH,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW;AAE/C;;;;;AAKG;AAEH;AACA,MAAM,cAAc,GAAG,CAAC,GAAW,KAAmB;AACpD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,IAAI;QACF,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC;IAC3C;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED;AACA,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,KAAa,KAAa;AAC7D,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK;AAC5B,IAAA,IAAI;QACF,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AACzC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED;AACA,MAAM,iBAAiB,GAAG,CAAC,GAAW,KAAa;AACjD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK;AAC5B,IAAA,IAAI;AACF,QAAA,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC;AACrC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IAC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AC;QACxB,CAAC;KACF;AACH;AAEA;;;AAGG;MACU,yBAAyB,GAAG,wBAAwB,CAAUA,kDAAoB,CAAC,yBAAyB,EAAE;AACzH,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAK,kBAAkB,CAAC,GAAG,EAAE,oCAAoC,CAAC;AACnF,IAAA,QAAQ,EAAE,SAAS;AACpB,CAAA;;;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web-only, typed `sessionStorage` persistence. DOM access (`window.sessionStorage`)
|
|
3
|
+
* lives here rather than in components, so component code stays free of `window.*`
|
|
4
|
+
* and keeps React Native parity — this is the `sessionStorage` counterpart of
|
|
5
|
+
* `localStorageUtils` (same isolation pattern). Every helper no-ops / returns
|
|
6
|
+
* `null` when `sessionStorage` is unavailable (SSR, React Native, private mode,
|
|
7
|
+
* quota errors).
|
|
8
|
+
*
|
|
9
|
+
* Every key this package persists is registered in `sessionStorageUtils.constants.ts`
|
|
10
|
+
* — check there for the full list before adding a new one.
|
|
11
|
+
*/
|
|
12
|
+
import { SESSION_STORAGE_KEYS } from './sessionStorageUtils.constants';
|
|
13
|
+
export { SESSION_STORAGE_KEYS };
|
|
14
|
+
export interface SessionStorageItem<T> {
|
|
15
|
+
/** Read and deserialize the value, or `null` when unset/invalid/unavailable. */
|
|
16
|
+
get(): T | null;
|
|
17
|
+
/** Serialize and persist the value; silently ignores write failures. */
|
|
18
|
+
set(value: T): void;
|
|
19
|
+
/** Remove the value; silently ignores failures. */
|
|
20
|
+
clear(): void;
|
|
21
|
+
}
|
|
22
|
+
export interface SessionStorageItemOptions<T> {
|
|
23
|
+
/** Serialize before writing. Defaults to `JSON.stringify`. */
|
|
24
|
+
serialize?: (value: T) => string;
|
|
25
|
+
/** Deserialize after reading. Defaults to `JSON.parse`. */
|
|
26
|
+
deserialize?: (raw: string) => T;
|
|
27
|
+
/** Optional runtime guard; `get()` returns `null` when it fails. */
|
|
28
|
+
validate?: (value: unknown) => value is T;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build a typed, failure-safe accessor for a single `sessionStorage` key.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const draft = createSessionStorageItem<Draft>('fd-draft');
|
|
35
|
+
* draft.set({ title: 'Hi' });
|
|
36
|
+
* const value = draft.get(); // Draft | null
|
|
37
|
+
*/
|
|
38
|
+
export declare const createSessionStorageItem: <T>(key: string, options?: SessionStorageItemOptions<T>) => SessionStorageItem<T>;
|
|
39
|
+
/**
|
|
40
|
+
* Persistence for `lazyWithRetry`'s force-refresh-once marker. Stored as the
|
|
41
|
+
* plain strings `'true'` / `'false'` to preserve the original portal-library format.
|
|
42
|
+
*/
|
|
43
|
+
export declare const pageForceRefreshedStorage: SessionStorageItem<boolean>;
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AA2ChC,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,gFAAgF;IAChF,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChB,wEAAwE;IACxE,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,mDAAmD;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,CAAC;IACjC,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC3C;AAkBD;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,UAAS,yBAAyB,CAAC,CAAC,CAAM,KAAG,kBAAkB,CAAC,CAAC,CAgCzH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,6BAIpC,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { SESSION_STORAGE_KEYS } from './sessionStorageUtils.constants.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Web-only, typed `sessionStorage` persistence. DOM access (`window.sessionStorage`)
|
|
5
|
+
* lives here rather than in components, so component code stays free of `window.*`
|
|
6
|
+
* and keeps React Native parity — this is the `sessionStorage` counterpart of
|
|
7
|
+
* `localStorageUtils` (same isolation pattern). Every helper no-ops / returns
|
|
8
|
+
* `null` when `sessionStorage` is unavailable (SSR, React Native, private mode,
|
|
9
|
+
* quota errors).
|
|
10
|
+
*
|
|
11
|
+
* Every key this package persists is registered in `sessionStorageUtils.constants.ts`
|
|
12
|
+
* — check there for the full list before adding a new one.
|
|
13
|
+
*/
|
|
14
|
+
const isBrowser = typeof window !== 'undefined';
|
|
15
|
+
/**
|
|
16
|
+
* Internal `sessionStorage` primitives backing `createSessionStorageItem`. Not
|
|
17
|
+
* exported — everything a consumer needs goes through `createSessionStorageItem`,
|
|
18
|
+
* which adds typed serialization/validation on top. Add a raw string export
|
|
19
|
+
* here only once a real caller needs plain-string storage without JSON typing.
|
|
20
|
+
*/
|
|
21
|
+
/** Read a raw string value, or `null` when unset/unavailable. */
|
|
22
|
+
const safeSessionGet = (key) => {
|
|
23
|
+
if (!isBrowser)
|
|
24
|
+
return null;
|
|
25
|
+
try {
|
|
26
|
+
return window.sessionStorage.getItem(key);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
/** Persist a raw string value; returns whether the write succeeded. */
|
|
33
|
+
const safeSessionSet = (key, value) => {
|
|
34
|
+
if (!isBrowser)
|
|
35
|
+
return false;
|
|
36
|
+
try {
|
|
37
|
+
window.sessionStorage.setItem(key, value);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/** Remove a value; returns whether the removal succeeded. */
|
|
45
|
+
const safeSessionRemove = (key) => {
|
|
46
|
+
if (!isBrowser)
|
|
47
|
+
return false;
|
|
48
|
+
try {
|
|
49
|
+
window.sessionStorage.removeItem(key);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Reusable `validate` guard for a `createSessionStorageItem<boolean>` item.
|
|
58
|
+
*/
|
|
59
|
+
const isBoolean = (value) => typeof value === 'boolean';
|
|
60
|
+
/**
|
|
61
|
+
* Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
|
|
62
|
+
* `errorMessage` for anything else so `createSessionStorageItem.get()` treats it
|
|
63
|
+
* as invalid data and returns `null`.
|
|
64
|
+
*/
|
|
65
|
+
const parseBooleanString = (raw, errorMessage) => {
|
|
66
|
+
if (raw === 'true')
|
|
67
|
+
return true;
|
|
68
|
+
if (raw === 'false')
|
|
69
|
+
return false;
|
|
70
|
+
throw new Error(errorMessage);
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Build a typed, failure-safe accessor for a single `sessionStorage` key.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const draft = createSessionStorageItem<Draft>('fd-draft');
|
|
77
|
+
* draft.set({ title: 'Hi' });
|
|
78
|
+
* const value = draft.get(); // Draft | null
|
|
79
|
+
*/
|
|
80
|
+
const createSessionStorageItem = (key, options = {}) => {
|
|
81
|
+
const { serialize = JSON.stringify, deserialize = JSON.parse, validate } = options;
|
|
82
|
+
return {
|
|
83
|
+
get() {
|
|
84
|
+
const raw = safeSessionGet(key);
|
|
85
|
+
if (raw == null)
|
|
86
|
+
return null;
|
|
87
|
+
try {
|
|
88
|
+
const value = deserialize(raw);
|
|
89
|
+
if (validate && !validate(value))
|
|
90
|
+
return null;
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
set(value) {
|
|
98
|
+
try {
|
|
99
|
+
const serialized = serialize(value);
|
|
100
|
+
// JSON.stringify (and a custom serializer) can return `undefined` for a
|
|
101
|
+
// top-level `undefined`, function, or symbol — treat that as a failed
|
|
102
|
+
// serialization rather than writing the literal string "undefined".
|
|
103
|
+
if (typeof serialized !== 'string')
|
|
104
|
+
return;
|
|
105
|
+
safeSessionSet(key, serialized);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// serialize() can throw (e.g. circular refs); matches the documented
|
|
109
|
+
// failure-safe contract — silently ignore, same as a write failure.
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
clear() {
|
|
113
|
+
safeSessionRemove(key);
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Persistence for `lazyWithRetry`'s force-refresh-once marker. Stored as the
|
|
119
|
+
* plain strings `'true'` / `'false'` to preserve the original portal-library format.
|
|
120
|
+
*/
|
|
121
|
+
const pageForceRefreshedStorage = createSessionStorageItem(SESSION_STORAGE_KEYS.pageHasBeenForceRefreshed, {
|
|
122
|
+
serialize: String,
|
|
123
|
+
deserialize: (raw) => parseBooleanString(raw, 'Invalid page-force-refreshed value'),
|
|
124
|
+
validate: isBoolean,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export { SESSION_STORAGE_KEYS, createSessionStorageItem, pageForceRefreshedStorage };
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;AAMH,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW;AAE/C;;;;;AAKG;AAEH;AACA,MAAM,cAAc,GAAG,CAAC,GAAW,KAAmB;AACpD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,IAAI;QACF,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC;IAC3C;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED;AACA,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,KAAa,KAAa;AAC7D,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK;AAC5B,IAAA,IAAI;QACF,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AACzC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED;AACA,MAAM,iBAAiB,GAAG,CAAC,GAAW,KAAa;AACjD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK;AAC5B,IAAA,IAAI;AACF,QAAA,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC;AACrC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAoBD;;AAEG;AACH,MAAM,SAAS,GAAG,CAAC,KAAc,KAAuB,OAAO,KAAK,KAAK,SAAS;AAElF;;;;AAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,YAAoB,KAAa;IACxE,IAAI,GAAG,KAAK,MAAM;AAAE,QAAA,OAAO,IAAI;IAC/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Q,EAAE,SAAS;AACpB,CAAA;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Central registry of every `sessionStorage` key `@flipdish/ui-library` writes.
|
|
5
|
+
* Add a new key here whenever a component needs to persist per-tab state via
|
|
6
|
+
* `createSessionStorageItem` (see `index.ts`), so this file stays the single
|
|
7
|
+
* place to see everything the library puts in `sessionStorage`.
|
|
8
|
+
*/
|
|
9
|
+
const SESSION_STORAGE_KEYS = {
|
|
10
|
+
/** `lazyWithRetry`'s force-refresh-once marker (key name preserved from the portal-library implementation). */
|
|
11
|
+
pageHasBeenForceRefreshed: 'fd-page-has-been-force-refreshed',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.SESSION_STORAGE_KEYS = SESSION_STORAGE_KEYS;
|
|
15
|
+
//# sourceMappingURL=sessionStorageUtils.constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionStorageUtils.constants.cjs","sources":["../../../src/utilities/sessionStorageUtils/sessionStorageUtils.constants.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;AAKG;AACI,MAAM,oBAAoB,GAAG;;AAElC,IAAA,yBAAyB,EAAE,kCAAkC;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central registry of every `sessionStorage` key `@flipdish/ui-library` writes.
|
|
3
|
+
* Add a new key here whenever a component needs to persist per-tab state via
|
|
4
|
+
* `createSessionStorageItem` (see `index.ts`), so this file stays the single
|
|
5
|
+
* place to see everything the library puts in `sessionStorage`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SESSION_STORAGE_KEYS: {
|
|
8
|
+
/** `lazyWithRetry`'s force-refresh-once marker (key name preserved from the portal-library implementation). */
|
|
9
|
+
readonly pageHasBeenForceRefreshed: "fd-page-has-been-force-refreshed";
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=sessionStorageUtils.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionStorageUtils.constants.d.ts","sourceRoot":"","sources":["../../../src/utilities/sessionStorageUtils/sessionStorageUtils.constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;IAC/B,+GAA+G;;CAEvG,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central registry of every `sessionStorage` key `@flipdish/ui-library` writes.
|
|
3
|
+
* Add a new key here whenever a component needs to persist per-tab state via
|
|
4
|
+
* `createSessionStorageItem` (see `index.ts`), so this file stays the single
|
|
5
|
+
* place to see everything the library puts in `sessionStorage`.
|
|
6
|
+
*/
|
|
7
|
+
const SESSION_STORAGE_KEYS = {
|
|
8
|
+
/** `lazyWithRetry`'s force-refresh-once marker (key name preserved from the portal-library implementation). */
|
|
9
|
+
pageHasBeenForceRefreshed: 'fd-page-has-been-force-refreshed',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { SESSION_STORAGE_KEYS };
|
|
13
|
+
//# sourceMappingURL=sessionStorageUtils.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionStorageUtils.constants.js","sources":["../../../src/utilities/sessionStorageUtils/sessionStorageUtils.constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AACI,MAAM,oBAAoB,GAAG;;AAElC,IAAA,yBAAyB,EAAE,kCAAkC;;;;;"}
|
package/package.json
CHANGED