@crystaldesign/widget-library 25.8.0-rc.0 → 25.8.0-rc.10
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/build/esm/index.js +10 -3
- package/build/types/widget-library/src/hooks/useGlobalCache.d.ts +6 -1
- package/build/types/widget-library/src/hooks/useGlobalCache.d.ts.map +1 -1
- package/build/types/widget-library/src/hooks/useProductData.d.ts +6 -1
- package/build/types/widget-library/src/hooks/useProductData.d.ts.map +1 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -99,9 +99,14 @@ if (typeof window !== 'undefined' && !window.__divaWidgetCache) {
|
|
|
99
99
|
*/
|
|
100
100
|
function useGlobalCache(_ref) {
|
|
101
101
|
var uniqueWidgetId = _ref.uniqueWidgetId,
|
|
102
|
-
widgetType = _ref.widgetType
|
|
102
|
+
widgetType = _ref.widgetType,
|
|
103
|
+
noGlobalCache = _ref.noGlobalCache;
|
|
103
104
|
var getOrFetch = useCallback(function (key, fetcher) {
|
|
104
105
|
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] getOrFetch called for key: ").concat(key));
|
|
106
|
+
if (noGlobalCache) {
|
|
107
|
+
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] Global cache disabled, fetching directly for key: ").concat(key));
|
|
108
|
+
return fetcher();
|
|
109
|
+
}
|
|
105
110
|
if (typeof window === 'undefined' || !window.__divaWidgetCache) {
|
|
106
111
|
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] No global cache available, fetching directly for key: ").concat(key));
|
|
107
112
|
return fetcher();
|
|
@@ -259,7 +264,8 @@ var generateWidgetId = function generateWidgetId() {
|
|
|
259
264
|
function useProductData(_ref) {
|
|
260
265
|
var productIds = _ref.productIds,
|
|
261
266
|
variants = _ref.variants,
|
|
262
|
-
widgetType = _ref.widgetType
|
|
267
|
+
widgetType = _ref.widgetType,
|
|
268
|
+
noGlobalCache = _ref.noGlobalCache;
|
|
263
269
|
// Generate stable widget ID that persists for the lifetime of this hook instance
|
|
264
270
|
// Function to handle selectedProduct changes
|
|
265
271
|
|
|
@@ -270,7 +276,8 @@ function useProductData(_ref) {
|
|
|
270
276
|
handler = _useDivaCore.handler;
|
|
271
277
|
var _useGlobalCache = useGlobalCache({
|
|
272
278
|
uniqueWidgetId: widgetId,
|
|
273
|
-
widgetType: widgetType
|
|
279
|
+
widgetType: widgetType,
|
|
280
|
+
noGlobalCache: noGlobalCache
|
|
274
281
|
}),
|
|
275
282
|
getOrFetch = _useGlobalCache.getOrFetch,
|
|
276
283
|
setCache = _useGlobalCache.setCache;
|
|
@@ -51,6 +51,11 @@ interface UseGlobalCacheProps {
|
|
|
51
51
|
* Widget type, used for events and logging
|
|
52
52
|
*/
|
|
53
53
|
widgetType: string;
|
|
54
|
+
/**
|
|
55
|
+
* If true, the global cache will not be used
|
|
56
|
+
* This is used in the product list, where we always want to fetch the latest data
|
|
57
|
+
*/
|
|
58
|
+
noGlobalCache?: boolean;
|
|
54
59
|
}
|
|
55
60
|
declare global {
|
|
56
61
|
interface Window {
|
|
@@ -63,6 +68,6 @@ declare global {
|
|
|
63
68
|
* Global cache for shared data between widgets of a website
|
|
64
69
|
* Simple implementation with request deduplication
|
|
65
70
|
*/
|
|
66
|
-
export declare function useGlobalCache({ uniqueWidgetId, widgetType }: UseGlobalCacheProps): DivaWidgetCache;
|
|
71
|
+
export declare function useGlobalCache({ uniqueWidgetId, widgetType, noGlobalCache }: UseGlobalCacheProps): DivaWidgetCache;
|
|
67
72
|
export {};
|
|
68
73
|
//# sourceMappingURL=useGlobalCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGlobalCache.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useGlobalCache.ts"],"names":[],"mappings":"AAKA,UAAU,UAAU,CAAC,CAAC;IACpB;;OAEG;IACH,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IACj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AAC,EAAE,CAAC,CAAC;IAC1E;;;OAGG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAC;IAErB;;;;OAIG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAC5C;AAED,UAAU,mBAAmB;IAC3B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,iBAAiB,EAAE;YACjB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;SACrC,CAAC;KACH;CACF;AASD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,mBAAmB,GAAG,eAAe,CAuGlH"}
|
|
@@ -6,8 +6,13 @@ export interface UseProductDataProps {
|
|
|
6
6
|
* Widget type, used for logging
|
|
7
7
|
*/
|
|
8
8
|
widgetType: string;
|
|
9
|
+
/**
|
|
10
|
+
* If true, the global cache will not be used
|
|
11
|
+
* This is used in the product list, where we always want to fetch the latest data
|
|
12
|
+
*/
|
|
13
|
+
noGlobalCache?: boolean;
|
|
9
14
|
}
|
|
10
|
-
export declare function useProductData({ productIds, variants, widgetType }: UseProductDataProps): {
|
|
15
|
+
export declare function useProductData({ productIds, variants, widgetType, noGlobalCache }: UseProductDataProps): {
|
|
11
16
|
productVariants: ProductData[];
|
|
12
17
|
error: boolean;
|
|
13
18
|
loading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProductData.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useProductData.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,WAAW,EAA0B,MAAM,0BAA0B,CAAC;AAM1F,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"useProductData.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useProductData.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,WAAW,EAA0B,MAAM,0BAA0B,CAAC;AAM1F,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAKD,wBAAgB,cAAc,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,mBAAmB;;;;oCA2JxD,MAAM,EAAE,KAAG,OAAO,CAAC,GAAG,CAAC;6CAyBd,MAAM,cAAc,MAAM,KAAG,OAAO,CAAC,GAAG,CAAC;;sCAxE3E,MAAM;2BAmGI,MAAM,QAAQ,GAAG;EAiBhD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crystaldesign/widget-library",
|
|
3
|
-
"version": "25.8.0-rc.
|
|
3
|
+
"version": "25.8.0-rc.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"storybook": "storybook dev -p 6006",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"suiteName": "widget-library",
|
|
37
37
|
"outputDirectory": "./test-reports"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "d67612c661ebed752cd2228d631bd5413484cf0c"
|
|
40
40
|
}
|