pixuireactcomponents 1.3.78 → 1.3.80
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/package.json
CHANGED
|
@@ -37,36 +37,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import { GameletAPI } from 'gamelet-pixui-frame';
|
|
38
38
|
import path from 'path';
|
|
39
39
|
import { tools } from './tools';
|
|
40
|
+
import { LibMgr } from '../../../lib/loadlib/lib_mgr';
|
|
40
41
|
var assetPrefix = 'cacheAsset';
|
|
41
42
|
var isJssdkEnv = function () {
|
|
42
43
|
return GameletAPI.getRuntimeEnv() == 'jssdk-appwindow' || GameletAPI.getRuntimeEnv() == 'jssdk-preprocessor';
|
|
43
44
|
};
|
|
44
45
|
//动态导入lib_mgr
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
_a.label = 1;
|
|
55
|
-
case 1:
|
|
56
|
-
_a.trys.push([1, 3, , 4]);
|
|
57
|
-
return [4 /*yield*/, import('../../../lib/loadlib/lib_mgr')];
|
|
58
|
-
case 2:
|
|
59
|
-
module_1 = _a.sent();
|
|
60
|
-
LibMgr = module_1.LibMgr;
|
|
61
|
-
return [3 /*break*/, 4];
|
|
62
|
-
case 3:
|
|
63
|
-
error_1 = _a.sent();
|
|
64
|
-
console.error('need puerts env');
|
|
65
|
-
return [2 /*return*/, null];
|
|
66
|
-
case 4: return [2 /*return*/, LibMgr];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}); };
|
|
46
|
+
// const getLibMgr = async () => {
|
|
47
|
+
// try {
|
|
48
|
+
// const module = await import('../../../lib/loadlib/lib_mgr');
|
|
49
|
+
// return module.LibMgr;
|
|
50
|
+
// } catch (error) {
|
|
51
|
+
// console.error('need puerts env');
|
|
52
|
+
// return null;
|
|
53
|
+
// }
|
|
54
|
+
// };
|
|
70
55
|
/**
|
|
71
56
|
* 缓存资源到本地,仅jssdk环境可用
|
|
72
57
|
*/
|
|
@@ -86,7 +71,7 @@ export var assetCache;
|
|
|
86
71
|
return __generator(this, function (_a) {
|
|
87
72
|
console.log('cacheAsset---', url);
|
|
88
73
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
89
|
-
var
|
|
74
|
+
var lib, localPath, xhr;
|
|
90
75
|
var _this = this;
|
|
91
76
|
return __generator(this, function (_a) {
|
|
92
77
|
switch (_a.label) {
|
|
@@ -96,16 +81,9 @@ export var assetCache;
|
|
|
96
81
|
reject();
|
|
97
82
|
return [2 /*return*/];
|
|
98
83
|
}
|
|
99
|
-
|
|
100
|
-
case 1:
|
|
101
|
-
mgr = _a.sent();
|
|
102
|
-
if (!mgr) {
|
|
103
|
-
reject();
|
|
104
|
-
return [2 /*return*/];
|
|
105
|
-
}
|
|
106
|
-
lib = mgr.getInstance().getMainLib();
|
|
84
|
+
lib = LibMgr.getInstance().getMainLib();
|
|
107
85
|
return [4 /*yield*/, getLocalPath(url)];
|
|
108
|
-
case
|
|
86
|
+
case 1:
|
|
109
87
|
localPath = _a.sent();
|
|
110
88
|
if (!force) {
|
|
111
89
|
if (lib.fileExists(localPath)) {
|
|
@@ -195,26 +173,17 @@ export var assetCache;
|
|
|
195
173
|
});
|
|
196
174
|
};
|
|
197
175
|
var getLocalPath = function (url) { return __awaiter(_this, void 0, void 0, function () {
|
|
198
|
-
var
|
|
176
|
+
var lib, filePath, fileName;
|
|
199
177
|
return __generator(this, function (_a) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (!mgr) {
|
|
207
|
-
return [2 /*return*/, ''];
|
|
208
|
-
}
|
|
209
|
-
lib = mgr.getInstance().getMainLib();
|
|
210
|
-
filePath = path.join(lib.getCachePath(), 'assetcache');
|
|
211
|
-
//检查assetcache文件夹
|
|
212
|
-
if (!lib.dirExists(filePath)) {
|
|
213
|
-
lib.makeDir(filePath);
|
|
214
|
-
}
|
|
215
|
-
fileName = tools.getHashStr(assetPrefix + url) + path.extname(url);
|
|
216
|
-
return [2 /*return*/, path.join(filePath, fileName)];
|
|
178
|
+
console.log('getLocalPath', url);
|
|
179
|
+
lib = LibMgr.getInstance().getMainLib();
|
|
180
|
+
filePath = path.join(lib.getCachePath(), 'assetcache');
|
|
181
|
+
//检查assetcache文件夹
|
|
182
|
+
if (!lib.dirExists(filePath)) {
|
|
183
|
+
lib.makeDir(filePath);
|
|
217
184
|
}
|
|
185
|
+
fileName = tools.getHashStr(assetPrefix + url) + path.extname(url);
|
|
186
|
+
return [2 /*return*/, path.join(filePath, fileName)];
|
|
218
187
|
});
|
|
219
188
|
}); };
|
|
220
189
|
})(assetCache || (assetCache = {}));
|