@tarojs/taro-h5 3.4.0-beta.2 → 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 +4 -0
- package/dist/api/ai/facial.js +5 -0
- package/dist/api/ai/index.js +2 -0
- package/dist/api/ai/visual.js +3 -0
- package/dist/api/alipay/index.js +3 -0
- package/dist/api/base/crypto.js +3 -0
- package/dist/api/base/debug.js +4 -0
- package/dist/api/base/index.js +17 -0
- package/dist/api/base/performance.js +4 -0
- package/dist/api/base/system/index.js +2 -0
- package/dist/api/base/system/info.js +57 -0
- package/dist/api/base/system/network.js +63 -0
- package/dist/api/base/update.js +4 -0
- package/dist/api/base/weapp/app-event.js +18 -0
- package/dist/api/base/weapp/life-cycle.js +4 -0
- package/dist/api/canvas/CanvasContext.js +191 -0
- package/dist/api/canvas/canvasGetImageData.js +25 -0
- package/dist/api/canvas/canvasPutImageData.js +22 -0
- package/dist/api/canvas/canvasToTempFilePath.js +22 -0
- package/dist/api/canvas/createCanvasContext.js +16 -0
- package/dist/api/canvas/index.js +8 -0
- package/dist/api/cloud/index.js +17 -0
- package/dist/api/data-analysis/index.js +5 -0
- package/dist/api/device/accelerometer.js +83 -0
- package/dist/api/device/accessibility.js +3 -0
- package/dist/api/device/battery.js +4 -0
- package/dist/api/device/bluetooth-ble.js +18 -0
- package/dist/api/device/bluetooth-peripheral.js +5 -0
- package/dist/api/device/bluetooth.js +15 -0
- package/dist/api/device/calendar.js +4 -0
- package/dist/api/device/clipboard.js +65 -0
- package/dist/api/device/compass.js +64 -0
- package/dist/api/device/contact.js +4 -0
- package/dist/api/device/crypto.js +3 -0
- package/dist/api/device/gyroscope.js +6 -0
- package/dist/api/device/iBeacon.js +9 -0
- package/dist/api/device/index.js +22 -0
- package/dist/api/device/keyboard.js +6 -0
- package/dist/api/device/memory.js +4 -0
- package/dist/api/device/motion.js +81 -0
- package/dist/api/device/nfc.js +9 -0
- package/dist/api/device/phone.js +24 -0
- package/dist/api/device/scan.js +6 -0
- package/dist/api/device/screen.js +8 -0
- package/dist/api/device/vibrate.js +35 -0
- package/dist/api/device/wifi.js +12 -0
- package/dist/api/ext/index.js +4 -0
- package/dist/api/files/index.js +10 -0
- package/dist/api/framework/index.js +7 -0
- package/dist/api/index.js +24 -0
- package/dist/api/location/chooseLocation.js +93 -0
- package/dist/api/location/index.js +13 -0
- package/dist/api/location/style.css +79 -0
- package/dist/api/media/audio/index.js +88 -0
- package/dist/api/media/background-audio.js +11 -0
- package/dist/api/media/camera.js +3 -0
- package/dist/api/media/editor.js +18 -0
- package/dist/api/media/image/chooseImage.js +74 -0
- package/dist/api/media/image/getImageInfo.js +31 -0
- package/dist/api/media/image/index.js +9 -0
- package/dist/api/media/image/previewImage.js +67 -0
- package/dist/api/media/index.js +13 -0
- package/dist/api/media/live.js +4 -0
- package/dist/api/media/map.js +3 -0
- package/dist/api/media/media-recorder.js +3 -0
- package/dist/api/media/recorder.js +5 -0
- package/dist/api/media/video/index.js +74 -0
- package/dist/api/media/video-decoder.js +3 -0
- package/dist/api/media/video-processing.js +3 -0
- package/dist/api/media/voip.js +16 -0
- package/dist/api/navigate/index.js +6 -0
- package/dist/api/network/download.js +124 -0
- package/dist/api/network/index.js +7 -0
- package/dist/api/network/mdns.js +12 -0
- package/dist/api/network/request/index.js +125 -0
- package/dist/api/network/tcp.js +3 -0
- package/dist/api/network/udp.js +3 -0
- package/dist/api/network/upload.js +151 -0
- package/dist/api/network/utils.js +65 -0
- package/dist/api/network/websocket/index.js +70 -0
- package/dist/api/network/websocket/socketTask.js +63 -0
- package/dist/api/open-api/account.js +3 -0
- package/dist/api/open-api/address.js +3 -0
- package/dist/api/open-api/authorize.js +4 -0
- package/dist/api/open-api/card.js +4 -0
- package/dist/api/open-api/channels-live.js +8 -0
- package/dist/api/open-api/customer-service.js +3 -0
- package/dist/api/open-api/facial.js +6 -0
- package/dist/api/open-api/favorites.js +4 -0
- package/dist/api/open-api/group.js +3 -0
- package/dist/api/open-api/index.js +18 -0
- package/dist/api/open-api/invoice.js +4 -0
- package/dist/api/open-api/license-plate.js +3 -0
- package/dist/api/open-api/login.js +5 -0
- package/dist/api/open-api/red-package.js +3 -0
- package/dist/api/open-api/settings.js +4 -0
- package/dist/api/open-api/soter.js +5 -0
- package/dist/api/open-api/subscribe-message.js +3 -0
- package/dist/api/open-api/user-info.js +4 -0
- package/dist/api/open-api/werun.js +4 -0
- package/dist/api/payment/index.js +4 -0
- package/dist/api/route/index.js +3 -0
- package/dist/api/share/index.js +12 -0
- package/dist/api/storage/background-fetch.js +6 -0
- package/dist/api/storage/index.js +157 -0
- package/dist/api/swan/index.js +26 -0
- package/dist/api/taro.js +47 -0
- package/dist/api/ui/animation/index.js +284 -0
- package/dist/api/ui/background.js +4 -0
- package/dist/api/ui/custom-component.js +3 -0
- package/dist/api/ui/fonts.js +3 -0
- package/dist/api/ui/index.js +12 -0
- package/dist/api/ui/interaction/actionSheet.js +188 -0
- package/dist/api/ui/interaction/index.js +268 -0
- package/dist/api/ui/interaction/modal.js +207 -0
- package/dist/api/ui/interaction/toast.js +195 -0
- package/dist/api/ui/menu.js +3 -0
- package/dist/api/ui/navigation-bar/index.js +42 -0
- package/dist/api/ui/pull-down-refresh.js +26 -0
- package/dist/api/ui/scroll/index.js +83 -0
- package/dist/api/ui/sticky.js +3 -0
- package/dist/api/ui/tab-bar.js +282 -0
- package/dist/api/ui/window.js +31 -0
- package/dist/api/utils/handler.js +80 -0
- package/dist/api/utils/index.js +148 -0
- package/dist/api/worker/index.js +3 -0
- package/dist/api/wxml/index.js +6 -0
- package/dist/api/wxml/nodesRef.js +42 -0
- package/dist/api/wxml/selectorQuery.js +201 -0
- package/dist/index.cjs.js +4626 -6915
- package/dist/index.js +4 -10767
- package/dist/types/type.js +2 -0
- package/package.json +10 -13
- package/src/api/canvas/CanvasContext.ts +35 -32
- package/src/api/canvas/createCanvasContext.ts +2 -2
- package/src/api/location/chooseLocation.ts +2 -2
- package/src/api/media/audio/index.ts +16 -16
- package/src/api/media/image/previewImage.ts +4 -25
- 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
- package/src/api/ui/animation/index.ts +1 -6
- package/src/api/ui/interaction/index.ts +6 -4
- package/src/api/ui/navigation-bar/index.ts +1 -1
- package/src/api/wxml/nodesRef.ts +10 -3
- package/src/api/wxml/selectorQuery.ts +68 -23
- package/src/index.ts +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 蓝牙-通用
|
|
3
|
+
export const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery');
|
|
4
|
+
export const startBluetoothDevicesDiscovery = temporarilyNotSupport('startBluetoothDevicesDiscovery');
|
|
5
|
+
export const openBluetoothAdapter = temporarilyNotSupport('openBluetoothAdapter');
|
|
6
|
+
export const onBluetoothDeviceFound = temporarilyNotSupport('onBluetoothDeviceFound');
|
|
7
|
+
export const onBluetoothAdapterStateChange = temporarilyNotSupport('onBluetoothAdapterStateChange');
|
|
8
|
+
export const offBluetoothDeviceFound = temporarilyNotSupport('offBluetoothDeviceFound');
|
|
9
|
+
export const offBluetoothAdapterStateChange = temporarilyNotSupport('offBluetoothAdapterStateChange');
|
|
10
|
+
export const makeBluetoothPair = temporarilyNotSupport('makeBluetoothPair');
|
|
11
|
+
export const isBluetoothDevicePaired = temporarilyNotSupport('isBluetoothDevicePaired');
|
|
12
|
+
export const getConnectedBluetoothDevices = temporarilyNotSupport('getConnectedBluetoothDevices');
|
|
13
|
+
export const getBluetoothDevices = temporarilyNotSupport('getBluetoothDevices');
|
|
14
|
+
export const getBluetoothAdapterState = temporarilyNotSupport('getBluetoothAdapterState');
|
|
15
|
+
export const closeBluetoothAdapter = temporarilyNotSupport('closeBluetoothAdapter');
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
*/
|
|
7
|
+
import { setStorage, setStorageSync, getStorageSync } from '../storage/index';
|
|
8
|
+
import { MethodHandler } from '../utils/handler';
|
|
9
|
+
const CLIPBOARD_STORAGE_NAME = 'taro_clipboard';
|
|
10
|
+
document.addEventListener('copy', () => {
|
|
11
|
+
var _a;
|
|
12
|
+
setStorage({
|
|
13
|
+
key: CLIPBOARD_STORAGE_NAME,
|
|
14
|
+
data: (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString()
|
|
15
|
+
}).catch(e => {
|
|
16
|
+
console.error(e);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* 设置系统剪贴板的内容
|
|
21
|
+
*/
|
|
22
|
+
export const setClipboardData = async ({ data, success, fail, complete }) => {
|
|
23
|
+
const handle = new MethodHandler({ name: 'setClipboardData', success, fail, complete });
|
|
24
|
+
try {
|
|
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
|
+
*/
|
|
31
|
+
if (typeof document.execCommand === 'function') {
|
|
32
|
+
const textarea = document.createElement('textarea');
|
|
33
|
+
textarea.readOnly = true;
|
|
34
|
+
textarea.value = data;
|
|
35
|
+
textarea.style.position = 'absolute';
|
|
36
|
+
textarea.style.width = '100px';
|
|
37
|
+
textarea.style.left = '-10000px';
|
|
38
|
+
document.body.appendChild(textarea);
|
|
39
|
+
textarea.select();
|
|
40
|
+
textarea.setSelectionRange(0, textarea.value.length);
|
|
41
|
+
document.execCommand('copy');
|
|
42
|
+
document.body.removeChild(textarea);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new Error('Unsupported Function: \'document.execCommand\'.');
|
|
46
|
+
}
|
|
47
|
+
return handle.success();
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
return handle.fail({ errMsg: e.message });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 获取系统剪贴板的内容
|
|
55
|
+
*/
|
|
56
|
+
export const getClipboardData = async ({ success, fail, complete } = {}) => {
|
|
57
|
+
const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
|
|
58
|
+
try {
|
|
59
|
+
const data = getStorageSync(CLIPBOARD_STORAGE_NAME);
|
|
60
|
+
return handle.success({ data });
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
return handle.fail({ errMsg: e.message });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CallbackManager, MethodHandler } from '../utils/handler';
|
|
2
|
+
const callbackManager = new CallbackManager();
|
|
3
|
+
let compassListener;
|
|
4
|
+
/**
|
|
5
|
+
* 停止监听罗盘数据
|
|
6
|
+
*/
|
|
7
|
+
export const stopCompass = ({ success, fail, complete } = {}) => {
|
|
8
|
+
const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete });
|
|
9
|
+
try {
|
|
10
|
+
window.removeEventListener('deviceorientation', compassListener, true);
|
|
11
|
+
return handle.success();
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
return handle.fail({ errMsg: e.message });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const getDeviceOrientationListener = interval => {
|
|
18
|
+
let lock;
|
|
19
|
+
let timer;
|
|
20
|
+
return evt => {
|
|
21
|
+
if (lock)
|
|
22
|
+
return;
|
|
23
|
+
lock = true;
|
|
24
|
+
timer && clearTimeout(timer);
|
|
25
|
+
callbackManager.trigger({
|
|
26
|
+
direction: 360 - evt.alpha
|
|
27
|
+
});
|
|
28
|
+
timer = setTimeout(() => { lock = false; }, interval);
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 开始监听罗盘数据
|
|
33
|
+
*/
|
|
34
|
+
export const startCompass = ({ success, fail, complete } = {}) => {
|
|
35
|
+
const handle = new MethodHandler({ name: 'startCompass', success, fail, complete });
|
|
36
|
+
try {
|
|
37
|
+
if (window.DeviceOrientationEvent) {
|
|
38
|
+
if (compassListener) {
|
|
39
|
+
stopCompass();
|
|
40
|
+
}
|
|
41
|
+
compassListener = getDeviceOrientationListener(200);
|
|
42
|
+
window.addEventListener('deviceorientation', compassListener, true);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new Error('compass is not supported');
|
|
46
|
+
}
|
|
47
|
+
return handle.success();
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
return handle.fail({ errMsg: e.message });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
|
|
55
|
+
*/
|
|
56
|
+
export const onCompassChange = callback => {
|
|
57
|
+
callbackManager.add(callback);
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
|
|
61
|
+
*/
|
|
62
|
+
export const offCompassChange = callback => {
|
|
63
|
+
callbackManager.remove(callback);
|
|
64
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 陀螺仪
|
|
3
|
+
export const stopGyroscope = temporarilyNotSupport('stopGyroscope');
|
|
4
|
+
export const startGyroscope = temporarilyNotSupport('startGyroscope');
|
|
5
|
+
export const onGyroscopeChange = temporarilyNotSupport('onGyroscopeChange');
|
|
6
|
+
export const offGyroscopeChange = temporarilyNotSupport('offGyroscopeChange');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 蓝牙-信标(Beacon)
|
|
3
|
+
export const stopBeaconDiscovery = temporarilyNotSupport('stopBeaconDiscovery');
|
|
4
|
+
export const startBeaconDiscovery = temporarilyNotSupport('startBeaconDiscovery');
|
|
5
|
+
export const onBeaconUpdate = temporarilyNotSupport('onBeaconUpdate');
|
|
6
|
+
export const onBeaconServiceChange = temporarilyNotSupport('onBeaconServiceChange');
|
|
7
|
+
export const offBeaconUpdate = temporarilyNotSupport('offBeaconUpdate');
|
|
8
|
+
export const offBeaconServiceChange = temporarilyNotSupport('offBeaconServiceChange');
|
|
9
|
+
export const getBeacons = temporarilyNotSupport('getBeacons');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './accelerometer';
|
|
2
|
+
export * from './accessibility';
|
|
3
|
+
export * from './battery';
|
|
4
|
+
export * from './bluetooth';
|
|
5
|
+
export * from './bluetooth-ble';
|
|
6
|
+
export * from './bluetooth-peripheral';
|
|
7
|
+
export * from './calendar';
|
|
8
|
+
export * from './clipboard';
|
|
9
|
+
export * from './compass';
|
|
10
|
+
export * from './contact';
|
|
11
|
+
export * from './crypto';
|
|
12
|
+
export * from './gyroscope';
|
|
13
|
+
export * from './iBeacon';
|
|
14
|
+
export * from './keyboard';
|
|
15
|
+
export * from './memory';
|
|
16
|
+
export * from './motion';
|
|
17
|
+
export * from './nfc';
|
|
18
|
+
export * from './phone';
|
|
19
|
+
export * from './scan';
|
|
20
|
+
export * from './screen';
|
|
21
|
+
export * from './vibrate';
|
|
22
|
+
export * from './wifi';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 键盘
|
|
3
|
+
export const onKeyboardHeightChange = temporarilyNotSupport('onKeyboardHeightChange');
|
|
4
|
+
export const offKeyboardHeightChange = temporarilyNotSupport('offKeyboardHeightChange');
|
|
5
|
+
export const hideKeyboard = temporarilyNotSupport('hideKeyboard');
|
|
6
|
+
export const getSelectedTextRange = temporarilyNotSupport('getSelectedTextRange');
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CallbackManager, MethodHandler } from '../utils/handler';
|
|
2
|
+
const callbackManager = new CallbackManager();
|
|
3
|
+
let deviceMotionListener;
|
|
4
|
+
const INTERVAL_MAP = {
|
|
5
|
+
game: {
|
|
6
|
+
interval: 20,
|
|
7
|
+
frequency: 50
|
|
8
|
+
},
|
|
9
|
+
ui: {
|
|
10
|
+
interval: 60,
|
|
11
|
+
frequency: 16.67
|
|
12
|
+
},
|
|
13
|
+
normal: {
|
|
14
|
+
interval: 200,
|
|
15
|
+
frequency: 5
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 停止监听设备方向的变化。
|
|
20
|
+
*/
|
|
21
|
+
export const stopDeviceMotionListening = ({ success, fail, complete } = {}) => {
|
|
22
|
+
const handle = new MethodHandler({ name: 'stopDeviceMotionListening', success, fail, complete });
|
|
23
|
+
try {
|
|
24
|
+
window.removeEventListener('deviceorientation', deviceMotionListener, true);
|
|
25
|
+
return handle.success();
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return handle.fail({ errMsg: e.message });
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const getDeviceOrientationListener = interval => {
|
|
32
|
+
let lock;
|
|
33
|
+
let timer;
|
|
34
|
+
return evt => {
|
|
35
|
+
if (lock)
|
|
36
|
+
return;
|
|
37
|
+
lock = true;
|
|
38
|
+
timer && clearTimeout(timer);
|
|
39
|
+
callbackManager.trigger({
|
|
40
|
+
alpha: evt.alpha,
|
|
41
|
+
beta: evt.beta,
|
|
42
|
+
gamma: evt.gamma
|
|
43
|
+
});
|
|
44
|
+
timer = setTimeout(() => { lock = false; }, interval);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* 开始监听设备方向的变化。
|
|
49
|
+
*/
|
|
50
|
+
export const startDeviceMotionListening = ({ interval = 'normal', success, fail, complete } = {}) => {
|
|
51
|
+
const handle = new MethodHandler({ name: 'startDeviceMotionListening', success, fail, complete });
|
|
52
|
+
try {
|
|
53
|
+
const intervalObj = INTERVAL_MAP[interval];
|
|
54
|
+
if (window.DeviceOrientationEvent) {
|
|
55
|
+
if (deviceMotionListener) {
|
|
56
|
+
stopDeviceMotionListening();
|
|
57
|
+
}
|
|
58
|
+
deviceMotionListener = getDeviceOrientationListener(intervalObj.interval);
|
|
59
|
+
window.addEventListener('deviceorientation', deviceMotionListener, true);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new Error('deviceMotion is not supported');
|
|
63
|
+
}
|
|
64
|
+
return handle.success();
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return handle.fail({ errMsg: e.message });
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* 监听设备方向变化事件。
|
|
72
|
+
*/
|
|
73
|
+
export const onDeviceMotionChange = callback => {
|
|
74
|
+
callbackManager.add(callback);
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* 取消监听设备方向变化事件,参数为空,则取消所有的事件监听。
|
|
78
|
+
*/
|
|
79
|
+
export const offDeviceMotionChange = callback => {
|
|
80
|
+
callbackManager.remove(callback);
|
|
81
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// NFC
|
|
3
|
+
export const stopHCE = temporarilyNotSupport('stopHCE');
|
|
4
|
+
export const startHCE = temporarilyNotSupport('startHCE');
|
|
5
|
+
export const sendHCEMessage = temporarilyNotSupport('sendHCEMessage');
|
|
6
|
+
export const onHCEMessage = temporarilyNotSupport('onHCEMessage');
|
|
7
|
+
export const offHCEMessage = temporarilyNotSupport('offHCEMessage');
|
|
8
|
+
export const getNFCAdapter = temporarilyNotSupport('getNFCAdapter');
|
|
9
|
+
export const getHCEState = temporarilyNotSupport('getHCEState');
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { shouldBeObject, getParameterError } from '../utils';
|
|
2
|
+
import { MethodHandler } from '../utils/handler';
|
|
3
|
+
export const makePhoneCall = (options) => {
|
|
4
|
+
// options must be an Object
|
|
5
|
+
const isObject = shouldBeObject(options);
|
|
6
|
+
if (!isObject.flag) {
|
|
7
|
+
const res = { errMsg: `makePhoneCall:fail ${isObject.msg}` };
|
|
8
|
+
console.error(res.errMsg);
|
|
9
|
+
return Promise.reject(res);
|
|
10
|
+
}
|
|
11
|
+
const { phoneNumber, success, fail, complete } = options;
|
|
12
|
+
const handle = new MethodHandler({ name: 'makePhoneCall', success, fail, complete });
|
|
13
|
+
if (typeof phoneNumber !== 'string') {
|
|
14
|
+
return handle.fail({
|
|
15
|
+
errMsg: getParameterError({
|
|
16
|
+
para: 'phoneNumber',
|
|
17
|
+
correct: 'String',
|
|
18
|
+
wrong: phoneNumber
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
window.location.href = `tel:${phoneNumber}`;
|
|
23
|
+
return handle.success();
|
|
24
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 屏幕
|
|
3
|
+
export const setVisualEffectOnCapture = temporarilyNotSupport('setVisualEffectOnCapture');
|
|
4
|
+
export const setScreenBrightness = temporarilyNotSupport('setScreenBrightness');
|
|
5
|
+
export const setKeepScreenOn = temporarilyNotSupport('setKeepScreenOn');
|
|
6
|
+
export const onUserCaptureScreen = temporarilyNotSupport('onUserCaptureScreen');
|
|
7
|
+
export const offUserCaptureScreen = temporarilyNotSupport('offUserCaptureScreen');
|
|
8
|
+
export const getScreenBrightness = temporarilyNotSupport('getScreenBrightness');
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MethodHandler } from '../utils/handler';
|
|
2
|
+
const vibrator = function vibrator(mm) {
|
|
3
|
+
try {
|
|
4
|
+
return window.navigator.vibrate(mm);
|
|
5
|
+
}
|
|
6
|
+
catch (e) {
|
|
7
|
+
console.warn('当前浏览器不支持vibrate');
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
|
|
12
|
+
*/
|
|
13
|
+
export const vibrateShort = ({ success, fail, complete } = {}) => {
|
|
14
|
+
const handle = new MethodHandler({ name: 'vibrateShort', success, fail, complete });
|
|
15
|
+
if (vibrator) {
|
|
16
|
+
vibrator(15);
|
|
17
|
+
return handle.success();
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return handle.fail();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 使手机发生较长时间的振动(400 ms)
|
|
25
|
+
*/
|
|
26
|
+
export const vibrateLong = ({ success, fail, complete } = {}) => {
|
|
27
|
+
const handle = new MethodHandler({ name: 'vibrateLong', success, fail, complete });
|
|
28
|
+
if (vibrator) {
|
|
29
|
+
vibrator(400);
|
|
30
|
+
return handle.success();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return handle.fail();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// Wi-Fi
|
|
3
|
+
export const stopWifi = temporarilyNotSupport('stopWifi');
|
|
4
|
+
export const startWifi = temporarilyNotSupport('startWifi');
|
|
5
|
+
export const setWifiList = temporarilyNotSupport('setWifiList');
|
|
6
|
+
export const onWifiConnected = temporarilyNotSupport('onWifiConnected');
|
|
7
|
+
export const onGetWifiList = temporarilyNotSupport('onGetWifiList');
|
|
8
|
+
export const offWifiConnected = temporarilyNotSupport('offWifiConnected');
|
|
9
|
+
export const offGetWifiList = temporarilyNotSupport('offGetWifiList');
|
|
10
|
+
export const getWifiList = temporarilyNotSupport('getWifiList');
|
|
11
|
+
export const getConnectedWifi = temporarilyNotSupport('getConnectedWifi');
|
|
12
|
+
export const connectWifi = temporarilyNotSupport('connectWifi');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
// 文件
|
|
3
|
+
export const saveFileToDisk = temporarilyNotSupport('saveFileToDisk');
|
|
4
|
+
export const saveFile = temporarilyNotSupport('saveFile');
|
|
5
|
+
export const removeSavedFile = temporarilyNotSupport('removeSavedFile');
|
|
6
|
+
export const openDocument = temporarilyNotSupport('openDocument');
|
|
7
|
+
export const getSavedFileList = temporarilyNotSupport('getSavedFileList');
|
|
8
|
+
export const getSavedFileInfo = temporarilyNotSupport('getSavedFileInfo');
|
|
9
|
+
export const getFileSystemManager = temporarilyNotSupport('getFileSystemManager');
|
|
10
|
+
export const getFileInfo = temporarilyNotSupport('getFileInfo');
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './ad';
|
|
2
|
+
export * from './ai';
|
|
3
|
+
export * from './base';
|
|
4
|
+
export * from './canvas';
|
|
5
|
+
export * from './cloud';
|
|
6
|
+
export * from './data-analysis';
|
|
7
|
+
export * from './device';
|
|
8
|
+
export * from './ext';
|
|
9
|
+
export * from './files';
|
|
10
|
+
export * from './framework';
|
|
11
|
+
export * from './location';
|
|
12
|
+
export * from './media';
|
|
13
|
+
export * from './navigate';
|
|
14
|
+
export * from './network';
|
|
15
|
+
export * from './open-api';
|
|
16
|
+
export * from './payment';
|
|
17
|
+
export * from './route';
|
|
18
|
+
export * from './share';
|
|
19
|
+
export * from './storage';
|
|
20
|
+
export * from './ui';
|
|
21
|
+
export * from './worker';
|
|
22
|
+
export * from './wxml';
|
|
23
|
+
export * from './alipay';
|
|
24
|
+
export * from './swan';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { MethodHandler } from '../utils/handler';
|
|
2
|
+
import './style.css';
|
|
3
|
+
function createLocationChooser(handler, key = LOCATION_APIKEY) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const html = `
|
|
6
|
+
<div class='taro_choose_location'>
|
|
7
|
+
<div class='taro_choose_location_bar'>
|
|
8
|
+
<div class='taro_choose_location_back'></div>
|
|
9
|
+
<p class='taro_choose_location_title'>位置</p>
|
|
10
|
+
<button class='taro_choose_location_submit'>完成</button>
|
|
11
|
+
</div>
|
|
12
|
+
<iframe class='taro_choose_location_frame' frameborder='0' src='https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=myapp'></iframe>
|
|
13
|
+
</div>
|
|
14
|
+
`;
|
|
15
|
+
const container = document.createElement('div');
|
|
16
|
+
container.innerHTML = html;
|
|
17
|
+
const main = container.querySelector('.taro_choose_location');
|
|
18
|
+
function show() {
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
main.style.top = '0';
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function hide() {
|
|
24
|
+
main.style.top = '100%';
|
|
25
|
+
}
|
|
26
|
+
function back() {
|
|
27
|
+
hide();
|
|
28
|
+
handler({ errMsg: 'cancel' });
|
|
29
|
+
}
|
|
30
|
+
function submit() {
|
|
31
|
+
hide();
|
|
32
|
+
handler();
|
|
33
|
+
}
|
|
34
|
+
function remove() {
|
|
35
|
+
container.remove();
|
|
36
|
+
window.removeEventListener('popstate', back);
|
|
37
|
+
}
|
|
38
|
+
(_a = container.querySelector('.taro_choose_location_back')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', back);
|
|
39
|
+
(_b = container.querySelector('.taro_choose_location_submit')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', submit);
|
|
40
|
+
window.addEventListener('popstate', back);
|
|
41
|
+
return {
|
|
42
|
+
show,
|
|
43
|
+
remove,
|
|
44
|
+
container
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 打开地图选择位置。
|
|
49
|
+
*/
|
|
50
|
+
export const chooseLocation = ({ success, fail, complete } = {}) => {
|
|
51
|
+
const key = LOCATION_APIKEY;
|
|
52
|
+
const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete });
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
const chooseLocation = {};
|
|
55
|
+
if (!key) {
|
|
56
|
+
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
57
|
+
return handle.fail({
|
|
58
|
+
errMsg: 'LOCATION_APIKEY needed'
|
|
59
|
+
}, reject);
|
|
60
|
+
}
|
|
61
|
+
const onMessage = event => {
|
|
62
|
+
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
63
|
+
const loc = event.data;
|
|
64
|
+
// 防止其他应用也会向该页面 post 信息,需判断 module 是否为'locationPicker'
|
|
65
|
+
if (!loc || loc.module !== 'locationPicker')
|
|
66
|
+
return;
|
|
67
|
+
chooseLocation.name = loc.poiname;
|
|
68
|
+
chooseLocation.address = loc.poiaddress;
|
|
69
|
+
chooseLocation.latitude = loc.latlng.lat;
|
|
70
|
+
chooseLocation.longitude = loc.latlng.lng;
|
|
71
|
+
};
|
|
72
|
+
const chooser = createLocationChooser(res => {
|
|
73
|
+
window.removeEventListener('message', onMessage, false);
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
chooser.remove();
|
|
76
|
+
}, 300);
|
|
77
|
+
if (res) {
|
|
78
|
+
return handle.fail(res, reject);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
82
|
+
return handle.success(chooseLocation, resolve);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return handle.fail({}, reject);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, key);
|
|
89
|
+
document.body.appendChild(chooser.container);
|
|
90
|
+
window.addEventListener('message', onMessage, false);
|
|
91
|
+
chooser.show();
|
|
92
|
+
});
|
|
93
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { processOpenApi, temporarilyNotSupport } from '../utils/index';
|
|
2
|
+
// 位置
|
|
3
|
+
export const stopLocationUpdate = temporarilyNotSupport('stopLocationUpdate');
|
|
4
|
+
export const startLocationUpdateBackground = temporarilyNotSupport('startLocationUpdateBackground');
|
|
5
|
+
export const startLocationUpdate = temporarilyNotSupport('startLocationUpdate');
|
|
6
|
+
export const openLocation = processOpenApi('openLocation', { scale: 18 });
|
|
7
|
+
export const onLocationChangeError = temporarilyNotSupport('onLocationChangeError');
|
|
8
|
+
export const onLocationChange = temporarilyNotSupport('onLocationChange');
|
|
9
|
+
export const offLocationChangeError = temporarilyNotSupport('offLocationChangeError');
|
|
10
|
+
export const offLocationChange = temporarilyNotSupport('offLocationChange');
|
|
11
|
+
export const getLocation = processOpenApi('getLocation');
|
|
12
|
+
export const choosePoi = temporarilyNotSupport('choosePoi');
|
|
13
|
+
export * from './chooseLocation';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
.taro_choose_location {
|
|
2
|
+
position: fixed;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
top: 100%;
|
|
8
|
+
background-color: #fff;
|
|
9
|
+
transition: ease top .3s;
|
|
10
|
+
z-index: 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.taro_choose_location_bar {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex: 0 95px;
|
|
16
|
+
height: 95px;
|
|
17
|
+
background-color: #ededed;
|
|
18
|
+
color: #090909;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.taro_choose_location_back {
|
|
22
|
+
flex: 0 45px;
|
|
23
|
+
position: relative;
|
|
24
|
+
width: 33px;
|
|
25
|
+
height: 30px;
|
|
26
|
+
margin-top: 30px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.taro_choose_location_back::before {
|
|
30
|
+
content: '';
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 0;
|
|
33
|
+
left: 0;
|
|
34
|
+
display: block;
|
|
35
|
+
width: 0;
|
|
36
|
+
height: 0;
|
|
37
|
+
border: solid 15px;
|
|
38
|
+
border-top-color: transparent;
|
|
39
|
+
border-right-color: #090909;
|
|
40
|
+
border-bottom-color: transparent;
|
|
41
|
+
border-left-color: transparent;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.taro_choose_location_back::after {
|
|
45
|
+
content: '';
|
|
46
|
+
position: absolute;
|
|
47
|
+
display: block;
|
|
48
|
+
width: 0;
|
|
49
|
+
height: 0;
|
|
50
|
+
top: 0;
|
|
51
|
+
left: 3px;
|
|
52
|
+
border: solid 15px;
|
|
53
|
+
border-top-color: transparent;
|
|
54
|
+
border-right-color: #ededed;
|
|
55
|
+
border-bottom-color: transparent;
|
|
56
|
+
border-left-color: transparent;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.taro_choose_location_title {
|
|
60
|
+
flex: 1;
|
|
61
|
+
line-height: 95px;
|
|
62
|
+
padding-left: 30px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.taro_choose_location_submit {
|
|
66
|
+
width: 110px;
|
|
67
|
+
height: 60px;
|
|
68
|
+
color: #fff;
|
|
69
|
+
background-color: #08bf62;
|
|
70
|
+
border: none;
|
|
71
|
+
font-size: 28px;
|
|
72
|
+
line-height: 60px;
|
|
73
|
+
padding: 0;
|
|
74
|
+
margin: 18px 30px 0 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.taro_choose_location_frame {
|
|
78
|
+
flex: 1;
|
|
79
|
+
}
|