@cloud-app-dev/vidc 4.0.0 → 4.0.1
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/es/FullScreen/index.js +0 -1
- package/es/Player/api/index.d.ts +4 -4
- package/es/Player/api/index.js +30 -7
- package/es/Player/event/errorEvent.d.ts +1 -1
- package/es/Player/event/errorEvent.js +1 -1
- package/es/Player/fps_play.js +3 -5
- package/es/Player/player.d.ts +1 -1
- package/es/Player/single_player.js +14 -12
- package/es/Player/util.d.ts +1 -1
- package/es/Player/util.js +1 -1
- package/es/ScreenPlayer/demo.js +3 -2
- package/es/ThemeAntd/demo.html +32 -0
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/package.json +2 -2
- package/es/LoaderApp/index.d.ts +0 -31
- package/es/LoaderApp/index.js +0 -138
- package/es/LoaderApp/index.less +0 -3
- package/es/LoaderApp/interface.d.ts +0 -9
- package/es/LoaderApp/loader.d.ts +0 -19
- package/es/LoaderApp/loader.js +0 -85
- package/es/LoaderApp/sandbox.back.d.ts +0 -18
- package/es/LoaderApp/sandbox.back.js +0 -368
- package/es/LoaderApp/sandbox.d.ts +0 -12
- package/es/LoaderApp/sandbox.js +0 -113
- package/es/LoaderApp/utils.d.ts +0 -19
- package/es/LoaderApp/utils.js +0 -275
package/es/FullScreen/index.js
CHANGED
|
@@ -31,7 +31,6 @@ function FullScreen(_ref) {
|
|
|
31
31
|
toggleFullscreen = _useFullscreen2[1].toggleFullscreen;
|
|
32
32
|
|
|
33
33
|
_useUpdateEffect(function () {
|
|
34
|
-
console.log(isFullscreen);
|
|
35
34
|
fullScreenChange === null || fullScreenChange === void 0 ? void 0 : fullScreenChange(isFullscreen); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
35
|
}, [isFullscreen]);
|
|
37
36
|
|
package/es/Player/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Flvjs from '@cloud-app-dev/
|
|
1
|
+
import Flvjs from '@cloud-app-dev/mpegts.js';
|
|
2
2
|
import Hls, { HlsConfig } from 'hls.js';
|
|
3
3
|
import type { FlvPlayerConfig } from '../player';
|
|
4
4
|
declare class Api {
|
|
@@ -34,11 +34,11 @@ declare class Api {
|
|
|
34
34
|
/**
|
|
35
35
|
* 获取视频总时长
|
|
36
36
|
*/
|
|
37
|
-
getDuration: () => number
|
|
37
|
+
getDuration: () => number;
|
|
38
38
|
/**
|
|
39
39
|
* 获取当前播放时间
|
|
40
40
|
*/
|
|
41
|
-
getCurrentTime: () => number
|
|
41
|
+
getCurrentTime: () => number;
|
|
42
42
|
/**
|
|
43
43
|
* 获取缓存时间
|
|
44
44
|
*/
|
|
@@ -64,5 +64,5 @@ export declare type TypeAndPlay = {
|
|
|
64
64
|
hls?: Hls;
|
|
65
65
|
};
|
|
66
66
|
export declare function useTypeAndPlay(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?: Flvjs.MediaSegment[], flvConfig?: FlvPlayerConfig, hlsConfig?: HlsConfig): [string, Flvjs.Player, Hls];
|
|
67
|
-
export declare function usePlayerApi(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?: Flvjs.MediaSegment[], flvConfig?: FlvPlayerConfig, hlsConfig?: HlsConfig): [Api | undefined, [string, Flvjs.Player, Hls]];
|
|
67
|
+
export declare function usePlayerApi(url?: string, type?: string, isLive?: boolean, container?: HTMLElement, segments?: Flvjs.MediaSegment[], flvConfig?: FlvPlayerConfig, hlsConfig?: HlsConfig): [Api | undefined, [string, Flvjs.Player, Hls], () => void];
|
|
68
68
|
export default Api;
|
package/es/Player/api/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import _nextTick from "@cloud-app-dev/utils/es/nextTick";
|
|
2
|
+
import _useMemoizedFn from "ahooks/es/useMemoizedFn";
|
|
3
|
+
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2
7
|
|
|
3
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
9
|
|
|
@@ -20,7 +25,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
20
25
|
|
|
21
26
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
27
|
|
|
23
|
-
import { useEffect, useState } from 'react';
|
|
28
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
24
29
|
import { tryCatch } from "../../utils";
|
|
25
30
|
import { createFlvPlayer, createHlsPlayer } from "../util";
|
|
26
31
|
|
|
@@ -103,17 +108,19 @@ var Api = /*#__PURE__*/function () {
|
|
|
103
108
|
return seekable.end(seekable.length - 1);
|
|
104
109
|
}
|
|
105
110
|
|
|
106
|
-
return duration;
|
|
111
|
+
return duration !== null && duration !== void 0 ? duration : 0;
|
|
107
112
|
});
|
|
108
113
|
|
|
109
114
|
_defineProperty(this, "getCurrentTime", function () {
|
|
110
|
-
var _this$video5;
|
|
115
|
+
var _this$video$currentTi, _this$video5;
|
|
111
116
|
|
|
112
|
-
return (_this$video5 = _this.video) === null || _this$video5 === void 0 ? void 0 : _this$video5.currentTime;
|
|
117
|
+
return (_this$video$currentTi = (_this$video5 = _this.video) === null || _this$video5 === void 0 ? void 0 : _this$video5.currentTime) !== null && _this$video$currentTi !== void 0 ? _this$video$currentTi : 0;
|
|
113
118
|
});
|
|
114
119
|
|
|
115
120
|
_defineProperty(this, "getSecondsLoaded", function () {
|
|
116
|
-
|
|
121
|
+
var _this$getBufferedTime;
|
|
122
|
+
|
|
123
|
+
return (_this$getBufferedTime = _this.getBufferedTime()[1]) !== null && _this$getBufferedTime !== void 0 ? _this$getBufferedTime : 0;
|
|
117
124
|
});
|
|
118
125
|
|
|
119
126
|
_defineProperty(this, "getBufferedTime", function () {
|
|
@@ -273,7 +280,23 @@ export function usePlayerApi(url, type, isLive, container, segments, flvConfig,
|
|
|
273
280
|
api = _useState4[0],
|
|
274
281
|
setApi = _useState4[1];
|
|
275
282
|
|
|
276
|
-
var
|
|
283
|
+
var _useState5 = useState(Date.now()),
|
|
284
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
285
|
+
forceKey = _useState6[0],
|
|
286
|
+
setForceKey = _useState6[1];
|
|
287
|
+
|
|
288
|
+
var config = useMemo(function () {
|
|
289
|
+
return {
|
|
290
|
+
flvConfig: _objectSpread({}, flvConfig),
|
|
291
|
+
hlsConfig: _objectSpread({}, hlsConfig)
|
|
292
|
+
};
|
|
293
|
+
}, [forceKey]);
|
|
294
|
+
var typePlay = useTypeAndPlay(url, type, isLive, container, segments, config.flvConfig, config.hlsConfig);
|
|
295
|
+
|
|
296
|
+
var rePlay = _useMemoizedFn(function () {
|
|
297
|
+
return setForceKey(Date.now());
|
|
298
|
+
});
|
|
299
|
+
|
|
277
300
|
useEffect(function () {
|
|
278
301
|
if (!container) {
|
|
279
302
|
console.debug('wait create api...');
|
|
@@ -288,6 +311,6 @@ export function usePlayerApi(url, type, isLive, container, segments, flvConfig,
|
|
|
288
311
|
});
|
|
289
312
|
};
|
|
290
313
|
}, [container, segments]);
|
|
291
|
-
return [api, typePlay];
|
|
314
|
+
return [api, typePlay, rePlay];
|
|
292
315
|
}
|
|
293
316
|
export default Api;
|
|
@@ -18,7 +18,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
18
18
|
|
|
19
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
20
|
|
|
21
|
-
import Flvjs from '@cloud-app-dev/
|
|
21
|
+
import Flvjs from '@cloud-app-dev/mpegts.js';
|
|
22
22
|
import Hls from 'hls.js';
|
|
23
23
|
import { useEffect, useRef, useState } from 'react';
|
|
24
24
|
import { useRegisterPlayerEvent, useVideoEvent } from '.';
|
package/es/Player/fps_play.js
CHANGED
|
@@ -36,17 +36,15 @@ function FPSPlay(_ref) {
|
|
|
36
36
|
}, [fps]);
|
|
37
37
|
useEffect(function () {
|
|
38
38
|
var fpsCapture = function fpsCapture() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!ref.current || !(event !== null && event !== void 0 && event.video)) {
|
|
39
|
+
if (!ref.current || !(event !== null && event !== void 0 && event.video) || !api) {
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
var video = event.video;
|
|
46
|
-
var fpsTime =
|
|
44
|
+
var fpsTime = api.getCurrentTime() + fps_second;
|
|
47
45
|
video.currentTime = fpsTime;
|
|
48
46
|
|
|
49
|
-
if (video.currentTime >=
|
|
47
|
+
if (video.currentTime >= api.getDuration()) {
|
|
50
48
|
clearInterval(timerRef.current);
|
|
51
49
|
video.currentTime = 0;
|
|
52
50
|
event.emit(Events.PLAY_ENDED);
|
package/es/Player/player.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
2
|
+
import _useMemoizedFn from "ahooks/es/useMemoizedFn";
|
|
2
3
|
import _useLatest from "ahooks/es/useLatest";
|
|
3
4
|
import _useToggle3 from "ahooks/es/useToggle";
|
|
4
5
|
var _excluded = ["className", "url", "type", "hideContrallerBar", "isLive", "errorReloadTimer", "children", "onCanPlayerInit", "extActions"];
|
|
@@ -38,7 +39,7 @@ import FPSPlay from "./fps_play";
|
|
|
38
39
|
import useLiveHeart from "./live_heart";
|
|
39
40
|
import VideoMessage from "./message";
|
|
40
41
|
import Timeline from "./timeline";
|
|
41
|
-
import { getVideoType,
|
|
42
|
+
import { getVideoType, playUnload } from "./util";
|
|
42
43
|
import "./style/index.less";
|
|
43
44
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
44
45
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -105,11 +106,12 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function SinglePlayer(_ref, ref
|
|
|
105
106
|
useRegisterPlayerEvents(event, playerEvents);
|
|
106
107
|
|
|
107
108
|
var _usePlayerApi = usePlayerApi(url, vType, isLive, state.container, flvConfig === null || flvConfig === void 0 ? void 0 : flvConfig.mediaDataSource.segments, flvConfig, hlsConfig),
|
|
108
|
-
_usePlayerApi2 = _slicedToArray(_usePlayerApi,
|
|
109
|
+
_usePlayerApi2 = _slicedToArray(_usePlayerApi, 3),
|
|
109
110
|
api = _usePlayerApi2[0],
|
|
110
111
|
_usePlayerApi2$ = _slicedToArray(_usePlayerApi2[1], 3),
|
|
111
112
|
flv = _usePlayerApi2$[1],
|
|
112
|
-
hls = _usePlayerApi2$[2]
|
|
113
|
+
hls = _usePlayerApi2$[2],
|
|
114
|
+
rePlay = _usePlayerApi2[2]; // 判断是否有链接传入
|
|
113
115
|
|
|
114
116
|
|
|
115
117
|
var hasLink = useMemo(function () {
|
|
@@ -133,31 +135,31 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function SinglePlayer(_ref, ref
|
|
|
133
135
|
event === null || event === void 0 ? void 0 : event.emit(EventName.CLEAR_ERROR_TIMER); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
136
|
}, [url]); // 特殊接口实现 reload是可能被重写的,但是API只暴露原生的方法
|
|
135
137
|
|
|
136
|
-
var reload = function
|
|
137
|
-
|
|
138
|
-
};
|
|
138
|
+
var reload = _useMemoizedFn(function () {
|
|
139
|
+
rePlay(); // playReload(video, event, flvRef.current, hlsRef.current, url);
|
|
140
|
+
});
|
|
139
141
|
|
|
140
|
-
var unload = function
|
|
142
|
+
var unload = _useMemoizedFn(function () {
|
|
141
143
|
return playUnload(video, flvRef.current, hlsRef.current);
|
|
142
|
-
};
|
|
144
|
+
});
|
|
143
145
|
|
|
144
|
-
var openFpsPlay = function
|
|
146
|
+
var openFpsPlay = _useMemoizedFn(function () {
|
|
145
147
|
setState(function (old) {
|
|
146
148
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
147
149
|
isFpsPlay: true
|
|
148
150
|
});
|
|
149
151
|
});
|
|
150
152
|
api === null || api === void 0 ? void 0 : api.pause();
|
|
151
|
-
};
|
|
153
|
+
});
|
|
152
154
|
|
|
153
|
-
var closeFpsPlay = function
|
|
155
|
+
var closeFpsPlay = _useMemoizedFn(function () {
|
|
154
156
|
setState(function (old) {
|
|
155
157
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
156
158
|
isFpsPlay: false
|
|
157
159
|
});
|
|
158
160
|
});
|
|
159
161
|
api === null || api === void 0 ? void 0 : api.play();
|
|
160
|
-
}; // 合并api,加上代理
|
|
162
|
+
}); // 合并api,加上代理
|
|
161
163
|
|
|
162
164
|
|
|
163
165
|
var playApi = useMemo(function () {
|
package/es/Player/util.d.ts
CHANGED
package/es/Player/util.js
CHANGED
|
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import Flvjs from '@cloud-app-dev/
|
|
7
|
+
import Flvjs from '@cloud-app-dev/mpegts.js';
|
|
8
8
|
import Hls from 'hls.js';
|
|
9
9
|
import { tryCatch } from "../utils";
|
|
10
10
|
import Events from "./event/eventName";
|
package/es/ScreenPlayer/demo.js
CHANGED
|
@@ -3,8 +3,9 @@ import React from 'react';
|
|
|
3
3
|
import LivePlayer from "./Live";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
var list = [{
|
|
6
|
-
url: 'https://jxsr-
|
|
7
|
-
type: '
|
|
6
|
+
url: 'https://jxsr-eye.antelopecloud.cn/staticResource/v2/video/live.flv/539173011?Authorization=eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6IjEwMDEwMTAwMDQ0NSIsImV4dCI6MTY3MjAzMzkyMzEyOSwidWlkIjoiMTAxMDAwMDAwNjk5IiwidmFsaWRTdGF0ZSI6MTA0NDA2LCJyb2xlSWQiOlsxMDAwMDAxMTA1MTgsMTAwMDAwMTEwNzI4XSwidmFsaWRUaW1lIjoxNzA0MzgzOTk5MDAwLCJvcHRDZW50ZXJJZCI6IjEwMDEwMDAwMDIzMyIsInVzZXJUeXBlIjoxMDA3MDQsImlhdCI6MTY3MTc3NDcyMzEyOX0.HYG9RLLbItoa7zK6pP9GS_2woLiYzRlIyUD_VA1c-YI',
|
|
7
|
+
type: 'flv',
|
|
8
|
+
cid: '111'
|
|
8
9
|
}];
|
|
9
10
|
export default function App() {
|
|
10
11
|
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>Document</title>
|
|
8
|
+
<style>
|
|
9
|
+
.div1{
|
|
10
|
+
width: 500px;
|
|
11
|
+
height: 300px;
|
|
12
|
+
position: relative;
|
|
13
|
+
margin:0 auto;
|
|
14
|
+
border:1px solid #000
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.div2{
|
|
18
|
+
width: 600px;
|
|
19
|
+
height: 400px;
|
|
20
|
+
position: absolute;
|
|
21
|
+
border:1px solid red;
|
|
22
|
+
transform-origin: left top;
|
|
23
|
+
transform: scale(1);
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<div class="div1">
|
|
29
|
+
<div class="div2"></div>
|
|
30
|
+
</div>
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|
package/es/index.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export { default as InstanceHistory } from './InstanceHistory';
|
|
|
21
21
|
export { default as LabelValue } from './LabelValue';
|
|
22
22
|
export { default as List } from './List';
|
|
23
23
|
export { default as ListWithSizeAnimate } from './ListWithSizeAnimate';
|
|
24
|
-
export { default as LoaderApp } from './LoaderApp';
|
|
25
24
|
export { default as LoaderScript } from './LoaderScript';
|
|
26
25
|
export { default as Map } from './Map';
|
|
27
26
|
export { default as Picture } from './Picture';
|
package/es/index.js
CHANGED
|
@@ -21,7 +21,6 @@ export { default as InstanceHistory } from "./InstanceHistory";
|
|
|
21
21
|
export { default as LabelValue } from "./LabelValue";
|
|
22
22
|
export { default as List } from "./List";
|
|
23
23
|
export { default as ListWithSizeAnimate } from "./ListWithSizeAnimate";
|
|
24
|
-
export { default as LoaderApp } from "./LoaderApp";
|
|
25
24
|
export { default as LoaderScript } from "./LoaderScript";
|
|
26
25
|
export { default as Map } from "./Map";
|
|
27
26
|
export { default as Picture } from "./Picture";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@cloud-app-dev/vidc",
|
|
4
4
|
"description": "Video Image Data Componennts",
|
|
5
|
-
"version": "4.0.
|
|
5
|
+
"version": "4.0.1",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"docs:deploy": "gh-pages -d docs-dist",
|
|
8
8
|
"build": "npm run entry && father build",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
]
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@cloud-app-dev/
|
|
45
|
+
"@cloud-app-dev/mpegts.js": "^1.7.2",
|
|
46
46
|
"@turf/boolean-disjoint": "^6.5.0",
|
|
47
47
|
"@turf/helpers": "^6.5.0",
|
|
48
48
|
"@turf/line-to-polygon": "^6.5.0",
|
package/es/LoaderApp/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { AppItemType } from '../Config/interface';
|
|
3
|
-
import './index.less';
|
|
4
|
-
interface ILoaderAppProps {
|
|
5
|
-
/**
|
|
6
|
-
* @description 微应用配置信息
|
|
7
|
-
* @default -
|
|
8
|
-
*/
|
|
9
|
-
appConfig: AppItemType;
|
|
10
|
-
/**
|
|
11
|
-
* @description 需要传递微应用的参数
|
|
12
|
-
* @default {}
|
|
13
|
-
*/
|
|
14
|
-
appProps: {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* @description 微应用加载容器样式
|
|
19
|
-
* @default
|
|
20
|
-
*/
|
|
21
|
-
style?: React.CSSProperties;
|
|
22
|
-
}
|
|
23
|
-
declare function LoaderApp({ appConfig, appProps, style }: ILoaderAppProps): JSX.Element;
|
|
24
|
-
declare namespace LoaderApp {
|
|
25
|
-
var defaultProps: {
|
|
26
|
-
appConfig: {};
|
|
27
|
-
appProps: {};
|
|
28
|
-
style: {};
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export default LoaderApp;
|
package/es/LoaderApp/index.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
|
|
3
|
-
import _useUnmount from "ahooks/es/useUnmount";
|
|
4
|
-
import _nextTick from "@cloud-app-dev/utils/es/nextTick";
|
|
5
|
-
import _useMount from "ahooks/es/useMount";
|
|
6
|
-
import _uuid from "@cloud-app-dev/utils/es/uuid";
|
|
7
|
-
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
9
|
-
|
|
10
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
-
|
|
12
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
|
|
18
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
|
|
20
|
-
import React, { useRef, useMemo } from 'react';
|
|
21
|
-
import LoaderModule from "./loader";
|
|
22
|
-
import "./index.less";
|
|
23
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
-
|
|
26
|
-
function LoaderApp(_ref) {
|
|
27
|
-
var appConfig = _ref.appConfig,
|
|
28
|
-
appProps = _ref.appProps,
|
|
29
|
-
style = _ref.style;
|
|
30
|
-
var domRef = useRef(null);
|
|
31
|
-
var styleRef = useRef(null);
|
|
32
|
-
var loadedAppRef = useRef();
|
|
33
|
-
var id = useMemo(function () {
|
|
34
|
-
return _uuid();
|
|
35
|
-
}, []);
|
|
36
|
-
var statusRef = useRef();
|
|
37
|
-
|
|
38
|
-
_useMount(function () {
|
|
39
|
-
if (!appConfig) {
|
|
40
|
-
console.error('微应用不存在', 'appConfig ->', appConfig, 'appProps ->', appProps);
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!domRef.current || !styleRef.current) {
|
|
45
|
-
console.error('LoaderApp组件未正常初始化!', 'config ->', appConfig, 'appProps ->', appProps);
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var props = _objectSpread(_objectSpread({}, appProps), {}, {
|
|
50
|
-
container: domRef.current
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
var routerPrefix = appConfig.routerPrefix,
|
|
54
|
-
html = appConfig.html;
|
|
55
|
-
var options = {
|
|
56
|
-
html: html,
|
|
57
|
-
name: routerPrefix,
|
|
58
|
-
prefix: ".".concat(routerPrefix, "-").concat(id),
|
|
59
|
-
styleNode: styleRef.current
|
|
60
|
-
};
|
|
61
|
-
LoaderModule(options).then( /*#__PURE__*/function () {
|
|
62
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(mod) {
|
|
63
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
64
|
-
while (1) {
|
|
65
|
-
switch (_context.prev = _context.next) {
|
|
66
|
-
case 0:
|
|
67
|
-
loadedAppRef.current = mod; // 沙箱销毁方法
|
|
68
|
-
|
|
69
|
-
_context.next = 3;
|
|
70
|
-
return mod.bootstrap(props);
|
|
71
|
-
|
|
72
|
-
case 3:
|
|
73
|
-
_nextTick(function () {
|
|
74
|
-
return statusRef.current = 'bootstrap';
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
_context.next = 6;
|
|
78
|
-
return mod.mount(props);
|
|
79
|
-
|
|
80
|
-
case 6:
|
|
81
|
-
_nextTick(function () {
|
|
82
|
-
return statusRef.current = 'mounted';
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
case 7:
|
|
86
|
-
case "end":
|
|
87
|
-
return _context.stop();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}, _callee);
|
|
91
|
-
}));
|
|
92
|
-
|
|
93
|
-
return function (_x) {
|
|
94
|
-
return _ref2.apply(this, arguments);
|
|
95
|
-
};
|
|
96
|
-
}());
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
_useUnmount(function () {
|
|
100
|
-
if (loadedAppRef.current) {
|
|
101
|
-
var app = loadedAppRef.current;
|
|
102
|
-
|
|
103
|
-
var props = _objectSpread(_objectSpread({}, appProps), {}, {
|
|
104
|
-
container: domRef.current
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
app.unmount(props);
|
|
108
|
-
|
|
109
|
-
_nextTick(function () {
|
|
110
|
-
return statusRef.current = 'unmount';
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
loadedAppRef.current = null;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return /*#__PURE__*/_jsxs("main", {
|
|
118
|
-
ref: domRef,
|
|
119
|
-
className: "loaded-app-layout ".concat(appConfig.routerPrefix, "-").concat(id),
|
|
120
|
-
style: style,
|
|
121
|
-
children: [/*#__PURE__*/_jsx("style", {
|
|
122
|
-
ref: styleRef
|
|
123
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
124
|
-
id: appConfig.routerPrefix,
|
|
125
|
-
style: {
|
|
126
|
-
width: '100%',
|
|
127
|
-
height: '100%'
|
|
128
|
-
}
|
|
129
|
-
})]
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
LoaderApp.defaultProps = {
|
|
134
|
-
appConfig: {},
|
|
135
|
-
appProps: {},
|
|
136
|
-
style: {}
|
|
137
|
-
};
|
|
138
|
-
export default LoaderApp;
|
package/es/LoaderApp/index.less
DELETED
package/es/LoaderApp/loader.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AppInstance } from './interface';
|
|
2
|
-
interface createScopedCssTextProps {
|
|
3
|
-
styleNode: HTMLStyleElement;
|
|
4
|
-
prefix: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function createScopedCssText({ styleNode, prefix }: createScopedCssTextProps): string;
|
|
7
|
-
interface ILoaderStyleProps {
|
|
8
|
-
cssText: string;
|
|
9
|
-
prefix: string;
|
|
10
|
-
styleNode: HTMLStyleElement;
|
|
11
|
-
}
|
|
12
|
-
export declare function LoaderStyle({ cssText, prefix, styleNode }: ILoaderStyleProps): Promise<void>;
|
|
13
|
-
interface ILoaderModuleProps {
|
|
14
|
-
prefix: string;
|
|
15
|
-
styleNode: HTMLStyleElement;
|
|
16
|
-
html: string;
|
|
17
|
-
}
|
|
18
|
-
export default function LoaderModule({ prefix, styleNode, html }: ILoaderModuleProps): Promise<AppInstance>;
|
|
19
|
-
export {};
|