@cloud-app-dev/vidc 4.0.20 → 4.0.22
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/AppContext/Sync.js +42 -0
- package/es/AppContext/index.js +141 -0
- package/es/AppContext/interface.d.ts +41 -0
- package/es/AppContext/static.js +9 -0
- package/es/Auth/index.js +14 -0
- package/es/AutoExit/index.js +19 -0
- package/es/CheckGroupFixed/demo.js +22 -0
- package/es/CheckGroupFixed/index.js +140 -0
- package/es/CheckGroupFixed/index.less +56 -0
- package/es/Config/index.js +77 -0
- package/es/Config/interface.d.ts +65 -0
- package/es/Config/utils.js +33 -0
- package/es/ConfigContext/index.js +21 -0
- package/es/CustomRenderSelect/index.js +72 -0
- package/es/CustomRenderSelect/index.less +25 -0
- package/es/DBTools/index.js +336 -0
- package/es/DisableMark/index.js +19 -0
- package/es/DisableMark/index.less +9 -0
- package/es/DomMove/demo.js +16 -0
- package/es/DomMove/index.js +139 -0
- package/es/DomMove/utils.js +32 -0
- package/es/Drag/DragAndDropItem.js +133 -0
- package/es/Drag/DropItem.js +50 -0
- package/es/Drag/index.d.ts +9 -0
- package/es/Drag/index.js +7 -0
- package/es/Drag/interface.d.ts +16 -0
- package/es/DynamicGridList/Demo.js +77 -0
- package/es/DynamicGridList/index.js +67 -0
- package/es/DynamicList/demo.js +44 -0
- package/es/DynamicList/index.js +86 -0
- package/es/DynamicList/index.less +17 -0
- package/es/DynamicList/interface.d.ts +19 -0
- package/es/DynamicList/utils.js +6 -0
- package/es/ErrorFallback/index.js +31 -0
- package/es/ErrorFallback/inerface.d.ts +48 -0
- package/es/EventTools/index.js +12 -0
- package/es/FrontendPlayer/index.js +2 -0
- package/es/FullScreen/index.js +33 -0
- package/es/FullScreen/index.less +18 -0
- package/es/GridList/Demo.js +80 -0
- package/es/GridList/data.js +609 -0
- package/es/GridList/hook.js +270 -0
- package/es/GridList/index.js +44 -0
- package/es/GridList/index.less +8 -0
- package/es/GridList/interface.d.ts +59 -0
- package/es/GridList/utils.js +42 -0
- package/es/HightLevel/index.js +18 -0
- package/es/HightLevel/index.less +3 -0
- package/es/IconFont/index.js +54 -0
- package/es/ImageView/index.js +51 -0
- package/es/ImageView/index.less +11 -0
- package/es/InstanceHistory/index.js +7 -0
- package/es/LabelPlayer/111.png +0 -0
- package/es/LabelPlayer/demo.js +115 -0
- package/es/LabelPlayer/index.js +160 -0
- package/es/LabelPlayer/index.less +24 -0
- package/es/LabelValue/index.js +27 -0
- package/es/LabelValue/index.less +23 -0
- package/es/List/demo.js +23 -0
- package/es/List/index.js +28 -0
- package/es/List/index.less +20 -0
- package/es/ListWithSizeAnimate/demo.js +98 -0
- package/es/ListWithSizeAnimate/index.js +85 -0
- package/es/ListWithSizeAnimate/index.less +23 -0
- package/es/LoaderScript/index.js +34 -0
- package/es/LoaderScript/utils.js +179 -0
- package/es/Map/AMap.d.ts +7109 -0
- package/es/Map/BasicMap/AMapInstance.js +98 -0
- package/es/Map/BasicMap/LeafletInstance.js +111 -0
- package/es/Map/BasicMap/index.js +90 -0
- package/es/Map/BasicMap/index.less +29 -0
- package/es/Map/ClusterLayer/demo.js +18 -0
- package/es/Map/ClusterLayer/hook.js +123 -0
- package/es/Map/ClusterLayer/index.js +28 -0
- package/es/Map/ClusterLayer/index.less +29 -0
- package/es/Map/ClusterLayer/props.d.ts +8 -0
- package/es/Map/Config/index.js +48 -0
- package/es/Map/Config/utils.js +65 -0
- package/es/Map/Context/index.js +51 -0
- package/es/Map/FindPio/index.js +13 -0
- package/es/Map/FindPio/index.less +7 -0
- package/es/Map/InfoWindow/MakerLikeWindow.js +108 -0
- package/es/Map/InfoWindow/demo.js +70 -0
- package/es/Map/InfoWindow/index.js +62 -0
- package/es/Map/LevelCenter/DragMarker/index.js +42 -0
- package/es/Map/LevelCenter/demo.js +38 -0
- package/es/Map/LevelCenter/index.js +66 -0
- package/es/Map/LoaderMap/index.js +62 -0
- package/es/Map/MapDrawSelect/demo.js +71 -0
- package/es/Map/MapDrawSelect/index.js +56 -0
- package/es/Map/MouseTool/index.js +40 -0
- package/es/Map/MouseTool/useMouseTools.js +83 -0
- package/es/Map/ResetTools/index.js +57 -0
- package/es/Map/ResetTools/index.less +39 -0
- package/es/Map/SinglePoint/demo.js +14 -0
- package/es/Map/SinglePoint/index.js +52 -0
- package/es/Map/SinglePoint/index.less +41 -0
- package/es/Map/hook/useMapEvent.js +19 -0
- package/es/Map/hook/useMapType.js +12 -0
- package/es/Map/icon.js +10 -0
- package/es/Map/index.js +25 -0
- package/es/Map/interface.d.ts +74 -0
- package/es/Map/points.js +1 -0
- package/es/Map/useMarker/index.js +71 -0
- package/es/Map/withMap/index.js +10 -0
- package/es/Picture/component/DefaultRects/RectInfo.js +80 -0
- package/es/Picture/component/DefaultRects/index.js +52 -0
- package/es/Picture/component/DefaultRects/index.less +211 -0
- package/es/Picture/component/DefaultRects/utils.js +11 -0
- package/es/Picture/component/DrawRect/index.js +46 -0
- package/es/Picture/component/DrawRect/index.less +8 -0
- package/es/Picture/component/RectMenu/index.js +76 -0
- package/es/Picture/component/RectMenu/index.less +36 -0
- package/es/Picture/component/RectMenu/utils.js +19 -0
- package/es/Picture/component/Tools/index.js +73 -0
- package/es/Picture/component/Tools/index.less +49 -0
- package/es/Picture/component/WheelScale/index.js +27 -0
- package/es/Picture/demo.js +105 -0
- package/es/Picture/index.js +341 -0
- package/es/Picture/index.less +20 -0
- package/es/Picture/interface.d.ts +196 -0
- package/es/Picture/loadCaptureRectImage.js +99 -0
- package/es/Picture/useDraw.js +103 -0
- package/es/Picture/utils.js +143 -0
- package/es/Player/api/index.js +309 -0
- package/es/Player/context.js +24 -0
- package/es/Player/contraller_bar/bar.js +20 -0
- package/es/Player/contraller_bar/contraller_event.js +48 -0
- package/es/Player/contraller_bar/index.js +27 -0
- package/es/Player/contraller_bar/left_bar.js +83 -0
- package/es/Player/contraller_bar/right_bar.js +32 -0
- package/es/Player/contraller_bar/time.js +19 -0
- package/es/Player/contraller_bar/useBarStatus.js +43 -0
- package/es/Player/contraller_bar/volume.js +62 -0
- package/es/Player/demo.js +266 -0
- package/es/Player/empty.js +4 -0
- package/es/Player/event/errorEvent.js +88 -0
- package/es/Player/event/eventName.js +29 -0
- package/es/Player/event/index.js +205 -0
- package/es/Player/fps_play.js +83 -0
- package/es/Player/frontend_player.js +64 -0
- package/es/Player/frontend_timeline.js +132 -0
- package/es/Player/iconfont.js +16 -0
- package/es/Player/index.js +2 -0
- package/es/Player/live_heart.js +45 -0
- package/es/Player/message.js +133 -0
- package/es/Player/player.d.ts +233 -0
- package/es/Player/segment_player.js +228 -0
- package/es/Player/segment_timeline.js +173 -0
- package/es/Player/single_player.js +262 -0
- package/es/Player/style/bar.less +43 -0
- package/es/Player/style/iconfont.js +43 -0
- package/es/Player/style/index.less +34 -0
- package/es/Player/style/message.less +56 -0
- package/es/Player/style/slider.less +106 -0
- package/es/Player/style/timeline.less +117 -0
- package/es/Player/style/volume.less +24 -0
- package/es/Player/timeline.js +95 -0
- package/es/Player/util.js +189 -0
- package/es/PlayerExt/demo.js +154 -0
- package/es/PlayerExt/index.js +188 -0
- package/es/PlayerExt/index.less +10 -0
- package/es/Progress/index.d.ts +9 -0
- package/es/Progress/index.js +53 -0
- package/es/Progress/index.less +21 -0
- package/es/ROI/demo.js +16 -0
- package/es/ROI/index.js +54 -0
- package/es/ROI/index.less +33 -0
- package/es/RefDrawer/Footer.js +22 -0
- package/es/RefDrawer/demo.js +18 -0
- package/es/RefDrawer/index.js +71 -0
- package/es/RefModal/demo.js +18 -0
- package/es/RefModal/index.js +70 -0
- package/es/ScreenPlayer/Live.js +212 -0
- package/es/ScreenPlayer/LiveTools.js +151 -0
- package/es/ScreenPlayer/PlayerWithExt.js +231 -0
- package/es/ScreenPlayer/RatePick.js +29 -0
- package/es/ScreenPlayer/Record.js +442 -0
- package/es/ScreenPlayer/RecordTools.js +169 -0
- package/es/ScreenPlayer/ScreenSelect.js +46 -0
- package/es/ScreenPlayer/SegmentTimeLine.js +36 -0
- package/es/ScreenPlayer/TimeMode.js +26 -0
- package/es/ScreenPlayer/TimeSelect.js +88 -0
- package/es/ScreenPlayer/demo.js +21 -0
- package/es/ScreenPlayer/demo2.js +194 -0
- package/es/ScreenPlayer/index.js +9 -0
- package/es/ScreenPlayer/index.less +335 -0
- package/es/ScreenPlayer/interface.d.ts +216 -0
- package/es/ScreenPlayer/useTimeSlider.js +456 -0
- package/es/ScreenPlayer/useVideoFit.js +35 -0
- package/es/ScreenPlayer/utils.js +85 -0
- package/es/SegmentPlayer/index.js +2 -0
- package/es/Service/http.js +133 -0
- package/es/Service/index.js +11 -0
- package/es/Service/interface.d.ts +23 -0
- package/es/Service/middleware.js +22 -0
- package/es/SocketEmitter/eventEmitter.js +88 -0
- package/es/SocketEmitter/index.js +125 -0
- package/es/SocketEmitter/interface.d.ts +4 -0
- package/es/TableLayout/index.js +27 -0
- package/es/TableLayout/index.less +4 -0
- package/es/ThemeAntd/demo.js +81 -0
- package/es/ThemeAntd/demo.less +20 -0
- package/es/ThemeAntd/index.js +21 -0
- package/es/ThemeAntd/index.less +4 -0
- package/es/Timeout/index.js +65 -0
- package/es/bigNumberTransformCN/index.js +58 -0
- package/es/cache/index.js +94 -0
- package/es/copy/index.js +9 -0
- package/es/core.d.ts +0 -0
- package/es/getThemeStyle/index.js +5 -0
- package/es/index.js +62 -0
- package/es/likeGo/index.js +31 -0
- package/es/likeGoSync/index.js +10 -0
- package/es/logger/index.js +30 -0
- package/es/nextTick/index.js +3 -0
- package/es/recorder/demo.js +181 -0
- package/es/recorder/index.js +992 -0
- package/es/submidstr/index.js +14 -0
- package/es/treeHelper/index.js +188 -0
- package/es/typings.d.ts +2 -0
- package/es/useDrawROI/index.js +318 -0
- package/es/useEventEmitterHandle/index.js +17 -0
- package/es/useFullscreen/demo.js +43 -0
- package/es/useFullscreen/index.js +76 -0
- package/es/useHistory/index.js +9 -0
- package/es/useHistory/interface.d.ts +3 -0
- package/es/useInfiniteScroll/index.js +102 -0
- package/es/useRafInterval/index.js +70 -0
- package/es/useSimpleState/index.js +35 -0
- package/es/useVirtualList/index.js +136 -0
- package/es/utils.js +46 -0
- package/es/uuid/index.js +19 -0
- package/package.json +2 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 大数字转换,将大额数字转换为万、千万、亿等
|
|
3
|
+
* @param value 数字值
|
|
4
|
+
*/
|
|
5
|
+
export default function bigNumberTransformCN(value) {
|
|
6
|
+
var newValue = ['', '', ''];
|
|
7
|
+
var fr = 1000;
|
|
8
|
+
var num = 3;
|
|
9
|
+
var text1 = '';
|
|
10
|
+
var fm = 1;
|
|
11
|
+
while (value / fr >= 1) {
|
|
12
|
+
fr *= 10;
|
|
13
|
+
num += 1;
|
|
14
|
+
}
|
|
15
|
+
if (num <= 4) {
|
|
16
|
+
// 千
|
|
17
|
+
newValue[0] = "".concat(Math.round(value / 1000));
|
|
18
|
+
newValue[1] = '千';
|
|
19
|
+
} else if (num <= 8) {
|
|
20
|
+
// 万
|
|
21
|
+
text1 = Math.round(num - 4) / 3 > 1 ? '千万' : '万';
|
|
22
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
23
|
+
fm = text1 === '万' ? 10000 : 10000000;
|
|
24
|
+
if (value % fm === 0) {
|
|
25
|
+
newValue[0] = Math.round(value / fm) + '';
|
|
26
|
+
} else {
|
|
27
|
+
newValue[0] = Math.round(value / fm).toFixed(2) + '';
|
|
28
|
+
}
|
|
29
|
+
newValue[1] = text1;
|
|
30
|
+
} else if (num <= 16) {
|
|
31
|
+
// 亿
|
|
32
|
+
text1 = (num - 8) / 3 > 1 ? '千亿' : '亿';
|
|
33
|
+
text1 = (num - 8) / 4 > 1 ? '万亿' : text1;
|
|
34
|
+
text1 = (num - 8) / 7 > 1 ? '千万亿' : text1;
|
|
35
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
36
|
+
fm = 1;
|
|
37
|
+
if (text1 === '亿') {
|
|
38
|
+
fm = 100000000;
|
|
39
|
+
} else if (text1 === '千亿') {
|
|
40
|
+
fm = 100000000000;
|
|
41
|
+
} else if (text1 === '万亿') {
|
|
42
|
+
fm = 1000000000000;
|
|
43
|
+
} else if (text1 === '千万亿') {
|
|
44
|
+
fm = 1000000000000000;
|
|
45
|
+
}
|
|
46
|
+
if (value % fm === 0) {
|
|
47
|
+
newValue[0] = Math.round(value / fm) + '';
|
|
48
|
+
} else {
|
|
49
|
+
newValue[0] = Math.round(value / fm).toFixed(2) + '';
|
|
50
|
+
}
|
|
51
|
+
newValue[1] = text1;
|
|
52
|
+
}
|
|
53
|
+
if (value < 1000) {
|
|
54
|
+
newValue[0] = value + '';
|
|
55
|
+
newValue[1] = '';
|
|
56
|
+
}
|
|
57
|
+
return newValue.join('');
|
|
58
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import Cookie from 'js-cookie';
|
|
2
|
+
/**
|
|
3
|
+
* 获取缓存数据
|
|
4
|
+
* @param {string} key
|
|
5
|
+
* @param {string} type: 缓存类型 'local'(默认) / cookie / session;
|
|
6
|
+
*/
|
|
7
|
+
function getCache(key) {
|
|
8
|
+
var _sessionStorage$getIt, _localStorage$getItem;
|
|
9
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'local';
|
|
10
|
+
var data;
|
|
11
|
+
var str;
|
|
12
|
+
switch (type) {
|
|
13
|
+
case 'cookie':
|
|
14
|
+
data = Cookie.get(key);
|
|
15
|
+
break;
|
|
16
|
+
case 'session':
|
|
17
|
+
str = (_sessionStorage$getIt = sessionStorage.getItem(key)) !== null && _sessionStorage$getIt !== void 0 ? _sessionStorage$getIt : '';
|
|
18
|
+
try {
|
|
19
|
+
data = JSON.parse(str);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
data = str;
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
str = (_localStorage$getItem = localStorage.getItem(key)) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : '';
|
|
26
|
+
try {
|
|
27
|
+
data = JSON.parse(str);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
data = str;
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 获取缓存数据
|
|
38
|
+
* @param {string} key
|
|
39
|
+
* @param {any} value
|
|
40
|
+
* @param {string} type: 缓存类型 'local'(默认) / cookie / session;
|
|
41
|
+
*/
|
|
42
|
+
function setCache(key, value) {
|
|
43
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'local';
|
|
44
|
+
switch (type) {
|
|
45
|
+
case 'cookie':
|
|
46
|
+
Cookie.set(key, value, {
|
|
47
|
+
expires: 7
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
case 'session':
|
|
51
|
+
sessionStorage.setItem(key, JSON.stringify(value));
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 获取用户缓存
|
|
61
|
+
* @param {*} key
|
|
62
|
+
* @param {*} type
|
|
63
|
+
*/
|
|
64
|
+
function getUserCache(key) {
|
|
65
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'local';
|
|
66
|
+
var id = getCache('userId', 'session');
|
|
67
|
+
if (!id) {
|
|
68
|
+
console.error('无法获取用户信息!');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
return getCache("".concat(id, "-").concat(key), type);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 设置用户缓存
|
|
76
|
+
* @param {*} key
|
|
77
|
+
* @param {*} value
|
|
78
|
+
* @param {*} type
|
|
79
|
+
*/
|
|
80
|
+
function setUserCache(key, value) {
|
|
81
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'local';
|
|
82
|
+
var id = getCache('userId', 'session');
|
|
83
|
+
if (!id) {
|
|
84
|
+
console.error('无法获取用户信息!');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
return setCache("".concat(id, "-").concat(key), value, type);
|
|
88
|
+
}
|
|
89
|
+
export default {
|
|
90
|
+
getCache: getCache,
|
|
91
|
+
setCache: setCache,
|
|
92
|
+
getUserCache: getUserCache,
|
|
93
|
+
setUserCache: setUserCache
|
|
94
|
+
};
|
package/es/copy/index.js
ADDED
package/es/core.d.ts
ADDED
|
File without changes
|
package/es/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export { default as AppContext } from "./AppContext";
|
|
2
|
+
export { default as Auth } from "./Auth";
|
|
3
|
+
export { default as AutoExit } from "./AutoExit";
|
|
4
|
+
export { default as bigNumberTransformCN } from "./bigNumberTransformCN";
|
|
5
|
+
export { default as cache } from "./cache";
|
|
6
|
+
export { default as CheckGroupFixed } from "./CheckGroupFixed";
|
|
7
|
+
export { default as Config } from "./Config";
|
|
8
|
+
export { default as ConfigContext } from "./ConfigContext";
|
|
9
|
+
export { default as copy } from "./copy";
|
|
10
|
+
export { default as CustomRenderSelect } from "./CustomRenderSelect";
|
|
11
|
+
export { default as DBTools } from "./DBTools";
|
|
12
|
+
export { default as DisableMark } from "./DisableMark";
|
|
13
|
+
export { default as DomMove } from "./DomMove";
|
|
14
|
+
export { default as Drag } from "./Drag";
|
|
15
|
+
export { default as DynamicGridList } from "./DynamicGridList";
|
|
16
|
+
export { default as DynamicList } from "./DynamicList";
|
|
17
|
+
export { default as ErrorFallback } from "./ErrorFallback";
|
|
18
|
+
export { default as EventTools } from "./EventTools";
|
|
19
|
+
export { default as FrontendPlayer } from "./FrontendPlayer";
|
|
20
|
+
export { default as FullScreen } from "./FullScreen";
|
|
21
|
+
export { default as getThemeStyle } from "./getThemeStyle";
|
|
22
|
+
export { default as GridList } from "./GridList";
|
|
23
|
+
export { default as HightLevel } from "./HightLevel";
|
|
24
|
+
export { default as IconFont } from "./IconFont";
|
|
25
|
+
export { default as ImageView } from "./ImageView";
|
|
26
|
+
export { default as InstanceHistory } from "./InstanceHistory";
|
|
27
|
+
export { default as LabelPlayer } from "./LabelPlayer";
|
|
28
|
+
export { default as LabelValue } from "./LabelValue";
|
|
29
|
+
export { default as likeGo } from "./likeGo";
|
|
30
|
+
export { default as likeGoSync } from "./likeGoSync";
|
|
31
|
+
export { default as List } from "./List";
|
|
32
|
+
export { default as ListWithSizeAnimate } from "./ListWithSizeAnimate";
|
|
33
|
+
export { default as LoaderScript } from "./LoaderScript";
|
|
34
|
+
export { default as logger } from "./logger";
|
|
35
|
+
export { default as Map } from "./Map";
|
|
36
|
+
export { default as nextTick } from "./nextTick";
|
|
37
|
+
export { default as Picture } from "./Picture";
|
|
38
|
+
export { default as Player } from "./Player";
|
|
39
|
+
export { default as PlayerExt } from "./PlayerExt";
|
|
40
|
+
export { default as Progress } from "./Progress";
|
|
41
|
+
export { default as recorder } from "./recorder";
|
|
42
|
+
export { default as RefDrawer } from "./RefDrawer";
|
|
43
|
+
export { default as RefModal } from "./RefModal";
|
|
44
|
+
export { default as ROI } from "./ROI";
|
|
45
|
+
export { default as ScreenPlayer } from "./ScreenPlayer";
|
|
46
|
+
export { default as SegmentPlayer } from "./SegmentPlayer";
|
|
47
|
+
export { default as Service } from "./Service";
|
|
48
|
+
export { default as SocketEmitter } from "./SocketEmitter";
|
|
49
|
+
export { default as submidstr } from "./submidstr";
|
|
50
|
+
export { default as TableLayout } from "./TableLayout";
|
|
51
|
+
export { default as ThemeAntd } from "./ThemeAntd";
|
|
52
|
+
export { default as Timeout } from "./Timeout";
|
|
53
|
+
export { default as treeHelper } from "./treeHelper";
|
|
54
|
+
export { default as useDrawROI } from "./useDrawROI";
|
|
55
|
+
export { default as useEventEmitterHandle } from "./useEventEmitterHandle";
|
|
56
|
+
export { default as useFullscreen } from "./useFullscreen";
|
|
57
|
+
export { default as useHistory } from "./useHistory";
|
|
58
|
+
export { default as useInfiniteScroll } from "./useInfiniteScroll";
|
|
59
|
+
export { default as useRafInterval } from "./useRafInterval";
|
|
60
|
+
export { default as useSimpleState } from "./useSimpleState";
|
|
61
|
+
export { default as useVirtualList } from "./useVirtualList";
|
|
62
|
+
export { default as uuid } from "./uuid";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
function likeGo(_x) {
|
|
6
|
+
return _likeGo.apply(this, arguments);
|
|
7
|
+
}
|
|
8
|
+
function _likeGo() {
|
|
9
|
+
_likeGo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fn) {
|
|
10
|
+
var result;
|
|
11
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
result = [];
|
|
15
|
+
_context.next = 3;
|
|
16
|
+
return fn().then(function (res) {
|
|
17
|
+
result[0] = res;
|
|
18
|
+
}).catch(function (err) {
|
|
19
|
+
result[1] = err;
|
|
20
|
+
});
|
|
21
|
+
case 3:
|
|
22
|
+
return _context.abrupt("return", result);
|
|
23
|
+
case 4:
|
|
24
|
+
case "end":
|
|
25
|
+
return _context.stop();
|
|
26
|
+
}
|
|
27
|
+
}, _callee);
|
|
28
|
+
}));
|
|
29
|
+
return _likeGo.apply(this, arguments);
|
|
30
|
+
}
|
|
31
|
+
export default likeGo;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
debug: function debug(title) {
|
|
3
|
+
var _console;
|
|
4
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
5
|
+
args[_key - 1] = arguments[_key];
|
|
6
|
+
}
|
|
7
|
+
(_console = console).debug.apply(_console, ["%c[DEBUG] -> ".concat(title), 'color:white;background-color:blue'].concat(args));
|
|
8
|
+
},
|
|
9
|
+
success: function success(title) {
|
|
10
|
+
var _console2;
|
|
11
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
12
|
+
args[_key2 - 1] = arguments[_key2];
|
|
13
|
+
}
|
|
14
|
+
(_console2 = console).debug.apply(_console2, ["%c[SUCCESS] -> ".concat(title), 'color:white;background-color:green'].concat(args));
|
|
15
|
+
},
|
|
16
|
+
error: function error(title) {
|
|
17
|
+
var _console3;
|
|
18
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
19
|
+
args[_key3 - 1] = arguments[_key3];
|
|
20
|
+
}
|
|
21
|
+
(_console3 = console).error.apply(_console3, ["%c[ERROR] -> ".concat(title), 'color:white;background-color:red'].concat(args));
|
|
22
|
+
},
|
|
23
|
+
warn: function warn(title) {
|
|
24
|
+
var _console4;
|
|
25
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
26
|
+
args[_key4 - 1] = arguments[_key4];
|
|
27
|
+
}
|
|
28
|
+
(_console4 = console).error.apply(_console4, ["%c[WARN] -> ".concat(title), 'color:white;background-color:yellow'].concat(args));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
/* eslint-disable react/button-has-type */
|
|
12
|
+
import { useCreation } from 'ahooks';
|
|
13
|
+
import React, { useEffect, useState } from 'react';
|
|
14
|
+
import io from 'socket.io-client';
|
|
15
|
+
import Recorder from "./index";
|
|
16
|
+
var recorder = new Recorder({
|
|
17
|
+
sampleBits: 16,
|
|
18
|
+
// 采样位数,支持 8 或 16,默认是16
|
|
19
|
+
sampleRate: 16000,
|
|
20
|
+
// 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
|
|
21
|
+
numChannels: 1,
|
|
22
|
+
// 声道,支持 1 或 2, 默认是1
|
|
23
|
+
compiling: true //(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
|
|
24
|
+
});
|
|
25
|
+
var recorder2 = new Recorder({
|
|
26
|
+
sampleBits: 16,
|
|
27
|
+
// 采样位数,支持 8 或 16,默认是16
|
|
28
|
+
sampleRate: 16000,
|
|
29
|
+
// 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
|
|
30
|
+
numChannels: 1,
|
|
31
|
+
// 声道,支持 1 或 2, 默认是1
|
|
32
|
+
compiling: true //(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
|
|
33
|
+
});
|
|
34
|
+
var App = function App() {
|
|
35
|
+
var _useState = useState(false),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
state = _useState2[0],
|
|
38
|
+
setState = _useState2[1];
|
|
39
|
+
var sokect = useCreation(function () {
|
|
40
|
+
return io('ws://192.168.101.89:9614', {
|
|
41
|
+
path: '/socket.io',
|
|
42
|
+
query: {
|
|
43
|
+
sn: '110110110110',
|
|
44
|
+
meetingNo: '54325432543',
|
|
45
|
+
manufacturer: 'speech',
|
|
46
|
+
audioType: 'wav',
|
|
47
|
+
sampleBytes: '16',
|
|
48
|
+
sampleRate: '16000',
|
|
49
|
+
channel: '1',
|
|
50
|
+
language: 'cn',
|
|
51
|
+
authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InNlcnZpY2VJZCI6IjE2NTU1NDAwMjI5ODQ3NzMiLCJlbmFibGVkIjp0cnVlLCJzZXJ2aWNlVHlwZSI6Miwic2VydmljZU5hbWUiOiLnu4Tku7bljJbmtYvor5XlubPlj7Bf5Yu_5YqoIiwic2VydmljZU5vIjoiMjAyMzA1MDUwMDEiLCJzaWduSW5UeXBlIjoic2VydmljZSIsImF1dGhvcml0eVR5cGUiOjIsIm1lZXRpbmdBY2Nlc3NJZCI6MTY0MTY5MjI3NDQ5MTQ2MSwidm9pY2VBY2Nlc3NJZCI6MTY1NTUzODM1NDQwNTQ0NSwiYXV0aG9yaXRpZXMiOm51bGx9LCJzY29wZSI6WyJzZXJ2aWNlIl0sImV4cCI6MTY4MzcyOTA0MSwianRpIjoiMjc1YjM2ZmMtY2FjNS00MjgyLWFlYzYtM2YxNWRlOTBkZjFkIiwiY2xpZW50X2lkIjoic2VydmljZTo5YzJiMTdjMGNmZjE0MDgzYmRiNmYyN2NhNzYzY2ZmOSJ9.FdWyBmWF-hmC16wNohViLbHJf4qiEzIqSk9shqGLCPs'
|
|
52
|
+
},
|
|
53
|
+
autoConnect: false,
|
|
54
|
+
transports: ['websocket']
|
|
55
|
+
});
|
|
56
|
+
}, []);
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
sokect.on('connect', function () {
|
|
59
|
+
console.log('connect');
|
|
60
|
+
});
|
|
61
|
+
sokect.on('message', function (event) {
|
|
62
|
+
console.log(event);
|
|
63
|
+
});
|
|
64
|
+
}, []);
|
|
65
|
+
var onstart = /*#__PURE__*/function () {
|
|
66
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
67
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
68
|
+
while (1) switch (_context.prev = _context.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
_context.next = 2;
|
|
71
|
+
return recorder.start();
|
|
72
|
+
case 2:
|
|
73
|
+
setState(true);
|
|
74
|
+
case 3:
|
|
75
|
+
case "end":
|
|
76
|
+
return _context.stop();
|
|
77
|
+
}
|
|
78
|
+
}, _callee);
|
|
79
|
+
}));
|
|
80
|
+
return function onstart() {
|
|
81
|
+
return _ref.apply(this, arguments);
|
|
82
|
+
};
|
|
83
|
+
}();
|
|
84
|
+
var oncanect = function oncanect() {
|
|
85
|
+
if (!sokect.connected) {
|
|
86
|
+
sokect.connect();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var onstop = function onstop() {
|
|
90
|
+
recorder.stop();
|
|
91
|
+
setState(false);
|
|
92
|
+
if (sokect.connected) {
|
|
93
|
+
sokect.disconnect();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
useEffect(function () {
|
|
97
|
+
if (state) {
|
|
98
|
+
var timer = setInterval(function () {
|
|
99
|
+
var voice = recorder.getNextData();
|
|
100
|
+
if (!voice) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
sokect.emit('message', {
|
|
104
|
+
sendTime: Date.now(),
|
|
105
|
+
voice: voice
|
|
106
|
+
});
|
|
107
|
+
}, 40);
|
|
108
|
+
return function () {
|
|
109
|
+
return clearInterval(timer);
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}, [state]);
|
|
113
|
+
var onstart2 = /*#__PURE__*/function () {
|
|
114
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
115
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
116
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
117
|
+
case 0:
|
|
118
|
+
_context2.next = 2;
|
|
119
|
+
return recorder2.start();
|
|
120
|
+
case 2:
|
|
121
|
+
setState(true);
|
|
122
|
+
case 3:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context2.stop();
|
|
125
|
+
}
|
|
126
|
+
}, _callee2);
|
|
127
|
+
}));
|
|
128
|
+
return function onstart2() {
|
|
129
|
+
return _ref2.apply(this, arguments);
|
|
130
|
+
};
|
|
131
|
+
}();
|
|
132
|
+
var onstop2 = /*#__PURE__*/function () {
|
|
133
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
134
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
135
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
136
|
+
case 0:
|
|
137
|
+
recorder2.stop();
|
|
138
|
+
setState(true);
|
|
139
|
+
case 2:
|
|
140
|
+
case "end":
|
|
141
|
+
return _context3.stop();
|
|
142
|
+
}
|
|
143
|
+
}, _callee3);
|
|
144
|
+
}));
|
|
145
|
+
return function onstop2() {
|
|
146
|
+
return _ref3.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
}();
|
|
149
|
+
var onplay2 = /*#__PURE__*/function () {
|
|
150
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
151
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
152
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
recorder2.play();
|
|
155
|
+
case 1:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context4.stop();
|
|
158
|
+
}
|
|
159
|
+
}, _callee4);
|
|
160
|
+
}));
|
|
161
|
+
return function onplay2() {
|
|
162
|
+
return _ref4.apply(this, arguments);
|
|
163
|
+
};
|
|
164
|
+
}();
|
|
165
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
166
|
+
className: "App"
|
|
167
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", null, "\u5B9E\u65F6\u8BED\u97F3\u8F6C\u5199"), /*#__PURE__*/React.createElement("button", {
|
|
168
|
+
onClick: oncanect
|
|
169
|
+
}, "\u8FDE\u63A5"), /*#__PURE__*/React.createElement("button", {
|
|
170
|
+
onClick: onstart
|
|
171
|
+
}, "\u5F00\u59CB"), /*#__PURE__*/React.createElement("button", {
|
|
172
|
+
onClick: onstop
|
|
173
|
+
}, "\u505C\u6B62")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", null, "\u97F3\u9891\u5F55\u5236"), /*#__PURE__*/React.createElement("button", {
|
|
174
|
+
onClick: onstart2
|
|
175
|
+
}, "\u5F00\u59CB"), /*#__PURE__*/React.createElement("button", {
|
|
176
|
+
onClick: onstop2
|
|
177
|
+
}, "\u505C\u6B62"), /*#__PURE__*/React.createElement("button", {
|
|
178
|
+
onClick: onplay2
|
|
179
|
+
}, "\u64AD\u653E")));
|
|
180
|
+
};
|
|
181
|
+
export default App;
|