@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,4 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const setEnableDebug = temporarilyNotSupport('setEnableDebug');
|
|
3
|
+
export const getRealtimeLogManager = temporarilyNotSupport('getRealtimeLogManager');
|
|
4
|
+
export const getLogManager = temporarilyNotSupport('getLogManager');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fromByteArray, toByteArray } from 'base64-js';
|
|
2
|
+
import { temporarilyNotSupport } from '../utils';
|
|
3
|
+
export const canIUse = temporarilyNotSupport('canIUse');
|
|
4
|
+
export function arrayBufferToBase64(arrayBuffer) {
|
|
5
|
+
return fromByteArray(arrayBuffer);
|
|
6
|
+
}
|
|
7
|
+
export function base64ToArrayBuffer(base64) {
|
|
8
|
+
return toByteArray(base64);
|
|
9
|
+
}
|
|
10
|
+
export * from './system';
|
|
11
|
+
export * from './update';
|
|
12
|
+
export * from './weapp/life-cycle';
|
|
13
|
+
export * from './weapp/app-event';
|
|
14
|
+
export * from './debug';
|
|
15
|
+
export * from './performance';
|
|
16
|
+
export * from './crypto';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import MobileDetect from 'mobile-detect';
|
|
2
|
+
import { MethodHandler } from '../../utils/handler';
|
|
3
|
+
export const getSystemInfoSync = () => {
|
|
4
|
+
const md = new MobileDetect(navigator.userAgent);
|
|
5
|
+
const info = {
|
|
6
|
+
brand: md.mobile() || '',
|
|
7
|
+
model: md.mobile() || '',
|
|
8
|
+
system: md.os(),
|
|
9
|
+
pixelRatio: window.devicePixelRatio,
|
|
10
|
+
screenWidth: window.screen.width,
|
|
11
|
+
screenHeight: window.screen.height,
|
|
12
|
+
windowWidth: document.documentElement.clientWidth,
|
|
13
|
+
windowHeight: document.documentElement.clientHeight,
|
|
14
|
+
version: '',
|
|
15
|
+
statusBarHeight: NaN,
|
|
16
|
+
platform: navigator.platform,
|
|
17
|
+
language: navigator.language,
|
|
18
|
+
fontSizeSetting: NaN,
|
|
19
|
+
SDKVersion: '',
|
|
20
|
+
albumAuthorized: false,
|
|
21
|
+
benchmarkLevel: 0,
|
|
22
|
+
bluetoothEnabled: false,
|
|
23
|
+
cameraAuthorized: false,
|
|
24
|
+
enableDebug: false,
|
|
25
|
+
locationAuthorized: false,
|
|
26
|
+
locationEnabled: false,
|
|
27
|
+
microphoneAuthorized: false,
|
|
28
|
+
notificationAlertAuthorized: false,
|
|
29
|
+
notificationAuthorized: false,
|
|
30
|
+
notificationBadgeAuthorized: false,
|
|
31
|
+
notificationSoundAuthorized: false,
|
|
32
|
+
safeArea: {
|
|
33
|
+
bottom: 0,
|
|
34
|
+
height: 0,
|
|
35
|
+
left: 0,
|
|
36
|
+
right: 0,
|
|
37
|
+
top: 0,
|
|
38
|
+
width: 0
|
|
39
|
+
},
|
|
40
|
+
wifiEnabled: false
|
|
41
|
+
};
|
|
42
|
+
return info;
|
|
43
|
+
};
|
|
44
|
+
export const getSystemInfo = async (options = {}) => {
|
|
45
|
+
const { success, fail, complete } = options;
|
|
46
|
+
const handle = new MethodHandler({ name: 'getSystemInfo', success, fail, complete });
|
|
47
|
+
try {
|
|
48
|
+
const info = await getSystemInfoSync();
|
|
49
|
+
return handle.success(info);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return handle.fail({
|
|
53
|
+
errMsg: error
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { MethodHandler } from '../../utils/handler';
|
|
2
|
+
import { temporarilyNotSupport } from '../../utils';
|
|
3
|
+
function getConnection() {
|
|
4
|
+
return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection;
|
|
5
|
+
}
|
|
6
|
+
export const getNetworkType = (options = {}) => {
|
|
7
|
+
const connection = getConnection();
|
|
8
|
+
const { success, fail, complete } = options;
|
|
9
|
+
const handle = new MethodHandler({ name: 'getNetworkType', success, fail, complete });
|
|
10
|
+
let networkType = 'unknown';
|
|
11
|
+
if (!connection) {
|
|
12
|
+
return handle.success({ networkType });
|
|
13
|
+
}
|
|
14
|
+
if (!isNaN(Number(connection.type))) {
|
|
15
|
+
switch (connection.type) {
|
|
16
|
+
case connection.WIFI:
|
|
17
|
+
networkType = 'wifi';
|
|
18
|
+
break;
|
|
19
|
+
case connection.CELL_3G:
|
|
20
|
+
networkType = '3g';
|
|
21
|
+
break;
|
|
22
|
+
case connection.CELL_2G:
|
|
23
|
+
networkType = '2g';
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
networkType = 'unknown';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (connection.type) {
|
|
30
|
+
networkType = connection.type;
|
|
31
|
+
}
|
|
32
|
+
else if (connection.effectiveType) {
|
|
33
|
+
networkType = connection.effectiveType;
|
|
34
|
+
}
|
|
35
|
+
return handle.success({ networkType });
|
|
36
|
+
};
|
|
37
|
+
export const onNetworkStatusChange = (cb) => {
|
|
38
|
+
const connection = getConnection();
|
|
39
|
+
if (connection) {
|
|
40
|
+
connection.addEventListener('change', function () {
|
|
41
|
+
getNetworkType()
|
|
42
|
+
.then(res => {
|
|
43
|
+
const { networkType } = res;
|
|
44
|
+
const isConnected = networkType !== 'none';
|
|
45
|
+
const obj = { isConnected, networkType };
|
|
46
|
+
cb(obj);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export const offNetworkStatusChange = temporarilyNotSupport('offNetworkStatusChange');
|
|
52
|
+
export const getLocalIPAddress = temporarilyNotSupport('getLocalIPAddress');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../../utils';
|
|
2
|
+
export const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection');
|
|
3
|
+
export const onThemeChange = temporarilyNotSupport('onThemeChange');
|
|
4
|
+
export const onPageNotFound = temporarilyNotSupport('onPageNotFound');
|
|
5
|
+
export const onError = temporarilyNotSupport('onError');
|
|
6
|
+
export const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd');
|
|
7
|
+
export const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin');
|
|
8
|
+
export const onAppShow = temporarilyNotSupport('onAppShow');
|
|
9
|
+
export const onAppHide = temporarilyNotSupport('onAppHide');
|
|
10
|
+
export const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection');
|
|
11
|
+
export const offThemeChange = temporarilyNotSupport('offThemeChange');
|
|
12
|
+
export const offPageNotFound = temporarilyNotSupport('offPageNotFound');
|
|
13
|
+
export const offError = temporarilyNotSupport('offError');
|
|
14
|
+
export const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd');
|
|
15
|
+
export const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin');
|
|
16
|
+
export const offAppShow = temporarilyNotSupport('offAppShow');
|
|
17
|
+
export const offAppHide = temporarilyNotSupport('offAppHide');
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
const TextBaseLineMap = {
|
|
2
|
+
top: 'top',
|
|
3
|
+
bottom: 'bottom',
|
|
4
|
+
middle: 'middle',
|
|
5
|
+
normal: 'alphabetic'
|
|
6
|
+
};
|
|
7
|
+
export class CanvasContext {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.actions = [];
|
|
10
|
+
this.arc = this.enqueueActions(this.ctx.arc);
|
|
11
|
+
this.arcTo = this.enqueueActions(this.ctx.arcTo);
|
|
12
|
+
this.beginPath = this.enqueueActions(this.ctx.beginPath);
|
|
13
|
+
this.bezierCurveTo = this.enqueueActions(this.ctx.bezierCurveTo);
|
|
14
|
+
this.clearRect = this.enqueueActions(this.ctx.clearRect);
|
|
15
|
+
this.clip = this.enqueueActions(this.ctx.clip);
|
|
16
|
+
this.closePath = this.enqueueActions(this.ctx.closePath);
|
|
17
|
+
this.fill = this.enqueueActions(this.ctx.fill);
|
|
18
|
+
this.fillRect = this.enqueueActions(this.ctx.fillRect);
|
|
19
|
+
this.fillText = this.enqueueActions(this.ctx.fillText);
|
|
20
|
+
this.lineTo = this.enqueueActions(this.ctx.lineTo);
|
|
21
|
+
this.moveTo = this.enqueueActions(this.ctx.moveTo);
|
|
22
|
+
this.quadraticCurveTo = this.enqueueActions(this.ctx.quadraticCurveTo);
|
|
23
|
+
this.rect = this.enqueueActions(this.ctx.rect);
|
|
24
|
+
this.restore = this.enqueueActions(this.ctx.restore);
|
|
25
|
+
this.rotate = this.enqueueActions(this.ctx.rotate);
|
|
26
|
+
this.save = this.enqueueActions(this.ctx.save);
|
|
27
|
+
this.scale = this.enqueueActions(this.ctx.scale);
|
|
28
|
+
this.setTransform = this.enqueueActions(this.ctx.setTransform);
|
|
29
|
+
this.stroke = this.enqueueActions(this.ctx.stroke);
|
|
30
|
+
this.strokeRect = this.enqueueActions(this.ctx.strokeRect);
|
|
31
|
+
this.strokeText = this.enqueueActions(this.ctx.strokeText);
|
|
32
|
+
this.transform = this.enqueueActions(this.ctx.transform);
|
|
33
|
+
this.translate = this.enqueueActions(this.ctx.translate);
|
|
34
|
+
}
|
|
35
|
+
set ctx(e) {
|
|
36
|
+
this.__raw__ = e;
|
|
37
|
+
}
|
|
38
|
+
get ctx() {
|
|
39
|
+
return this.__raw__;
|
|
40
|
+
}
|
|
41
|
+
emptyActions() {
|
|
42
|
+
this.actions.length = 0;
|
|
43
|
+
}
|
|
44
|
+
enqueueActions(func) {
|
|
45
|
+
return (...args) => {
|
|
46
|
+
this.actions.push({
|
|
47
|
+
func,
|
|
48
|
+
args
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
set fillStyle(e) { this.enqueueActions(() => { this.ctx.fillStyle = e; }); }
|
|
53
|
+
get fillStyle() { return this.ctx.fillStyle; }
|
|
54
|
+
set font(e) { this.ctx.font = e; }
|
|
55
|
+
get font() { return this.ctx.font; }
|
|
56
|
+
set globalAlpha(e) { this.enqueueActions(() => { this.ctx.globalAlpha = e; }); }
|
|
57
|
+
get globalAlpha() { return this.ctx.globalAlpha; }
|
|
58
|
+
set globalCompositeOperation(e) { this.enqueueActions(() => { this.ctx.globalCompositeOperation = e; }); }
|
|
59
|
+
get globalCompositeOperation() { return this.ctx.globalCompositeOperation; }
|
|
60
|
+
set lineCap(e) { this.enqueueActions(() => { this.ctx.lineCap = e; }); }
|
|
61
|
+
get lineCap() { return this.ctx.lineCap; }
|
|
62
|
+
set lineDashOffset(e) { this.enqueueActions(() => { this.ctx.lineDashOffset = e; }); }
|
|
63
|
+
get lineDashOffset() { return this.ctx.lineDashOffset; }
|
|
64
|
+
set lineJoin(e) { this.enqueueActions(() => { this.ctx.lineJoin = e; }); }
|
|
65
|
+
get lineJoin() { return this.ctx.lineJoin; }
|
|
66
|
+
set lineWidth(e) { this.enqueueActions(() => { this.ctx.lineWidth = e; }); }
|
|
67
|
+
get lineWidth() { return this.ctx.lineWidth; }
|
|
68
|
+
set miterLimit(e) { this.enqueueActions(() => { this.ctx.miterLimit = e; }); }
|
|
69
|
+
get miterLimit() { return this.ctx.miterLimit; }
|
|
70
|
+
set shadowBlur(e) { this.enqueueActions(() => { this.ctx.shadowBlur = e; }); }
|
|
71
|
+
get shadowBlur() { return this.ctx.shadowBlur; }
|
|
72
|
+
set shadowColor(e) { this.enqueueActions(() => { this.ctx.shadowColor = e; }); }
|
|
73
|
+
get shadowColor() { return this.ctx.shadowColor; }
|
|
74
|
+
set shadowOffsetX(e) { this.enqueueActions(() => { this.ctx.shadowOffsetX = e; }); }
|
|
75
|
+
get shadowOffsetX() { return this.ctx.shadowOffsetX; }
|
|
76
|
+
set shadowOffsetY(e) { this.enqueueActions(() => { this.ctx.shadowOffsetY = e; }); }
|
|
77
|
+
get shadowOffsetY() { return this.ctx.shadowOffsetY; }
|
|
78
|
+
set strokeStyle(e) { this.enqueueActions(() => { this.ctx.strokeStyle = e; }); }
|
|
79
|
+
get strokeStyle() { return this.ctx.strokeStyle; }
|
|
80
|
+
set textAlign(e) { this.ctx.textAlign = e; }
|
|
81
|
+
get textAlign() { return this.ctx.textAlign; }
|
|
82
|
+
set textBaseline(e) { this.ctx.textBaseline = e; }
|
|
83
|
+
get textBaseline() { return this.ctx.textBaseline; }
|
|
84
|
+
set direction(e) { this.ctx.direction = e; }
|
|
85
|
+
get direction() { return this.ctx.direction; }
|
|
86
|
+
set imageSmoothingEnabled(e) { this.enqueueActions(() => { this.ctx.imageSmoothingEnabled = e; }); }
|
|
87
|
+
get imageSmoothingEnabled() { return this.ctx.imageSmoothingEnabled; }
|
|
88
|
+
set imageSmoothingQuality(e) { this.enqueueActions(() => { this.ctx.imageSmoothingQuality = e; }); }
|
|
89
|
+
get imageSmoothingQuality() { return this.ctx.imageSmoothingQuality; }
|
|
90
|
+
set filter(e) { this.enqueueActions(() => { this.ctx.filter = e; }); }
|
|
91
|
+
get filter() { return this.ctx.filter; }
|
|
92
|
+
createPattern(image, repetition) {
|
|
93
|
+
return this.createPattern(image, repetition);
|
|
94
|
+
}
|
|
95
|
+
async draw(reserve, callback) {
|
|
96
|
+
try {
|
|
97
|
+
if (!reserve) {
|
|
98
|
+
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
99
|
+
}
|
|
100
|
+
for (const { func, args } of this.actions) {
|
|
101
|
+
await func.apply(this.ctx, args);
|
|
102
|
+
}
|
|
103
|
+
this.emptyActions();
|
|
104
|
+
callback && callback();
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
throw {
|
|
108
|
+
errMsg: e.message
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
drawImage(imageResource, ...extra) {
|
|
113
|
+
this.enqueueActions(() => {
|
|
114
|
+
if (typeof imageResource === 'string') {
|
|
115
|
+
const img = new Image();
|
|
116
|
+
img.src = imageResource;
|
|
117
|
+
return new Promise((resolve, reject) => {
|
|
118
|
+
img.onload = () => {
|
|
119
|
+
this.ctx.drawImage(img, ...extra);
|
|
120
|
+
resolve();
|
|
121
|
+
};
|
|
122
|
+
img.onerror = reject;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
this.ctx.drawImage(imageResource, ...extra);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
setFillStyle(color) {
|
|
129
|
+
this.enqueueActions(() => { this.ctx.fillStyle = color; });
|
|
130
|
+
}
|
|
131
|
+
setFontSize(fontSize) {
|
|
132
|
+
this.font = `${fontSize}px`;
|
|
133
|
+
}
|
|
134
|
+
setGlobalAlpha(alpha) {
|
|
135
|
+
this.globalAlpha = alpha;
|
|
136
|
+
}
|
|
137
|
+
setLineCap(lineCap) {
|
|
138
|
+
this.lineCap = lineCap;
|
|
139
|
+
}
|
|
140
|
+
setLineDash(pattern, offset) {
|
|
141
|
+
this.enqueueActions(() => {
|
|
142
|
+
this.ctx.setLineDash(pattern);
|
|
143
|
+
this.ctx.lineDashOffset = offset;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
setLineJoin(lineJoin) {
|
|
147
|
+
this.lineJoin = lineJoin;
|
|
148
|
+
}
|
|
149
|
+
setLineWidth(lineWidth) {
|
|
150
|
+
this.lineWidth = lineWidth;
|
|
151
|
+
}
|
|
152
|
+
setMiterLimit(miterLimit) {
|
|
153
|
+
this.miterLimit = miterLimit;
|
|
154
|
+
}
|
|
155
|
+
setShadow(offsetX, offsetY, blur, color) {
|
|
156
|
+
this.enqueueActions(() => {
|
|
157
|
+
this.ctx.shadowOffsetX = offsetX;
|
|
158
|
+
this.ctx.shadowOffsetY = offsetY;
|
|
159
|
+
this.ctx.shadowColor = color;
|
|
160
|
+
this.ctx.shadowBlur = blur;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
setStrokeStyle(color) {
|
|
164
|
+
this.enqueueActions(() => { this.ctx.strokeStyle = color; });
|
|
165
|
+
}
|
|
166
|
+
setTextAlign(align) {
|
|
167
|
+
this.textAlign = align;
|
|
168
|
+
}
|
|
169
|
+
setTextBaseline(textBaseline) {
|
|
170
|
+
this.textBaseline = TextBaseLineMap[textBaseline] || 'alphabetic';
|
|
171
|
+
}
|
|
172
|
+
measureText(text) {
|
|
173
|
+
return this.measureText(text);
|
|
174
|
+
}
|
|
175
|
+
createCircularGradient(x, y, r) {
|
|
176
|
+
const radialGradient = this.ctx.createRadialGradient(x, y, 0, x, y, r);
|
|
177
|
+
return radialGradient;
|
|
178
|
+
}
|
|
179
|
+
createLinearGradient(x0, y0, x1, y1) {
|
|
180
|
+
return this.createLinearGradient(x0, y0, x1, y1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MethodHandler } from '../utils/handler';
|
|
2
|
+
import { findDOM } from '../utils';
|
|
3
|
+
export const canvasGetImageData = ({ canvasId, success, fail, complete, x, y, width, height }, inst) => {
|
|
4
|
+
const handle = new MethodHandler({ name: 'canvasGetImageData', success, fail, complete });
|
|
5
|
+
const el = findDOM(inst);
|
|
6
|
+
const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
|
|
7
|
+
try {
|
|
8
|
+
const ctx = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d');
|
|
9
|
+
const data = ctx === null || ctx === void 0 ? void 0 : ctx.getImageData(x, y, width, height);
|
|
10
|
+
return handle.success({
|
|
11
|
+
width,
|
|
12
|
+
height,
|
|
13
|
+
data
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
return handle.fail({
|
|
18
|
+
errMsg: e.message
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MethodHandler } from '../utils/handler';
|
|
2
|
+
import { findDOM } from '../utils';
|
|
3
|
+
export const canvasPutImageData = ({ canvasId, data, x, y, success, fail, complete }, inst) => {
|
|
4
|
+
const handle = new MethodHandler({ name: 'canvasPutImageData', success, fail, complete });
|
|
5
|
+
const el = findDOM(inst);
|
|
6
|
+
const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
|
|
7
|
+
try {
|
|
8
|
+
const ctx = canvas.getContext('2d');
|
|
9
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.putImageData(data, x, y);
|
|
10
|
+
return handle.success();
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
return handle.fail({
|
|
14
|
+
errMsg: e.message
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { findDOM } from '../utils';
|
|
2
|
+
import { MethodHandler } from '../utils/handler';
|
|
3
|
+
export const canvasToTempFilePath = ({ canvasId, fileType, quality, success, fail, complete }, inst) => {
|
|
4
|
+
const handle = new MethodHandler({ name: 'canvasToTempFilePath', success, fail, complete });
|
|
5
|
+
const el = findDOM(inst);
|
|
6
|
+
const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
|
|
7
|
+
try {
|
|
8
|
+
const dataURL = canvas === null || canvas === void 0 ? void 0 : canvas.toDataURL(`image/${fileType || 'png'}`, quality);
|
|
9
|
+
return handle.success({
|
|
10
|
+
tempFilePath: dataURL
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
return handle.fail({
|
|
15
|
+
errMsg: e.message
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { findDOM } from '../utils';
|
|
2
|
+
import { CanvasContext } from './CanvasContext';
|
|
3
|
+
export const createCanvasContext = (canvasId, inst) => {
|
|
4
|
+
const context = new CanvasContext();
|
|
5
|
+
const el = findDOM(inst);
|
|
6
|
+
const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
|
|
7
|
+
const ctx = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d');
|
|
8
|
+
if (!ctx)
|
|
9
|
+
return context;
|
|
10
|
+
context.canvas = canvas;
|
|
11
|
+
context.ctx = ctx;
|
|
12
|
+
return context;
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const createOffscreenCanvas = temporarilyNotSupport('createOffscreenCanvas');
|
|
3
|
+
export * from './createCanvasContext';
|
|
4
|
+
export * from './canvasToTempFilePath';
|
|
5
|
+
export * from './canvasPutImageData';
|
|
6
|
+
export * from './canvasGetImageData';
|
|
7
|
+
export const drawCanvas = temporarilyNotSupport('drawCanvas');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export class cloud {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.init = temporarilyNotSupport('cloud.init');
|
|
5
|
+
this.CloudID = temporarilyNotSupport('cloud.CloudID');
|
|
6
|
+
this.callFunction = temporarilyNotSupport('cloud.callFunction');
|
|
7
|
+
this.uploadFile = temporarilyNotSupport('cloud.uploadFile');
|
|
8
|
+
this.downloadFile = temporarilyNotSupport('cloud.downloadFile');
|
|
9
|
+
this.getTempFileURL = temporarilyNotSupport('cloud.getTempFileURL');
|
|
10
|
+
this.deleteFile = temporarilyNotSupport('cloud.deleteFile');
|
|
11
|
+
this.database = temporarilyNotSupport('cloud.database');
|
|
12
|
+
this.callContainer = temporarilyNotSupport('cloud.callContainer');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const reportMonitor = temporarilyNotSupport('reportMonitor');
|
|
3
|
+
export const reportAnalytics = temporarilyNotSupport('reportAnalytics');
|
|
4
|
+
export const reportEvent = temporarilyNotSupport('reportEvent');
|
|
5
|
+
export const getExptInfoSync = temporarilyNotSupport('getExptInfoSync');
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CallbackManager, MethodHandler } from '../utils/handler';
|
|
2
|
+
const callbackManager = new CallbackManager();
|
|
3
|
+
let devicemotionListener;
|
|
4
|
+
export const stopAccelerometer = ({ success, fail, complete } = {}) => {
|
|
5
|
+
const res = {};
|
|
6
|
+
const handle = new MethodHandler({ name: 'stopAccelerometer', success, fail, complete });
|
|
7
|
+
try {
|
|
8
|
+
window.removeEventListener('devicemotion', devicemotionListener, true);
|
|
9
|
+
return handle.success(res);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
res.errMsg = e.message;
|
|
13
|
+
return handle.fail(res);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const INTERVAL_MAP = {
|
|
17
|
+
game: {
|
|
18
|
+
interval: 20,
|
|
19
|
+
frequency: 50
|
|
20
|
+
},
|
|
21
|
+
ui: {
|
|
22
|
+
interval: 60,
|
|
23
|
+
frequency: 16.67
|
|
24
|
+
},
|
|
25
|
+
normal: {
|
|
26
|
+
interval: 200,
|
|
27
|
+
frequency: 5
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const getDevicemotionListener = interval => {
|
|
31
|
+
let lock;
|
|
32
|
+
let timer;
|
|
33
|
+
return evt => {
|
|
34
|
+
if (lock)
|
|
35
|
+
return;
|
|
36
|
+
lock = true;
|
|
37
|
+
timer && clearTimeout(timer);
|
|
38
|
+
callbackManager.trigger({
|
|
39
|
+
x: evt.acceleration.x || 0,
|
|
40
|
+
y: evt.acceleration.y || 0,
|
|
41
|
+
z: evt.acceleration.z || 0
|
|
42
|
+
});
|
|
43
|
+
timer = setTimeout(() => { lock = false; }, interval);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export const startAccelerometer = ({ interval = 'normal', success, fail, complete } = {}) => {
|
|
47
|
+
const handle = new MethodHandler({ name: 'startAccelerometer', success, fail, complete });
|
|
48
|
+
try {
|
|
49
|
+
if (window.DeviceMotionEvent) {
|
|
50
|
+
const intervalObj = INTERVAL_MAP[interval];
|
|
51
|
+
if (devicemotionListener) {
|
|
52
|
+
stopAccelerometer();
|
|
53
|
+
}
|
|
54
|
+
devicemotionListener = getDevicemotionListener(intervalObj.interval);
|
|
55
|
+
window.addEventListener('devicemotion', devicemotionListener, true);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw new Error('accelerometer is not supported');
|
|
59
|
+
}
|
|
60
|
+
return handle.success();
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
return handle.fail({ errMsg: e.message });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
export const onAccelerometerChange = callback => {
|
|
67
|
+
callbackManager.add(callback);
|
|
68
|
+
};
|
|
69
|
+
export const offAccelerometerChange = callback => {
|
|
70
|
+
callbackManager.remove(callback);
|
|
71
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const writeBLECharacteristicValue = temporarilyNotSupport('writeBLECharacteristicValue');
|
|
3
|
+
export const setBLEMTU = temporarilyNotSupport('setBLEMTU');
|
|
4
|
+
export const readBLECharacteristicValue = temporarilyNotSupport('readBLECharacteristicValue');
|
|
5
|
+
export const onBLEMTUChange = temporarilyNotSupport('onBLEMTUChange');
|
|
6
|
+
export const onBLEConnectionStateChange = temporarilyNotSupport('onBLEConnectionStateChange');
|
|
7
|
+
export const onBLECharacteristicValueChange = temporarilyNotSupport('onBLECharacteristicValueChange');
|
|
8
|
+
export const offBLEMTUChange = temporarilyNotSupport('offBLEMTUChange');
|
|
9
|
+
export const offBLEConnectionStateChange = temporarilyNotSupport('offBLEConnectionStateChange');
|
|
10
|
+
export const offBLECharacteristicValueChange = temporarilyNotSupport('offBLECharacteristicValueChange');
|
|
11
|
+
export const notifyBLECharacteristicValueChange = temporarilyNotSupport('notifyBLECharacteristicValueChange');
|
|
12
|
+
export const getBLEMTU = temporarilyNotSupport('getBLEMTU');
|
|
13
|
+
export const getBLEDeviceServices = temporarilyNotSupport('getBLEDeviceServices');
|
|
14
|
+
export const getBLEDeviceRSSI = temporarilyNotSupport('getBLEDeviceRSSI');
|
|
15
|
+
export const getBLEDeviceCharacteristics = temporarilyNotSupport('getBLEDeviceCharacteristics');
|
|
16
|
+
export const createBLEConnection = temporarilyNotSupport('createBLEConnection');
|
|
17
|
+
export const closeBLEConnection = temporarilyNotSupport('closeBLEConnection');
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const onBLEPeripheralConnectionStateChanged = temporarilyNotSupport('onBLEPeripheralConnectionStateChanged');
|
|
3
|
+
export const offBLEPeripheralConnectionStateChanged = temporarilyNotSupport('offBLEPeripheralConnectionStateChanged');
|
|
4
|
+
export const createBLEPeripheralServer = temporarilyNotSupport('createBLEPeripheralServer');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils';
|
|
2
|
+
export const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery');
|
|
3
|
+
export const startBluetoothDevicesDiscovery = temporarilyNotSupport('startBluetoothDevicesDiscovery');
|
|
4
|
+
export const openBluetoothAdapter = temporarilyNotSupport('openBluetoothAdapter');
|
|
5
|
+
export const onBluetoothDeviceFound = temporarilyNotSupport('onBluetoothDeviceFound');
|
|
6
|
+
export const onBluetoothAdapterStateChange = temporarilyNotSupport('onBluetoothAdapterStateChange');
|
|
7
|
+
export const offBluetoothDeviceFound = temporarilyNotSupport('offBluetoothDeviceFound');
|
|
8
|
+
export const offBluetoothAdapterStateChange = temporarilyNotSupport('offBluetoothAdapterStateChange');
|
|
9
|
+
export const makeBluetoothPair = temporarilyNotSupport('makeBluetoothPair');
|
|
10
|
+
export const isBluetoothDevicePaired = temporarilyNotSupport('isBluetoothDevicePaired');
|
|
11
|
+
export const getConnectedBluetoothDevices = temporarilyNotSupport('getConnectedBluetoothDevices');
|
|
12
|
+
export const getBluetoothDevices = temporarilyNotSupport('getBluetoothDevices');
|
|
13
|
+
export const getBluetoothAdapterState = temporarilyNotSupport('getBluetoothAdapterState');
|
|
14
|
+
export const closeBluetoothAdapter = temporarilyNotSupport('closeBluetoothAdapter');
|