@microblink/blinkid-ux-manager 7.3.2 → 7.4.0
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/dist/blinkid-ux-manager.js +205 -28
- package/dist/blinkid-ux-manager.js.map +1 -1
- package/package.json +3 -3
- package/types/core/BlinkIdProcessingError.d.ts +5 -0
- package/types/core/BlinkIdProcessingError.d.ts.map +1 -1
- package/types/core/BlinkIdUxManager.d.ts +80 -25
- package/types/core/BlinkIdUxManager.d.ts.map +1 -1
- package/types/core/DocumentClassFilter.d.ts +5 -3
- package/types/core/DocumentClassFilter.d.ts.map +1 -1
- package/types/core/blinkid-ui-state.d.ts +38 -0
- package/types/core/blinkid-ui-state.d.ts.map +1 -1
- package/types/core/utils.d.ts +18 -0
- package/types/core/utils.d.ts.map +1 -1
- package/types/index.d.ts +14 -0
- package/types/index.d.ts.map +1 -1
- package/types/index.rollup.d.ts +242 -34
- package/types/ui/BlinkIdFeedbackUi.d.ts +8 -0
- package/types/ui/BlinkIdFeedbackUi.d.ts.map +1 -1
- package/types/ui/BlinkIdUiStoreContext.d.ts +44 -0
- package/types/ui/BlinkIdUiStoreContext.d.ts.map +1 -1
- package/types/ui/LocalizationContext.d.ts +14 -0
- package/types/ui/LocalizationContext.d.ts.map +1 -1
- package/types/ui/UiFeedbackOverlay.d.ts +6 -0
- package/types/ui/UiFeedbackOverlay.d.ts.map +1 -1
- package/types/ui/createBlinkIdFeedbackUi.d.ts +15 -0
- package/types/ui/createBlinkIdFeedbackUi.d.ts.map +1 -1
- package/types/ui/dialogs/ErrorModal.d.ts +9 -0
- package/types/ui/dialogs/ErrorModal.d.ts.map +1 -1
- package/types/ui/dialogs/HelpModal.d.ts +11 -0
- package/types/ui/dialogs/HelpModal.d.ts.map +1 -1
- package/types/ui/dialogs/OnboardingGuideModal.d.ts +5 -0
- package/types/ui/dialogs/OnboardingGuideModal.d.ts.map +1 -1
- package/types/ui/feedbackMessages.d.ts +3 -0
- package/types/ui/feedbackMessages.d.ts.map +1 -1
- package/types/ui/locales/en.d.ts +3 -0
- package/types/ui/locales/en.d.ts.map +1 -1
|
@@ -698,33 +698,75 @@ function getKeyWithHighestValue(obj) {
|
|
|
698
698
|
return maxKey;
|
|
699
699
|
}
|
|
700
700
|
class FeedbackStabilizer {
|
|
701
|
+
/** The initial key. */
|
|
701
702
|
initialKey;
|
|
703
|
+
/** The UI state map. */
|
|
702
704
|
uiStateMap;
|
|
705
|
+
/** Time window (in ms) for considering UI state events. */
|
|
703
706
|
timeWindow = 3e3;
|
|
707
|
+
/** The decay rate. */
|
|
708
|
+
/** Rate at which event weights decay over time */
|
|
704
709
|
decayRate = 0.95;
|
|
710
|
+
/** Queue of regular UI state events within the time window */
|
|
705
711
|
eventQueue = [];
|
|
706
|
-
/**
|
|
712
|
+
/** Special queue for single-emit events that bypass normal stabilization */
|
|
707
713
|
singleEventQueue = [];
|
|
708
|
-
|
|
714
|
+
/** Currently displayed state key */
|
|
709
715
|
currentKey;
|
|
716
|
+
/** Timestamp when current state started displaying */
|
|
710
717
|
currentStateStartTime = performance.now();
|
|
718
|
+
/** Accumulated scores for each state in current calculation */
|
|
711
719
|
summedScores = {};
|
|
720
|
+
/** History of scores for each state */
|
|
712
721
|
scoreBoard = {};
|
|
722
|
+
/**
|
|
723
|
+
* Gets the currently active UI state configuration.
|
|
724
|
+
*
|
|
725
|
+
* @returns The currently active UI state configuration.
|
|
726
|
+
*/
|
|
713
727
|
get currentState() {
|
|
714
728
|
return this.uiStateMap[this.currentKey];
|
|
715
729
|
}
|
|
730
|
+
/**
|
|
731
|
+
* Gets a copy of the current event queue for debugging.
|
|
732
|
+
*
|
|
733
|
+
* @returns A copy of the current event queue.
|
|
734
|
+
*/
|
|
716
735
|
getEventQueue() {
|
|
717
736
|
return structuredClone(this.eventQueue);
|
|
718
737
|
}
|
|
738
|
+
/**
|
|
739
|
+
* Gets the current summed scores for each state.
|
|
740
|
+
*
|
|
741
|
+
* @returns The current summed scores for each state.
|
|
742
|
+
*/
|
|
719
743
|
getScores() {
|
|
720
744
|
return structuredClone(this.summedScores);
|
|
721
745
|
}
|
|
746
|
+
/**
|
|
747
|
+
* Gets the score history for each state.
|
|
748
|
+
*
|
|
749
|
+
* @returns The score history for each state.
|
|
750
|
+
*/
|
|
722
751
|
getScoreBoard() {
|
|
723
752
|
return structuredClone(this.scoreBoard);
|
|
724
753
|
}
|
|
754
|
+
/**
|
|
755
|
+
* Updates the time window used for state stabilization
|
|
756
|
+
*
|
|
757
|
+
* @param timeWindow - New time window in milliseconds
|
|
758
|
+
*/
|
|
725
759
|
setTimeWindow(timeWindow) {
|
|
726
760
|
this.timeWindow = timeWindow;
|
|
727
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* Creates a new FeedbackStabilizer instance.
|
|
764
|
+
*
|
|
765
|
+
* @param uiStateMap - Map of all possible UI states and their configurations
|
|
766
|
+
* @param initialKey - Key of the initial UI state to display
|
|
767
|
+
* @param timeWindow - Optional custom time window (in ms) for state averaging
|
|
768
|
+
* @param decayRate - Optional custom decay rate for event weights
|
|
769
|
+
*/
|
|
728
770
|
constructor(uiStateMap, initialKey, timeWindow, decayRate) {
|
|
729
771
|
this.uiStateMap = uiStateMap;
|
|
730
772
|
this.initialKey = initialKey;
|
|
@@ -737,17 +779,35 @@ class FeedbackStabilizer {
|
|
|
737
779
|
this.decayRate = decayRate;
|
|
738
780
|
}
|
|
739
781
|
}
|
|
782
|
+
/**
|
|
783
|
+
* Resets the stabilizer to its initial state.
|
|
784
|
+
*
|
|
785
|
+
* @returns The initial state.
|
|
786
|
+
*/
|
|
740
787
|
reset() {
|
|
741
788
|
this.currentKey = this.initialKey;
|
|
742
789
|
this.eventQueue = [];
|
|
743
790
|
this.singleEventQueue = [];
|
|
744
791
|
this.summedScores = {};
|
|
745
792
|
}
|
|
793
|
+
/**
|
|
794
|
+
* Checks if enough time has passed to show a new UI state
|
|
795
|
+
*
|
|
796
|
+
* @returns true if the current state's minimum duration has elapsed
|
|
797
|
+
*/
|
|
746
798
|
canShowNewUiState = () => {
|
|
747
799
|
return performance.now() - this.currentStateStartTime >= this.currentState.minDuration;
|
|
748
800
|
};
|
|
749
801
|
/**
|
|
750
|
-
*
|
|
802
|
+
* Processes a new UI state event and determines the state to display.
|
|
803
|
+
*
|
|
804
|
+
* This method:
|
|
805
|
+
* 1. Handles single-emit events that bypass normal stabilization
|
|
806
|
+
* 2. Maintains a time-windowed queue of regular events
|
|
807
|
+
* 3. Applies temporal averaging with decay to determine the winning state
|
|
808
|
+
*
|
|
809
|
+
* @param incomingUiStateKey - Key of the new UI state event
|
|
810
|
+
* @returns The UI state that should be displayed.
|
|
751
811
|
*/
|
|
752
812
|
getNewUiState(incomingUiStateKey) {
|
|
753
813
|
const now = performance.now();
|
|
@@ -814,8 +874,11 @@ async function sleep(ms) {
|
|
|
814
874
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
815
875
|
}
|
|
816
876
|
class BlinkIdUxManager {
|
|
877
|
+
/** The success process result. */
|
|
817
878
|
#successProcessResult;
|
|
879
|
+
/** Whether the thread is busy. */
|
|
818
880
|
#threadBusy = false;
|
|
881
|
+
/** The scanning session timeout ID. */
|
|
819
882
|
#timeoutId;
|
|
820
883
|
/** Timeout duration in ms for the scanning session. If null, timeout won't be triggered ever. */
|
|
821
884
|
#timeoutDuration = 1e4;
|
|
@@ -826,12 +889,24 @@ class BlinkIdUxManager {
|
|
|
826
889
|
/** Time in ms before the help tooltip is hidden. If null, tooltip won't be auto hidden. */
|
|
827
890
|
#helpTooltipHideDelay = 5e3;
|
|
828
891
|
// 5s
|
|
892
|
+
/** The callbacks for when the UI state changes. */
|
|
829
893
|
#onUiStateChangedCallbacks = /* @__PURE__ */ new Set();
|
|
894
|
+
/** The callbacks for when a scan result is available. */
|
|
830
895
|
#onResultCallbacks = /* @__PURE__ */ new Set();
|
|
896
|
+
/** The callbacks for when a frame is processed. */
|
|
831
897
|
#onFrameProcessCallbacks = /* @__PURE__ */ new Set();
|
|
898
|
+
/** The callbacks for when an error occurs during processing. */
|
|
832
899
|
#onErrorCallbacks = /* @__PURE__ */ new Set();
|
|
900
|
+
/** The callbacks for when a document is filtered. */
|
|
833
901
|
#onDocumentFilteredCallbacks = /* @__PURE__ */ new Set();
|
|
902
|
+
/** The document class filter. */
|
|
834
903
|
#documentClassFilter;
|
|
904
|
+
/**
|
|
905
|
+
* The constructor for the BlinkIdUxManager class.
|
|
906
|
+
*
|
|
907
|
+
* @param cameraManager - The camera manager.
|
|
908
|
+
* @param scanningSession - The scanning session.
|
|
909
|
+
*/
|
|
835
910
|
constructor(cameraManager, scanningSession) {
|
|
836
911
|
this.cameraManager = cameraManager;
|
|
837
912
|
this.scanningSession = scanningSession;
|
|
@@ -878,42 +953,44 @@ class BlinkIdUxManager {
|
|
|
878
953
|
cameraManager.addFrameCaptureCallback(this.#frameCaptureCallback);
|
|
879
954
|
}
|
|
880
955
|
/**
|
|
881
|
-
* Indicates whether the UI should display the demo overlay. Controlled by the
|
|
956
|
+
* Indicates whether the UI should display the demo overlay. Controlled by the
|
|
957
|
+
* license property.
|
|
882
958
|
*/
|
|
883
959
|
getShowDemoOverlay() {
|
|
884
960
|
return this.showDemoOverlay;
|
|
885
961
|
}
|
|
886
962
|
/**
|
|
887
|
-
* Indicates whether the UI should display the production overlay. Controlled by
|
|
963
|
+
* Indicates whether the UI should display the production overlay. Controlled by
|
|
964
|
+
* the license property.
|
|
888
965
|
*/
|
|
889
966
|
getShowProductionOverlay() {
|
|
890
967
|
return this.showProductionOverlay;
|
|
891
968
|
}
|
|
892
969
|
/**
|
|
893
970
|
* Returns the timeout duration in ms. Null if timeout won't be triggered ever.
|
|
894
|
-
* @returns The timeout duration in ms.
|
|
895
971
|
*/
|
|
896
972
|
getTimeoutDuration() {
|
|
897
973
|
return this.#timeoutDuration;
|
|
898
974
|
}
|
|
899
975
|
/**
|
|
900
976
|
* Returns the time in ms before the help tooltip is shown. Null if tooltip won't be auto shown.
|
|
901
|
-
* @returns The time in ms before the help tooltip is shown.
|
|
902
977
|
*/
|
|
903
978
|
getHelpTooltipShowDelay() {
|
|
904
979
|
return this.#helpTooltipShowDelay;
|
|
905
980
|
}
|
|
906
981
|
/**
|
|
907
982
|
* Returns the time in ms before the help tooltip is hidden. Null if tooltip won't be auto hidden.
|
|
908
|
-
* @returns The time in ms before the help tooltip is hidden.
|
|
909
983
|
*/
|
|
910
984
|
getHelpTooltipHideDelay() {
|
|
911
985
|
return this.#helpTooltipHideDelay;
|
|
912
986
|
}
|
|
913
987
|
/**
|
|
914
988
|
* Adds a callback function to be executed when the UI state changes.
|
|
915
|
-
*
|
|
989
|
+
*
|
|
990
|
+
* @param callback - Function to be called when UI state changes. Receives the
|
|
991
|
+
* new UI state as parameter.
|
|
916
992
|
* @returns A cleanup function that removes the callback when called.
|
|
993
|
+
*
|
|
917
994
|
* @example
|
|
918
995
|
* const cleanup = manager.addOnUiStateChangedCallback((newState) => {
|
|
919
996
|
* console.log('UI state changed to:', newState);
|
|
@@ -929,8 +1006,10 @@ class BlinkIdUxManager {
|
|
|
929
1006
|
}
|
|
930
1007
|
/**
|
|
931
1008
|
* Registers a callback function to be called when a scan result is available.
|
|
1009
|
+
*
|
|
932
1010
|
* @param callback - A function that will be called with the scan result.
|
|
933
|
-
* @returns A cleanup function that, when called, will remove the registered
|
|
1011
|
+
* @returns A cleanup function that, when called, will remove the registered
|
|
1012
|
+
* callback.
|
|
934
1013
|
*
|
|
935
1014
|
* @example
|
|
936
1015
|
*
|
|
@@ -949,8 +1028,11 @@ class BlinkIdUxManager {
|
|
|
949
1028
|
}
|
|
950
1029
|
/**
|
|
951
1030
|
* Registers a callback function to filter document classes.
|
|
952
|
-
*
|
|
953
|
-
* @
|
|
1031
|
+
*
|
|
1032
|
+
* @param callback - A function that will be called with the document class
|
|
1033
|
+
* info.
|
|
1034
|
+
* @returns A cleanup function that, when called, will remove the registered
|
|
1035
|
+
* callback.
|
|
954
1036
|
*
|
|
955
1037
|
* @example
|
|
956
1038
|
* const cleanup = manager.addDocumentClassFilter((docClassInfo) => {
|
|
@@ -968,8 +1050,11 @@ class BlinkIdUxManager {
|
|
|
968
1050
|
}
|
|
969
1051
|
/**
|
|
970
1052
|
* Registers a callback function to be called when a frame is processed.
|
|
971
|
-
*
|
|
972
|
-
* @
|
|
1053
|
+
*
|
|
1054
|
+
* @param callback - A function that will be called with the frame analysis
|
|
1055
|
+
* result.
|
|
1056
|
+
* @returns A cleanup function that, when called, will remove the registered
|
|
1057
|
+
* callback.
|
|
973
1058
|
*
|
|
974
1059
|
* @example
|
|
975
1060
|
* const cleanup = manager.addOnFrameProcessCallback((frameResult) => {
|
|
@@ -986,9 +1071,12 @@ class BlinkIdUxManager {
|
|
|
986
1071
|
};
|
|
987
1072
|
}
|
|
988
1073
|
/**
|
|
989
|
-
* Registers a callback function to be called when an error occurs during
|
|
1074
|
+
* Registers a callback function to be called when an error occurs during
|
|
1075
|
+
* processing.
|
|
1076
|
+
*
|
|
990
1077
|
* @param callback - A function that will be called with the error state.
|
|
991
|
-
* @returns A cleanup function that, when called, will remove the registered
|
|
1078
|
+
* @returns A cleanup function that, when called, will remove the registered
|
|
1079
|
+
* callback.
|
|
992
1080
|
*
|
|
993
1081
|
* @example
|
|
994
1082
|
* const cleanup = manager.addOnErrorCallback((error) => {
|
|
@@ -1004,6 +1092,11 @@ class BlinkIdUxManager {
|
|
|
1004
1092
|
this.#onErrorCallbacks.delete(callback);
|
|
1005
1093
|
};
|
|
1006
1094
|
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Invokes the onError callbacks.
|
|
1097
|
+
*
|
|
1098
|
+
* @param errorState - The error state.
|
|
1099
|
+
*/
|
|
1007
1100
|
#invokeOnErrorCallbacks = (errorState) => {
|
|
1008
1101
|
for (const callback of this.#onErrorCallbacks) {
|
|
1009
1102
|
try {
|
|
@@ -1013,12 +1106,33 @@ class BlinkIdUxManager {
|
|
|
1013
1106
|
}
|
|
1014
1107
|
}
|
|
1015
1108
|
};
|
|
1109
|
+
/**
|
|
1110
|
+
* Registers a callback function to be called when a document is filtered.
|
|
1111
|
+
*
|
|
1112
|
+
* @param callback - A function that will be called with the document class
|
|
1113
|
+
* info.
|
|
1114
|
+
* @returns A cleanup function that, when called, will remove the registered
|
|
1115
|
+
* callback.
|
|
1116
|
+
*
|
|
1117
|
+
* @example
|
|
1118
|
+
* const cleanup = manager.addOnDocumentFilteredCallback((docClassInfo) => {
|
|
1119
|
+
* console.log('Document filtered:', docClassInfo);
|
|
1120
|
+
* });
|
|
1121
|
+
*
|
|
1122
|
+
* // Later, to remove the callback:
|
|
1123
|
+
* cleanup();
|
|
1124
|
+
*/
|
|
1016
1125
|
addOnDocumentFilteredCallback(callback) {
|
|
1017
1126
|
this.#onDocumentFilteredCallbacks.add(callback);
|
|
1018
1127
|
return () => {
|
|
1019
1128
|
this.#onDocumentFilteredCallbacks.delete(callback);
|
|
1020
1129
|
};
|
|
1021
1130
|
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Invokes the onDocumentFiltered callbacks.
|
|
1133
|
+
*
|
|
1134
|
+
* @param documentClassInfo - The document class info.
|
|
1135
|
+
*/
|
|
1022
1136
|
#invokeOnDocumentFilteredCallbacks = (documentClassInfo) => {
|
|
1023
1137
|
for (const callback of this.#onDocumentFilteredCallbacks) {
|
|
1024
1138
|
try {
|
|
@@ -1028,6 +1142,11 @@ class BlinkIdUxManager {
|
|
|
1028
1142
|
}
|
|
1029
1143
|
}
|
|
1030
1144
|
};
|
|
1145
|
+
/**
|
|
1146
|
+
* Invokes the onResult callbacks.
|
|
1147
|
+
*
|
|
1148
|
+
* @param result - The scan result.
|
|
1149
|
+
*/
|
|
1031
1150
|
#invokeOnResultCallbacks = (result) => {
|
|
1032
1151
|
for (const callback of this.#onResultCallbacks) {
|
|
1033
1152
|
try {
|
|
@@ -1037,6 +1156,11 @@ class BlinkIdUxManager {
|
|
|
1037
1156
|
}
|
|
1038
1157
|
}
|
|
1039
1158
|
};
|
|
1159
|
+
/**
|
|
1160
|
+
* Invokes the onFrameProcess callbacks.
|
|
1161
|
+
*
|
|
1162
|
+
* @param frameResult - The frame result.
|
|
1163
|
+
*/
|
|
1040
1164
|
#invokeOnFrameProcessCallbacks = (frameResult) => {
|
|
1041
1165
|
for (const callback of this.#onFrameProcessCallbacks) {
|
|
1042
1166
|
try {
|
|
@@ -1046,6 +1170,11 @@ class BlinkIdUxManager {
|
|
|
1046
1170
|
}
|
|
1047
1171
|
}
|
|
1048
1172
|
};
|
|
1173
|
+
/**
|
|
1174
|
+
* Invokes the onUiStateChanged callbacks.
|
|
1175
|
+
*
|
|
1176
|
+
* @param uiState - The UI state.
|
|
1177
|
+
*/
|
|
1049
1178
|
#invokeOnUiStateChangedCallbacks = (uiState) => {
|
|
1050
1179
|
for (const callback of this.#onUiStateChangedCallbacks) {
|
|
1051
1180
|
try {
|
|
@@ -1055,6 +1184,13 @@ class BlinkIdUxManager {
|
|
|
1055
1184
|
}
|
|
1056
1185
|
}
|
|
1057
1186
|
};
|
|
1187
|
+
/**
|
|
1188
|
+
* The frame capture callback. This is the main function that is called when a
|
|
1189
|
+
* new frame is captured. It is responsible for processing the frame and
|
|
1190
|
+
* updating the UI state.
|
|
1191
|
+
*
|
|
1192
|
+
* @param imageData - The image data.
|
|
1193
|
+
*/
|
|
1058
1194
|
#frameCaptureCallback = async (imageData) => {
|
|
1059
1195
|
if (this.#threadBusy) {
|
|
1060
1196
|
return;
|
|
@@ -1088,11 +1224,15 @@ class BlinkIdUxManager {
|
|
|
1088
1224
|
return processResult.arrayBuffer;
|
|
1089
1225
|
};
|
|
1090
1226
|
/**
|
|
1091
|
-
* Sets the duration after which the scanning session will timeout. The
|
|
1092
|
-
* and may be restarted by different
|
|
1227
|
+
* Sets the duration after which the scanning session will timeout. The
|
|
1228
|
+
* timeout can occur in various scenarios and may be restarted by different
|
|
1229
|
+
* scanning events.
|
|
1093
1230
|
*
|
|
1094
|
-
* @param duration The timeout duration in milliseconds. If null, timeout won't
|
|
1095
|
-
*
|
|
1231
|
+
* @param duration The timeout duration in milliseconds. If null, timeout won't
|
|
1232
|
+
* be triggered ever.
|
|
1233
|
+
* @param setHelpTooltipShowDelay If true, also sets the help tooltip show
|
|
1234
|
+
* delay to half of the provided duration. If timeout duration is null, help
|
|
1235
|
+
* tooltip show delay will be set to null. Defaults to true.
|
|
1096
1236
|
* @throws {Error} Throws an error if duration is less than or equal to 0 when not null.
|
|
1097
1237
|
*/
|
|
1098
1238
|
setTimeoutDuration(duration, setHelpTooltipShowDelay = true) {
|
|
@@ -1107,8 +1247,11 @@ class BlinkIdUxManager {
|
|
|
1107
1247
|
/**
|
|
1108
1248
|
* Sets the duration in milliseconds before the help tooltip is shown.
|
|
1109
1249
|
* A value of null means the help tooltip will not be auto shown.
|
|
1110
|
-
*
|
|
1111
|
-
* @
|
|
1250
|
+
*
|
|
1251
|
+
* @param duration The duration in milliseconds before the help tooltip is
|
|
1252
|
+
* shown. If null, tooltip won't be auto shown.
|
|
1253
|
+
* @throws {Error} Throws an error if duration is less than or equal to 0 when
|
|
1254
|
+
* not null.
|
|
1112
1255
|
*/
|
|
1113
1256
|
setHelpTooltipShowDelay(duration) {
|
|
1114
1257
|
if (duration !== null && duration <= 0) {
|
|
@@ -1119,8 +1262,11 @@ class BlinkIdUxManager {
|
|
|
1119
1262
|
/**
|
|
1120
1263
|
* Sets the duration in milliseconds before the help tooltip is hidden.
|
|
1121
1264
|
* A value of null means the help tooltip will not be auto hidden.
|
|
1122
|
-
*
|
|
1123
|
-
* @
|
|
1265
|
+
*
|
|
1266
|
+
* @param duration The duration in milliseconds before the help tooltip is
|
|
1267
|
+
* hidden. If null, tooltip won't be auto hidden.
|
|
1268
|
+
* @throws {Error} Throws an error if duration is less than or equal to 0 when
|
|
1269
|
+
* not null.
|
|
1124
1270
|
*/
|
|
1125
1271
|
setHelpTooltipHideDelay(duration) {
|
|
1126
1272
|
if (duration !== null && duration <= 0) {
|
|
@@ -1128,6 +1274,11 @@ class BlinkIdUxManager {
|
|
|
1128
1274
|
}
|
|
1129
1275
|
this.#helpTooltipHideDelay = duration;
|
|
1130
1276
|
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Sets the timeout for the scanning session.
|
|
1279
|
+
*
|
|
1280
|
+
* @param uiState - The UI state.
|
|
1281
|
+
*/
|
|
1131
1282
|
#setTimeout = (uiState) => {
|
|
1132
1283
|
if (this.#timeoutDuration === null) {
|
|
1133
1284
|
console.debug("⏳🟢 timeout duration is null, not starting timeout");
|
|
@@ -1143,6 +1294,13 @@ class BlinkIdUxManager {
|
|
|
1143
1294
|
this.uiState = this.feedbackStabilizer.currentState;
|
|
1144
1295
|
}, this.#timeoutDuration);
|
|
1145
1296
|
};
|
|
1297
|
+
/**
|
|
1298
|
+
* Handles the UI state changes. This is the main function that is called
|
|
1299
|
+
* when a new frame is processed. It is responsible for updating the UI state,
|
|
1300
|
+
* handling the timeout, and handling the first side captured states.
|
|
1301
|
+
*
|
|
1302
|
+
* @param processResult - The process result.
|
|
1303
|
+
*/
|
|
1146
1304
|
#handleUiStateChanges = (processResult) => {
|
|
1147
1305
|
const nextUiStateKey = getUiStateKey(
|
|
1148
1306
|
processResult,
|
|
@@ -1160,7 +1318,14 @@ class BlinkIdUxManager {
|
|
|
1160
1318
|
this.#invokeOnUiStateChangedCallbacks(newUiState);
|
|
1161
1319
|
void this.#handleUiStateChange(newUiState);
|
|
1162
1320
|
};
|
|
1163
|
-
|
|
1321
|
+
/**
|
|
1322
|
+
* Handles the UI state change. This is the main function that is called
|
|
1323
|
+
* when a new UI state is set. It is responsible for handling the timeout,
|
|
1324
|
+
* handling the first side captured states, and handling the UNSUPPORTED_DOCUMENT
|
|
1325
|
+
* state.
|
|
1326
|
+
*
|
|
1327
|
+
* @param uiState - The UI state.
|
|
1328
|
+
*/
|
|
1164
1329
|
#handleUiStateChange = async (uiState) => {
|
|
1165
1330
|
if (this.#timeoutDuration !== null) {
|
|
1166
1331
|
this.#setTimeout(uiState);
|
|
@@ -1185,14 +1350,26 @@ class BlinkIdUxManager {
|
|
|
1185
1350
|
return;
|
|
1186
1351
|
}
|
|
1187
1352
|
};
|
|
1353
|
+
/**
|
|
1354
|
+
* Extracts the document class info from the process result.
|
|
1355
|
+
*
|
|
1356
|
+
* @param processResult - The process result.
|
|
1357
|
+
* @returns The document class info.
|
|
1358
|
+
*/
|
|
1188
1359
|
#extractDocumentClassInfo(processResult) {
|
|
1189
1360
|
return processResult.inputImageAnalysisResult.documentClassInfo;
|
|
1190
1361
|
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Checks if the document class is classified.
|
|
1364
|
+
*
|
|
1365
|
+
* @param documentClassInfo - The document class info.
|
|
1366
|
+
* @returns Whether the document class is classified.
|
|
1367
|
+
*/
|
|
1191
1368
|
#isDocumentClassified(documentClassInfo) {
|
|
1192
1369
|
return documentClassInfo?.country !== void 0 && documentClassInfo?.type !== void 0;
|
|
1193
1370
|
}
|
|
1194
1371
|
/**
|
|
1195
|
-
* Clears
|
|
1372
|
+
* Clears the scanning session timeout.
|
|
1196
1373
|
*/
|
|
1197
1374
|
clearScanTimeout = () => {
|
|
1198
1375
|
if (!this.#timeoutId) {
|
|
@@ -1202,9 +1379,9 @@ class BlinkIdUxManager {
|
|
|
1202
1379
|
window.clearTimeout(this.#timeoutId);
|
|
1203
1380
|
};
|
|
1204
1381
|
/**
|
|
1205
|
-
* Resets the
|
|
1382
|
+
* Resets the BlinkIdUxManager.
|
|
1206
1383
|
*
|
|
1207
|
-
* Does not reset the camera manager or the
|
|
1384
|
+
* Does not reset the camera manager or the scanning session.
|
|
1208
1385
|
*/
|
|
1209
1386
|
reset() {
|
|
1210
1387
|
this.clearScanTimeout();
|