@tarojs/taro-h5 3.4.0-beta.0 → 3.4.0
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/dist/api/ad/index.js +4 -0
- package/dist/api/ai/facial.js +5 -0
- package/dist/api/ai/index.js +2 -0
- package/dist/api/ai/visual.js +3 -0
- package/dist/api/alipay/index.js +3 -0
- package/dist/api/base/crypto.js +3 -0
- package/dist/api/base/debug.js +4 -0
- package/dist/api/base/index.js +17 -0
- package/dist/api/base/performance.js +4 -0
- package/dist/api/base/system/index.js +2 -0
- package/dist/api/base/system/info.js +57 -0
- package/dist/api/base/system/network.js +63 -0
- package/dist/api/base/update.js +4 -0
- package/dist/api/base/weapp/app-event.js +18 -0
- package/dist/api/base/weapp/life-cycle.js +4 -0
- package/dist/api/canvas/CanvasContext.js +191 -0
- package/dist/api/canvas/canvasGetImageData.js +25 -0
- package/dist/api/canvas/canvasPutImageData.js +22 -0
- package/dist/api/canvas/canvasToTempFilePath.js +22 -0
- package/dist/api/canvas/createCanvasContext.js +16 -0
- package/dist/api/canvas/index.js +8 -0
- package/dist/api/cloud/index.js +17 -0
- package/dist/api/data-analysis/index.js +5 -0
- package/dist/api/device/accelerometer.js +83 -0
- package/dist/api/device/accessibility.js +3 -0
- package/dist/api/device/battery.js +4 -0
- package/dist/api/device/bluetooth-ble.js +18 -0
- package/dist/api/device/bluetooth-peripheral.js +5 -0
- package/dist/api/device/bluetooth.js +15 -0
- package/dist/api/device/calendar.js +4 -0
- package/dist/api/device/clipboard.js +65 -0
- package/dist/api/device/compass.js +64 -0
- package/dist/api/device/contact.js +4 -0
- package/dist/api/device/crypto.js +3 -0
- package/dist/api/device/gyroscope.js +6 -0
- package/dist/api/device/iBeacon.js +9 -0
- package/dist/api/device/index.js +22 -0
- package/dist/api/device/keyboard.js +6 -0
- package/dist/api/device/memory.js +4 -0
- package/dist/api/device/motion.js +81 -0
- package/dist/api/device/nfc.js +9 -0
- package/dist/api/device/phone.js +24 -0
- package/dist/api/device/scan.js +6 -0
- package/dist/api/device/screen.js +8 -0
- package/dist/api/device/vibrate.js +35 -0
- package/dist/api/device/wifi.js +12 -0
- package/dist/api/ext/index.js +4 -0
- package/dist/api/files/index.js +10 -0
- package/dist/api/framework/index.js +7 -0
- package/dist/api/index.js +24 -0
- package/dist/api/location/chooseLocation.js +93 -0
- package/dist/api/location/index.js +13 -0
- package/dist/api/location/style.css +79 -0
- package/dist/api/media/audio/index.js +88 -0
- package/dist/api/media/background-audio.js +11 -0
- package/dist/api/media/camera.js +3 -0
- package/dist/api/media/editor.js +18 -0
- package/dist/api/media/image/chooseImage.js +74 -0
- package/dist/api/media/image/getImageInfo.js +31 -0
- package/dist/api/media/image/index.js +9 -0
- package/dist/api/media/image/previewImage.js +67 -0
- package/dist/api/media/index.js +13 -0
- package/dist/api/media/live.js +4 -0
- package/dist/api/media/map.js +3 -0
- package/dist/api/media/media-recorder.js +3 -0
- package/dist/api/media/recorder.js +5 -0
- package/dist/api/media/video/index.js +74 -0
- package/dist/api/media/video-decoder.js +3 -0
- package/dist/api/media/video-processing.js +3 -0
- package/dist/api/media/voip.js +16 -0
- package/dist/api/navigate/index.js +6 -0
- package/dist/api/network/download.js +124 -0
- package/dist/api/network/index.js +7 -0
- package/dist/api/network/mdns.js +12 -0
- package/dist/api/network/request/index.js +125 -0
- package/dist/api/network/tcp.js +3 -0
- package/dist/api/network/udp.js +3 -0
- package/dist/api/network/upload.js +151 -0
- package/dist/api/network/utils.js +65 -0
- package/dist/api/network/websocket/index.js +70 -0
- package/dist/api/network/websocket/socketTask.js +63 -0
- package/dist/api/open-api/account.js +3 -0
- package/dist/api/open-api/address.js +3 -0
- package/dist/api/open-api/authorize.js +4 -0
- package/dist/api/open-api/card.js +4 -0
- package/dist/api/open-api/channels-live.js +8 -0
- package/dist/api/open-api/customer-service.js +3 -0
- package/dist/api/open-api/facial.js +6 -0
- package/dist/api/open-api/favorites.js +4 -0
- package/dist/api/open-api/group.js +3 -0
- package/dist/api/open-api/index.js +18 -0
- package/dist/api/open-api/invoice.js +4 -0
- package/dist/api/open-api/license-plate.js +3 -0
- package/dist/api/open-api/login.js +5 -0
- package/dist/api/open-api/red-package.js +3 -0
- package/dist/api/open-api/settings.js +4 -0
- package/dist/api/open-api/soter.js +5 -0
- package/dist/api/open-api/subscribe-message.js +3 -0
- package/dist/api/open-api/user-info.js +4 -0
- package/dist/api/open-api/werun.js +4 -0
- package/dist/api/payment/index.js +4 -0
- package/dist/api/route/index.js +3 -0
- package/dist/api/share/index.js +12 -0
- package/dist/api/storage/background-fetch.js +6 -0
- package/dist/api/storage/index.js +157 -0
- package/dist/api/swan/index.js +26 -0
- package/dist/api/taro.js +47 -0
- package/dist/api/ui/animation/index.js +284 -0
- package/dist/api/ui/background.js +4 -0
- package/dist/api/ui/custom-component.js +3 -0
- package/dist/api/ui/fonts.js +3 -0
- package/dist/api/ui/index.js +12 -0
- package/dist/api/ui/interaction/actionSheet.js +188 -0
- package/dist/api/ui/interaction/index.js +268 -0
- package/dist/api/ui/interaction/modal.js +207 -0
- package/dist/api/ui/interaction/toast.js +195 -0
- package/dist/api/ui/menu.js +3 -0
- package/dist/api/ui/navigation-bar/index.js +42 -0
- package/dist/api/ui/pull-down-refresh.js +26 -0
- package/dist/api/ui/scroll/index.js +83 -0
- package/dist/api/ui/sticky.js +3 -0
- package/dist/api/ui/tab-bar.js +282 -0
- package/dist/api/ui/window.js +31 -0
- package/dist/api/utils/handler.js +80 -0
- package/dist/api/utils/index.js +148 -0
- package/dist/api/worker/index.js +3 -0
- package/dist/api/wxml/index.js +6 -0
- package/dist/api/wxml/nodesRef.js +42 -0
- package/dist/api/wxml/selectorQuery.js +201 -0
- package/dist/index.cjs.js +7852 -11638
- package/dist/index.js +4 -0
- package/dist/taroApis.js +1 -1
- package/dist/types/type.js +2 -0
- package/package.json +14 -16
- package/src/api/ad/index.ts +5 -0
- package/src/api/ai/facial.ts +6 -0
- package/src/api/ai/index.ts +2 -0
- package/src/api/ai/visual.ts +4 -0
- package/src/api/alipay/index.ts +4 -0
- package/src/api/base/crypto.ts +4 -0
- package/src/api/base/debug.ts +5 -0
- package/src/api/base/index.ts +23 -0
- package/src/api/base/performance.ts +5 -0
- package/src/api/base/system/index.ts +2 -0
- package/src/api/base/system/info.ts +64 -0
- package/src/api/base/system/network.ts +70 -0
- package/src/api/base/update.ts +5 -0
- package/src/api/base/weapp/app-event.ts +19 -0
- package/src/api/base/weapp/life-cycle.ts +5 -0
- package/src/api/canvas/CanvasContext.ts +233 -0
- package/src/api/canvas/canvasGetImageData.ts +27 -0
- package/src/api/canvas/canvasPutImageData.ts +24 -0
- package/src/api/canvas/canvasToTempFilePath.ts +24 -0
- package/src/api/canvas/createCanvasContext.ts +18 -0
- package/src/api/canvas/index.ts +10 -0
- package/src/api/cloud/index.ts +27 -0
- package/src/api/data-analysis/index.ts +6 -0
- package/src/api/device/accelerometer.ts +87 -0
- package/src/api/device/accessibility.ts +4 -0
- package/src/api/device/battery.ts +5 -0
- package/src/api/device/bluetooth-ble.ts +19 -0
- package/src/api/device/bluetooth-peripheral.ts +6 -0
- package/src/api/device/bluetooth.ts +16 -0
- package/src/api/device/calendar.ts +5 -0
- package/src/api/device/clipboard.ts +67 -0
- package/src/api/device/compass.ts +67 -0
- package/src/api/device/contact.ts +5 -0
- package/src/api/device/crypto.ts +4 -0
- package/src/api/device/gyroscope.ts +7 -0
- package/src/api/device/iBeacon.ts +10 -0
- package/src/api/device/index.ts +22 -0
- package/src/api/device/keyboard.ts +7 -0
- package/src/api/device/memory.ts +5 -0
- package/src/api/device/motion.ts +85 -0
- package/src/api/device/nfc.ts +10 -0
- package/src/api/device/phone.ts +30 -0
- package/src/api/device/scan.ts +7 -0
- package/src/api/device/screen.ts +9 -0
- package/src/api/device/vibrate.ts +36 -0
- package/src/api/device/wifi.ts +13 -0
- package/src/api/ext/index.ts +5 -0
- package/src/api/files/index.ts +11 -0
- package/src/api/framework/index.ts +10 -0
- package/src/api/index.ts +25 -0
- package/src/api/location/chooseLocation.ts +106 -0
- package/src/api/location/index.ts +19 -0
- package/src/api/location/style.css +8 -8
- package/src/api/media/audio/index.ts +105 -0
- package/src/api/media/background-audio.ts +12 -0
- package/src/api/media/camera.ts +4 -0
- package/src/api/media/editor.ts +29 -0
- package/src/api/media/image/chooseImage.ts +78 -0
- package/src/api/media/image/getImageInfo.ts +35 -0
- package/src/api/media/image/index.ts +13 -0
- package/src/api/media/image/previewImage.ts +80 -0
- package/src/api/media/index.ts +13 -0
- package/src/api/media/live.ts +5 -0
- package/src/api/media/map.ts +4 -0
- package/src/api/media/media-recorder.ts +4 -0
- package/src/api/media/recorder.ts +6 -0
- package/src/api/media/video/index.ts +82 -0
- package/src/api/media/video-decoder.ts +4 -0
- package/src/api/media/video-processing.ts +4 -0
- package/src/api/media/voip.ts +17 -0
- package/src/api/navigate/index.ts +7 -0
- package/src/api/{fileTransfer/downloadFile.js → network/download.ts} +16 -27
- package/src/api/network/index.ts +7 -0
- package/src/api/network/mdns.ts +13 -0
- package/src/api/{request/index.js → network/request/index.ts} +9 -6
- package/src/api/network/tcp.ts +4 -0
- package/src/api/network/udp.ts +4 -0
- package/src/api/{fileTransfer/uploadFile.js → network/upload.ts} +28 -32
- package/src/api/{fileTransfer/utils.js → network/utils.ts} +0 -0
- package/src/api/network/websocket/index.ts +88 -0
- package/src/api/{webSocket/socketTask.js → network/websocket/socketTask.ts} +17 -7
- package/src/api/open-api/account.ts +4 -0
- package/src/api/open-api/address.ts +4 -0
- package/src/api/open-api/authorize.ts +5 -0
- package/src/api/open-api/card.ts +5 -0
- package/src/api/open-api/channels-live.ts +9 -0
- package/src/api/open-api/customer-service.ts +4 -0
- package/src/api/open-api/facial.ts +7 -0
- package/src/api/open-api/favorites.ts +5 -0
- package/src/api/open-api/group.ts +4 -0
- package/src/api/open-api/index.ts +18 -0
- package/src/api/open-api/invoice.ts +5 -0
- package/src/api/open-api/license-plate.ts +4 -0
- package/src/api/open-api/login.ts +6 -0
- package/src/api/open-api/red-package.ts +4 -0
- package/src/api/open-api/settings.ts +5 -0
- package/src/api/open-api/soter.ts +6 -0
- package/src/api/open-api/subscribe-message.ts +4 -0
- package/src/api/open-api/user-info.ts +5 -0
- package/src/api/open-api/werun.ts +5 -0
- package/src/api/payment/index.ts +5 -0
- package/src/api/route/index.ts +10 -0
- package/src/api/share/index.ts +13 -0
- package/src/api/storage/background-fetch.ts +7 -0
- package/src/api/storage/index.ts +181 -0
- package/src/api/swan/index.ts +31 -0
- package/src/{taro/index.js → api/taro.ts} +89 -104
- package/src/api/{createAnimation/index.js → ui/animation/index.ts} +52 -41
- package/src/api/ui/background.ts +5 -0
- package/src/api/ui/custom-component.ts +4 -0
- package/src/api/ui/fonts.ts +4 -0
- package/src/api/ui/index.ts +12 -0
- package/src/api/ui/interaction/actionSheet.ts +212 -0
- package/src/api/{interactive/index.js → ui/interaction/index.ts} +95 -77
- package/src/api/ui/interaction/modal.ts +237 -0
- package/src/api/{interactive/toast.js → ui/interaction/toast.ts} +35 -33
- package/src/api/ui/menu.ts +4 -0
- package/src/api/ui/navigation-bar/index.ts +52 -0
- package/src/api/ui/pull-down-refresh.ts +27 -0
- package/src/api/ui/scroll/index.ts +85 -0
- package/src/api/ui/sticky.ts +4 -0
- package/src/api/ui/tab-bar.ts +326 -0
- package/src/api/ui/window.ts +37 -0
- package/src/api/utils/handler.ts +105 -0
- package/src/api/utils/{index.js → index.ts} +36 -115
- package/src/api/worker/index.ts +4 -0
- package/src/api/wxml/index.ts +9 -0
- package/src/api/wxml/nodesRef.ts +56 -0
- package/src/api/wxml/selectorQuery.ts +219 -0
- package/src/index.ts +6 -0
- package/src/types/api.d.ts +4 -0
- package/src/types/define.d.ts +2 -0
- package/{types → src/types}/index.d.ts +0 -0
- package/{types → src/types}/type.ts +1 -1
- package/src/api/accelerometer/index.js +0 -105
- package/src/api/audio/index.js +0 -137
- package/src/api/canvas/canvasGetImageData.js +0 -44
- package/src/api/canvas/canvasPutImageData.js +0 -45
- package/src/api/canvas/canvasToTempFilePath.js +0 -49
- package/src/api/canvas/createCanvasContext.js +0 -340
- package/src/api/canvas/index.js +0 -4
- package/src/api/clipboard/index.js +0 -113
- package/src/api/compass/index.js +0 -99
- package/src/api/createSelectorQuery/index.js +0 -193
- package/src/api/deviceMotion/index.js +0 -105
- package/src/api/fileTransfer/index.js +0 -2
- package/src/api/image/chooseImage.js +0 -87
- package/src/api/image/getImageInfo.js +0 -74
- package/src/api/image/index.js +0 -7
- package/src/api/image/previewImage.js +0 -94
- package/src/api/index.js +0 -29
- package/src/api/interactive/actionSheet.js +0 -214
- package/src/api/interactive/modal.js +0 -256
- package/src/api/location/chooseLocation.js +0 -143
- package/src/api/location/index.js +0 -5
- package/src/api/navigationBar/index.js +0 -57
- package/src/api/open/index.js +0 -5
- package/src/api/others/index.js +0 -43
- package/src/api/pullDownRefresh/index.js +0 -51
- package/src/api/scroll/index.js +0 -99
- package/src/api/storage/index.js +0 -211
- package/src/api/system/index.js +0 -9
- package/src/api/system/info.js +0 -36
- package/src/api/system/network.js +0 -68
- package/src/api/tabBar/index.js +0 -402
- package/src/api/unsupportedApi/index.js +0 -278
- package/src/api/vibrate/index.js +0 -49
- package/src/api/video/index.js +0 -87
- package/src/api/webSocket/index.js +0 -103
- package/src/api/window/index.js +0 -38
- package/src/index.cjs.js +0 -11
- package/src/index.js +0 -6
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
2
|
+
import { temporarilyNotSupport } from '../../utils';
|
|
3
|
+
import { CallbackManager } from '../../utils/handler';
|
|
4
|
+
// 音频
|
|
5
|
+
class InnerAudioContext {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
8
|
+
this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
|
|
9
|
+
this.stop = () => {
|
|
10
|
+
this.pause();
|
|
11
|
+
this.seek(0);
|
|
12
|
+
this.stopStack.trigger();
|
|
13
|
+
};
|
|
14
|
+
this.seek = (position) => {
|
|
15
|
+
if (this.Instance) {
|
|
16
|
+
this.Instance.currentTime = position;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @TODO destroy得并不干净
|
|
21
|
+
*/
|
|
22
|
+
this.destroy = () => {
|
|
23
|
+
this.stop();
|
|
24
|
+
if (this.Instance) {
|
|
25
|
+
document.body.removeChild(this.Instance);
|
|
26
|
+
this.Instance = undefined;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
|
|
30
|
+
this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
|
|
31
|
+
this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
|
|
32
|
+
this.onStop = (callback = () => { }) => this.stopStack.add(callback);
|
|
33
|
+
this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
|
|
34
|
+
this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
|
|
35
|
+
this.onError = (callback) => this.errorStack.add(callback);
|
|
36
|
+
this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
|
|
37
|
+
this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
|
|
38
|
+
this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
|
|
39
|
+
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
|
|
40
|
+
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
|
|
41
|
+
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
|
|
42
|
+
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
43
|
+
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
|
|
44
|
+
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
|
|
45
|
+
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
46
|
+
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
|
|
47
|
+
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
|
|
48
|
+
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
|
|
49
|
+
this.Instance = new Audio();
|
|
50
|
+
this.errorStack = new CallbackManager();
|
|
51
|
+
this.stopStack = new CallbackManager();
|
|
52
|
+
Taro.eventCenter.on('__taroRouterChange', () => { this.stop(); });
|
|
53
|
+
}
|
|
54
|
+
set autoplay(e) { this.setProperty('autoplay', e); }
|
|
55
|
+
get autoplay() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.autoplay) || false; }
|
|
56
|
+
get buffered() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.buffered.length) || 0; }
|
|
57
|
+
get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
|
|
58
|
+
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
59
|
+
set loop(e) { this.setProperty('loop', e); }
|
|
60
|
+
get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
|
|
61
|
+
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || true; }
|
|
62
|
+
set src(e) { this.setProperty('src', e); }
|
|
63
|
+
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
64
|
+
set volume(e) { this.setProperty('volume', e); }
|
|
65
|
+
get volume() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
66
|
+
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
67
|
+
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
68
|
+
get obeyMuteSwitch() { return true; }
|
|
69
|
+
set startTime(e) { this.setProperty('startTime', e); }
|
|
70
|
+
get startTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
71
|
+
setProperty(key, value) {
|
|
72
|
+
if (this.Instance) {
|
|
73
|
+
this.Instance[key] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export const stopVoice = temporarilyNotSupport('stopVoice');
|
|
78
|
+
export const setInnerAudioOption = temporarilyNotSupport('setInnerAudioOption');
|
|
79
|
+
export const playVoice = temporarilyNotSupport('playVoice');
|
|
80
|
+
export const pauseVoice = temporarilyNotSupport('pauseVoice');
|
|
81
|
+
export const getAvailableAudioSources = temporarilyNotSupport('getAvailableAudioSources');
|
|
82
|
+
export const createWebAudioContext = temporarilyNotSupport('createWebAudioContext');
|
|
83
|
+
export const createMediaAudioPlayer = temporarilyNotSupport('createMediaAudioPlayer');
|
|
84
|
+
/**
|
|
85
|
+
* 创建内部 audio 上下文 InnerAudioContext 对象。
|
|
86
|
+
*/
|
|
87
|
+
export const createInnerAudioContext = () => new InnerAudioContext();
|
|
88
|
+
export const createAudioContext = temporarilyNotSupport('createAudioContext');
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 背景音频
|
|
3
|
+
export const stopBackgroundAudio = temporarilyNotSupport('stopBackgroundAudio');
|
|
4
|
+
export const seekBackgroundAudio = temporarilyNotSupport('seekBackgroundAudio');
|
|
5
|
+
export const playBackgroundAudio = temporarilyNotSupport('playBackgroundAudio');
|
|
6
|
+
export const pauseBackgroundAudio = temporarilyNotSupport('pauseBackgroundAudio');
|
|
7
|
+
export const onBackgroundAudioStop = temporarilyNotSupport('onBackgroundAudioStop');
|
|
8
|
+
export const onBackgroundAudioPlay = temporarilyNotSupport('onBackgroundAudioPlay');
|
|
9
|
+
export const onBackgroundAudioPause = temporarilyNotSupport('onBackgroundAudioPause');
|
|
10
|
+
export const getBackgroundAudioPlayerState = temporarilyNotSupport('getBackgroundAudioPlayerState');
|
|
11
|
+
export const getBackgroundAudioManager = temporarilyNotSupport('getBackgroundAudioManager');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 富文本
|
|
3
|
+
export class EditorContext {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.blur = temporarilyNotSupport('EditorContext.blur');
|
|
6
|
+
this.clear = temporarilyNotSupport('EditorContext.clear');
|
|
7
|
+
this.format = temporarilyNotSupport('EditorContext.format');
|
|
8
|
+
this.getContents = temporarilyNotSupport('EditorContext.getContents');
|
|
9
|
+
this.insertDivider = temporarilyNotSupport('EditorContext.insertDivider');
|
|
10
|
+
this.insertImage = temporarilyNotSupport('EditorContext.insertImage');
|
|
11
|
+
this.insertText = temporarilyNotSupport('EditorContext.insertText');
|
|
12
|
+
this.redo = temporarilyNotSupport('EditorContext.redo');
|
|
13
|
+
this.removeFormat = temporarilyNotSupport('EditorContext.removeFormat');
|
|
14
|
+
this.scrollIntoView = temporarilyNotSupport('EditorContext.scrollIntoView');
|
|
15
|
+
this.setContents = temporarilyNotSupport('EditorContext.setContents');
|
|
16
|
+
this.undo = temporarilyNotSupport('EditorContext.undo');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { MethodHandler } from '../../utils/handler';
|
|
2
|
+
import { shouldBeObject, getParameterError } from '../../utils';
|
|
3
|
+
/**
|
|
4
|
+
* 从本地相册选择图片或使用相机拍照。
|
|
5
|
+
*/
|
|
6
|
+
export const chooseImage = function (options) {
|
|
7
|
+
// options must be an Object
|
|
8
|
+
const isObject = shouldBeObject(options);
|
|
9
|
+
if (!isObject.flag) {
|
|
10
|
+
const res = { errMsg: `chooseImage:fail ${isObject.msg}` };
|
|
11
|
+
console.error(res.errMsg);
|
|
12
|
+
return Promise.reject(res);
|
|
13
|
+
}
|
|
14
|
+
const { count = 1, success, fail, complete, imageId = 'taroChooseImage' } = options;
|
|
15
|
+
const handle = new MethodHandler({ name: 'chooseImage', success, fail, complete });
|
|
16
|
+
const res = {
|
|
17
|
+
tempFilePaths: [],
|
|
18
|
+
tempFiles: []
|
|
19
|
+
};
|
|
20
|
+
if (count && typeof count !== 'number') {
|
|
21
|
+
res.errMsg = getParameterError({
|
|
22
|
+
para: 'count',
|
|
23
|
+
correct: 'Number',
|
|
24
|
+
wrong: count
|
|
25
|
+
});
|
|
26
|
+
return handle.fail(res);
|
|
27
|
+
}
|
|
28
|
+
let el = document.getElementById(imageId);
|
|
29
|
+
if (!el) {
|
|
30
|
+
const obj = document.createElement('input');
|
|
31
|
+
obj.setAttribute('type', 'file');
|
|
32
|
+
obj.setAttribute('id', imageId);
|
|
33
|
+
if (count > 1) {
|
|
34
|
+
obj.setAttribute('multiple', 'multiple');
|
|
35
|
+
}
|
|
36
|
+
obj.setAttribute('accept', 'image/*');
|
|
37
|
+
obj.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
|
|
38
|
+
document.body.appendChild(obj);
|
|
39
|
+
el = document.getElementById(imageId);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (count > 1) {
|
|
43
|
+
el.setAttribute('multiple', 'multiple');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
el.removeAttribute('multiple');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return new Promise(resolve => {
|
|
50
|
+
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
51
|
+
TaroMouseEvents.initEvent('click', true, true);
|
|
52
|
+
if (el) {
|
|
53
|
+
el.dispatchEvent(TaroMouseEvents);
|
|
54
|
+
el.onchange = function (e) {
|
|
55
|
+
const target = e.target;
|
|
56
|
+
if (target) {
|
|
57
|
+
const files = target.files || [];
|
|
58
|
+
const arr = [...files];
|
|
59
|
+
arr && arr.forEach(item => {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const blob = new Blob([item], {
|
|
62
|
+
type: item.type
|
|
63
|
+
});
|
|
64
|
+
const url = URL.createObjectURL(blob);
|
|
65
|
+
(_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
|
|
66
|
+
(_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
|
|
67
|
+
});
|
|
68
|
+
handle.success(res, resolve);
|
|
69
|
+
target.value = '';
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { shouldBeObject } from '../../utils';
|
|
2
|
+
import { MethodHandler } from '../../utils/handler';
|
|
3
|
+
/**
|
|
4
|
+
* 获取图片信息。网络图片需先配置download域名才能生效。
|
|
5
|
+
*/
|
|
6
|
+
export const getImageInfo = (options) => {
|
|
7
|
+
// options must be an Object
|
|
8
|
+
const isObject = shouldBeObject(options);
|
|
9
|
+
if (!isObject.flag) {
|
|
10
|
+
const res = { errMsg: `getImageInfo:fail ${isObject.msg}` };
|
|
11
|
+
console.error(res.errMsg);
|
|
12
|
+
return Promise.reject(res);
|
|
13
|
+
}
|
|
14
|
+
const { src, success, fail, complete } = options;
|
|
15
|
+
const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete });
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const image = new Image();
|
|
18
|
+
image.onload = () => {
|
|
19
|
+
handle.success({
|
|
20
|
+
width: image.naturalWidth,
|
|
21
|
+
height: image.naturalHeight
|
|
22
|
+
}, resolve);
|
|
23
|
+
};
|
|
24
|
+
image.onerror = (e) => {
|
|
25
|
+
handle.fail({
|
|
26
|
+
errMsg: e.message
|
|
27
|
+
}, reject);
|
|
28
|
+
};
|
|
29
|
+
image.src = src;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../../utils';
|
|
2
|
+
// 图片
|
|
3
|
+
export const saveImageToPhotosAlbum = temporarilyNotSupport('saveImageToPhotosAlbum');
|
|
4
|
+
export const previewMedia = temporarilyNotSupport('previewMedia');
|
|
5
|
+
export * from './previewImage';
|
|
6
|
+
export * from './getImageInfo';
|
|
7
|
+
export const compressImage = temporarilyNotSupport('compressImage');
|
|
8
|
+
export const chooseMessageFile = temporarilyNotSupport('chooseMessageFile');
|
|
9
|
+
export * from './chooseImage';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { shouldBeObject } from '../../utils';
|
|
2
|
+
import { MethodHandler } from '../../utils/handler';
|
|
3
|
+
/**
|
|
4
|
+
* previewImage api基于开源的React组件[react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer)开发,感谢!
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
|
|
8
|
+
*/
|
|
9
|
+
export const previewImage = async (options) => {
|
|
10
|
+
function loadImage(url, loadFail) {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const item = document.createElement('taro-swiper-item-core');
|
|
13
|
+
item.style.cssText = 'display:flex;align-items:start;justify-content:center;overflow-y:scroll;';
|
|
14
|
+
const image = new Image();
|
|
15
|
+
image.style.maxWidth = '100%';
|
|
16
|
+
image.src = url;
|
|
17
|
+
const div = document.createElement('div');
|
|
18
|
+
div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;';
|
|
19
|
+
div.appendChild(image);
|
|
20
|
+
item.appendChild(div);
|
|
21
|
+
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
22
|
+
resolve(item);
|
|
23
|
+
if (typeof loadFail === 'function') {
|
|
24
|
+
image.addEventListener('error', (err) => {
|
|
25
|
+
loadFail({ errMsg: err.message });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// options must be an Object
|
|
31
|
+
const isObject = shouldBeObject(options);
|
|
32
|
+
if (!isObject.flag) {
|
|
33
|
+
const res = { errMsg: `previewImage:fail ${isObject.msg}` };
|
|
34
|
+
console.error(res.errMsg);
|
|
35
|
+
return Promise.reject(res);
|
|
36
|
+
}
|
|
37
|
+
const { urls = [], current = '', success, fail, complete } = options;
|
|
38
|
+
const handle = new MethodHandler({ name: 'previewImage', success, fail, complete });
|
|
39
|
+
const container = document.createElement('div');
|
|
40
|
+
container.classList.add('preview-image');
|
|
41
|
+
container.style.cssText = 'position:fixed;top:0;left:0;z-index:1050;width:100%;height:100%;overflow:hidden;outline:0;background-color:#111;';
|
|
42
|
+
container.addEventListener('click', () => {
|
|
43
|
+
container.remove();
|
|
44
|
+
});
|
|
45
|
+
const swiper = document.createElement('taro-swiper-core');
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
swiper.full = true;
|
|
48
|
+
let children = [];
|
|
49
|
+
try {
|
|
50
|
+
children = await Promise.all(urls.map(e => loadImage(e, fail)));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return handle.fail({
|
|
54
|
+
errMsg: error
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
for (let i = 0; i < children.length; i++) {
|
|
58
|
+
const child = children[i];
|
|
59
|
+
swiper.appendChild(child);
|
|
60
|
+
}
|
|
61
|
+
const currentIndex = urls.indexOf(current);
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
swiper.current = currentIndex;
|
|
64
|
+
container.appendChild(swiper);
|
|
65
|
+
document.body.appendChild(container);
|
|
66
|
+
return handle.success();
|
|
67
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './audio';
|
|
2
|
+
export * from './background-audio';
|
|
3
|
+
export * from './camera';
|
|
4
|
+
export * from './editor';
|
|
5
|
+
export * from './image';
|
|
6
|
+
export * from './live';
|
|
7
|
+
export * from './map';
|
|
8
|
+
export * from './media-recorder';
|
|
9
|
+
export * from './recorder';
|
|
10
|
+
export * from './video';
|
|
11
|
+
export * from './video-decoder';
|
|
12
|
+
export * from './video-processing';
|
|
13
|
+
export * from './voip';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { MethodHandler } from '../../utils/handler';
|
|
2
|
+
import { findDOM, shouldBeObject, temporarilyNotSupport } from '../../utils';
|
|
3
|
+
// 视频
|
|
4
|
+
export const saveVideoToPhotosAlbum = temporarilyNotSupport('saveVideoToPhotosAlbum');
|
|
5
|
+
export const openVideoEditor = temporarilyNotSupport('openVideoEditor');
|
|
6
|
+
export const getVideoInfo = temporarilyNotSupport('getVideoInfo');
|
|
7
|
+
/**
|
|
8
|
+
* 创建 video 上下文 VideoContext 对象。
|
|
9
|
+
*/
|
|
10
|
+
export const createVideoContext = (id, inst) => {
|
|
11
|
+
const el = findDOM(inst);
|
|
12
|
+
// TODO HTMLVideoElement to VideoContext
|
|
13
|
+
return el === null || el === void 0 ? void 0 : el.querySelector(`taro-video-core[id=${id}]`);
|
|
14
|
+
};
|
|
15
|
+
export const compressVideo = temporarilyNotSupport('compressVideo');
|
|
16
|
+
/**
|
|
17
|
+
* 拍摄视频或从手机相册中选视频。
|
|
18
|
+
*/
|
|
19
|
+
export const chooseVideo = (options) => {
|
|
20
|
+
// options must be an Object
|
|
21
|
+
const isObject = shouldBeObject(options);
|
|
22
|
+
if (!isObject.flag) {
|
|
23
|
+
const res = { errMsg: `chooseVideo:fail ${isObject.msg}` };
|
|
24
|
+
console.error(res.errMsg);
|
|
25
|
+
return Promise.reject(res);
|
|
26
|
+
}
|
|
27
|
+
const { success, fail, complete } = options;
|
|
28
|
+
const handle = new MethodHandler({ name: 'chooseVideo', success, fail, complete });
|
|
29
|
+
const res = {
|
|
30
|
+
tempFilePath: '',
|
|
31
|
+
duration: 0,
|
|
32
|
+
size: 0,
|
|
33
|
+
height: 0,
|
|
34
|
+
width: 0
|
|
35
|
+
};
|
|
36
|
+
const inputEl = document.createElement('input');
|
|
37
|
+
inputEl.setAttribute('type', 'file');
|
|
38
|
+
inputEl.setAttribute('multiple', 'multiple');
|
|
39
|
+
inputEl.setAttribute('accept', 'video/*');
|
|
40
|
+
inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
|
|
41
|
+
document.body.appendChild(inputEl);
|
|
42
|
+
return new Promise(resolve => {
|
|
43
|
+
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
44
|
+
TaroMouseEvents.initEvent('click', true, true);
|
|
45
|
+
inputEl.dispatchEvent(TaroMouseEvents);
|
|
46
|
+
inputEl.onchange = function (e) {
|
|
47
|
+
var _a;
|
|
48
|
+
const target = e.target;
|
|
49
|
+
const file = (_a = target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
50
|
+
const reader = new FileReader();
|
|
51
|
+
reader.onload = function (event) {
|
|
52
|
+
var _a;
|
|
53
|
+
const videoEl = document.createElement('video');
|
|
54
|
+
const url = (_a = event.target) === null || _a === void 0 ? void 0 : _a.result;
|
|
55
|
+
videoEl.preload = 'metadata';
|
|
56
|
+
videoEl.src = url;
|
|
57
|
+
videoEl.onloadedmetadata = () => {
|
|
58
|
+
res.tempFilePath = url;
|
|
59
|
+
res.duration = videoEl.duration;
|
|
60
|
+
res.size = event.total;
|
|
61
|
+
res.height = videoEl.videoHeight;
|
|
62
|
+
res.width = videoEl.videoHeight;
|
|
63
|
+
return handle.success(res, resolve);
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
if (file) {
|
|
67
|
+
reader.readAsDataURL(file);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}).finally(() => {
|
|
71
|
+
document.body.removeChild(inputEl);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export const chooseMedia = temporarilyNotSupport('chooseMedia');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 实时语音
|
|
3
|
+
export const updateVoIPChatMuteConfig = temporarilyNotSupport('updateVoIPChatMuteConfig');
|
|
4
|
+
export const subscribeVoIPVideoMembers = temporarilyNotSupport('subscribeVoIPVideoMembers');
|
|
5
|
+
export const setEnable1v1Chat = temporarilyNotSupport('setEnable1v1Chat');
|
|
6
|
+
export const onVoIPVideoMembersChanged = temporarilyNotSupport('onVoIPVideoMembersChanged');
|
|
7
|
+
export const onVoIPChatStateChanged = temporarilyNotSupport('onVoIPChatStateChanged');
|
|
8
|
+
export const onVoIPChatSpeakersChanged = temporarilyNotSupport('onVoIPChatSpeakersChanged');
|
|
9
|
+
export const onVoIPChatMembersChanged = temporarilyNotSupport('onVoIPChatMembersChanged');
|
|
10
|
+
export const onVoIPChatInterrupted = temporarilyNotSupport('onVoIPChatInterrupted');
|
|
11
|
+
export const offVoIPVideoMembersChanged = temporarilyNotSupport('offVoIPVideoMembersChanged');
|
|
12
|
+
export const offVoIPChatStateChanged = temporarilyNotSupport('offVoIPChatStateChanged');
|
|
13
|
+
export const offVoIPChatMembersChanged = temporarilyNotSupport('offVoIPChatMembersChanged');
|
|
14
|
+
export const offVoIPChatInterrupted = temporarilyNotSupport('offVoIPChatInterrupted');
|
|
15
|
+
export const joinVoIPChat = temporarilyNotSupport('joinVoIPChat');
|
|
16
|
+
export const exitVoIPChat = temporarilyNotSupport('exitVoIPChat');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 跳转
|
|
3
|
+
export const openEmbeddedMiniProgram = temporarilyNotSupport('openEmbeddedMiniProgram');
|
|
4
|
+
export const navigateToMiniProgram = temporarilyNotSupport('navigateToMiniProgram');
|
|
5
|
+
export const navigateBackMiniProgram = temporarilyNotSupport('navigateBackMiniProgram');
|
|
6
|
+
export const exitMiniProgram = temporarilyNotSupport('exitMiniProgram');
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { CallbackManager } from '../utils/handler';
|
|
2
|
+
import { NETWORK_TIMEOUT, setHeader, XHR_STATS } from './utils';
|
|
3
|
+
const createDownloadTask = ({ url, header, success, error }) => {
|
|
4
|
+
let timeout;
|
|
5
|
+
const apiName = 'downloadFile';
|
|
6
|
+
const xhr = new XMLHttpRequest();
|
|
7
|
+
const callbackManager = {
|
|
8
|
+
headersReceived: new CallbackManager(),
|
|
9
|
+
progressUpdate: new CallbackManager()
|
|
10
|
+
};
|
|
11
|
+
xhr.open('GET', url, true);
|
|
12
|
+
xhr.responseType = 'blob';
|
|
13
|
+
setHeader(xhr, header);
|
|
14
|
+
xhr.onprogress = e => {
|
|
15
|
+
const { loaded, total } = e;
|
|
16
|
+
callbackManager.progressUpdate.trigger({
|
|
17
|
+
progress: Math.round(loaded / total * 100),
|
|
18
|
+
totalBytesWritten: loaded,
|
|
19
|
+
totalBytesExpectedToWrite: total
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
xhr.onreadystatechange = () => {
|
|
23
|
+
if (xhr.readyState !== XHR_STATS.HEADERS_RECEIVED)
|
|
24
|
+
return;
|
|
25
|
+
callbackManager.headersReceived.trigger({
|
|
26
|
+
header: xhr.getAllResponseHeaders()
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
xhr.onload = () => {
|
|
30
|
+
const response = xhr.response;
|
|
31
|
+
const status = xhr.status;
|
|
32
|
+
success({
|
|
33
|
+
errMsg: `${apiName}:ok`,
|
|
34
|
+
statusCode: status,
|
|
35
|
+
tempFilePath: window.URL.createObjectURL(response)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
xhr.onabort = () => {
|
|
39
|
+
clearTimeout(timeout);
|
|
40
|
+
error({
|
|
41
|
+
errMsg: `${apiName}:fail abort`
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
xhr.onerror = (e) => {
|
|
45
|
+
error({
|
|
46
|
+
errMsg: `${apiName}:fail ${e.message}`
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 中断任务
|
|
51
|
+
*/
|
|
52
|
+
const abort = () => {
|
|
53
|
+
xhr.abort();
|
|
54
|
+
};
|
|
55
|
+
const send = () => {
|
|
56
|
+
xhr.send();
|
|
57
|
+
timeout = setTimeout(() => {
|
|
58
|
+
xhr.onabort = null;
|
|
59
|
+
xhr.onload = null;
|
|
60
|
+
xhr.onprogress = null;
|
|
61
|
+
xhr.onreadystatechange = null;
|
|
62
|
+
xhr.onerror = null;
|
|
63
|
+
abort();
|
|
64
|
+
error({
|
|
65
|
+
errMsg: `${apiName}:fail timeout`
|
|
66
|
+
});
|
|
67
|
+
}, NETWORK_TIMEOUT);
|
|
68
|
+
};
|
|
69
|
+
send();
|
|
70
|
+
/**
|
|
71
|
+
* 监听 HTTP Response Header 事件。会比请求完成事件更早
|
|
72
|
+
* @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
|
|
73
|
+
*/
|
|
74
|
+
const onHeadersReceived = callbackManager.headersReceived.add;
|
|
75
|
+
/**
|
|
76
|
+
* 取消监听 HTTP Response Header 事件
|
|
77
|
+
* @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
|
|
78
|
+
*/
|
|
79
|
+
const offHeadersReceived = callbackManager.headersReceived.remove;
|
|
80
|
+
/**
|
|
81
|
+
* 监听进度变化事件
|
|
82
|
+
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
83
|
+
*/
|
|
84
|
+
const onProgressUpdate = callbackManager.progressUpdate.add;
|
|
85
|
+
/**
|
|
86
|
+
* 取消监听进度变化事件
|
|
87
|
+
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
88
|
+
*/
|
|
89
|
+
const offProgressUpdate = callbackManager.progressUpdate.remove;
|
|
90
|
+
return {
|
|
91
|
+
abort,
|
|
92
|
+
onHeadersReceived,
|
|
93
|
+
offHeadersReceived,
|
|
94
|
+
onProgressUpdate,
|
|
95
|
+
offProgressUpdate
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。使用前请注意阅读相关说明。
|
|
100
|
+
* 注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
|
|
101
|
+
*/
|
|
102
|
+
export const downloadFile = ({ url, header, success, fail, complete }) => {
|
|
103
|
+
let task;
|
|
104
|
+
const result = new Promise((resolve, reject) => {
|
|
105
|
+
task = createDownloadTask({
|
|
106
|
+
url,
|
|
107
|
+
header,
|
|
108
|
+
success: res => {
|
|
109
|
+
success && success(res);
|
|
110
|
+
complete && complete(res);
|
|
111
|
+
resolve(res);
|
|
112
|
+
},
|
|
113
|
+
error: res => {
|
|
114
|
+
fail && fail(res);
|
|
115
|
+
complete && complete(res);
|
|
116
|
+
reject(res);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
result.headersReceive = task.onHeadersReceived;
|
|
121
|
+
result.progress = task.onProgressUpdate;
|
|
122
|
+
result.abort = task.abort;
|
|
123
|
+
return result;
|
|
124
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// mDNS
|
|
3
|
+
export const stopLocalServiceDiscovery = temporarilyNotSupport('stopLocalServiceDiscovery');
|
|
4
|
+
export const startLocalServiceDiscovery = temporarilyNotSupport('startLocalServiceDiscovery');
|
|
5
|
+
export const onLocalServiceResolveFail = temporarilyNotSupport('onLocalServiceResolveFail');
|
|
6
|
+
export const onLocalServiceLost = temporarilyNotSupport('onLocalServiceLost');
|
|
7
|
+
export const onLocalServiceFound = temporarilyNotSupport('onLocalServiceFound');
|
|
8
|
+
export const onLocalServiceDiscoveryStop = temporarilyNotSupport('onLocalServiceDiscoveryStop');
|
|
9
|
+
export const offLocalServiceResolveFail = temporarilyNotSupport('offLocalServiceResolveFail');
|
|
10
|
+
export const offLocalServiceLost = temporarilyNotSupport('offLocalServiceLost');
|
|
11
|
+
export const offLocalServiceFound = temporarilyNotSupport('offLocalServiceFound');
|
|
12
|
+
export const offLocalServiceDiscoveryStop = temporarilyNotSupport('offLocalServiceDiscoveryStop');
|