@tarojs/taro-h5 3.5.0-alpha.13 → 3.5.0-alpha.16
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.d.ts +6 -0
- package/dist/api/ai/facial.d.ts +9 -0
- package/dist/api/ai/index.d.ts +2 -0
- package/dist/api/ai/visual.d.ts +6 -0
- package/dist/api/alipay/index.d.ts +3 -0
- package/dist/api/base/crypto.d.ts +3 -0
- package/dist/api/base/debug.d.ts +9 -0
- package/dist/api/base/index.d.ts +12 -0
- package/dist/api/base/performance.d.ts +6 -0
- package/dist/api/base/system.d.ts +27 -0
- package/dist/api/base/system.js +2 -2
- package/dist/api/base/update.d.ts +6 -0
- package/dist/api/base/weapp/app-event.d.ts +41 -0
- package/dist/api/base/weapp/app-event.js +55 -4
- package/dist/api/base/weapp/life-cycle.d.ts +6 -0
- package/dist/api/canvas/CanvasContext.d.ts +104 -0
- package/dist/api/canvas/canvasGetImageData.d.ts +5 -0
- package/dist/api/canvas/canvasPutImageData.d.ts +6 -0
- package/dist/api/canvas/canvasToTempFilePath.d.ts +6 -0
- package/dist/api/canvas/canvasToTempFilePath.js +1 -1
- package/dist/api/canvas/createCanvasContext.d.ts +5 -0
- package/dist/api/canvas/index.d.ts +12 -0
- package/dist/api/cloud/index.d.ts +31 -0
- package/dist/api/data-analysis/index.d.ts +12 -0
- package/dist/api/device/accelerometer.d.ts +17 -0
- package/dist/api/device/accessibility.d.ts +3 -0
- package/dist/api/device/battery.d.ts +5 -0
- package/dist/api/device/bluetooth-ble.d.ts +48 -0
- package/dist/api/device/bluetooth-peripheral.d.ts +9 -0
- package/dist/api/device/bluetooth.d.ts +39 -0
- package/dist/api/device/calendar.d.ts +6 -0
- package/dist/api/device/clipboard.d.ts +15 -0
- package/dist/api/device/compass.d.ts +17 -0
- package/dist/api/device/contact.d.ts +6 -0
- package/dist/api/device/crypto.d.ts +3 -0
- package/dist/api/device/gyroscope.d.ts +12 -0
- package/dist/api/device/iBeacon.d.ts +21 -0
- package/dist/api/device/index.d.ts +23 -0
- package/dist/api/device/keyboard.d.ts +12 -0
- package/dist/api/device/memory.d.ts +6 -0
- package/dist/api/device/motion.d.ts +17 -0
- package/dist/api/device/network.d.ts +20 -0
- package/dist/api/device/nfc.d.ts +21 -0
- package/dist/api/device/phone.d.ts +2 -0
- package/dist/api/device/scan.d.ts +3 -0
- package/dist/api/device/screen.d.ts +18 -0
- package/dist/api/device/vibrate.d.ts +9 -0
- package/dist/api/device/vibrate.js +5 -7
- package/dist/api/device/wifi.d.ts +33 -0
- package/dist/api/ext/index.d.ts +6 -0
- package/dist/api/files/index.d.ts +24 -0
- package/dist/api/framework/index.d.ts +4 -0
- package/dist/api/index.d.ts +24 -0
- package/dist/api/location/chooseLocation.d.ts +6 -0
- package/dist/api/location/getLocation.d.ts +2 -0
- package/dist/api/location/index.d.ts +32 -0
- package/dist/api/location/index.js +1 -0
- package/dist/api/media/EditorContext.d.ts +42 -0
- package/dist/api/media/audio/InnerAudioContext.d.ts +58 -0
- package/dist/api/media/audio/InnerAudioContext.js +1 -1
- package/dist/api/media/audio/index.d.ts +29 -0
- package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +71 -0
- package/dist/api/media/background-audio/index.d.ts +29 -0
- package/dist/api/media/camera.d.ts +3 -0
- package/dist/api/media/image/chooseImage.d.ts +5 -0
- package/dist/api/media/image/getImageInfo.d.ts +5 -0
- package/dist/api/media/image/index.d.ts +15 -0
- package/dist/api/media/image/previewImage.d.ts +8 -0
- package/dist/api/media/index.d.ts +12 -0
- package/dist/api/media/live.d.ts +6 -0
- package/dist/api/media/map.d.ts +3 -0
- package/dist/api/media/media-recorder.d.ts +3 -0
- package/dist/api/media/recorder.d.ts +9 -0
- package/dist/api/media/video/index.d.ts +24 -0
- package/dist/api/media/video-decoder.d.ts +3 -0
- package/dist/api/media/video-processing.d.ts +3 -0
- package/dist/api/media/voip.d.ts +42 -0
- package/dist/api/navigate/index.d.ts +12 -0
- package/dist/api/network/download.d.ts +6 -0
- package/dist/api/network/download.js +1 -0
- package/dist/api/network/index.d.ts +7 -0
- package/dist/api/network/mdns.d.ts +30 -0
- package/dist/api/network/request/index.d.ts +4 -0
- package/dist/api/network/tcp.d.ts +3 -0
- package/dist/api/network/udp.d.ts +3 -0
- package/dist/api/network/upload.d.ts +5 -0
- package/dist/api/network/upload.js +2 -1
- package/{src/api/network/utils.ts → dist/api/network/utils.d.ts} +44 -71
- package/dist/api/network/utils.js +1 -0
- package/dist/api/network/websocket/index.d.ts +7 -0
- package/dist/api/network/websocket/socketTask.d.ts +25 -0
- package/dist/api/open-api/account.d.ts +3 -0
- package/dist/api/open-api/address.d.ts +3 -0
- package/dist/api/open-api/authorize.d.ts +6 -0
- package/dist/api/open-api/card.d.ts +6 -0
- package/dist/api/open-api/channels-live.d.ts +18 -0
- package/dist/api/open-api/customer-service.d.ts +3 -0
- package/dist/api/open-api/facial.d.ts +12 -0
- package/dist/api/open-api/favorites.d.ts +6 -0
- package/dist/api/open-api/group.d.ts +3 -0
- package/dist/api/open-api/index.d.ts +18 -0
- package/dist/api/open-api/invoice.d.ts +6 -0
- package/dist/api/open-api/license-plate.d.ts +3 -0
- package/dist/api/open-api/login.d.ts +9 -0
- package/dist/api/open-api/red-package.d.ts +3 -0
- package/dist/api/open-api/settings.d.ts +6 -0
- package/dist/api/open-api/soter.d.ts +9 -0
- package/dist/api/open-api/subscribe-message.d.ts +3 -0
- package/dist/api/open-api/user-info.d.ts +6 -0
- package/dist/api/open-api/werun.d.ts +6 -0
- package/dist/api/payment/index.d.ts +6 -0
- package/dist/api/route/index.d.ts +1 -0
- package/dist/api/share/index.d.ts +30 -0
- package/dist/api/storage/background-fetch.d.ts +12 -0
- package/dist/api/storage/index.d.ts +18 -0
- package/dist/api/swan/index.d.ts +63 -0
- package/dist/api/taro.d.ts +12 -0
- package/dist/api/ui/animation/index.d.ts +2 -0
- package/dist/api/ui/background.d.ts +6 -0
- package/dist/api/ui/custom-component.d.ts +1 -0
- package/dist/api/ui/fonts.d.ts +2 -0
- package/dist/api/ui/index.d.ts +12 -0
- package/dist/api/ui/interaction/actionSheet.d.ts +61 -0
- package/dist/api/ui/interaction/index.d.ts +14 -0
- package/dist/api/ui/interaction/modal.d.ts +69 -0
- package/dist/api/ui/interaction/modal.js +1 -0
- package/dist/api/ui/interaction/toast.d.ts +85 -0
- package/dist/api/ui/menu.d.ts +3 -0
- package/dist/api/ui/navigation-bar/index.d.ts +15 -0
- package/dist/api/ui/navigation-bar/index.js +2 -3
- package/dist/api/ui/pull-down-refresh.d.ts +9 -0
- package/dist/api/ui/scroll/index.d.ts +5 -0
- package/dist/api/ui/sticky.d.ts +3 -0
- package/dist/api/ui/tab-bar.d.ts +34 -0
- package/dist/api/ui/window.d.ts +15 -0
- package/dist/api/worker/index.d.ts +3 -0
- package/dist/api/wxml/index.d.ts +5 -0
- package/dist/api/wxml/nodesRef.d.ts +13 -0
- package/dist/api/wxml/selectorQuery.d.ts +24 -0
- package/dist/api/wxml/selectorQuery.js +1 -1
- package/dist/index.cjs.d.ts +1373 -0
- package/dist/index.cjs.js +105 -81
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.d.ts +1373 -0
- package/dist/index.esm.js +93 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/taroApis.d.ts +1364 -0
- package/dist/taroApis.js +1 -1
- package/dist/utils/animation.d.ts +6 -0
- package/dist/utils/handler.d.ts +48 -0
- package/dist/utils/index.d.ts +39 -0
- package/dist/utils/index.js +3 -7
- package/dist/utils/lodash.d.ts +2 -0
- package/dist/utils/valid.d.ts +2 -0
- package/package.json +17 -19
- package/types/api.d.ts +4 -0
- package/types/define.d.ts +2 -0
- package/types/index.d.ts +33 -0
- package/types/overlay.d.ts +9 -0
- package/LICENSE +0 -21
- package/src/api/ad/index.ts +0 -5
- package/src/api/ai/facial.ts +0 -6
- package/src/api/ai/index.ts +0 -2
- package/src/api/ai/visual.ts +0 -7
- package/src/api/alipay/index.ts +0 -4
- package/src/api/base/crypto.ts +0 -4
- package/src/api/base/debug.ts +0 -5
- package/src/api/base/index.ts +0 -23
- package/src/api/base/performance.ts +0 -5
- package/src/api/base/system.ts +0 -207
- package/src/api/base/update.ts +0 -5
- package/src/api/base/weapp/app-event.ts +0 -19
- package/src/api/base/weapp/life-cycle.ts +0 -5
- package/src/api/canvas/CanvasContext.ts +0 -233
- package/src/api/canvas/canvasGetImageData.ts +0 -28
- package/src/api/canvas/canvasPutImageData.ts +0 -25
- package/src/api/canvas/canvasToTempFilePath.ts +0 -25
- package/src/api/canvas/createCanvasContext.ts +0 -19
- package/src/api/canvas/index.ts +0 -18
- package/src/api/cloud/index.ts +0 -32
- package/src/api/data-analysis/index.ts +0 -6
- package/src/api/device/accelerometer.ts +0 -79
- package/src/api/device/accessibility.ts +0 -4
- package/src/api/device/battery.ts +0 -23
- package/src/api/device/bluetooth-ble.ts +0 -19
- package/src/api/device/bluetooth-peripheral.ts +0 -6
- package/src/api/device/bluetooth.ts +0 -16
- package/src/api/device/calendar.ts +0 -5
- package/src/api/device/clipboard.ts +0 -68
- package/src/api/device/compass.ts +0 -83
- package/src/api/device/contact.ts +0 -5
- package/src/api/device/crypto.ts +0 -4
- package/src/api/device/gyroscope.ts +0 -7
- package/src/api/device/iBeacon.ts +0 -10
- package/src/api/device/index.ts +0 -23
- package/src/api/device/keyboard.ts +0 -7
- package/src/api/device/memory.ts +0 -5
- package/src/api/device/motion.ts +0 -77
- package/src/api/device/network.ts +0 -90
- package/src/api/device/nfc.ts +0 -10
- package/src/api/device/phone.ts +0 -31
- package/src/api/device/scan.ts +0 -11
- package/src/api/device/screen.ts +0 -9
- package/src/api/device/vibrate.ts +0 -37
- package/src/api/device/wifi.ts +0 -14
- package/src/api/ext/index.ts +0 -5
- package/src/api/files/index.ts +0 -11
- package/src/api/framework/index.ts +0 -10
- package/src/api/index.ts +0 -24
- package/src/api/location/chooseLocation.ts +0 -117
- package/src/api/location/getLocation.ts +0 -81
- package/src/api/location/index.ts +0 -22
- package/src/api/location/style.css +0 -79
- package/src/api/media/EditorContext.ts +0 -32
- package/src/api/media/audio/InnerAudioContext.ts +0 -99
- package/src/api/media/audio/index.ts +0 -21
- package/src/api/media/background-audio/BackgroundAudioManager.ts +0 -104
- package/src/api/media/background-audio/index.ts +0 -17
- package/src/api/media/camera.ts +0 -4
- package/src/api/media/image/chooseImage.ts +0 -95
- package/src/api/media/image/getImageInfo.ts +0 -50
- package/src/api/media/image/index.ts +0 -13
- package/src/api/media/image/previewImage.ts +0 -80
- package/src/api/media/index.ts +0 -12
- package/src/api/media/live.ts +0 -5
- package/src/api/media/map.ts +0 -4
- package/src/api/media/media-recorder.ts +0 -4
- package/src/api/media/recorder.ts +0 -6
- package/src/api/media/video/index.ts +0 -82
- package/src/api/media/video-decoder.ts +0 -4
- package/src/api/media/video-processing.ts +0 -4
- package/src/api/media/voip.ts +0 -17
- package/src/api/navigate/index.ts +0 -7
- package/src/api/network/download.ts +0 -141
- package/src/api/network/index.ts +0 -7
- package/src/api/network/mdns.ts +0 -13
- package/src/api/network/request/index.ts +0 -135
- package/src/api/network/tcp.ts +0 -4
- package/src/api/network/udp.ts +0 -4
- package/src/api/network/upload.ts +0 -169
- package/src/api/network/websocket/index.ts +0 -88
- package/src/api/network/websocket/socketTask.ts +0 -89
- package/src/api/open-api/account.ts +0 -4
- package/src/api/open-api/address.ts +0 -4
- package/src/api/open-api/authorize.ts +0 -5
- package/src/api/open-api/card.ts +0 -5
- package/src/api/open-api/channels-live.ts +0 -9
- package/src/api/open-api/customer-service.ts +0 -4
- package/src/api/open-api/facial.ts +0 -7
- package/src/api/open-api/favorites.ts +0 -5
- package/src/api/open-api/group.ts +0 -4
- package/src/api/open-api/index.ts +0 -18
- package/src/api/open-api/invoice.ts +0 -5
- package/src/api/open-api/license-plate.ts +0 -4
- package/src/api/open-api/login.ts +0 -6
- package/src/api/open-api/red-package.ts +0 -4
- package/src/api/open-api/settings.ts +0 -5
- package/src/api/open-api/soter.ts +0 -6
- package/src/api/open-api/subscribe-message.ts +0 -4
- package/src/api/open-api/user-info.ts +0 -5
- package/src/api/open-api/werun.ts +0 -5
- package/src/api/payment/index.ts +0 -5
- package/src/api/route/index.ts +0 -10
- package/src/api/share/index.ts +0 -13
- package/src/api/storage/background-fetch.ts +0 -7
- package/src/api/storage/index.ts +0 -182
- package/src/api/swan/index.ts +0 -31
- package/src/api/taro.ts +0 -84
- package/src/api/ui/animation/index.ts +0 -356
- package/src/api/ui/background.ts +0 -5
- package/src/api/ui/custom-component.ts +0 -4
- package/src/api/ui/fonts.ts +0 -64
- package/src/api/ui/index.ts +0 -12
- package/src/api/ui/interaction/actionSheet.ts +0 -212
- package/src/api/ui/interaction/index.ts +0 -302
- package/src/api/ui/interaction/modal.ts +0 -237
- package/src/api/ui/interaction/toast.ts +0 -220
- package/src/api/ui/menu.ts +0 -4
- package/src/api/ui/navigation-bar/index.ts +0 -52
- package/src/api/ui/pull-down-refresh.ts +0 -28
- package/src/api/ui/scroll/index.ts +0 -85
- package/src/api/ui/sticky.ts +0 -4
- package/src/api/ui/tab-bar.ts +0 -327
- package/src/api/ui/window.ts +0 -38
- package/src/api/worker/index.ts +0 -4
- package/src/api/wxml/index.ts +0 -10
- package/src/api/wxml/nodesRef.ts +0 -56
- package/src/api/wxml/selectorQuery.ts +0 -220
- package/src/index.ts +0 -6
- package/src/utils/animation.ts +0 -15
- package/src/utils/handler.ts +0 -105
- package/src/utils/index.ts +0 -184
- package/src/utils/lodash.ts +0 -30
- package/src/utils/valid.ts +0 -8
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { CallbackManager } from '../../utils/handler'
|
|
4
|
-
import {
|
|
5
|
-
convertObjectUrlToBlob,
|
|
6
|
-
NETWORK_TIMEOUT,
|
|
7
|
-
setHeader,
|
|
8
|
-
XHR_STATS
|
|
9
|
-
} from './utils'
|
|
10
|
-
|
|
11
|
-
const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout, fileName, success, error }): Taro.UploadTask => {
|
|
12
|
-
let timeoutInter: ReturnType<typeof setTimeout>
|
|
13
|
-
let formKey
|
|
14
|
-
const apiName = 'uploadFile'
|
|
15
|
-
const xhr = new XMLHttpRequest()
|
|
16
|
-
const form = new FormData()
|
|
17
|
-
const callbackManager = {
|
|
18
|
-
headersReceived: new CallbackManager(),
|
|
19
|
-
progressUpdate: new CallbackManager()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
xhr.open('POST', url)
|
|
23
|
-
setHeader(xhr, header)
|
|
24
|
-
|
|
25
|
-
for (formKey in formData) {
|
|
26
|
-
form.append(formKey, formData[formKey])
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
xhr.upload.onprogress = e => {
|
|
30
|
-
const { loaded, total } = e
|
|
31
|
-
callbackManager.progressUpdate.trigger({
|
|
32
|
-
progress: Math.round(loaded / total * 100),
|
|
33
|
-
totalBytesSent: loaded,
|
|
34
|
-
totalBytesExpectedToSent: total
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
xhr.onreadystatechange = () => {
|
|
39
|
-
if (xhr.readyState !== XHR_STATS.HEADERS_RECEIVED) return
|
|
40
|
-
callbackManager.headersReceived.trigger({
|
|
41
|
-
header: xhr.getAllResponseHeaders()
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
xhr.onload = () => {
|
|
46
|
-
const status = xhr.status
|
|
47
|
-
clearTimeout(timeoutInter)
|
|
48
|
-
success({
|
|
49
|
-
errMsg: `${apiName}:ok`,
|
|
50
|
-
statusCode: status,
|
|
51
|
-
data: xhr.responseText || xhr.response
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
xhr.onabort = () => {
|
|
56
|
-
clearTimeout(timeoutInter)
|
|
57
|
-
error({
|
|
58
|
-
errMsg: `${apiName}:fail abort`
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
xhr.onerror = (e: ProgressEvent<EventTarget> & { message?: string }) => {
|
|
63
|
-
clearTimeout(timeoutInter)
|
|
64
|
-
error({
|
|
65
|
-
errMsg: `${apiName}:fail ${e.message}`
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 中断任务
|
|
71
|
-
*/
|
|
72
|
-
const abort = () => {
|
|
73
|
-
clearTimeout(timeoutInter)
|
|
74
|
-
xhr.abort()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const send = () => {
|
|
78
|
-
xhr.send(form)
|
|
79
|
-
timeoutInter = setTimeout(() => {
|
|
80
|
-
xhr.onabort = null
|
|
81
|
-
xhr.onload = null
|
|
82
|
-
xhr.upload.onprogress = null
|
|
83
|
-
xhr.onreadystatechange = null
|
|
84
|
-
xhr.onerror = null
|
|
85
|
-
abort()
|
|
86
|
-
error({
|
|
87
|
-
errMsg: `${apiName}:fail timeout`
|
|
88
|
-
})
|
|
89
|
-
}, timeout || NETWORK_TIMEOUT)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
convertObjectUrlToBlob(filePath)
|
|
93
|
-
.then((fileObj: string | (Blob & { name?: string })) => {
|
|
94
|
-
if (!fileName) {
|
|
95
|
-
fileName = typeof fileObj !== 'string' && fileObj.name
|
|
96
|
-
}
|
|
97
|
-
form.append(name, fileObj, fileName || `file-${Date.now()}`)
|
|
98
|
-
send()
|
|
99
|
-
})
|
|
100
|
-
.catch(e => {
|
|
101
|
-
error({
|
|
102
|
-
errMsg: `${apiName}:fail ${e.message}`
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 监听 HTTP Response Header 事件。会比请求完成事件更早
|
|
108
|
-
* @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
|
|
109
|
-
*/
|
|
110
|
-
const onHeadersReceived = callbackManager.headersReceived.add
|
|
111
|
-
/**
|
|
112
|
-
* 取消监听 HTTP Response Header 事件
|
|
113
|
-
* @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
|
|
114
|
-
*/
|
|
115
|
-
const offHeadersReceived = callbackManager.headersReceived.remove
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* 监听进度变化事件
|
|
119
|
-
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
120
|
-
*/
|
|
121
|
-
const onProgressUpdate = callbackManager.progressUpdate.add
|
|
122
|
-
/**
|
|
123
|
-
* 取消监听进度变化事件
|
|
124
|
-
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
125
|
-
*/
|
|
126
|
-
const offProgressUpdate = callbackManager.progressUpdate.remove
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
abort,
|
|
130
|
-
onHeadersReceived,
|
|
131
|
-
offHeadersReceived,
|
|
132
|
-
onProgressUpdate,
|
|
133
|
-
offProgressUpdate
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data。使用前请注意阅读相关说明。
|
|
139
|
-
*/
|
|
140
|
-
export const uploadFile: typeof Taro.uploadFile = ({ url, filePath, name, header, formData, timeout, fileName, success, fail, complete }) => {
|
|
141
|
-
let task!: Taro.UploadTask
|
|
142
|
-
const result: ReturnType<typeof Taro.uploadFile> = new Promise((resolve, reject) => {
|
|
143
|
-
task = createUploadTask({
|
|
144
|
-
url,
|
|
145
|
-
header,
|
|
146
|
-
name,
|
|
147
|
-
filePath,
|
|
148
|
-
formData,
|
|
149
|
-
timeout,
|
|
150
|
-
fileName,
|
|
151
|
-
success: res => {
|
|
152
|
-
success && success(res)
|
|
153
|
-
complete && complete(res)
|
|
154
|
-
resolve(res)
|
|
155
|
-
},
|
|
156
|
-
error: res => {
|
|
157
|
-
fail && fail(res)
|
|
158
|
-
complete && complete(res)
|
|
159
|
-
reject(res)
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
}) as any
|
|
163
|
-
|
|
164
|
-
result.headersReceive = task.onHeadersReceived
|
|
165
|
-
result.progress = task.onProgressUpdate
|
|
166
|
-
result.abort = task.abort
|
|
167
|
-
|
|
168
|
-
return result
|
|
169
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { getParameterError, shouldBeObject } from '../../../utils'
|
|
2
|
-
import { MethodHandler } from '../../../utils/handler'
|
|
3
|
-
import { SocketTask } from './socketTask'
|
|
4
|
-
|
|
5
|
-
let socketTasks: SocketTask[] = []
|
|
6
|
-
let socketsCounter = 1
|
|
7
|
-
|
|
8
|
-
export function sendSocketMessage () {
|
|
9
|
-
console.warn('Deprecated.Please use socketTask.send instead.')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function onSocketOpen () {
|
|
13
|
-
console.warn('Deprecated.Please use socketTask.onOpen instead.')
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function onSocketMessage () {
|
|
17
|
-
console.warn('Deprecated.Please use socketTask.onMessage instead.')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function onSocketError () {
|
|
21
|
-
console.warn('Deprecated.Please use socketTask.onError instead.')
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function onSocketClose () {
|
|
25
|
-
console.warn('Deprecated.Please use socketTask.onClose instead.')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function connectSocket (options) {
|
|
29
|
-
const name = 'connectSocket'
|
|
30
|
-
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
// options must be an Object
|
|
33
|
-
const isObject = shouldBeObject(options)
|
|
34
|
-
if (!isObject.flag) {
|
|
35
|
-
const res = { errMsg: `${name}:fail ${isObject.msg}` }
|
|
36
|
-
console.error(res.errMsg)
|
|
37
|
-
return reject(res)
|
|
38
|
-
}
|
|
39
|
-
const { url, protocols, success, fail, complete } = options
|
|
40
|
-
const handle = new MethodHandler<{
|
|
41
|
-
socketTaskId?: number
|
|
42
|
-
}>({ name, success, fail, complete })
|
|
43
|
-
|
|
44
|
-
// options.url must be String
|
|
45
|
-
if (typeof url !== 'string') {
|
|
46
|
-
return handle.fail({
|
|
47
|
-
errMsg: getParameterError({
|
|
48
|
-
para: 'url',
|
|
49
|
-
correct: 'String',
|
|
50
|
-
wrong: url
|
|
51
|
-
})
|
|
52
|
-
}, reject)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// options.url must be invalid
|
|
56
|
-
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
57
|
-
return handle.fail({
|
|
58
|
-
errMsg: `request:fail invalid url "${url}"`
|
|
59
|
-
}, reject)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// protocols must be array
|
|
63
|
-
const _protocols = Array.isArray(protocols) ? protocols : null
|
|
64
|
-
|
|
65
|
-
// 2 connection at most
|
|
66
|
-
if (socketTasks.length > 1) {
|
|
67
|
-
return handle.fail({
|
|
68
|
-
errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
|
|
69
|
-
}, reject)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const task = new SocketTask(url, _protocols)
|
|
73
|
-
task._destroyWhenClose = function () {
|
|
74
|
-
socketTasks = socketTasks.filter(socketTask => socketTask !== this)
|
|
75
|
-
}
|
|
76
|
-
socketTasks.push(task)
|
|
77
|
-
|
|
78
|
-
handle.success({
|
|
79
|
-
socketTaskId: socketsCounter++
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
return resolve(task)
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function closeSocket () {
|
|
87
|
-
console.warn('Deprecated.Please use socketTask.close instead.')
|
|
88
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
export class SocketTask {
|
|
4
|
-
ws: WebSocket
|
|
5
|
-
CONNECTING: number
|
|
6
|
-
OPEN: number
|
|
7
|
-
CLOSING: number
|
|
8
|
-
CLOSED: number
|
|
9
|
-
closeDetail: { code: any; reason: any }
|
|
10
|
-
_destroyWhenClose?: () => void
|
|
11
|
-
|
|
12
|
-
constructor (url, protocols) {
|
|
13
|
-
if (protocols && protocols.length) {
|
|
14
|
-
this.ws = new WebSocket(url, protocols)
|
|
15
|
-
} else {
|
|
16
|
-
this.ws = new WebSocket(url)
|
|
17
|
-
}
|
|
18
|
-
this.CONNECTING = 0
|
|
19
|
-
this.OPEN = 1
|
|
20
|
-
this.CLOSING = 2
|
|
21
|
-
this.CLOSED = 3
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get readyState () {
|
|
25
|
-
return this.ws.readyState
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
send (opts: Partial<Taro.SocketTask.SendOption> = {}) {
|
|
29
|
-
if (typeof opts !== 'object' || !opts) opts = {}
|
|
30
|
-
|
|
31
|
-
const { data = '', success, fail, complete } = opts
|
|
32
|
-
|
|
33
|
-
if (this.readyState !== 1) {
|
|
34
|
-
const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' }
|
|
35
|
-
console.error(res.errMsg)
|
|
36
|
-
typeof fail === 'function' && fail(res)
|
|
37
|
-
typeof complete === 'function' && complete(res)
|
|
38
|
-
return Promise.reject(res)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this.ws.send(data)
|
|
42
|
-
|
|
43
|
-
const res = { errMsg: 'sendSocketMessage:ok' }
|
|
44
|
-
typeof success === 'function' && success(res)
|
|
45
|
-
typeof complete === 'function' && complete(res)
|
|
46
|
-
return Promise.resolve(res)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
close (opts: Partial<Taro.SocketTask.CloseOption> = {}) {
|
|
50
|
-
if (typeof opts !== 'object' || !opts) opts = {}
|
|
51
|
-
|
|
52
|
-
const {
|
|
53
|
-
code = 1000,
|
|
54
|
-
reason = 'server complete,close',
|
|
55
|
-
success,
|
|
56
|
-
complete
|
|
57
|
-
} = opts
|
|
58
|
-
|
|
59
|
-
this.closeDetail = { code, reason }
|
|
60
|
-
// 主动断开时需要重置链接数
|
|
61
|
-
this._destroyWhenClose && this._destroyWhenClose()
|
|
62
|
-
this.ws.close()
|
|
63
|
-
|
|
64
|
-
const res = { errMsg: 'closeSocket:ok' }
|
|
65
|
-
typeof success === 'function' && success(res)
|
|
66
|
-
typeof complete === 'function' && complete(res)
|
|
67
|
-
return Promise.resolve(res)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
onOpen (func) {
|
|
71
|
-
this.ws.onopen = func
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
onMessage (func) {
|
|
75
|
-
this.ws.onmessage = func
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
onClose (func) {
|
|
79
|
-
this.ws.onclose = () => {
|
|
80
|
-
// 若服务器方断掉也需要重置链接数
|
|
81
|
-
this._destroyWhenClose && this._destroyWhenClose()
|
|
82
|
-
func(this.closeDetail || { code: 1006, reason: 'abnormal closure' })
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
onError (func) {
|
|
87
|
-
this.ws.onerror = func
|
|
88
|
-
}
|
|
89
|
-
}
|
package/src/api/open-api/card.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '../../utils'
|
|
2
|
-
|
|
3
|
-
// 视频号
|
|
4
|
-
export const reserveChannelsLive = temporarilyNotSupport('reserveChannelsLive')
|
|
5
|
-
export const openChannelsLive = temporarilyNotSupport('openChannelsLive')
|
|
6
|
-
export const openChannelsEvent = temporarilyNotSupport('openChannelsEvent')
|
|
7
|
-
export const openChannelsActivity = temporarilyNotSupport('openChannelsActivity')
|
|
8
|
-
export const getChannelsLiveNoticeInfo = temporarilyNotSupport('getChannelsLiveNoticeInfo')
|
|
9
|
-
export const getChannelsLiveInfo = temporarilyNotSupport('getChannelsLiveInfo')
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '../../utils'
|
|
2
|
-
|
|
3
|
-
// 过往接口
|
|
4
|
-
export const checkIsSupportFacialRecognition = temporarilyNotSupport('checkIsSupportFacialRecognition')
|
|
5
|
-
export const startFacialRecognitionVerify = temporarilyNotSupport('startFacialRecognitionVerify')
|
|
6
|
-
export const startFacialRecognitionVerifyAndUploadVideo = temporarilyNotSupport('startFacialRecognitionVerifyAndUploadVideo')
|
|
7
|
-
export const faceVerifyForPay = temporarilyNotSupport('faceVerifyForPay')
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export * from './account'
|
|
2
|
-
export * from './address'
|
|
3
|
-
export * from './authorize'
|
|
4
|
-
export * from './card'
|
|
5
|
-
export * from './channels-live'
|
|
6
|
-
export * from './customer-service'
|
|
7
|
-
export * from './facial'
|
|
8
|
-
export * from './favorites'
|
|
9
|
-
export * from './group'
|
|
10
|
-
export * from './invoice'
|
|
11
|
-
export * from './license-plate'
|
|
12
|
-
export * from './login'
|
|
13
|
-
export * from './red-package'
|
|
14
|
-
export * from './settings'
|
|
15
|
-
export * from './soter'
|
|
16
|
-
export * from './subscribe-message'
|
|
17
|
-
export * from './user-info'
|
|
18
|
-
export * from './werun'
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '../../utils'
|
|
2
|
-
|
|
3
|
-
// 生物认证
|
|
4
|
-
export const startSoterAuthentication = temporarilyNotSupport('startSoterAuthentication')
|
|
5
|
-
export const checkIsSupportSoterAuthentication = temporarilyNotSupport('checkIsSupportSoterAuthentication')
|
|
6
|
-
export const checkIsSoterEnrolledInDevice = temporarilyNotSupport('checkIsSoterEnrolledInDevice')
|
package/src/api/payment/index.ts
DELETED
package/src/api/route/index.ts
DELETED
package/src/api/share/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '../../utils'
|
|
2
|
-
|
|
3
|
-
// 转发
|
|
4
|
-
export const updateShareMenu = temporarilyNotSupport('updateShareMenu')
|
|
5
|
-
export const showShareMenu = temporarilyNotSupport('showShareMenu')
|
|
6
|
-
export const showShareImageMenu = temporarilyNotSupport('showShareImageMenu')
|
|
7
|
-
export const shareVideoMessage = temporarilyNotSupport('shareVideoMessage')
|
|
8
|
-
export const shareFileMessage = temporarilyNotSupport('shareFileMessage')
|
|
9
|
-
export const onCopyUrl = temporarilyNotSupport('onCopyUrl')
|
|
10
|
-
export const offCopyUrl = temporarilyNotSupport('offCopyUrl')
|
|
11
|
-
export const hideShareMenu = temporarilyNotSupport('hideShareMenu')
|
|
12
|
-
export const getShareInfo = temporarilyNotSupport('getShareInfo')
|
|
13
|
-
export const authPrivateMessage = temporarilyNotSupport('authPrivateMessage')
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '../../utils'
|
|
2
|
-
|
|
3
|
-
// 周期性更新
|
|
4
|
-
export const setBackgroundFetchToken = temporarilyNotSupport('setBackgroundFetchToken')
|
|
5
|
-
export const onBackgroundFetchData = temporarilyNotSupport('onBackgroundFetchData')
|
|
6
|
-
export const getBackgroundFetchToken = temporarilyNotSupport('getBackgroundFetchToken')
|
|
7
|
-
export const getBackgroundFetchData = temporarilyNotSupport('getBackgroundFetchData')
|