@next-core/brick-kit 2.152.1 → 2.153.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/dist/index.bundle.js +62 -32
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +62 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/hooks/useProvider/fetch.d.ts +1 -1
- package/dist/types/hooks/useProvider/fetch.d.ts.map +1 -1
- package/dist/types/hooks/useProvider/useProvider.d.ts.map +1 -1
- package/dist/types/hooks/useProvider/useProviderArgsDefaults.d.ts.map +1 -1
- package/dist/types/hooks/useProvider/useProviderTypes.d.ts +1 -0
- package/dist/types/hooks/useProvider/useProviderTypes.d.ts.map +1 -1
- package/package.json +10 -10
package/dist/index.bundle.js
CHANGED
|
@@ -12512,17 +12512,20 @@
|
|
|
12512
12512
|
route_alias: route === null || route === void 0 ? void 0 : route.alias
|
|
12513
12513
|
}, analyticsData));
|
|
12514
12514
|
_this3.state = "mounted";
|
|
12515
|
-
devtoolsHookEmit("rendered");
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
|
|
12515
|
+
devtoolsHookEmit("rendered");
|
|
12516
|
+
|
|
12517
|
+
if (!_this3.featureFlags["disable-prefetch-scripts"]) {
|
|
12518
|
+
// Try to prefetch during a browser's idle periods.
|
|
12519
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback
|
|
12520
|
+
if (typeof window.requestIdleCallback === "function") {
|
|
12521
|
+
window.requestIdleCallback(() => {
|
|
12522
|
+
_this3.kernel.prefetchDepsOfStoryboard(storyboard);
|
|
12523
|
+
});
|
|
12524
|
+
} else {
|
|
12525
|
+
setTimeout(() => {
|
|
12526
|
+
_this3.kernel.prefetchDepsOfStoryboard(storyboard);
|
|
12527
|
+
}, 0);
|
|
12528
|
+
}
|
|
12526
12529
|
}
|
|
12527
12530
|
|
|
12528
12531
|
return;
|
|
@@ -14834,7 +14837,8 @@
|
|
|
14834
14837
|
transform: (oldData, newData) => newData,
|
|
14835
14838
|
data: undefined,
|
|
14836
14839
|
loading: false,
|
|
14837
|
-
suspense: false
|
|
14840
|
+
suspense: false,
|
|
14841
|
+
cache: true
|
|
14838
14842
|
},
|
|
14839
14843
|
dependencies: undefined
|
|
14840
14844
|
};
|
|
@@ -14907,7 +14911,7 @@
|
|
|
14907
14911
|
};
|
|
14908
14912
|
}
|
|
14909
14913
|
|
|
14910
|
-
var cache
|
|
14914
|
+
var cache = new Map();
|
|
14911
14915
|
function fetchProviderArgs(_x, _x2) {
|
|
14912
14916
|
return _fetchProviderArgs.apply(this, arguments);
|
|
14913
14917
|
}
|
|
@@ -14923,33 +14927,57 @@
|
|
|
14923
14927
|
args,
|
|
14924
14928
|
originalArgs
|
|
14925
14929
|
});
|
|
14926
|
-
if (cache
|
|
14930
|
+
if (cache.has(cacheKey)) return cache.get(cacheKey);
|
|
14927
14931
|
var actualArgs = yield getArgsOfCustomApi(provider, [...args, ...originalArgs]);
|
|
14928
|
-
cache
|
|
14932
|
+
cache.set(cacheKey, actualArgs);
|
|
14929
14933
|
return actualArgs;
|
|
14930
14934
|
});
|
|
14931
14935
|
return _fetchProviderArgs.apply(this, arguments);
|
|
14932
14936
|
}
|
|
14933
14937
|
|
|
14934
|
-
var
|
|
14935
|
-
|
|
14936
|
-
|
|
14938
|
+
var cacheMap = new Map();
|
|
14939
|
+
|
|
14940
|
+
function isObj(v) {
|
|
14941
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
14937
14942
|
}
|
|
14938
14943
|
|
|
14939
|
-
function
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
}
|
|
14944
|
+
function buildSortedCacheKey(provider, args) {
|
|
14945
|
+
var sortObj = obj => Object.keys(obj).sort().map(k => ({
|
|
14946
|
+
[k]: obj[k]
|
|
14947
|
+
}));
|
|
14944
14948
|
|
|
14945
|
-
|
|
14949
|
+
try {
|
|
14950
|
+
var sortedArgs = isObj(args) ? sortObj(args) : args.map(arg => sortObj(arg));
|
|
14951
|
+
return JSON.stringify({
|
|
14952
|
+
provider,
|
|
14953
|
+
args: sortedArgs
|
|
14954
|
+
});
|
|
14955
|
+
} catch (e) {
|
|
14956
|
+
return JSON.stringify({
|
|
14946
14957
|
provider,
|
|
14947
14958
|
args
|
|
14948
14959
|
});
|
|
14949
|
-
|
|
14960
|
+
}
|
|
14961
|
+
}
|
|
14962
|
+
|
|
14963
|
+
function fetch(_x, _x2) {
|
|
14964
|
+
return _fetch.apply(this, arguments);
|
|
14965
|
+
}
|
|
14966
|
+
|
|
14967
|
+
function _fetch() {
|
|
14968
|
+
_fetch = _asyncToGenerator__default["default"](function* (provider, cache) {
|
|
14969
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
14970
|
+
args[_key - 2] = arguments[_key];
|
|
14971
|
+
}
|
|
14972
|
+
|
|
14973
|
+
var promise; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14974
|
+
// @ts-ignore
|
|
14975
|
+
|
|
14976
|
+
var cacheKey = buildSortedCacheKey(provider, ...args);
|
|
14977
|
+
!cache && cacheMap.has(cacheKey) && cacheMap.delete(cacheKey);
|
|
14950
14978
|
|
|
14951
|
-
if (
|
|
14952
|
-
promise =
|
|
14979
|
+
if (cacheMap.has(cacheKey)) {
|
|
14980
|
+
promise = cacheMap.get(cacheKey);
|
|
14953
14981
|
} else {
|
|
14954
14982
|
promise = _asyncToGenerator__default["default"](function* () {
|
|
14955
14983
|
if (!isCustomApiProvider(provider)) {
|
|
@@ -14965,7 +14993,7 @@
|
|
|
14965
14993
|
|
|
14966
14994
|
return CustomApi(...args);
|
|
14967
14995
|
})();
|
|
14968
|
-
cache.set(cacheKey, promise);
|
|
14996
|
+
cache && cacheMap.set(cacheKey, promise);
|
|
14969
14997
|
}
|
|
14970
14998
|
|
|
14971
14999
|
return promise;
|
|
@@ -14973,7 +15001,7 @@
|
|
|
14973
15001
|
return _fetch.apply(this, arguments);
|
|
14974
15002
|
}
|
|
14975
15003
|
|
|
14976
|
-
var _excluded = ["onError", "transform", "suspense"];
|
|
15004
|
+
var _excluded = ["onError", "transform", "suspense", "cache"];
|
|
14977
15005
|
function useProvider() {
|
|
14978
15006
|
var {
|
|
14979
15007
|
provider,
|
|
@@ -14985,7 +15013,8 @@
|
|
|
14985
15013
|
var {
|
|
14986
15014
|
onError,
|
|
14987
15015
|
transform,
|
|
14988
|
-
suspense
|
|
15016
|
+
suspense,
|
|
15017
|
+
cache
|
|
14989
15018
|
} = customOptions,
|
|
14990
15019
|
defaults = _objectWithoutProperties__default["default"](customOptions, _excluded);
|
|
14991
15020
|
|
|
@@ -15007,11 +15036,12 @@
|
|
|
15007
15036
|
args[_key - 1] = arguments[_key];
|
|
15008
15037
|
}
|
|
15009
15038
|
|
|
15010
|
-
var newRes = yield fetch(provider, ...args);
|
|
15039
|
+
var newRes = yield fetch(provider, cache, ...args);
|
|
15011
15040
|
response.current = newRes;
|
|
15012
15041
|
data.current = transform(data.current, newRes);
|
|
15013
15042
|
} catch (e) {
|
|
15014
15043
|
error.current = e;
|
|
15044
|
+
data.current = undefined;
|
|
15015
15045
|
}
|
|
15016
15046
|
|
|
15017
15047
|
if (!suspense) setLoading(false);
|
|
@@ -15022,7 +15052,7 @@
|
|
|
15022
15052
|
return function (_x) {
|
|
15023
15053
|
return _ref.apply(this, arguments);
|
|
15024
15054
|
};
|
|
15025
|
-
}(), [provider, customOptions, dependencies, requestInit, suspense, transform, defaults.data, onError]);
|
|
15055
|
+
}(), [provider, customOptions, dependencies, requestInit, suspense, transform, defaults.data, onError, cache]);
|
|
15026
15056
|
var makeFetch = React.useCallback( /*#__PURE__*/function () {
|
|
15027
15057
|
var _ref2 = _asyncToGenerator__default["default"](function* (providerOrBody, args) {
|
|
15028
15058
|
var providerStr = provider;
|