veryfi-lens-wasm 3.5.0 → 3.5.2
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/README.md +1 -0
- package/components/blueprintsModal.js +10 -9
- package/components/captureButton.js +2 -1
- package/components/checkOverlay.js +3 -5
- package/components/createFileUpload.js +3 -3
- package/components/desktopModeModal.js +5 -3
- package/components/liquid-glass.js +34 -31
- package/components/modalBase.js +5 -5
- package/components/prescriptionLabelGuide.js +2 -2
- package/components/reviewGallery.js +36 -17
- package/components/uploadDropZone.js +3 -3
- package/core/api.js +3 -1
- package/core/capture/prescription_label.js +2 -1
- package/core/capture-store.js +30 -0
- package/core/constants.js +1 -1
- package/core/lifecycle.js +2 -0
- package/core/review-flow.js +7 -0
- package/core/state.js +2 -0
- package/core/theme.js +156 -0
- package/flavors/document.js +2 -7
- package/package.json +5 -5
- package/veryfi-lens.js +20 -2
package/README.md
CHANGED
|
@@ -110,6 +110,7 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
|
|
|
110
110
|
|---|---|---|---|
|
|
111
111
|
| `lensFlavor` | `string` | — | **Required.** Capture mode (see [Supported Flavors](#supported-flavors)) |
|
|
112
112
|
| `container` | `string` | — | ID of an HTML element to render into. If omitted, creates a fullscreen overlay |
|
|
113
|
+
| `theme` | `"light"\|"dark"\|"system"` | `"system"` | UI color theme. `"system"` follows OS changes while the lens is open |
|
|
113
114
|
| `enableSubmit` | `boolean` | `true` | Show submit button after capture |
|
|
114
115
|
| `enableFullScreen` | `boolean` | `false` | Enable fullscreen mode |
|
|
115
116
|
| `debug_mode` | `boolean` | `false` | Enable console logging |
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ensureSpinKeyframes, releaseSpinKeyframes } from './shared-styles.js';
|
|
2
|
+
import { LIQUID_GLASS } from './liquid-glass.js';
|
|
2
3
|
|
|
3
4
|
export const createBlueprintsModal = (container, onSelect, onClose, options = {}) => {
|
|
4
5
|
const modal = document.createElement('div');
|
|
@@ -19,14 +20,14 @@ export const createBlueprintsModal = (container, onSelect, onClose, options = {}
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
const contentStyles = {
|
|
22
|
-
backgroundColor:
|
|
23
|
+
backgroundColor: LIQUID_GLASS.panelBackground,
|
|
23
24
|
borderRadius: '16px',
|
|
24
25
|
padding: '24px 28px',
|
|
25
26
|
maxWidth: '400px',
|
|
26
27
|
width: '90%',
|
|
27
28
|
maxHeight: '80vh',
|
|
28
29
|
overflow: 'auto',
|
|
29
|
-
textColor:
|
|
30
|
+
textColor: LIQUID_GLASS.panelText,
|
|
30
31
|
textFontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
|
|
31
32
|
textFontSize: '17px',
|
|
32
33
|
buttonPadding: '14px 24px',
|
|
@@ -36,12 +37,12 @@ export const createBlueprintsModal = (container, onSelect, onClose, options = {}
|
|
|
36
37
|
buttonFontWeight: '700',
|
|
37
38
|
primaryButtonBackground: '#00AA00',
|
|
38
39
|
primaryButtonColor: 'white',
|
|
39
|
-
secondaryButtonBackground:
|
|
40
|
-
secondaryButtonBorder:
|
|
41
|
-
secondaryButtonColor:
|
|
42
|
-
itemBackground: '#f8f9fa',
|
|
43
|
-
itemHoverBackground: '#e9ecef',
|
|
44
|
-
itemSelectedBackground: '#d4edda',
|
|
40
|
+
secondaryButtonBackground: LIQUID_GLASS.secondaryBackground,
|
|
41
|
+
secondaryButtonBorder: LIQUID_GLASS.secondaryBorder,
|
|
42
|
+
secondaryButtonColor: LIQUID_GLASS.panelText,
|
|
43
|
+
itemBackground: 'var(--veryfi-blueprint-item-background, #f8f9fa)',
|
|
44
|
+
itemHoverBackground: 'var(--veryfi-blueprint-item-hover, #e9ecef)',
|
|
45
|
+
itemSelectedBackground: 'var(--veryfi-blueprint-item-selected, #d4edda)',
|
|
45
46
|
itemBorderRadius: '6px',
|
|
46
47
|
};
|
|
47
48
|
|
|
@@ -82,7 +83,7 @@ export const createBlueprintsModal = (container, onSelect, onClose, options = {}
|
|
|
82
83
|
<div style="
|
|
83
84
|
width: 40px;
|
|
84
85
|
height: 40px;
|
|
85
|
-
border: 3px solid #f3f3f3;
|
|
86
|
+
border: 3px solid var(--veryfi-review-border, #f3f3f3);
|
|
86
87
|
border-top: 3px solid ${contentStyles.primaryButtonBackground};
|
|
87
88
|
border-radius: 50%;
|
|
88
89
|
margin: 20px auto;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const CAPTURE_BUTTON_BACKGROUND = 'var(--capture-button-background-color, #FFFFFF)';
|
|
1
2
|
export const createCaptureButton = (container, onCapture, onStopStitching) => {
|
|
2
3
|
const button = document.createElement('button');
|
|
3
4
|
button.id = 'veryfi-capture-button';
|
|
@@ -50,7 +51,7 @@ export const createCaptureButton = (container, onCapture, onStopStitching) => {
|
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
button.addEventListener('mouseleave', () => {
|
|
53
|
-
button.style.backgroundColor =
|
|
54
|
+
button.style.backgroundColor = CAPTURE_BUTTON_BACKGROUND;
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
let isStitching = false;
|
|
@@ -14,8 +14,8 @@ export const createCheckOverlay = (container, options = {}) => {
|
|
|
14
14
|
const tipFontFamily = options.tipFontFamily || "Arial, sans-serif";
|
|
15
15
|
const tipFontSize = options.tipFontSize || "16px";
|
|
16
16
|
const tipFontWeight = options.tipFontWeight || "bold";
|
|
17
|
-
const tipColor = options.tipColor || "
|
|
18
|
-
const tipTextShadow = options.tipTextShadow || "
|
|
17
|
+
const tipColor = options.tipColor || "var(--veryfi-panel-text, #1e293b)";
|
|
18
|
+
const tipTextShadow = options.tipTextShadow || "none";
|
|
19
19
|
const tipOffset = options.tipOffset || "35%";
|
|
20
20
|
|
|
21
21
|
const rectHole = document.createElement("div");
|
|
@@ -116,11 +116,9 @@ export const createCheckOverlay = (container, options = {}) => {
|
|
|
116
116
|
zIndex: "1004",
|
|
117
117
|
textShadow: tipTextShadow,
|
|
118
118
|
whiteSpace: "nowrap",
|
|
119
|
-
backgroundColor: "rgba(255, 255, 255, 0.85)",
|
|
120
|
-
color: "#333",
|
|
119
|
+
backgroundColor: "var(--veryfi-panel-background, rgba(255, 255, 255, 0.85))",
|
|
121
120
|
padding: "6px 14px",
|
|
122
121
|
borderRadius: "20px",
|
|
123
|
-
textShadow: "none",
|
|
124
122
|
});
|
|
125
123
|
|
|
126
124
|
switch (tipPosition) {
|
|
@@ -26,10 +26,10 @@ export function createFileUpload(container, captureUploaded, onSubmit, options =
|
|
|
26
26
|
uploadZoneWidth: '500px',
|
|
27
27
|
uploadZoneMaxWidth: '500px',
|
|
28
28
|
uploadZoneHeight: '100px',
|
|
29
|
-
uploadZoneBorder: '2px dashed #ccc',
|
|
29
|
+
uploadZoneBorder: '2px dashed var(--veryfi-upload-zone-border, #ccc)',
|
|
30
30
|
uploadZoneBorderRadius: '5px',
|
|
31
|
-
uploadZoneBackgroundColor: 'rgba(255, 255, 255, 0.8)',
|
|
32
|
-
uploadZoneColor: 'black',
|
|
31
|
+
uploadZoneBackgroundColor: 'var(--veryfi-upload-zone-background, rgba(255, 255, 255, 0.8))',
|
|
32
|
+
uploadZoneColor: 'var(--veryfi-upload-zone-text, black)',
|
|
33
33
|
uploadZoneFontFamily: 'sans-serif',
|
|
34
34
|
buttonPadding: '10px 20px',
|
|
35
35
|
buttonBackgroundColor: '#4CAF50',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LIQUID_GLASS } from './liquid-glass.js';
|
|
2
|
+
import { registerThemedElement } from '../core/theme.js';
|
|
2
3
|
|
|
3
4
|
const WIDE_VIEWPORT_THRESHOLD = 900;
|
|
4
5
|
const MODAL_ID = 'veryfi-desktop-mode-modal';
|
|
@@ -66,7 +67,7 @@ const ensureStyles = () => {
|
|
|
66
67
|
background: ${LIQUID_GLASS.darkPanelBackground};
|
|
67
68
|
backdrop-filter: ${LIQUID_GLASS.blur};
|
|
68
69
|
-webkit-backdrop-filter: ${LIQUID_GLASS.blur};
|
|
69
|
-
color:
|
|
70
|
+
color: ${LIQUID_GLASS.panelText};
|
|
70
71
|
border-radius: 20px;
|
|
71
72
|
border: ${LIQUID_GLASS.darkBorder};
|
|
72
73
|
box-shadow: ${LIQUID_GLASS.darkPanelBoxShadow};
|
|
@@ -85,7 +86,7 @@ const ensureStyles = () => {
|
|
|
85
86
|
border-radius: 999px;
|
|
86
87
|
border: none;
|
|
87
88
|
background: transparent;
|
|
88
|
-
color:
|
|
89
|
+
color: ${LIQUID_GLASS.panelMutedText};
|
|
89
90
|
cursor: pointer;
|
|
90
91
|
padding: 0;
|
|
91
92
|
transition: background-color 0.15s, color 0.15s;
|
|
@@ -116,7 +117,7 @@ const ensureStyles = () => {
|
|
|
116
117
|
#${MODAL_ID} .veryfi-dm-body {
|
|
117
118
|
font-size: 14px;
|
|
118
119
|
line-height: 1.5;
|
|
119
|
-
color:
|
|
120
|
+
color: ${LIQUID_GLASS.panelMutedText};
|
|
120
121
|
margin: 0 0 20px 0;
|
|
121
122
|
}
|
|
122
123
|
#${MODAL_ID} .veryfi-dm-reload {
|
|
@@ -175,6 +176,7 @@ const ensureStyles = () => {
|
|
|
175
176
|
const createModalNode = () => {
|
|
176
177
|
const root = document.createElement('div');
|
|
177
178
|
root.id = MODAL_ID;
|
|
179
|
+
registerThemedElement(root);
|
|
178
180
|
root.setAttribute('role', 'dialog');
|
|
179
181
|
root.setAttribute('aria-modal', 'true');
|
|
180
182
|
root.innerHTML = `
|
|
@@ -4,25 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
export const LIQUID_GLASS = {
|
|
6
6
|
// Translucent fill for dark-on-camera controls (idle / hover / active).
|
|
7
|
-
backgroundColor: 'rgba(255, 255, 255, 0.12)',
|
|
8
|
-
hoverBackgroundColor: 'rgba(255, 255, 255, 0.24)',
|
|
9
|
-
activeBackgroundColor: 'rgba(255, 255, 255, 0.34)',
|
|
10
|
-
//
|
|
11
|
-
panelBackground: 'rgba(250, 250, 252, 0.
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
backgroundColor: 'var(--veryfi-control-background, rgba(255, 255, 255, 0.12))',
|
|
8
|
+
hoverBackgroundColor: 'var(--veryfi-control-hover-background, rgba(255, 255, 255, 0.24))',
|
|
9
|
+
activeBackgroundColor: 'var(--veryfi-control-active-background, rgba(255, 255, 255, 0.34))',
|
|
10
|
+
// Theme-aware frosted panel colors.
|
|
11
|
+
panelBackground: 'var(--veryfi-panel-background, rgba(250, 250, 252, 0.88))',
|
|
12
|
+
darkPanelBackground: 'var(--veryfi-panel-background, rgba(30, 41, 59, 0.88))',
|
|
13
|
+
panelText: 'var(--veryfi-panel-text, #1e293b)',
|
|
14
|
+
panelMutedText: 'var(--veryfi-panel-muted-text, #475569)',
|
|
15
|
+
secondaryBackground: 'var(--veryfi-panel-secondary-background, rgba(255, 255, 255, 0.45))',
|
|
16
|
+
secondaryBorder: 'var(--veryfi-panel-secondary-border, 1px solid rgba(0, 0, 0, 0.12))',
|
|
14
17
|
// Heavy blur + saturation is what produces the "liquid" refraction.
|
|
15
18
|
blur: 'blur(18px) saturate(180%)',
|
|
16
19
|
// Bright hairline edge.
|
|
17
|
-
border: '1px solid rgba(255, 255, 255, 0.5)',
|
|
18
|
-
darkBorder: '1px solid rgba(255, 255, 255, 0.14)',
|
|
20
|
+
border: 'var(--veryfi-panel-border, 1px solid rgba(255, 255, 255, 0.5))',
|
|
21
|
+
darkBorder: 'var(--veryfi-panel-border, 1px solid rgba(255, 255, 255, 0.14))',
|
|
19
22
|
// Outer float shadow + inner specular highlights (bright top, soft bottom).
|
|
20
23
|
boxShadow:
|
|
21
24
|
'0 8px 32px rgba(0, 0, 0, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.65), inset 0 -2px 6px rgba(255, 255, 255, 0.12)',
|
|
22
|
-
panelBoxShadow:
|
|
23
|
-
|
|
24
|
-
darkPanelBoxShadow:
|
|
25
|
-
'0 16px 48px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.22), inset 0 -2px 8px rgba(0, 0, 0, 0.25)',
|
|
25
|
+
panelBoxShadow: 'var(--veryfi-panel-shadow, 0 16px 48px rgba(0, 0, 0, 0.28))',
|
|
26
|
+
darkPanelBoxShadow: 'var(--veryfi-panel-shadow, 0 16px 48px rgba(0, 0, 0, 0.45))',
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
// Inline-style fragment for on-camera glass controls (buttons, toggles).
|
|
@@ -40,25 +41,27 @@ export const liquidGlassStyles = (overrides = {}) => ({
|
|
|
40
41
|
// Light review-gallery surface (wireframe: pale sage background, white cards,
|
|
41
42
|
// dark icons). Use reviewGalleryStyles() to spread into gallery components.
|
|
42
43
|
export const REVIEW_LIGHT = {
|
|
43
|
-
background: '#E8EBE6',
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
background: 'var(--veryfi-review-background, #E8EBE6)',
|
|
45
|
+
chromeBackground: 'var(--veryfi-review-chrome-background, #E8EBE6)',
|
|
46
|
+
cardBackground: 'var(--veryfi-review-card-background, #FFFFFF)',
|
|
47
|
+
textColor: 'var(--veryfi-review-text, #1A1A1A)',
|
|
48
|
+
iconColor: 'var(--veryfi-review-text, #1A1A1A)',
|
|
49
|
+
mutedText: 'var(--veryfi-review-muted-text, rgba(26, 26, 26, 0.55))',
|
|
50
|
+
border: '1px solid var(--veryfi-review-border, rgba(0, 0, 0, 0.08))',
|
|
51
|
+
tileBorder: '2px solid var(--veryfi-review-tile-border, #FFFFFF)',
|
|
52
|
+
addTileBorder: '2px dashed var(--veryfi-review-add-border, rgba(0, 0, 0, 0.25))',
|
|
53
|
+
addTileBackground: 'var(--veryfi-review-add-background, rgba(255, 255, 255, 0.6))',
|
|
54
|
+
stripBorder: 'var(--veryfi-review-border, rgba(0, 0, 0, 0.08))',
|
|
53
55
|
toolbarButtonBackground: 'transparent',
|
|
54
|
-
toolbarButtonColor: '#1A1A1A',
|
|
55
|
-
cropBackground: '#E8EBE6',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
toolbarButtonColor: 'var(--veryfi-review-text, #1A1A1A)',
|
|
57
|
+
cropBackground: 'var(--veryfi-review-background, #E8EBE6)',
|
|
58
|
+
cropBarBackground: 'var(--veryfi-review-crop-bar-background, #FFFFFF)',
|
|
59
|
+
cropCancelColor: 'var(--veryfi-review-crop-cancel, #8B2942)',
|
|
60
|
+
cropCancelBorder: '1px solid var(--veryfi-review-crop-cancel, #8B2942)',
|
|
61
|
+
cropApplyBackground: 'var(--veryfi-review-crop-apply-background, #1A2332)',
|
|
62
|
+
cropApplyColor: 'var(--veryfi-review-crop-apply-text, #FFFFFF)',
|
|
63
|
+
loadingOverlay: 'var(--veryfi-review-loading-background, rgba(232, 235, 230, 0.72))',
|
|
64
|
+
loadingText: 'var(--veryfi-review-text, #1A1A1A)',
|
|
62
65
|
};
|
|
63
66
|
|
|
64
67
|
export const reviewGalleryStyles = (overrides = {}) => ({
|
package/components/modalBase.js
CHANGED
|
@@ -12,7 +12,7 @@ const DEFAULT_STYLES = {
|
|
|
12
12
|
borderRadius: '20px',
|
|
13
13
|
padding: '24px 28px',
|
|
14
14
|
maxWidth: '300px',
|
|
15
|
-
textColor:
|
|
15
|
+
textColor: LIQUID_GLASS.panelText,
|
|
16
16
|
textFontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
|
|
17
17
|
textFontSize: '17px',
|
|
18
18
|
buttonWidth: '100%',
|
|
@@ -24,11 +24,11 @@ const DEFAULT_STYLES = {
|
|
|
24
24
|
primaryButtonBackground: '#00AA00',
|
|
25
25
|
primaryButtonColor: 'white',
|
|
26
26
|
primaryButtonBoxShadow: LIQUID_GLASS.boxShadow,
|
|
27
|
-
secondaryButtonBackground:
|
|
28
|
-
secondaryButtonBorder:
|
|
29
|
-
secondaryButtonColor:
|
|
27
|
+
secondaryButtonBackground: LIQUID_GLASS.secondaryBackground,
|
|
28
|
+
secondaryButtonBorder: LIQUID_GLASS.secondaryBorder,
|
|
29
|
+
secondaryButtonColor: LIQUID_GLASS.panelText,
|
|
30
30
|
panelBackdropFilter: LIQUID_GLASS.blur,
|
|
31
|
-
panelBorder:
|
|
31
|
+
panelBorder: LIQUID_GLASS.darkBorder,
|
|
32
32
|
panelBoxShadow: LIQUID_GLASS.panelBoxShadow,
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -53,7 +53,7 @@ export const createPrescriptionLabelGuide = (container, options = {}) => {
|
|
|
53
53
|
WebkitBackdropFilter: LIQUID_GLASS.blur,
|
|
54
54
|
border: LIQUID_GLASS.darkBorder,
|
|
55
55
|
boxShadow: LIQUID_GLASS.darkPanelBoxShadow,
|
|
56
|
-
color:
|
|
56
|
+
color: LIQUID_GLASS.panelText,
|
|
57
57
|
borderRadius: '20px',
|
|
58
58
|
fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
|
|
59
59
|
fontSize: '14px',
|
|
@@ -94,7 +94,7 @@ export const createPrescriptionLabelGuide = (container, options = {}) => {
|
|
|
94
94
|
justifyContent: 'center',
|
|
95
95
|
border: 'none',
|
|
96
96
|
background: 'transparent',
|
|
97
|
-
color:
|
|
97
|
+
color: LIQUID_GLASS.panelText,
|
|
98
98
|
cursor: 'pointer',
|
|
99
99
|
opacity: '0.85',
|
|
100
100
|
pointerEvents: 'auto',
|
|
@@ -189,7 +189,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
189
189
|
display: 'none',
|
|
190
190
|
flexDirection: 'column',
|
|
191
191
|
zIndex: 'var(--review-gallery-z-index, 1200)',
|
|
192
|
-
background:
|
|
192
|
+
background: `var(--review-gallery-background, ${REVIEW_LIGHT.background})`,
|
|
193
193
|
pointerEvents: 'auto',
|
|
194
194
|
fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
|
|
195
195
|
color: REVIEW_LIGHT.textColor,
|
|
@@ -229,6 +229,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
229
229
|
// Clear the status bar / notch on mobile.
|
|
230
230
|
padding: 'calc(14px + env(safe-area-inset-top, 0px)) 16px 14px',
|
|
231
231
|
color: REVIEW_LIGHT.textColor,
|
|
232
|
+
background: REVIEW_LIGHT.chromeBackground,
|
|
232
233
|
flex: '0 0 auto',
|
|
233
234
|
});
|
|
234
235
|
|
|
@@ -288,6 +289,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
288
289
|
justifyContent: 'stretch',
|
|
289
290
|
alignItems: 'center',
|
|
290
291
|
padding: '12px 16px calc(12px + env(safe-area-inset-bottom, 0px))',
|
|
292
|
+
background: REVIEW_LIGHT.chromeBackground,
|
|
291
293
|
flex: '0 0 auto',
|
|
292
294
|
});
|
|
293
295
|
|
|
@@ -443,7 +445,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
443
445
|
display: 'flex',
|
|
444
446
|
alignItems: 'center',
|
|
445
447
|
justifyContent: 'center',
|
|
446
|
-
color: danger ? '#C62828' : REVIEW_LIGHT.toolbarButtonColor,
|
|
448
|
+
color: danger ? 'var(--veryfi-danger-color, #C62828)' : REVIEW_LIGHT.toolbarButtonColor,
|
|
447
449
|
borderRadius: '50%',
|
|
448
450
|
cursor: 'pointer',
|
|
449
451
|
border: 'none',
|
|
@@ -567,7 +569,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
567
569
|
justifyContent: 'center',
|
|
568
570
|
padding: '12px 16px calc(12px + env(safe-area-inset-bottom, 0px))',
|
|
569
571
|
flex: '0 0 auto',
|
|
570
|
-
background:
|
|
572
|
+
background: REVIEW_LIGHT.cropBarBackground,
|
|
571
573
|
});
|
|
572
574
|
const cancelBtn = document.createElement('button');
|
|
573
575
|
cancelBtn.textContent = 'CANCEL';
|
|
@@ -575,7 +577,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
575
577
|
flex: '1 1 0',
|
|
576
578
|
padding: '14px 24px',
|
|
577
579
|
borderRadius: '28px',
|
|
578
|
-
background:
|
|
580
|
+
background: REVIEW_LIGHT.cropBarBackground,
|
|
579
581
|
color: REVIEW_LIGHT.cropCancelColor,
|
|
580
582
|
border: REVIEW_LIGHT.cropCancelBorder,
|
|
581
583
|
fontWeight: '700',
|
|
@@ -731,8 +733,9 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
731
733
|
return img;
|
|
732
734
|
};
|
|
733
735
|
|
|
734
|
-
// Dashed "+" tile used to add a document (strip) or a page (grid).
|
|
735
|
-
|
|
736
|
+
// Dashed "+" tile used to add a document (strip) or a page (grid). The grid
|
|
737
|
+
// tile is much larger than the strip tile, so type sizes are passed in.
|
|
738
|
+
const buildAddTile = (label, onClick, sizeStyle = {}, { plusSize = '26px', labelSize = '11px' } = {}) => {
|
|
736
739
|
const tile = document.createElement('button');
|
|
737
740
|
tile.classList.add('veryfi-rg-tile');
|
|
738
741
|
Object.assign(tile.style, {
|
|
@@ -752,11 +755,11 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
752
755
|
});
|
|
753
756
|
const plus = document.createElement('span');
|
|
754
757
|
plus.textContent = '+';
|
|
755
|
-
Object.assign(plus.style, { fontSize:
|
|
758
|
+
Object.assign(plus.style, { fontSize: plusSize, lineHeight: '1', fontWeight: '400' });
|
|
756
759
|
const lbl = document.createElement('span');
|
|
757
760
|
lbl.textContent = label;
|
|
758
761
|
Object.assign(lbl.style, {
|
|
759
|
-
fontSize:
|
|
762
|
+
fontSize: labelSize,
|
|
760
763
|
fontWeight: '600',
|
|
761
764
|
textAlign: 'center',
|
|
762
765
|
lineHeight: '1.1',
|
|
@@ -847,7 +850,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
847
850
|
flexDirection: 'column',
|
|
848
851
|
alignItems: 'center',
|
|
849
852
|
justifyContent: 'center',
|
|
850
|
-
|
|
853
|
+
height: '100%',
|
|
851
854
|
minHeight: '100%',
|
|
852
855
|
});
|
|
853
856
|
|
|
@@ -855,21 +858,28 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
855
858
|
Object.assign(media.style, {
|
|
856
859
|
position: 'relative',
|
|
857
860
|
width: '100%',
|
|
861
|
+
// Fill the grid area so the document can use every available pixel of
|
|
862
|
+
// vertical space; minHeight:0 lets it shrink inside the flex column.
|
|
863
|
+
flex: '1 1 auto',
|
|
864
|
+
minHeight: '0',
|
|
858
865
|
display: 'flex',
|
|
859
866
|
alignItems: 'center',
|
|
860
867
|
justifyContent: 'center',
|
|
861
868
|
// Not clipped: field-detection overlays (scan caption, field pills) extend
|
|
862
869
|
// just outside the image bounds.
|
|
863
870
|
overflow: 'visible',
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
871
|
+
// No card behind the document — it would show as borders around a capture
|
|
872
|
+
// whose aspect ratio doesn't match the area.
|
|
873
|
+
background: 'transparent',
|
|
867
874
|
});
|
|
868
875
|
const thumb = buildPageThumb(page);
|
|
869
|
-
//
|
|
870
|
-
Object.assign(thumb.style, {
|
|
871
|
-
|
|
872
|
-
|
|
876
|
+
// Scale to the available area while keeping the capture's aspect ratio.
|
|
877
|
+
Object.assign(thumb.style, {
|
|
878
|
+
width: 'auto',
|
|
879
|
+
height: 'auto',
|
|
880
|
+
maxWidth: '100%',
|
|
881
|
+
maxHeight: '100%',
|
|
882
|
+
});
|
|
873
883
|
if (thumb.tagName === 'VIDEO') thumb.controls = true;
|
|
874
884
|
thumb.addEventListener('click', (e) => e.stopPropagation());
|
|
875
885
|
media.appendChild(thumb);
|
|
@@ -1029,6 +1039,9 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
1029
1039
|
|
|
1030
1040
|
if (detailIndex !== null) {
|
|
1031
1041
|
gridEl.style.gridTemplateColumns = '1fr';
|
|
1042
|
+
// Let the single detail row fill the scroll area instead of hugging its
|
|
1043
|
+
// content, so the document gets the full height.
|
|
1044
|
+
gridEl.style.alignContent = 'stretch';
|
|
1032
1045
|
// Clicking the backdrop (anywhere in the grid area that isn't the toolbar
|
|
1033
1046
|
// or the image — including below the image) returns to the gallery grid.
|
|
1034
1047
|
// Only when there is a grid to go back to.
|
|
@@ -1044,6 +1057,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
1044
1057
|
return;
|
|
1045
1058
|
}
|
|
1046
1059
|
gridEl.onclick = null;
|
|
1060
|
+
gridEl.style.alignContent = 'start';
|
|
1047
1061
|
|
|
1048
1062
|
// Stacked layout: one full-width preview per row (landscape captures such as
|
|
1049
1063
|
// checks read better this way). Otherwise a responsive multi-column grid.
|
|
@@ -1056,7 +1070,12 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
1056
1070
|
gridEl.appendChild(tile);
|
|
1057
1071
|
});
|
|
1058
1072
|
if (allowAddPageNow) {
|
|
1059
|
-
const addTile = buildAddTile(
|
|
1073
|
+
const addTile = buildAddTile(
|
|
1074
|
+
o.addPageText,
|
|
1075
|
+
() => callbacks.onAddPage?.(),
|
|
1076
|
+
{ aspectRatio: o.pageAspectRatio },
|
|
1077
|
+
{ plusSize: '40px', labelSize: '16px' }
|
|
1078
|
+
);
|
|
1060
1079
|
addTile.style.animationDelay = `${pages.length * 45}ms`;
|
|
1061
1080
|
gridEl.appendChild(addTile);
|
|
1062
1081
|
}
|
|
@@ -29,16 +29,16 @@ export const createUploadDropZone = (parentElement, styles, options = {}) => {
|
|
|
29
29
|
|
|
30
30
|
uploadZone.addEventListener('dragover', (e) => {
|
|
31
31
|
e.preventDefault();
|
|
32
|
-
uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color-active, #000)';
|
|
32
|
+
uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color-active, var(--veryfi-panel-text, #000))';
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
uploadZone.addEventListener('dragleave', () => {
|
|
36
|
-
uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color, #ccc)';
|
|
36
|
+
uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color, var(--veryfi-upload-zone-border, #ccc))';
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
uploadZone.addEventListener('drop', (e) => {
|
|
40
40
|
e.preventDefault();
|
|
41
|
-
uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color, #ccc)';
|
|
41
|
+
uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color, var(--veryfi-upload-zone-border, #ccc))';
|
|
42
42
|
if (e.dataTransfer.files.length && onFileSelected) {
|
|
43
43
|
onFileSelected(e.dataTransfer.files[0]);
|
|
44
44
|
}
|
package/core/api.js
CHANGED
|
@@ -205,6 +205,7 @@ export const uploadPackage = async () => {
|
|
|
205
205
|
const uploadId = state.packageUploadId;
|
|
206
206
|
const clientId = state.clientId;
|
|
207
207
|
const sessionId = state.clientData?.session;
|
|
208
|
+
const qrSessionId = getQrSessionId();
|
|
208
209
|
|
|
209
210
|
if (!scans?.length) {
|
|
210
211
|
throw new Error('No scans to upload');
|
|
@@ -234,7 +235,8 @@ export const uploadPackage = async () => {
|
|
|
234
235
|
method: "POST",
|
|
235
236
|
headers: {
|
|
236
237
|
"CLIENT-ID": clientId,
|
|
237
|
-
"SESSION-ID": sessionId
|
|
238
|
+
"SESSION-ID": sessionId,
|
|
239
|
+
...(qrSessionId ? { 'QR-SESSION-ID': qrSessionId } : {})
|
|
238
240
|
},
|
|
239
241
|
body: formData
|
|
240
242
|
}
|
|
@@ -2,6 +2,7 @@ import { state } from '../state.js';
|
|
|
2
2
|
import { hideVideoOverlay, showVideoOverlay } from '../overlay-controls.js';
|
|
3
3
|
import { newStartLens } from '../lifecycle.js';
|
|
4
4
|
import { DEFAULTS } from '../constants.js';
|
|
5
|
+
import { CAPTURE_BUTTON_BACKGROUND } from '../../components/captureButton.js';
|
|
5
6
|
|
|
6
7
|
let previewRecorder = null;
|
|
7
8
|
let previewChunks = [];
|
|
@@ -47,7 +48,7 @@ const updateRecordingUI = (recording, progressFillMode = false) => {
|
|
|
47
48
|
<rect x="6" y="6" width="12" height="12" rx="2"/>
|
|
48
49
|
</svg>`;
|
|
49
50
|
} else {
|
|
50
|
-
captureBtn.style.backgroundColor =
|
|
51
|
+
captureBtn.style.backgroundColor = CAPTURE_BUTTON_BACKGROUND;
|
|
51
52
|
captureBtn.innerHTML = '';
|
|
52
53
|
}
|
|
53
54
|
}
|
package/core/capture-store.js
CHANGED
|
@@ -40,8 +40,34 @@ export const createDocument = (kind = 'image') => ({
|
|
|
40
40
|
id: genId(),
|
|
41
41
|
kind,
|
|
42
42
|
pages: [],
|
|
43
|
+
submitted: false,
|
|
44
|
+
submitResult: null,
|
|
43
45
|
});
|
|
44
46
|
|
|
47
|
+
// Submission bookkeeping: a batch submit uploads documents one by one, so a
|
|
48
|
+
// failure partway through leaves earlier documents already accepted by the
|
|
49
|
+
// backend. Marking them keeps a retry from creating duplicates. Editing a
|
|
50
|
+
// document's pages clears the mark, since the edited version was never sent.
|
|
51
|
+
export const markDocumentSubmitted = (docIndex, result = null) => {
|
|
52
|
+
const doc = state.capturedDocs[docIndex];
|
|
53
|
+
if (!doc) return;
|
|
54
|
+
doc.submitted = true;
|
|
55
|
+
doc.submitResult = result;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const isDocumentSubmitted = (docIndex) =>
|
|
59
|
+
!!state.capturedDocs[docIndex]?.submitted;
|
|
60
|
+
|
|
61
|
+
export const submitResultOf = (docIndex) =>
|
|
62
|
+
state.capturedDocs[docIndex]?.submitResult ?? null;
|
|
63
|
+
|
|
64
|
+
const clearDocumentSubmitted = (docIndex) => {
|
|
65
|
+
const doc = state.capturedDocs[docIndex];
|
|
66
|
+
if (!doc) return;
|
|
67
|
+
doc.submitted = false;
|
|
68
|
+
doc.submitResult = null;
|
|
69
|
+
};
|
|
70
|
+
|
|
45
71
|
export const resetStore = () => {
|
|
46
72
|
state.capturedDocs = [];
|
|
47
73
|
state.activeDocIndex = -1;
|
|
@@ -115,6 +141,7 @@ export const addPage = (page, docIndex = state.activeDocIndex) => {
|
|
|
115
141
|
if (!canAddPage(docIndex)) return null;
|
|
116
142
|
const normalized = normalizePage(page);
|
|
117
143
|
doc.pages.push(normalized);
|
|
144
|
+
clearDocumentSubmitted(docIndex);
|
|
118
145
|
return normalized;
|
|
119
146
|
};
|
|
120
147
|
|
|
@@ -124,6 +151,7 @@ export const replacePage = (target, page) => {
|
|
|
124
151
|
if (target.pageIndex < 0 || target.pageIndex >= doc.pages.length) return null;
|
|
125
152
|
const normalized = normalizePage(page);
|
|
126
153
|
doc.pages[target.pageIndex] = normalized;
|
|
154
|
+
clearDocumentSubmitted(target.docIndex);
|
|
127
155
|
return normalized;
|
|
128
156
|
};
|
|
129
157
|
|
|
@@ -135,7 +163,9 @@ export const removePage = (docIndex, pageIndex) => {
|
|
|
135
163
|
doc.pages.splice(pageIndex, 1);
|
|
136
164
|
if (doc.pages.length === 0) {
|
|
137
165
|
removeDocument(docIndex);
|
|
166
|
+
return;
|
|
138
167
|
}
|
|
168
|
+
clearDocumentSubmitted(docIndex);
|
|
139
169
|
};
|
|
140
170
|
|
|
141
171
|
// Add the next captured page, honoring an in-flight recapture target and a
|
package/core/constants.js
CHANGED
package/core/lifecycle.js
CHANGED
|
@@ -18,6 +18,7 @@ import { cleanupPrescriptionLabelRecording } from './capture/prescription_label.
|
|
|
18
18
|
import { installDesktopModeWatchdog, uninstallDesktopModeWatchdog } from '../components/desktopModeModal.js';
|
|
19
19
|
import { shouldRunFieldDetection } from './field-detection-policy.js';
|
|
20
20
|
import { hideCropPreview } from '../components/croppedImage.js';
|
|
21
|
+
import { clearTheme } from './theme.js';
|
|
21
22
|
|
|
22
23
|
export const newStartLens = async () => {
|
|
23
24
|
state.started = true;
|
|
@@ -285,6 +286,7 @@ export const removeOverlay = () => {
|
|
|
285
286
|
}
|
|
286
287
|
|
|
287
288
|
cleanupPrescriptionLabelRecording();
|
|
289
|
+
clearTheme();
|
|
288
290
|
|
|
289
291
|
if (state.usingOverlayContainer) {
|
|
290
292
|
stopLens();
|
package/core/review-flow.js
CHANGED
|
@@ -205,7 +205,14 @@ const submitAll = async () => {
|
|
|
205
205
|
const docCount = store.totalDocs();
|
|
206
206
|
let lastResult = null;
|
|
207
207
|
for (let i = 0; i < docCount; i += 1) {
|
|
208
|
+
// A retry after a partial failure resumes where it left off instead of
|
|
209
|
+
// re-uploading documents the backend already accepted.
|
|
210
|
+
if (store.isDocumentSubmitted(i)) {
|
|
211
|
+
lastResult = store.submitResultOf(i) ?? lastResult;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
208
214
|
lastResult = await submitOneDocument(i);
|
|
215
|
+
store.markDocumentSubmitted(i, lastResult);
|
|
209
216
|
}
|
|
210
217
|
if (state.batchReady) {
|
|
211
218
|
await finishBatch();
|
package/core/state.js
CHANGED
|
@@ -77,6 +77,7 @@ export const state = {
|
|
|
77
77
|
useDevApi: false,
|
|
78
78
|
|
|
79
79
|
// UI Configuration
|
|
80
|
+
theme: 'system',
|
|
80
81
|
torchButton: true,
|
|
81
82
|
switchCameraButton: true,
|
|
82
83
|
mirrorButton: true,
|
|
@@ -343,6 +344,7 @@ export const resetState = () => {
|
|
|
343
344
|
state.bottleCapText = MESSAGES.BOTTLE_CAP;
|
|
344
345
|
state.enforceAndSkipBothSides = false;
|
|
345
346
|
state.delayBetweenCaptures = 0;
|
|
347
|
+
state.theme = 'system';
|
|
346
348
|
|
|
347
349
|
// Reset UI references
|
|
348
350
|
state.videoOverlay = null;
|
package/core/theme.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const THEME_STYLE_ID = 'veryfi-theme-styles';
|
|
2
|
+
const VALID_THEMES = new Set(['light', 'dark', 'system']);
|
|
3
|
+
|
|
4
|
+
let mediaQuery = null;
|
|
5
|
+
let mediaQueryListener = null;
|
|
6
|
+
let requestedTheme = 'system';
|
|
7
|
+
let resolvedTheme = 'light';
|
|
8
|
+
const themedElements = new Set();
|
|
9
|
+
|
|
10
|
+
const THEME_VARIABLES = {
|
|
11
|
+
light: {
|
|
12
|
+
'--veryfi-control-background': 'rgba(255, 255, 255, 0.12)',
|
|
13
|
+
'--veryfi-control-hover-background': 'rgba(255, 255, 255, 0.24)',
|
|
14
|
+
'--veryfi-control-active-background': 'rgba(255, 255, 255, 0.34)',
|
|
15
|
+
'--veryfi-panel-background': 'rgba(250, 250, 252, 0.88)',
|
|
16
|
+
'--veryfi-panel-text': '#1e293b',
|
|
17
|
+
'--veryfi-panel-muted-text': '#475569',
|
|
18
|
+
'--veryfi-panel-secondary-background': 'rgba(255, 255, 255, 0.45)',
|
|
19
|
+
'--veryfi-panel-secondary-border': '1px solid rgba(0, 0, 0, 0.12)',
|
|
20
|
+
'--veryfi-panel-border': '1px solid rgba(255, 255, 255, 0.6)',
|
|
21
|
+
'--veryfi-panel-shadow': '0 16px 48px rgba(0, 0, 0, 0.28), inset 0 1px 1px rgba(255, 255, 255, 0.85), inset 0 -2px 8px rgba(255, 255, 255, 0.22)',
|
|
22
|
+
'--veryfi-review-background': '#E8EBE6',
|
|
23
|
+
'--veryfi-review-chrome-background': '#E8EBE6',
|
|
24
|
+
'--veryfi-review-card-background': '#FFFFFF',
|
|
25
|
+
'--veryfi-review-text': '#1A1A1A',
|
|
26
|
+
'--veryfi-review-muted-text': 'rgba(26, 26, 26, 0.55)',
|
|
27
|
+
'--veryfi-review-border': 'rgba(0, 0, 0, 0.08)',
|
|
28
|
+
'--veryfi-review-tile-border': '#FFFFFF',
|
|
29
|
+
'--veryfi-review-add-border': 'rgba(0, 0, 0, 0.25)',
|
|
30
|
+
'--veryfi-review-add-background': 'rgba(255, 255, 255, 0.6)',
|
|
31
|
+
'--veryfi-review-crop-bar-background': '#FFFFFF',
|
|
32
|
+
'--veryfi-review-crop-cancel': '#8B2942',
|
|
33
|
+
'--veryfi-review-crop-apply-background': '#1A2332',
|
|
34
|
+
'--veryfi-review-crop-apply-text': '#FFFFFF',
|
|
35
|
+
'--veryfi-review-loading-background': 'rgba(232, 235, 230, 0.72)',
|
|
36
|
+
'--veryfi-danger-color': '#C62828',
|
|
37
|
+
'--veryfi-upload-zone-background': 'rgba(255, 255, 255, 0.88)',
|
|
38
|
+
'--veryfi-upload-zone-text': '#111827',
|
|
39
|
+
'--veryfi-upload-zone-border': '#94A3B8',
|
|
40
|
+
'--veryfi-blueprint-item-background': '#F8F9FA',
|
|
41
|
+
'--veryfi-blueprint-item-hover': '#E9ECEF',
|
|
42
|
+
'--veryfi-blueprint-item-selected': '#D4EDDA',
|
|
43
|
+
},
|
|
44
|
+
dark: {
|
|
45
|
+
'--veryfi-control-background': 'rgba(15, 23, 42, 0.48)',
|
|
46
|
+
'--veryfi-control-hover-background': 'rgba(15, 23, 42, 0.68)',
|
|
47
|
+
'--veryfi-control-active-background': 'rgba(15, 23, 42, 0.82)',
|
|
48
|
+
'--veryfi-panel-background': 'rgba(30, 41, 59, 0.88)',
|
|
49
|
+
'--veryfi-panel-text': '#F8FAFC',
|
|
50
|
+
'--veryfi-panel-muted-text': '#CBD5E1',
|
|
51
|
+
'--veryfi-panel-secondary-background': 'rgba(255, 255, 255, 0.1)',
|
|
52
|
+
'--veryfi-panel-secondary-border': '1px solid rgba(255, 255, 255, 0.2)',
|
|
53
|
+
'--veryfi-panel-border': '1px solid rgba(255, 255, 255, 0.14)',
|
|
54
|
+
'--veryfi-panel-shadow': '0 16px 48px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.22), inset 0 -2px 8px rgba(0, 0, 0, 0.25)',
|
|
55
|
+
'--veryfi-review-background': '#45495F',
|
|
56
|
+
'--veryfi-review-chrome-background': '#171C3A',
|
|
57
|
+
'--veryfi-review-card-background': '#292E49',
|
|
58
|
+
'--veryfi-review-text': '#F8FAFC',
|
|
59
|
+
'--veryfi-review-muted-text': 'rgba(248, 250, 252, 0.62)',
|
|
60
|
+
'--veryfi-review-border': 'rgba(255, 255, 255, 0.12)',
|
|
61
|
+
'--veryfi-review-tile-border': '#292E49',
|
|
62
|
+
'--veryfi-review-add-border': '#FFFFFF',
|
|
63
|
+
'--veryfi-review-add-background': '#292E49',
|
|
64
|
+
'--veryfi-review-crop-bar-background': '#171C3A',
|
|
65
|
+
'--veryfi-review-crop-cancel': '#E73C4E',
|
|
66
|
+
'--veryfi-review-crop-apply-background': '#FFFFFF',
|
|
67
|
+
'--veryfi-review-crop-apply-text': '#171C3A',
|
|
68
|
+
'--veryfi-review-loading-background': 'rgba(69, 73, 95, 0.78)',
|
|
69
|
+
'--veryfi-danger-color': '#E73C4E',
|
|
70
|
+
'--veryfi-upload-zone-background': 'rgba(30, 41, 59, 0.92)',
|
|
71
|
+
'--veryfi-upload-zone-text': '#F8FAFC',
|
|
72
|
+
'--veryfi-upload-zone-border': '#64748B',
|
|
73
|
+
'--veryfi-blueprint-item-background': '#334155',
|
|
74
|
+
'--veryfi-blueprint-item-hover': '#475569',
|
|
75
|
+
'--veryfi-blueprint-item-selected': '#14532D',
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const ensureThemeStyles = () => {
|
|
80
|
+
if (document.getElementById(THEME_STYLE_ID)) return;
|
|
81
|
+
const style = document.createElement('style');
|
|
82
|
+
style.id = THEME_STYLE_ID;
|
|
83
|
+
style.textContent = Object.entries(THEME_VARIABLES)
|
|
84
|
+
.map(([theme, variables]) => `
|
|
85
|
+
[data-veryfi-theme="${theme}"] {
|
|
86
|
+
${Object.entries(variables).map(([name, value]) => `${name}: ${value};`).join('\n')}
|
|
87
|
+
color-scheme: ${theme};
|
|
88
|
+
}
|
|
89
|
+
`)
|
|
90
|
+
.join('\n');
|
|
91
|
+
document.head.appendChild(style);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const systemTheme = () =>
|
|
95
|
+
typeof window.matchMedia === 'function' &&
|
|
96
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
97
|
+
? 'dark'
|
|
98
|
+
: 'light';
|
|
99
|
+
|
|
100
|
+
const updateElements = () => {
|
|
101
|
+
resolvedTheme = requestedTheme === 'system' ? systemTheme() : requestedTheme;
|
|
102
|
+
themedElements.forEach((element) => {
|
|
103
|
+
if (element?.dataset) {
|
|
104
|
+
element.dataset.veryfiTheme = resolvedTheme;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const removeSystemListener = () => {
|
|
110
|
+
if (!mediaQuery || !mediaQueryListener) return;
|
|
111
|
+
if (typeof mediaQuery.removeEventListener === 'function') {
|
|
112
|
+
mediaQuery.removeEventListener('change', mediaQueryListener);
|
|
113
|
+
} else {
|
|
114
|
+
mediaQuery.removeListener?.(mediaQueryListener);
|
|
115
|
+
}
|
|
116
|
+
mediaQuery = null;
|
|
117
|
+
mediaQueryListener = null;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const isValidTheme = (theme) => VALID_THEMES.has(theme);
|
|
121
|
+
|
|
122
|
+
export const applyTheme = (element, theme = 'system') => {
|
|
123
|
+
if (!element || !isValidTheme(theme)) return;
|
|
124
|
+
ensureThemeStyles();
|
|
125
|
+
requestedTheme = theme;
|
|
126
|
+
themedElements.add(element);
|
|
127
|
+
removeSystemListener();
|
|
128
|
+
|
|
129
|
+
if (theme === 'system' && typeof window.matchMedia === 'function') {
|
|
130
|
+
mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
131
|
+
mediaQueryListener = updateElements;
|
|
132
|
+
if (typeof mediaQuery.addEventListener === 'function') {
|
|
133
|
+
mediaQuery.addEventListener('change', mediaQueryListener);
|
|
134
|
+
} else {
|
|
135
|
+
mediaQuery.addListener?.(mediaQueryListener);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
updateElements();
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const registerThemedElement = (element) => {
|
|
142
|
+
if (!element) return;
|
|
143
|
+
ensureThemeStyles();
|
|
144
|
+
themedElements.add(element);
|
|
145
|
+
element.dataset.veryfiTheme = resolvedTheme;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const clearTheme = () => {
|
|
149
|
+
removeSystemListener();
|
|
150
|
+
themedElements.forEach((element) => {
|
|
151
|
+
if (element?.dataset) delete element.dataset.veryfiTheme;
|
|
152
|
+
});
|
|
153
|
+
themedElements.clear();
|
|
154
|
+
requestedTheme = 'system';
|
|
155
|
+
resolvedTheme = systemTheme();
|
|
156
|
+
};
|
package/flavors/document.js
CHANGED
|
@@ -8,13 +8,8 @@ export const setup = async (state, refs, actions) => {
|
|
|
8
8
|
actions.handleDocumentAutoCaptureDone = handleDocumentAutoCaptureDone;
|
|
9
9
|
actions.logDocument = logDocument;
|
|
10
10
|
actions.checkIfDocumentOnCapture = checkIfDocumentOnCapture;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// single-document experience (collapsed Retake/Confirm) unless the partner
|
|
14
|
-
// opts into multi-page (maxPagesPerDocument) or multi-document capture
|
|
15
|
-
// (maxDocuments, or the legacy multiSubmission flag).
|
|
16
|
-
if (state.maxPagesPerDocument == null) state.maxPagesPerDocument = 1;
|
|
17
|
-
if (state.maxDocuments == null) state.maxDocuments = state.multiSubmission ? null : 1;
|
|
11
|
+
state.maxPagesPerDocument = 1;
|
|
12
|
+
state.maxDocuments = 1;
|
|
18
13
|
};
|
|
19
14
|
|
|
20
15
|
export const render = async (state, refs, actions) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfi-lens-wasm",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"description": "Lens For Web SDK with WASM",
|
|
5
5
|
"main": "veryfi-lens.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"author": "George Veryfi",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@fingerprintjs/fingerprintjs": "
|
|
16
|
-
"@fingerprintjs/fingerprintjs-pro": "
|
|
17
|
-
"jszip": "
|
|
18
|
-
"tesseract.js": "
|
|
15
|
+
"@fingerprintjs/fingerprintjs": "4.6.2",
|
|
16
|
+
"@fingerprintjs/fingerprintjs-pro": "3.12.8",
|
|
17
|
+
"jszip": "3.10.1",
|
|
18
|
+
"tesseract.js": "7.0.0"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist",
|
package/veryfi-lens.js
CHANGED
|
@@ -17,6 +17,7 @@ import { newStartLens, stopLens, removeOverlay } from './core/lifecycle.js';
|
|
|
17
17
|
import { createOverlayContainer } from './components/overlayContainer.js';
|
|
18
18
|
import { createSpinner } from './components/spinner.js';
|
|
19
19
|
import { installResizeObserverLoopErrorHandler } from './core/safe-resize-observer.js';
|
|
20
|
+
import { applyTheme, isValidTheme } from './core/theme.js';
|
|
20
21
|
|
|
21
22
|
// Wire up shared action references for cross-module callbacks
|
|
22
23
|
actions.newStartLens = newStartLens;
|
|
@@ -36,6 +37,15 @@ const normalizeCaptureConfig = (config) => {
|
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
|
|
40
|
+
const normalizeThemeConfig = (config) => {
|
|
41
|
+
if (config.theme === undefined) return;
|
|
42
|
+
if (isValidTheme(config.theme)) {
|
|
43
|
+
state.theme = config.theme;
|
|
44
|
+
} else {
|
|
45
|
+
console.warn('theme must be "light", "dark", or "system". Ignoring invalid value.');
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
39
49
|
const VeryfiLens = {
|
|
40
50
|
|
|
41
51
|
init: async (clientId, config) => {
|
|
@@ -61,12 +71,13 @@ const VeryfiLens = {
|
|
|
61
71
|
config.debug_mode && console.log(state.clientData);
|
|
62
72
|
|
|
63
73
|
Object.keys(config).forEach(key => {
|
|
64
|
-
if (state.hasOwnProperty(key)) {
|
|
74
|
+
if (state.hasOwnProperty(key) && key !== 'theme') {
|
|
65
75
|
state[key] = config[key];
|
|
66
76
|
}
|
|
67
77
|
});
|
|
68
78
|
|
|
69
79
|
normalizeCaptureConfig(config);
|
|
80
|
+
normalizeThemeConfig(config);
|
|
70
81
|
|
|
71
82
|
if (config.lensFlavor !== "caps" && config.lensFlavor !== "code_strips" && config.lensFlavor !== "prescription_label") {
|
|
72
83
|
await initializeWasmWrapper();
|
|
@@ -98,6 +109,7 @@ const VeryfiLens = {
|
|
|
98
109
|
state.container = oc.element;
|
|
99
110
|
state.overlayContainerRef = oc;
|
|
100
111
|
}
|
|
112
|
+
applyTheme(state.container, state.theme);
|
|
101
113
|
|
|
102
114
|
state.debug_mode && console.log(state);
|
|
103
115
|
|
|
@@ -129,6 +141,7 @@ const VeryfiLens = {
|
|
|
129
141
|
}
|
|
130
142
|
}
|
|
131
143
|
|
|
144
|
+
applyTheme(state.container, state.theme);
|
|
132
145
|
state.container.dataset.enableSubmit = state.enableSubmit.toString();
|
|
133
146
|
|
|
134
147
|
const loadingSpinner = createSpinner(state.container, 'Initializing...');
|
|
@@ -242,12 +255,17 @@ const VeryfiLens = {
|
|
|
242
255
|
Object.keys(config).forEach(key => {
|
|
243
256
|
if (state.hasOwnProperty(key) &&
|
|
244
257
|
key !== 'lensFlavor' &&
|
|
245
|
-
key !== 'container'
|
|
258
|
+
key !== 'container' &&
|
|
259
|
+
key !== 'theme') {
|
|
246
260
|
state[key] = config[key];
|
|
247
261
|
}
|
|
248
262
|
});
|
|
249
263
|
|
|
250
264
|
normalizeCaptureConfig(config);
|
|
265
|
+
normalizeThemeConfig(config);
|
|
266
|
+
if (state.container) {
|
|
267
|
+
applyTheme(state.container, state.theme);
|
|
268
|
+
}
|
|
251
269
|
|
|
252
270
|
if (config.customData !== undefined) {
|
|
253
271
|
if (typeof config.customData === 'object' && config.customData !== null && !Array.isArray(config.customData)) {
|