@tarojs/taro-h5 3.3.18 → 3.3.19
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 +3 -0
- package/dist/api/ai/facial.js +4 -0
- package/dist/api/ai/index.js +2 -0
- package/dist/api/ai/visual.js +2 -0
- package/dist/api/alipay/index.js +2 -0
- package/dist/api/base/crypto.js +2 -0
- package/dist/api/base/debug.js +4 -0
- package/dist/api/base/index.js +16 -0
- package/dist/api/base/performance.js +3 -0
- package/dist/api/base/system/index.js +2 -0
- package/dist/api/base/system/info.js +56 -0
- package/dist/api/base/system/network.js +52 -0
- package/dist/api/base/update.js +3 -0
- package/dist/api/base/weapp/app-event.js +17 -0
- package/dist/api/base/weapp/life-cycle.js +3 -0
- package/dist/api/canvas/CanvasContext.js +182 -0
- package/dist/api/canvas/canvasGetImageData.js +21 -0
- package/dist/api/canvas/canvasPutImageData.js +17 -0
- package/dist/api/canvas/canvasToTempFilePath.js +18 -0
- package/dist/api/canvas/createCanvasContext.js +13 -0
- package/dist/api/canvas/index.js +7 -0
- package/dist/api/cloud/index.js +14 -0
- package/dist/api/data-analysis/index.js +5 -0
- package/dist/api/device/accelerometer.js +71 -0
- package/dist/api/device/accessibility.js +2 -0
- package/dist/api/device/battery.js +3 -0
- package/dist/api/device/bluetooth-ble.js +17 -0
- package/dist/api/device/bluetooth-peripheral.js +4 -0
- package/dist/api/device/bluetooth.js +14 -0
- package/dist/api/device/calendar.js +3 -0
- package/dist/api/device/clipboard.js +48 -0
- package/dist/api/device/compass.js +52 -0
- package/dist/api/device/contact.js +3 -0
- package/dist/api/device/crypto.js +2 -0
- package/dist/api/device/gyroscope.js +5 -0
- package/dist/api/device/iBeacon.js +8 -0
- package/dist/api/device/index.js +22 -0
- package/dist/api/device/keyboard.js +5 -0
- package/dist/api/device/memory.js +3 -0
- package/dist/api/device/motion.js +69 -0
- package/dist/api/device/nfc.js +8 -0
- package/dist/api/device/phone.js +23 -0
- package/dist/api/device/scan.js +5 -0
- package/dist/api/device/screen.js +7 -0
- package/dist/api/device/vibrate.js +29 -0
- package/dist/api/device/wifi.js +11 -0
- package/dist/api/ext/index.js +3 -0
- package/dist/api/files/index.js +9 -0
- package/dist/api/framework/index.js +6 -0
- package/dist/api/index.js +24 -0
- package/dist/api/location/chooseLocation.js +88 -0
- package/dist/api/location/index.js +12 -0
- package/dist/api/location/style.css +79 -0
- package/dist/api/media/audio/index.js +81 -0
- package/dist/api/media/background-audio.js +10 -0
- package/dist/api/media/camera.js +2 -0
- package/dist/api/media/editor.js +17 -0
- package/dist/api/media/image/chooseImage.js +70 -0
- package/dist/api/media/image/getImageInfo.js +27 -0
- package/dist/api/media/image/index.js +8 -0
- package/dist/api/media/image/previewImage.js +78 -0
- package/dist/api/media/index.js +13 -0
- package/dist/api/media/live.js +3 -0
- package/dist/api/media/map.js +2 -0
- package/dist/api/media/media-recorder.js +2 -0
- package/dist/api/media/recorder.js +4 -0
- package/dist/api/media/video/index.js +65 -0
- package/dist/api/media/video-decoder.js +2 -0
- package/dist/api/media/video-processing.js +2 -0
- package/dist/api/media/voip.js +15 -0
- package/dist/api/navigate/index.js +5 -0
- package/dist/api/network/download.js +101 -0
- package/dist/api/network/index.js +7 -0
- package/dist/api/network/mdns.js +11 -0
- package/dist/api/network/request/index.js +123 -0
- package/dist/api/network/tcp.js +2 -0
- package/dist/api/network/udp.js +2 -0
- package/dist/api/network/upload.js +129 -0
- package/dist/api/network/utils.js +30 -0
- package/dist/api/network/websocket/index.js +65 -0
- package/dist/api/network/websocket/socketTask.js +61 -0
- package/dist/api/open-api/account.js +2 -0
- package/dist/api/open-api/address.js +2 -0
- package/dist/api/open-api/authorize.js +3 -0
- package/dist/api/open-api/card.js +3 -0
- package/dist/api/open-api/channels-live.js +7 -0
- package/dist/api/open-api/customer-service.js +2 -0
- package/dist/api/open-api/facial.js +5 -0
- package/dist/api/open-api/favorites.js +3 -0
- package/dist/api/open-api/group.js +2 -0
- package/dist/api/open-api/index.js +18 -0
- package/dist/api/open-api/invoice.js +3 -0
- package/dist/api/open-api/license-plate.js +2 -0
- package/dist/api/open-api/login.js +4 -0
- package/dist/api/open-api/red-package.js +2 -0
- package/dist/api/open-api/settings.js +3 -0
- package/dist/api/open-api/soter.js +4 -0
- package/dist/api/open-api/subscribe-message.js +2 -0
- package/dist/api/open-api/user-info.js +3 -0
- package/dist/api/open-api/werun.js +3 -0
- package/dist/api/payment/index.js +3 -0
- package/dist/api/route/index.js +1 -0
- package/dist/api/share/index.js +11 -0
- package/dist/api/storage/background-fetch.js +5 -0
- package/dist/api/storage/index.js +152 -0
- package/dist/api/swan/index.js +22 -0
- package/dist/api/taro.js +59 -0
- package/dist/api/ui/animation/index.js +255 -0
- package/dist/api/ui/background.js +3 -0
- package/dist/api/ui/custom-component.js +2 -0
- package/dist/api/ui/fonts.js +2 -0
- package/dist/api/ui/index.js +12 -0
- package/dist/api/ui/interaction/actionSheet.js +172 -0
- package/dist/api/ui/interaction/index.js +263 -0
- package/dist/api/ui/interaction/modal.js +185 -0
- package/dist/api/ui/interaction/toast.js +179 -0
- package/dist/api/ui/menu.js +2 -0
- package/dist/api/ui/navigation-bar/index.js +37 -0
- package/dist/api/ui/pull-down-refresh.js +20 -0
- package/dist/api/ui/scroll/index.js +80 -0
- package/dist/api/ui/sticky.js +2 -0
- package/dist/api/ui/tab-bar.js +250 -0
- package/dist/api/ui/window.js +22 -0
- package/dist/api/utils/handler.js +64 -0
- package/dist/api/utils/index.js +141 -0
- package/dist/api/worker/index.js +2 -0
- package/dist/api/wxml/index.js +6 -0
- package/dist/api/wxml/nodesRef.js +35 -0
- package/dist/api/wxml/selectorQuery.js +140 -0
- package/dist/index.cjs.js +4261 -5796
- package/dist/index.js +4 -9493
- package/dist/types/type.js +2 -0
- package/package.json +8 -11
- package/src/api/network/download.ts +5 -5
- package/src/api/network/upload.ts +5 -5
- package/src/api/network/websocket/index.ts +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
import { CallbackManager } from '../utils/handler';
|
|
3
|
+
import { convertObjectUrlToBlob, NETWORK_TIMEOUT, setHeader, XHR_STATS } from './utils';
|
|
4
|
+
const createUploadTask = ({ url, filePath, formData, name, header, timeout, fileName, success, error }) => {
|
|
5
|
+
let timeoutInter;
|
|
6
|
+
let formKey;
|
|
7
|
+
const apiName = 'uploadFile';
|
|
8
|
+
const xhr = new XMLHttpRequest();
|
|
9
|
+
const form = new FormData();
|
|
10
|
+
const callbackManager = {
|
|
11
|
+
headersReceived: new CallbackManager(),
|
|
12
|
+
progressUpdate: new CallbackManager()
|
|
13
|
+
};
|
|
14
|
+
xhr.open('POST', url);
|
|
15
|
+
setHeader(xhr, header);
|
|
16
|
+
for (formKey in formData) {
|
|
17
|
+
form.append(formKey, formData[formKey]);
|
|
18
|
+
}
|
|
19
|
+
xhr.upload.onprogress = e => {
|
|
20
|
+
const { loaded, total } = e;
|
|
21
|
+
callbackManager.progressUpdate.trigger({
|
|
22
|
+
progress: Math.round(loaded / total * 100),
|
|
23
|
+
totalBytesSent: loaded,
|
|
24
|
+
totalBytesExpectedToSent: total
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
xhr.onreadystatechange = () => {
|
|
28
|
+
if (xhr.readyState !== XHR_STATS.HEADERS_RECEIVED)
|
|
29
|
+
return;
|
|
30
|
+
callbackManager.headersReceived.trigger({
|
|
31
|
+
header: xhr.getAllResponseHeaders()
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
xhr.onload = () => {
|
|
35
|
+
const status = xhr.status;
|
|
36
|
+
clearTimeout(timeoutInter);
|
|
37
|
+
success({
|
|
38
|
+
errMsg: `${apiName}:ok`,
|
|
39
|
+
statusCode: status,
|
|
40
|
+
data: xhr.responseText || xhr.response
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
xhr.onabort = () => {
|
|
44
|
+
clearTimeout(timeoutInter);
|
|
45
|
+
error({
|
|
46
|
+
errMsg: `${apiName}:fail abort`
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
xhr.onerror = (e) => {
|
|
50
|
+
clearTimeout(timeoutInter);
|
|
51
|
+
error({
|
|
52
|
+
errMsg: `${apiName}:fail ${e.message}`
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const abort = () => {
|
|
56
|
+
clearTimeout(timeoutInter);
|
|
57
|
+
xhr.abort();
|
|
58
|
+
};
|
|
59
|
+
const send = () => {
|
|
60
|
+
xhr.send(form);
|
|
61
|
+
timeoutInter = setTimeout(() => {
|
|
62
|
+
xhr.onabort = null;
|
|
63
|
+
xhr.onload = null;
|
|
64
|
+
xhr.upload.onprogress = null;
|
|
65
|
+
xhr.onreadystatechange = null;
|
|
66
|
+
xhr.onerror = null;
|
|
67
|
+
abort();
|
|
68
|
+
error({
|
|
69
|
+
errMsg: `${apiName}:fail timeout`
|
|
70
|
+
});
|
|
71
|
+
}, timeout || NETWORK_TIMEOUT);
|
|
72
|
+
};
|
|
73
|
+
convertObjectUrlToBlob(filePath)
|
|
74
|
+
.then((fileObj) => {
|
|
75
|
+
if (!fileName) {
|
|
76
|
+
fileName = typeof fileObj !== 'string' && fileObj.name;
|
|
77
|
+
}
|
|
78
|
+
form.append(name, fileObj, fileName || `file-${Date.now()}`);
|
|
79
|
+
send();
|
|
80
|
+
})
|
|
81
|
+
.catch(e => {
|
|
82
|
+
error({
|
|
83
|
+
errMsg: `${apiName}:fail ${e.message}`
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
const onHeadersReceived = callbackManager.headersReceived.add;
|
|
87
|
+
const offHeadersReceived = callbackManager.headersReceived.remove;
|
|
88
|
+
const onProgressUpdate = callbackManager.progressUpdate.add;
|
|
89
|
+
const offProgressUpdate = callbackManager.progressUpdate.remove;
|
|
90
|
+
const headersReceived = temporarilyNotSupport('UploadTask.headersReceived');
|
|
91
|
+
const progress = temporarilyNotSupport('UploadTask.progress');
|
|
92
|
+
return {
|
|
93
|
+
abort,
|
|
94
|
+
onHeadersReceived,
|
|
95
|
+
offHeadersReceived,
|
|
96
|
+
onProgressUpdate,
|
|
97
|
+
offProgressUpdate,
|
|
98
|
+
headersReceived,
|
|
99
|
+
progress
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export const uploadFile = ({ url, filePath, name, header, formData, timeout, fileName, success, fail, complete }) => {
|
|
103
|
+
let task;
|
|
104
|
+
const result = new Promise((resolve, reject) => {
|
|
105
|
+
task = createUploadTask({
|
|
106
|
+
url,
|
|
107
|
+
header,
|
|
108
|
+
name,
|
|
109
|
+
filePath,
|
|
110
|
+
formData,
|
|
111
|
+
timeout,
|
|
112
|
+
fileName,
|
|
113
|
+
success: res => {
|
|
114
|
+
success && success(res);
|
|
115
|
+
complete && complete(res);
|
|
116
|
+
resolve(res);
|
|
117
|
+
},
|
|
118
|
+
error: res => {
|
|
119
|
+
fail && fail(res);
|
|
120
|
+
complete && complete(res);
|
|
121
|
+
reject(res);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
result.headersReceive = task.onHeadersReceived;
|
|
126
|
+
result.progress = task.onProgressUpdate;
|
|
127
|
+
result.abort = task.abort;
|
|
128
|
+
return result;
|
|
129
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const NETWORK_TIMEOUT = 60000;
|
|
2
|
+
export const XHR_STATS = {
|
|
3
|
+
UNSENT: 0,
|
|
4
|
+
OPENED: 1,
|
|
5
|
+
HEADERS_RECEIVED: 2,
|
|
6
|
+
LOADING: 3,
|
|
7
|
+
DONE: 4
|
|
8
|
+
};
|
|
9
|
+
export const setHeader = (xhr, header) => {
|
|
10
|
+
let headerKey;
|
|
11
|
+
for (headerKey in header) {
|
|
12
|
+
xhr.setRequestHeader(headerKey, header[headerKey]);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export const convertObjectUrlToBlob = url => {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const xhr = new XMLHttpRequest();
|
|
18
|
+
xhr.open('GET', url, true);
|
|
19
|
+
xhr.responseType = 'blob';
|
|
20
|
+
xhr.onload = function () {
|
|
21
|
+
if (this.status === 200) {
|
|
22
|
+
resolve(this.response);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
reject({ status: this.status });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
xhr.send();
|
|
29
|
+
});
|
|
30
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { SocketTask } from './socketTask';
|
|
2
|
+
import { shouldBeObject, getParameterError } from '../../utils';
|
|
3
|
+
import { MethodHandler } from '../../utils/handler';
|
|
4
|
+
let socketTasks = [];
|
|
5
|
+
let socketsCounter = 1;
|
|
6
|
+
export function sendSocketMessage() {
|
|
7
|
+
console.warn('Deprecated.Please use socketTask.send instead.');
|
|
8
|
+
}
|
|
9
|
+
export function onSocketOpen() {
|
|
10
|
+
console.warn('Deprecated.Please use socketTask.onOpen instead.');
|
|
11
|
+
}
|
|
12
|
+
export function onSocketMessage() {
|
|
13
|
+
console.warn('Deprecated.Please use socketTask.onMessage instead.');
|
|
14
|
+
}
|
|
15
|
+
export function onSocketError() {
|
|
16
|
+
console.warn('Deprecated.Please use socketTask.onError instead.');
|
|
17
|
+
}
|
|
18
|
+
export function onSocketClose() {
|
|
19
|
+
console.warn('Deprecated.Please use socketTask.onClose instead.');
|
|
20
|
+
}
|
|
21
|
+
export function connectSocket(options) {
|
|
22
|
+
const name = 'connectSocket';
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const isObject = shouldBeObject(options);
|
|
25
|
+
if (!isObject.flag) {
|
|
26
|
+
const res = { errMsg: `${name}:fail ${isObject.msg}` };
|
|
27
|
+
console.error(res.errMsg);
|
|
28
|
+
return reject(res);
|
|
29
|
+
}
|
|
30
|
+
const { url, protocols, success, fail, complete } = options;
|
|
31
|
+
const handle = new MethodHandler({ name, success, fail, complete });
|
|
32
|
+
if (typeof url !== 'string') {
|
|
33
|
+
return handle.fail({
|
|
34
|
+
errMsg: getParameterError({
|
|
35
|
+
para: 'url',
|
|
36
|
+
correct: 'String',
|
|
37
|
+
wrong: url
|
|
38
|
+
})
|
|
39
|
+
}, reject);
|
|
40
|
+
}
|
|
41
|
+
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
42
|
+
return handle.fail({
|
|
43
|
+
errMsg: `request:fail invalid url "${url}"`
|
|
44
|
+
}, reject);
|
|
45
|
+
}
|
|
46
|
+
const _protocols = Array.isArray(protocols) ? protocols : null;
|
|
47
|
+
if (socketTasks.length > 1) {
|
|
48
|
+
return handle.fail({
|
|
49
|
+
errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
|
|
50
|
+
}, reject);
|
|
51
|
+
}
|
|
52
|
+
const task = new SocketTask(url, _protocols);
|
|
53
|
+
task._destroyWhenClose = function () {
|
|
54
|
+
socketTasks = socketTasks.filter(socketTask => socketTask !== this);
|
|
55
|
+
};
|
|
56
|
+
socketTasks.push(task);
|
|
57
|
+
handle.success({
|
|
58
|
+
socketTaskId: socketsCounter++
|
|
59
|
+
});
|
|
60
|
+
return resolve(task);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export function closeSocket() {
|
|
64
|
+
console.warn('Deprecated.Please use socketTask.close instead.');
|
|
65
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export class SocketTask {
|
|
2
|
+
constructor(url, protocols) {
|
|
3
|
+
if (protocols && protocols.length) {
|
|
4
|
+
this.ws = new WebSocket(url, protocols);
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
this.ws = new WebSocket(url);
|
|
8
|
+
}
|
|
9
|
+
this.CONNECTING = 0;
|
|
10
|
+
this.OPEN = 1;
|
|
11
|
+
this.CLOSING = 2;
|
|
12
|
+
this.CLOSED = 3;
|
|
13
|
+
}
|
|
14
|
+
get readyState() {
|
|
15
|
+
return this.ws.readyState;
|
|
16
|
+
}
|
|
17
|
+
send(opts = {}) {
|
|
18
|
+
if (typeof opts !== 'object' || !opts)
|
|
19
|
+
opts = {};
|
|
20
|
+
const { data = '', success, fail, complete } = opts;
|
|
21
|
+
if (this.readyState !== 1) {
|
|
22
|
+
const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
|
|
23
|
+
console.error(res.errMsg);
|
|
24
|
+
typeof fail === 'function' && fail(res);
|
|
25
|
+
typeof complete === 'function' && complete(res);
|
|
26
|
+
return Promise.reject(res);
|
|
27
|
+
}
|
|
28
|
+
this.ws.send(data);
|
|
29
|
+
const res = { errMsg: 'sendSocketMessage:ok' };
|
|
30
|
+
typeof success === 'function' && success(res);
|
|
31
|
+
typeof complete === 'function' && complete(res);
|
|
32
|
+
return Promise.resolve(res);
|
|
33
|
+
}
|
|
34
|
+
close(opts = {}) {
|
|
35
|
+
if (typeof opts !== 'object' || !opts)
|
|
36
|
+
opts = {};
|
|
37
|
+
const { code = 1000, reason = 'server complete,close', success, complete } = opts;
|
|
38
|
+
this.closeDetail = { code, reason };
|
|
39
|
+
this._destroyWhenClose && this._destroyWhenClose();
|
|
40
|
+
this.ws.close();
|
|
41
|
+
const res = { errMsg: 'closeSocket:ok' };
|
|
42
|
+
typeof success === 'function' && success(res);
|
|
43
|
+
typeof complete === 'function' && complete(res);
|
|
44
|
+
return Promise.resolve(res);
|
|
45
|
+
}
|
|
46
|
+
onOpen(func) {
|
|
47
|
+
this.ws.onopen = func;
|
|
48
|
+
}
|
|
49
|
+
onMessage(func) {
|
|
50
|
+
this.ws.onmessage = func;
|
|
51
|
+
}
|
|
52
|
+
onClose(func) {
|
|
53
|
+
this.ws.onclose = () => {
|
|
54
|
+
this._destroyWhenClose && this._destroyWhenClose();
|
|
55
|
+
func(this.closeDetail || { code: 1006, reason: 'abnormal closure' });
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
onError(func) {
|
|
59
|
+
this.ws.onerror = func;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const reserveChannelsLive = temporarilyNotSupport('reserveChannelsLive');
|
|
3
|
+
export const openChannelsLive = temporarilyNotSupport('openChannelsLive');
|
|
4
|
+
export const openChannelsEvent = temporarilyNotSupport('openChannelsEvent');
|
|
5
|
+
export const openChannelsActivity = temporarilyNotSupport('openChannelsActivity');
|
|
6
|
+
export const getChannelsLiveNoticeInfo = temporarilyNotSupport('getChannelsLiveNoticeInfo');
|
|
7
|
+
export const getChannelsLiveInfo = temporarilyNotSupport('getChannelsLiveInfo');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const checkIsSupportFacialRecognition = temporarilyNotSupport('checkIsSupportFacialRecognition');
|
|
3
|
+
export const startFacialRecognitionVerify = temporarilyNotSupport('startFacialRecognitionVerify');
|
|
4
|
+
export const startFacialRecognitionVerifyAndUploadVideo = temporarilyNotSupport('startFacialRecognitionVerifyAndUploadVideo');
|
|
5
|
+
export const faceVerifyForPay = temporarilyNotSupport('faceVerifyForPay');
|
|
@@ -0,0 +1,18 @@
|
|
|
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';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const startSoterAuthentication = temporarilyNotSupport('startSoterAuthentication');
|
|
3
|
+
export const checkIsSupportSoterAuthentication = temporarilyNotSupport('checkIsSupportSoterAuthentication');
|
|
4
|
+
export const checkIsSoterEnrolledInDevice = temporarilyNotSupport('checkIsSoterEnrolledInDevice');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { switchTab, reLaunch, redirectTo, navigateTo, navigateBack } from '@tarojs/router';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const updateShareMenu = temporarilyNotSupport('updateShareMenu');
|
|
3
|
+
export const showShareMenu = temporarilyNotSupport('showShareMenu');
|
|
4
|
+
export const showShareImageMenu = temporarilyNotSupport('showShareImageMenu');
|
|
5
|
+
export const shareVideoMessage = temporarilyNotSupport('shareVideoMessage');
|
|
6
|
+
export const shareFileMessage = temporarilyNotSupport('shareFileMessage');
|
|
7
|
+
export const onCopyUrl = temporarilyNotSupport('onCopyUrl');
|
|
8
|
+
export const offCopyUrl = temporarilyNotSupport('offCopyUrl');
|
|
9
|
+
export const hideShareMenu = temporarilyNotSupport('hideShareMenu');
|
|
10
|
+
export const getShareInfo = temporarilyNotSupport('getShareInfo');
|
|
11
|
+
export const authPrivateMessage = temporarilyNotSupport('authPrivateMessage');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const setBackgroundFetchToken = temporarilyNotSupport('setBackgroundFetchToken');
|
|
3
|
+
export const onBackgroundFetchData = temporarilyNotSupport('onBackgroundFetchData');
|
|
4
|
+
export const getBackgroundFetchToken = temporarilyNotSupport('getBackgroundFetchToken');
|
|
5
|
+
export const getBackgroundFetchData = temporarilyNotSupport('getBackgroundFetchData');
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { shouldBeObject, getParameterError, temporarilyNotSupport } from '../utils';
|
|
2
|
+
import { MethodHandler } from '../utils/handler';
|
|
3
|
+
function getItem(key) {
|
|
4
|
+
let item;
|
|
5
|
+
try {
|
|
6
|
+
item = JSON.parse(localStorage.getItem(key) || '');
|
|
7
|
+
}
|
|
8
|
+
catch (e) { }
|
|
9
|
+
if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
|
|
10
|
+
return { result: true, data: item.data };
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return { result: false };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export const setStorageSync = (key, data = '') => {
|
|
17
|
+
if (typeof key !== 'string') {
|
|
18
|
+
console.error(getParameterError({
|
|
19
|
+
name: 'setStorage',
|
|
20
|
+
correct: 'String',
|
|
21
|
+
wrong: key
|
|
22
|
+
}));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const type = typeof data;
|
|
26
|
+
let obj = {};
|
|
27
|
+
if (type === 'symbol') {
|
|
28
|
+
obj = { data: '' };
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
obj = { data };
|
|
32
|
+
}
|
|
33
|
+
localStorage.setItem(key, JSON.stringify(obj));
|
|
34
|
+
};
|
|
35
|
+
export const setStorage = (options) => {
|
|
36
|
+
const isObject = shouldBeObject(options);
|
|
37
|
+
if (!isObject.flag) {
|
|
38
|
+
const res = { errMsg: `setStorage:fail ${isObject.msg}` };
|
|
39
|
+
console.error(res.errMsg);
|
|
40
|
+
return Promise.reject(res);
|
|
41
|
+
}
|
|
42
|
+
const { key, data, success, fail, complete } = options;
|
|
43
|
+
const handle = new MethodHandler({ name: 'setStorage', success, fail, complete });
|
|
44
|
+
if (typeof key !== 'string') {
|
|
45
|
+
return handle.fail({
|
|
46
|
+
errMsg: getParameterError({
|
|
47
|
+
para: 'key',
|
|
48
|
+
correct: 'String',
|
|
49
|
+
wrong: key
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
setStorageSync(key, data);
|
|
54
|
+
return handle.success();
|
|
55
|
+
};
|
|
56
|
+
export const revokeBufferURL = temporarilyNotSupport('revokeBufferURL');
|
|
57
|
+
export const removeStorageSync = (key) => {
|
|
58
|
+
if (typeof key !== 'string') {
|
|
59
|
+
console.error(getParameterError({
|
|
60
|
+
name: 'removeStorage',
|
|
61
|
+
correct: 'String',
|
|
62
|
+
wrong: key
|
|
63
|
+
}));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
localStorage.removeItem(key);
|
|
67
|
+
};
|
|
68
|
+
export const removeStorage = (options) => {
|
|
69
|
+
const isObject = shouldBeObject(options);
|
|
70
|
+
if (!isObject.flag) {
|
|
71
|
+
const res = { errMsg: `removeStorage:fail ${isObject.msg}` };
|
|
72
|
+
console.error(res.errMsg);
|
|
73
|
+
return Promise.reject(res);
|
|
74
|
+
}
|
|
75
|
+
const { key, success, fail, complete } = options;
|
|
76
|
+
const handle = new MethodHandler({ name: 'removeStorage', success, fail, complete });
|
|
77
|
+
if (typeof key !== 'string') {
|
|
78
|
+
return handle.fail({
|
|
79
|
+
errMsg: getParameterError({
|
|
80
|
+
para: 'key',
|
|
81
|
+
correct: 'String',
|
|
82
|
+
wrong: key
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
removeStorageSync(key);
|
|
87
|
+
return handle.success();
|
|
88
|
+
};
|
|
89
|
+
export const getStorageSync = (key) => {
|
|
90
|
+
if (typeof key !== 'string') {
|
|
91
|
+
console.error(getParameterError({
|
|
92
|
+
name: 'getStorageSync',
|
|
93
|
+
correct: 'String',
|
|
94
|
+
wrong: key
|
|
95
|
+
}));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const res = getItem(key);
|
|
99
|
+
if (res.result)
|
|
100
|
+
return res.data;
|
|
101
|
+
return '';
|
|
102
|
+
};
|
|
103
|
+
export const getStorageInfoSync = () => {
|
|
104
|
+
const res = {
|
|
105
|
+
keys: Object.keys(localStorage),
|
|
106
|
+
limitSize: NaN,
|
|
107
|
+
currentSize: NaN
|
|
108
|
+
};
|
|
109
|
+
return res;
|
|
110
|
+
};
|
|
111
|
+
export const getStorageInfo = ({ success, fail, complete } = {}) => {
|
|
112
|
+
const handle = new MethodHandler({ name: 'getStorageInfo', success, fail, complete });
|
|
113
|
+
return handle.success(getStorageInfoSync());
|
|
114
|
+
};
|
|
115
|
+
export const getStorage = (options) => {
|
|
116
|
+
const isObject = shouldBeObject(options);
|
|
117
|
+
if (!isObject.flag) {
|
|
118
|
+
const res = { errMsg: `getStorage:fail ${isObject.msg}` };
|
|
119
|
+
console.error(res.errMsg);
|
|
120
|
+
return Promise.reject(res);
|
|
121
|
+
}
|
|
122
|
+
const { key, success, fail, complete } = options;
|
|
123
|
+
const handle = new MethodHandler({ name: 'getStorage', success, fail, complete });
|
|
124
|
+
if (typeof key !== 'string') {
|
|
125
|
+
return handle.fail({
|
|
126
|
+
errMsg: getParameterError({
|
|
127
|
+
para: 'key',
|
|
128
|
+
correct: 'String',
|
|
129
|
+
wrong: key
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const { result, data } = getItem(key);
|
|
134
|
+
if (result) {
|
|
135
|
+
return handle.success({ data });
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
return handle.fail({
|
|
139
|
+
errMsg: 'data not found'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export const createBufferURL = temporarilyNotSupport('createBufferURL');
|
|
144
|
+
export const clearStorageSync = () => {
|
|
145
|
+
localStorage.clear();
|
|
146
|
+
};
|
|
147
|
+
export const clearStorage = ({ success, fail, complete } = {}) => {
|
|
148
|
+
const handle = new MethodHandler({ name: 'clearStorage', success, fail, complete });
|
|
149
|
+
clearStorageSync();
|
|
150
|
+
return handle.success();
|
|
151
|
+
};
|
|
152
|
+
export * from './background-fetch';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const setPageInfo = temporarilyNotSupport('setPageInfo');
|
|
3
|
+
export const ocrIdCard = temporarilyNotSupport('ocrIdCard');
|
|
4
|
+
export const ocrBankCard = temporarilyNotSupport('ocrBankCard');
|
|
5
|
+
export const ocrDrivingLicense = temporarilyNotSupport('ocrDrivingLicense');
|
|
6
|
+
export const ocrVehicleLicense = temporarilyNotSupport('ocrVehicleLicense');
|
|
7
|
+
export const textReview = temporarilyNotSupport('textReview');
|
|
8
|
+
export const textToAudio = temporarilyNotSupport('textToAudio');
|
|
9
|
+
export const imageAudit = temporarilyNotSupport('imageAudit');
|
|
10
|
+
export const advancedGeneralIdentify = temporarilyNotSupport('advancedGeneralIdentify');
|
|
11
|
+
export const objectDetectIdentify = temporarilyNotSupport('objectDetectIdentify');
|
|
12
|
+
export const carClassify = temporarilyNotSupport('carClassify');
|
|
13
|
+
export const dishClassify = temporarilyNotSupport('dishClassify');
|
|
14
|
+
export const logoClassify = temporarilyNotSupport('logoClassify');
|
|
15
|
+
export const animalClassify = temporarilyNotSupport('animalClassify');
|
|
16
|
+
export const plantClassify = temporarilyNotSupport('plantClassify');
|
|
17
|
+
export const getSwanId = temporarilyNotSupport('getSwanId');
|
|
18
|
+
export const requestPolymerPayment = temporarilyNotSupport('requestPolymerPayment');
|
|
19
|
+
export const navigateToSmartGameProgram = temporarilyNotSupport('navigateToSmartGameProgram');
|
|
20
|
+
export const navigateToSmartProgram = temporarilyNotSupport('navigateToSmartProgram');
|
|
21
|
+
export const navigateBackSmartProgram = temporarilyNotSupport('navigateBackSmartProgram');
|
|
22
|
+
export const preloadSubPackage = temporarilyNotSupport('preloadSubPackage');
|
package/dist/api/taro.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
2
|
+
import { history, createRouter } from '@tarojs/router';
|
|
3
|
+
import { getApp, getCurrentInstance, getCurrentPages, nextTick, navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from '../api';
|
|
4
|
+
import { permanentlyNotSupport } from '../api/utils';
|
|
5
|
+
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload, useDidShow, useDidHide, usePullDownRefresh, useReachBottom, usePageScroll, useResize, useShareAppMessage, useTabItemTap, useTitleClick, useOptionMenuClick, usePullIntercept, useShareTimeline, useAddToFavorites, useReady, useRouter } = Taro;
|
|
6
|
+
const taro = {
|
|
7
|
+
Behavior,
|
|
8
|
+
getEnv,
|
|
9
|
+
ENV_TYPE,
|
|
10
|
+
Link,
|
|
11
|
+
interceptors,
|
|
12
|
+
Current,
|
|
13
|
+
getCurrentInstance,
|
|
14
|
+
options,
|
|
15
|
+
nextTick,
|
|
16
|
+
eventCenter,
|
|
17
|
+
Events,
|
|
18
|
+
preload,
|
|
19
|
+
history,
|
|
20
|
+
createRouter,
|
|
21
|
+
navigateBack,
|
|
22
|
+
navigateTo,
|
|
23
|
+
reLaunch,
|
|
24
|
+
redirectTo,
|
|
25
|
+
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
|
|
42
|
+
};
|
|
43
|
+
const initPxTransform = getInitPxTransform(taro);
|
|
44
|
+
const requirePlugin = permanentlyNotSupport('requirePlugin');
|
|
45
|
+
const pxTransform = function (size) {
|
|
46
|
+
const { designWidth } = taro.config;
|
|
47
|
+
return Math.ceil((((parseInt(size, 10) / 40) * 640) / designWidth) * 10000) / 10000 + 'rem';
|
|
48
|
+
};
|
|
49
|
+
const canIUseWebp = function () {
|
|
50
|
+
const canvas = document.createElement('canvas');
|
|
51
|
+
return canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0;
|
|
52
|
+
};
|
|
53
|
+
taro.requirePlugin = requirePlugin;
|
|
54
|
+
taro.getApp = getApp;
|
|
55
|
+
taro.pxTransform = pxTransform;
|
|
56
|
+
taro.initPxTransform = initPxTransform;
|
|
57
|
+
taro.canIUseWebp = canIUseWebp;
|
|
58
|
+
export default taro;
|
|
59
|
+
export { Behavior, getEnv, ENV_TYPE, Link, interceptors, initPxTransform, Current, options, eventCenter, Events, preload, requirePlugin, pxTransform, canIUseWebp, history, createRouter, useDidShow, useDidHide, usePullDownRefresh, useReachBottom, usePageScroll, useResize, useShareAppMessage, useTabItemTap, useTitleClick, useOptionMenuClick, usePullIntercept, useShareTimeline, useAddToFavorites, useReady, useRouter };
|