@tarojs/taro-h5 3.3.20 → 3.4.0-beta.3
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 +1 -0
- package/dist/api/ai/facial.js +1 -0
- package/dist/api/ai/visual.js +1 -0
- package/dist/api/alipay/index.js +1 -0
- package/dist/api/base/crypto.js +1 -0
- package/dist/api/base/index.js +1 -0
- package/dist/api/base/performance.js +1 -0
- package/dist/api/base/system/info.js +1 -0
- package/dist/api/base/system/network.js +12 -1
- package/dist/api/base/update.js +1 -0
- package/dist/api/base/weapp/app-event.js +1 -0
- package/dist/api/base/weapp/life-cycle.js +1 -0
- package/dist/api/canvas/CanvasContext.js +9 -0
- package/dist/api/canvas/canvasGetImageData.js +4 -0
- package/dist/api/canvas/canvasPutImageData.js +5 -0
- package/dist/api/canvas/canvasToTempFilePath.js +4 -0
- package/dist/api/canvas/createCanvasContext.js +3 -0
- package/dist/api/canvas/index.js +1 -0
- package/dist/api/cloud/index.js +3 -0
- package/dist/api/device/accelerometer.js +12 -0
- package/dist/api/device/accessibility.js +1 -0
- package/dist/api/device/battery.js +1 -0
- package/dist/api/device/bluetooth-ble.js +1 -0
- package/dist/api/device/bluetooth-peripheral.js +1 -0
- package/dist/api/device/bluetooth.js +1 -0
- package/dist/api/device/calendar.js +1 -0
- package/dist/api/device/clipboard.js +17 -0
- package/dist/api/device/compass.js +12 -0
- package/dist/api/device/contact.js +1 -0
- package/dist/api/device/crypto.js +1 -0
- package/dist/api/device/gyroscope.js +1 -0
- package/dist/api/device/iBeacon.js +1 -0
- package/dist/api/device/keyboard.js +1 -0
- package/dist/api/device/memory.js +1 -0
- package/dist/api/device/motion.js +12 -0
- package/dist/api/device/nfc.js +1 -0
- package/dist/api/device/phone.js +1 -0
- package/dist/api/device/scan.js +1 -0
- package/dist/api/device/screen.js +1 -0
- package/dist/api/device/vibrate.js +6 -0
- package/dist/api/device/wifi.js +1 -0
- package/dist/api/ext/index.js +1 -0
- package/dist/api/files/index.js +1 -0
- package/dist/api/framework/index.js +1 -0
- package/dist/api/location/chooseLocation.js +5 -0
- package/dist/api/location/index.js +1 -0
- package/dist/api/media/audio/index.js +7 -0
- package/dist/api/media/background-audio.js +1 -0
- package/dist/api/media/camera.js +1 -0
- package/dist/api/media/editor.js +1 -0
- package/dist/api/media/image/chooseImage.js +4 -0
- package/dist/api/media/image/getImageInfo.js +4 -0
- package/dist/api/media/image/index.js +1 -0
- package/dist/api/media/image/previewImage.js +10 -0
- package/dist/api/media/live.js +1 -0
- package/dist/api/media/map.js +1 -0
- package/dist/api/media/media-recorder.js +1 -0
- package/dist/api/media/recorder.js +1 -0
- package/dist/api/media/video/index.js +9 -0
- package/dist/api/media/video-decoder.js +1 -0
- package/dist/api/media/video-processing.js +1 -0
- package/dist/api/media/voip.js +1 -0
- package/dist/api/navigate/index.js +1 -0
- package/dist/api/network/download.js +23 -0
- package/dist/api/network/mdns.js +1 -0
- package/dist/api/network/request/index.js +2 -0
- package/dist/api/network/tcp.js +1 -0
- package/dist/api/network/udp.js +1 -0
- package/dist/api/network/upload.js +22 -0
- package/dist/api/network/utils.js +36 -1
- package/dist/api/network/websocket/index.js +5 -0
- package/dist/api/network/websocket/socketTask.js +2 -0
- package/dist/api/open-api/account.js +1 -0
- package/dist/api/open-api/address.js +1 -0
- package/dist/api/open-api/authorize.js +1 -0
- package/dist/api/open-api/card.js +1 -0
- package/dist/api/open-api/channels-live.js +1 -0
- package/dist/api/open-api/customer-service.js +1 -0
- package/dist/api/open-api/facial.js +1 -0
- package/dist/api/open-api/favorites.js +1 -0
- package/dist/api/open-api/group.js +1 -0
- package/dist/api/open-api/invoice.js +1 -0
- package/dist/api/open-api/license-plate.js +1 -0
- package/dist/api/open-api/login.js +1 -0
- package/dist/api/open-api/red-package.js +1 -0
- package/dist/api/open-api/settings.js +1 -0
- package/dist/api/open-api/soter.js +1 -0
- package/dist/api/open-api/subscribe-message.js +1 -0
- package/dist/api/open-api/user-info.js +1 -0
- package/dist/api/open-api/werun.js +1 -0
- package/dist/api/payment/index.js +1 -0
- package/dist/api/route/index.js +2 -0
- package/dist/api/share/index.js +1 -0
- package/dist/api/storage/background-fetch.js +1 -0
- package/dist/api/storage/index.js +5 -0
- package/dist/api/swan/index.js +4 -0
- package/dist/api/taro.js +6 -18
- package/dist/api/ui/animation/index.js +34 -0
- package/dist/api/ui/background.js +1 -0
- package/dist/api/ui/custom-component.js +1 -0
- package/dist/api/ui/fonts.js +1 -0
- package/dist/api/ui/interaction/actionSheet.js +16 -0
- package/dist/api/ui/interaction/index.js +9 -4
- package/dist/api/ui/interaction/modal.js +22 -0
- package/dist/api/ui/interaction/toast.js +16 -0
- package/dist/api/ui/menu.js +1 -0
- package/dist/api/ui/navigation-bar/index.js +5 -0
- package/dist/api/ui/pull-down-refresh.js +6 -0
- package/dist/api/ui/scroll/index.js +3 -0
- package/dist/api/ui/sticky.js +1 -0
- package/dist/api/ui/tab-bar.js +32 -0
- package/dist/api/ui/window.js +9 -0
- package/dist/api/utils/handler.js +16 -0
- package/dist/api/utils/index.js +7 -0
- package/dist/api/worker/index.js +1 -0
- package/dist/api/wxml/selectorQuery.js +13 -0
- package/dist/index.cjs.js +637 -160
- package/dist/index.js +2 -2
- package/package.json +9 -13
- package/src/api/media/image/previewImage.ts +1 -1
- package/src/api/taro.ts +4 -48
- package/src/api/ui/interaction/index.ts +6 -4
- package/src/api/ui/navigation-bar/index.ts +1 -1
- package/src/api/ui/scroll/index.ts +1 -1
- package/src/index.ts +2 -2
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { shouldBeObject } from '../../utils';
|
|
2
2
|
import { MethodHandler } from '../../utils/handler';
|
|
3
|
+
/**
|
|
4
|
+
* 获取图片信息。网络图片需先配置download域名才能生效。
|
|
5
|
+
*/
|
|
3
6
|
export const getImageInfo = (options) => {
|
|
7
|
+
// options must be an Object
|
|
4
8
|
const isObject = shouldBeObject(options);
|
|
5
9
|
if (!isObject.flag) {
|
|
6
10
|
const res = { errMsg: `getImageInfo:fail ${isObject.msg}` };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { shouldBeObject } from '../../utils';
|
|
2
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
|
+
*/
|
|
3
9
|
export const previewImage = async (options) => {
|
|
4
10
|
function loadImage(url, loadFail) {
|
|
5
11
|
return new Promise((resolve) => {
|
|
@@ -12,6 +18,7 @@ export const previewImage = async (options) => {
|
|
|
12
18
|
div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;';
|
|
13
19
|
div.appendChild(image);
|
|
14
20
|
item.appendChild(div);
|
|
21
|
+
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
15
22
|
resolve(item);
|
|
16
23
|
if (typeof loadFail === 'function') {
|
|
17
24
|
image.addEventListener('error', (err) => {
|
|
@@ -20,6 +27,7 @@ export const previewImage = async (options) => {
|
|
|
20
27
|
}
|
|
21
28
|
});
|
|
22
29
|
}
|
|
30
|
+
// options must be an Object
|
|
23
31
|
const isObject = shouldBeObject(options);
|
|
24
32
|
if (!isObject.flag) {
|
|
25
33
|
const res = { errMsg: `previewImage:fail ${isObject.msg}` };
|
|
@@ -35,6 +43,7 @@ export const previewImage = async (options) => {
|
|
|
35
43
|
container.remove();
|
|
36
44
|
});
|
|
37
45
|
const swiper = document.createElement('taro-swiper-core');
|
|
46
|
+
// @ts-ignore
|
|
38
47
|
swiper.full = true;
|
|
39
48
|
let children = [];
|
|
40
49
|
try {
|
|
@@ -50,6 +59,7 @@ export const previewImage = async (options) => {
|
|
|
50
59
|
swiper.appendChild(child);
|
|
51
60
|
}
|
|
52
61
|
const currentIndex = urls.indexOf(current);
|
|
62
|
+
// @ts-ignore
|
|
53
63
|
swiper.current = currentIndex;
|
|
54
64
|
container.appendChild(swiper);
|
|
55
65
|
document.body.appendChild(container);
|
package/dist/api/media/live.js
CHANGED
package/dist/api/media/map.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { MethodHandler } from '../../utils/handler';
|
|
2
2
|
import { findDOM, shouldBeObject, temporarilyNotSupport } from '../../utils';
|
|
3
|
+
// 视频
|
|
3
4
|
export const saveVideoToPhotosAlbum = temporarilyNotSupport('saveVideoToPhotosAlbum');
|
|
4
5
|
export const openVideoEditor = temporarilyNotSupport('openVideoEditor');
|
|
5
6
|
export const getVideoInfo = temporarilyNotSupport('getVideoInfo');
|
|
7
|
+
/**
|
|
8
|
+
* 创建 video 上下文 VideoContext 对象。
|
|
9
|
+
*/
|
|
6
10
|
export const createVideoContext = (id, inst) => {
|
|
7
11
|
const el = findDOM(inst);
|
|
12
|
+
// TODO HTMLVideoElement to VideoContext
|
|
8
13
|
return el === null || el === void 0 ? void 0 : el.querySelector(`taro-video-core[id=${id}]`);
|
|
9
14
|
};
|
|
10
15
|
export const compressVideo = temporarilyNotSupport('compressVideo');
|
|
16
|
+
/**
|
|
17
|
+
* 拍摄视频或从手机相册中选视频。
|
|
18
|
+
*/
|
|
11
19
|
export const chooseVideo = (options) => {
|
|
20
|
+
// options must be an Object
|
|
12
21
|
const isObject = shouldBeObject(options);
|
|
13
22
|
if (!isObject.flag) {
|
|
14
23
|
const res = { errMsg: `chooseVideo:fail ${isObject.msg}` };
|
package/dist/api/media/voip.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 实时语音
|
|
2
3
|
export const updateVoIPChatMuteConfig = temporarilyNotSupport('updateVoIPChatMuteConfig');
|
|
3
4
|
export const subscribeVoIPVideoMembers = temporarilyNotSupport('subscribeVoIPVideoMembers');
|
|
4
5
|
export const setEnable1v1Chat = temporarilyNotSupport('setEnable1v1Chat');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 跳转
|
|
2
3
|
export const openEmbeddedMiniProgram = temporarilyNotSupport('openEmbeddedMiniProgram');
|
|
3
4
|
export const navigateToMiniProgram = temporarilyNotSupport('navigateToMiniProgram');
|
|
4
5
|
export const navigateBackMiniProgram = temporarilyNotSupport('navigateBackMiniProgram');
|
|
@@ -46,6 +46,9 @@ const createDownloadTask = ({ url, header, success, error }) => {
|
|
|
46
46
|
errMsg: `${apiName}:fail ${e.message}`
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* 中断任务
|
|
51
|
+
*/
|
|
49
52
|
const abort = () => {
|
|
50
53
|
xhr.abort();
|
|
51
54
|
};
|
|
@@ -64,9 +67,25 @@ const createDownloadTask = ({ url, header, success, error }) => {
|
|
|
64
67
|
}, NETWORK_TIMEOUT);
|
|
65
68
|
};
|
|
66
69
|
send();
|
|
70
|
+
/**
|
|
71
|
+
* 监听 HTTP Response Header 事件。会比请求完成事件更早
|
|
72
|
+
* @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
|
|
73
|
+
*/
|
|
67
74
|
const onHeadersReceived = callbackManager.headersReceived.add;
|
|
75
|
+
/**
|
|
76
|
+
* 取消监听 HTTP Response Header 事件
|
|
77
|
+
* @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
|
|
78
|
+
*/
|
|
68
79
|
const offHeadersReceived = callbackManager.headersReceived.remove;
|
|
80
|
+
/**
|
|
81
|
+
* 监听进度变化事件
|
|
82
|
+
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
83
|
+
*/
|
|
69
84
|
const onProgressUpdate = callbackManager.progressUpdate.add;
|
|
85
|
+
/**
|
|
86
|
+
* 取消监听进度变化事件
|
|
87
|
+
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
88
|
+
*/
|
|
70
89
|
const offProgressUpdate = callbackManager.progressUpdate.remove;
|
|
71
90
|
return {
|
|
72
91
|
abort,
|
|
@@ -76,6 +95,10 @@ const createDownloadTask = ({ url, header, success, error }) => {
|
|
|
76
95
|
offProgressUpdate
|
|
77
96
|
};
|
|
78
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。使用前请注意阅读相关说明。
|
|
100
|
+
* 注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
|
|
101
|
+
*/
|
|
79
102
|
export const downloadFile = ({ url, header, success, fail, complete }) => {
|
|
80
103
|
let task;
|
|
81
104
|
const result = new Promise((resolve, reject) => {
|
package/dist/api/network/mdns.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// mDNS
|
|
2
3
|
export const stopLocalServiceDiscovery = temporarilyNotSupport('stopLocalServiceDiscovery');
|
|
3
4
|
export const startLocalServiceDiscovery = temporarilyNotSupport('startLocalServiceDiscovery');
|
|
4
5
|
export const onLocalServiceResolveFail = temporarilyNotSupport('onLocalServiceResolveFail');
|
|
@@ -2,6 +2,7 @@ import Taro from '@tarojs/api';
|
|
|
2
2
|
import 'whatwg-fetch';
|
|
3
3
|
import jsonpRetry from 'jsonp-retry';
|
|
4
4
|
import { serializeParams } from '../../utils';
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
const { Link } = Taro;
|
|
6
7
|
function generateRequestUrlWithParams(url, params) {
|
|
7
8
|
params = typeof params === 'string' ? params : serializeParams(params);
|
|
@@ -11,6 +12,7 @@ function generateRequestUrlWithParams(url, params) {
|
|
|
11
12
|
url = url.replace('?&', '?');
|
|
12
13
|
return url;
|
|
13
14
|
}
|
|
15
|
+
// FIXME 移除 any 标注
|
|
14
16
|
function _request(options) {
|
|
15
17
|
options = options || {};
|
|
16
18
|
if (typeof options === 'string') {
|
package/dist/api/network/tcp.js
CHANGED
package/dist/api/network/udp.js
CHANGED
|
@@ -52,6 +52,9 @@ const createUploadTask = ({ url, filePath, formData, name, header, timeout, file
|
|
|
52
52
|
errMsg: `${apiName}:fail ${e.message}`
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* 中断任务
|
|
57
|
+
*/
|
|
55
58
|
const abort = () => {
|
|
56
59
|
clearTimeout(timeoutInter);
|
|
57
60
|
xhr.abort();
|
|
@@ -83,9 +86,25 @@ const createUploadTask = ({ url, filePath, formData, name, header, timeout, file
|
|
|
83
86
|
errMsg: `${apiName}:fail ${e.message}`
|
|
84
87
|
});
|
|
85
88
|
});
|
|
89
|
+
/**
|
|
90
|
+
* 监听 HTTP Response Header 事件。会比请求完成事件更早
|
|
91
|
+
* @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
|
|
92
|
+
*/
|
|
86
93
|
const onHeadersReceived = callbackManager.headersReceived.add;
|
|
94
|
+
/**
|
|
95
|
+
* 取消监听 HTTP Response Header 事件
|
|
96
|
+
* @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
|
|
97
|
+
*/
|
|
87
98
|
const offHeadersReceived = callbackManager.headersReceived.remove;
|
|
99
|
+
/**
|
|
100
|
+
* 监听进度变化事件
|
|
101
|
+
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
102
|
+
*/
|
|
88
103
|
const onProgressUpdate = callbackManager.progressUpdate.add;
|
|
104
|
+
/**
|
|
105
|
+
* 取消监听进度变化事件
|
|
106
|
+
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
107
|
+
*/
|
|
89
108
|
const offProgressUpdate = callbackManager.progressUpdate.remove;
|
|
90
109
|
const headersReceived = temporarilyNotSupport('UploadTask.headersReceived');
|
|
91
110
|
const progress = temporarilyNotSupport('UploadTask.progress');
|
|
@@ -99,6 +118,9 @@ const createUploadTask = ({ url, filePath, formData, name, header, timeout, file
|
|
|
99
118
|
progress
|
|
100
119
|
};
|
|
101
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* 将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data。使用前请注意阅读相关说明。
|
|
123
|
+
*/
|
|
102
124
|
export const uploadFile = ({ url, filePath, name, header, formData, timeout, fileName, success, fail, complete }) => {
|
|
103
125
|
let task;
|
|
104
126
|
const result = new Promise((resolve, reject) => {
|
|
@@ -1,17 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Response Header 事件回调函数的参数
|
|
3
|
+
* @typedef {Object} HeadersReceivedParam
|
|
4
|
+
* @property {Object} header 开发者服务器返回的 HTTP Response Header
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* HTTP Response Header 事件的回调函数
|
|
8
|
+
* @callback HeadersReceivedCallback
|
|
9
|
+
* @param {HeadersReceivedParam} res 参数
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* 进度变化回调函数的参数
|
|
13
|
+
* @typedef {Object} ProgressUpdateParam
|
|
14
|
+
* @property {number} progress 进度百分比
|
|
15
|
+
* @property {number} [totalBytesWritten] 已经下载的数据长度,单位 Bytes
|
|
16
|
+
* @property {number} [totalBytesSent] 已经上传的数据长度,单位 Bytes
|
|
17
|
+
* @property {number} [totalBytesExpectedToWrite] 预期需要下载的数据总长度,单位 Bytes
|
|
18
|
+
* @property {number} [totalBytesExpectedToSend] 预期需要上传的数据总长度,单位 Bytes
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* 进度变化事件的回调函数
|
|
22
|
+
* @callback ProgressUpdateCallback
|
|
23
|
+
* @param {ProgressUpdateParam} res 参数
|
|
24
|
+
*/
|
|
1
25
|
export const NETWORK_TIMEOUT = 60000;
|
|
2
26
|
export const XHR_STATS = {
|
|
3
27
|
UNSENT: 0,
|
|
4
28
|
OPENED: 1,
|
|
5
29
|
HEADERS_RECEIVED: 2,
|
|
6
30
|
LOADING: 3,
|
|
7
|
-
DONE: 4
|
|
31
|
+
DONE: 4 // The operation is complete.
|
|
8
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* 设置xhr的header
|
|
35
|
+
* @param {XMLHttpRequest} xhr
|
|
36
|
+
* @param {Object} header
|
|
37
|
+
*/
|
|
9
38
|
export const setHeader = (xhr, header) => {
|
|
10
39
|
let headerKey;
|
|
11
40
|
for (headerKey in header) {
|
|
12
41
|
xhr.setRequestHeader(headerKey, header[headerKey]);
|
|
13
42
|
}
|
|
14
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* 将 blob url 转化为文件
|
|
46
|
+
* @param {string} url 要转换的 blob url
|
|
47
|
+
* @returns {Promise<File>}
|
|
48
|
+
*/
|
|
15
49
|
export const convertObjectUrlToBlob = url => {
|
|
16
50
|
return new Promise((resolve, reject) => {
|
|
17
51
|
const xhr = new XMLHttpRequest();
|
|
@@ -22,6 +56,7 @@ export const convertObjectUrlToBlob = url => {
|
|
|
22
56
|
resolve(this.response);
|
|
23
57
|
}
|
|
24
58
|
else {
|
|
59
|
+
/* eslint-disable prefer-promise-reject-errors */
|
|
25
60
|
reject({ status: this.status });
|
|
26
61
|
}
|
|
27
62
|
};
|
|
@@ -21,6 +21,7 @@ export function onSocketClose() {
|
|
|
21
21
|
export function connectSocket(options) {
|
|
22
22
|
const name = 'connectSocket';
|
|
23
23
|
return new Promise((resolve, reject) => {
|
|
24
|
+
// options must be an Object
|
|
24
25
|
const isObject = shouldBeObject(options);
|
|
25
26
|
if (!isObject.flag) {
|
|
26
27
|
const res = { errMsg: `${name}:fail ${isObject.msg}` };
|
|
@@ -29,6 +30,7 @@ export function connectSocket(options) {
|
|
|
29
30
|
}
|
|
30
31
|
const { url, protocols, success, fail, complete } = options;
|
|
31
32
|
const handle = new MethodHandler({ name, success, fail, complete });
|
|
33
|
+
// options.url must be String
|
|
32
34
|
if (typeof url !== 'string') {
|
|
33
35
|
return handle.fail({
|
|
34
36
|
errMsg: getParameterError({
|
|
@@ -38,12 +40,15 @@ export function connectSocket(options) {
|
|
|
38
40
|
})
|
|
39
41
|
}, reject);
|
|
40
42
|
}
|
|
43
|
+
// options.url must be invalid
|
|
41
44
|
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
42
45
|
return handle.fail({
|
|
43
46
|
errMsg: `request:fail invalid url "${url}"`
|
|
44
47
|
}, reject);
|
|
45
48
|
}
|
|
49
|
+
// protocols must be array
|
|
46
50
|
const _protocols = Array.isArray(protocols) ? protocols : null;
|
|
51
|
+
// 2 connection at most
|
|
47
52
|
if (socketTasks.length > 1) {
|
|
48
53
|
return handle.fail({
|
|
49
54
|
errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
|
|
@@ -36,6 +36,7 @@ export class SocketTask {
|
|
|
36
36
|
opts = {};
|
|
37
37
|
const { code = 1000, reason = 'server complete,close', success, complete } = opts;
|
|
38
38
|
this.closeDetail = { code, reason };
|
|
39
|
+
// 主动断开时需要重置链接数
|
|
39
40
|
this._destroyWhenClose && this._destroyWhenClose();
|
|
40
41
|
this.ws.close();
|
|
41
42
|
const res = { errMsg: 'closeSocket:ok' };
|
|
@@ -51,6 +52,7 @@ export class SocketTask {
|
|
|
51
52
|
}
|
|
52
53
|
onClose(func) {
|
|
53
54
|
this.ws.onclose = () => {
|
|
55
|
+
// 若服务器方断掉也需要重置链接数
|
|
54
56
|
this._destroyWhenClose && this._destroyWhenClose();
|
|
55
57
|
func(this.closeDetail || { code: 1006, reason: 'abnormal closure' });
|
|
56
58
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 视频号
|
|
2
3
|
export const reserveChannelsLive = temporarilyNotSupport('reserveChannelsLive');
|
|
3
4
|
export const openChannelsLive = temporarilyNotSupport('openChannelsLive');
|
|
4
5
|
export const openChannelsEvent = temporarilyNotSupport('openChannelsEvent');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 过往接口
|
|
2
3
|
export const checkIsSupportFacialRecognition = temporarilyNotSupport('checkIsSupportFacialRecognition');
|
|
3
4
|
export const startFacialRecognitionVerify = temporarilyNotSupport('startFacialRecognitionVerify');
|
|
4
5
|
export const startFacialRecognitionVerifyAndUploadVideo = temporarilyNotSupport('startFacialRecognitionVerifyAndUploadVideo');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 生物认证
|
|
2
3
|
export const startSoterAuthentication = temporarilyNotSupport('startSoterAuthentication');
|
|
3
4
|
export const checkIsSupportSoterAuthentication = temporarilyNotSupport('checkIsSupportSoterAuthentication');
|
|
4
5
|
export const checkIsSoterEnrolledInDevice = temporarilyNotSupport('checkIsSoterEnrolledInDevice');
|
package/dist/api/route/index.js
CHANGED
package/dist/api/share/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 转发
|
|
2
3
|
export const updateShareMenu = temporarilyNotSupport('updateShareMenu');
|
|
3
4
|
export const showShareMenu = temporarilyNotSupport('showShareMenu');
|
|
4
5
|
export const showShareImageMenu = temporarilyNotSupport('showShareImageMenu');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 周期性更新
|
|
2
3
|
export const setBackgroundFetchToken = temporarilyNotSupport('setBackgroundFetchToken');
|
|
3
4
|
export const onBackgroundFetchData = temporarilyNotSupport('onBackgroundFetchData');
|
|
4
5
|
export const getBackgroundFetchToken = temporarilyNotSupport('getBackgroundFetchToken');
|
|
@@ -6,6 +6,7 @@ function getItem(key) {
|
|
|
6
6
|
item = JSON.parse(localStorage.getItem(key) || '');
|
|
7
7
|
}
|
|
8
8
|
catch (e) { }
|
|
9
|
+
// 只返回使用 Taro.setStorage API 存储的数据
|
|
9
10
|
if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
|
|
10
11
|
return { result: true, data: item.data };
|
|
11
12
|
}
|
|
@@ -13,6 +14,7 @@ function getItem(key) {
|
|
|
13
14
|
return { result: false };
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
// 数据缓存
|
|
16
18
|
export const setStorageSync = (key, data = '') => {
|
|
17
19
|
if (typeof key !== 'string') {
|
|
18
20
|
console.error(getParameterError({
|
|
@@ -33,6 +35,7 @@ export const setStorageSync = (key, data = '') => {
|
|
|
33
35
|
localStorage.setItem(key, JSON.stringify(obj));
|
|
34
36
|
};
|
|
35
37
|
export const setStorage = (options) => {
|
|
38
|
+
// options must be an Object
|
|
36
39
|
const isObject = shouldBeObject(options);
|
|
37
40
|
if (!isObject.flag) {
|
|
38
41
|
const res = { errMsg: `setStorage:fail ${isObject.msg}` };
|
|
@@ -66,6 +69,7 @@ export const removeStorageSync = (key) => {
|
|
|
66
69
|
localStorage.removeItem(key);
|
|
67
70
|
};
|
|
68
71
|
export const removeStorage = (options) => {
|
|
72
|
+
// options must be an Object
|
|
69
73
|
const isObject = shouldBeObject(options);
|
|
70
74
|
if (!isObject.flag) {
|
|
71
75
|
const res = { errMsg: `removeStorage:fail ${isObject.msg}` };
|
|
@@ -113,6 +117,7 @@ export const getStorageInfo = ({ success, fail, complete } = {}) => {
|
|
|
113
117
|
return handle.success(getStorageInfoSync());
|
|
114
118
|
};
|
|
115
119
|
export const getStorage = (options) => {
|
|
120
|
+
// options must be an Object
|
|
116
121
|
const isObject = shouldBeObject(options);
|
|
117
122
|
if (!isObject.flag) {
|
|
118
123
|
const res = { errMsg: `getStorage:fail ${isObject.msg}` };
|
package/dist/api/swan/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
2
|
export const setPageInfo = temporarilyNotSupport('setPageInfo');
|
|
3
|
+
// 百度小程序 AI 相关
|
|
3
4
|
export const ocrIdCard = temporarilyNotSupport('ocrIdCard');
|
|
4
5
|
export const ocrBankCard = temporarilyNotSupport('ocrBankCard');
|
|
5
6
|
export const ocrDrivingLicense = temporarilyNotSupport('ocrDrivingLicense');
|
|
@@ -14,8 +15,11 @@ export const dishClassify = temporarilyNotSupport('dishClassify');
|
|
|
14
15
|
export const logoClassify = temporarilyNotSupport('logoClassify');
|
|
15
16
|
export const animalClassify = temporarilyNotSupport('animalClassify');
|
|
16
17
|
export const plantClassify = temporarilyNotSupport('plantClassify');
|
|
18
|
+
// 用户信息
|
|
17
19
|
export const getSwanId = temporarilyNotSupport('getSwanId');
|
|
20
|
+
// 百度收银台支付
|
|
18
21
|
export const requestPolymerPayment = temporarilyNotSupport('requestPolymerPayment');
|
|
22
|
+
// 打开小程序
|
|
19
23
|
export const navigateToSmartGameProgram = temporarilyNotSupport('navigateToSmartGameProgram');
|
|
20
24
|
export const navigateToSmartProgram = temporarilyNotSupport('navigateToSmartProgram');
|
|
21
25
|
export const navigateBackSmartProgram = temporarilyNotSupport('navigateBackSmartProgram');
|
package/dist/api/taro.js
CHANGED
|
@@ -2,8 +2,9 @@ import Taro from '@tarojs/api';
|
|
|
2
2
|
import { history, createRouter } from '@tarojs/router';
|
|
3
3
|
import { getApp, getCurrentInstance, getCurrentPages, nextTick, navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from '../api';
|
|
4
4
|
import { permanentlyNotSupport } from '../api/utils';
|
|
5
|
-
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload
|
|
5
|
+
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload } = Taro;
|
|
6
6
|
const taro = {
|
|
7
|
+
// @ts-ignore
|
|
7
8
|
Behavior,
|
|
8
9
|
getEnv,
|
|
9
10
|
ENV_TYPE,
|
|
@@ -23,26 +24,12 @@ const taro = {
|
|
|
23
24
|
reLaunch,
|
|
24
25
|
redirectTo,
|
|
25
26
|
getCurrentPages,
|
|
26
|
-
switchTab
|
|
27
|
-
useDidShow,
|
|
28
|
-
useDidHide,
|
|
29
|
-
usePullDownRefresh,
|
|
30
|
-
useReachBottom,
|
|
31
|
-
usePageScroll,
|
|
32
|
-
useResize,
|
|
33
|
-
useShareAppMessage,
|
|
34
|
-
useTabItemTap,
|
|
35
|
-
useTitleClick,
|
|
36
|
-
useOptionMenuClick,
|
|
37
|
-
usePullIntercept,
|
|
38
|
-
useShareTimeline,
|
|
39
|
-
useAddToFavorites,
|
|
40
|
-
useReady,
|
|
41
|
-
useRouter
|
|
27
|
+
switchTab
|
|
42
28
|
};
|
|
43
29
|
const initPxTransform = getInitPxTransform(taro);
|
|
44
30
|
const requirePlugin = permanentlyNotSupport('requirePlugin');
|
|
45
31
|
const pxTransform = function (size) {
|
|
32
|
+
// @ts-ignore
|
|
46
33
|
const { designWidth } = taro.config;
|
|
47
34
|
return Math.ceil((((parseInt(size, 10) / 40) * 640) / designWidth) * 10000) / 10000 + 'rem';
|
|
48
35
|
};
|
|
@@ -54,6 +41,7 @@ taro.requirePlugin = requirePlugin;
|
|
|
54
41
|
taro.getApp = getApp;
|
|
55
42
|
taro.pxTransform = pxTransform;
|
|
56
43
|
taro.initPxTransform = initPxTransform;
|
|
44
|
+
// @ts-ignore
|
|
57
45
|
taro.canIUseWebp = canIUseWebp;
|
|
58
46
|
export default taro;
|
|
59
|
-
export { Behavior, getEnv, ENV_TYPE, Link, interceptors, initPxTransform, Current, options, eventCenter, Events, preload, requirePlugin, pxTransform, canIUseWebp, history, createRouter
|
|
47
|
+
export { Behavior, getEnv, ENV_TYPE, Link, interceptors, initPxTransform, Current, options, eventCenter, Events, preload, requirePlugin, pxTransform, canIUseWebp, history, createRouter };
|