pixuireactcomponents 1.3.79 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixuireactcomponents",
3
- "version": "1.3.79",
3
+ "version": "1.3.80",
4
4
  "description": "pixui react components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -37,29 +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
- var getLibMgr = function () { return __awaiter(void 0, void 0, void 0, function () {
46
- var module_1, error_1;
47
- return __generator(this, function (_a) {
48
- switch (_a.label) {
49
- case 0:
50
- _a.trys.push([0, 2, , 3]);
51
- return [4 /*yield*/, import('../../../lib/loadlib/lib_mgr')];
52
- case 1:
53
- module_1 = _a.sent();
54
- return [2 /*return*/, module_1.LibMgr];
55
- case 2:
56
- error_1 = _a.sent();
57
- console.error('need puerts env');
58
- return [2 /*return*/, null];
59
- case 3: return [2 /*return*/];
60
- }
61
- });
62
- }); };
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
+ // };
63
55
  /**
64
56
  * 缓存资源到本地,仅jssdk环境可用
65
57
  */
@@ -79,7 +71,7 @@ export var assetCache;
79
71
  return __generator(this, function (_a) {
80
72
  console.log('cacheAsset---', url);
81
73
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
82
- var mgr, lib, localPath, xhr;
74
+ var lib, localPath, xhr;
83
75
  var _this = this;
84
76
  return __generator(this, function (_a) {
85
77
  switch (_a.label) {
@@ -89,16 +81,9 @@ export var assetCache;
89
81
  reject();
90
82
  return [2 /*return*/];
91
83
  }
92
- return [4 /*yield*/, getLibMgr()];
93
- case 1:
94
- mgr = _a.sent();
95
- if (!mgr) {
96
- reject();
97
- return [2 /*return*/];
98
- }
99
- lib = mgr.getInstance().getMainLib();
84
+ lib = LibMgr.getInstance().getMainLib();
100
85
  return [4 /*yield*/, getLocalPath(url)];
101
- case 2:
86
+ case 1:
102
87
  localPath = _a.sent();
103
88
  if (!force) {
104
89
  if (lib.fileExists(localPath)) {
@@ -188,26 +173,17 @@ export var assetCache;
188
173
  });
189
174
  };
190
175
  var getLocalPath = function (url) { return __awaiter(_this, void 0, void 0, function () {
191
- var mgr, lib, filePath, fileName;
176
+ var lib, filePath, fileName;
192
177
  return __generator(this, function (_a) {
193
- switch (_a.label) {
194
- case 0:
195
- console.log('getLocalPath', url);
196
- return [4 /*yield*/, getLibMgr()];
197
- case 1:
198
- mgr = _a.sent();
199
- if (!mgr) {
200
- return [2 /*return*/, ''];
201
- }
202
- lib = mgr.getInstance().getMainLib();
203
- filePath = path.join(lib.getCachePath(), 'assetcache');
204
- //检查assetcache文件夹
205
- if (!lib.dirExists(filePath)) {
206
- lib.makeDir(filePath);
207
- }
208
- fileName = tools.getHashStr(assetPrefix + url) + path.extname(url);
209
- 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);
210
184
  }
185
+ fileName = tools.getHashStr(assetPrefix + url) + path.extname(url);
186
+ return [2 /*return*/, path.join(filePath, fileName)];
211
187
  });
212
188
  }); };
213
189
  })(assetCache || (assetCache = {}));