@tarojs/taro-h5 3.4.1 → 3.4.4
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/ai/visual.js +2 -0
- package/dist/api/base/system.js +187 -0
- package/dist/api/canvas/index.js +5 -1
- package/dist/api/device/battery.js +18 -1
- package/dist/api/device/index.js +1 -0
- package/dist/api/{base/system → device}/network.js +29 -14
- package/dist/api/device/wifi.js +1 -0
- package/dist/api/media/EditorContext.js +1 -0
- package/dist/api/network/upload.js +1 -6
- package/dist/api/ui/fonts.js +50 -2
- package/dist/api/utils/handler.js +45 -45
- package/dist/index.cjs.js +359 -141
- package/dist/taroApis.js +1 -1
- package/package.json +6 -6
- package/src/api/ai/visual.ts +3 -0
- package/src/api/base/system.ts +207 -0
- package/src/api/canvas/CanvasContext.ts +6 -6
- package/src/api/canvas/index.ts +10 -2
- package/src/api/device/battery.ts +18 -1
- package/src/api/device/index.ts +1 -0
- package/src/api/{base/system → device}/network.ts +35 -15
- package/src/api/device/wifi.ts +1 -0
- package/src/api/media/EditorContext.ts +2 -0
- package/src/api/network/upload.ts +1 -7
- package/src/api/ui/fonts.ts +61 -2
- package/src/api/utils/handler.ts +4 -4
- package/dist/api/base/system/index.js +0 -2
- package/dist/api/base/system/info.js +0 -57
- package/src/api/base/system/index.ts +0 -2
- package/src/api/base/system/info.ts +0 -64
package/dist/index.cjs.js
CHANGED
|
@@ -191,6 +191,8 @@ const stopFaceDetect = temporarilyNotSupport('stopFaceDetect');
|
|
|
191
191
|
const initFaceDetect = temporarilyNotSupport('initFaceDetect');
|
|
192
192
|
const faceDetect = temporarilyNotSupport('faceDetect');
|
|
193
193
|
|
|
194
|
+
// 判断支持版本
|
|
195
|
+
const isVKSupport = temporarilyNotSupport('isVKSupport');
|
|
194
196
|
// 视觉算法
|
|
195
197
|
const createVKSession = temporarilyNotSupport('createVKSession');
|
|
196
198
|
|
|
@@ -1325,86 +1327,76 @@ class MethodHandler {
|
|
|
1325
1327
|
class CallbackManager {
|
|
1326
1328
|
constructor() {
|
|
1327
1329
|
this.callbacks = [];
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1330
|
+
/**
|
|
1331
|
+
* 添加回调
|
|
1332
|
+
* @param {{ callback: function, ctx: any } | function} opt
|
|
1333
|
+
*/
|
|
1334
|
+
this.add = (opt) => {
|
|
1335
|
+
if (opt)
|
|
1336
|
+
this.callbacks.push(opt);
|
|
1337
|
+
};
|
|
1338
|
+
/**
|
|
1339
|
+
* 移除回调
|
|
1340
|
+
* @param {{ callback: function, ctx: any } | function} opt
|
|
1341
|
+
*/
|
|
1342
|
+
this.remove = (opt) => {
|
|
1343
|
+
if (opt) {
|
|
1344
|
+
let pos = -1;
|
|
1345
|
+
this.callbacks.forEach((callback, k) => {
|
|
1346
|
+
if (callback === opt) {
|
|
1347
|
+
pos = k;
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
if (pos > -1) {
|
|
1351
|
+
this.callbacks.splice(pos, 1);
|
|
1347
1352
|
}
|
|
1348
|
-
});
|
|
1349
|
-
if (pos > -1) {
|
|
1350
|
-
this.callbacks.splice(pos, 1);
|
|
1351
1353
|
}
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1354
|
+
};
|
|
1355
|
+
/**
|
|
1356
|
+
* 获取回调函数数量
|
|
1357
|
+
* @return {number}
|
|
1358
|
+
*/
|
|
1359
|
+
this.count = () => {
|
|
1360
|
+
return this.callbacks.length;
|
|
1361
|
+
};
|
|
1362
|
+
/**
|
|
1363
|
+
* 触发回调
|
|
1364
|
+
* @param {...any} args 回调的调用参数
|
|
1365
|
+
*/
|
|
1366
|
+
this.trigger = (...args) => {
|
|
1367
|
+
this.callbacks.forEach(opt => {
|
|
1368
|
+
if (typeof opt === 'function') {
|
|
1369
|
+
opt(...args);
|
|
1370
|
+
}
|
|
1371
|
+
else {
|
|
1372
|
+
const { callback, ctx } = opt;
|
|
1373
|
+
typeof callback === 'function' && callback.call(ctx, ...args);
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
};
|
|
1375
1377
|
}
|
|
1376
1378
|
}
|
|
1377
1379
|
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
+
/** 跳转系统蓝牙设置页 */
|
|
1381
|
+
const openSystemBluetoothSetting = temporarilyNotSupport('openSystemBluetoothSetting');
|
|
1382
|
+
/** 跳转系统微信授权管理页 */
|
|
1383
|
+
const openAppAuthorizeSetting = temporarilyNotSupport('openAppAuthorizeSetting');
|
|
1384
|
+
/** 获取窗口信息 */
|
|
1385
|
+
const getWindowInfo = () => {
|
|
1380
1386
|
const info = {
|
|
1381
|
-
|
|
1382
|
-
model: md.mobile() || '',
|
|
1383
|
-
system: md.os(),
|
|
1387
|
+
/** 设备像素比 */
|
|
1384
1388
|
pixelRatio: window.devicePixelRatio,
|
|
1389
|
+
/** 屏幕宽度,单位px */
|
|
1385
1390
|
screenWidth: window.screen.width,
|
|
1391
|
+
/** 屏幕高度,单位px */
|
|
1386
1392
|
screenHeight: window.screen.height,
|
|
1393
|
+
/** 可使用窗口宽度,单位px */
|
|
1387
1394
|
windowWidth: document.documentElement.clientWidth,
|
|
1395
|
+
/** 可使用窗口高度,单位px */
|
|
1388
1396
|
windowHeight: document.documentElement.clientHeight,
|
|
1389
|
-
|
|
1397
|
+
/** 状态栏的高度,单位px */
|
|
1390
1398
|
statusBarHeight: NaN,
|
|
1391
|
-
|
|
1392
|
-
language: navigator.language,
|
|
1393
|
-
fontSizeSetting: NaN,
|
|
1394
|
-
SDKVersion: '',
|
|
1395
|
-
// TODO
|
|
1396
|
-
albumAuthorized: false,
|
|
1397
|
-
benchmarkLevel: 0,
|
|
1398
|
-
bluetoothEnabled: false,
|
|
1399
|
-
cameraAuthorized: false,
|
|
1400
|
-
enableDebug: false,
|
|
1401
|
-
locationAuthorized: false,
|
|
1402
|
-
locationEnabled: false,
|
|
1403
|
-
microphoneAuthorized: false,
|
|
1404
|
-
notificationAlertAuthorized: false,
|
|
1405
|
-
notificationAuthorized: false,
|
|
1406
|
-
notificationBadgeAuthorized: false,
|
|
1407
|
-
notificationSoundAuthorized: false,
|
|
1399
|
+
/** 在竖屏正方向下的安全区域 */
|
|
1408
1400
|
safeArea: {
|
|
1409
1401
|
bottom: 0,
|
|
1410
1402
|
height: 0,
|
|
@@ -1412,14 +1404,139 @@ const getSystemInfoSync = () => {
|
|
|
1412
1404
|
right: 0,
|
|
1413
1405
|
top: 0,
|
|
1414
1406
|
width: 0
|
|
1415
|
-
}
|
|
1416
|
-
wifiEnabled: false
|
|
1407
|
+
}
|
|
1417
1408
|
};
|
|
1418
1409
|
return info;
|
|
1419
1410
|
};
|
|
1420
|
-
|
|
1411
|
+
/** 获取设备设置 */
|
|
1412
|
+
const getSystemSetting = () => {
|
|
1413
|
+
const isLandscape = window.screen.width >= window.screen.height;
|
|
1414
|
+
const info = {
|
|
1415
|
+
/** 蓝牙的系统开关 */
|
|
1416
|
+
bluetoothEnabled: false,
|
|
1417
|
+
/** 地理位置的系统开关 */
|
|
1418
|
+
locationEnabled: false,
|
|
1419
|
+
/** Wi-Fi 的系统开关 */
|
|
1420
|
+
wifiEnabled: false,
|
|
1421
|
+
/** 设备方向 */
|
|
1422
|
+
deviceOrientation: isLandscape ? 'landscape' : 'portrait'
|
|
1423
|
+
};
|
|
1424
|
+
return info;
|
|
1425
|
+
};
|
|
1426
|
+
/** 获取设备设置 */
|
|
1427
|
+
const getDeviceInfo = () => {
|
|
1428
|
+
const md = new MobileDetect(navigator.userAgent);
|
|
1429
|
+
const info = {
|
|
1430
|
+
/** 应用二进制接口类型(仅 Android 支持) */
|
|
1431
|
+
abi: '',
|
|
1432
|
+
/** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) */
|
|
1433
|
+
benchmarkLevel: -1,
|
|
1434
|
+
/** 设备品牌 */
|
|
1435
|
+
brand: md.mobile() || '',
|
|
1436
|
+
/** 设备型号 */
|
|
1437
|
+
model: md.mobile() || '',
|
|
1438
|
+
/** 操作系统及版本 */
|
|
1439
|
+
system: md.os(),
|
|
1440
|
+
/** 客户端平台 */
|
|
1441
|
+
platform: navigator.platform
|
|
1442
|
+
};
|
|
1443
|
+
return info;
|
|
1444
|
+
};
|
|
1445
|
+
/** 获取微信APP基础信息 */
|
|
1446
|
+
const getAppBaseInfo = () => {
|
|
1447
|
+
var _a;
|
|
1448
|
+
let isDarkMode = false;
|
|
1449
|
+
if ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)').matches) {
|
|
1450
|
+
isDarkMode = true;
|
|
1451
|
+
}
|
|
1452
|
+
const info = {
|
|
1453
|
+
/** 客户端基础库版本 */
|
|
1454
|
+
SDKVersion: '',
|
|
1455
|
+
/** 是否已打开调试。可通过右上角菜单或 [Taro.setEnableDebug](/docs/apis/base/debug/setEnableDebug) 打开调试。 */
|
|
1456
|
+
enableDebug: process.env.NODE_ENV === 'development',
|
|
1457
|
+
/** 当前小程序运行的宿主环境 */
|
|
1458
|
+
// host: { appId: '' },
|
|
1459
|
+
/** 微信设置的语言 */
|
|
1460
|
+
language: navigator.language,
|
|
1461
|
+
/** 微信版本号 */
|
|
1462
|
+
version: '',
|
|
1463
|
+
/** 系统当前主题,取值为light或dark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏) */
|
|
1464
|
+
theme: isDarkMode ? 'dark' : 'light'
|
|
1465
|
+
};
|
|
1466
|
+
return info;
|
|
1467
|
+
};
|
|
1468
|
+
/** 获取微信APP授权设置 */
|
|
1469
|
+
const getAppAuthorizeSetting = () => {
|
|
1470
|
+
const info = {
|
|
1471
|
+
/** 允许微信使用相册的开关(仅 iOS 有效) */
|
|
1472
|
+
albumAuthorized: 'not determined',
|
|
1473
|
+
/** 允许微信使用蓝牙的开关(仅 iOS 有效) */
|
|
1474
|
+
bluetoothAuthorized: 'not determined',
|
|
1475
|
+
/** 允许微信使用摄像头的开关 */
|
|
1476
|
+
cameraAuthorized: 'not determined',
|
|
1477
|
+
/** 允许微信使用定位的开关 */
|
|
1478
|
+
locationAuthorized: 'not determined',
|
|
1479
|
+
/** 定位准确度。true 表示模糊定位,false 表示精确定位(仅 iOS 有效) */
|
|
1480
|
+
locationReducedAccuracy: false,
|
|
1481
|
+
/** 允许微信使用麦克风的开关 */
|
|
1482
|
+
microphoneAuthorized: 'not determined',
|
|
1483
|
+
/** 允许微信通知的开关 */
|
|
1484
|
+
notificationAuthorized: 'not determined',
|
|
1485
|
+
/** 允许微信通知带有提醒的开关(仅 iOS 有效) */
|
|
1486
|
+
notificationAlertAuthorized: 'not determined',
|
|
1487
|
+
/** 允许微信通知带有标记的开关(仅 iOS 有效) */
|
|
1488
|
+
notificationBadgeAuthorized: 'not determined',
|
|
1489
|
+
/** 允许微信通知带有声音的开关(仅 iOS 有效) */
|
|
1490
|
+
notificationSoundAuthorized: 'not determined',
|
|
1491
|
+
/** 允许微信使用日历的开关 */
|
|
1492
|
+
phoneCalendarAuthorized: 'not determined'
|
|
1493
|
+
};
|
|
1494
|
+
return info;
|
|
1495
|
+
};
|
|
1496
|
+
/** 获取设备设置 */
|
|
1497
|
+
const getSystemInfoSync = () => {
|
|
1498
|
+
const windowInfo = getWindowInfo();
|
|
1499
|
+
const systemSetting = getSystemSetting();
|
|
1500
|
+
const deviceInfo = getDeviceInfo();
|
|
1501
|
+
const appBaseInfo = getAppBaseInfo();
|
|
1502
|
+
const appAuthorizeSetting = getAppAuthorizeSetting();
|
|
1503
|
+
delete deviceInfo.abi;
|
|
1504
|
+
const info = {
|
|
1505
|
+
...windowInfo,
|
|
1506
|
+
...systemSetting,
|
|
1507
|
+
...deviceInfo,
|
|
1508
|
+
...appBaseInfo,
|
|
1509
|
+
/** 用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准 */
|
|
1510
|
+
fontSizeSetting: NaN,
|
|
1511
|
+
/** 允许微信使用相册的开关(仅 iOS 有效) */
|
|
1512
|
+
albumAuthorized: appAuthorizeSetting.albumAuthorized === 'authorized',
|
|
1513
|
+
/** 允许微信使用摄像头的开关 */
|
|
1514
|
+
cameraAuthorized: appAuthorizeSetting.cameraAuthorized === 'authorized',
|
|
1515
|
+
/** 允许微信使用定位的开关 */
|
|
1516
|
+
locationAuthorized: appAuthorizeSetting.locationAuthorized === 'authorized',
|
|
1517
|
+
/** 允许微信使用麦克风的开关 */
|
|
1518
|
+
microphoneAuthorized: appAuthorizeSetting.microphoneAuthorized === 'authorized',
|
|
1519
|
+
/** 允许微信通知的开关 */
|
|
1520
|
+
notificationAuthorized: appAuthorizeSetting.notificationAuthorized === 'authorized',
|
|
1521
|
+
/** 允许微信通知带有提醒的开关(仅 iOS 有效) */
|
|
1522
|
+
notificationAlertAuthorized: appAuthorizeSetting.notificationAlertAuthorized === 'authorized',
|
|
1523
|
+
/** 允许微信通知带有标记的开关(仅 iOS 有效) */
|
|
1524
|
+
notificationBadgeAuthorized: appAuthorizeSetting.notificationBadgeAuthorized === 'authorized',
|
|
1525
|
+
/** 允许微信通知带有声音的开关(仅 iOS 有效) */
|
|
1526
|
+
notificationSoundAuthorized: appAuthorizeSetting.notificationSoundAuthorized === 'authorized',
|
|
1527
|
+
/** 允许微信使用日历的开关 */
|
|
1528
|
+
phoneCalendarAuthorized: appAuthorizeSetting.phoneCalendarAuthorized === 'authorized',
|
|
1529
|
+
/** `true` 表示模糊定位,`false` 表示精确定位,仅 iOS 支持 */
|
|
1530
|
+
locationReducedAccuracy: appAuthorizeSetting.locationReducedAccuracy,
|
|
1531
|
+
/** 小程序当前运行环境 */
|
|
1532
|
+
environment: ''
|
|
1533
|
+
};
|
|
1534
|
+
return info;
|
|
1535
|
+
};
|
|
1536
|
+
/** 获取系统信息 */
|
|
1537
|
+
const getSystemInfoAsync = async (options = {}) => {
|
|
1421
1538
|
const { success, fail, complete } = options;
|
|
1422
|
-
const handle = new MethodHandler({ name: '
|
|
1539
|
+
const handle = new MethodHandler({ name: 'getSystemInfoAsync', success, fail, complete });
|
|
1423
1540
|
try {
|
|
1424
1541
|
const info = await getSystemInfoSync();
|
|
1425
1542
|
return handle.success(info);
|
|
@@ -1429,69 +1546,21 @@ const getSystemInfo = async (options = {}) => {
|
|
|
1429
1546
|
errMsg: error
|
|
1430
1547
|
});
|
|
1431
1548
|
}
|
|
1432
|
-
};
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
// @ts-ignore
|
|
1436
|
-
return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection;
|
|
1437
|
-
}
|
|
1438
|
-
const getNetworkType = (options = {}) => {
|
|
1439
|
-
const connection = getConnection();
|
|
1549
|
+
};
|
|
1550
|
+
/** 获取系统信息 */
|
|
1551
|
+
const getSystemInfo = async (options = {}) => {
|
|
1440
1552
|
const { success, fail, complete } = options;
|
|
1441
|
-
const handle = new MethodHandler({ name: '
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
return handle.success({ networkType });
|
|
1446
|
-
}
|
|
1447
|
-
// Supports only the navigator.connection.type value which doesn't match the latest spec.
|
|
1448
|
-
// https://www.davidbcalhoun.com/2010/using-navigator-connection-android/
|
|
1449
|
-
if (!isNaN(Number(connection.type))) {
|
|
1450
|
-
switch (connection.type) {
|
|
1451
|
-
// @ts-ignore
|
|
1452
|
-
case connection.WIFI:
|
|
1453
|
-
networkType = 'wifi';
|
|
1454
|
-
break;
|
|
1455
|
-
// @ts-ignore
|
|
1456
|
-
case connection.CELL_3G:
|
|
1457
|
-
networkType = '3g';
|
|
1458
|
-
break;
|
|
1459
|
-
// @ts-ignore
|
|
1460
|
-
case connection.CELL_2G:
|
|
1461
|
-
networkType = '2g';
|
|
1462
|
-
break;
|
|
1463
|
-
default:
|
|
1464
|
-
// ETHERNET, UNKNOWN
|
|
1465
|
-
networkType = 'unknown';
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
else if (connection.type) {
|
|
1469
|
-
// @ts-ignore
|
|
1470
|
-
networkType = connection.type; // Only supports the type value.
|
|
1471
|
-
// @ts-ignore
|
|
1472
|
-
}
|
|
1473
|
-
else if (connection.effectiveType) {
|
|
1474
|
-
// @ts-ignore
|
|
1475
|
-
networkType = connection.effectiveType;
|
|
1553
|
+
const handle = new MethodHandler({ name: 'getSystemInfo', success, fail, complete });
|
|
1554
|
+
try {
|
|
1555
|
+
const info = await getSystemInfoSync();
|
|
1556
|
+
return handle.success(info);
|
|
1476
1557
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
const connection = getConnection();
|
|
1481
|
-
if (connection) {
|
|
1482
|
-
connection.addEventListener('change', function () {
|
|
1483
|
-
getNetworkType()
|
|
1484
|
-
.then(res => {
|
|
1485
|
-
const { networkType } = res;
|
|
1486
|
-
const isConnected = networkType !== 'none';
|
|
1487
|
-
const obj = { isConnected, networkType };
|
|
1488
|
-
cb(obj);
|
|
1489
|
-
});
|
|
1558
|
+
catch (error) {
|
|
1559
|
+
return handle.fail({
|
|
1560
|
+
errMsg: error
|
|
1490
1561
|
});
|
|
1491
1562
|
}
|
|
1492
|
-
};
|
|
1493
|
-
const offNetworkStatusChange = temporarilyNotSupport('offNetworkStatusChange');
|
|
1494
|
-
const getLocalIPAddress = temporarilyNotSupport('getLocalIPAddress');
|
|
1563
|
+
};
|
|
1495
1564
|
|
|
1496
1565
|
// 更新
|
|
1497
1566
|
const updateWeChatApp = temporarilyNotSupport('updateWeChatApp');
|
|
@@ -1813,8 +1882,8 @@ const canvasGetImageData = ({ canvasId, success, fail, complete, x, y, width, he
|
|
|
1813
1882
|
};
|
|
1814
1883
|
|
|
1815
1884
|
// 画布
|
|
1816
|
-
|
|
1817
|
-
const
|
|
1885
|
+
/** 创建离屏 canvas 实例 */
|
|
1886
|
+
const createOffscreenCanvas = temporarilyNotSupport('createOffscreenCanvas');
|
|
1818
1887
|
|
|
1819
1888
|
class cloud {
|
|
1820
1889
|
constructor() {
|
|
@@ -1930,7 +1999,23 @@ const checkIsOpenAccessibility = temporarilyNotSupport('checkIsOpenAccessibility
|
|
|
1930
1999
|
|
|
1931
2000
|
// 电量
|
|
1932
2001
|
const getBatteryInfoSync = temporarilyNotSupport('getBatteryInfoSync');
|
|
1933
|
-
const getBatteryInfo =
|
|
2002
|
+
const getBatteryInfo = async ({ success, fail, complete } = {}) => {
|
|
2003
|
+
var _a;
|
|
2004
|
+
const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete });
|
|
2005
|
+
try {
|
|
2006
|
+
// @ts-ignore
|
|
2007
|
+
const battery = await ((_a = navigator.getBattery) === null || _a === void 0 ? void 0 : _a.call(navigator));
|
|
2008
|
+
return handle.success({
|
|
2009
|
+
isCharging: battery.charging,
|
|
2010
|
+
level: Number(battery.level || 0) * 100
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
catch (error) {
|
|
2014
|
+
return handle.fail({
|
|
2015
|
+
errMsg: (error === null || error === void 0 ? void 0 : error.message) || error
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
};
|
|
1934
2019
|
|
|
1935
2020
|
// 蓝牙-通用
|
|
1936
2021
|
const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery');
|
|
@@ -2376,6 +2461,83 @@ const offDeviceMotionChange = callback => {
|
|
|
2376
2461
|
callbackManager$1.remove(callback);
|
|
2377
2462
|
};
|
|
2378
2463
|
|
|
2464
|
+
function getConnection() {
|
|
2465
|
+
// @ts-ignore
|
|
2466
|
+
return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection;
|
|
2467
|
+
}
|
|
2468
|
+
const getNetworkType = (options = {}) => {
|
|
2469
|
+
const connection = getConnection();
|
|
2470
|
+
const { success, fail, complete } = options;
|
|
2471
|
+
const handle = new MethodHandler({ name: 'getNetworkType', success, fail, complete });
|
|
2472
|
+
let networkType = 'unknown';
|
|
2473
|
+
// 浏览器不支持获取网络状态
|
|
2474
|
+
if (!connection) {
|
|
2475
|
+
return handle.success({ networkType });
|
|
2476
|
+
}
|
|
2477
|
+
// Supports only the navigator.connection.type value which doesn't match the latest spec.
|
|
2478
|
+
// https://www.davidbcalhoun.com/2010/using-navigator-connection-android/
|
|
2479
|
+
if (!isNaN(Number(connection.type))) {
|
|
2480
|
+
switch (connection.type) {
|
|
2481
|
+
// @ts-ignore
|
|
2482
|
+
case connection.WIFI:
|
|
2483
|
+
networkType = 'wifi';
|
|
2484
|
+
break;
|
|
2485
|
+
// @ts-ignore
|
|
2486
|
+
case connection.CELL_3G:
|
|
2487
|
+
networkType = '3g';
|
|
2488
|
+
break;
|
|
2489
|
+
// @ts-ignore
|
|
2490
|
+
case connection.CELL_2G:
|
|
2491
|
+
networkType = '2g';
|
|
2492
|
+
break;
|
|
2493
|
+
default:
|
|
2494
|
+
// ETHERNET, UNKNOWN
|
|
2495
|
+
networkType = 'unknown';
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
else if (connection.type) {
|
|
2499
|
+
// @ts-ignore
|
|
2500
|
+
networkType = connection.type; // Only supports the type value.
|
|
2501
|
+
// @ts-ignore
|
|
2502
|
+
}
|
|
2503
|
+
else if (connection.effectiveType) {
|
|
2504
|
+
// @ts-ignore
|
|
2505
|
+
networkType = connection.effectiveType;
|
|
2506
|
+
}
|
|
2507
|
+
return handle.success({ networkType });
|
|
2508
|
+
};
|
|
2509
|
+
const networkStatusManager = new CallbackManager();
|
|
2510
|
+
const networkStatusListener = async () => {
|
|
2511
|
+
const { networkType } = await getNetworkType();
|
|
2512
|
+
const isConnected = networkType !== 'none';
|
|
2513
|
+
const obj = { isConnected, networkType };
|
|
2514
|
+
networkStatusManager.trigger(obj);
|
|
2515
|
+
};
|
|
2516
|
+
/**
|
|
2517
|
+
* 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。
|
|
2518
|
+
* - 出现三次以上连接超时
|
|
2519
|
+
* - 出现三次 rtt 超过 400
|
|
2520
|
+
* - 出现三次以上的丢包
|
|
2521
|
+
* > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。
|
|
2522
|
+
*/
|
|
2523
|
+
const onNetworkWeakChange = temporarilyNotSupport('onNetworkWeakChange');
|
|
2524
|
+
const onNetworkStatusChange = callback => {
|
|
2525
|
+
networkStatusManager.add(callback);
|
|
2526
|
+
const connection = getConnection();
|
|
2527
|
+
if (connection && networkStatusManager.count() === 1) {
|
|
2528
|
+
connection.addEventListener('change', networkStatusListener);
|
|
2529
|
+
}
|
|
2530
|
+
};
|
|
2531
|
+
const offNetworkWeakChange = temporarilyNotSupport('offNetworkStatusChange');
|
|
2532
|
+
const offNetworkStatusChange = callback => {
|
|
2533
|
+
networkStatusManager.remove(callback);
|
|
2534
|
+
const connection = getConnection();
|
|
2535
|
+
if (connection && networkStatusManager.count() === 0) {
|
|
2536
|
+
connection.removeEventListener('change', networkStatusListener);
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
const getLocalIPAddress = temporarilyNotSupport('getLocalIPAddress');
|
|
2540
|
+
|
|
2379
2541
|
// NFC
|
|
2380
2542
|
const stopHCE = temporarilyNotSupport('stopHCE');
|
|
2381
2543
|
const startHCE = temporarilyNotSupport('startHCE');
|
|
@@ -2461,6 +2623,7 @@ const vibrateLong = ({ success, fail, complete } = {}) => {
|
|
|
2461
2623
|
const stopWifi = temporarilyNotSupport('stopWifi');
|
|
2462
2624
|
const startWifi = temporarilyNotSupport('startWifi');
|
|
2463
2625
|
const setWifiList = temporarilyNotSupport('setWifiList');
|
|
2626
|
+
const onWifiConnectedWithPartialInfo = temporarilyNotSupport('onWifiConnectedWithPartialInfo');
|
|
2464
2627
|
const onWifiConnected = temporarilyNotSupport('onWifiConnected');
|
|
2465
2628
|
const onGetWifiList = temporarilyNotSupport('onGetWifiList');
|
|
2466
2629
|
const offWifiConnected = temporarilyNotSupport('offWifiConnected');
|
|
@@ -6347,16 +6510,12 @@ const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout,
|
|
|
6347
6510
|
* @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
|
|
6348
6511
|
*/
|
|
6349
6512
|
const offProgressUpdate = callbackManager.progressUpdate.remove;
|
|
6350
|
-
const headersReceived = temporarilyNotSupport('UploadTask.headersReceived');
|
|
6351
|
-
const progress = temporarilyNotSupport('UploadTask.progress');
|
|
6352
6513
|
return {
|
|
6353
6514
|
abort,
|
|
6354
6515
|
onHeadersReceived,
|
|
6355
6516
|
offHeadersReceived,
|
|
6356
6517
|
onProgressUpdate,
|
|
6357
|
-
offProgressUpdate
|
|
6358
|
-
headersReceived,
|
|
6359
|
-
progress
|
|
6518
|
+
offProgressUpdate
|
|
6360
6519
|
};
|
|
6361
6520
|
};
|
|
6362
6521
|
/**
|
|
@@ -6912,7 +7071,55 @@ const setBackgroundColor = temporarilyNotSupport('setBackgroundColor');
|
|
|
6912
7071
|
const nextTick = Taro__default['default'].nextTick;
|
|
6913
7072
|
|
|
6914
7073
|
// 字体
|
|
6915
|
-
const loadFontFace =
|
|
7074
|
+
const loadFontFace = async (options) => {
|
|
7075
|
+
options = Object.assign({ global: false }, options);
|
|
7076
|
+
const { success, fail, complete, family, source, desc = {} } = options;
|
|
7077
|
+
const handle = new MethodHandler({ name: 'loadFontFace', success, fail, complete });
|
|
7078
|
+
// @ts-ignore
|
|
7079
|
+
const fonts = document.fonts;
|
|
7080
|
+
if (fonts) {
|
|
7081
|
+
// @ts-ignore
|
|
7082
|
+
const fontFace = new FontFace(family, source, desc);
|
|
7083
|
+
try {
|
|
7084
|
+
await fontFace.load();
|
|
7085
|
+
fonts.add(fontFace);
|
|
7086
|
+
return handle.success({});
|
|
7087
|
+
}
|
|
7088
|
+
catch (error) {
|
|
7089
|
+
return handle.fail({
|
|
7090
|
+
errMsg: error.message || error
|
|
7091
|
+
});
|
|
7092
|
+
}
|
|
7093
|
+
}
|
|
7094
|
+
else {
|
|
7095
|
+
const style = document.createElement('style');
|
|
7096
|
+
let innerText = `font-family:"${family}";src:${source};font-style:${desc.style || 'normal'};font-weight:${desc.weight || 'normal'};font-variant:${desc.variant || 'normal'};`;
|
|
7097
|
+
if (desc.ascentOverride) {
|
|
7098
|
+
innerText += `ascent-override:${desc.ascentOverride};`;
|
|
7099
|
+
}
|
|
7100
|
+
if (desc.descentOverride) {
|
|
7101
|
+
innerText += `descent-override:${desc.descentOverride};`;
|
|
7102
|
+
}
|
|
7103
|
+
if (desc.featureSettings) {
|
|
7104
|
+
innerText += `font-feature-settings:${desc.featureSettings};`;
|
|
7105
|
+
}
|
|
7106
|
+
if (desc.lineGapOverride) {
|
|
7107
|
+
innerText += `line-gap-override:${desc.lineGapOverride};`;
|
|
7108
|
+
}
|
|
7109
|
+
if (desc.stretch) {
|
|
7110
|
+
innerText += `font-stretch:${desc.stretch};`;
|
|
7111
|
+
}
|
|
7112
|
+
if (desc.unicodeRange) {
|
|
7113
|
+
innerText += `unicode-range:${desc.unicodeRange};`;
|
|
7114
|
+
}
|
|
7115
|
+
if (desc.variationSettings) {
|
|
7116
|
+
innerText += `font-variation-settings:${desc.variationSettings};`;
|
|
7117
|
+
}
|
|
7118
|
+
style.innerText = `@font-face{${innerText}}`;
|
|
7119
|
+
document.head.appendChild(style);
|
|
7120
|
+
return handle.success();
|
|
7121
|
+
}
|
|
7122
|
+
};
|
|
6916
7123
|
|
|
6917
7124
|
// 菜单
|
|
6918
7125
|
const getMenuButtonBoundingClientRect = temporarilyNotSupport('getMenuButtonBoundingClientRect');
|
|
@@ -8679,7 +8886,6 @@ exports['default'] = taro;
|
|
|
8679
8886
|
exports.disableAlertBeforeUnload = disableAlertBeforeUnload;
|
|
8680
8887
|
exports.dishClassify = dishClassify;
|
|
8681
8888
|
exports.downloadFile = downloadFile;
|
|
8682
|
-
exports.drawCanvas = drawCanvas;
|
|
8683
8889
|
exports.enableAlertBeforeUnload = enableAlertBeforeUnload;
|
|
8684
8890
|
exports.eventCenter = eventCenter;
|
|
8685
8891
|
exports.exitMiniProgram = exitMiniProgram;
|
|
@@ -8688,6 +8894,8 @@ exports.faceDetect = faceDetect;
|
|
|
8688
8894
|
exports.faceVerifyForPay = faceVerifyForPay;
|
|
8689
8895
|
exports.getAccountInfoSync = getAccountInfoSync;
|
|
8690
8896
|
exports.getApp = getApp;
|
|
8897
|
+
exports.getAppAuthorizeSetting = getAppAuthorizeSetting;
|
|
8898
|
+
exports.getAppBaseInfo = getAppBaseInfo;
|
|
8691
8899
|
exports.getAvailableAudioSources = getAvailableAudioSources;
|
|
8692
8900
|
exports.getBLEDeviceCharacteristics = getBLEDeviceCharacteristics;
|
|
8693
8901
|
exports.getBLEDeviceRSSI = getBLEDeviceRSSI;
|
|
@@ -8708,6 +8916,7 @@ exports.getClipboardData = getClipboardData;
|
|
|
8708
8916
|
exports.getConnectedBluetoothDevices = getConnectedBluetoothDevices;
|
|
8709
8917
|
exports.getConnectedWifi = getConnectedWifi;
|
|
8710
8918
|
exports.getCurrentInstance = getCurrentInstance;
|
|
8919
|
+
exports.getDeviceInfo = getDeviceInfo;
|
|
8711
8920
|
exports.getEnterOptionsSync = getEnterOptionsSync;
|
|
8712
8921
|
exports.getEnv = getEnv;
|
|
8713
8922
|
exports.getExptInfoSync = getExptInfoSync;
|
|
@@ -8742,7 +8951,9 @@ exports.getStorageInfoSync = getStorageInfoSync;
|
|
|
8742
8951
|
exports.getStorageSync = getStorageSync;
|
|
8743
8952
|
exports.getSwanId = getSwanId;
|
|
8744
8953
|
exports.getSystemInfo = getSystemInfo;
|
|
8954
|
+
exports.getSystemInfoAsync = getSystemInfoAsync;
|
|
8745
8955
|
exports.getSystemInfoSync = getSystemInfoSync;
|
|
8956
|
+
exports.getSystemSetting = getSystemSetting;
|
|
8746
8957
|
exports.getUpdateManager = getUpdateManager;
|
|
8747
8958
|
exports.getUserCryptoManager = getUserCryptoManager;
|
|
8748
8959
|
exports.getUserInfo = getUserInfo;
|
|
@@ -8750,6 +8961,7 @@ exports.getUserProfile = getUserProfile;
|
|
|
8750
8961
|
exports.getVideoInfo = getVideoInfo;
|
|
8751
8962
|
exports.getWeRunData = getWeRunData;
|
|
8752
8963
|
exports.getWifiList = getWifiList;
|
|
8964
|
+
exports.getWindowInfo = getWindowInfo;
|
|
8753
8965
|
exports.hideHomeButton = hideHomeButton;
|
|
8754
8966
|
exports.hideKeyboard = hideKeyboard;
|
|
8755
8967
|
exports.hideLoading = hideLoading;
|
|
@@ -8764,6 +8976,7 @@ exports.initPxTransform = initPxTransform;
|
|
|
8764
8976
|
exports.initTabBarApis = initTabBarApis;
|
|
8765
8977
|
exports.interceptors = interceptors;
|
|
8766
8978
|
exports.isBluetoothDevicePaired = isBluetoothDevicePaired;
|
|
8979
|
+
exports.isVKSupport = isVKSupport;
|
|
8767
8980
|
exports.joinVoIPChat = joinVoIPChat;
|
|
8768
8981
|
exports.loadFontFace = loadFontFace;
|
|
8769
8982
|
exports.login = login;
|
|
@@ -8811,6 +9024,7 @@ exports.offLocationChange = offLocationChange;
|
|
|
8811
9024
|
exports.offLocationChangeError = offLocationChangeError;
|
|
8812
9025
|
exports.offMemoryWarning = offMemoryWarning;
|
|
8813
9026
|
exports.offNetworkStatusChange = offNetworkStatusChange;
|
|
9027
|
+
exports.offNetworkWeakChange = offNetworkWeakChange;
|
|
8814
9028
|
exports.offPageNotFound = offPageNotFound;
|
|
8815
9029
|
exports.offThemeChange = offThemeChange;
|
|
8816
9030
|
exports.offUnhandledRejection = offUnhandledRejection;
|
|
@@ -8854,6 +9068,7 @@ exports.onLocationChange = onLocationChange;
|
|
|
8854
9068
|
exports.onLocationChangeError = onLocationChangeError;
|
|
8855
9069
|
exports.onMemoryWarning = onMemoryWarning;
|
|
8856
9070
|
exports.onNetworkStatusChange = onNetworkStatusChange;
|
|
9071
|
+
exports.onNetworkWeakChange = onNetworkWeakChange;
|
|
8857
9072
|
exports.onPageNotFound = onPageNotFound;
|
|
8858
9073
|
exports.onSocketClose = onSocketClose;
|
|
8859
9074
|
exports.onSocketError = onSocketError;
|
|
@@ -8868,7 +9083,9 @@ exports.onVoIPChatSpeakersChanged = onVoIPChatSpeakersChanged;
|
|
|
8868
9083
|
exports.onVoIPChatStateChanged = onVoIPChatStateChanged;
|
|
8869
9084
|
exports.onVoIPVideoMembersChanged = onVoIPVideoMembersChanged;
|
|
8870
9085
|
exports.onWifiConnected = onWifiConnected;
|
|
9086
|
+
exports.onWifiConnectedWithPartialInfo = onWifiConnectedWithPartialInfo;
|
|
8871
9087
|
exports.onWindowResize = onWindowResize;
|
|
9088
|
+
exports.openAppAuthorizeSetting = openAppAuthorizeSetting;
|
|
8872
9089
|
exports.openBluetoothAdapter = openBluetoothAdapter;
|
|
8873
9090
|
exports.openCard = openCard;
|
|
8874
9091
|
exports.openChannelsActivity = openChannelsActivity;
|
|
@@ -8879,6 +9096,7 @@ exports.openDocument = openDocument;
|
|
|
8879
9096
|
exports.openEmbeddedMiniProgram = openEmbeddedMiniProgram;
|
|
8880
9097
|
exports.openLocation = openLocation;
|
|
8881
9098
|
exports.openSetting = openSetting;
|
|
9099
|
+
exports.openSystemBluetoothSetting = openSystemBluetoothSetting;
|
|
8882
9100
|
exports.openVideoEditor = openVideoEditor;
|
|
8883
9101
|
exports.options = options;
|
|
8884
9102
|
exports.pageScrollTo = pageScrollTo;
|