@authme/util 2.8.3 → 2.8.5
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 +89 -9
- package/index.js +89 -10
- package/package.json +1 -1
- package/src/lib/enum/deviceType.enum.d.ts +5 -0
- package/src/lib/enum/index.d.ts +1 -0
- package/src/ui/dropMenu.d.ts +1 -0
- package/src/ui/index.d.ts +1 -0
- package/src/ui/uiThemeStyle.d.ts +1 -1
package/index.cjs
CHANGED
|
@@ -835,7 +835,9 @@ function debugTools() {
|
|
|
835
835
|
const debugImage = yield getDebugImageData(data);
|
|
836
836
|
// 創建一個虛擬的 canvas
|
|
837
837
|
const canvas = document.createElement('canvas');
|
|
838
|
-
const ctx = canvas.getContext('2d'
|
|
838
|
+
const ctx = canvas.getContext('2d', {
|
|
839
|
+
willReadFrequently: true
|
|
840
|
+
});
|
|
839
841
|
// 設置 canvas 的尺寸
|
|
840
842
|
canvas.width = width;
|
|
841
843
|
canvas.height = height;
|
|
@@ -899,6 +901,13 @@ exports.TIME_UNIT = void 0;
|
|
|
899
901
|
TIME_UNIT[TIME_UNIT["HOUR"] = 3600000] = "HOUR";
|
|
900
902
|
})(exports.TIME_UNIT || (exports.TIME_UNIT = {}));
|
|
901
903
|
|
|
904
|
+
exports.DEVICE_TYPE = void 0;
|
|
905
|
+
(function (DEVICE_TYPE) {
|
|
906
|
+
DEVICE_TYPE["web"] = "web";
|
|
907
|
+
DEVICE_TYPE["mobile"] = "mobile";
|
|
908
|
+
DEVICE_TYPE["pad"] = "pad";
|
|
909
|
+
})(exports.DEVICE_TYPE || (exports.DEVICE_TYPE = {}));
|
|
910
|
+
|
|
902
911
|
function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType = 'jpg') {
|
|
903
912
|
canvas.width = sizeInfo.canvasWidth;
|
|
904
913
|
canvas.height = sizeInfo.canvasHeight;
|
|
@@ -916,7 +925,9 @@ function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType =
|
|
|
916
925
|
}
|
|
917
926
|
|
|
918
927
|
function clearCanvas(canvas) {
|
|
919
|
-
const ctx = canvas.getContext('2d'
|
|
928
|
+
const ctx = canvas.getContext('2d', {
|
|
929
|
+
willReadFrequently: true
|
|
930
|
+
});
|
|
920
931
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
921
932
|
}
|
|
922
933
|
|
|
@@ -1030,12 +1041,19 @@ const uiThemeHint = (dom, hintStyle) => {
|
|
|
1030
1041
|
dom.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1031
1042
|
dom.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1032
1043
|
};
|
|
1033
|
-
const uiThemeButton = (dom, buttonStyle) => {
|
|
1034
|
-
dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
|
|
1035
|
-
dom.style.backgroundColor = buttonStyle.backgroundColor;
|
|
1044
|
+
const uiThemeButton = (dom, buttonStyle, disabled) => {
|
|
1036
1045
|
dom.style.opacity = buttonStyle.backgroundOpacity;
|
|
1037
|
-
|
|
1038
|
-
|
|
1046
|
+
if (disabled) {
|
|
1047
|
+
dom.style.color = buttonStyle.disabledTextColor;
|
|
1048
|
+
dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
|
|
1049
|
+
dom.style.backgroundColor = buttonStyle.disabledBackgroundColor;
|
|
1050
|
+
dom.style.borderColor = hexToRgba(buttonStyle.disabledBorderColor, buttonStyle.borderOpacity);
|
|
1051
|
+
} else {
|
|
1052
|
+
dom.style.color = buttonStyle.textColor;
|
|
1053
|
+
dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
|
|
1054
|
+
dom.style.backgroundColor = buttonStyle.backgroundColor;
|
|
1055
|
+
dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
|
|
1056
|
+
}
|
|
1039
1057
|
dom.style.borderWidth = `${buttonStyle.borderWidth}px`;
|
|
1040
1058
|
dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
|
|
1041
1059
|
dom.style.fontSize = `${buttonStyle.fontSize}px`;
|
|
@@ -2675,6 +2693,46 @@ const uploadModal = arg => {
|
|
|
2675
2693
|
};
|
|
2676
2694
|
};
|
|
2677
2695
|
|
|
2696
|
+
const dropMenu = function dropMenu(dom, callback) {
|
|
2697
|
+
if (!dom) {
|
|
2698
|
+
console.error('dom is required');
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
const ul = dom.querySelector('ul');
|
|
2702
|
+
const ulSection = dom.querySelector('section');
|
|
2703
|
+
const list = dom.querySelectorAll('li');
|
|
2704
|
+
dom.querySelector('.drop_menu_title').addEventListener('click', function (e) {
|
|
2705
|
+
e.stopPropagation();
|
|
2706
|
+
ulSection.classList.toggle('hide');
|
|
2707
|
+
dom.querySelector('.drop_menu_title').classList.toggle('focus');
|
|
2708
|
+
});
|
|
2709
|
+
for (let i = 0; i < list.length; i++) {
|
|
2710
|
+
const element = list[i];
|
|
2711
|
+
element.addEventListener('click', function (e) {
|
|
2712
|
+
e.stopPropagation();
|
|
2713
|
+
if (ul.querySelector('.active')) {
|
|
2714
|
+
ul.querySelector('.active').classList.remove('active');
|
|
2715
|
+
}
|
|
2716
|
+
this.classList.add('active');
|
|
2717
|
+
dom.querySelector('.drop_menu_title span').innerText = this.innerText.trim();
|
|
2718
|
+
if (callback) {
|
|
2719
|
+
callback(this);
|
|
2720
|
+
}
|
|
2721
|
+
ulSection.classList.toggle('hide');
|
|
2722
|
+
dom.querySelector('.drop_menu_title').classList.toggle('focus');
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
window.addEventListener('click', function (e) {
|
|
2726
|
+
e.stopPropagation();
|
|
2727
|
+
if (!ulSection.classList.contains('hide')) {
|
|
2728
|
+
ulSection.classList.add('hide');
|
|
2729
|
+
}
|
|
2730
|
+
if (dom.querySelector('.drop_menu_title').classList.contains('focus')) {
|
|
2731
|
+
dom.querySelector('.drop_menu_title').classList.remove('focus');
|
|
2732
|
+
}
|
|
2733
|
+
});
|
|
2734
|
+
};
|
|
2735
|
+
|
|
2678
2736
|
const QUEUE_LENGTH = 10;
|
|
2679
2737
|
const requstQueue = [];
|
|
2680
2738
|
function pushRequest(request) {
|
|
@@ -2978,12 +3036,33 @@ const themeConfigDefault = {
|
|
|
2978
3036
|
textColor: '#E0E0E0',
|
|
2979
3037
|
textWeight: 'regular',
|
|
2980
3038
|
fontSize: 12
|
|
3039
|
+
},
|
|
3040
|
+
resultTitle: {
|
|
3041
|
+
// G.6
|
|
3042
|
+
// Figma標示resultPage_text_title
|
|
3043
|
+
textColor: '#25608A',
|
|
3044
|
+
textWeight: 'medium',
|
|
3045
|
+
fontSize: 22
|
|
3046
|
+
},
|
|
3047
|
+
resultBody: {
|
|
3048
|
+
// G.7
|
|
3049
|
+
// Figma標示resultPage_text_body
|
|
3050
|
+
textColor: '#757575',
|
|
3051
|
+
textWeight: 'regular',
|
|
3052
|
+
fontSize: 14
|
|
3053
|
+
},
|
|
3054
|
+
resultTime: {
|
|
3055
|
+
// G.8
|
|
3056
|
+
// Figma標示resultPage_timeText
|
|
3057
|
+
textColor: '#FF3B30',
|
|
3058
|
+
textWeight: 'medium',
|
|
3059
|
+
fontSize: 16
|
|
2981
3060
|
}
|
|
2982
3061
|
};
|
|
2983
3062
|
|
|
2984
3063
|
var name = "authme/sdk";
|
|
2985
|
-
var version$1 = "2.8.
|
|
2986
|
-
var date = "2025-03-
|
|
3064
|
+
var version$1 = "2.8.5";
|
|
3065
|
+
var date = "2025-03-17T05:56:00+0000";
|
|
2987
3066
|
var packageInfo = {
|
|
2988
3067
|
name: name,
|
|
2989
3068
|
version: version$1,
|
|
@@ -3014,6 +3093,7 @@ exports.dataURItoBlob = dataURItoBlob;
|
|
|
3014
3093
|
exports.debugLog = debugLog;
|
|
3015
3094
|
exports.debugTools = debugTools;
|
|
3016
3095
|
exports.decodeToken = decodeToken;
|
|
3096
|
+
exports.dropMenu = dropMenu;
|
|
3017
3097
|
exports.fontWeight = fontWeight;
|
|
3018
3098
|
exports.getCanvasSize = getCanvasSize;
|
|
3019
3099
|
exports.getCssVariable = getCssVariable;
|
package/index.js
CHANGED
|
@@ -825,7 +825,9 @@ function debugTools() {
|
|
|
825
825
|
const debugImage = yield getDebugImageData(data);
|
|
826
826
|
// 創建一個虛擬的 canvas
|
|
827
827
|
const canvas = document.createElement('canvas');
|
|
828
|
-
const ctx = canvas.getContext('2d'
|
|
828
|
+
const ctx = canvas.getContext('2d', {
|
|
829
|
+
willReadFrequently: true
|
|
830
|
+
});
|
|
829
831
|
// 設置 canvas 的尺寸
|
|
830
832
|
canvas.width = width;
|
|
831
833
|
canvas.height = height;
|
|
@@ -889,6 +891,13 @@ var TIME_UNIT;
|
|
|
889
891
|
TIME_UNIT[TIME_UNIT["HOUR"] = 3600000] = "HOUR";
|
|
890
892
|
})(TIME_UNIT || (TIME_UNIT = {}));
|
|
891
893
|
|
|
894
|
+
var DEVICE_TYPE;
|
|
895
|
+
(function (DEVICE_TYPE) {
|
|
896
|
+
DEVICE_TYPE["web"] = "web";
|
|
897
|
+
DEVICE_TYPE["mobile"] = "mobile";
|
|
898
|
+
DEVICE_TYPE["pad"] = "pad";
|
|
899
|
+
})(DEVICE_TYPE || (DEVICE_TYPE = {}));
|
|
900
|
+
|
|
892
901
|
function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType = 'jpg') {
|
|
893
902
|
canvas.width = sizeInfo.canvasWidth;
|
|
894
903
|
canvas.height = sizeInfo.canvasHeight;
|
|
@@ -906,7 +915,9 @@ function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType =
|
|
|
906
915
|
}
|
|
907
916
|
|
|
908
917
|
function clearCanvas(canvas) {
|
|
909
|
-
const ctx = canvas.getContext('2d'
|
|
918
|
+
const ctx = canvas.getContext('2d', {
|
|
919
|
+
willReadFrequently: true
|
|
920
|
+
});
|
|
910
921
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
911
922
|
}
|
|
912
923
|
|
|
@@ -1020,12 +1031,19 @@ const uiThemeHint = (dom, hintStyle) => {
|
|
|
1020
1031
|
dom.style.fontWeight = fontWeight[hintStyle.textWeight];
|
|
1021
1032
|
dom.style.fontSize = `${hintStyle.fontSize}px`;
|
|
1022
1033
|
};
|
|
1023
|
-
const uiThemeButton = (dom, buttonStyle) => {
|
|
1024
|
-
dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
|
|
1025
|
-
dom.style.backgroundColor = buttonStyle.backgroundColor;
|
|
1034
|
+
const uiThemeButton = (dom, buttonStyle, disabled) => {
|
|
1026
1035
|
dom.style.opacity = buttonStyle.backgroundOpacity;
|
|
1027
|
-
|
|
1028
|
-
|
|
1036
|
+
if (disabled) {
|
|
1037
|
+
dom.style.color = buttonStyle.disabledTextColor;
|
|
1038
|
+
dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
|
|
1039
|
+
dom.style.backgroundColor = buttonStyle.disabledBackgroundColor;
|
|
1040
|
+
dom.style.borderColor = hexToRgba(buttonStyle.disabledBorderColor, buttonStyle.borderOpacity);
|
|
1041
|
+
} else {
|
|
1042
|
+
dom.style.color = buttonStyle.textColor;
|
|
1043
|
+
dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
|
|
1044
|
+
dom.style.backgroundColor = buttonStyle.backgroundColor;
|
|
1045
|
+
dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
|
|
1046
|
+
}
|
|
1029
1047
|
dom.style.borderWidth = `${buttonStyle.borderWidth}px`;
|
|
1030
1048
|
dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
|
|
1031
1049
|
dom.style.fontSize = `${buttonStyle.fontSize}px`;
|
|
@@ -2665,6 +2683,46 @@ const uploadModal = arg => {
|
|
|
2665
2683
|
};
|
|
2666
2684
|
};
|
|
2667
2685
|
|
|
2686
|
+
const dropMenu = function dropMenu(dom, callback) {
|
|
2687
|
+
if (!dom) {
|
|
2688
|
+
console.error('dom is required');
|
|
2689
|
+
return;
|
|
2690
|
+
}
|
|
2691
|
+
const ul = dom.querySelector('ul');
|
|
2692
|
+
const ulSection = dom.querySelector('section');
|
|
2693
|
+
const list = dom.querySelectorAll('li');
|
|
2694
|
+
dom.querySelector('.drop_menu_title').addEventListener('click', function (e) {
|
|
2695
|
+
e.stopPropagation();
|
|
2696
|
+
ulSection.classList.toggle('hide');
|
|
2697
|
+
dom.querySelector('.drop_menu_title').classList.toggle('focus');
|
|
2698
|
+
});
|
|
2699
|
+
for (let i = 0; i < list.length; i++) {
|
|
2700
|
+
const element = list[i];
|
|
2701
|
+
element.addEventListener('click', function (e) {
|
|
2702
|
+
e.stopPropagation();
|
|
2703
|
+
if (ul.querySelector('.active')) {
|
|
2704
|
+
ul.querySelector('.active').classList.remove('active');
|
|
2705
|
+
}
|
|
2706
|
+
this.classList.add('active');
|
|
2707
|
+
dom.querySelector('.drop_menu_title span').innerText = this.innerText.trim();
|
|
2708
|
+
if (callback) {
|
|
2709
|
+
callback(this);
|
|
2710
|
+
}
|
|
2711
|
+
ulSection.classList.toggle('hide');
|
|
2712
|
+
dom.querySelector('.drop_menu_title').classList.toggle('focus');
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
window.addEventListener('click', function (e) {
|
|
2716
|
+
e.stopPropagation();
|
|
2717
|
+
if (!ulSection.classList.contains('hide')) {
|
|
2718
|
+
ulSection.classList.add('hide');
|
|
2719
|
+
}
|
|
2720
|
+
if (dom.querySelector('.drop_menu_title').classList.contains('focus')) {
|
|
2721
|
+
dom.querySelector('.drop_menu_title').classList.remove('focus');
|
|
2722
|
+
}
|
|
2723
|
+
});
|
|
2724
|
+
};
|
|
2725
|
+
|
|
2668
2726
|
const QUEUE_LENGTH = 10;
|
|
2669
2727
|
const requstQueue = [];
|
|
2670
2728
|
function pushRequest(request) {
|
|
@@ -2968,12 +3026,33 @@ const themeConfigDefault = {
|
|
|
2968
3026
|
textColor: '#E0E0E0',
|
|
2969
3027
|
textWeight: 'regular',
|
|
2970
3028
|
fontSize: 12
|
|
3029
|
+
},
|
|
3030
|
+
resultTitle: {
|
|
3031
|
+
// G.6
|
|
3032
|
+
// Figma標示resultPage_text_title
|
|
3033
|
+
textColor: '#25608A',
|
|
3034
|
+
textWeight: 'medium',
|
|
3035
|
+
fontSize: 22
|
|
3036
|
+
},
|
|
3037
|
+
resultBody: {
|
|
3038
|
+
// G.7
|
|
3039
|
+
// Figma標示resultPage_text_body
|
|
3040
|
+
textColor: '#757575',
|
|
3041
|
+
textWeight: 'regular',
|
|
3042
|
+
fontSize: 14
|
|
3043
|
+
},
|
|
3044
|
+
resultTime: {
|
|
3045
|
+
// G.8
|
|
3046
|
+
// Figma標示resultPage_timeText
|
|
3047
|
+
textColor: '#FF3B30',
|
|
3048
|
+
textWeight: 'medium',
|
|
3049
|
+
fontSize: 16
|
|
2971
3050
|
}
|
|
2972
3051
|
};
|
|
2973
3052
|
|
|
2974
3053
|
var name = "authme/sdk";
|
|
2975
|
-
var version$1 = "2.8.
|
|
2976
|
-
var date = "2025-03-
|
|
3054
|
+
var version$1 = "2.8.5";
|
|
3055
|
+
var date = "2025-03-17T05:56:00+0000";
|
|
2977
3056
|
var packageInfo = {
|
|
2978
3057
|
name: name,
|
|
2979
3058
|
version: version$1,
|
|
@@ -2986,4 +3065,4 @@ const version = packageInfo.version;
|
|
|
2986
3065
|
(_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
|
|
2987
3066
|
window[Symbol.for('authme-sdk')][packageInfo.name] = version;
|
|
2988
3067
|
|
|
2989
|
-
export { AuthmeError, 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, 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 };
|
|
3068
|
+
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 };
|
package/package.json
CHANGED
package/src/lib/enum/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const dropMenu: (dom: any, callback: any) => void;
|
package/src/ui/index.d.ts
CHANGED
package/src/ui/uiThemeStyle.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const fontWeight: any;
|
|
2
2
|
export declare const uiThemeText: (dom: any, textStyle: any) => void;
|
|
3
3
|
export declare const uiThemeHint: (dom: any, hintStyle: any) => void;
|
|
4
|
-
export declare const uiThemeButton: (dom: any, buttonStyle: any) => void;
|
|
4
|
+
export declare const uiThemeButton: (dom: any, buttonStyle: any, disabled?: boolean) => void;
|
|
5
5
|
export declare const uiThemeSmallButton: (dom: any, buttonStyle: any) => void;
|