pixuireactcomponents 1.3.88 → 1.3.90
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// @ts-nocheck
|
|
3
3
|
// make it callable from typescript
|
|
4
|
-
if (globalThis.oplatSDKRunningTestRoutine) {
|
|
4
|
+
if (globalThis.oplatSDKRunningTestRoutine || typeof addlibpath === 'undefined') {
|
|
5
5
|
exports.addlibpath = function (path) { };
|
|
6
6
|
exports.clearlibpath = function (path) { };
|
|
7
7
|
exports.loadlib = function (libname) { return undefined; };
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState } from 'preact/hooks';
|
|
1
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
2
2
|
import { h } from 'preact';
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -16,10 +16,18 @@ export var DropDown = function (props) {
|
|
|
16
16
|
var _a;
|
|
17
17
|
var rootId = props.rootId, rootClassName = props.rootClassName, spreadFrameClassName = props.spreadFrameClassName, mainItemClassName = props.mainItemClassName, itemClassName = props.itemClassName, mainContent = props.mainContent, itemContent = props.itemContent, onClick = props.onClick, onSpread = props.onSpread;
|
|
18
18
|
var spread = (_a = useState(false), _a[0]), setSpread = _a[1];
|
|
19
|
+
//导出ref
|
|
20
|
+
if (props.compRef) {
|
|
21
|
+
props.compRef.current = {
|
|
22
|
+
setSpread: setSpread,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
onSpread && onSpread(spread);
|
|
27
|
+
}, [spread]);
|
|
19
28
|
return (h("div", { style: { flexDirection: 'column', flexShrink: 0 }, className: rootClassName, id: rootId },
|
|
20
29
|
h("div", { onClick: function () {
|
|
21
30
|
setSpread(!spread);
|
|
22
|
-
onSpread && onSpread(!spread);
|
|
23
31
|
}, className: mainItemClassName, style: { flexShrink: 0 } }, mainContent),
|
|
24
32
|
spread && (
|
|
25
33
|
//在下方展开
|
|
@@ -37,30 +37,11 @@ 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
|
-
|
|
40
|
+
import { LibMgr } from '../../../lib/loadlib/lib_mgr';
|
|
41
41
|
var assetPrefix = 'cacheAsset';
|
|
42
|
-
var isJssdkEnv =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//动态导入lib_mgr
|
|
46
|
-
var getLibMgr = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var module_1, error_1;
|
|
48
|
-
return __generator(this, function (_a) {
|
|
49
|
-
switch (_a.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
_a.trys.push([0, 2, , 3]);
|
|
52
|
-
return [4 /*yield*/, import('../../../lib/loadlib/lib_mgr')];
|
|
53
|
-
case 1:
|
|
54
|
-
module_1 = _a.sent();
|
|
55
|
-
return [2 /*return*/, module_1.LibMgr];
|
|
56
|
-
case 2:
|
|
57
|
-
error_1 = _a.sent();
|
|
58
|
-
console.error('need puerts env', error_1);
|
|
59
|
-
return [2 /*return*/, null];
|
|
60
|
-
case 3: return [2 /*return*/];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}); };
|
|
42
|
+
var isJssdkEnv = GameletAPI.getRuntimeEnv() == 'jssdk-appwindow' || GameletAPI.getRuntimeEnv() == 'jssdk-preprocessor';
|
|
43
|
+
var OPLib = LibMgr.getInstance().getMainLib();
|
|
44
|
+
console.log('new lib test');
|
|
64
45
|
/**
|
|
65
46
|
* 缓存资源到本地,仅jssdk环境可用
|
|
66
47
|
*/
|
|
@@ -80,27 +61,18 @@ export var assetCache;
|
|
|
80
61
|
return __generator(this, function (_a) {
|
|
81
62
|
console.log('cacheAsset---', url);
|
|
82
63
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
83
|
-
var urlWithoutParams,
|
|
64
|
+
var urlWithoutParams, localPath, xhr;
|
|
84
65
|
var _this = this;
|
|
85
66
|
return __generator(this, function (_a) {
|
|
86
67
|
switch (_a.label) {
|
|
87
68
|
case 0:
|
|
88
|
-
if (!isJssdkEnv
|
|
69
|
+
if (!isJssdkEnv) {
|
|
89
70
|
console.log('非jssdk环境');
|
|
90
71
|
reject(url);
|
|
91
72
|
}
|
|
92
73
|
urlWithoutParams = url.split('?')[0];
|
|
93
|
-
return [4 /*yield*/, getLibMgr()];
|
|
94
|
-
case 1:
|
|
95
|
-
LibMgr = _a.sent();
|
|
96
|
-
if (!LibMgr) {
|
|
97
|
-
console.log('getLibMgr failed');
|
|
98
|
-
reject();
|
|
99
|
-
return [2 /*return*/];
|
|
100
|
-
}
|
|
101
|
-
lib = LibMgr.getInstance().getMainLib();
|
|
102
74
|
return [4 /*yield*/, getLocalPath(urlWithoutParams)];
|
|
103
|
-
case
|
|
75
|
+
case 1:
|
|
104
76
|
localPath = _a.sent();
|
|
105
77
|
if (!localPath) {
|
|
106
78
|
console.log('getLocalPath failed');
|
|
@@ -109,7 +81,7 @@ export var assetCache;
|
|
|
109
81
|
}
|
|
110
82
|
console.log('cacheAsset getlocalPath', localPath);
|
|
111
83
|
if (!force) {
|
|
112
|
-
if (
|
|
84
|
+
if (OPLib.fileExists(localPath)) {
|
|
113
85
|
console.log('cacheAsset file exist', localPath);
|
|
114
86
|
resolve(localPath);
|
|
115
87
|
}
|
|
@@ -124,7 +96,7 @@ export var assetCache;
|
|
|
124
96
|
console.log('cacheAsset xhr statue=200', url, localPath);
|
|
125
97
|
// let buf = Buffer.from(xhr.response, 'binary').buffer;
|
|
126
98
|
if (localPath) {
|
|
127
|
-
|
|
99
|
+
OPLib.saveToFile(localPath, xhr.response);
|
|
128
100
|
resolve(localPath);
|
|
129
101
|
}
|
|
130
102
|
else {
|
|
@@ -208,27 +180,16 @@ export var assetCache;
|
|
|
208
180
|
});
|
|
209
181
|
};
|
|
210
182
|
var getLocalPath = function (url) { return __awaiter(_this, void 0, void 0, function () {
|
|
211
|
-
var
|
|
183
|
+
var filePath, fileName;
|
|
212
184
|
return __generator(this, function (_a) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
LibMgr = _a.sent();
|
|
219
|
-
if (!LibMgr) {
|
|
220
|
-
console.log('getLibMgr failed');
|
|
221
|
-
return [2 /*return*/];
|
|
222
|
-
}
|
|
223
|
-
lib = LibMgr.getInstance().getMainLib();
|
|
224
|
-
filePath = path.join(lib.getCachePath(), 'assetcache');
|
|
225
|
-
//检查assetcache文件夹
|
|
226
|
-
if (!lib.dirExists(filePath)) {
|
|
227
|
-
lib.makeDir(filePath);
|
|
228
|
-
}
|
|
229
|
-
fileName = tools.getHashStr(assetPrefix + url) + path.extname(url);
|
|
230
|
-
return [2 /*return*/, path.join(filePath, fileName)];
|
|
185
|
+
console.log('getLocalPath', url);
|
|
186
|
+
filePath = path.join(OPLib.getCachePath(), 'assetcache');
|
|
187
|
+
//检查assetcache文件夹
|
|
188
|
+
if (!OPLib.dirExists(filePath)) {
|
|
189
|
+
OPLib.makeDir(filePath);
|
|
231
190
|
}
|
|
191
|
+
fileName = tools.getHashStr(assetPrefix + url) + path.extname(url);
|
|
192
|
+
return [2 /*return*/, path.join(filePath, fileName)];
|
|
232
193
|
});
|
|
233
194
|
}); };
|
|
234
195
|
})(assetCache || (assetCache = {}));
|