@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
package/dist/api/ad/index.js
CHANGED
package/dist/api/ai/facial.js
CHANGED
package/dist/api/ai/visual.js
CHANGED
package/dist/api/alipay/index.js
CHANGED
package/dist/api/base/crypto.js
CHANGED
package/dist/api/base/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fromByteArray, toByteArray } from 'base64-js';
|
|
2
2
|
import { temporarilyNotSupport } from '../utils';
|
|
3
|
+
// TODO env 环境变量
|
|
3
4
|
export const canIUse = temporarilyNotSupport('canIUse');
|
|
4
5
|
export function arrayBufferToBase64(arrayBuffer) {
|
|
5
6
|
return fromByteArray(arrayBuffer);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MethodHandler } from '../../utils/handler';
|
|
2
2
|
import { temporarilyNotSupport } from '../../utils';
|
|
3
3
|
function getConnection() {
|
|
4
|
+
// @ts-ignore
|
|
4
5
|
return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection;
|
|
5
6
|
}
|
|
6
7
|
export const getNetworkType = (options = {}) => {
|
|
@@ -8,28 +9,38 @@ export const getNetworkType = (options = {}) => {
|
|
|
8
9
|
const { success, fail, complete } = options;
|
|
9
10
|
const handle = new MethodHandler({ name: 'getNetworkType', success, fail, complete });
|
|
10
11
|
let networkType = 'unknown';
|
|
12
|
+
// 浏览器不支持获取网络状态
|
|
11
13
|
if (!connection) {
|
|
12
14
|
return handle.success({ networkType });
|
|
13
15
|
}
|
|
16
|
+
// Supports only the navigator.connection.type value which doesn't match the latest spec.
|
|
17
|
+
// https://www.davidbcalhoun.com/2010/using-navigator-connection-android/
|
|
14
18
|
if (!isNaN(Number(connection.type))) {
|
|
15
19
|
switch (connection.type) {
|
|
20
|
+
// @ts-ignore
|
|
16
21
|
case connection.WIFI:
|
|
17
22
|
networkType = 'wifi';
|
|
18
23
|
break;
|
|
24
|
+
// @ts-ignore
|
|
19
25
|
case connection.CELL_3G:
|
|
20
26
|
networkType = '3g';
|
|
21
27
|
break;
|
|
28
|
+
// @ts-ignore
|
|
22
29
|
case connection.CELL_2G:
|
|
23
30
|
networkType = '2g';
|
|
24
31
|
break;
|
|
25
32
|
default:
|
|
33
|
+
// ETHERNET, UNKNOWN
|
|
26
34
|
networkType = 'unknown';
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
else if (connection.type) {
|
|
30
|
-
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
networkType = connection.type; // Only supports the type value.
|
|
40
|
+
// @ts-ignore
|
|
31
41
|
}
|
|
32
42
|
else if (connection.effectiveType) {
|
|
43
|
+
// @ts-ignore
|
|
33
44
|
networkType = connection.effectiveType;
|
|
34
45
|
}
|
|
35
46
|
return handle.success({ networkType });
|
package/dist/api/base/update.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils';
|
|
2
|
+
// 应用级事件
|
|
2
3
|
export const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection');
|
|
3
4
|
export const onThemeChange = temporarilyNotSupport('onThemeChange');
|
|
4
5
|
export const onPageNotFound = temporarilyNotSupport('onPageNotFound');
|
|
@@ -53,6 +53,7 @@ export class CanvasContext {
|
|
|
53
53
|
get shadowOffsetY() { return this.ctx.shadowOffsetY; }
|
|
54
54
|
set strokeStyle(e) { this.enqueueActions(() => { this.ctx.strokeStyle = e; }); }
|
|
55
55
|
get strokeStyle() { return this.ctx.strokeStyle; }
|
|
56
|
+
/** 小程序文档中不包括 ↓↓↓ */
|
|
56
57
|
set textAlign(e) { this.ctx.textAlign = e; }
|
|
57
58
|
get textAlign() { return this.ctx.textAlign; }
|
|
58
59
|
set textBaseline(e) { this.ctx.textBaseline = e; }
|
|
@@ -65,6 +66,7 @@ export class CanvasContext {
|
|
|
65
66
|
get imageSmoothingQuality() { return this.ctx.imageSmoothingQuality; }
|
|
66
67
|
set filter(e) { this.enqueueActions(() => { this.ctx.filter = e; }); }
|
|
67
68
|
get filter() { return this.ctx.filter; }
|
|
69
|
+
/** 小程序文档中不包括 ↑↑↑ */
|
|
68
70
|
arc(...args) { return this.enqueueActions(this.ctx.arc, ...args); }
|
|
69
71
|
arcTo(...args) { return this.enqueueActions(this.ctx.arcTo, ...args); }
|
|
70
72
|
beginPath(...args) { return this.enqueueActions(this.ctx.beginPath, ...args); }
|
|
@@ -75,11 +77,16 @@ export class CanvasContext {
|
|
|
75
77
|
createPattern(image, repetition) {
|
|
76
78
|
return this.createPattern(image, repetition);
|
|
77
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。
|
|
82
|
+
* @todo 每次 draw 都会读取 width 和 height
|
|
83
|
+
*/
|
|
78
84
|
async draw(reserve, callback) {
|
|
79
85
|
try {
|
|
80
86
|
if (!reserve) {
|
|
81
87
|
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
82
88
|
}
|
|
89
|
+
// 部分 action 是异步的
|
|
83
90
|
for (const { func, args } of this.actions) {
|
|
84
91
|
await func.apply(this.ctx, args);
|
|
85
92
|
}
|
|
@@ -87,6 +94,7 @@ export class CanvasContext {
|
|
|
87
94
|
callback && callback();
|
|
88
95
|
}
|
|
89
96
|
catch (e) {
|
|
97
|
+
/* eslint-disable no-throw-literal */
|
|
90
98
|
throw {
|
|
91
99
|
errMsg: e.message
|
|
92
100
|
};
|
|
@@ -94,6 +102,7 @@ export class CanvasContext {
|
|
|
94
102
|
}
|
|
95
103
|
drawImage(imageResource, ...extra) {
|
|
96
104
|
this.enqueueActions(() => {
|
|
105
|
+
// 需要转换为 Image
|
|
97
106
|
if (typeof imageResource === 'string') {
|
|
98
107
|
const img = new Image();
|
|
99
108
|
img.src = imageResource;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { MethodHandler } from '../utils/handler';
|
|
2
2
|
import { findDOM } from '../utils';
|
|
3
|
+
/**
|
|
4
|
+
* 获取 canvas 区域隐含的像素数据。
|
|
5
|
+
*/
|
|
3
6
|
export const canvasGetImageData = ({ canvasId, success, fail, complete, x, y, width, height }, inst) => {
|
|
4
7
|
const handle = new MethodHandler({ name: 'canvasGetImageData', success, fail, complete });
|
|
5
8
|
const el = findDOM(inst);
|
|
6
9
|
const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
|
|
7
10
|
try {
|
|
8
11
|
const ctx = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d');
|
|
12
|
+
// TODO ImageData => Uint8ClampedArray
|
|
9
13
|
const data = ctx === null || ctx === void 0 ? void 0 : ctx.getImageData(x, y, width, height);
|
|
10
14
|
return handle.success({
|
|
11
15
|
width,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { MethodHandler } from '../utils/handler';
|
|
2
2
|
import { findDOM } from '../utils';
|
|
3
|
+
/**
|
|
4
|
+
* 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 <canvas> 组件
|
|
5
|
+
* @todo 暂未支持尺寸相关功能
|
|
6
|
+
*/
|
|
3
7
|
export const canvasPutImageData = ({ canvasId, data, x, y, success, fail, complete }, inst) => {
|
|
4
8
|
const handle = new MethodHandler({ name: 'canvasPutImageData', success, fail, complete });
|
|
5
9
|
const el = findDOM(inst);
|
|
6
10
|
const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
|
|
7
11
|
try {
|
|
8
12
|
const ctx = canvas.getContext('2d');
|
|
13
|
+
// TODO Uint8ClampedArray => ImageData
|
|
9
14
|
ctx === null || ctx === void 0 ? void 0 : ctx.putImageData(data, x, y);
|
|
10
15
|
return handle.success();
|
|
11
16
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { findDOM } from '../utils';
|
|
2
2
|
import { MethodHandler } from '../utils/handler';
|
|
3
|
+
/**
|
|
4
|
+
* 把当前画布指定区域的内容导出生成指定大小的图片。在 draw() 回调里调用该方法才能保证图片导出成功。
|
|
5
|
+
* @todo 暂未支持尺寸相关功能
|
|
6
|
+
*/
|
|
3
7
|
export const canvasToTempFilePath = ({ canvasId, fileType, quality, success, fail, complete }, inst) => {
|
|
4
8
|
const handle = new MethodHandler({ name: 'canvasToTempFilePath', success, fail, complete });
|
|
5
9
|
const el = findDOM(inst);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { findDOM } from '../utils';
|
|
2
2
|
import { CanvasContext } from './CanvasContext';
|
|
3
|
+
/**
|
|
4
|
+
* 创建 canvas 的绘图上下文 CanvasContext 对象
|
|
5
|
+
*/
|
|
3
6
|
export const createCanvasContext = (canvasId, inst) => {
|
|
4
7
|
const el = findDOM(inst);
|
|
5
8
|
const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
|
package/dist/api/canvas/index.js
CHANGED
package/dist/api/cloud/index.js
CHANGED
|
@@ -4,10 +4,13 @@ export class cloud {
|
|
|
4
4
|
this.init = temporarilyNotSupport('cloud.init');
|
|
5
5
|
this.CloudID = temporarilyNotSupport('cloud.CloudID');
|
|
6
6
|
this.callFunction = temporarilyNotSupport('cloud.callFunction');
|
|
7
|
+
// @ts-ignore
|
|
7
8
|
this.uploadFile = temporarilyNotSupport('cloud.uploadFile');
|
|
9
|
+
// @ts-ignore
|
|
8
10
|
this.downloadFile = temporarilyNotSupport('cloud.downloadFile');
|
|
9
11
|
this.getTempFileURL = temporarilyNotSupport('cloud.getTempFileURL');
|
|
10
12
|
this.deleteFile = temporarilyNotSupport('cloud.deleteFile');
|
|
13
|
+
// @ts-ignore
|
|
11
14
|
this.database = temporarilyNotSupport('cloud.database');
|
|
12
15
|
this.callContainer = temporarilyNotSupport('cloud.callContainer');
|
|
13
16
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { CallbackManager, MethodHandler } from '../utils/handler';
|
|
2
2
|
const callbackManager = new CallbackManager();
|
|
3
3
|
let devicemotionListener;
|
|
4
|
+
/**
|
|
5
|
+
* 停止监听加速度数据。
|
|
6
|
+
*/
|
|
4
7
|
export const stopAccelerometer = ({ success, fail, complete } = {}) => {
|
|
5
8
|
const res = {};
|
|
6
9
|
const handle = new MethodHandler({ name: 'stopAccelerometer', success, fail, complete });
|
|
@@ -43,6 +46,9 @@ const getDevicemotionListener = interval => {
|
|
|
43
46
|
timer = setTimeout(() => { lock = false; }, interval);
|
|
44
47
|
};
|
|
45
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* 开始监听加速度数据。
|
|
51
|
+
*/
|
|
46
52
|
export const startAccelerometer = ({ interval = 'normal', success, fail, complete } = {}) => {
|
|
47
53
|
const handle = new MethodHandler({ name: 'startAccelerometer', success, fail, complete });
|
|
48
54
|
try {
|
|
@@ -63,9 +69,15 @@ export const startAccelerometer = ({ interval = 'normal', success, fail, complet
|
|
|
63
69
|
return handle.fail({ errMsg: e.message });
|
|
64
70
|
}
|
|
65
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* 监听加速度数据事件。频率根据 Taro.startAccelerometer() 的 interval 参数。可使用 Taro.stopAccelerometer() 停止监听。
|
|
74
|
+
*/
|
|
66
75
|
export const onAccelerometerChange = callback => {
|
|
67
76
|
callbackManager.add(callback);
|
|
68
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* 取消监听加速度数据事件,参数为空,则取消所有的事件监听
|
|
80
|
+
*/
|
|
69
81
|
export const offAccelerometerChange = callback => {
|
|
70
82
|
callbackManager.remove(callback);
|
|
71
83
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 蓝牙-低功耗中心设备
|
|
2
3
|
export const writeBLECharacteristicValue = temporarilyNotSupport('writeBLECharacteristicValue');
|
|
3
4
|
export const setBLEMTU = temporarilyNotSupport('setBLEMTU');
|
|
4
5
|
export const readBLECharacteristicValue = temporarilyNotSupport('readBLECharacteristicValue');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 蓝牙-低功耗外围设备
|
|
2
3
|
export const onBLEPeripheralConnectionStateChanged = temporarilyNotSupport('onBLEPeripheralConnectionStateChanged');
|
|
3
4
|
export const offBLEPeripheralConnectionStateChanged = temporarilyNotSupport('offBLEPeripheralConnectionStateChanged');
|
|
4
5
|
export const createBLEPeripheralServer = temporarilyNotSupport('createBLEPeripheralServer');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 蓝牙-通用
|
|
2
3
|
export const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery');
|
|
3
4
|
export const startBluetoothDevicesDiscovery = temporarilyNotSupport('startBluetoothDevicesDiscovery');
|
|
4
5
|
export const openBluetoothAdapter = temporarilyNotSupport('openBluetoothAdapter');
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 剪贴板部分的api参考了Chameleon项目的实现:
|
|
3
|
+
*
|
|
4
|
+
* setClipboardData: https://github.com/chameleon-team/chameleon-api/tree/master/src/interfaces/setClipBoardData
|
|
5
|
+
* getClipboardData: https://github.com/chameleon-team/chameleon-api/tree/master/src/interfaces/getClipBoardData
|
|
6
|
+
*/
|
|
1
7
|
import { setStorage, setStorageSync, getStorageSync } from '../storage/index';
|
|
2
8
|
import { MethodHandler } from '../utils/handler';
|
|
3
9
|
const CLIPBOARD_STORAGE_NAME = 'taro_clipboard';
|
|
@@ -10,10 +16,18 @@ document.addEventListener('copy', () => {
|
|
|
10
16
|
console.error(e);
|
|
11
17
|
});
|
|
12
18
|
});
|
|
19
|
+
/**
|
|
20
|
+
* 设置系统剪贴板的内容
|
|
21
|
+
*/
|
|
13
22
|
export const setClipboardData = async ({ data, success, fail, complete }) => {
|
|
14
23
|
const handle = new MethodHandler({ name: 'setClipboardData', success, fail, complete });
|
|
15
24
|
try {
|
|
16
25
|
setStorageSync(CLIPBOARD_STORAGE_NAME, data);
|
|
26
|
+
/**
|
|
27
|
+
* 已于 iPhone 6s Plus iOS 13.1.3 上的 Safari 测试通过
|
|
28
|
+
* iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
|
|
29
|
+
* https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
|
|
30
|
+
*/
|
|
17
31
|
if (typeof document.execCommand === 'function') {
|
|
18
32
|
const textarea = document.createElement('textarea');
|
|
19
33
|
textarea.readOnly = true;
|
|
@@ -36,6 +50,9 @@ export const setClipboardData = async ({ data, success, fail, complete }) => {
|
|
|
36
50
|
return handle.fail({ errMsg: e.message });
|
|
37
51
|
}
|
|
38
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* 获取系统剪贴板的内容
|
|
55
|
+
*/
|
|
39
56
|
export const getClipboardData = async ({ success, fail, complete } = {}) => {
|
|
40
57
|
const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
|
|
41
58
|
try {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { CallbackManager, MethodHandler } from '../utils/handler';
|
|
2
2
|
const callbackManager = new CallbackManager();
|
|
3
3
|
let compassListener;
|
|
4
|
+
/**
|
|
5
|
+
* 停止监听罗盘数据
|
|
6
|
+
*/
|
|
4
7
|
export const stopCompass = ({ success, fail, complete } = {}) => {
|
|
5
8
|
const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete });
|
|
6
9
|
try {
|
|
@@ -25,6 +28,9 @@ const getDeviceOrientationListener = interval => {
|
|
|
25
28
|
timer = setTimeout(() => { lock = false; }, interval);
|
|
26
29
|
};
|
|
27
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* 开始监听罗盘数据
|
|
33
|
+
*/
|
|
28
34
|
export const startCompass = ({ success, fail, complete } = {}) => {
|
|
29
35
|
const handle = new MethodHandler({ name: 'startCompass', success, fail, complete });
|
|
30
36
|
try {
|
|
@@ -44,9 +50,15 @@ export const startCompass = ({ success, fail, complete } = {}) => {
|
|
|
44
50
|
return handle.fail({ errMsg: e.message });
|
|
45
51
|
}
|
|
46
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
|
|
55
|
+
*/
|
|
47
56
|
export const onCompassChange = callback => {
|
|
48
57
|
callbackManager.add(callback);
|
|
49
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
|
|
61
|
+
*/
|
|
50
62
|
export const offCompassChange = callback => {
|
|
51
63
|
callbackManager.remove(callback);
|
|
52
64
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 陀螺仪
|
|
2
3
|
export const stopGyroscope = temporarilyNotSupport('stopGyroscope');
|
|
3
4
|
export const startGyroscope = temporarilyNotSupport('startGyroscope');
|
|
4
5
|
export const onGyroscopeChange = temporarilyNotSupport('onGyroscopeChange');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 蓝牙-信标(Beacon)
|
|
2
3
|
export const stopBeaconDiscovery = temporarilyNotSupport('stopBeaconDiscovery');
|
|
3
4
|
export const startBeaconDiscovery = temporarilyNotSupport('startBeaconDiscovery');
|
|
4
5
|
export const onBeaconUpdate = temporarilyNotSupport('onBeaconUpdate');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 键盘
|
|
2
3
|
export const onKeyboardHeightChange = temporarilyNotSupport('onKeyboardHeightChange');
|
|
3
4
|
export const offKeyboardHeightChange = temporarilyNotSupport('offKeyboardHeightChange');
|
|
4
5
|
export const hideKeyboard = temporarilyNotSupport('hideKeyboard');
|
|
@@ -15,6 +15,9 @@ const INTERVAL_MAP = {
|
|
|
15
15
|
frequency: 5
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* 停止监听设备方向的变化。
|
|
20
|
+
*/
|
|
18
21
|
export const stopDeviceMotionListening = ({ success, fail, complete } = {}) => {
|
|
19
22
|
const handle = new MethodHandler({ name: 'stopDeviceMotionListening', success, fail, complete });
|
|
20
23
|
try {
|
|
@@ -41,6 +44,9 @@ const getDeviceOrientationListener = interval => {
|
|
|
41
44
|
timer = setTimeout(() => { lock = false; }, interval);
|
|
42
45
|
};
|
|
43
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* 开始监听设备方向的变化。
|
|
49
|
+
*/
|
|
44
50
|
export const startDeviceMotionListening = ({ interval = 'normal', success, fail, complete } = {}) => {
|
|
45
51
|
const handle = new MethodHandler({ name: 'startDeviceMotionListening', success, fail, complete });
|
|
46
52
|
try {
|
|
@@ -61,9 +67,15 @@ export const startDeviceMotionListening = ({ interval = 'normal', success, fail,
|
|
|
61
67
|
return handle.fail({ errMsg: e.message });
|
|
62
68
|
}
|
|
63
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* 监听设备方向变化事件。
|
|
72
|
+
*/
|
|
64
73
|
export const onDeviceMotionChange = callback => {
|
|
65
74
|
callbackManager.add(callback);
|
|
66
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* 取消监听设备方向变化事件,参数为空,则取消所有的事件监听。
|
|
78
|
+
*/
|
|
67
79
|
export const offDeviceMotionChange = callback => {
|
|
68
80
|
callbackManager.remove(callback);
|
|
69
81
|
};
|
package/dist/api/device/nfc.js
CHANGED
package/dist/api/device/phone.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { shouldBeObject, getParameterError } from '../utils';
|
|
2
2
|
import { MethodHandler } from '../utils/handler';
|
|
3
3
|
export const makePhoneCall = (options) => {
|
|
4
|
+
// options must be an Object
|
|
4
5
|
const isObject = shouldBeObject(options);
|
|
5
6
|
if (!isObject.flag) {
|
|
6
7
|
const res = { errMsg: `makePhoneCall:fail ${isObject.msg}` };
|
package/dist/api/device/scan.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 屏幕
|
|
2
3
|
export const setVisualEffectOnCapture = temporarilyNotSupport('setVisualEffectOnCapture');
|
|
3
4
|
export const setScreenBrightness = temporarilyNotSupport('setScreenBrightness');
|
|
4
5
|
export const setKeepScreenOn = temporarilyNotSupport('setKeepScreenOn');
|
|
@@ -7,6 +7,9 @@ const vibrator = function vibrator(mm) {
|
|
|
7
7
|
console.warn('当前浏览器不支持vibrate');
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* 使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
|
|
12
|
+
*/
|
|
10
13
|
export const vibrateShort = ({ success, fail, complete } = {}) => {
|
|
11
14
|
const handle = new MethodHandler({ name: 'vibrateShort', success, fail, complete });
|
|
12
15
|
if (vibrator) {
|
|
@@ -17,6 +20,9 @@ export const vibrateShort = ({ success, fail, complete } = {}) => {
|
|
|
17
20
|
return handle.fail();
|
|
18
21
|
}
|
|
19
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* 使手机发生较长时间的振动(400 ms)
|
|
25
|
+
*/
|
|
20
26
|
export const vibrateLong = ({ success, fail, complete } = {}) => {
|
|
21
27
|
const handle = new MethodHandler({ name: 'vibrateLong', success, fail, complete });
|
|
22
28
|
if (vibrator) {
|
package/dist/api/device/wifi.js
CHANGED
package/dist/api/ext/index.js
CHANGED
package/dist/api/files/index.js
CHANGED
|
@@ -44,6 +44,9 @@ function createLocationChooser(handler, key = LOCATION_APIKEY) {
|
|
|
44
44
|
container
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* 打开地图选择位置。
|
|
49
|
+
*/
|
|
47
50
|
export const chooseLocation = ({ success, fail, complete } = {}) => {
|
|
48
51
|
const key = LOCATION_APIKEY;
|
|
49
52
|
const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete });
|
|
@@ -56,7 +59,9 @@ export const chooseLocation = ({ success, fail, complete } = {}) => {
|
|
|
56
59
|
}, reject);
|
|
57
60
|
}
|
|
58
61
|
const onMessage = event => {
|
|
62
|
+
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
59
63
|
const loc = event.data;
|
|
64
|
+
// 防止其他应用也会向该页面 post 信息,需判断 module 是否为'locationPicker'
|
|
60
65
|
if (!loc || loc.module !== 'locationPicker')
|
|
61
66
|
return;
|
|
62
67
|
chooseLocation.name = loc.poiname;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { processOpenApi, temporarilyNotSupport } from '../utils/index';
|
|
2
|
+
// 位置
|
|
2
3
|
export const stopLocationUpdate = temporarilyNotSupport('stopLocationUpdate');
|
|
3
4
|
export const startLocationUpdateBackground = temporarilyNotSupport('startLocationUpdateBackground');
|
|
4
5
|
export const startLocationUpdate = temporarilyNotSupport('startLocationUpdate');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
import { temporarilyNotSupport } from '../../utils';
|
|
3
3
|
import { CallbackManager } from '../../utils/handler';
|
|
4
|
+
// 音频
|
|
4
5
|
class InnerAudioContext {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
@@ -15,6 +16,9 @@ class InnerAudioContext {
|
|
|
15
16
|
this.Instance.currentTime = position;
|
|
16
17
|
}
|
|
17
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* @TODO destroy得并不干净
|
|
21
|
+
*/
|
|
18
22
|
this.destroy = () => {
|
|
19
23
|
this.stop();
|
|
20
24
|
if (this.Instance) {
|
|
@@ -77,5 +81,8 @@ export const pauseVoice = temporarilyNotSupport('pauseVoice');
|
|
|
77
81
|
export const getAvailableAudioSources = temporarilyNotSupport('getAvailableAudioSources');
|
|
78
82
|
export const createWebAudioContext = temporarilyNotSupport('createWebAudioContext');
|
|
79
83
|
export const createMediaAudioPlayer = temporarilyNotSupport('createMediaAudioPlayer');
|
|
84
|
+
/**
|
|
85
|
+
* 创建内部 audio 上下文 InnerAudioContext 对象。
|
|
86
|
+
*/
|
|
80
87
|
export const createInnerAudioContext = () => new InnerAudioContext();
|
|
81
88
|
export const createAudioContext = temporarilyNotSupport('createAudioContext');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 背景音频
|
|
2
3
|
export const stopBackgroundAudio = temporarilyNotSupport('stopBackgroundAudio');
|
|
3
4
|
export const seekBackgroundAudio = temporarilyNotSupport('seekBackgroundAudio');
|
|
4
5
|
export const playBackgroundAudio = temporarilyNotSupport('playBackgroundAudio');
|
package/dist/api/media/camera.js
CHANGED
package/dist/api/media/editor.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { MethodHandler } from '../../utils/handler';
|
|
2
2
|
import { shouldBeObject, getParameterError } from '../../utils';
|
|
3
|
+
/**
|
|
4
|
+
* 从本地相册选择图片或使用相机拍照。
|
|
5
|
+
*/
|
|
3
6
|
export const chooseImage = function (options) {
|
|
7
|
+
// options must be an Object
|
|
4
8
|
const isObject = shouldBeObject(options);
|
|
5
9
|
if (!isObject.flag) {
|
|
6
10
|
const res = { errMsg: `chooseImage:fail ${isObject.msg}` };
|