@authme/util 2.8.25 → 2.8.27
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 +123 -32
- package/index.js +123 -33
- 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
|
@@ -999,12 +999,14 @@ function getCanvasSize(video) {
|
|
|
999
999
|
result.startX = 0;
|
|
1000
1000
|
result.startY = Math.floor((videoHeight - result.height) / 2);
|
|
1001
1001
|
}
|
|
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
|
-
//
|
|
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
|
+
// 暫時降低解析度測試
|
|
1008
|
+
const maxDimension = 1920; // 限制最大尺寸
|
|
1009
|
+
const resizeRatio = Math.min(1, maxDimension / Math.max(result.width, result.height));
|
|
1008
1010
|
result.canvasWidth = Math.floor(result.width * resizeRatio);
|
|
1009
1011
|
result.canvasHeight = Math.floor(result.height * resizeRatio);
|
|
1010
1012
|
return result;
|
|
@@ -1045,18 +1047,82 @@ const hexToRgba = (hex, alpha = 1) => {
|
|
|
1045
1047
|
const b = parseInt(hex.substring(4, 6), 16);
|
|
1046
1048
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
1047
1049
|
};
|
|
1048
|
-
const uiThemeText = (dom, textStyle) => {
|
|
1050
|
+
const uiThemeText = (dom, textStyle, distance) => {
|
|
1049
1051
|
dom.style.color = textStyle.textColor;
|
|
1050
1052
|
dom.style.fontWeight = fontWeight[textStyle.textWeight];
|
|
1051
1053
|
dom.style.fontSize = `${textStyle.fontSize}px`;
|
|
1054
|
+
// Position parent element at the bottom by default
|
|
1055
|
+
if (dom.parentElement) {
|
|
1056
|
+
const parent = dom.parentElement;
|
|
1057
|
+
parent.style.position = 'absolute';
|
|
1058
|
+
parent.style.display = 'block';
|
|
1059
|
+
// Adjust based on direction if provided
|
|
1060
|
+
if (textStyle.direction === 'top') {
|
|
1061
|
+
parent.style.top = distance || '7vh';
|
|
1062
|
+
parent.style.bottom = 'unset';
|
|
1063
|
+
} else if (textStyle.direction === 'bottom') {
|
|
1064
|
+
parent.style.top = 'unset';
|
|
1065
|
+
parent.style.bottom = distance || '7vh';
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1052
1068
|
};
|
|
1053
|
-
const uiThemeHint = (dom, hintStyle) => {
|
|
1069
|
+
const uiThemeHint = (dom, hintStyle, distance) => {
|
|
1054
1070
|
dom.style.borderRadius = `${hintStyle.cornerRadius}px`;
|
|
1055
1071
|
dom.style.backgroundColor = hintStyle.backgroundColor;
|
|
1056
1072
|
dom.style.opacity = hintStyle.opacity;
|
|
1057
1073
|
dom.style.color = hintStyle.textColor;
|
|
1058
1074
|
dom.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1059
1075
|
dom.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1076
|
+
// Position parent element at the top by default
|
|
1077
|
+
if (dom.parentElement) {
|
|
1078
|
+
const parent = dom.parentElement;
|
|
1079
|
+
parent.style.display = 'block';
|
|
1080
|
+
parent.style.position = 'absolute';
|
|
1081
|
+
// Adjust based on direction if provided
|
|
1082
|
+
if (hintStyle.direction === 'top') {
|
|
1083
|
+
parent.style.top = distance || '7vh';
|
|
1084
|
+
parent.style.bottom = 'unset';
|
|
1085
|
+
} else {
|
|
1086
|
+
parent.style.top = 'unset';
|
|
1087
|
+
parent.style.bottom = distance || '7vh';
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
const uiThemeDirection = (panel, hintStyle) => {
|
|
1092
|
+
// Apply background styles to the panel (directionTextPanel)
|
|
1093
|
+
panel.style.borderRadius = `${hintStyle.cornerRadius || 20}px`;
|
|
1094
|
+
panel.style.backgroundColor = hintStyle.backgroundColor;
|
|
1095
|
+
panel.style.opacity = hintStyle.backgroundOpacity;
|
|
1096
|
+
panel.style.display = 'none';
|
|
1097
|
+
panel.style.flexDirection = 'row';
|
|
1098
|
+
panel.style.alignItems = 'center';
|
|
1099
|
+
panel.style.justifyContent = 'center';
|
|
1100
|
+
panel.style.gap = '12px';
|
|
1101
|
+
panel.style.padding = '16px 24px';
|
|
1102
|
+
panel.style.boxSizing = 'border-box';
|
|
1103
|
+
panel.style.minWidth = hintStyle.width;
|
|
1104
|
+
panel.style.width = hintStyle.width;
|
|
1105
|
+
panel.style.height = `${hintStyle.height || 'auto'}`;
|
|
1106
|
+
// Style the text child
|
|
1107
|
+
const directionText = panel.querySelector('.status-text');
|
|
1108
|
+
if (directionText) {
|
|
1109
|
+
directionText.style.color = hintStyle.textColor;
|
|
1110
|
+
directionText.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1111
|
+
directionText.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1112
|
+
directionText.style.whiteSpace = 'nowrap';
|
|
1113
|
+
directionText.style.display = 'inline-block';
|
|
1114
|
+
directionText.style.verticalAlign = 'middle';
|
|
1115
|
+
}
|
|
1116
|
+
// Style the icon child
|
|
1117
|
+
const directionIcon = panel.querySelector('.direction-icon');
|
|
1118
|
+
if (directionIcon) {
|
|
1119
|
+
directionIcon.style.display = 'flex';
|
|
1120
|
+
directionIcon.style.alignItems = 'center';
|
|
1121
|
+
directionIcon.style.justifyContent = 'center';
|
|
1122
|
+
directionIcon.style.flexShrink = '0';
|
|
1123
|
+
directionIcon.style.width = '72px';
|
|
1124
|
+
directionIcon.style.height = '72px';
|
|
1125
|
+
}
|
|
1060
1126
|
};
|
|
1061
1127
|
const uiThemeButton = (dom, buttonStyle, disabled) => {
|
|
1062
1128
|
dom.style.opacity = buttonStyle.backgroundOpacity;
|
|
@@ -1077,8 +1143,7 @@ const uiThemeButton = (dom, buttonStyle, disabled) => {
|
|
|
1077
1143
|
dom.style.borderStyle = 'solid';
|
|
1078
1144
|
// dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
|
|
1079
1145
|
dom.style.height = `48px`;
|
|
1080
|
-
dom.style.width = `
|
|
1081
|
-
dom.style.maxWidth = `327px`;
|
|
1146
|
+
dom.style.width = `774px`;
|
|
1082
1147
|
};
|
|
1083
1148
|
const uiThemeSmallButton = (dom, buttonStyle) => {
|
|
1084
1149
|
dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
|
|
@@ -1360,13 +1425,11 @@ const videoConstraintsFactory = (isPC, facingMode) => {
|
|
|
1360
1425
|
video: {
|
|
1361
1426
|
width: {
|
|
1362
1427
|
min: 1280,
|
|
1363
|
-
ideal: 1920
|
|
1364
|
-
max: 1920
|
|
1428
|
+
ideal: 1920
|
|
1365
1429
|
},
|
|
1366
1430
|
height: {
|
|
1367
1431
|
min: 720,
|
|
1368
|
-
ideal: 1080
|
|
1369
|
-
max: 1080
|
|
1432
|
+
ideal: 1080
|
|
1370
1433
|
},
|
|
1371
1434
|
facingMode
|
|
1372
1435
|
}
|
|
@@ -1441,23 +1504,36 @@ function switchCamera(deviceId, video) {
|
|
|
1441
1504
|
if (stream) {
|
|
1442
1505
|
stream.getTracks().forEach(track => track.stop());
|
|
1443
1506
|
}
|
|
1444
|
-
|
|
1507
|
+
// 第一階段:使用基本約束獲取流,確保相機能工作
|
|
1508
|
+
const basicConstraints = {
|
|
1445
1509
|
video: {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
focusMode: 'auto',
|
|
1449
|
-
deviceId: deviceId
|
|
1510
|
+
deviceId: deviceId,
|
|
1511
|
+
focusMode: 'auto'
|
|
1450
1512
|
}
|
|
1451
1513
|
};
|
|
1452
1514
|
const constraint = localStorage.getItem('camera_constraint');
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
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
|
+
}
|
|
1459
1536
|
}
|
|
1460
|
-
stream = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
1461
1537
|
// try {
|
|
1462
1538
|
// stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
1463
1539
|
// console.log("獲取媒體流成功:", stream);
|
|
@@ -1465,19 +1541,16 @@ function switchCamera(deviceId, video) {
|
|
|
1465
1541
|
// console.error("獲取媒體流失敗:", error);
|
|
1466
1542
|
// }
|
|
1467
1543
|
if (stream.getVideoTracks().length === 0) {
|
|
1468
|
-
console.error('沒有 video track');
|
|
1469
1544
|
throw new Error('沒有 video track');
|
|
1470
1545
|
}
|
|
1471
1546
|
try {
|
|
1472
1547
|
video.srcObject = stream;
|
|
1473
1548
|
} catch (error) {
|
|
1474
|
-
// console.error("設置視訊流失敗:", error);
|
|
1475
1549
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1476
1550
|
}
|
|
1477
1551
|
try {
|
|
1478
1552
|
yield video.play();
|
|
1479
1553
|
} catch (error) {
|
|
1480
|
-
// console.error("播放視訊失敗:", error);
|
|
1481
1554
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1482
1555
|
}
|
|
1483
1556
|
// console.log('stream', stream.getVideoTracks()[0].getSettings());
|
|
@@ -3092,7 +3165,24 @@ const themeConfigDefault = {
|
|
|
3092
3165
|
// Figma標示dark_title 1
|
|
3093
3166
|
textColor: '#ffffff',
|
|
3094
3167
|
textWeight: 'medium',
|
|
3095
|
-
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: '向下翻轉'
|
|
3096
3186
|
},
|
|
3097
3187
|
titleTwoDarkMode: {
|
|
3098
3188
|
// G.T.D.2
|
|
@@ -3151,8 +3241,8 @@ const themeConfigDefault = {
|
|
|
3151
3241
|
};
|
|
3152
3242
|
|
|
3153
3243
|
var name = "authme/sdk";
|
|
3154
|
-
var version$1 = "2.8.
|
|
3155
|
-
var date = "2025-
|
|
3244
|
+
var version$1 = "2.8.27";
|
|
3245
|
+
var date = "2025-10-02T06:50:39+0000";
|
|
3156
3246
|
var packageInfo = {
|
|
3157
3247
|
name: name,
|
|
3158
3248
|
version: version$1,
|
|
@@ -3213,6 +3303,7 @@ exports.stopSpinner = stopSpinner;
|
|
|
3213
3303
|
exports.switchCamera = switchCamera;
|
|
3214
3304
|
exports.themeConfigDefault = themeConfigDefault;
|
|
3215
3305
|
exports.uiThemeButton = uiThemeButton;
|
|
3306
|
+
exports.uiThemeDirection = uiThemeDirection;
|
|
3216
3307
|
exports.uiThemeHint = uiThemeHint;
|
|
3217
3308
|
exports.uiThemeSmallButton = uiThemeSmallButton;
|
|
3218
3309
|
exports.uiThemeText = uiThemeText;
|
package/index.js
CHANGED
|
@@ -989,12 +989,14 @@ function getCanvasSize(video) {
|
|
|
989
989
|
result.startX = 0;
|
|
990
990
|
result.startY = Math.floor((videoHeight - result.height) / 2);
|
|
991
991
|
}
|
|
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
|
-
//
|
|
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
|
+
// 暫時降低解析度測試
|
|
998
|
+
const maxDimension = 1920; // 限制最大尺寸
|
|
999
|
+
const resizeRatio = Math.min(1, maxDimension / Math.max(result.width, result.height));
|
|
998
1000
|
result.canvasWidth = Math.floor(result.width * resizeRatio);
|
|
999
1001
|
result.canvasHeight = Math.floor(result.height * resizeRatio);
|
|
1000
1002
|
return result;
|
|
@@ -1035,18 +1037,82 @@ const hexToRgba = (hex, alpha = 1) => {
|
|
|
1035
1037
|
const b = parseInt(hex.substring(4, 6), 16);
|
|
1036
1038
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
1037
1039
|
};
|
|
1038
|
-
const uiThemeText = (dom, textStyle) => {
|
|
1040
|
+
const uiThemeText = (dom, textStyle, distance) => {
|
|
1039
1041
|
dom.style.color = textStyle.textColor;
|
|
1040
1042
|
dom.style.fontWeight = fontWeight[textStyle.textWeight];
|
|
1041
1043
|
dom.style.fontSize = `${textStyle.fontSize}px`;
|
|
1044
|
+
// Position parent element at the bottom by default
|
|
1045
|
+
if (dom.parentElement) {
|
|
1046
|
+
const parent = dom.parentElement;
|
|
1047
|
+
parent.style.position = 'absolute';
|
|
1048
|
+
parent.style.display = 'block';
|
|
1049
|
+
// Adjust based on direction if provided
|
|
1050
|
+
if (textStyle.direction === 'top') {
|
|
1051
|
+
parent.style.top = distance || '7vh';
|
|
1052
|
+
parent.style.bottom = 'unset';
|
|
1053
|
+
} else if (textStyle.direction === 'bottom') {
|
|
1054
|
+
parent.style.top = 'unset';
|
|
1055
|
+
parent.style.bottom = distance || '7vh';
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1042
1058
|
};
|
|
1043
|
-
const uiThemeHint = (dom, hintStyle) => {
|
|
1059
|
+
const uiThemeHint = (dom, hintStyle, distance) => {
|
|
1044
1060
|
dom.style.borderRadius = `${hintStyle.cornerRadius}px`;
|
|
1045
1061
|
dom.style.backgroundColor = hintStyle.backgroundColor;
|
|
1046
1062
|
dom.style.opacity = hintStyle.opacity;
|
|
1047
1063
|
dom.style.color = hintStyle.textColor;
|
|
1048
1064
|
dom.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1049
1065
|
dom.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1066
|
+
// Position parent element at the top by default
|
|
1067
|
+
if (dom.parentElement) {
|
|
1068
|
+
const parent = dom.parentElement;
|
|
1069
|
+
parent.style.display = 'block';
|
|
1070
|
+
parent.style.position = 'absolute';
|
|
1071
|
+
// Adjust based on direction if provided
|
|
1072
|
+
if (hintStyle.direction === 'top') {
|
|
1073
|
+
parent.style.top = distance || '7vh';
|
|
1074
|
+
parent.style.bottom = 'unset';
|
|
1075
|
+
} else {
|
|
1076
|
+
parent.style.top = 'unset';
|
|
1077
|
+
parent.style.bottom = distance || '7vh';
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
const uiThemeDirection = (panel, hintStyle) => {
|
|
1082
|
+
// Apply background styles to the panel (directionTextPanel)
|
|
1083
|
+
panel.style.borderRadius = `${hintStyle.cornerRadius || 20}px`;
|
|
1084
|
+
panel.style.backgroundColor = hintStyle.backgroundColor;
|
|
1085
|
+
panel.style.opacity = hintStyle.backgroundOpacity;
|
|
1086
|
+
panel.style.display = 'none';
|
|
1087
|
+
panel.style.flexDirection = 'row';
|
|
1088
|
+
panel.style.alignItems = 'center';
|
|
1089
|
+
panel.style.justifyContent = 'center';
|
|
1090
|
+
panel.style.gap = '12px';
|
|
1091
|
+
panel.style.padding = '16px 24px';
|
|
1092
|
+
panel.style.boxSizing = 'border-box';
|
|
1093
|
+
panel.style.minWidth = hintStyle.width;
|
|
1094
|
+
panel.style.width = hintStyle.width;
|
|
1095
|
+
panel.style.height = `${hintStyle.height || 'auto'}`;
|
|
1096
|
+
// Style the text child
|
|
1097
|
+
const directionText = panel.querySelector('.status-text');
|
|
1098
|
+
if (directionText) {
|
|
1099
|
+
directionText.style.color = hintStyle.textColor;
|
|
1100
|
+
directionText.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1101
|
+
directionText.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1102
|
+
directionText.style.whiteSpace = 'nowrap';
|
|
1103
|
+
directionText.style.display = 'inline-block';
|
|
1104
|
+
directionText.style.verticalAlign = 'middle';
|
|
1105
|
+
}
|
|
1106
|
+
// Style the icon child
|
|
1107
|
+
const directionIcon = panel.querySelector('.direction-icon');
|
|
1108
|
+
if (directionIcon) {
|
|
1109
|
+
directionIcon.style.display = 'flex';
|
|
1110
|
+
directionIcon.style.alignItems = 'center';
|
|
1111
|
+
directionIcon.style.justifyContent = 'center';
|
|
1112
|
+
directionIcon.style.flexShrink = '0';
|
|
1113
|
+
directionIcon.style.width = '72px';
|
|
1114
|
+
directionIcon.style.height = '72px';
|
|
1115
|
+
}
|
|
1050
1116
|
};
|
|
1051
1117
|
const uiThemeButton = (dom, buttonStyle, disabled) => {
|
|
1052
1118
|
dom.style.opacity = buttonStyle.backgroundOpacity;
|
|
@@ -1067,8 +1133,7 @@ const uiThemeButton = (dom, buttonStyle, disabled) => {
|
|
|
1067
1133
|
dom.style.borderStyle = 'solid';
|
|
1068
1134
|
// dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
|
|
1069
1135
|
dom.style.height = `48px`;
|
|
1070
|
-
dom.style.width = `
|
|
1071
|
-
dom.style.maxWidth = `327px`;
|
|
1136
|
+
dom.style.width = `774px`;
|
|
1072
1137
|
};
|
|
1073
1138
|
const uiThemeSmallButton = (dom, buttonStyle) => {
|
|
1074
1139
|
dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
|
|
@@ -1350,13 +1415,11 @@ const videoConstraintsFactory = (isPC, facingMode) => {
|
|
|
1350
1415
|
video: {
|
|
1351
1416
|
width: {
|
|
1352
1417
|
min: 1280,
|
|
1353
|
-
ideal: 1920
|
|
1354
|
-
max: 1920
|
|
1418
|
+
ideal: 1920
|
|
1355
1419
|
},
|
|
1356
1420
|
height: {
|
|
1357
1421
|
min: 720,
|
|
1358
|
-
ideal: 1080
|
|
1359
|
-
max: 1080
|
|
1422
|
+
ideal: 1080
|
|
1360
1423
|
},
|
|
1361
1424
|
facingMode
|
|
1362
1425
|
}
|
|
@@ -1431,23 +1494,36 @@ function switchCamera(deviceId, video) {
|
|
|
1431
1494
|
if (stream) {
|
|
1432
1495
|
stream.getTracks().forEach(track => track.stop());
|
|
1433
1496
|
}
|
|
1434
|
-
|
|
1497
|
+
// 第一階段:使用基本約束獲取流,確保相機能工作
|
|
1498
|
+
const basicConstraints = {
|
|
1435
1499
|
video: {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
focusMode: 'auto',
|
|
1439
|
-
deviceId: deviceId
|
|
1500
|
+
deviceId: deviceId,
|
|
1501
|
+
focusMode: 'auto'
|
|
1440
1502
|
}
|
|
1441
1503
|
};
|
|
1442
1504
|
const constraint = localStorage.getItem('camera_constraint');
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1505
|
+
stream = yield navigator.mediaDevices.getUserMedia(basicConstraints);
|
|
1506
|
+
// 第二階段:如果沒有設定跳過約束,嘗試使用 applyConstraints 提升解析度
|
|
1507
|
+
if (!constraint && stream) {
|
|
1508
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
1509
|
+
if (videoTrack && videoTrack.applyConstraints) {
|
|
1510
|
+
try {
|
|
1511
|
+
// 嘗試應用更高解析度(使用 ideal 而非 min/max)
|
|
1512
|
+
yield videoTrack.applyConstraints({
|
|
1513
|
+
width: {
|
|
1514
|
+
ideal: 1920,
|
|
1515
|
+
max: 3840
|
|
1516
|
+
},
|
|
1517
|
+
height: {
|
|
1518
|
+
ideal: 1080,
|
|
1519
|
+
max: 2160
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1522
|
+
} catch (error) {
|
|
1523
|
+
// 失敗時保持原有流,不會中斷相機
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1449
1526
|
}
|
|
1450
|
-
stream = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
1451
1527
|
// try {
|
|
1452
1528
|
// stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
1453
1529
|
// console.log("獲取媒體流成功:", stream);
|
|
@@ -1455,19 +1531,16 @@ function switchCamera(deviceId, video) {
|
|
|
1455
1531
|
// console.error("獲取媒體流失敗:", error);
|
|
1456
1532
|
// }
|
|
1457
1533
|
if (stream.getVideoTracks().length === 0) {
|
|
1458
|
-
console.error('沒有 video track');
|
|
1459
1534
|
throw new Error('沒有 video track');
|
|
1460
1535
|
}
|
|
1461
1536
|
try {
|
|
1462
1537
|
video.srcObject = stream;
|
|
1463
1538
|
} catch (error) {
|
|
1464
|
-
// console.error("設置視訊流失敗:", error);
|
|
1465
1539
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1466
1540
|
}
|
|
1467
1541
|
try {
|
|
1468
1542
|
yield video.play();
|
|
1469
1543
|
} catch (error) {
|
|
1470
|
-
// console.error("播放視訊失敗:", error);
|
|
1471
1544
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1472
1545
|
}
|
|
1473
1546
|
// console.log('stream', stream.getVideoTracks()[0].getSettings());
|
|
@@ -3082,7 +3155,24 @@ const themeConfigDefault = {
|
|
|
3082
3155
|
// Figma標示dark_title 1
|
|
3083
3156
|
textColor: '#ffffff',
|
|
3084
3157
|
textWeight: 'medium',
|
|
3085
|
-
fontSize: 20
|
|
3158
|
+
fontSize: 20,
|
|
3159
|
+
direction: 'bottom' //文字方向 bottom / top / center,
|
|
3160
|
+
},
|
|
3161
|
+
|
|
3162
|
+
fraudScanHintText: {
|
|
3163
|
+
// D.F.SC.2
|
|
3164
|
+
backgroundColor: '#000000',
|
|
3165
|
+
backgroundOpacity: 0.7,
|
|
3166
|
+
cornerRadius: 28,
|
|
3167
|
+
width: '153px',
|
|
3168
|
+
height: '56px',
|
|
3169
|
+
textColor: '#FFFFFF',
|
|
3170
|
+
textWeight: 'medium',
|
|
3171
|
+
fontSize: 18,
|
|
3172
|
+
leftText: '向左翻轉',
|
|
3173
|
+
rightText: '向右翻轉',
|
|
3174
|
+
upText: '向上翻轉',
|
|
3175
|
+
downText: '向下翻轉'
|
|
3086
3176
|
},
|
|
3087
3177
|
titleTwoDarkMode: {
|
|
3088
3178
|
// G.T.D.2
|
|
@@ -3141,8 +3231,8 @@ const themeConfigDefault = {
|
|
|
3141
3231
|
};
|
|
3142
3232
|
|
|
3143
3233
|
var name = "authme/sdk";
|
|
3144
|
-
var version$1 = "2.8.
|
|
3145
|
-
var date = "2025-
|
|
3234
|
+
var version$1 = "2.8.27";
|
|
3235
|
+
var date = "2025-10-02T06:50:39+0000";
|
|
3146
3236
|
var packageInfo = {
|
|
3147
3237
|
name: name,
|
|
3148
3238
|
version: version$1,
|
|
@@ -3155,4 +3245,4 @@ const version = packageInfo.version;
|
|
|
3155
3245
|
(_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
|
|
3156
3246
|
window[Symbol.for('authme-sdk')][packageInfo.name] = version;
|
|
3157
3247
|
|
|
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 };
|
|
3248
|
+
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;
|