use-frontbacked 5.1.6 → 5.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/dist/cjs/index.js +33 -23
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.es.js +33 -23
- package/dist/esm/index.es.js.map +1 -1
- package/package.json +2 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2943,17 +2943,20 @@ var DownloadType = function DownloadType(_a) {
|
|
|
2943
2943
|
}
|
|
2944
2944
|
}, [adminInfo]);
|
|
2945
2945
|
React.useEffect(function () {
|
|
2946
|
+
var _a, _b, _c, _d;
|
|
2946
2947
|
if (onGetTool && toolId) {
|
|
2947
2948
|
var tool = onGetTool(toolId);
|
|
2948
2949
|
consoleLog("DownloadType.setDocRules", tool);
|
|
2949
|
-
setDocRules(!tool ? null :
|
|
2950
|
-
allow_freemium: (tool === null || tool === void 0 ? void 0 : tool.allow_freemium)
|
|
2951
|
-
create_price: (tool === null || tool === void 0 ? void 0 : tool.create_price)
|
|
2952
|
-
update_price: (tool === null || tool === void 0 ? void 0 : tool.update_price)
|
|
2953
|
-
create_price_is_monthly: (tool === null || tool === void 0 ? void 0 : tool.create_price_is_monthly)
|
|
2950
|
+
setDocRules(!tool ? null : {
|
|
2951
|
+
allow_freemium: (_a = tool === null || tool === void 0 ? void 0 : tool.allow_freemium) !== null && _a !== void 0 ? _a : true,
|
|
2952
|
+
create_price: (_b = tool === null || tool === void 0 ? void 0 : tool.create_price) !== null && _b !== void 0 ? _b : 0,
|
|
2953
|
+
update_price: (_c = tool === null || tool === void 0 ? void 0 : tool.update_price) !== null && _c !== void 0 ? _c : 0,
|
|
2954
|
+
create_price_is_monthly: (_d = tool === null || tool === void 0 ? void 0 : tool.create_price_is_monthly) !== null && _d !== void 0 ? _d : false,
|
|
2954
2955
|
yearly_price: tool === null || tool === void 0 ? void 0 : tool.yearly_price,
|
|
2955
2956
|
quarterly_price: tool === null || tool === void 0 ? void 0 : tool.quarterly_price
|
|
2956
|
-
})
|
|
2957
|
+
});
|
|
2958
|
+
} else {
|
|
2959
|
+
setDocRules(null);
|
|
2957
2960
|
}
|
|
2958
2961
|
}, [onGetTool, toolId]);
|
|
2959
2962
|
var download = function download() {
|
|
@@ -3092,7 +3095,7 @@ var DownloadType = function DownloadType(_a) {
|
|
|
3092
3095
|
setAutoProcessOn(false);
|
|
3093
3096
|
}
|
|
3094
3097
|
}
|
|
3095
|
-
}, [docRules]);
|
|
3098
|
+
}, [docRules, permission.isToolsEditor, toolId, updateMessage, removeFreemiumBeforeUpdate, renewSubscription, isFreemium]);
|
|
3096
3099
|
if (permission.isToolsEditor && toolId == "other_tools" || !toolId || !onGetTool || !freeTitle || !freeMessage || !paidTitle || !paidMessage) return null;
|
|
3097
3100
|
return /*#__PURE__*/React__default["default"].createElement(DrawerPop, {
|
|
3098
3101
|
placement: "bottom",
|
|
@@ -3265,11 +3268,23 @@ var readCachedMetadata = function readCachedMetadata() {
|
|
|
3265
3268
|
return null;
|
|
3266
3269
|
}
|
|
3267
3270
|
};
|
|
3271
|
+
var readCachedToolsData = function readCachedToolsData() {
|
|
3272
|
+
if (!isBrowser()) return null;
|
|
3273
|
+
if (window.toolsCache) return window.toolsCache;
|
|
3274
|
+
var cachedMetadata = readCachedMetadata();
|
|
3275
|
+
var cachedData = cachedMetadata === null || cachedMetadata === void 0 ? void 0 : cachedMetadata.cachedData;
|
|
3276
|
+
if (cachedData) {
|
|
3277
|
+
window.toolsCache = cachedData;
|
|
3278
|
+
return cachedData;
|
|
3279
|
+
}
|
|
3280
|
+
return null;
|
|
3281
|
+
};
|
|
3268
3282
|
var useTools = function useTools(config) {
|
|
3269
|
-
var
|
|
3283
|
+
var cachedToolsData = readCachedToolsData();
|
|
3284
|
+
var _a = React.useState(cachedToolsData),
|
|
3270
3285
|
data = _a[0],
|
|
3271
3286
|
setData = _a[1];
|
|
3272
|
-
var _b = React.useState(!
|
|
3287
|
+
var _b = React.useState(!cachedToolsData),
|
|
3273
3288
|
loading = _b[0],
|
|
3274
3289
|
setLoading = _b[1];
|
|
3275
3290
|
var _c = React.useState(null),
|
|
@@ -3283,31 +3298,26 @@ var useTools = function useTools(config) {
|
|
|
3283
3298
|
setToolsByTemplatesUrl = _e[1];
|
|
3284
3299
|
React.useEffect(function () {
|
|
3285
3300
|
if (!(config === null || config === void 0 ? void 0 : config.r2Domain)) return;
|
|
3286
|
-
|
|
3287
|
-
|
|
3301
|
+
var cachedToolsData = readCachedToolsData();
|
|
3302
|
+
if (cachedToolsData) {
|
|
3303
|
+
setData(cachedToolsData);
|
|
3288
3304
|
setLoading(false);
|
|
3289
|
-
consoleLog("useTools.returns
|
|
3305
|
+
consoleLog("useTools.returns cached tools data: ", cachedToolsData);
|
|
3290
3306
|
}
|
|
3291
3307
|
if (!window.toolsFetchPromise) {
|
|
3292
3308
|
window.toolsFetchPromise = function () {
|
|
3293
3309
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
3294
|
-
var attempts,
|
|
3310
|
+
var attempts, cachedData, response, err_1;
|
|
3295
3311
|
var _a, _b;
|
|
3296
3312
|
return __generator(this, function (_c) {
|
|
3297
3313
|
switch (_c.label) {
|
|
3298
3314
|
case 0:
|
|
3299
3315
|
attempts = 0;
|
|
3300
|
-
|
|
3301
|
-
if (
|
|
3302
|
-
cachedData
|
|
3303
|
-
|
|
3304
|
-
window.toolsCache = cachedData;
|
|
3305
|
-
setData(cachedData);
|
|
3306
|
-
setLoading(false);
|
|
3307
|
-
//return cachedData;
|
|
3308
|
-
}
|
|
3316
|
+
cachedData = readCachedToolsData();
|
|
3317
|
+
if (cachedData) {
|
|
3318
|
+
setData(cachedData);
|
|
3319
|
+
setLoading(false);
|
|
3309
3320
|
}
|
|
3310
|
-
|
|
3311
3321
|
consoleLog("useTools.refreshing");
|
|
3312
3322
|
_c.label = 1;
|
|
3313
3323
|
case 1:
|