@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,48 @@
|
|
|
1
|
+
import { setStorage, setStorageSync, getStorageSync } from '../storage/index';
|
|
2
|
+
import { MethodHandler } from '../utils/handler';
|
|
3
|
+
const CLIPBOARD_STORAGE_NAME = 'taro_clipboard';
|
|
4
|
+
document.addEventListener('copy', () => {
|
|
5
|
+
var _a;
|
|
6
|
+
setStorage({
|
|
7
|
+
key: CLIPBOARD_STORAGE_NAME,
|
|
8
|
+
data: (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString()
|
|
9
|
+
}).catch(e => {
|
|
10
|
+
console.error(e);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
export const setClipboardData = async ({ data, success, fail, complete }) => {
|
|
14
|
+
const handle = new MethodHandler({ name: 'setClipboardData', success, fail, complete });
|
|
15
|
+
try {
|
|
16
|
+
setStorageSync(CLIPBOARD_STORAGE_NAME, data);
|
|
17
|
+
if (typeof document.execCommand === 'function') {
|
|
18
|
+
const textarea = document.createElement('textarea');
|
|
19
|
+
textarea.readOnly = true;
|
|
20
|
+
textarea.value = data;
|
|
21
|
+
textarea.style.position = 'absolute';
|
|
22
|
+
textarea.style.width = '100px';
|
|
23
|
+
textarea.style.left = '-10000px';
|
|
24
|
+
document.body.appendChild(textarea);
|
|
25
|
+
textarea.select();
|
|
26
|
+
textarea.setSelectionRange(0, textarea.value.length);
|
|
27
|
+
document.execCommand('copy');
|
|
28
|
+
document.body.removeChild(textarea);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new Error('Unsupported Function: \'document.execCommand\'.');
|
|
32
|
+
}
|
|
33
|
+
return handle.success();
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
return handle.fail({ errMsg: e.message });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const getClipboardData = async ({ success, fail, complete } = {}) => {
|
|
40
|
+
const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
|
|
41
|
+
try {
|
|
42
|
+
const data = getStorageSync(CLIPBOARD_STORAGE_NAME);
|
|
43
|
+
return handle.success({ data });
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
return handle.fail({ errMsg: e.message });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CallbackManager, MethodHandler } from '../utils/handler';
|
|
2
|
+
const callbackManager = new CallbackManager();
|
|
3
|
+
let compassListener;
|
|
4
|
+
export const stopCompass = ({ success, fail, complete } = {}) => {
|
|
5
|
+
const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete });
|
|
6
|
+
try {
|
|
7
|
+
window.removeEventListener('deviceorientation', compassListener, true);
|
|
8
|
+
return handle.success();
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
return handle.fail({ errMsg: e.message });
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const getDeviceOrientationListener = interval => {
|
|
15
|
+
let lock;
|
|
16
|
+
let timer;
|
|
17
|
+
return evt => {
|
|
18
|
+
if (lock)
|
|
19
|
+
return;
|
|
20
|
+
lock = true;
|
|
21
|
+
timer && clearTimeout(timer);
|
|
22
|
+
callbackManager.trigger({
|
|
23
|
+
direction: 360 - evt.alpha
|
|
24
|
+
});
|
|
25
|
+
timer = setTimeout(() => { lock = false; }, interval);
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export const startCompass = ({ success, fail, complete } = {}) => {
|
|
29
|
+
const handle = new MethodHandler({ name: 'startCompass', success, fail, complete });
|
|
30
|
+
try {
|
|
31
|
+
if (window.DeviceOrientationEvent) {
|
|
32
|
+
if (compassListener) {
|
|
33
|
+
stopCompass();
|
|
34
|
+
}
|
|
35
|
+
compassListener = getDeviceOrientationListener(200);
|
|
36
|
+
window.addEventListener('deviceorientation', compassListener, true);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new Error('compass is not supported');
|
|
40
|
+
}
|
|
41
|
+
return handle.success();
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
return handle.fail({ errMsg: e.message });
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export const onCompassChange = callback => {
|
|
48
|
+
callbackManager.add(callback);
|
|
49
|
+
};
|
|
50
|
+
export const offCompassChange = callback => {
|
|
51
|
+
callbackManager.remove(callback);
|
|
52
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const stopGyroscope = temporarilyNotSupport('stopGyroscope');
|
|
3
|
+
export const startGyroscope = temporarilyNotSupport('startGyroscope');
|
|
4
|
+
export const onGyroscopeChange = temporarilyNotSupport('onGyroscopeChange');
|
|
5
|
+
export const offGyroscopeChange = temporarilyNotSupport('offGyroscopeChange');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const stopBeaconDiscovery = temporarilyNotSupport('stopBeaconDiscovery');
|
|
3
|
+
export const startBeaconDiscovery = temporarilyNotSupport('startBeaconDiscovery');
|
|
4
|
+
export const onBeaconUpdate = temporarilyNotSupport('onBeaconUpdate');
|
|
5
|
+
export const onBeaconServiceChange = temporarilyNotSupport('onBeaconServiceChange');
|
|
6
|
+
export const offBeaconUpdate = temporarilyNotSupport('offBeaconUpdate');
|
|
7
|
+
export const offBeaconServiceChange = temporarilyNotSupport('offBeaconServiceChange');
|
|
8
|
+
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,5 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const onKeyboardHeightChange = temporarilyNotSupport('onKeyboardHeightChange');
|
|
3
|
+
export const offKeyboardHeightChange = temporarilyNotSupport('offKeyboardHeightChange');
|
|
4
|
+
export const hideKeyboard = temporarilyNotSupport('hideKeyboard');
|
|
5
|
+
export const getSelectedTextRange = temporarilyNotSupport('getSelectedTextRange');
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
export const stopDeviceMotionListening = ({ success, fail, complete } = {}) => {
|
|
19
|
+
const handle = new MethodHandler({ name: 'stopDeviceMotionListening', success, fail, complete });
|
|
20
|
+
try {
|
|
21
|
+
window.removeEventListener('deviceorientation', deviceMotionListener, true);
|
|
22
|
+
return handle.success();
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
return handle.fail({ errMsg: e.message });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const getDeviceOrientationListener = interval => {
|
|
29
|
+
let lock;
|
|
30
|
+
let timer;
|
|
31
|
+
return evt => {
|
|
32
|
+
if (lock)
|
|
33
|
+
return;
|
|
34
|
+
lock = true;
|
|
35
|
+
timer && clearTimeout(timer);
|
|
36
|
+
callbackManager.trigger({
|
|
37
|
+
alpha: evt.alpha,
|
|
38
|
+
beta: evt.beta,
|
|
39
|
+
gamma: evt.gamma
|
|
40
|
+
});
|
|
41
|
+
timer = setTimeout(() => { lock = false; }, interval);
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export const startDeviceMotionListening = ({ interval = 'normal', success, fail, complete } = {}) => {
|
|
45
|
+
const handle = new MethodHandler({ name: 'startDeviceMotionListening', success, fail, complete });
|
|
46
|
+
try {
|
|
47
|
+
const intervalObj = INTERVAL_MAP[interval];
|
|
48
|
+
if (window.DeviceOrientationEvent) {
|
|
49
|
+
if (deviceMotionListener) {
|
|
50
|
+
stopDeviceMotionListening();
|
|
51
|
+
}
|
|
52
|
+
deviceMotionListener = getDeviceOrientationListener(intervalObj.interval);
|
|
53
|
+
window.addEventListener('deviceorientation', deviceMotionListener, true);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new Error('deviceMotion is not supported');
|
|
57
|
+
}
|
|
58
|
+
return handle.success();
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return handle.fail({ errMsg: e.message });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export const onDeviceMotionChange = callback => {
|
|
65
|
+
callbackManager.add(callback);
|
|
66
|
+
};
|
|
67
|
+
export const offDeviceMotionChange = callback => {
|
|
68
|
+
callbackManager.remove(callback);
|
|
69
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const stopHCE = temporarilyNotSupport('stopHCE');
|
|
3
|
+
export const startHCE = temporarilyNotSupport('startHCE');
|
|
4
|
+
export const sendHCEMessage = temporarilyNotSupport('sendHCEMessage');
|
|
5
|
+
export const onHCEMessage = temporarilyNotSupport('onHCEMessage');
|
|
6
|
+
export const offHCEMessage = temporarilyNotSupport('offHCEMessage');
|
|
7
|
+
export const getNFCAdapter = temporarilyNotSupport('getNFCAdapter');
|
|
8
|
+
export const getHCEState = temporarilyNotSupport('getHCEState');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { shouldBeObject, getParameterError } from '../utils';
|
|
2
|
+
import { MethodHandler } from '../utils/handler';
|
|
3
|
+
export const makePhoneCall = (options) => {
|
|
4
|
+
const isObject = shouldBeObject(options);
|
|
5
|
+
if (!isObject.flag) {
|
|
6
|
+
const res = { errMsg: `makePhoneCall:fail ${isObject.msg}` };
|
|
7
|
+
console.error(res.errMsg);
|
|
8
|
+
return Promise.reject(res);
|
|
9
|
+
}
|
|
10
|
+
const { phoneNumber, success, fail, complete } = options;
|
|
11
|
+
const handle = new MethodHandler({ name: 'makePhoneCall', success, fail, complete });
|
|
12
|
+
if (typeof phoneNumber !== 'string') {
|
|
13
|
+
return handle.fail({
|
|
14
|
+
errMsg: getParameterError({
|
|
15
|
+
para: 'phoneNumber',
|
|
16
|
+
correct: 'String',
|
|
17
|
+
wrong: phoneNumber
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
window.location.href = `tel:${phoneNumber}`;
|
|
22
|
+
return handle.success();
|
|
23
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const setVisualEffectOnCapture = temporarilyNotSupport('setVisualEffectOnCapture');
|
|
3
|
+
export const setScreenBrightness = temporarilyNotSupport('setScreenBrightness');
|
|
4
|
+
export const setKeepScreenOn = temporarilyNotSupport('setKeepScreenOn');
|
|
5
|
+
export const onUserCaptureScreen = temporarilyNotSupport('onUserCaptureScreen');
|
|
6
|
+
export const offUserCaptureScreen = temporarilyNotSupport('offUserCaptureScreen');
|
|
7
|
+
export const getScreenBrightness = temporarilyNotSupport('getScreenBrightness');
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
export const vibrateShort = ({ success, fail, complete } = {}) => {
|
|
11
|
+
const handle = new MethodHandler({ name: 'vibrateShort', success, fail, complete });
|
|
12
|
+
if (vibrator) {
|
|
13
|
+
vibrator(15);
|
|
14
|
+
return handle.success();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return handle.fail();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export const vibrateLong = ({ success, fail, complete } = {}) => {
|
|
21
|
+
const handle = new MethodHandler({ name: 'vibrateLong', success, fail, complete });
|
|
22
|
+
if (vibrator) {
|
|
23
|
+
vibrator(400);
|
|
24
|
+
return handle.success();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return handle.fail();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const stopWifi = temporarilyNotSupport('stopWifi');
|
|
3
|
+
export const startWifi = temporarilyNotSupport('startWifi');
|
|
4
|
+
export const setWifiList = temporarilyNotSupport('setWifiList');
|
|
5
|
+
export const onWifiConnected = temporarilyNotSupport('onWifiConnected');
|
|
6
|
+
export const onGetWifiList = temporarilyNotSupport('onGetWifiList');
|
|
7
|
+
export const offWifiConnected = temporarilyNotSupport('offWifiConnected');
|
|
8
|
+
export const offGetWifiList = temporarilyNotSupport('offGetWifiList');
|
|
9
|
+
export const getWifiList = temporarilyNotSupport('getWifiList');
|
|
10
|
+
export const getConnectedWifi = temporarilyNotSupport('getConnectedWifi');
|
|
11
|
+
export const connectWifi = temporarilyNotSupport('connectWifi');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const saveFileToDisk = temporarilyNotSupport('saveFileToDisk');
|
|
3
|
+
export const saveFile = temporarilyNotSupport('saveFile');
|
|
4
|
+
export const removeSavedFile = temporarilyNotSupport('removeSavedFile');
|
|
5
|
+
export const openDocument = temporarilyNotSupport('openDocument');
|
|
6
|
+
export const getSavedFileList = temporarilyNotSupport('getSavedFileList');
|
|
7
|
+
export const getSavedFileInfo = temporarilyNotSupport('getSavedFileInfo');
|
|
8
|
+
export const getFileSystemManager = temporarilyNotSupport('getFileSystemManager');
|
|
9
|
+
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,88 @@
|
|
|
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
|
+
handler({ errMsg: 'cancel' });
|
|
28
|
+
hide();
|
|
29
|
+
}
|
|
30
|
+
function submit() {
|
|
31
|
+
handler();
|
|
32
|
+
hide();
|
|
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
|
+
export const chooseLocation = ({ success, fail, complete } = {}) => {
|
|
48
|
+
const key = LOCATION_APIKEY;
|
|
49
|
+
const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete });
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
const chooseLocation = {};
|
|
52
|
+
if (!key) {
|
|
53
|
+
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
54
|
+
return handle.fail({
|
|
55
|
+
errMsg: 'LOCATION_APIKEY needed'
|
|
56
|
+
}, reject);
|
|
57
|
+
}
|
|
58
|
+
const onMessage = event => {
|
|
59
|
+
const loc = event.data;
|
|
60
|
+
if (!loc || loc.module !== 'locationPicker')
|
|
61
|
+
return;
|
|
62
|
+
chooseLocation.name = loc.poiname;
|
|
63
|
+
chooseLocation.address = loc.poiaddress;
|
|
64
|
+
chooseLocation.latitude = loc.latlng.lat;
|
|
65
|
+
chooseLocation.longitude = loc.latlng.lng;
|
|
66
|
+
};
|
|
67
|
+
const chooser = createLocationChooser(res => {
|
|
68
|
+
window.removeEventListener('message', onMessage, false);
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
chooser.remove();
|
|
71
|
+
}, 300);
|
|
72
|
+
if (res) {
|
|
73
|
+
return handle.fail(res, reject);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
77
|
+
return handle.success(chooseLocation, resolve);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return handle.fail({}, reject);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, key);
|
|
84
|
+
document.body.appendChild(chooser.container);
|
|
85
|
+
window.addEventListener('message', onMessage, false);
|
|
86
|
+
chooser.show();
|
|
87
|
+
});
|
|
88
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { processOpenApi, temporarilyNotSupport } from '../utils/index';
|
|
2
|
+
export const stopLocationUpdate = temporarilyNotSupport('stopLocationUpdate');
|
|
3
|
+
export const startLocationUpdateBackground = temporarilyNotSupport('startLocationUpdateBackground');
|
|
4
|
+
export const startLocationUpdate = temporarilyNotSupport('startLocationUpdate');
|
|
5
|
+
export const openLocation = processOpenApi('openLocation', { scale: 18 });
|
|
6
|
+
export const onLocationChangeError = temporarilyNotSupport('onLocationChangeError');
|
|
7
|
+
export const onLocationChange = temporarilyNotSupport('onLocationChange');
|
|
8
|
+
export const offLocationChangeError = temporarilyNotSupport('offLocationChangeError');
|
|
9
|
+
export const offLocationChange = temporarilyNotSupport('offLocationChange');
|
|
10
|
+
export const getLocation = processOpenApi('getLocation');
|
|
11
|
+
export const choosePoi = temporarilyNotSupport('choosePoi');
|
|
12
|
+
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
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
2
|
+
import { temporarilyNotSupport } from '../../utils';
|
|
3
|
+
import { CallbackManager } from '../../utils/handler';
|
|
4
|
+
class InnerAudioContext {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
7
|
+
this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
|
|
8
|
+
this.stop = () => {
|
|
9
|
+
this.pause();
|
|
10
|
+
this.seek(0);
|
|
11
|
+
this.stopStack.trigger();
|
|
12
|
+
};
|
|
13
|
+
this.seek = (position) => {
|
|
14
|
+
if (this.Instance) {
|
|
15
|
+
this.Instance.currentTime = position;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
this.destroy = () => {
|
|
19
|
+
this.stop();
|
|
20
|
+
if (this.Instance) {
|
|
21
|
+
document.body.removeChild(this.Instance);
|
|
22
|
+
this.Instance = undefined;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('oncanplay', callback); };
|
|
26
|
+
this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('onplay', callback); };
|
|
27
|
+
this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('onpause', callback); };
|
|
28
|
+
this.onStop = (callback = () => { }) => this.stopStack.add(callback);
|
|
29
|
+
this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('onended', callback); };
|
|
30
|
+
this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ontimeUpdate', callback); };
|
|
31
|
+
this.onError = (callback) => this.errorStack.add(callback);
|
|
32
|
+
this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('onwaiting', callback); };
|
|
33
|
+
this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('onseeking', callback); };
|
|
34
|
+
this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('onseeked', callback); };
|
|
35
|
+
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('offcanplay', callback); };
|
|
36
|
+
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('offplay', callback); };
|
|
37
|
+
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('offpause', callback); };
|
|
38
|
+
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
39
|
+
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('offended', callback); };
|
|
40
|
+
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('offtimeUpdate', callback); };
|
|
41
|
+
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
42
|
+
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('offwaiting', callback); };
|
|
43
|
+
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('offseeking', callback); };
|
|
44
|
+
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('offseeked', callback); };
|
|
45
|
+
this.Instance = new Audio();
|
|
46
|
+
this.errorStack = new CallbackManager();
|
|
47
|
+
this.stopStack = new CallbackManager();
|
|
48
|
+
Taro.eventCenter.on('__taroRouterChange', () => { this.stop(); });
|
|
49
|
+
}
|
|
50
|
+
set autoplay(e) { this.setProperty('autoplay', e); }
|
|
51
|
+
get autoplay() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.autoplay) || false; }
|
|
52
|
+
get buffered() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.buffered.length) || 0; }
|
|
53
|
+
get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
|
|
54
|
+
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
55
|
+
set loop(e) { this.setProperty('loop', e); }
|
|
56
|
+
get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
|
|
57
|
+
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || true; }
|
|
58
|
+
set src(e) { this.setProperty('src', e); }
|
|
59
|
+
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
60
|
+
set volume(e) { this.setProperty('volume', e); }
|
|
61
|
+
get volume() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
62
|
+
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
63
|
+
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
64
|
+
get obeyMuteSwitch() { return true; }
|
|
65
|
+
set startTime(e) { this.setProperty('startTime', e); }
|
|
66
|
+
get startTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
67
|
+
setProperty(key, value) {
|
|
68
|
+
if (this.Instance) {
|
|
69
|
+
this.Instance[key] = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export const stopVoice = temporarilyNotSupport('stopVoice');
|
|
74
|
+
export const setInnerAudioOption = temporarilyNotSupport('setInnerAudioOption');
|
|
75
|
+
export const playVoice = temporarilyNotSupport('playVoice');
|
|
76
|
+
export const pauseVoice = temporarilyNotSupport('pauseVoice');
|
|
77
|
+
export const getAvailableAudioSources = temporarilyNotSupport('getAvailableAudioSources');
|
|
78
|
+
export const createWebAudioContext = temporarilyNotSupport('createWebAudioContext');
|
|
79
|
+
export const createMediaAudioPlayer = temporarilyNotSupport('createMediaAudioPlayer');
|
|
80
|
+
export const createInnerAudioContext = () => new InnerAudioContext();
|
|
81
|
+
export const createAudioContext = temporarilyNotSupport('createAudioContext');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const stopBackgroundAudio = temporarilyNotSupport('stopBackgroundAudio');
|
|
3
|
+
export const seekBackgroundAudio = temporarilyNotSupport('seekBackgroundAudio');
|
|
4
|
+
export const playBackgroundAudio = temporarilyNotSupport('playBackgroundAudio');
|
|
5
|
+
export const pauseBackgroundAudio = temporarilyNotSupport('pauseBackgroundAudio');
|
|
6
|
+
export const onBackgroundAudioStop = temporarilyNotSupport('onBackgroundAudioStop');
|
|
7
|
+
export const onBackgroundAudioPlay = temporarilyNotSupport('onBackgroundAudioPlay');
|
|
8
|
+
export const onBackgroundAudioPause = temporarilyNotSupport('onBackgroundAudioPause');
|
|
9
|
+
export const getBackgroundAudioPlayerState = temporarilyNotSupport('getBackgroundAudioPlayerState');
|
|
10
|
+
export const getBackgroundAudioManager = temporarilyNotSupport('getBackgroundAudioManager');
|