@authme/util 2.8.32 → 2.8.34
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/index.cjs +69 -15
- package/index.js +69 -15
- package/package.json +1 -1
- package/src/ui/camera.d.ts +1 -1
- package/src/ui/popup.d.ts +2 -2
package/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ require('core-js/modules/es.parse-int.js');
|
|
|
29
29
|
var Lottie = require('lottie-web');
|
|
30
30
|
require('core-js/modules/es.number.to-fixed.js');
|
|
31
31
|
require('core-js/modules/es.array.sort.js');
|
|
32
|
+
require('core-js/modules/esnext.global-this.js');
|
|
32
33
|
require('core-js/modules/es.string.trim.js');
|
|
33
34
|
require('core-js/modules/es.string.starts-with.js');
|
|
34
35
|
require('core-js/modules/es.symbol.description.js');
|
|
@@ -1095,7 +1096,6 @@ const uiThemeDirection = (panel, hintStyle) => {
|
|
|
1095
1096
|
panel.style.borderRadius = `${hintStyle.cornerRadius || 20}px`;
|
|
1096
1097
|
panel.style.backgroundColor = hintStyle.backgroundColor;
|
|
1097
1098
|
panel.style.opacity = hintStyle.backgroundOpacity;
|
|
1098
|
-
panel.style.display = 'none';
|
|
1099
1099
|
panel.style.flexDirection = 'row';
|
|
1100
1100
|
panel.style.alignItems = 'center';
|
|
1101
1101
|
panel.style.justifyContent = 'center';
|
|
@@ -1363,7 +1363,7 @@ function checkOnlineStatus(msg, buttonText) {
|
|
|
1363
1363
|
});
|
|
1364
1364
|
}
|
|
1365
1365
|
|
|
1366
|
-
function showPopup(title, content, showButton = true,
|
|
1366
|
+
function showPopup(title, content, showButton = true, buttonText, callback) {
|
|
1367
1367
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1368
1368
|
const target = document.querySelector('.authme-container');
|
|
1369
1369
|
const popupBackground = document.createElement('div');
|
|
@@ -1378,7 +1378,7 @@ function showPopup(title, content, showButton = true, button, callback) {
|
|
|
1378
1378
|
popupContent.textContent = content;
|
|
1379
1379
|
const popupConfirmBtn = document.createElement('button');
|
|
1380
1380
|
popupConfirmBtn.className = 'popup-btn';
|
|
1381
|
-
popupConfirmBtn.textContent = '確定';
|
|
1381
|
+
popupConfirmBtn.textContent = buttonText || '確定';
|
|
1382
1382
|
popupPanel.appendChild(popupTitle);
|
|
1383
1383
|
popupPanel.appendChild(popupContent);
|
|
1384
1384
|
if (showButton) {
|
|
@@ -1401,14 +1401,14 @@ function hidePopup() {
|
|
|
1401
1401
|
popupBackground.remove();
|
|
1402
1402
|
}
|
|
1403
1403
|
}
|
|
1404
|
-
function asyncShowPopup(title, content, showButton = true,
|
|
1404
|
+
function asyncShowPopup(title, content, showButton = true, buttonText) {
|
|
1405
1405
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1406
1406
|
return new Promise((res, rej) => {
|
|
1407
1407
|
const callback = () => {
|
|
1408
1408
|
res(true);
|
|
1409
1409
|
hidePopup();
|
|
1410
1410
|
};
|
|
1411
|
-
showPopup(title, content, showButton,
|
|
1411
|
+
showPopup(title, content, showButton, buttonText, callback);
|
|
1412
1412
|
});
|
|
1413
1413
|
});
|
|
1414
1414
|
}
|
|
@@ -1421,6 +1421,7 @@ var BROWSER_CAMERA_ERRORS;
|
|
|
1421
1421
|
BROWSER_CAMERA_ERRORS["NOT_FOUND_ERROR"] = "NotFoundError";
|
|
1422
1422
|
BROWSER_CAMERA_ERRORS["NOT_READABLE_ERROR"] = "NotReadableError";
|
|
1423
1423
|
BROWSER_CAMERA_ERRORS["ABORT_ERROR"] = "AbortError";
|
|
1424
|
+
BROWSER_CAMERA_ERRORS["LOW_RESOLUTION"] = "LowResolutionError";
|
|
1424
1425
|
})(BROWSER_CAMERA_ERRORS || (BROWSER_CAMERA_ERRORS = {}));
|
|
1425
1426
|
let stream;
|
|
1426
1427
|
const videoConstraintsFactory = (isPC, facingMode) => {
|
|
@@ -1515,8 +1516,8 @@ function upgradeResolution(videoTrack) {
|
|
|
1515
1516
|
}
|
|
1516
1517
|
};
|
|
1517
1518
|
const minAcceptableWidth = 1280; // 最低可接受的解析度寬度
|
|
1518
|
-
const maxAttempts =
|
|
1519
|
-
const retryDelay =
|
|
1519
|
+
const maxAttempts = 5; // 最多嘗試10次
|
|
1520
|
+
const retryDelay = 2000; // 每次重試間隔1秒
|
|
1520
1521
|
console.log('🚀 開始提升解析度...');
|
|
1521
1522
|
const startTime = Date.now();
|
|
1522
1523
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
@@ -1546,7 +1547,7 @@ function upgradeResolution(videoTrack) {
|
|
|
1546
1547
|
console.warn(`⚠️ 達到最大重試次數,使用當前解析度: ${finalSettings.width}x${finalSettings.height}`);
|
|
1547
1548
|
});
|
|
1548
1549
|
}
|
|
1549
|
-
function switchCamera(deviceId, video) {
|
|
1550
|
+
function switchCamera(deviceId, video, translate) {
|
|
1550
1551
|
var _a, _b;
|
|
1551
1552
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1552
1553
|
const startTime = performance.now();
|
|
@@ -1578,6 +1579,26 @@ function switchCamera(deviceId, video) {
|
|
|
1578
1579
|
initTime: `${initTime}ms`
|
|
1579
1580
|
});
|
|
1580
1581
|
}
|
|
1582
|
+
// 檢查最終解析度是否達到最低要求
|
|
1583
|
+
const currentTrack = stream.getVideoTracks()[0];
|
|
1584
|
+
if (currentTrack) {
|
|
1585
|
+
const currentSettings = currentTrack.getSettings();
|
|
1586
|
+
const minRequiredWidth = 1280;
|
|
1587
|
+
if (currentSettings.width && currentSettings.width < minRequiredWidth) {
|
|
1588
|
+
console.error('❌ Camera解析度不足', {
|
|
1589
|
+
current: `${currentSettings.width}x${currentSettings.height}`,
|
|
1590
|
+
required: `${minRequiredWidth}px minimum width`,
|
|
1591
|
+
deviceId
|
|
1592
|
+
});
|
|
1593
|
+
// 關閉當前相機流
|
|
1594
|
+
stream.getTracks().forEach(track => track.stop());
|
|
1595
|
+
// 顯示彈窗並等待用戶點擊
|
|
1596
|
+
if (translate) {
|
|
1597
|
+
yield asyncShowPopup('相機解析度不足', '相機解析度不足,請重新嘗試或更換裝置', true, '重新嘗試');
|
|
1598
|
+
}
|
|
1599
|
+
throw BROWSER_CAMERA_ERRORS.LOW_RESOLUTION;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1581
1602
|
// try {
|
|
1582
1603
|
// stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
1583
1604
|
// console.log("獲取媒體流成功:", stream);
|
|
@@ -1621,6 +1642,10 @@ function switchCamera(deviceId, video) {
|
|
|
1621
1642
|
video.srcObject = stream;
|
|
1622
1643
|
}, 10);
|
|
1623
1644
|
} catch (e) {
|
|
1645
|
+
// 如果是低解析度錯誤,直接拋出不包裝,讓外層處理重試
|
|
1646
|
+
if (e === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
|
|
1647
|
+
throw e;
|
|
1648
|
+
}
|
|
1624
1649
|
// 🆕 增強錯誤日誌
|
|
1625
1650
|
const initTime = (performance.now() - startTime).toFixed(2);
|
|
1626
1651
|
console.error('❌ Camera切換失敗', {
|
|
@@ -1636,7 +1661,7 @@ function switchCamera(deviceId, video) {
|
|
|
1636
1661
|
}
|
|
1637
1662
|
});
|
|
1638
1663
|
}
|
|
1639
|
-
function _requestCamera(video, facingMode) {
|
|
1664
|
+
function _requestCamera(video, facingMode, translate) {
|
|
1640
1665
|
var _a, _b, _c, _d, _e, _f;
|
|
1641
1666
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1642
1667
|
const requestStartTime = performance.now();
|
|
@@ -1735,7 +1760,28 @@ function _requestCamera(video, facingMode) {
|
|
|
1735
1760
|
if (stream) {
|
|
1736
1761
|
stream.getTracks().forEach(track => track.stop());
|
|
1737
1762
|
}
|
|
1738
|
-
|
|
1763
|
+
// 嘗試開啟相機,如果解析度不足會持續重試
|
|
1764
|
+
let retryCount = 0;
|
|
1765
|
+
const MAX_RETRIES = 5;
|
|
1766
|
+
while (retryCount < MAX_RETRIES) {
|
|
1767
|
+
try {
|
|
1768
|
+
yield switchCamera(deviceId, video, translate);
|
|
1769
|
+
break; // 成功就跳出循環
|
|
1770
|
+
} catch (error) {
|
|
1771
|
+
if (error === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
|
|
1772
|
+
retryCount++;
|
|
1773
|
+
if (retryCount >= MAX_RETRIES) {
|
|
1774
|
+
console.error(`❌ 達到最大重試次數 (${MAX_RETRIES}),相機解析度持續不足`);
|
|
1775
|
+
throw error;
|
|
1776
|
+
}
|
|
1777
|
+
console.log(`🔄 解析度不足,第 ${retryCount} 次重試...`);
|
|
1778
|
+
// 等待一下再重試
|
|
1779
|
+
yield new Promise(resolve => setTimeout(resolve, 500));
|
|
1780
|
+
} else {
|
|
1781
|
+
throw error; // 其他錯誤直接拋出
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1739
1785
|
// 🆕 記錄整個請求流程的總結資訊
|
|
1740
1786
|
const totalTime = (performance.now() - requestStartTime).toFixed(2);
|
|
1741
1787
|
console.log('🎉 Camera請求流程完成', {
|
|
@@ -1783,7 +1829,7 @@ function requestCamera({
|
|
|
1783
1829
|
try {
|
|
1784
1830
|
//for ios 17.4.1 hack, if you call getUserMedia too early will only get not allowed.
|
|
1785
1831
|
yield sleep(1000);
|
|
1786
|
-
return yield _requestCamera(video, facingMode);
|
|
1832
|
+
return yield _requestCamera(video, facingMode, translate);
|
|
1787
1833
|
} catch (error) {
|
|
1788
1834
|
if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_ALLOWED_ERROR) {
|
|
1789
1835
|
perm = yield navigator.permissions.query({
|
|
@@ -1794,9 +1840,9 @@ function requestCamera({
|
|
|
1794
1840
|
}
|
|
1795
1841
|
}
|
|
1796
1842
|
}
|
|
1797
|
-
return yield _requestCamera(video, facingMode);
|
|
1843
|
+
return yield _requestCamera(video, facingMode, translate);
|
|
1798
1844
|
} else {
|
|
1799
|
-
return yield _requestCamera(video, facingMode);
|
|
1845
|
+
return yield _requestCamera(video, facingMode, translate);
|
|
1800
1846
|
}
|
|
1801
1847
|
} catch (error) {
|
|
1802
1848
|
if (error === BROWSER_CAMERA_ERRORS.NOT_SUPPORT) {
|
|
@@ -1820,6 +1866,14 @@ function requestCamera({
|
|
|
1820
1866
|
*/
|
|
1821
1867
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1822
1868
|
}
|
|
1869
|
+
if (error === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
|
|
1870
|
+
// 顯示彈窗並等待用戶點擊後重新載入
|
|
1871
|
+
yield asyncShowPopup(translate('sdk.general.error.cameraLowResolution'), translate('sdk.general.error.cameraLowResolution') + ',請重新嘗試或更換裝置', true);
|
|
1872
|
+
// 用戶點擊確定後,重新載入頁面
|
|
1873
|
+
globalThis.location.reload();
|
|
1874
|
+
// 不會執行到這裡,因為頁面已重新載入
|
|
1875
|
+
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1876
|
+
}
|
|
1823
1877
|
if (isOverconstrainedError(error)) {
|
|
1824
1878
|
showMessage(translate('sdk.general.error.cameraLowResolution'));
|
|
1825
1879
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
@@ -3314,8 +3368,8 @@ const themeConfigDefault = {
|
|
|
3314
3368
|
};
|
|
3315
3369
|
|
|
3316
3370
|
var name = "authme/sdk";
|
|
3317
|
-
var version$1 = "2.8.
|
|
3318
|
-
var date = "2025-11-
|
|
3371
|
+
var version$1 = "2.8.34";
|
|
3372
|
+
var date = "2025-11-24T03:00:21+0000";
|
|
3319
3373
|
var packageInfo = {
|
|
3320
3374
|
name: name,
|
|
3321
3375
|
version: version$1,
|
package/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import 'core-js/modules/es.parse-int.js';
|
|
|
25
25
|
import Lottie from 'lottie-web';
|
|
26
26
|
import 'core-js/modules/es.number.to-fixed.js';
|
|
27
27
|
import 'core-js/modules/es.array.sort.js';
|
|
28
|
+
import 'core-js/modules/esnext.global-this.js';
|
|
28
29
|
import 'core-js/modules/es.string.trim.js';
|
|
29
30
|
import 'core-js/modules/es.string.starts-with.js';
|
|
30
31
|
import 'core-js/modules/es.symbol.description.js';
|
|
@@ -1085,7 +1086,6 @@ const uiThemeDirection = (panel, hintStyle) => {
|
|
|
1085
1086
|
panel.style.borderRadius = `${hintStyle.cornerRadius || 20}px`;
|
|
1086
1087
|
panel.style.backgroundColor = hintStyle.backgroundColor;
|
|
1087
1088
|
panel.style.opacity = hintStyle.backgroundOpacity;
|
|
1088
|
-
panel.style.display = 'none';
|
|
1089
1089
|
panel.style.flexDirection = 'row';
|
|
1090
1090
|
panel.style.alignItems = 'center';
|
|
1091
1091
|
panel.style.justifyContent = 'center';
|
|
@@ -1353,7 +1353,7 @@ function checkOnlineStatus(msg, buttonText) {
|
|
|
1353
1353
|
});
|
|
1354
1354
|
}
|
|
1355
1355
|
|
|
1356
|
-
function showPopup(title, content, showButton = true,
|
|
1356
|
+
function showPopup(title, content, showButton = true, buttonText, callback) {
|
|
1357
1357
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1358
1358
|
const target = document.querySelector('.authme-container');
|
|
1359
1359
|
const popupBackground = document.createElement('div');
|
|
@@ -1368,7 +1368,7 @@ function showPopup(title, content, showButton = true, button, callback) {
|
|
|
1368
1368
|
popupContent.textContent = content;
|
|
1369
1369
|
const popupConfirmBtn = document.createElement('button');
|
|
1370
1370
|
popupConfirmBtn.className = 'popup-btn';
|
|
1371
|
-
popupConfirmBtn.textContent = '確定';
|
|
1371
|
+
popupConfirmBtn.textContent = buttonText || '確定';
|
|
1372
1372
|
popupPanel.appendChild(popupTitle);
|
|
1373
1373
|
popupPanel.appendChild(popupContent);
|
|
1374
1374
|
if (showButton) {
|
|
@@ -1391,14 +1391,14 @@ function hidePopup() {
|
|
|
1391
1391
|
popupBackground.remove();
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
|
-
function asyncShowPopup(title, content, showButton = true,
|
|
1394
|
+
function asyncShowPopup(title, content, showButton = true, buttonText) {
|
|
1395
1395
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1396
1396
|
return new Promise((res, rej) => {
|
|
1397
1397
|
const callback = () => {
|
|
1398
1398
|
res(true);
|
|
1399
1399
|
hidePopup();
|
|
1400
1400
|
};
|
|
1401
|
-
showPopup(title, content, showButton,
|
|
1401
|
+
showPopup(title, content, showButton, buttonText, callback);
|
|
1402
1402
|
});
|
|
1403
1403
|
});
|
|
1404
1404
|
}
|
|
@@ -1411,6 +1411,7 @@ var BROWSER_CAMERA_ERRORS;
|
|
|
1411
1411
|
BROWSER_CAMERA_ERRORS["NOT_FOUND_ERROR"] = "NotFoundError";
|
|
1412
1412
|
BROWSER_CAMERA_ERRORS["NOT_READABLE_ERROR"] = "NotReadableError";
|
|
1413
1413
|
BROWSER_CAMERA_ERRORS["ABORT_ERROR"] = "AbortError";
|
|
1414
|
+
BROWSER_CAMERA_ERRORS["LOW_RESOLUTION"] = "LowResolutionError";
|
|
1414
1415
|
})(BROWSER_CAMERA_ERRORS || (BROWSER_CAMERA_ERRORS = {}));
|
|
1415
1416
|
let stream;
|
|
1416
1417
|
const videoConstraintsFactory = (isPC, facingMode) => {
|
|
@@ -1505,8 +1506,8 @@ function upgradeResolution(videoTrack) {
|
|
|
1505
1506
|
}
|
|
1506
1507
|
};
|
|
1507
1508
|
const minAcceptableWidth = 1280; // 最低可接受的解析度寬度
|
|
1508
|
-
const maxAttempts =
|
|
1509
|
-
const retryDelay =
|
|
1509
|
+
const maxAttempts = 5; // 最多嘗試10次
|
|
1510
|
+
const retryDelay = 2000; // 每次重試間隔1秒
|
|
1510
1511
|
console.log('🚀 開始提升解析度...');
|
|
1511
1512
|
const startTime = Date.now();
|
|
1512
1513
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
@@ -1536,7 +1537,7 @@ function upgradeResolution(videoTrack) {
|
|
|
1536
1537
|
console.warn(`⚠️ 達到最大重試次數,使用當前解析度: ${finalSettings.width}x${finalSettings.height}`);
|
|
1537
1538
|
});
|
|
1538
1539
|
}
|
|
1539
|
-
function switchCamera(deviceId, video) {
|
|
1540
|
+
function switchCamera(deviceId, video, translate) {
|
|
1540
1541
|
var _a, _b;
|
|
1541
1542
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1542
1543
|
const startTime = performance.now();
|
|
@@ -1568,6 +1569,26 @@ function switchCamera(deviceId, video) {
|
|
|
1568
1569
|
initTime: `${initTime}ms`
|
|
1569
1570
|
});
|
|
1570
1571
|
}
|
|
1572
|
+
// 檢查最終解析度是否達到最低要求
|
|
1573
|
+
const currentTrack = stream.getVideoTracks()[0];
|
|
1574
|
+
if (currentTrack) {
|
|
1575
|
+
const currentSettings = currentTrack.getSettings();
|
|
1576
|
+
const minRequiredWidth = 1280;
|
|
1577
|
+
if (currentSettings.width && currentSettings.width < minRequiredWidth) {
|
|
1578
|
+
console.error('❌ Camera解析度不足', {
|
|
1579
|
+
current: `${currentSettings.width}x${currentSettings.height}`,
|
|
1580
|
+
required: `${minRequiredWidth}px minimum width`,
|
|
1581
|
+
deviceId
|
|
1582
|
+
});
|
|
1583
|
+
// 關閉當前相機流
|
|
1584
|
+
stream.getTracks().forEach(track => track.stop());
|
|
1585
|
+
// 顯示彈窗並等待用戶點擊
|
|
1586
|
+
if (translate) {
|
|
1587
|
+
yield asyncShowPopup('相機解析度不足', '相機解析度不足,請重新嘗試或更換裝置', true, '重新嘗試');
|
|
1588
|
+
}
|
|
1589
|
+
throw BROWSER_CAMERA_ERRORS.LOW_RESOLUTION;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1571
1592
|
// try {
|
|
1572
1593
|
// stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
1573
1594
|
// console.log("獲取媒體流成功:", stream);
|
|
@@ -1611,6 +1632,10 @@ function switchCamera(deviceId, video) {
|
|
|
1611
1632
|
video.srcObject = stream;
|
|
1612
1633
|
}, 10);
|
|
1613
1634
|
} catch (e) {
|
|
1635
|
+
// 如果是低解析度錯誤,直接拋出不包裝,讓外層處理重試
|
|
1636
|
+
if (e === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
|
|
1637
|
+
throw e;
|
|
1638
|
+
}
|
|
1614
1639
|
// 🆕 增強錯誤日誌
|
|
1615
1640
|
const initTime = (performance.now() - startTime).toFixed(2);
|
|
1616
1641
|
console.error('❌ Camera切換失敗', {
|
|
@@ -1626,7 +1651,7 @@ function switchCamera(deviceId, video) {
|
|
|
1626
1651
|
}
|
|
1627
1652
|
});
|
|
1628
1653
|
}
|
|
1629
|
-
function _requestCamera(video, facingMode) {
|
|
1654
|
+
function _requestCamera(video, facingMode, translate) {
|
|
1630
1655
|
var _a, _b, _c, _d, _e, _f;
|
|
1631
1656
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1632
1657
|
const requestStartTime = performance.now();
|
|
@@ -1725,7 +1750,28 @@ function _requestCamera(video, facingMode) {
|
|
|
1725
1750
|
if (stream) {
|
|
1726
1751
|
stream.getTracks().forEach(track => track.stop());
|
|
1727
1752
|
}
|
|
1728
|
-
|
|
1753
|
+
// 嘗試開啟相機,如果解析度不足會持續重試
|
|
1754
|
+
let retryCount = 0;
|
|
1755
|
+
const MAX_RETRIES = 5;
|
|
1756
|
+
while (retryCount < MAX_RETRIES) {
|
|
1757
|
+
try {
|
|
1758
|
+
yield switchCamera(deviceId, video, translate);
|
|
1759
|
+
break; // 成功就跳出循環
|
|
1760
|
+
} catch (error) {
|
|
1761
|
+
if (error === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
|
|
1762
|
+
retryCount++;
|
|
1763
|
+
if (retryCount >= MAX_RETRIES) {
|
|
1764
|
+
console.error(`❌ 達到最大重試次數 (${MAX_RETRIES}),相機解析度持續不足`);
|
|
1765
|
+
throw error;
|
|
1766
|
+
}
|
|
1767
|
+
console.log(`🔄 解析度不足,第 ${retryCount} 次重試...`);
|
|
1768
|
+
// 等待一下再重試
|
|
1769
|
+
yield new Promise(resolve => setTimeout(resolve, 500));
|
|
1770
|
+
} else {
|
|
1771
|
+
throw error; // 其他錯誤直接拋出
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1729
1775
|
// 🆕 記錄整個請求流程的總結資訊
|
|
1730
1776
|
const totalTime = (performance.now() - requestStartTime).toFixed(2);
|
|
1731
1777
|
console.log('🎉 Camera請求流程完成', {
|
|
@@ -1773,7 +1819,7 @@ function requestCamera({
|
|
|
1773
1819
|
try {
|
|
1774
1820
|
//for ios 17.4.1 hack, if you call getUserMedia too early will only get not allowed.
|
|
1775
1821
|
yield sleep(1000);
|
|
1776
|
-
return yield _requestCamera(video, facingMode);
|
|
1822
|
+
return yield _requestCamera(video, facingMode, translate);
|
|
1777
1823
|
} catch (error) {
|
|
1778
1824
|
if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_ALLOWED_ERROR) {
|
|
1779
1825
|
perm = yield navigator.permissions.query({
|
|
@@ -1784,9 +1830,9 @@ function requestCamera({
|
|
|
1784
1830
|
}
|
|
1785
1831
|
}
|
|
1786
1832
|
}
|
|
1787
|
-
return yield _requestCamera(video, facingMode);
|
|
1833
|
+
return yield _requestCamera(video, facingMode, translate);
|
|
1788
1834
|
} else {
|
|
1789
|
-
return yield _requestCamera(video, facingMode);
|
|
1835
|
+
return yield _requestCamera(video, facingMode, translate);
|
|
1790
1836
|
}
|
|
1791
1837
|
} catch (error) {
|
|
1792
1838
|
if (error === BROWSER_CAMERA_ERRORS.NOT_SUPPORT) {
|
|
@@ -1810,6 +1856,14 @@ function requestCamera({
|
|
|
1810
1856
|
*/
|
|
1811
1857
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1812
1858
|
}
|
|
1859
|
+
if (error === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
|
|
1860
|
+
// 顯示彈窗並等待用戶點擊後重新載入
|
|
1861
|
+
yield asyncShowPopup(translate('sdk.general.error.cameraLowResolution'), translate('sdk.general.error.cameraLowResolution') + ',請重新嘗試或更換裝置', true);
|
|
1862
|
+
// 用戶點擊確定後,重新載入頁面
|
|
1863
|
+
globalThis.location.reload();
|
|
1864
|
+
// 不會執行到這裡,因為頁面已重新載入
|
|
1865
|
+
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1866
|
+
}
|
|
1813
1867
|
if (isOverconstrainedError(error)) {
|
|
1814
1868
|
showMessage(translate('sdk.general.error.cameraLowResolution'));
|
|
1815
1869
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
@@ -3304,8 +3358,8 @@ const themeConfigDefault = {
|
|
|
3304
3358
|
};
|
|
3305
3359
|
|
|
3306
3360
|
var name = "authme/sdk";
|
|
3307
|
-
var version$1 = "2.8.
|
|
3308
|
-
var date = "2025-11-
|
|
3361
|
+
var version$1 = "2.8.34";
|
|
3362
|
+
var date = "2025-11-24T03:00:21+0000";
|
|
3309
3363
|
var packageInfo = {
|
|
3310
3364
|
name: name,
|
|
3311
3365
|
version: version$1,
|
package/package.json
CHANGED
package/src/ui/camera.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare const videoConstraintsFactory: (isPC: boolean, facingMode: 'user'
|
|
|
39
39
|
facingMode: "user" | "environment";
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
export declare function switchCamera(deviceId: string, video: HTMLVideoElement): Promise<void>;
|
|
42
|
+
export declare function switchCamera(deviceId: string, video: HTMLVideoElement, translate?: (key: string) => string): Promise<void>;
|
|
43
43
|
export declare function requestCamera({ video, facingMode, translate, showMessage, }: {
|
|
44
44
|
video: HTMLVideoElement;
|
|
45
45
|
facingMode: 'front' | 'back';
|
package/src/ui/popup.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function showPopup(title: string, content: string, showButton?: boolean,
|
|
1
|
+
export declare function showPopup(title: string, content: string, showButton?: boolean, buttonText?: string, callback?: (e: Event) => void): Promise<void>;
|
|
2
2
|
export declare function hidePopup(): void;
|
|
3
|
-
export declare function asyncShowPopup(title: string, content: string, showButton?: boolean,
|
|
3
|
+
export declare function asyncShowPopup(title: string, content: string, showButton?: boolean, buttonText?: string): Promise<boolean>;
|