@tarojs/taro-h5 3.4.4 → 3.4.7
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/device/scan.js +8 -4
- package/dist/api/location/chooseLocation.js +16 -7
- package/dist/api/location/getLocation.js +64 -0
- package/dist/api/location/index.js +6 -3
- package/dist/api/media/image/chooseImage.js +12 -1
- package/dist/api/media/image/getImageInfo.js +16 -1
- package/dist/api/network/request/index.js +4 -0
- package/dist/api/utils/index.js +30 -25
- package/dist/dist/api/ad/index.d.ts +6 -0
- package/dist/dist/api/ai/facial.d.ts +9 -0
- package/dist/dist/api/ai/index.d.ts +2 -0
- package/dist/dist/api/ai/visual.d.ts +6 -0
- package/dist/dist/api/alipay/index.d.ts +3 -0
- package/dist/dist/api/base/crypto.d.ts +3 -0
- package/dist/dist/api/base/debug.d.ts +9 -0
- package/dist/dist/api/base/index.d.ts +12 -0
- package/dist/dist/api/base/performance.d.ts +6 -0
- package/dist/dist/api/base/system.d.ts +25 -0
- package/dist/dist/api/base/update.d.ts +6 -0
- package/dist/dist/api/base/weapp/app-event.d.ts +48 -0
- package/dist/dist/api/base/weapp/life-cycle.d.ts +6 -0
- package/dist/dist/api/canvas/CanvasContext.d.ts +104 -0
- package/dist/dist/api/canvas/canvasGetImageData.d.ts +5 -0
- package/dist/dist/api/canvas/canvasPutImageData.d.ts +6 -0
- package/dist/dist/api/canvas/canvasToTempFilePath.d.ts +6 -0
- package/dist/dist/api/canvas/createCanvasContext.d.ts +5 -0
- package/dist/dist/api/canvas/index.d.ts +12 -0
- package/dist/dist/api/cloud/index.d.ts +31 -0
- package/dist/dist/api/data-analysis/index.d.ts +12 -0
- package/dist/dist/api/device/accelerometer.d.ts +17 -0
- package/dist/dist/api/device/accessibility.d.ts +3 -0
- package/dist/dist/api/device/battery.d.ts +5 -0
- package/dist/dist/api/device/bluetooth-ble.d.ts +48 -0
- package/dist/dist/api/device/bluetooth-peripheral.d.ts +9 -0
- package/dist/dist/api/device/bluetooth.d.ts +39 -0
- package/dist/dist/api/device/calendar.d.ts +6 -0
- package/dist/dist/api/device/clipboard.d.ts +15 -0
- package/dist/dist/api/device/compass.d.ts +17 -0
- package/dist/dist/api/device/contact.d.ts +6 -0
- package/dist/dist/api/device/crypto.d.ts +3 -0
- package/dist/dist/api/device/gyroscope.d.ts +12 -0
- package/dist/dist/api/device/iBeacon.d.ts +21 -0
- package/dist/dist/api/device/index.d.ts +23 -0
- package/dist/dist/api/device/keyboard.d.ts +12 -0
- package/dist/dist/api/device/memory.d.ts +6 -0
- package/dist/dist/api/device/motion.d.ts +17 -0
- package/dist/dist/api/device/network.d.ts +20 -0
- package/dist/dist/api/device/nfc.d.ts +21 -0
- package/dist/dist/api/device/phone.d.ts +2 -0
- package/dist/dist/api/device/scan.d.ts +3 -0
- package/dist/dist/api/device/screen.d.ts +18 -0
- package/dist/dist/api/device/vibrate.d.ts +9 -0
- package/dist/dist/api/device/wifi.d.ts +33 -0
- package/dist/dist/api/ext/index.d.ts +6 -0
- package/dist/dist/api/files/index.d.ts +24 -0
- package/dist/dist/api/framework/index.d.ts +4 -0
- package/dist/dist/api/index.d.ts +24 -0
- package/dist/dist/api/location/chooseLocation.d.ts +6 -0
- package/dist/dist/api/location/getLocation.d.ts +2 -0
- package/dist/dist/api/location/index.d.ts +29 -0
- package/dist/dist/api/media/EditorContext.d.ts +42 -0
- package/dist/dist/api/media/audio/InnerAudioContext.d.ts +58 -0
- package/dist/dist/api/media/audio/index.d.ts +29 -0
- package/dist/dist/api/media/background-audio/BackgroundAudioManager.d.ts +71 -0
- package/dist/dist/api/media/background-audio/index.d.ts +29 -0
- package/dist/dist/api/media/camera.d.ts +3 -0
- package/dist/dist/api/media/image/chooseImage.d.ts +5 -0
- package/dist/dist/api/media/image/getImageInfo.d.ts +5 -0
- package/dist/dist/api/media/image/index.d.ts +15 -0
- package/dist/dist/api/media/image/previewImage.d.ts +8 -0
- package/dist/dist/api/media/index.d.ts +12 -0
- package/dist/dist/api/media/live.d.ts +6 -0
- package/dist/dist/api/media/map.d.ts +3 -0
- package/dist/dist/api/media/media-recorder.d.ts +3 -0
- package/dist/dist/api/media/recorder.d.ts +9 -0
- package/dist/dist/api/media/video/index.d.ts +24 -0
- package/dist/dist/api/media/video-decoder.d.ts +3 -0
- package/dist/dist/api/media/video-processing.d.ts +3 -0
- package/dist/dist/api/media/voip.d.ts +42 -0
- package/dist/dist/api/navigate/index.d.ts +12 -0
- package/dist/dist/api/network/download.d.ts +6 -0
- package/dist/dist/api/network/index.d.ts +7 -0
- package/dist/dist/api/network/mdns.d.ts +30 -0
- package/dist/dist/api/network/request/index.d.ts +4 -0
- package/dist/dist/api/network/tcp.d.ts +3 -0
- package/dist/dist/api/network/udp.d.ts +3 -0
- package/dist/dist/api/network/upload.d.ts +5 -0
- package/dist/dist/api/network/utils.d.ts +44 -0
- package/dist/dist/api/network/websocket/index.d.ts +7 -0
- package/dist/dist/api/network/websocket/socketTask.d.ts +25 -0
- package/dist/dist/api/open-api/account.d.ts +3 -0
- package/dist/dist/api/open-api/address.d.ts +3 -0
- package/dist/dist/api/open-api/authorize.d.ts +6 -0
- package/dist/dist/api/open-api/card.d.ts +6 -0
- package/dist/dist/api/open-api/channels-live.d.ts +18 -0
- package/dist/dist/api/open-api/customer-service.d.ts +3 -0
- package/dist/dist/api/open-api/facial.d.ts +12 -0
- package/dist/dist/api/open-api/favorites.d.ts +6 -0
- package/dist/dist/api/open-api/group.d.ts +3 -0
- package/dist/dist/api/open-api/index.d.ts +18 -0
- package/dist/dist/api/open-api/invoice.d.ts +6 -0
- package/dist/dist/api/open-api/license-plate.d.ts +3 -0
- package/dist/dist/api/open-api/login.d.ts +9 -0
- package/dist/dist/api/open-api/red-package.d.ts +3 -0
- package/dist/dist/api/open-api/settings.d.ts +6 -0
- package/dist/dist/api/open-api/soter.d.ts +9 -0
- package/dist/dist/api/open-api/subscribe-message.d.ts +3 -0
- package/dist/dist/api/open-api/user-info.d.ts +6 -0
- package/dist/dist/api/open-api/werun.d.ts +6 -0
- package/dist/dist/api/payment/index.d.ts +6 -0
- package/dist/dist/api/route/index.d.ts +1 -0
- package/dist/dist/api/share/index.d.ts +30 -0
- package/dist/dist/api/storage/background-fetch.d.ts +12 -0
- package/dist/dist/api/storage/index.d.ts +18 -0
- package/dist/dist/api/swan/index.d.ts +63 -0
- package/dist/dist/api/taro.d.ts +12 -0
- package/dist/dist/api/ui/animation/index.d.ts +2 -0
- package/dist/dist/api/ui/background.d.ts +6 -0
- package/dist/dist/api/ui/custom-component.d.ts +1 -0
- package/dist/dist/api/ui/fonts.d.ts +2 -0
- package/dist/dist/api/ui/index.d.ts +12 -0
- package/dist/dist/api/ui/interaction/actionSheet.d.ts +61 -0
- package/dist/dist/api/ui/interaction/index.d.ts +14 -0
- package/dist/dist/api/ui/interaction/modal.d.ts +69 -0
- package/dist/dist/api/ui/interaction/toast.d.ts +85 -0
- package/dist/dist/api/ui/menu.d.ts +3 -0
- package/dist/dist/api/ui/navigation-bar/index.d.ts +15 -0
- package/dist/dist/api/ui/pull-down-refresh.d.ts +9 -0
- package/dist/dist/api/ui/scroll/index.d.ts +5 -0
- package/dist/dist/api/ui/sticky.d.ts +3 -0
- package/dist/dist/api/ui/tab-bar.d.ts +34 -0
- package/dist/dist/api/ui/window.d.ts +15 -0
- package/dist/dist/api/utils/handler.d.ts +48 -0
- package/dist/dist/api/utils/index.d.ts +45 -0
- package/dist/dist/api/worker/index.d.ts +3 -0
- package/dist/dist/api/wxml/index.d.ts +5 -0
- package/dist/dist/api/wxml/nodesRef.d.ts +13 -0
- package/dist/dist/api/wxml/selectorQuery.d.ts +24 -0
- package/dist/dist/index.d.ts +4 -0
- package/dist/dist/types/type.d.ts +29 -0
- package/dist/index.cjs.js +4675 -8471
- package/dist/index.cjs.js.map +1 -0
- package/dist/taroApis.js +1 -0
- package/dist/taroApis.js.map +1 -0
- package/package.json +12 -9
- package/src/api/device/scan.ts +8 -4
- package/src/api/location/chooseLocation.ts +14 -4
- package/src/api/location/getLocation.ts +80 -0
- package/src/api/location/index.ts +6 -3
- package/src/api/media/image/chooseImage.ts +18 -1
- package/src/api/media/image/getImageInfo.ts +16 -1
- package/src/api/network/request/index.ts +4 -0
- package/src/api/utils/index.ts +39 -23
package/dist/api/device/scan.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { processOpenApi } from '../utils';
|
|
2
2
|
// 扫码
|
|
3
|
-
export const scanCode = processOpenApi(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export const scanCode = processOpenApi({
|
|
4
|
+
name: 'scanQRCode',
|
|
5
|
+
defaultOptions: { needResult: 1 },
|
|
6
|
+
formatResult: res => ({
|
|
7
|
+
errMsg: res.errMsg === 'scanQRCode:ok' ? 'scanCode:ok' : res.errMsg,
|
|
8
|
+
result: res.resultStr
|
|
9
|
+
})
|
|
10
|
+
});
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { stringify } from 'query-string';
|
|
1
2
|
import { MethodHandler } from '../utils/handler';
|
|
2
3
|
import './style.css';
|
|
3
|
-
function createLocationChooser(handler, key = LOCATION_APIKEY) {
|
|
4
|
-
var _a, _b;
|
|
4
|
+
function createLocationChooser(handler, key = LOCATION_APIKEY, mapOpt = {}) {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
const { latitude, longitude, ...opts } = mapOpt;
|
|
7
|
+
const query = {
|
|
8
|
+
key,
|
|
9
|
+
type: 1,
|
|
10
|
+
coord: ((_a = mapOpt.coord) !== null && _a !== void 0 ? _a : [latitude, longitude].every(e => Number(e) >= 0)) ? `${latitude},${longitude}` : undefined,
|
|
11
|
+
referer: 'myapp',
|
|
12
|
+
...opts
|
|
13
|
+
};
|
|
5
14
|
const html = `
|
|
6
15
|
<div class='taro_choose_location'>
|
|
7
16
|
<div class='taro_choose_location_bar'>
|
|
@@ -9,7 +18,7 @@ function createLocationChooser(handler, key = LOCATION_APIKEY) {
|
|
|
9
18
|
<p class='taro_choose_location_title'>位置</p>
|
|
10
19
|
<button class='taro_choose_location_submit'>完成</button>
|
|
11
20
|
</div>
|
|
12
|
-
<iframe class='taro_choose_location_frame' frameborder='0' src=
|
|
21
|
+
<iframe class='taro_choose_location_frame' frameborder='0' src="https://apis.map.qq.com/tools/locpicker?${stringify(query, { arrayFormat: 'comma', skipNull: true })}" />
|
|
13
22
|
</div>
|
|
14
23
|
`;
|
|
15
24
|
const container = document.createElement('div');
|
|
@@ -35,8 +44,8 @@ function createLocationChooser(handler, key = LOCATION_APIKEY) {
|
|
|
35
44
|
container.remove();
|
|
36
45
|
window.removeEventListener('popstate', back);
|
|
37
46
|
}
|
|
38
|
-
(
|
|
39
|
-
(
|
|
47
|
+
(_b = container.querySelector('.taro_choose_location_back')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', back);
|
|
48
|
+
(_c = container.querySelector('.taro_choose_location_submit')) === null || _c === void 0 ? void 0 : _c.addEventListener('click', submit);
|
|
40
49
|
window.addEventListener('popstate', back);
|
|
41
50
|
return {
|
|
42
51
|
show,
|
|
@@ -47,7 +56,7 @@ function createLocationChooser(handler, key = LOCATION_APIKEY) {
|
|
|
47
56
|
/**
|
|
48
57
|
* 打开地图选择位置。
|
|
49
58
|
*/
|
|
50
|
-
export const chooseLocation = ({ success, fail, complete } = {}) => {
|
|
59
|
+
export const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
51
60
|
const key = LOCATION_APIKEY;
|
|
52
61
|
const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete });
|
|
53
62
|
return new Promise((resolve, reject) => {
|
|
@@ -85,7 +94,7 @@ export const chooseLocation = ({ success, fail, complete } = {}) => {
|
|
|
85
94
|
return handle.fail({}, reject);
|
|
86
95
|
}
|
|
87
96
|
}
|
|
88
|
-
}, key);
|
|
97
|
+
}, key, mapOpts);
|
|
89
98
|
document.body.appendChild(chooser.container);
|
|
90
99
|
window.addEventListener('message', onMessage, false);
|
|
91
100
|
chooser.show();
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { processOpenApi, shouldBeObject } from '../utils';
|
|
2
|
+
import { MethodHandler } from '../utils/handler';
|
|
3
|
+
const getLocationByW3CApi = (options) => {
|
|
4
|
+
var _a;
|
|
5
|
+
// 断言 options 必须是 Object
|
|
6
|
+
const isObject = shouldBeObject(options);
|
|
7
|
+
if (!isObject.flag) {
|
|
8
|
+
const res = { errMsg: `getLocation:fail ${isObject.msg}` };
|
|
9
|
+
console.error(res.errMsg);
|
|
10
|
+
return Promise.reject(res);
|
|
11
|
+
}
|
|
12
|
+
// 解构回调函数
|
|
13
|
+
const { success, fail, complete } = options;
|
|
14
|
+
const handle = new MethodHandler({ name: 'getLocation', success, fail, complete });
|
|
15
|
+
// const defaultMaximumAge = 5 * 1000
|
|
16
|
+
const positionOptions = {
|
|
17
|
+
enableHighAccuracy: options.isHighAccuracy || (options.altitude != null),
|
|
18
|
+
// maximumAge: defaultMaximumAge, // 允许取多久以内的缓存位置
|
|
19
|
+
timeout: options.highAccuracyExpireTime // 高精度定位超时时间
|
|
20
|
+
};
|
|
21
|
+
// Web端API实现暂时仅支持GPS坐标系
|
|
22
|
+
if (((_a = options.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== 'WGS84') {
|
|
23
|
+
return handle.fail({
|
|
24
|
+
errMsg: 'This coordinate system type is not temporarily supported'
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// 判断当前浏览器是否支持位置API
|
|
28
|
+
const geolocationSupported = navigator.geolocation;
|
|
29
|
+
if (!geolocationSupported) {
|
|
30
|
+
return handle.fail({
|
|
31
|
+
errMsg: 'The current browser does not support this feature'
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// 开始获取位置
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
navigator.geolocation.getCurrentPosition((position) => {
|
|
37
|
+
const result = {
|
|
38
|
+
/** 位置的精确度 */
|
|
39
|
+
accuracy: position.coords.accuracy,
|
|
40
|
+
/** 高度,单位 m */
|
|
41
|
+
altitude: position.coords.altitude,
|
|
42
|
+
/** 水平精度,单位 m */
|
|
43
|
+
horizontalAccuracy: position.coords.accuracy,
|
|
44
|
+
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
45
|
+
latitude: position.coords.latitude,
|
|
46
|
+
/** 经度,范围为 -180~180,负数表示西经 */
|
|
47
|
+
longitude: position.coords.longitude,
|
|
48
|
+
/** 速度,单位 m/s */
|
|
49
|
+
speed: position.coords.speed,
|
|
50
|
+
/** 垂直精度,单位 m(Android 无法获取,返回 0) */
|
|
51
|
+
verticalAccuracy: position.coords.altitudeAccuracy || 0,
|
|
52
|
+
/** 调用结果,自动补充 */
|
|
53
|
+
errMsg: ''
|
|
54
|
+
};
|
|
55
|
+
handle.success(result, resolve);
|
|
56
|
+
}, (error) => {
|
|
57
|
+
handle.fail({ errMsg: error.message }, reject);
|
|
58
|
+
}, positionOptions);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
export const getLocation = processOpenApi({
|
|
62
|
+
name: 'getLocation',
|
|
63
|
+
standardMethod: getLocationByW3CApi
|
|
64
|
+
});
|
|
@@ -3,11 +3,14 @@ import { processOpenApi, temporarilyNotSupport } from '../utils/index';
|
|
|
3
3
|
export const stopLocationUpdate = temporarilyNotSupport('stopLocationUpdate');
|
|
4
4
|
export const startLocationUpdateBackground = temporarilyNotSupport('startLocationUpdateBackground');
|
|
5
5
|
export const startLocationUpdate = temporarilyNotSupport('startLocationUpdate');
|
|
6
|
-
export const openLocation = processOpenApi(
|
|
6
|
+
export const openLocation = processOpenApi({
|
|
7
|
+
name: 'openLocation',
|
|
8
|
+
defaultOptions: { scale: 18 }
|
|
9
|
+
});
|
|
7
10
|
export const onLocationChangeError = temporarilyNotSupport('onLocationChangeError');
|
|
8
11
|
export const onLocationChange = temporarilyNotSupport('onLocationChange');
|
|
9
12
|
export const offLocationChangeError = temporarilyNotSupport('offLocationChangeError');
|
|
10
13
|
export const offLocationChange = temporarilyNotSupport('offLocationChange');
|
|
11
|
-
export
|
|
14
|
+
export { getLocation } from './getLocation';
|
|
12
15
|
export const choosePoi = temporarilyNotSupport('choosePoi');
|
|
13
|
-
export
|
|
16
|
+
export { chooseLocation } from './chooseLocation';
|
|
@@ -11,12 +11,14 @@ export const chooseImage = function (options) {
|
|
|
11
11
|
console.error(res.errMsg);
|
|
12
12
|
return Promise.reject(res);
|
|
13
13
|
}
|
|
14
|
-
const { count = 1, success, fail, complete, imageId = 'taroChooseImage' } = options;
|
|
14
|
+
const { count = 1, success, fail, complete, imageId = 'taroChooseImage', sourceType = ['album', 'camera'] } = options;
|
|
15
15
|
const handle = new MethodHandler({ name: 'chooseImage', success, fail, complete });
|
|
16
16
|
const res = {
|
|
17
17
|
tempFilePaths: [],
|
|
18
18
|
tempFiles: []
|
|
19
19
|
};
|
|
20
|
+
const sourceTypeString = sourceType && sourceType.toString();
|
|
21
|
+
const acceptableSourceType = ['user', 'environment', 'camera'];
|
|
20
22
|
if (count && typeof count !== 'number') {
|
|
21
23
|
res.errMsg = getParameterError({
|
|
22
24
|
para: 'count',
|
|
@@ -33,6 +35,9 @@ export const chooseImage = function (options) {
|
|
|
33
35
|
if (count > 1) {
|
|
34
36
|
obj.setAttribute('multiple', 'multiple');
|
|
35
37
|
}
|
|
38
|
+
if (acceptableSourceType.indexOf(sourceTypeString) > -1) {
|
|
39
|
+
obj.setAttribute('capture', sourceTypeString);
|
|
40
|
+
}
|
|
36
41
|
obj.setAttribute('accept', 'image/*');
|
|
37
42
|
obj.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
|
|
38
43
|
document.body.appendChild(obj);
|
|
@@ -45,6 +50,12 @@ export const chooseImage = function (options) {
|
|
|
45
50
|
else {
|
|
46
51
|
el.removeAttribute('multiple');
|
|
47
52
|
}
|
|
53
|
+
if (acceptableSourceType.indexOf(sourceTypeString) > -1) {
|
|
54
|
+
el.setAttribute('capture', sourceTypeString);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
el.removeAttribute('capture');
|
|
58
|
+
}
|
|
48
59
|
}
|
|
49
60
|
return new Promise(resolve => {
|
|
50
61
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
@@ -11,14 +11,29 @@ export const getImageInfo = (options) => {
|
|
|
11
11
|
console.error(res.errMsg);
|
|
12
12
|
return Promise.reject(res);
|
|
13
13
|
}
|
|
14
|
+
const getBase64Image = (image) => {
|
|
15
|
+
try {
|
|
16
|
+
const canvas = document.createElement('canvas');
|
|
17
|
+
canvas.width = image.width;
|
|
18
|
+
canvas.height = image.height;
|
|
19
|
+
const ctx = canvas.getContext('2d');
|
|
20
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
21
|
+
return canvas.toDataURL('image/png');
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
console.error('getImageInfo:get base64 fail', e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
14
27
|
const { src, success, fail, complete } = options;
|
|
15
28
|
const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete });
|
|
16
29
|
return new Promise((resolve, reject) => {
|
|
17
30
|
const image = new Image();
|
|
31
|
+
image.crossOrigin = '';
|
|
18
32
|
image.onload = () => {
|
|
19
33
|
handle.success({
|
|
20
34
|
width: image.naturalWidth,
|
|
21
|
-
height: image.naturalHeight
|
|
35
|
+
height: image.naturalHeight,
|
|
36
|
+
path: getBase64Image(image) || src
|
|
22
37
|
}, resolve);
|
|
23
38
|
};
|
|
24
39
|
image.onerror = (e) => {
|
|
@@ -84,6 +84,10 @@ function _request(options) {
|
|
|
84
84
|
params.credentials = options.credentials;
|
|
85
85
|
return fetch(url, params)
|
|
86
86
|
.then(response => {
|
|
87
|
+
if (!response) {
|
|
88
|
+
const errorResponse = { ok: false };
|
|
89
|
+
throw errorResponse;
|
|
90
|
+
}
|
|
87
91
|
res.statusCode = response.status;
|
|
88
92
|
res.header = {};
|
|
89
93
|
for (const key of response.headers.keys()) {
|
package/dist/api/utils/index.js
CHANGED
|
@@ -90,7 +90,7 @@ export function temporarilyNotSupport(apiName) {
|
|
|
90
90
|
}
|
|
91
91
|
export function weixinCorpSupport(apiName) {
|
|
92
92
|
return () => {
|
|
93
|
-
const errMsg = `h5
|
|
93
|
+
const errMsg = `h5端当前仅在微信公众号JS-SDK环境下支持此 API ${apiName}`;
|
|
94
94
|
if (process.env.NODE_ENV !== 'production') {
|
|
95
95
|
console.error(errMsg);
|
|
96
96
|
return Promise.reject({
|
|
@@ -129,31 +129,36 @@ const VALID_COLOR_REG = /^#[0-9a-fA-F]{6}$/;
|
|
|
129
129
|
export const isValidColor = (color) => {
|
|
130
130
|
return VALID_COLOR_REG.test(color);
|
|
131
131
|
};
|
|
132
|
-
export function processOpenApi(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
132
|
+
export function processOpenApi({ name, defaultOptions, standardMethod, formatOptions = options => options, formatResult = res => res }) {
|
|
133
|
+
const notSupported = weixinCorpSupport(name);
|
|
134
|
+
return (options = {}) => {
|
|
135
|
+
var _a;
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
|
|
138
|
+
const opts = formatOptions(Object.assign({}, defaultOptions, options));
|
|
139
|
+
if (typeof targetApi === 'function') {
|
|
140
|
+
return new Promise((resolve, reject) => {
|
|
141
|
+
['fail', 'success', 'complete'].forEach(k => {
|
|
142
|
+
opts[k] = preRef => {
|
|
143
|
+
const res = formatResult(preRef);
|
|
144
|
+
options[k] && options[k](res);
|
|
145
|
+
if (k === 'success') {
|
|
146
|
+
resolve(res);
|
|
147
|
+
}
|
|
148
|
+
else if (k === 'fail') {
|
|
149
|
+
reject(res);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return targetApi(opts);
|
|
153
|
+
});
|
|
152
154
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
}
|
|
156
|
+
else if (typeof standardMethod === 'function') {
|
|
157
|
+
return standardMethod(opts);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
return notSupported();
|
|
161
|
+
}
|
|
157
162
|
};
|
|
158
163
|
}
|
|
159
164
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const canIUse: () => Promise<{
|
|
2
|
+
errMsg: string;
|
|
3
|
+
}>;
|
|
4
|
+
export declare function arrayBufferToBase64(arrayBuffer: any): string;
|
|
5
|
+
export declare function base64ToArrayBuffer(base64: any): Uint8Array;
|
|
6
|
+
export * from './system';
|
|
7
|
+
export * from './update';
|
|
8
|
+
export * from './weapp/life-cycle';
|
|
9
|
+
export * from './weapp/app-event';
|
|
10
|
+
export * from './debug';
|
|
11
|
+
export * from './performance';
|
|
12
|
+
export * from './crypto';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
2
|
+
/** 跳转系统蓝牙设置页 */
|
|
3
|
+
export declare const openSystemBluetoothSetting: () => Promise<{
|
|
4
|
+
errMsg: string;
|
|
5
|
+
}>;
|
|
6
|
+
/** 跳转系统微信授权管理页 */
|
|
7
|
+
export declare const openAppAuthorizeSetting: () => Promise<{
|
|
8
|
+
errMsg: string;
|
|
9
|
+
}>;
|
|
10
|
+
/** 获取窗口信息 */
|
|
11
|
+
export declare const getWindowInfo: typeof Taro.getWindowInfo;
|
|
12
|
+
/** 获取设备设置 */
|
|
13
|
+
export declare const getSystemSetting: typeof Taro.getSystemSetting;
|
|
14
|
+
/** 获取设备设置 */
|
|
15
|
+
export declare const getDeviceInfo: typeof Taro.getDeviceInfo;
|
|
16
|
+
/** 获取微信APP基础信息 */
|
|
17
|
+
export declare const getAppBaseInfo: typeof Taro.getAppBaseInfo;
|
|
18
|
+
/** 获取微信APP授权设置 */
|
|
19
|
+
export declare const getAppAuthorizeSetting: typeof Taro.getAppAuthorizeSetting;
|
|
20
|
+
/** 获取设备设置 */
|
|
21
|
+
export declare const getSystemInfoSync: typeof Taro.getSystemInfoSync;
|
|
22
|
+
/** 获取系统信息 */
|
|
23
|
+
export declare const getSystemInfoAsync: typeof Taro.getSystemInfoAsync;
|
|
24
|
+
/** 获取系统信息 */
|
|
25
|
+
export declare const getSystemInfo: typeof Taro.getSystemInfo;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const onUnhandledRejection: () => Promise<{
|
|
2
|
+
errMsg: string;
|
|
3
|
+
}>;
|
|
4
|
+
export declare const onThemeChange: () => Promise<{
|
|
5
|
+
errMsg: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const onPageNotFound: () => Promise<{
|
|
8
|
+
errMsg: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const onError: () => Promise<{
|
|
11
|
+
errMsg: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const onAudioInterruptionEnd: () => Promise<{
|
|
14
|
+
errMsg: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const onAudioInterruptionBegin: () => Promise<{
|
|
17
|
+
errMsg: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const onAppShow: () => Promise<{
|
|
20
|
+
errMsg: string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const onAppHide: () => Promise<{
|
|
23
|
+
errMsg: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const offUnhandledRejection: () => Promise<{
|
|
26
|
+
errMsg: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const offThemeChange: () => Promise<{
|
|
29
|
+
errMsg: string;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const offPageNotFound: () => Promise<{
|
|
32
|
+
errMsg: string;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const offError: () => Promise<{
|
|
35
|
+
errMsg: string;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const offAudioInterruptionEnd: () => Promise<{
|
|
38
|
+
errMsg: string;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const offAudioInterruptionBegin: () => Promise<{
|
|
41
|
+
errMsg: string;
|
|
42
|
+
}>;
|
|
43
|
+
export declare const offAppShow: () => Promise<{
|
|
44
|
+
errMsg: string;
|
|
45
|
+
}>;
|
|
46
|
+
export declare const offAppHide: () => Promise<{
|
|
47
|
+
errMsg: string;
|
|
48
|
+
}>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { CanvasGradient } from '@tarojs/api';
|
|
2
|
+
interface IAction {
|
|
3
|
+
func: (...arr: any[]) => void;
|
|
4
|
+
args: any[];
|
|
5
|
+
}
|
|
6
|
+
export declare class CanvasContext implements Taro.CanvasContext {
|
|
7
|
+
__raw__: CanvasRenderingContext2D;
|
|
8
|
+
actions: IAction[];
|
|
9
|
+
constructor(canvas: any, ctx: any);
|
|
10
|
+
set ctx(e: CanvasRenderingContext2D);
|
|
11
|
+
get ctx(): CanvasRenderingContext2D;
|
|
12
|
+
canvas: HTMLCanvasElement;
|
|
13
|
+
protected emptyActions(): void;
|
|
14
|
+
protected enqueueActions(func: IAction['func'], ...args: any[]): void;
|
|
15
|
+
set fillStyle(e: string);
|
|
16
|
+
get fillStyle(): string;
|
|
17
|
+
set font(e: string);
|
|
18
|
+
get font(): string;
|
|
19
|
+
set globalAlpha(e: number);
|
|
20
|
+
get globalAlpha(): number;
|
|
21
|
+
set globalCompositeOperation(e: string);
|
|
22
|
+
get globalCompositeOperation(): string;
|
|
23
|
+
set lineCap(e: CanvasLineCap);
|
|
24
|
+
get lineCap(): CanvasLineCap;
|
|
25
|
+
set lineDashOffset(e: number);
|
|
26
|
+
get lineDashOffset(): number;
|
|
27
|
+
set lineJoin(e: CanvasLineJoin);
|
|
28
|
+
get lineJoin(): CanvasLineJoin;
|
|
29
|
+
set lineWidth(e: number);
|
|
30
|
+
get lineWidth(): number;
|
|
31
|
+
set miterLimit(e: number);
|
|
32
|
+
get miterLimit(): number;
|
|
33
|
+
set shadowBlur(e: number);
|
|
34
|
+
get shadowBlur(): number;
|
|
35
|
+
set shadowColor(e: string);
|
|
36
|
+
get shadowColor(): string;
|
|
37
|
+
set shadowOffsetX(e: number);
|
|
38
|
+
get shadowOffsetX(): number;
|
|
39
|
+
set shadowOffsetY(e: number);
|
|
40
|
+
get shadowOffsetY(): number;
|
|
41
|
+
set strokeStyle(e: string);
|
|
42
|
+
get strokeStyle(): string;
|
|
43
|
+
/** 小程序文档中不包括 ↓↓↓ */
|
|
44
|
+
set textAlign(e: CanvasTextAlign);
|
|
45
|
+
get textAlign(): CanvasTextAlign;
|
|
46
|
+
set textBaseline(e: CanvasTextBaseline);
|
|
47
|
+
get textBaseline(): CanvasTextBaseline;
|
|
48
|
+
set direction(e: CanvasDirection);
|
|
49
|
+
get direction(): CanvasDirection;
|
|
50
|
+
set imageSmoothingEnabled(e: boolean);
|
|
51
|
+
get imageSmoothingEnabled(): boolean;
|
|
52
|
+
set imageSmoothingQuality(e: ImageSmoothingQuality);
|
|
53
|
+
get imageSmoothingQuality(): ImageSmoothingQuality;
|
|
54
|
+
set filter(e: string);
|
|
55
|
+
get filter(): string;
|
|
56
|
+
/** 小程序文档中不包括 ↑↑↑ */
|
|
57
|
+
arc(...args: any[]): void;
|
|
58
|
+
arcTo(...args: any[]): void;
|
|
59
|
+
beginPath(...args: any[]): void;
|
|
60
|
+
bezierCurveTo(...args: any[]): void;
|
|
61
|
+
clearRect(...args: any[]): void;
|
|
62
|
+
clip(...args: any[]): void;
|
|
63
|
+
closePath(...args: any[]): void;
|
|
64
|
+
createPattern(image: string, repetition: keyof Taro.CanvasContext.Repetition): void;
|
|
65
|
+
/**
|
|
66
|
+
* 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。
|
|
67
|
+
* @todo 每次 draw 都会读取 width 和 height
|
|
68
|
+
*/
|
|
69
|
+
draw(reserve?: boolean, callback?: (...args: any[]) => any): Promise<void>;
|
|
70
|
+
drawImage(imageResource: string, ...extra: any[]): void;
|
|
71
|
+
fill(...args: any[]): void;
|
|
72
|
+
fillRect(...args: any[]): void;
|
|
73
|
+
fillText(...args: any[]): void;
|
|
74
|
+
lineTo(...args: any[]): void;
|
|
75
|
+
moveTo(...args: any[]): void;
|
|
76
|
+
quadraticCurveTo(...args: any[]): void;
|
|
77
|
+
rect(...args: any[]): void;
|
|
78
|
+
restore(...args: any[]): void;
|
|
79
|
+
rotate(...args: any[]): void;
|
|
80
|
+
save(...args: any[]): void;
|
|
81
|
+
scale(...args: any[]): void;
|
|
82
|
+
setFillStyle(color: string | CanvasGradient): void;
|
|
83
|
+
setFontSize(fontSize: number): void;
|
|
84
|
+
setGlobalAlpha(alpha: number): void;
|
|
85
|
+
setLineCap(lineCap: keyof Taro.CanvasContext.LineCap): void;
|
|
86
|
+
setLineDash(pattern: number[], offset: number): void;
|
|
87
|
+
setLineJoin(lineJoin: keyof Taro.CanvasContext.LineJoin): void;
|
|
88
|
+
setLineWidth(lineWidth: number): void;
|
|
89
|
+
setMiterLimit(miterLimit: number): void;
|
|
90
|
+
setShadow(offsetX: number, offsetY: number, blur: number, color: string): void;
|
|
91
|
+
setStrokeStyle(color: string | CanvasGradient): void;
|
|
92
|
+
setTextAlign(align: keyof Taro.CanvasContext.Align): void;
|
|
93
|
+
setTextBaseline(textBaseline: keyof Taro.CanvasContext.TextBaseline): void;
|
|
94
|
+
setTransform(...args: any[]): void;
|
|
95
|
+
stroke(...args: any[]): void;
|
|
96
|
+
strokeRect(...args: any[]): void;
|
|
97
|
+
strokeText(...args: any[]): void;
|
|
98
|
+
transform(...args: any[]): void;
|
|
99
|
+
translate(...args: any[]): void;
|
|
100
|
+
measureText(text: string): TextMetrics;
|
|
101
|
+
createCircularGradient(x: number, y: number, r: number): CanvasGradient;
|
|
102
|
+
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 创建离屏 canvas 实例 */
|
|
2
|
+
export declare const createOffscreenCanvas: () => Promise<{
|
|
3
|
+
errMsg: string;
|
|
4
|
+
}>;
|
|
5
|
+
/** 创建 canvas 的绘图上下文 CanvasContext 对象 */
|
|
6
|
+
export * from './createCanvasContext';
|
|
7
|
+
/** 把当前画布指定区域的内容导出生成指定大小的图片 */
|
|
8
|
+
export * from './canvasToTempFilePath';
|
|
9
|
+
/** 将像素数据绘制到画布 */
|
|
10
|
+
export * from './canvasPutImageData';
|
|
11
|
+
/** 获取 canvas 区域隐含的像素数据 */
|
|
12
|
+
export * from './canvasGetImageData';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
2
|
+
export declare class cloud implements Taro.cloud {
|
|
3
|
+
Cloud: new (options: Taro.cloud.IOptions) => Taro.Cloud;
|
|
4
|
+
init: () => Promise<{
|
|
5
|
+
errMsg: string;
|
|
6
|
+
}>;
|
|
7
|
+
CloudID: () => Promise<{
|
|
8
|
+
errMsg: string;
|
|
9
|
+
}>;
|
|
10
|
+
callFunction: () => Promise<{
|
|
11
|
+
errMsg: string;
|
|
12
|
+
}>;
|
|
13
|
+
uploadFile: () => Promise<{
|
|
14
|
+
errMsg: string;
|
|
15
|
+
}>;
|
|
16
|
+
downloadFile: () => Promise<{
|
|
17
|
+
errMsg: string;
|
|
18
|
+
}>;
|
|
19
|
+
getTempFileURL: () => Promise<{
|
|
20
|
+
errMsg: string;
|
|
21
|
+
}>;
|
|
22
|
+
deleteFile: () => Promise<{
|
|
23
|
+
errMsg: string;
|
|
24
|
+
}>;
|
|
25
|
+
database: () => Promise<{
|
|
26
|
+
errMsg: string;
|
|
27
|
+
}>;
|
|
28
|
+
callContainer: () => Promise<{
|
|
29
|
+
errMsg: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|