@authme/util 2.8.25 → 2.8.26
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 +131 -30
- package/index.js +131 -31
- package/package.json +1 -1
- package/src/ui/camera.d.ts +0 -4
- package/src/ui/uiThemeStyle.d.ts +3 -2
package/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ require('core-js/modules/es.array.includes.js');
|
|
|
25
25
|
require('core-js/modules/es.string.includes.js');
|
|
26
26
|
var fileSaver = require('file-saver');
|
|
27
27
|
var JSZip = require('jszip');
|
|
28
|
+
require('core-js/modules/es.number.to-fixed.js');
|
|
28
29
|
require('core-js/modules/es.parse-int.js');
|
|
29
30
|
var Lottie = require('lottie-web');
|
|
30
31
|
require('core-js/modules/es.array.sort.js');
|
|
@@ -976,6 +977,8 @@ function getCanvasSize(video) {
|
|
|
976
977
|
videoWidth = video.videoWidth;
|
|
977
978
|
videoHeight = video.videoHeight;
|
|
978
979
|
}
|
|
980
|
+
console.log('=== 相機解析度 ===', videoWidth, 'x', videoHeight);
|
|
981
|
+
console.log('視窗尺寸:', window.innerWidth, 'x', window.innerHeight);
|
|
979
982
|
const result = {
|
|
980
983
|
height: 0,
|
|
981
984
|
width: 0,
|
|
@@ -999,14 +1002,22 @@ function getCanvasSize(video) {
|
|
|
999
1002
|
result.startX = 0;
|
|
1000
1003
|
result.startY = Math.floor((videoHeight - result.height) / 2);
|
|
1001
1004
|
}
|
|
1002
|
-
const maxHeight = videoHeight > videoWidth ? 1280 : 720;
|
|
1003
|
-
const maxWidth = videoHeight > videoWidth ? 720 : 1280;
|
|
1004
|
-
const resizeRatioH = maxHeight / Math.max(result.height, maxHeight);
|
|
1005
|
-
const resizeRatioW = maxWidth / Math.max(result.width, maxWidth);
|
|
1006
|
-
const resizeRatio = Math.max(resizeRatioH, resizeRatioW);
|
|
1007
|
-
//
|
|
1005
|
+
// const maxHeight = videoHeight > videoWidth ? 1280 : 720;
|
|
1006
|
+
// const maxWidth = videoHeight > videoWidth ? 720 : 1280;
|
|
1007
|
+
// const resizeRatioH = maxHeight / Math.max(result.height, maxHeight);
|
|
1008
|
+
// const resizeRatioW = maxWidth / Math.max(result.width, maxWidth);
|
|
1009
|
+
// const resizeRatio = Math.max(resizeRatioH, resizeRatioW);
|
|
1010
|
+
// 暫時降低解析度測試
|
|
1011
|
+
const maxDimension = 1920; // 限制最大尺寸
|
|
1012
|
+
const resizeRatio = Math.min(1, maxDimension / Math.max(result.width, result.height));
|
|
1008
1013
|
result.canvasWidth = Math.floor(result.width * resizeRatio);
|
|
1009
1014
|
result.canvasHeight = Math.floor(result.height * resizeRatio);
|
|
1015
|
+
console.log('調整比例:', resizeRatio.toFixed(3));
|
|
1016
|
+
console.log('=== 最終輸出解析度 ===', result.canvasWidth, 'x', result.canvasHeight);
|
|
1017
|
+
console.log('裁切區域:', `${result.width}x${result.height} 起始點:(${result.startX}, ${result.startY})`);
|
|
1018
|
+
const totalPixels = result.canvasWidth * result.canvasHeight;
|
|
1019
|
+
const estimatedMB = totalPixels * 4 / 1024 / 1024; // 4 bytes per pixel (RGBA)
|
|
1020
|
+
console.log('估計記憶體用量:', estimatedMB.toFixed(2), 'MB (未壓縮)');
|
|
1010
1021
|
return result;
|
|
1011
1022
|
});
|
|
1012
1023
|
}
|
|
@@ -1045,18 +1056,82 @@ const hexToRgba = (hex, alpha = 1) => {
|
|
|
1045
1056
|
const b = parseInt(hex.substring(4, 6), 16);
|
|
1046
1057
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
1047
1058
|
};
|
|
1048
|
-
const uiThemeText = (dom, textStyle) => {
|
|
1059
|
+
const uiThemeText = (dom, textStyle, distance) => {
|
|
1049
1060
|
dom.style.color = textStyle.textColor;
|
|
1050
1061
|
dom.style.fontWeight = fontWeight[textStyle.textWeight];
|
|
1051
1062
|
dom.style.fontSize = `${textStyle.fontSize}px`;
|
|
1063
|
+
// Position parent element at the bottom by default
|
|
1064
|
+
if (dom.parentElement) {
|
|
1065
|
+
const parent = dom.parentElement;
|
|
1066
|
+
parent.style.position = 'absolute';
|
|
1067
|
+
parent.style.display = 'block';
|
|
1068
|
+
// Adjust based on direction if provided
|
|
1069
|
+
if (textStyle.direction === 'top') {
|
|
1070
|
+
parent.style.top = distance || '10vh';
|
|
1071
|
+
parent.style.bottom = 'unset';
|
|
1072
|
+
} else if (textStyle.direction === 'bottom') {
|
|
1073
|
+
parent.style.top = 'unset';
|
|
1074
|
+
parent.style.bottom = distance || '10vh';
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1052
1077
|
};
|
|
1053
|
-
const uiThemeHint = (dom, hintStyle) => {
|
|
1078
|
+
const uiThemeHint = (dom, hintStyle, distance) => {
|
|
1054
1079
|
dom.style.borderRadius = `${hintStyle.cornerRadius}px`;
|
|
1055
1080
|
dom.style.backgroundColor = hintStyle.backgroundColor;
|
|
1056
1081
|
dom.style.opacity = hintStyle.opacity;
|
|
1057
1082
|
dom.style.color = hintStyle.textColor;
|
|
1058
1083
|
dom.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1059
1084
|
dom.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1085
|
+
// Position parent element at the top by default
|
|
1086
|
+
if (dom.parentElement) {
|
|
1087
|
+
const parent = dom.parentElement;
|
|
1088
|
+
parent.style.display = 'block';
|
|
1089
|
+
parent.style.position = 'absolute';
|
|
1090
|
+
// Adjust based on direction if provided
|
|
1091
|
+
if (hintStyle.direction === 'top') {
|
|
1092
|
+
parent.style.top = distance || '10vh';
|
|
1093
|
+
parent.style.bottom = 'unset';
|
|
1094
|
+
} else {
|
|
1095
|
+
parent.style.top = 'unset';
|
|
1096
|
+
parent.style.bottom = distance || '10vh';
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
const uiThemeDirection = (panel, hintStyle) => {
|
|
1101
|
+
// Apply background styles to the panel (directionTextPanel)
|
|
1102
|
+
panel.style.borderRadius = `${hintStyle.cornerRadius || 20}px`;
|
|
1103
|
+
panel.style.backgroundColor = hintStyle.backgroundColor;
|
|
1104
|
+
panel.style.opacity = hintStyle.backgroundOpacity;
|
|
1105
|
+
panel.style.display = 'none';
|
|
1106
|
+
panel.style.flexDirection = 'row';
|
|
1107
|
+
panel.style.alignItems = 'center';
|
|
1108
|
+
panel.style.justifyContent = 'center';
|
|
1109
|
+
panel.style.gap = '12px';
|
|
1110
|
+
panel.style.padding = '16px 24px';
|
|
1111
|
+
panel.style.boxSizing = 'border-box';
|
|
1112
|
+
panel.style.minWidth = hintStyle.width;
|
|
1113
|
+
panel.style.width = hintStyle.width;
|
|
1114
|
+
panel.style.height = `${hintStyle.height || 'auto'}`;
|
|
1115
|
+
// Style the text child
|
|
1116
|
+
const directionText = panel.querySelector('.status-text');
|
|
1117
|
+
if (directionText) {
|
|
1118
|
+
directionText.style.color = hintStyle.textColor;
|
|
1119
|
+
directionText.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1120
|
+
directionText.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1121
|
+
directionText.style.whiteSpace = 'nowrap';
|
|
1122
|
+
directionText.style.display = 'inline-block';
|
|
1123
|
+
directionText.style.verticalAlign = 'middle';
|
|
1124
|
+
}
|
|
1125
|
+
// Style the icon child
|
|
1126
|
+
const directionIcon = panel.querySelector('.direction-icon');
|
|
1127
|
+
if (directionIcon) {
|
|
1128
|
+
directionIcon.style.display = 'flex';
|
|
1129
|
+
directionIcon.style.alignItems = 'center';
|
|
1130
|
+
directionIcon.style.justifyContent = 'center';
|
|
1131
|
+
directionIcon.style.flexShrink = '0';
|
|
1132
|
+
directionIcon.style.width = '72px';
|
|
1133
|
+
directionIcon.style.height = '72px';
|
|
1134
|
+
}
|
|
1060
1135
|
};
|
|
1061
1136
|
const uiThemeButton = (dom, buttonStyle, disabled) => {
|
|
1062
1137
|
dom.style.opacity = buttonStyle.backgroundOpacity;
|
|
@@ -1360,13 +1435,11 @@ const videoConstraintsFactory = (isPC, facingMode) => {
|
|
|
1360
1435
|
video: {
|
|
1361
1436
|
width: {
|
|
1362
1437
|
min: 1280,
|
|
1363
|
-
ideal: 1920
|
|
1364
|
-
max: 1920
|
|
1438
|
+
ideal: 1920
|
|
1365
1439
|
},
|
|
1366
1440
|
height: {
|
|
1367
1441
|
min: 720,
|
|
1368
|
-
ideal: 1080
|
|
1369
|
-
max: 1080
|
|
1442
|
+
ideal: 1080
|
|
1370
1443
|
},
|
|
1371
1444
|
facingMode
|
|
1372
1445
|
}
|
|
@@ -1441,23 +1514,36 @@ function switchCamera(deviceId, video) {
|
|
|
1441
1514
|
if (stream) {
|
|
1442
1515
|
stream.getTracks().forEach(track => track.stop());
|
|
1443
1516
|
}
|
|
1444
|
-
|
|
1517
|
+
// 第一階段:使用基本約束獲取流,確保相機能工作
|
|
1518
|
+
const basicConstraints = {
|
|
1445
1519
|
video: {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
focusMode: 'auto',
|
|
1449
|
-
deviceId: deviceId
|
|
1520
|
+
deviceId: deviceId,
|
|
1521
|
+
focusMode: 'auto'
|
|
1450
1522
|
}
|
|
1451
1523
|
};
|
|
1452
1524
|
const constraint = localStorage.getItem('camera_constraint');
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1525
|
+
stream = yield navigator.mediaDevices.getUserMedia(basicConstraints);
|
|
1526
|
+
// 第二階段:如果沒有設定跳過約束,嘗試使用 applyConstraints 提升解析度
|
|
1527
|
+
if (!constraint && stream) {
|
|
1528
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
1529
|
+
if (videoTrack && videoTrack.applyConstraints) {
|
|
1530
|
+
try {
|
|
1531
|
+
// 嘗試應用更高解析度(使用 ideal 而非 min/max)
|
|
1532
|
+
yield videoTrack.applyConstraints({
|
|
1533
|
+
width: {
|
|
1534
|
+
ideal: 1920,
|
|
1535
|
+
max: 3840
|
|
1536
|
+
},
|
|
1537
|
+
height: {
|
|
1538
|
+
ideal: 1080,
|
|
1539
|
+
max: 2160
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
} catch (error) {
|
|
1543
|
+
// 失敗時保持原有流,不會中斷相機
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1459
1546
|
}
|
|
1460
|
-
stream = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
1461
1547
|
// try {
|
|
1462
1548
|
// stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
1463
1549
|
// console.log("獲取媒體流成功:", stream);
|
|
@@ -1465,19 +1551,16 @@ function switchCamera(deviceId, video) {
|
|
|
1465
1551
|
// console.error("獲取媒體流失敗:", error);
|
|
1466
1552
|
// }
|
|
1467
1553
|
if (stream.getVideoTracks().length === 0) {
|
|
1468
|
-
console.error('沒有 video track');
|
|
1469
1554
|
throw new Error('沒有 video track');
|
|
1470
1555
|
}
|
|
1471
1556
|
try {
|
|
1472
1557
|
video.srcObject = stream;
|
|
1473
1558
|
} catch (error) {
|
|
1474
|
-
// console.error("設置視訊流失敗:", error);
|
|
1475
1559
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1476
1560
|
}
|
|
1477
1561
|
try {
|
|
1478
1562
|
yield video.play();
|
|
1479
1563
|
} catch (error) {
|
|
1480
|
-
// console.error("播放視訊失敗:", error);
|
|
1481
1564
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1482
1565
|
}
|
|
1483
1566
|
// console.log('stream', stream.getVideoTracks()[0].getSettings());
|
|
@@ -3092,7 +3175,24 @@ const themeConfigDefault = {
|
|
|
3092
3175
|
// Figma標示dark_title 1
|
|
3093
3176
|
textColor: '#ffffff',
|
|
3094
3177
|
textWeight: 'medium',
|
|
3095
|
-
fontSize: 20
|
|
3178
|
+
fontSize: 20,
|
|
3179
|
+
direction: 'bottom' //文字方向 bottom / top / center,
|
|
3180
|
+
},
|
|
3181
|
+
|
|
3182
|
+
fraudScanHintText: {
|
|
3183
|
+
// D.F.SC.2
|
|
3184
|
+
backgroundColor: '#000000',
|
|
3185
|
+
backgroundOpacity: 0.7,
|
|
3186
|
+
cornerRadius: 28,
|
|
3187
|
+
width: '153px',
|
|
3188
|
+
height: '56px',
|
|
3189
|
+
textColor: '#FFFFFF',
|
|
3190
|
+
textWeight: 'medium',
|
|
3191
|
+
fontSize: 18,
|
|
3192
|
+
leftText: '向左翻轉',
|
|
3193
|
+
rightText: '向右翻轉',
|
|
3194
|
+
upText: '向上翻轉',
|
|
3195
|
+
downText: '向下翻轉'
|
|
3096
3196
|
},
|
|
3097
3197
|
titleTwoDarkMode: {
|
|
3098
3198
|
// G.T.D.2
|
|
@@ -3151,8 +3251,8 @@ const themeConfigDefault = {
|
|
|
3151
3251
|
};
|
|
3152
3252
|
|
|
3153
3253
|
var name = "authme/sdk";
|
|
3154
|
-
var version$1 = "2.8.
|
|
3155
|
-
var date = "2025-
|
|
3254
|
+
var version$1 = "2.8.26";
|
|
3255
|
+
var date = "2025-09-30T03:00:07+0000";
|
|
3156
3256
|
var packageInfo = {
|
|
3157
3257
|
name: name,
|
|
3158
3258
|
version: version$1,
|
|
@@ -3213,6 +3313,7 @@ exports.stopSpinner = stopSpinner;
|
|
|
3213
3313
|
exports.switchCamera = switchCamera;
|
|
3214
3314
|
exports.themeConfigDefault = themeConfigDefault;
|
|
3215
3315
|
exports.uiThemeButton = uiThemeButton;
|
|
3316
|
+
exports.uiThemeDirection = uiThemeDirection;
|
|
3216
3317
|
exports.uiThemeHint = uiThemeHint;
|
|
3217
3318
|
exports.uiThemeSmallButton = uiThemeSmallButton;
|
|
3218
3319
|
exports.uiThemeText = uiThemeText;
|
package/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import 'core-js/modules/es.array.includes.js';
|
|
|
21
21
|
import 'core-js/modules/es.string.includes.js';
|
|
22
22
|
import { saveAs } from 'file-saver';
|
|
23
23
|
import JSZip from 'jszip';
|
|
24
|
+
import 'core-js/modules/es.number.to-fixed.js';
|
|
24
25
|
import 'core-js/modules/es.parse-int.js';
|
|
25
26
|
import Lottie from 'lottie-web';
|
|
26
27
|
import 'core-js/modules/es.array.sort.js';
|
|
@@ -966,6 +967,8 @@ function getCanvasSize(video) {
|
|
|
966
967
|
videoWidth = video.videoWidth;
|
|
967
968
|
videoHeight = video.videoHeight;
|
|
968
969
|
}
|
|
970
|
+
console.log('=== 相機解析度 ===', videoWidth, 'x', videoHeight);
|
|
971
|
+
console.log('視窗尺寸:', window.innerWidth, 'x', window.innerHeight);
|
|
969
972
|
const result = {
|
|
970
973
|
height: 0,
|
|
971
974
|
width: 0,
|
|
@@ -989,14 +992,22 @@ function getCanvasSize(video) {
|
|
|
989
992
|
result.startX = 0;
|
|
990
993
|
result.startY = Math.floor((videoHeight - result.height) / 2);
|
|
991
994
|
}
|
|
992
|
-
const maxHeight = videoHeight > videoWidth ? 1280 : 720;
|
|
993
|
-
const maxWidth = videoHeight > videoWidth ? 720 : 1280;
|
|
994
|
-
const resizeRatioH = maxHeight / Math.max(result.height, maxHeight);
|
|
995
|
-
const resizeRatioW = maxWidth / Math.max(result.width, maxWidth);
|
|
996
|
-
const resizeRatio = Math.max(resizeRatioH, resizeRatioW);
|
|
997
|
-
//
|
|
995
|
+
// const maxHeight = videoHeight > videoWidth ? 1280 : 720;
|
|
996
|
+
// const maxWidth = videoHeight > videoWidth ? 720 : 1280;
|
|
997
|
+
// const resizeRatioH = maxHeight / Math.max(result.height, maxHeight);
|
|
998
|
+
// const resizeRatioW = maxWidth / Math.max(result.width, maxWidth);
|
|
999
|
+
// const resizeRatio = Math.max(resizeRatioH, resizeRatioW);
|
|
1000
|
+
// 暫時降低解析度測試
|
|
1001
|
+
const maxDimension = 1920; // 限制最大尺寸
|
|
1002
|
+
const resizeRatio = Math.min(1, maxDimension / Math.max(result.width, result.height));
|
|
998
1003
|
result.canvasWidth = Math.floor(result.width * resizeRatio);
|
|
999
1004
|
result.canvasHeight = Math.floor(result.height * resizeRatio);
|
|
1005
|
+
console.log('調整比例:', resizeRatio.toFixed(3));
|
|
1006
|
+
console.log('=== 最終輸出解析度 ===', result.canvasWidth, 'x', result.canvasHeight);
|
|
1007
|
+
console.log('裁切區域:', `${result.width}x${result.height} 起始點:(${result.startX}, ${result.startY})`);
|
|
1008
|
+
const totalPixels = result.canvasWidth * result.canvasHeight;
|
|
1009
|
+
const estimatedMB = totalPixels * 4 / 1024 / 1024; // 4 bytes per pixel (RGBA)
|
|
1010
|
+
console.log('估計記憶體用量:', estimatedMB.toFixed(2), 'MB (未壓縮)');
|
|
1000
1011
|
return result;
|
|
1001
1012
|
});
|
|
1002
1013
|
}
|
|
@@ -1035,18 +1046,82 @@ const hexToRgba = (hex, alpha = 1) => {
|
|
|
1035
1046
|
const b = parseInt(hex.substring(4, 6), 16);
|
|
1036
1047
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
1037
1048
|
};
|
|
1038
|
-
const uiThemeText = (dom, textStyle) => {
|
|
1049
|
+
const uiThemeText = (dom, textStyle, distance) => {
|
|
1039
1050
|
dom.style.color = textStyle.textColor;
|
|
1040
1051
|
dom.style.fontWeight = fontWeight[textStyle.textWeight];
|
|
1041
1052
|
dom.style.fontSize = `${textStyle.fontSize}px`;
|
|
1053
|
+
// Position parent element at the bottom by default
|
|
1054
|
+
if (dom.parentElement) {
|
|
1055
|
+
const parent = dom.parentElement;
|
|
1056
|
+
parent.style.position = 'absolute';
|
|
1057
|
+
parent.style.display = 'block';
|
|
1058
|
+
// Adjust based on direction if provided
|
|
1059
|
+
if (textStyle.direction === 'top') {
|
|
1060
|
+
parent.style.top = distance || '10vh';
|
|
1061
|
+
parent.style.bottom = 'unset';
|
|
1062
|
+
} else if (textStyle.direction === 'bottom') {
|
|
1063
|
+
parent.style.top = 'unset';
|
|
1064
|
+
parent.style.bottom = distance || '10vh';
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1042
1067
|
};
|
|
1043
|
-
const uiThemeHint = (dom, hintStyle) => {
|
|
1068
|
+
const uiThemeHint = (dom, hintStyle, distance) => {
|
|
1044
1069
|
dom.style.borderRadius = `${hintStyle.cornerRadius}px`;
|
|
1045
1070
|
dom.style.backgroundColor = hintStyle.backgroundColor;
|
|
1046
1071
|
dom.style.opacity = hintStyle.opacity;
|
|
1047
1072
|
dom.style.color = hintStyle.textColor;
|
|
1048
1073
|
dom.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1049
1074
|
dom.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1075
|
+
// Position parent element at the top by default
|
|
1076
|
+
if (dom.parentElement) {
|
|
1077
|
+
const parent = dom.parentElement;
|
|
1078
|
+
parent.style.display = 'block';
|
|
1079
|
+
parent.style.position = 'absolute';
|
|
1080
|
+
// Adjust based on direction if provided
|
|
1081
|
+
if (hintStyle.direction === 'top') {
|
|
1082
|
+
parent.style.top = distance || '10vh';
|
|
1083
|
+
parent.style.bottom = 'unset';
|
|
1084
|
+
} else {
|
|
1085
|
+
parent.style.top = 'unset';
|
|
1086
|
+
parent.style.bottom = distance || '10vh';
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
const uiThemeDirection = (panel, hintStyle) => {
|
|
1091
|
+
// Apply background styles to the panel (directionTextPanel)
|
|
1092
|
+
panel.style.borderRadius = `${hintStyle.cornerRadius || 20}px`;
|
|
1093
|
+
panel.style.backgroundColor = hintStyle.backgroundColor;
|
|
1094
|
+
panel.style.opacity = hintStyle.backgroundOpacity;
|
|
1095
|
+
panel.style.display = 'none';
|
|
1096
|
+
panel.style.flexDirection = 'row';
|
|
1097
|
+
panel.style.alignItems = 'center';
|
|
1098
|
+
panel.style.justifyContent = 'center';
|
|
1099
|
+
panel.style.gap = '12px';
|
|
1100
|
+
panel.style.padding = '16px 24px';
|
|
1101
|
+
panel.style.boxSizing = 'border-box';
|
|
1102
|
+
panel.style.minWidth = hintStyle.width;
|
|
1103
|
+
panel.style.width = hintStyle.width;
|
|
1104
|
+
panel.style.height = `${hintStyle.height || 'auto'}`;
|
|
1105
|
+
// Style the text child
|
|
1106
|
+
const directionText = panel.querySelector('.status-text');
|
|
1107
|
+
if (directionText) {
|
|
1108
|
+
directionText.style.color = hintStyle.textColor;
|
|
1109
|
+
directionText.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1110
|
+
directionText.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1111
|
+
directionText.style.whiteSpace = 'nowrap';
|
|
1112
|
+
directionText.style.display = 'inline-block';
|
|
1113
|
+
directionText.style.verticalAlign = 'middle';
|
|
1114
|
+
}
|
|
1115
|
+
// Style the icon child
|
|
1116
|
+
const directionIcon = panel.querySelector('.direction-icon');
|
|
1117
|
+
if (directionIcon) {
|
|
1118
|
+
directionIcon.style.display = 'flex';
|
|
1119
|
+
directionIcon.style.alignItems = 'center';
|
|
1120
|
+
directionIcon.style.justifyContent = 'center';
|
|
1121
|
+
directionIcon.style.flexShrink = '0';
|
|
1122
|
+
directionIcon.style.width = '72px';
|
|
1123
|
+
directionIcon.style.height = '72px';
|
|
1124
|
+
}
|
|
1050
1125
|
};
|
|
1051
1126
|
const uiThemeButton = (dom, buttonStyle, disabled) => {
|
|
1052
1127
|
dom.style.opacity = buttonStyle.backgroundOpacity;
|
|
@@ -1350,13 +1425,11 @@ const videoConstraintsFactory = (isPC, facingMode) => {
|
|
|
1350
1425
|
video: {
|
|
1351
1426
|
width: {
|
|
1352
1427
|
min: 1280,
|
|
1353
|
-
ideal: 1920
|
|
1354
|
-
max: 1920
|
|
1428
|
+
ideal: 1920
|
|
1355
1429
|
},
|
|
1356
1430
|
height: {
|
|
1357
1431
|
min: 720,
|
|
1358
|
-
ideal: 1080
|
|
1359
|
-
max: 1080
|
|
1432
|
+
ideal: 1080
|
|
1360
1433
|
},
|
|
1361
1434
|
facingMode
|
|
1362
1435
|
}
|
|
@@ -1431,23 +1504,36 @@ function switchCamera(deviceId, video) {
|
|
|
1431
1504
|
if (stream) {
|
|
1432
1505
|
stream.getTracks().forEach(track => track.stop());
|
|
1433
1506
|
}
|
|
1434
|
-
|
|
1507
|
+
// 第一階段:使用基本約束獲取流,確保相機能工作
|
|
1508
|
+
const basicConstraints = {
|
|
1435
1509
|
video: {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
focusMode: 'auto',
|
|
1439
|
-
deviceId: deviceId
|
|
1510
|
+
deviceId: deviceId,
|
|
1511
|
+
focusMode: 'auto'
|
|
1440
1512
|
}
|
|
1441
1513
|
};
|
|
1442
1514
|
const constraint = localStorage.getItem('camera_constraint');
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1515
|
+
stream = yield navigator.mediaDevices.getUserMedia(basicConstraints);
|
|
1516
|
+
// 第二階段:如果沒有設定跳過約束,嘗試使用 applyConstraints 提升解析度
|
|
1517
|
+
if (!constraint && stream) {
|
|
1518
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
1519
|
+
if (videoTrack && videoTrack.applyConstraints) {
|
|
1520
|
+
try {
|
|
1521
|
+
// 嘗試應用更高解析度(使用 ideal 而非 min/max)
|
|
1522
|
+
yield videoTrack.applyConstraints({
|
|
1523
|
+
width: {
|
|
1524
|
+
ideal: 1920,
|
|
1525
|
+
max: 3840
|
|
1526
|
+
},
|
|
1527
|
+
height: {
|
|
1528
|
+
ideal: 1080,
|
|
1529
|
+
max: 2160
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
} catch (error) {
|
|
1533
|
+
// 失敗時保持原有流,不會中斷相機
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1449
1536
|
}
|
|
1450
|
-
stream = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
1451
1537
|
// try {
|
|
1452
1538
|
// stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
1453
1539
|
// console.log("獲取媒體流成功:", stream);
|
|
@@ -1455,19 +1541,16 @@ function switchCamera(deviceId, video) {
|
|
|
1455
1541
|
// console.error("獲取媒體流失敗:", error);
|
|
1456
1542
|
// }
|
|
1457
1543
|
if (stream.getVideoTracks().length === 0) {
|
|
1458
|
-
console.error('沒有 video track');
|
|
1459
1544
|
throw new Error('沒有 video track');
|
|
1460
1545
|
}
|
|
1461
1546
|
try {
|
|
1462
1547
|
video.srcObject = stream;
|
|
1463
1548
|
} catch (error) {
|
|
1464
|
-
// console.error("設置視訊流失敗:", error);
|
|
1465
1549
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1466
1550
|
}
|
|
1467
1551
|
try {
|
|
1468
1552
|
yield video.play();
|
|
1469
1553
|
} catch (error) {
|
|
1470
|
-
// console.error("播放視訊失敗:", error);
|
|
1471
1554
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1472
1555
|
}
|
|
1473
1556
|
// console.log('stream', stream.getVideoTracks()[0].getSettings());
|
|
@@ -3082,7 +3165,24 @@ const themeConfigDefault = {
|
|
|
3082
3165
|
// Figma標示dark_title 1
|
|
3083
3166
|
textColor: '#ffffff',
|
|
3084
3167
|
textWeight: 'medium',
|
|
3085
|
-
fontSize: 20
|
|
3168
|
+
fontSize: 20,
|
|
3169
|
+
direction: 'bottom' //文字方向 bottom / top / center,
|
|
3170
|
+
},
|
|
3171
|
+
|
|
3172
|
+
fraudScanHintText: {
|
|
3173
|
+
// D.F.SC.2
|
|
3174
|
+
backgroundColor: '#000000',
|
|
3175
|
+
backgroundOpacity: 0.7,
|
|
3176
|
+
cornerRadius: 28,
|
|
3177
|
+
width: '153px',
|
|
3178
|
+
height: '56px',
|
|
3179
|
+
textColor: '#FFFFFF',
|
|
3180
|
+
textWeight: 'medium',
|
|
3181
|
+
fontSize: 18,
|
|
3182
|
+
leftText: '向左翻轉',
|
|
3183
|
+
rightText: '向右翻轉',
|
|
3184
|
+
upText: '向上翻轉',
|
|
3185
|
+
downText: '向下翻轉'
|
|
3086
3186
|
},
|
|
3087
3187
|
titleTwoDarkMode: {
|
|
3088
3188
|
// G.T.D.2
|
|
@@ -3141,8 +3241,8 @@ const themeConfigDefault = {
|
|
|
3141
3241
|
};
|
|
3142
3242
|
|
|
3143
3243
|
var name = "authme/sdk";
|
|
3144
|
-
var version$1 = "2.8.
|
|
3145
|
-
var date = "2025-
|
|
3244
|
+
var version$1 = "2.8.26";
|
|
3245
|
+
var date = "2025-09-30T03:00:07+0000";
|
|
3146
3246
|
var packageInfo = {
|
|
3147
3247
|
name: name,
|
|
3148
3248
|
version: version$1,
|
|
@@ -3155,4 +3255,4 @@ const version = packageInfo.version;
|
|
|
3155
3255
|
(_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
|
|
3156
3256
|
window[Symbol.for('authme-sdk')][packageInfo.name] = version;
|
|
3157
3257
|
|
|
3158
|
-
export { AuthmeError, DEVICE_TYPE, ErrorCode, Icon, RGBToLottieColor, RUN_FUNCTION_NAME, STORAGE_KEY, Storage, TIME_UNIT, UintArrayToBlob, asyncOnLineShowErrorMessage, asyncShowErrorMessage, asyncShowPopup, backgroundRequest, checkOnlineStatus, clearCanvas, colorStringToRGB, colorToRGB, combineResult, cropByRatio, dataURItoBlob, debugLog, debugTools, decodeToken, dropMenu, fontWeight, getCanvasSize, getCssVariable, getDeviceInfo, getImageData, getSystemInfo, hexToRGB, hideElement, hideErrorMessage, hidePopup, isIphone14proOrProMax, isMobile, isMobileOrTablet, osVersion, requestCamera, resize, retryPromiseWithCondition, showElement, showErrorMessage, showErrorMessageEventName, showPopup, splitResult, startLoadingSDK, startSpinner, stopLoadingSDK, stopSpinner, switchCamera, themeConfigDefault, uiThemeButton, uiThemeHint, uiThemeSmallButton, uiThemeText, uploadModal, useState, verificationErrorMessages, version, videoConstraintsFactory, waitTime };
|
|
3258
|
+
export { AuthmeError, DEVICE_TYPE, ErrorCode, Icon, RGBToLottieColor, RUN_FUNCTION_NAME, STORAGE_KEY, Storage, TIME_UNIT, UintArrayToBlob, asyncOnLineShowErrorMessage, asyncShowErrorMessage, asyncShowPopup, backgroundRequest, checkOnlineStatus, clearCanvas, colorStringToRGB, colorToRGB, combineResult, cropByRatio, dataURItoBlob, debugLog, debugTools, decodeToken, dropMenu, fontWeight, getCanvasSize, getCssVariable, getDeviceInfo, getImageData, getSystemInfo, hexToRGB, hideElement, hideErrorMessage, hidePopup, isIphone14proOrProMax, isMobile, isMobileOrTablet, osVersion, requestCamera, resize, retryPromiseWithCondition, showElement, showErrorMessage, showErrorMessageEventName, showPopup, splitResult, startLoadingSDK, startSpinner, stopLoadingSDK, stopSpinner, switchCamera, themeConfigDefault, uiThemeButton, uiThemeDirection, uiThemeHint, uiThemeSmallButton, uiThemeText, uploadModal, useState, verificationErrorMessages, version, videoConstraintsFactory, waitTime };
|
package/package.json
CHANGED
package/src/ui/camera.d.ts
CHANGED
|
@@ -19,12 +19,10 @@ export declare const videoConstraintsFactory: (isPC: boolean, facingMode: 'user'
|
|
|
19
19
|
width: {
|
|
20
20
|
min: number;
|
|
21
21
|
ideal: number;
|
|
22
|
-
max: number;
|
|
23
22
|
};
|
|
24
23
|
height: {
|
|
25
24
|
min: number;
|
|
26
25
|
ideal: number;
|
|
27
|
-
max: number;
|
|
28
26
|
};
|
|
29
27
|
facingMode: "user" | "environment";
|
|
30
28
|
};
|
|
@@ -33,12 +31,10 @@ export declare const videoConstraintsFactory: (isPC: boolean, facingMode: 'user'
|
|
|
33
31
|
width: {
|
|
34
32
|
ideal: number;
|
|
35
33
|
min?: undefined;
|
|
36
|
-
max?: undefined;
|
|
37
34
|
};
|
|
38
35
|
height: {
|
|
39
36
|
ideal: number;
|
|
40
37
|
min?: undefined;
|
|
41
|
-
max?: undefined;
|
|
42
38
|
};
|
|
43
39
|
facingMode: "user" | "environment";
|
|
44
40
|
};
|
package/src/ui/uiThemeStyle.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const fontWeight: any;
|
|
2
|
-
export declare const uiThemeText: (dom: any, textStyle: any) => void;
|
|
3
|
-
export declare const uiThemeHint: (dom: any, hintStyle: any) => void;
|
|
2
|
+
export declare const uiThemeText: (dom: any, textStyle: any, distance?: string) => void;
|
|
3
|
+
export declare const uiThemeHint: (dom: any, hintStyle: any, distance?: string) => void;
|
|
4
|
+
export declare const uiThemeDirection: (panel: any, hintStyle: any) => void;
|
|
4
5
|
export declare const uiThemeButton: (dom: any, buttonStyle: any, disabled?: boolean) => void;
|
|
5
6
|
export declare const uiThemeSmallButton: (dom: any, buttonStyle: any) => void;
|