@authme/util 2.8.2 → 2.8.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/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;
@@ -916,7 +918,9 @@ function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType =
916
918
  }
917
919
 
918
920
  function clearCanvas(canvas) {
919
- const ctx = canvas.getContext('2d');
921
+ const ctx = canvas.getContext('2d', {
922
+ willReadFrequently: true
923
+ });
920
924
  ctx.clearRect(0, 0, canvas.width, canvas.height);
921
925
  }
922
926
 
@@ -1030,7 +1034,29 @@ const uiThemeHint = (dom, hintStyle) => {
1030
1034
  dom.style.fontWeight = fontWeight[hintStyle.textWeight];
1031
1035
  dom.style.fontSize = `${hintStyle.fontSize}px`;
1032
1036
  };
1033
- const uiThemeButton = (dom, buttonStyle) => {
1037
+ const uiThemeButton = (dom, buttonStyle, disabled) => {
1038
+ dom.style.opacity = buttonStyle.backgroundOpacity;
1039
+ if (disabled) {
1040
+ dom.style.color = buttonStyle.disabledTextColor;
1041
+ dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1042
+ dom.style.backgroundColor = buttonStyle.disabledBackgroundColor;
1043
+ dom.style.borderColor = hexToRgba(buttonStyle.disabledBorderColor, buttonStyle.borderOpacity);
1044
+ } else {
1045
+ dom.style.color = buttonStyle.textColor;
1046
+ dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1047
+ dom.style.backgroundColor = buttonStyle.backgroundColor;
1048
+ dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
1049
+ }
1050
+ dom.style.borderWidth = `${buttonStyle.borderWidth}px`;
1051
+ dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
1052
+ dom.style.fontSize = `${buttonStyle.fontSize}px`;
1053
+ dom.style.borderStyle = 'solid';
1054
+ // dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
1055
+ dom.style.height = `48px`;
1056
+ dom.style.width = `calc(100% - ${buttonStyle.cornerRadius * 2}px)`;
1057
+ dom.style.maxWidth = `327px`;
1058
+ };
1059
+ const uiThemeSmallButton = (dom, buttonStyle) => {
1034
1060
  dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1035
1061
  dom.style.backgroundColor = buttonStyle.backgroundColor;
1036
1062
  dom.style.opacity = buttonStyle.backgroundOpacity;
@@ -1040,9 +1066,10 @@ const uiThemeButton = (dom, buttonStyle) => {
1040
1066
  dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
1041
1067
  dom.style.fontSize = `${buttonStyle.fontSize}px`;
1042
1068
  dom.style.borderStyle = 'solid';
1043
- dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
1069
+ // dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
1070
+ dom.style.height = `30px`;
1044
1071
  dom.style.width = `calc(100% - ${buttonStyle.cornerRadius * 2}px)`;
1045
- dom.style.maxWidth = `327px`;
1072
+ dom.style.maxWidth = `106px`;
1046
1073
  };
1047
1074
 
1048
1075
  function startSpinner(args) {
@@ -2659,6 +2686,46 @@ const uploadModal = arg => {
2659
2686
  };
2660
2687
  };
2661
2688
 
2689
+ const dropMenu = function dropMenu(dom, callback) {
2690
+ if (!dom) {
2691
+ console.error('dom is required');
2692
+ return;
2693
+ }
2694
+ const ul = dom.querySelector('ul');
2695
+ const ulSection = dom.querySelector('section');
2696
+ const list = dom.querySelectorAll('li');
2697
+ dom.querySelector('.drop_menu_title').addEventListener('click', function (e) {
2698
+ e.stopPropagation();
2699
+ ulSection.classList.toggle('hide');
2700
+ dom.querySelector('.drop_menu_title').classList.toggle('focus');
2701
+ });
2702
+ for (let i = 0; i < list.length; i++) {
2703
+ const element = list[i];
2704
+ element.addEventListener('click', function (e) {
2705
+ e.stopPropagation();
2706
+ if (ul.querySelector('.active')) {
2707
+ ul.querySelector('.active').classList.remove('active');
2708
+ }
2709
+ this.classList.add('active');
2710
+ dom.querySelector('.drop_menu_title span').innerText = this.innerText.trim();
2711
+ if (callback) {
2712
+ callback(this);
2713
+ }
2714
+ ulSection.classList.toggle('hide');
2715
+ dom.querySelector('.drop_menu_title').classList.toggle('focus');
2716
+ });
2717
+ }
2718
+ window.addEventListener('click', function (e) {
2719
+ e.stopPropagation();
2720
+ if (!ulSection.classList.contains('hide')) {
2721
+ ulSection.classList.add('hide');
2722
+ }
2723
+ if (dom.querySelector('.drop_menu_title').classList.contains('focus')) {
2724
+ dom.querySelector('.drop_menu_title').classList.remove('focus');
2725
+ }
2726
+ });
2727
+ };
2728
+
2662
2729
  const QUEUE_LENGTH = 10;
2663
2730
  const requstQueue = [];
2664
2731
  function pushRequest(request) {
@@ -2962,12 +3029,33 @@ const themeConfigDefault = {
2962
3029
  textColor: '#E0E0E0',
2963
3030
  textWeight: 'regular',
2964
3031
  fontSize: 12
3032
+ },
3033
+ resultTitle: {
3034
+ // G.6
3035
+ // Figma標示resultPage_text_title
3036
+ textColor: '#25608A',
3037
+ textWeight: 'medium',
3038
+ fontSize: 22
3039
+ },
3040
+ resultBody: {
3041
+ // G.7
3042
+ // Figma標示resultPage_text_body
3043
+ textColor: '#757575',
3044
+ textWeight: 'regular',
3045
+ fontSize: 14
3046
+ },
3047
+ resultTime: {
3048
+ // G.8
3049
+ // Figma標示resultPage_timeText
3050
+ textColor: '#FF3B30',
3051
+ textWeight: 'medium',
3052
+ fontSize: 16
2965
3053
  }
2966
3054
  };
2967
3055
 
2968
3056
  var name = "authme/sdk";
2969
- var version$1 = "2.8.2";
2970
- var date = "2025-02-26T06:47:43+0000";
3057
+ var version$1 = "2.8.4";
3058
+ var date = "2025-03-13T06:47:53+0000";
2971
3059
  var packageInfo = {
2972
3060
  name: name,
2973
3061
  version: version$1,
@@ -2998,6 +3086,7 @@ exports.dataURItoBlob = dataURItoBlob;
2998
3086
  exports.debugLog = debugLog;
2999
3087
  exports.debugTools = debugTools;
3000
3088
  exports.decodeToken = decodeToken;
3089
+ exports.dropMenu = dropMenu;
3001
3090
  exports.fontWeight = fontWeight;
3002
3091
  exports.getCanvasSize = getCanvasSize;
3003
3092
  exports.getCssVariable = getCssVariable;
@@ -3028,6 +3117,7 @@ exports.switchCamera = switchCamera;
3028
3117
  exports.themeConfigDefault = themeConfigDefault;
3029
3118
  exports.uiThemeButton = uiThemeButton;
3030
3119
  exports.uiThemeHint = uiThemeHint;
3120
+ exports.uiThemeSmallButton = uiThemeSmallButton;
3031
3121
  exports.uiThemeText = uiThemeText;
3032
3122
  exports.uploadModal = uploadModal;
3033
3123
  exports.useState = useState;
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;
@@ -906,7 +908,9 @@ function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType =
906
908
  }
907
909
 
908
910
  function clearCanvas(canvas) {
909
- const ctx = canvas.getContext('2d');
911
+ const ctx = canvas.getContext('2d', {
912
+ willReadFrequently: true
913
+ });
910
914
  ctx.clearRect(0, 0, canvas.width, canvas.height);
911
915
  }
912
916
 
@@ -1020,7 +1024,29 @@ const uiThemeHint = (dom, hintStyle) => {
1020
1024
  dom.style.fontWeight = fontWeight[hintStyle.textWeight];
1021
1025
  dom.style.fontSize = `${hintStyle.fontSize}px`;
1022
1026
  };
1023
- const uiThemeButton = (dom, buttonStyle) => {
1027
+ const uiThemeButton = (dom, buttonStyle, disabled) => {
1028
+ dom.style.opacity = buttonStyle.backgroundOpacity;
1029
+ if (disabled) {
1030
+ dom.style.color = buttonStyle.disabledTextColor;
1031
+ dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1032
+ dom.style.backgroundColor = buttonStyle.disabledBackgroundColor;
1033
+ dom.style.borderColor = hexToRgba(buttonStyle.disabledBorderColor, buttonStyle.borderOpacity);
1034
+ } else {
1035
+ dom.style.color = buttonStyle.textColor;
1036
+ dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1037
+ dom.style.backgroundColor = buttonStyle.backgroundColor;
1038
+ dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
1039
+ }
1040
+ dom.style.borderWidth = `${buttonStyle.borderWidth}px`;
1041
+ dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
1042
+ dom.style.fontSize = `${buttonStyle.fontSize}px`;
1043
+ dom.style.borderStyle = 'solid';
1044
+ // dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
1045
+ dom.style.height = `48px`;
1046
+ dom.style.width = `calc(100% - ${buttonStyle.cornerRadius * 2}px)`;
1047
+ dom.style.maxWidth = `327px`;
1048
+ };
1049
+ const uiThemeSmallButton = (dom, buttonStyle) => {
1024
1050
  dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1025
1051
  dom.style.backgroundColor = buttonStyle.backgroundColor;
1026
1052
  dom.style.opacity = buttonStyle.backgroundOpacity;
@@ -1030,9 +1056,10 @@ const uiThemeButton = (dom, buttonStyle) => {
1030
1056
  dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
1031
1057
  dom.style.fontSize = `${buttonStyle.fontSize}px`;
1032
1058
  dom.style.borderStyle = 'solid';
1033
- dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
1059
+ // dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
1060
+ dom.style.height = `30px`;
1034
1061
  dom.style.width = `calc(100% - ${buttonStyle.cornerRadius * 2}px)`;
1035
- dom.style.maxWidth = `327px`;
1062
+ dom.style.maxWidth = `106px`;
1036
1063
  };
1037
1064
 
1038
1065
  function startSpinner(args) {
@@ -2649,6 +2676,46 @@ const uploadModal = arg => {
2649
2676
  };
2650
2677
  };
2651
2678
 
2679
+ const dropMenu = function dropMenu(dom, callback) {
2680
+ if (!dom) {
2681
+ console.error('dom is required');
2682
+ return;
2683
+ }
2684
+ const ul = dom.querySelector('ul');
2685
+ const ulSection = dom.querySelector('section');
2686
+ const list = dom.querySelectorAll('li');
2687
+ dom.querySelector('.drop_menu_title').addEventListener('click', function (e) {
2688
+ e.stopPropagation();
2689
+ ulSection.classList.toggle('hide');
2690
+ dom.querySelector('.drop_menu_title').classList.toggle('focus');
2691
+ });
2692
+ for (let i = 0; i < list.length; i++) {
2693
+ const element = list[i];
2694
+ element.addEventListener('click', function (e) {
2695
+ e.stopPropagation();
2696
+ if (ul.querySelector('.active')) {
2697
+ ul.querySelector('.active').classList.remove('active');
2698
+ }
2699
+ this.classList.add('active');
2700
+ dom.querySelector('.drop_menu_title span').innerText = this.innerText.trim();
2701
+ if (callback) {
2702
+ callback(this);
2703
+ }
2704
+ ulSection.classList.toggle('hide');
2705
+ dom.querySelector('.drop_menu_title').classList.toggle('focus');
2706
+ });
2707
+ }
2708
+ window.addEventListener('click', function (e) {
2709
+ e.stopPropagation();
2710
+ if (!ulSection.classList.contains('hide')) {
2711
+ ulSection.classList.add('hide');
2712
+ }
2713
+ if (dom.querySelector('.drop_menu_title').classList.contains('focus')) {
2714
+ dom.querySelector('.drop_menu_title').classList.remove('focus');
2715
+ }
2716
+ });
2717
+ };
2718
+
2652
2719
  const QUEUE_LENGTH = 10;
2653
2720
  const requstQueue = [];
2654
2721
  function pushRequest(request) {
@@ -2952,12 +3019,33 @@ const themeConfigDefault = {
2952
3019
  textColor: '#E0E0E0',
2953
3020
  textWeight: 'regular',
2954
3021
  fontSize: 12
3022
+ },
3023
+ resultTitle: {
3024
+ // G.6
3025
+ // Figma標示resultPage_text_title
3026
+ textColor: '#25608A',
3027
+ textWeight: 'medium',
3028
+ fontSize: 22
3029
+ },
3030
+ resultBody: {
3031
+ // G.7
3032
+ // Figma標示resultPage_text_body
3033
+ textColor: '#757575',
3034
+ textWeight: 'regular',
3035
+ fontSize: 14
3036
+ },
3037
+ resultTime: {
3038
+ // G.8
3039
+ // Figma標示resultPage_timeText
3040
+ textColor: '#FF3B30',
3041
+ textWeight: 'medium',
3042
+ fontSize: 16
2955
3043
  }
2956
3044
  };
2957
3045
 
2958
3046
  var name = "authme/sdk";
2959
- var version$1 = "2.8.2";
2960
- var date = "2025-02-26T06:47:43+0000";
3047
+ var version$1 = "2.8.4";
3048
+ var date = "2025-03-13T06:47:53+0000";
2961
3049
  var packageInfo = {
2962
3050
  name: name,
2963
3051
  version: version$1,
@@ -2970,4 +3058,4 @@ const version = packageInfo.version;
2970
3058
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
2971
3059
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
2972
3060
 
2973
- 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, uiThemeText, uploadModal, useState, verificationErrorMessages, version, videoConstraintsFactory, waitTime };
3061
+ 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, 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authme/util",
3
- "version": "2.8.2",
3
+ "version": "2.8.4",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
6
  "jwt-decode": "3.1.2",
@@ -0,0 +1 @@
1
+ export declare const dropMenu: (dom: any, callback: any) => void;
package/src/ui/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from './sdk-loading';
9
9
  export * from './cssToJs';
10
10
  export * from './uiThemeStyle';
11
11
  export * from './uploadModal';
12
+ export * from './dropMenu';
@@ -1,4 +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
+ export declare const uiThemeSmallButton: (dom: any, buttonStyle: any) => void;