pixuireactcomponents 1.5.36 → 1.5.38
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/index.d.ts
CHANGED
|
@@ -14,11 +14,9 @@ export { FrameAnimation } from "./src/components/react/app/frameAnimation/FrameA
|
|
|
14
14
|
export { AsyncTaskProcessor } from "./src/components/tools/AsyncTaskProcessor";
|
|
15
15
|
export { assetCache } from "./src/components/tools/assetCache";
|
|
16
16
|
export { ScrollBar } from "./src/components/react/app/scrollBar/ScrollBar";
|
|
17
|
-
export { tools } from "./src/components/tools/tools";
|
|
18
17
|
export { PreloadImg } from "./src/components/react/app/preloadImg/PreloadImg";
|
|
19
18
|
export { LoadChecker } from "./src/components/tools/LoadChecker";
|
|
20
19
|
export { AntiRepeat } from "./src/components/tools/antiRepeat";
|
|
21
20
|
export { DragList } from "./src/components/react/app/dragList/dragList";
|
|
22
21
|
export { QRCode } from "./src/components/react/app/qrcode/QRCode";
|
|
23
22
|
export { Slider, SliderProps } from "./src/components/react/app/slider/Slider";
|
|
24
|
-
export { ImgPreLoader_base64, PreLoadPic_base64 } from "./src/components/tools/ImgPreLoader";
|
package/index.js
CHANGED
|
@@ -15,11 +15,11 @@ export { GradientText } from './src/components/react/base/gradient/GradientText'
|
|
|
15
15
|
export { PVideo } from './src/components/react/base/pixVideo/PixVideo';
|
|
16
16
|
export { OutlineText } from './src/components/react/base/outlinetext/OutlineText';
|
|
17
17
|
export { FrameAnimation } from './src/components/react/app/frameAnimation/FrameAnimation';
|
|
18
|
-
export { ImgPreLoader_base64, PreLoadPic_base64 } from './src/components/tools/ImgPreLoader';
|
|
18
|
+
// export { ImgPreLoader_base64, PreLoadPic_base64 } from './src/components/tools/ImgPreLoader';
|
|
19
19
|
export { AsyncTaskProcessor } from './src/components/tools/AsyncTaskProcessor';
|
|
20
20
|
export { assetCache } from './src/components/tools/assetCache';
|
|
21
21
|
export { ScrollBar } from './src/components/react/app/scrollBar/ScrollBar';
|
|
22
|
-
export { tools } from './src/components/tools/tools';
|
|
22
|
+
// export { tools } from './src/components/tools/tools';
|
|
23
23
|
export { PreloadImg } from './src/components/react/app/preloadImg/PreloadImg';
|
|
24
24
|
export { LoadChecker } from './src/components/tools/LoadChecker';
|
|
25
25
|
export { AntiRepeat } from './src/components/tools/antiRepeat';
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixuireactcomponents",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.38",
|
|
4
4
|
"description": "pixui react components",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
9
|
"build": "tsc && node -e \"const path = require('path'); const cpx = require('cpx'); cpx.copySync(path.join('src', 'components', 'asset', '**'), path.join('publish_components', 'asset'));\""
|
|
@@ -11,26 +11,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { useEffect, useState } from 'preact/hooks';
|
|
13
13
|
import { h } from 'preact';
|
|
14
|
-
import { GameletAPI } from 'gamelet-pixui-frame';
|
|
15
14
|
import { assetCache } from '../../../tools/assetCache';
|
|
16
15
|
export var PreloadImg = function (props) {
|
|
17
16
|
var src = props.src, useImgTag = props.useImgTag;
|
|
18
17
|
var _a = useState(''), realSrc = _a[0], setRealSrc = _a[1];
|
|
19
18
|
useEffect(function () {
|
|
20
19
|
if (src) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
setRealSrc(src);
|
|
29
|
-
}
|
|
20
|
+
assetCache.cache(src)
|
|
21
|
+
.then(function (localSrc) {
|
|
22
|
+
setRealSrc(localSrc);
|
|
23
|
+
console.log('使用预加载图片', src, ' -> ', localSrc);
|
|
24
|
+
})
|
|
25
|
+
.catch(function (error) {
|
|
26
|
+
console.error('Failed to cache asset:', error);
|
|
27
|
+
setRealSrc(src); // 回退到使用原始的src
|
|
28
|
+
});
|
|
30
29
|
}
|
|
31
30
|
}, [src]);
|
|
32
31
|
return useImgTag ? (h("img", __assign({}, props, { src: realSrc }))) : (h("div", __assign({}, props, { style: __assign({ backgroundImage: "url(".concat(realSrc, ")"), backgroundSize: '100% 100%', backgroundRepeat: 'no-repeat' }, props.style) })));
|
|
33
32
|
};
|
|
34
|
-
var isJssdkEnv = function () {
|
|
35
|
-
return GameletAPI.getRuntimeEnv() == 'jssdk-appwindow' || GameletAPI.getRuntimeEnv() == 'jssdk-preprocessor';
|
|
36
|
-
};
|
|
@@ -35,7 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import path from 'path';
|
|
38
|
-
import {
|
|
38
|
+
import { sha1 } from './Sha1';
|
|
39
39
|
import { LibMgr } from '../../../lib/loadlib/lib_mgr';
|
|
40
40
|
var assetPrefix = 'cacheAsset';
|
|
41
41
|
var OPLib = LibMgr.getInstance().getMainLib();
|
|
@@ -215,7 +215,7 @@ export var assetCache;
|
|
|
215
215
|
if (!OPLib.dirExists(filePath)) {
|
|
216
216
|
OPLib.makeDir(filePath);
|
|
217
217
|
}
|
|
218
|
-
var fileName =
|
|
218
|
+
var fileName = sha1(assetPrefix + url).substring(0, 20) + path.extname(url);
|
|
219
219
|
return path.join(filePath, fileName || '');
|
|
220
220
|
};
|
|
221
221
|
})(assetCache || (assetCache = {}));
|