veryfi-lens-wasm 3.3.3 → 3.3.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/README.md +8 -0
- package/components/anydocPageControls.js +17 -9
- package/components/captureButton.js +6 -7
- package/components/desktopModeModal.js +11 -6
- package/components/exitButton.js +6 -7
- package/components/liquid-glass.js +38 -0
- package/components/mirrorButton.js +6 -6
- package/components/modalBase.js +24 -7
- package/components/prescriptionLabelGuide.js +3 -2
- package/components/prescriptionOverlayToggleButton.js +9 -6
- package/components/submitButton.js +3 -3
- package/components/switchCameraButton.js +6 -6
- package/components/torchButton.js +6 -6
- package/core/capture/anydoc.js +2 -0
- package/core/capture/prescription_label.js +142 -9
- package/core/constants.js +5 -1
- package/core/lifecycle.js +1 -0
- package/core/state.js +10 -0
- package/core/ui-renderer.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -207,6 +207,8 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
|
|
|
207
207
|
| `anydocShowFlipMessage` | `boolean` | `false` | Show flip document message between pages |
|
|
208
208
|
| `anydocFlipMessageText` | `string` | `"Please flip the document..."` | Flip message text |
|
|
209
209
|
| `anydocFlipContinueText` | `string` | `"Continue"` | Continue button text |
|
|
210
|
+
| `anydocShowGuide` | `boolean` | `false` | Show a dismissible on-screen text guide explaining how to capture. Auto-hides after each page capture and reappears when the camera restarts for the next page |
|
|
211
|
+
| `anydocGuideText` | `string` | `"Position the document within the frame..."` | Guide text shown for anydocs capture. Use `\n` for line breaks |
|
|
210
212
|
|
|
211
213
|
### Bottle Cap Settings (`caps` flavor)
|
|
212
214
|
|
|
@@ -240,6 +242,12 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
|
|
|
240
242
|
| `prescriptionLabelShowOverlayToggle` | `boolean` | `true` | Show a toggle that lets the user switch between the bottle and box overlays during capture. The **bottle** overlay records a video; the **box** overlay captures a still image |
|
|
241
243
|
| `prescriptionLabelBottleLabel` | `string` | `"Bottle"` | Label for the bottle (video) segment of the overlay toggle |
|
|
242
244
|
| `prescriptionLabelBoxLabel` | `string` | `"Box"` | Label for the box (image) segment of the overlay toggle |
|
|
245
|
+
| `prescriptionLabelBoxMultiSide` | `boolean` | `true` | When capturing with the box overlay, prompt after each capture to add another side of the same box. All captured sides are submitted as a single document (requires `packageMode: true` to group into one document) |
|
|
246
|
+
| `prescriptionLabelBoxMaxSides` | `number` | `4` | Maximum number of sides that can be captured for a single box. Once reached, the capture is submitted automatically instead of prompting for another side |
|
|
247
|
+
| `prescriptionLabelBoxSideMessage` | `string` | `"Capture another side of the box?"` | Message shown in the "another side" prompt for box captures |
|
|
248
|
+
| `prescriptionLabelBoxSideAddText` | `string` | `"Capture another side"` | Text for the button that captures another side of the box |
|
|
249
|
+
| `prescriptionLabelBoxSideSubmitText` | `string` | `"Submit"` | Text for the button that submits the captured box sides as one document |
|
|
250
|
+
| `prescriptionLabelMaxVideoDuration` | `number` | `12` | Maximum length, in seconds, of a bottle (video) capture. When reached, recording stops automatically. An on-screen countdown is shown while recording. Set to `0` to disable the limit |
|
|
243
251
|
|
|
244
252
|
### Upload Settings (`upload` flavor)
|
|
245
253
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createGallery } from './gallery.js';
|
|
2
|
+
import { LIQUID_GLASS } from './liquid-glass.js';
|
|
2
3
|
|
|
3
4
|
export const createAnydocPageControls = (container, onAddPage, onSubmit, removeOverlay, options = {}) => {
|
|
4
5
|
const wrapper = document.createElement('div');
|
|
@@ -88,14 +89,16 @@ export const createAnydocPageControls = (container, onAddPage, onSubmit, removeO
|
|
|
88
89
|
addButton.style.padding = `var(--anydoc-add-button-padding, ${defaultStyles.addButtonPadding})`;
|
|
89
90
|
addButton.style.backgroundColor = `var(--anydoc-add-button-background-color, ${defaultStyles.addButtonBackgroundColor})`;
|
|
90
91
|
addButton.style.color = `var(--anydoc-add-button-color, ${defaultStyles.addButtonColor})`;
|
|
91
|
-
addButton.style.border =
|
|
92
|
+
addButton.style.border = `var(--anydoc-add-button-border, ${LIQUID_GLASS.border})`;
|
|
92
93
|
addButton.style.borderRadius = `var(--anydoc-add-button-border-radius, ${defaultStyles.addButtonBorderRadius})`;
|
|
93
94
|
addButton.style.cursor = 'pointer';
|
|
94
95
|
addButton.style.fontSize = `var(--anydoc-add-button-font-size, ${defaultStyles.addButtonFontSize})`;
|
|
95
96
|
addButton.style.fontFamily = `var(--anydoc-add-button-font-family, ${defaultStyles.addButtonFontFamily})`;
|
|
96
97
|
addButton.style.fontWeight = `var(--anydoc-add-button-font-weight, 600)`;
|
|
97
98
|
addButton.style.transition = 'all 0.2s ease';
|
|
98
|
-
addButton.style.
|
|
99
|
+
addButton.style.backdropFilter = LIQUID_GLASS.blur;
|
|
100
|
+
addButton.style.webkitBackdropFilter = LIQUID_GLASS.blur;
|
|
101
|
+
addButton.style.boxShadow = `var(--anydoc-add-button-box-shadow, ${LIQUID_GLASS.boxShadow})`;
|
|
99
102
|
addButton.style.letterSpacing = '0.3px';
|
|
100
103
|
addButton.style.whiteSpace = 'nowrap';
|
|
101
104
|
|
|
@@ -105,14 +108,16 @@ export const createAnydocPageControls = (container, onAddPage, onSubmit, removeO
|
|
|
105
108
|
submitButton.style.padding = `var(--anydoc-submit-button-padding, ${defaultStyles.submitButtonPadding})`;
|
|
106
109
|
submitButton.style.backgroundColor = `var(--anydoc-submit-button-background-color, ${defaultStyles.submitButtonBackgroundColor})`;
|
|
107
110
|
submitButton.style.color = `var(--anydoc-submit-button-color, ${defaultStyles.submitButtonColor})`;
|
|
108
|
-
submitButton.style.border =
|
|
111
|
+
submitButton.style.border = `var(--anydoc-submit-button-border, ${LIQUID_GLASS.border})`;
|
|
109
112
|
submitButton.style.borderRadius = `var(--anydoc-submit-button-border-radius, ${defaultStyles.submitButtonBorderRadius})`;
|
|
110
113
|
submitButton.style.cursor = 'pointer';
|
|
111
114
|
submitButton.style.fontSize = `var(--anydoc-submit-button-font-size, ${defaultStyles.submitButtonFontSize})`;
|
|
112
115
|
submitButton.style.fontFamily = `var(--anydoc-submit-button-font-family, ${defaultStyles.submitButtonFontFamily})`;
|
|
113
116
|
submitButton.style.fontWeight = `var(--anydoc-submit-button-font-weight, 600)`;
|
|
114
117
|
submitButton.style.transition = 'all 0.2s ease';
|
|
115
|
-
submitButton.style.
|
|
118
|
+
submitButton.style.backdropFilter = LIQUID_GLASS.blur;
|
|
119
|
+
submitButton.style.webkitBackdropFilter = LIQUID_GLASS.blur;
|
|
120
|
+
submitButton.style.boxShadow = `var(--anydoc-submit-button-box-shadow, ${LIQUID_GLASS.boxShadow})`;
|
|
116
121
|
submitButton.style.letterSpacing = '0.3px';
|
|
117
122
|
submitButton.style.whiteSpace = 'nowrap';
|
|
118
123
|
|
|
@@ -143,23 +148,26 @@ export const createAnydocPageControls = (container, onAddPage, onSubmit, removeO
|
|
|
143
148
|
exitButton.style.minWidth = '40px';
|
|
144
149
|
exitButton.style.minHeight = '40px';
|
|
145
150
|
exitButton.style.padding = '0';
|
|
146
|
-
exitButton.style.backgroundColor =
|
|
151
|
+
exitButton.style.backgroundColor = LIQUID_GLASS.backgroundColor;
|
|
147
152
|
exitButton.style.color = 'white';
|
|
148
153
|
exitButton.style.fontWeight = 'bold';
|
|
149
154
|
exitButton.style.fontFamily = 'sans-serif';
|
|
150
|
-
exitButton.style.border =
|
|
155
|
+
exitButton.style.border = LIQUID_GLASS.border;
|
|
151
156
|
exitButton.style.borderRadius = '50%';
|
|
152
157
|
exitButton.style.cursor = 'pointer';
|
|
153
158
|
exitButton.style.display = 'flex';
|
|
154
159
|
exitButton.style.alignItems = 'center';
|
|
155
160
|
exitButton.style.justifyContent = 'center';
|
|
156
|
-
exitButton.style.transition = 'background-color 0.3s ease';
|
|
161
|
+
exitButton.style.transition = 'background-color 0.3s ease, box-shadow 0.3s ease';
|
|
157
162
|
exitButton.style.boxSizing = 'border-box';
|
|
163
|
+
exitButton.style.backdropFilter = LIQUID_GLASS.blur;
|
|
164
|
+
exitButton.style.webkitBackdropFilter = LIQUID_GLASS.blur;
|
|
165
|
+
exitButton.style.boxShadow = LIQUID_GLASS.boxShadow;
|
|
158
166
|
exitButton.addEventListener('mouseenter', () => {
|
|
159
|
-
exitButton.style.backgroundColor =
|
|
167
|
+
exitButton.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
|
|
160
168
|
});
|
|
161
169
|
exitButton.addEventListener('mouseleave', () => {
|
|
162
|
-
exitButton.style.backgroundColor =
|
|
170
|
+
exitButton.style.backgroundColor = LIQUID_GLASS.backgroundColor;
|
|
163
171
|
});
|
|
164
172
|
exitButton.addEventListener('click', (e) => {
|
|
165
173
|
e.preventDefault();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
export const createCaptureButton = (container, onCapture, onStopStitching) => {
|
|
2
4
|
const button = document.createElement('button');
|
|
3
5
|
button.id = 'veryfi-capture-button';
|
|
@@ -10,17 +12,14 @@ export const createCaptureButton = (container, onCapture, onStopStitching) => {
|
|
|
10
12
|
width: '4rem',
|
|
11
13
|
height: '4rem',
|
|
12
14
|
borderRadius: '50%',
|
|
13
|
-
border: '3px solid rgba(255, 255, 255, 0.4)',
|
|
14
|
-
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
15
15
|
cursor: 'pointer',
|
|
16
16
|
zIndex: '1000',
|
|
17
|
-
transition: 'background-color 0.3s ease',
|
|
17
|
+
transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
|
|
18
18
|
padding: '0',
|
|
19
19
|
outline: 'none',
|
|
20
20
|
pointerEvents: 'auto',
|
|
21
|
-
backdropFilter: 'blur(2px)',
|
|
22
|
-
WebkitBackdropFilter: 'blur(2px)',
|
|
23
21
|
boxSizing: 'border-box',
|
|
22
|
+
...liquidGlassStyles({ border: '3px solid rgba(255, 255, 255, 0.55)' }),
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
Object.entries(defaultStyles).forEach(([key, value]) => {
|
|
@@ -47,11 +46,11 @@ export const createCaptureButton = (container, onCapture, onStopStitching) => {
|
|
|
47
46
|
|
|
48
47
|
// Add hover effect
|
|
49
48
|
button.addEventListener('mouseenter', () => {
|
|
50
|
-
button.style.backgroundColor =
|
|
49
|
+
button.style.backgroundColor = `var(--capture-button-hover-background-color, ${LIQUID_GLASS.hoverBackgroundColor})`;
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
button.addEventListener('mouseleave', () => {
|
|
54
|
-
button.style.backgroundColor =
|
|
53
|
+
button.style.backgroundColor = `var(--capture-button-background-color, ${LIQUID_GLASS.backgroundColor})`;
|
|
55
54
|
});
|
|
56
55
|
|
|
57
56
|
let isStitching = false;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIQUID_GLASS } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
const WIDE_VIEWPORT_THRESHOLD = 900;
|
|
2
4
|
const MODAL_ID = 'veryfi-desktop-mode-modal';
|
|
3
5
|
const STYLE_ID = 'veryfi-desktop-mode-modal-styles';
|
|
@@ -61,11 +63,13 @@ const ensureStyles = () => {
|
|
|
61
63
|
position: relative;
|
|
62
64
|
width: 100%;
|
|
63
65
|
max-width: 420px;
|
|
64
|
-
background:
|
|
66
|
+
background: ${LIQUID_GLASS.darkPanelBackground};
|
|
67
|
+
backdrop-filter: ${LIQUID_GLASS.blur};
|
|
68
|
+
-webkit-backdrop-filter: ${LIQUID_GLASS.blur};
|
|
65
69
|
color: #ffffff;
|
|
66
|
-
border-radius:
|
|
67
|
-
border:
|
|
68
|
-
box-shadow:
|
|
70
|
+
border-radius: 20px;
|
|
71
|
+
border: ${LIQUID_GLASS.darkBorder};
|
|
72
|
+
box-shadow: ${LIQUID_GLASS.darkPanelBoxShadow};
|
|
69
73
|
padding: 24px;
|
|
70
74
|
box-sizing: border-box;
|
|
71
75
|
}
|
|
@@ -118,12 +122,13 @@ const ensureStyles = () => {
|
|
|
118
122
|
#${MODAL_ID} .veryfi-dm-reload {
|
|
119
123
|
width: 100%;
|
|
120
124
|
padding: 12px 16px;
|
|
121
|
-
border-radius:
|
|
125
|
+
border-radius: 12px;
|
|
122
126
|
background: #10b981;
|
|
123
127
|
color: #0f172a;
|
|
124
128
|
font-weight: 600;
|
|
125
129
|
font-size: 14px;
|
|
126
|
-
border:
|
|
130
|
+
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
131
|
+
box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.5);
|
|
127
132
|
cursor: pointer;
|
|
128
133
|
transition: background-color 0.15s;
|
|
129
134
|
}
|
package/components/exitButton.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
export const createExitButton = (container, options, removeOverlay) => {
|
|
2
4
|
const { setter, redirectUrl, lensFlavor } = options;
|
|
3
5
|
|
|
@@ -9,14 +11,13 @@ export const createExitButton = (container, options, removeOverlay) => {
|
|
|
9
11
|
position: 'absolute',
|
|
10
12
|
bottom: '50px',
|
|
11
13
|
left: '115px',
|
|
12
|
-
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
13
14
|
color: 'white',
|
|
14
15
|
fontWeight: 'bold',
|
|
15
16
|
borderRadius: '50%',
|
|
16
17
|
textDecoration: 'none',
|
|
17
18
|
zIndex: '1000',
|
|
18
19
|
cursor: 'pointer',
|
|
19
|
-
transition: 'background-color 0.3s ease',
|
|
20
|
+
transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
|
|
20
21
|
width: '40px',
|
|
21
22
|
height: '40px',
|
|
22
23
|
display: 'flex',
|
|
@@ -24,7 +25,6 @@ export const createExitButton = (container, options, removeOverlay) => {
|
|
|
24
25
|
alignItems: 'center',
|
|
25
26
|
justifyContent: 'center',
|
|
26
27
|
pointerEvents: 'auto',
|
|
27
|
-
border: '1px solid rgba(255, 255, 255, 0.4)',
|
|
28
28
|
outline: 'none',
|
|
29
29
|
boxSizing: 'border-box',
|
|
30
30
|
margin: '0',
|
|
@@ -33,8 +33,7 @@ export const createExitButton = (container, options, removeOverlay) => {
|
|
|
33
33
|
minHeight: '40px',
|
|
34
34
|
maxWidth: '40px',
|
|
35
35
|
maxHeight: '40px',
|
|
36
|
-
|
|
37
|
-
WebkitBackdropFilter: 'blur(8px)',
|
|
36
|
+
...liquidGlassStyles(),
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
Object.entries(defaultStyles).forEach(([key, value]) => {
|
|
@@ -70,11 +69,11 @@ export const createExitButton = (container, options, removeOverlay) => {
|
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
button.addEventListener('mouseenter', () => {
|
|
73
|
-
button.style.backgroundColor =
|
|
72
|
+
button.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
|
|
74
73
|
});
|
|
75
74
|
|
|
76
75
|
button.addEventListener('mouseleave', () => {
|
|
77
|
-
button.style.backgroundColor =
|
|
76
|
+
button.style.backgroundColor = LIQUID_GLASS.backgroundColor;
|
|
78
77
|
});
|
|
79
78
|
|
|
80
79
|
button.addEventListener('click', (e) => {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Shared "liquid glass" design tokens for every glassy surface in the SDK
|
|
2
|
+
// (on-camera control buttons, segmented toggles and modal panels). Centralized
|
|
3
|
+
// so the look stays consistent and can be tuned from a single place.
|
|
4
|
+
|
|
5
|
+
export const LIQUID_GLASS = {
|
|
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
|
+
// Frosted panel fill for light modals (dark content sits on top).
|
|
11
|
+
panelBackground: 'rgba(250, 250, 252, 0.72)',
|
|
12
|
+
// Dark frosted panel fill for warning / system modals.
|
|
13
|
+
darkPanelBackground: 'rgba(30, 41, 59, 0.72)',
|
|
14
|
+
// Heavy blur + saturation is what produces the "liquid" refraction.
|
|
15
|
+
blur: 'blur(18px) saturate(180%)',
|
|
16
|
+
// Bright hairline edge.
|
|
17
|
+
border: '1px solid rgba(255, 255, 255, 0.5)',
|
|
18
|
+
darkBorder: '1px solid rgba(255, 255, 255, 0.14)',
|
|
19
|
+
// Outer float shadow + inner specular highlights (bright top, soft bottom).
|
|
20
|
+
boxShadow:
|
|
21
|
+
'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
|
+
'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)',
|
|
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)',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Inline-style fragment for on-camera glass controls (buttons, toggles).
|
|
29
|
+
// Spread into a component's defaultStyles; pass overrides (e.g. a thicker
|
|
30
|
+
// border for the capture ring) to customize per control.
|
|
31
|
+
export const liquidGlassStyles = (overrides = {}) => ({
|
|
32
|
+
backgroundColor: LIQUID_GLASS.backgroundColor,
|
|
33
|
+
backdropFilter: LIQUID_GLASS.blur,
|
|
34
|
+
WebkitBackdropFilter: LIQUID_GLASS.blur,
|
|
35
|
+
border: LIQUID_GLASS.border,
|
|
36
|
+
boxShadow: LIQUID_GLASS.boxShadow,
|
|
37
|
+
...overrides,
|
|
38
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
export const createMirrorButton = (container, toggleCallback) => {
|
|
2
4
|
const button = document.createElement('button');
|
|
3
5
|
button.id = 'veryfi-mirror-button';
|
|
@@ -5,7 +7,6 @@ export const createMirrorButton = (container, toggleCallback) => {
|
|
|
5
7
|
const defaultStyles = {
|
|
6
8
|
width: '40px',
|
|
7
9
|
height: '40px',
|
|
8
|
-
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
9
10
|
color: '#FFFFFF',
|
|
10
11
|
borderRadius: '50%',
|
|
11
12
|
position: 'absolute',
|
|
@@ -18,7 +19,6 @@ export const createMirrorButton = (container, toggleCallback) => {
|
|
|
18
19
|
padding: '0',
|
|
19
20
|
cursor: 'pointer',
|
|
20
21
|
pointerEvents: 'auto',
|
|
21
|
-
border: '1px solid rgba(255, 255, 255, 0.4)',
|
|
22
22
|
outline: 'none',
|
|
23
23
|
boxSizing: 'border-box',
|
|
24
24
|
margin: '0',
|
|
@@ -26,8 +26,8 @@ export const createMirrorButton = (container, toggleCallback) => {
|
|
|
26
26
|
minHeight: '40px',
|
|
27
27
|
maxWidth: '40px',
|
|
28
28
|
maxHeight: '40px',
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
|
|
30
|
+
...liquidGlassStyles(),
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
Object.entries(defaultStyles).forEach(([key, value]) => {
|
|
@@ -35,10 +35,10 @@ export const createMirrorButton = (container, toggleCallback) => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
button.addEventListener('mouseover', () => {
|
|
38
|
-
button.style.backgroundColor =
|
|
38
|
+
button.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
|
|
39
39
|
});
|
|
40
40
|
button.addEventListener('mouseout', () => {
|
|
41
|
-
button.style.backgroundColor =
|
|
41
|
+
button.style.backgroundColor = LIQUID_GLASS.backgroundColor;
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
button.addEventListener('click', toggleCallback);
|
package/components/modalBase.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIQUID_GLASS } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
const DEFAULT_STYLES = {
|
|
2
4
|
position: 'fixed',
|
|
3
5
|
width: '300px',
|
|
@@ -6,8 +8,8 @@ const DEFAULT_STYLES = {
|
|
|
6
8
|
justifyContent: 'center',
|
|
7
9
|
alignItems: 'center',
|
|
8
10
|
zIndex: '1000',
|
|
9
|
-
backgroundColor:
|
|
10
|
-
borderRadius: '
|
|
11
|
+
backgroundColor: LIQUID_GLASS.panelBackground,
|
|
12
|
+
borderRadius: '20px',
|
|
11
13
|
padding: '24px 28px',
|
|
12
14
|
maxWidth: '300px',
|
|
13
15
|
textColor: '#1e293b',
|
|
@@ -21,9 +23,13 @@ const DEFAULT_STYLES = {
|
|
|
21
23
|
buttonFontWeight: '700',
|
|
22
24
|
primaryButtonBackground: '#00AA00',
|
|
23
25
|
primaryButtonColor: 'white',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
primaryButtonBoxShadow: LIQUID_GLASS.boxShadow,
|
|
27
|
+
secondaryButtonBackground: 'rgba(255, 255, 255, 0.45)',
|
|
28
|
+
secondaryButtonBorder: '1px solid rgba(0, 0, 0, 0.12)',
|
|
29
|
+
secondaryButtonColor: '#1e293b',
|
|
30
|
+
panelBackdropFilter: LIQUID_GLASS.blur,
|
|
31
|
+
panelBorder: '1px solid rgba(255, 255, 255, 0.6)',
|
|
32
|
+
panelBoxShadow: LIQUID_GLASS.panelBoxShadow,
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
export const createModal = (container, {
|
|
@@ -86,6 +92,13 @@ export const createModal = (container, {
|
|
|
86
92
|
modal.style.transform = `var(--modal-transform, ${s.transform})`;
|
|
87
93
|
}
|
|
88
94
|
|
|
95
|
+
const glassPanelStyle = `
|
|
96
|
+
backdrop-filter: var(--${cssPrefix}-panel-backdrop-filter, ${s.panelBackdropFilter});
|
|
97
|
+
-webkit-backdrop-filter: var(--${cssPrefix}-panel-backdrop-filter, ${s.panelBackdropFilter});
|
|
98
|
+
border: var(--${cssPrefix}-panel-border, ${s.panelBorder});
|
|
99
|
+
box-shadow: var(--${cssPrefix}-panel-box-shadow, ${s.panelBoxShadow});
|
|
100
|
+
`;
|
|
101
|
+
|
|
89
102
|
const contentStyle = useBackdrop ? `
|
|
90
103
|
background-color: var(--${cssPrefix}-background-color, ${s.backgroundColor});
|
|
91
104
|
border-radius: var(--${cssPrefix}-border-radius, ${s.borderRadius});
|
|
@@ -97,13 +110,14 @@ export const createModal = (container, {
|
|
|
97
110
|
display: flex;
|
|
98
111
|
flex-direction: column;
|
|
99
112
|
align-items: stretch;
|
|
100
|
-
|
|
113
|
+
${glassPanelStyle}
|
|
101
114
|
` : `
|
|
102
115
|
background-color: var(--${cssPrefix}-background-color, ${s.backgroundColor});
|
|
103
116
|
border-radius: var(--${cssPrefix}-border-radius, ${s.borderRadius});
|
|
104
117
|
padding: var(--${cssPrefix}-padding, ${s.padding});
|
|
105
118
|
width: var(--${cssPrefix}-width, ${s.width});
|
|
106
119
|
max-width: var(--${cssPrefix}-max-width, ${s.maxWidth});
|
|
120
|
+
${glassPanelStyle}
|
|
107
121
|
`;
|
|
108
122
|
|
|
109
123
|
const btnWidth = useBackdrop ? 'width: 100%;' : `width: var(--${cssPrefix}-button-width, ${s.buttonWidth});`;
|
|
@@ -130,7 +144,8 @@ export const createModal = (container, {
|
|
|
130
144
|
border-radius: var(--${cssPrefix}-button-border-radius, ${s.buttonBorderRadius});
|
|
131
145
|
background-color: var(--${cssPrefix}-primary-button-background, ${s.primaryButtonBackground});
|
|
132
146
|
color: var(--${cssPrefix}-primary-button-color, ${s.primaryButtonColor});
|
|
133
|
-
border:
|
|
147
|
+
border: var(--${cssPrefix}-primary-button-border, ${LIQUID_GLASS.border});
|
|
148
|
+
box-shadow: var(--${cssPrefix}-primary-button-box-shadow, ${s.primaryButtonBoxShadow});
|
|
134
149
|
cursor: pointer;
|
|
135
150
|
font-weight: var(--${cssPrefix}-button-font-weight, ${s.buttonFontWeight});
|
|
136
151
|
font-family: var(--${cssPrefix}-button-font-family, ${s.buttonFontFamily});
|
|
@@ -149,6 +164,8 @@ export const createModal = (container, {
|
|
|
149
164
|
background-color: var(--${cssPrefix}-secondary-button-background, ${s.secondaryButtonBackground});
|
|
150
165
|
color: var(--${cssPrefix}-secondary-button-color, ${s.secondaryButtonColor});
|
|
151
166
|
border: var(--${cssPrefix}-secondary-button-border, ${s.secondaryButtonBorder});
|
|
167
|
+
backdrop-filter: blur(8px);
|
|
168
|
+
-webkit-backdrop-filter: blur(8px);
|
|
152
169
|
cursor: pointer;
|
|
153
170
|
font-weight: var(--${cssPrefix}-button-font-weight, ${s.buttonFontWeight});
|
|
154
171
|
font-family: var(--${cssPrefix}-button-font-family, ${s.buttonFontFamily});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export const createPrescriptionLabelGuide = (container, options = {}) => {
|
|
2
2
|
const text = options.text || '';
|
|
3
|
+
const id = options.id || 'veryfi-prescription-label-guide';
|
|
3
4
|
|
|
4
5
|
const guide = document.createElement('div');
|
|
5
|
-
guide.id =
|
|
6
|
+
guide.id = id;
|
|
6
7
|
|
|
7
8
|
Object.assign(guide.style, {
|
|
8
9
|
position: 'absolute',
|
|
@@ -33,7 +34,7 @@ export const createPrescriptionLabelGuide = (container, options = {}) => {
|
|
|
33
34
|
guide.appendChild(textEl);
|
|
34
35
|
|
|
35
36
|
const closeButton = document.createElement('button');
|
|
36
|
-
closeButton.id =
|
|
37
|
+
closeButton.id = `${id}-close`;
|
|
37
38
|
closeButton.setAttribute('aria-label', 'Close guide');
|
|
38
39
|
closeButton.textContent = '\u00D7';
|
|
39
40
|
Object.assign(closeButton.style, {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
export const createPrescriptionOverlayToggleButton = (container, options = {}) => {
|
|
2
4
|
const bottleLabel = options.bottleLabel || 'Bottle';
|
|
3
5
|
const boxLabel = options.boxLabel || 'Box';
|
|
@@ -14,13 +16,10 @@ export const createPrescriptionOverlayToggleButton = (container, options = {}) =
|
|
|
14
16
|
display: 'flex',
|
|
15
17
|
gap: '4px',
|
|
16
18
|
padding: '4px',
|
|
17
|
-
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
18
|
-
border: '1px solid rgba(255, 255, 255, 0.4)',
|
|
19
19
|
borderRadius: '25px',
|
|
20
|
-
backdropFilter: 'blur(8px)',
|
|
21
|
-
WebkitBackdropFilter: 'blur(8px)',
|
|
22
20
|
zIndex: '1004',
|
|
23
21
|
pointerEvents: 'auto',
|
|
22
|
+
...liquidGlassStyles(),
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
const makeSegment = (label, type) => {
|
|
@@ -39,7 +38,7 @@ export const createPrescriptionOverlayToggleButton = (container, options = {}) =
|
|
|
39
38
|
fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
|
|
40
39
|
color: 'white',
|
|
41
40
|
backgroundColor: 'transparent',
|
|
42
|
-
transition: 'background-color 0.2s ease',
|
|
41
|
+
transition: 'background-color 0.2s ease, box-shadow 0.2s ease',
|
|
43
42
|
});
|
|
44
43
|
btn.addEventListener('click', () => {
|
|
45
44
|
if (active === type) return;
|
|
@@ -55,7 +54,11 @@ export const createPrescriptionOverlayToggleButton = (container, options = {}) =
|
|
|
55
54
|
|
|
56
55
|
const updateSegments = () => {
|
|
57
56
|
[[bottleBtn, 'bottle'], [boxBtn, 'box']].forEach(([btn, type]) => {
|
|
58
|
-
|
|
57
|
+
const isActive = active === type;
|
|
58
|
+
btn.style.backgroundColor = isActive ? LIQUID_GLASS.activeBackgroundColor : 'transparent';
|
|
59
|
+
btn.style.boxShadow = isActive
|
|
60
|
+
? 'inset 0 1px 1px rgba(255, 255, 255, 0.6), 0 2px 8px rgba(0, 0, 0, 0.12)'
|
|
61
|
+
: 'none';
|
|
59
62
|
});
|
|
60
63
|
};
|
|
61
64
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { liquidGlassStyles } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
export const createSubmitButton = (container, onSubmit, removeOverlay, options = {}) => {
|
|
2
4
|
const button = document.createElement('button');
|
|
3
5
|
button.id = 'veryfi-submit-button';
|
|
@@ -8,9 +10,7 @@ export const createSubmitButton = (container, onSubmit, removeOverlay, options =
|
|
|
8
10
|
bottom: '50px',
|
|
9
11
|
transform: 'translateX(-50%)',
|
|
10
12
|
padding: '12px 28px',
|
|
11
|
-
backgroundColor: '#00AA00',
|
|
12
13
|
color: 'white',
|
|
13
|
-
border: 'none',
|
|
14
14
|
borderRadius: '25px',
|
|
15
15
|
cursor: 'pointer',
|
|
16
16
|
fontSize: '14px',
|
|
@@ -18,7 +18,7 @@ export const createSubmitButton = (container, onSubmit, removeOverlay, options =
|
|
|
18
18
|
fontWeight: '600',
|
|
19
19
|
letterSpacing: '0.3px',
|
|
20
20
|
transition: 'all 0.2s ease',
|
|
21
|
-
|
|
21
|
+
...liquidGlassStyles({ backgroundColor: '#00AA00' }),
|
|
22
22
|
zIndex: '1000',
|
|
23
23
|
display: 'none',
|
|
24
24
|
pointerEvents: 'auto',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
export const createSwitchCameraButton = (container, toggleCallback) => {
|
|
2
4
|
const button = document.createElement('button');
|
|
3
5
|
button.id = 'veryfi-switch-camera-button';
|
|
@@ -5,7 +7,6 @@ export const createSwitchCameraButton = (container, toggleCallback) => {
|
|
|
5
7
|
const defaultStyles = {
|
|
6
8
|
width: '40px',
|
|
7
9
|
height: '40px',
|
|
8
|
-
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
9
10
|
color: '#FFFFFF',
|
|
10
11
|
borderRadius: '50%',
|
|
11
12
|
position: 'absolute',
|
|
@@ -18,7 +19,6 @@ export const createSwitchCameraButton = (container, toggleCallback) => {
|
|
|
18
19
|
padding: '0',
|
|
19
20
|
cursor: 'pointer',
|
|
20
21
|
pointerEvents: 'auto',
|
|
21
|
-
border: '1px solid rgba(255, 255, 255, 0.4)',
|
|
22
22
|
outline: 'none',
|
|
23
23
|
boxSizing: 'border-box',
|
|
24
24
|
margin: '0',
|
|
@@ -26,8 +26,8 @@ export const createSwitchCameraButton = (container, toggleCallback) => {
|
|
|
26
26
|
minHeight: '40px',
|
|
27
27
|
maxWidth: '40px',
|
|
28
28
|
maxHeight: '40px',
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
|
|
30
|
+
...liquidGlassStyles(),
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
Object.entries(defaultStyles).forEach(([key, value]) => {
|
|
@@ -35,10 +35,10 @@ export const createSwitchCameraButton = (container, toggleCallback) => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
button.addEventListener('mouseover', () => {
|
|
38
|
-
button.style.backgroundColor =
|
|
38
|
+
button.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
|
|
39
39
|
});
|
|
40
40
|
button.addEventListener('mouseout', () => {
|
|
41
|
-
button.style.backgroundColor =
|
|
41
|
+
button.style.backgroundColor = LIQUID_GLASS.backgroundColor;
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
button.addEventListener('click', toggleCallback);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
|
|
2
|
+
|
|
1
3
|
export const createTorchButton = (container, toggleCallback, lensFlavor) => {
|
|
2
4
|
const button = document.createElement("button");
|
|
3
5
|
button.id = "veryfi-torch-button";
|
|
@@ -5,7 +7,6 @@ export const createTorchButton = (container, toggleCallback, lensFlavor) => {
|
|
|
5
7
|
const defaultStyles = {
|
|
6
8
|
width: '40px',
|
|
7
9
|
height: '40px',
|
|
8
|
-
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
9
10
|
color: '#FFFFFF',
|
|
10
11
|
borderRadius: '50%',
|
|
11
12
|
position: 'absolute',
|
|
@@ -18,7 +19,6 @@ export const createTorchButton = (container, toggleCallback, lensFlavor) => {
|
|
|
18
19
|
padding: '0',
|
|
19
20
|
cursor: 'pointer',
|
|
20
21
|
pointerEvents: 'auto',
|
|
21
|
-
border: '1px solid rgba(255, 255, 255, 0.4)',
|
|
22
22
|
outline: 'none',
|
|
23
23
|
boxSizing: 'border-box',
|
|
24
24
|
margin: '0',
|
|
@@ -26,8 +26,8 @@ export const createTorchButton = (container, toggleCallback, lensFlavor) => {
|
|
|
26
26
|
minHeight: '40px',
|
|
27
27
|
maxWidth: '40px',
|
|
28
28
|
maxHeight: '40px',
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
|
|
30
|
+
...liquidGlassStyles(),
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
|
|
@@ -59,10 +59,10 @@ export const createTorchButton = (container, toggleCallback, lensFlavor) => {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
button.addEventListener('mouseover', () => {
|
|
62
|
-
button.style.backgroundColor =
|
|
62
|
+
button.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
|
|
63
63
|
});
|
|
64
64
|
button.addEventListener('mouseout', () => {
|
|
65
|
-
button.style.backgroundColor =
|
|
65
|
+
button.style.backgroundColor = LIQUID_GLASS.backgroundColor;
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
button.addEventListener('click', toggleCallback);
|
package/core/capture/anydoc.js
CHANGED
|
@@ -4,6 +4,8 @@ import { hideVideoOverlay, showVideoOverlay } from '../overlay-controls.js';
|
|
|
4
4
|
import { removeOverlay, newStartLens } from '../lifecycle.js';
|
|
5
5
|
import { promptForAnotherCapture } from '../multi-submission.js';
|
|
6
6
|
import { createSubmitButton } from '../../components/submitButton.js';
|
|
7
|
+
import { createMultiCaptureModal } from '../../components/multiCaptureModal.js';
|
|
8
|
+
import { liquidGlassStyles } from '../../components/liquid-glass.js';
|
|
7
9
|
import { DEFAULTS } from '../constants.js';
|
|
8
10
|
|
|
9
11
|
let previewRecorder = null;
|
|
@@ -20,6 +22,9 @@ let lastVideoBlob = null;
|
|
|
20
22
|
let cropCanvas = null;
|
|
21
23
|
let cropAnimationFrameId = null;
|
|
22
24
|
let recordingStartTime = 0;
|
|
25
|
+
let boxSideCount = 0;
|
|
26
|
+
let maxDurationTimeoutId = null;
|
|
27
|
+
let countdownIntervalId = null;
|
|
23
28
|
|
|
24
29
|
const ensurePulseKeyframes = () => {
|
|
25
30
|
if (pulseStyleEl) return;
|
|
@@ -86,6 +91,7 @@ const updateRecordingUI = (recording) => {
|
|
|
86
91
|
});
|
|
87
92
|
|
|
88
93
|
const text = document.createElement('span');
|
|
94
|
+
text.id = 'veryfi-recording-countdown';
|
|
89
95
|
Object.assign(text.style, {
|
|
90
96
|
color: 'white',
|
|
91
97
|
fontSize: '14px',
|
|
@@ -217,6 +223,45 @@ const stopCroppedDrawLoop = () => {
|
|
|
217
223
|
cropCanvas = null;
|
|
218
224
|
};
|
|
219
225
|
|
|
226
|
+
const formatCountdown = (totalSeconds) => {
|
|
227
|
+
const s = Math.max(0, Math.floor(totalSeconds));
|
|
228
|
+
const mins = Math.floor(s / 60);
|
|
229
|
+
const secs = s % 60;
|
|
230
|
+
return `${mins}:${String(secs).padStart(2, '0')}`;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const startRecordingCountdown = (maxDuration) => {
|
|
234
|
+
stopRecordingCountdown();
|
|
235
|
+
let remaining = maxDuration;
|
|
236
|
+
const render = () => {
|
|
237
|
+
const el = document.getElementById('veryfi-recording-countdown');
|
|
238
|
+
if (el) el.textContent = `REC ${formatCountdown(remaining)}`;
|
|
239
|
+
};
|
|
240
|
+
render();
|
|
241
|
+
countdownIntervalId = setInterval(() => {
|
|
242
|
+
remaining -= 1;
|
|
243
|
+
render();
|
|
244
|
+
if (remaining <= 0) {
|
|
245
|
+
stopRecordingCountdown();
|
|
246
|
+
}
|
|
247
|
+
}, 1000);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const stopRecordingCountdown = () => {
|
|
251
|
+
if (countdownIntervalId !== null) {
|
|
252
|
+
clearInterval(countdownIntervalId);
|
|
253
|
+
countdownIntervalId = null;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const clearRecordingTimers = () => {
|
|
258
|
+
if (maxDurationTimeoutId !== null) {
|
|
259
|
+
clearTimeout(maxDurationTimeoutId);
|
|
260
|
+
maxDurationTimeoutId = null;
|
|
261
|
+
}
|
|
262
|
+
stopRecordingCountdown();
|
|
263
|
+
};
|
|
264
|
+
|
|
220
265
|
const startRecording = () => {
|
|
221
266
|
const stream = state.videoRef?.srcObject;
|
|
222
267
|
if (!stream) {
|
|
@@ -273,6 +318,17 @@ const startRecording = () => {
|
|
|
273
318
|
state.prescriptionOverlayToggleButton?.hide?.();
|
|
274
319
|
state.updateHandler?.({ status: 'recording_started' });
|
|
275
320
|
state.debug_mode && console.log('[EVENT] prescription label recording started');
|
|
321
|
+
|
|
322
|
+
// Optional hard cap on recording length with an on-screen countdown. When the
|
|
323
|
+
// limit is reached the recording auto-stops through the normal capture path.
|
|
324
|
+
const maxDuration = state.prescriptionLabelMaxVideoDuration;
|
|
325
|
+
if (maxDuration && maxDuration > 0) {
|
|
326
|
+
startRecordingCountdown(maxDuration);
|
|
327
|
+
maxDurationTimeoutId = setTimeout(() => {
|
|
328
|
+
maxDurationTimeoutId = null;
|
|
329
|
+
if (isRecording) capturePrescriptionLabel();
|
|
330
|
+
}, maxDuration * 1000);
|
|
331
|
+
}
|
|
276
332
|
};
|
|
277
333
|
|
|
278
334
|
const stopRecording = () => {
|
|
@@ -284,6 +340,8 @@ const stopRecording = () => {
|
|
|
284
340
|
|
|
285
341
|
let previewBlob = null;
|
|
286
342
|
let submissionBlob = null;
|
|
343
|
+
clearRecordingTimers();
|
|
344
|
+
|
|
287
345
|
const finalize = () => {
|
|
288
346
|
if (!previewBlob || !submissionBlob) return;
|
|
289
347
|
const durationSec = (performance.now() - recordingStartTime) / 1000;
|
|
@@ -393,15 +451,14 @@ const showVideoPreview = (videoBlob) => {
|
|
|
393
451
|
width: '60px',
|
|
394
452
|
height: '60px',
|
|
395
453
|
borderRadius: '50%',
|
|
396
|
-
border: 'none',
|
|
397
|
-
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
398
454
|
cursor: 'pointer',
|
|
399
455
|
zIndex: '950',
|
|
400
456
|
pointerEvents: 'auto',
|
|
401
457
|
display: 'flex',
|
|
402
458
|
alignItems: 'center',
|
|
403
459
|
justifyContent: 'center',
|
|
404
|
-
transition: 'opacity 0.2s',
|
|
460
|
+
transition: 'opacity 0.2s, box-shadow 0.3s ease',
|
|
461
|
+
...liquidGlassStyles(),
|
|
405
462
|
});
|
|
406
463
|
|
|
407
464
|
playPauseButtonEl.addEventListener('click', () => {
|
|
@@ -430,9 +487,7 @@ const showVideoPreview = (videoBlob) => {
|
|
|
430
487
|
transform: 'translateX(calc(-100% - 8px))',
|
|
431
488
|
width: '140px',
|
|
432
489
|
padding: '12px 0',
|
|
433
|
-
backgroundColor: 'rgba(255,255,255,0.15)',
|
|
434
490
|
color: 'white',
|
|
435
|
-
border: '1px solid rgba(255,255,255,0.4)',
|
|
436
491
|
borderRadius: '25px',
|
|
437
492
|
cursor: 'pointer',
|
|
438
493
|
fontSize: '14px',
|
|
@@ -441,6 +496,7 @@ const showVideoPreview = (videoBlob) => {
|
|
|
441
496
|
textAlign: 'center',
|
|
442
497
|
zIndex: '1000',
|
|
443
498
|
pointerEvents: 'auto',
|
|
499
|
+
...liquidGlassStyles(),
|
|
444
500
|
});
|
|
445
501
|
retakeButtonEl.addEventListener('click', async () => {
|
|
446
502
|
cleanupPreview();
|
|
@@ -560,14 +616,18 @@ const capturePrescriptionImage = async () => {
|
|
|
560
616
|
state.cropImgRef?.setRectangleDisplay?.();
|
|
561
617
|
state.cropImgRef?.showSuccessBorder?.();
|
|
562
618
|
|
|
563
|
-
//
|
|
564
|
-
//
|
|
565
|
-
//
|
|
619
|
+
// Accumulate this side. Upload is deferred to submit so multiple box sides
|
|
620
|
+
// land in a single document via the package flow (parity with anydocs
|
|
621
|
+
// multi-page). In packageMode: true each side is added to state.packageScans
|
|
622
|
+
// and uploaded once on submit; in packageMode: false each side POSTs to
|
|
623
|
+
// /rest/send-cropped as its own document.
|
|
566
624
|
state.updateHandler?.({ status: 'processing_started' });
|
|
567
625
|
state.docReadyResult = await docReady();
|
|
568
626
|
state.updateHandler?.({ status: 'processing_completed' });
|
|
569
627
|
|
|
570
|
-
|
|
628
|
+
boxSideCount += 1;
|
|
629
|
+
|
|
630
|
+
const clearCropPreview = () => {
|
|
571
631
|
if (state.cropImgRef) {
|
|
572
632
|
const previewImg = state.cropImgRef.previewImg;
|
|
573
633
|
if (previewImg) {
|
|
@@ -578,6 +638,23 @@ const capturePrescriptionImage = async () => {
|
|
|
578
638
|
const cctx = state.cropImgRef.getContext('2d');
|
|
579
639
|
cctx?.clearRect(0, 0, state.cropImgRef.width, state.cropImgRef.height);
|
|
580
640
|
}
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
// Re-open the box camera to capture another side of the SAME box. Keeps the
|
|
644
|
+
// accumulated package scans and locks to the box overlay (toggle hidden).
|
|
645
|
+
const captureAnotherSide = async () => {
|
|
646
|
+
clearCropPreview();
|
|
647
|
+
showVideoOverlay();
|
|
648
|
+
state.prescriptionLabelOverlay?.hide?.();
|
|
649
|
+
state.prescriptionSquareOverlay?.show?.();
|
|
650
|
+
state.prescriptionLabelGuide?.show?.();
|
|
651
|
+
state.prescriptionOverlayToggleButton?.hide?.();
|
|
652
|
+
await newStartLens();
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
// Restart for a brand new document (multi-submission "capture another").
|
|
656
|
+
const restartPrescription = async () => {
|
|
657
|
+
clearCropPreview();
|
|
581
658
|
showVideoOverlay();
|
|
582
659
|
state.prescriptionSquareOverlay?.show?.();
|
|
583
660
|
state.prescriptionLabelGuide?.show?.();
|
|
@@ -585,6 +662,60 @@ const capturePrescriptionImage = async () => {
|
|
|
585
662
|
await newStartLens();
|
|
586
663
|
};
|
|
587
664
|
|
|
665
|
+
const finalizeBoxDocument = async () => {
|
|
666
|
+
boxSideCount = 0;
|
|
667
|
+
|
|
668
|
+
if (state.packageMode && !state.enableSubmit && typeof state.customSubmitHandler !== 'function') {
|
|
669
|
+
const packageInfo = await ensurePackageUploaded();
|
|
670
|
+
state.resultSetter?.({ ...(packageInfo || {}), image: state.finalImage });
|
|
671
|
+
removeOverlay();
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const result = await submitPrescriptionImage(state.finalImage);
|
|
676
|
+
if (state.multiSubmission && result) {
|
|
677
|
+
promptForAnotherCapture(restartPrescription);
|
|
678
|
+
} else {
|
|
679
|
+
removeOverlay();
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// Multi-side box capture: after each side, ask whether to capture another
|
|
684
|
+
// side of the same box (accumulated into one document) or submit now.
|
|
685
|
+
if (state.prescriptionLabelBoxMultiSide) {
|
|
686
|
+
state.resultSetter?.(state.finalImage);
|
|
687
|
+
|
|
688
|
+
// Cap the number of sides per box; once reached, submit automatically
|
|
689
|
+
// instead of prompting for another side.
|
|
690
|
+
const maxSides = state.prescriptionLabelBoxMaxSides;
|
|
691
|
+
if (maxSides && boxSideCount >= maxSides) {
|
|
692
|
+
await finalizeBoxDocument();
|
|
693
|
+
state.updateHandler?.({ status: 'capture_completed' });
|
|
694
|
+
return state.finalImage;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
const sideModal = createMultiCaptureModal(
|
|
698
|
+
state.container,
|
|
699
|
+
async () => {
|
|
700
|
+
sideModal.remove();
|
|
701
|
+
await captureAnotherSide();
|
|
702
|
+
},
|
|
703
|
+
async () => {
|
|
704
|
+
sideModal.remove();
|
|
705
|
+
await finalizeBoxDocument();
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
message: state.prescriptionLabelBoxSideMessage,
|
|
709
|
+
yesButtonText: state.prescriptionLabelBoxSideAddText,
|
|
710
|
+
noButtonText: state.prescriptionLabelBoxSideSubmitText,
|
|
711
|
+
}
|
|
712
|
+
);
|
|
713
|
+
sideModal.show();
|
|
714
|
+
|
|
715
|
+
state.updateHandler?.({ status: 'capture_completed' });
|
|
716
|
+
return state.finalImage;
|
|
717
|
+
}
|
|
718
|
+
|
|
588
719
|
state.submitButton = createSubmitButton(
|
|
589
720
|
state.container,
|
|
590
721
|
async () => {
|
|
@@ -722,6 +853,8 @@ export const cleanupPrescriptionLabelRecording = () => {
|
|
|
722
853
|
previewChunks = [];
|
|
723
854
|
submissionChunks = [];
|
|
724
855
|
isRecording = false;
|
|
856
|
+
boxSideCount = 0;
|
|
857
|
+
clearRecordingTimers();
|
|
725
858
|
updateRecordingUI(false);
|
|
726
859
|
stopCroppedDrawLoop();
|
|
727
860
|
cleanupPreview();
|
package/core/constants.js
CHANGED
|
@@ -89,17 +89,21 @@ export const MESSAGES = {
|
|
|
89
89
|
PRESCRIPTION_SQUARE_GUIDE: 'Position the prescription label within the square.\n\nPress the capture button to take a photo of the label.',
|
|
90
90
|
PRESCRIPTION_TOGGLE_BOTTLE: 'Bottle',
|
|
91
91
|
PRESCRIPTION_TOGGLE_BOX: 'Box',
|
|
92
|
+
PRESCRIPTION_BOX_SIDE: 'Capture another side of the box?',
|
|
93
|
+
PRESCRIPTION_BOX_SIDE_ADD: 'Capture another side',
|
|
94
|
+
PRESCRIPTION_BOX_SIDE_SUBMIT: 'Submit',
|
|
92
95
|
CODE_STRIPS: 'Position code strip in rectangle',
|
|
93
96
|
CHECK_POSITION: 'We could not detect a check, hope this will make it easier',
|
|
94
97
|
ANYDOC_ADD_PAGE: 'Add Page',
|
|
95
98
|
ANYDOC_SUBMIT: 'Submit',
|
|
96
99
|
ANYDOC_FLIP: 'Please flip the document and capture the other side',
|
|
97
100
|
ANYDOC_FLIP_CONTINUE: 'Continue',
|
|
101
|
+
ANYDOC_GUIDE: 'Position the document within the frame.\n\nPress the capture button to scan a page. Use "Add Page" to capture multiple pages, then press "Submit" when done.',
|
|
98
102
|
MULTI_CAPTURE_PROMPT: 'Do you need to capture another document?',
|
|
99
103
|
MULTI_CAPTURE_YES: 'Capture another',
|
|
100
104
|
MULTI_CAPTURE_NO: "No, I'm done",
|
|
101
105
|
BATCH_FINISHING: 'Completing batch...',
|
|
102
|
-
BATCH_FINISH_FAILED: 'Failed to
|
|
106
|
+
BATCH_FINISH_FAILED: 'Failed to submit the batch. Would you like to try again?',
|
|
103
107
|
BATCH_FINISH_RETRY: 'Retry',
|
|
104
108
|
BATCH_FINISH_CANCEL: 'Close without notifying',
|
|
105
109
|
AUTH_FAILED: 'Authorization failed, please provide correct client-id or contact customer support at support@veryfi.com',
|
package/core/lifecycle.js
CHANGED
package/core/state.js
CHANGED
|
@@ -143,6 +143,9 @@ export const state = {
|
|
|
143
143
|
anydocShowFlipMessage: false,
|
|
144
144
|
anydocFlipMessageText: MESSAGES.ANYDOC_FLIP,
|
|
145
145
|
anydocFlipContinueText: MESSAGES.ANYDOC_FLIP_CONTINUE,
|
|
146
|
+
anydocShowGuide: false,
|
|
147
|
+
anydocGuideText: MESSAGES.ANYDOC_GUIDE,
|
|
148
|
+
anydocGuide: null,
|
|
146
149
|
capCircleRadius: DEFAULTS.CAP_CIRCLE_RADIUS,
|
|
147
150
|
bottleCapText: MESSAGES.BOTTLE_CAP,
|
|
148
151
|
|
|
@@ -219,6 +222,12 @@ export const state = {
|
|
|
219
222
|
prescriptionLabelBottleLabel: MESSAGES.PRESCRIPTION_TOGGLE_BOTTLE,
|
|
220
223
|
prescriptionLabelBoxLabel: MESSAGES.PRESCRIPTION_TOGGLE_BOX,
|
|
221
224
|
prescriptionOverlayToggleButton: null,
|
|
225
|
+
prescriptionLabelBoxMultiSide: true,
|
|
226
|
+
prescriptionLabelBoxMaxSides: 4,
|
|
227
|
+
prescriptionLabelBoxSideMessage: MESSAGES.PRESCRIPTION_BOX_SIDE,
|
|
228
|
+
prescriptionLabelBoxSideAddText: MESSAGES.PRESCRIPTION_BOX_SIDE_ADD,
|
|
229
|
+
prescriptionLabelBoxSideSubmitText: MESSAGES.PRESCRIPTION_BOX_SIDE_SUBMIT,
|
|
230
|
+
prescriptionLabelMaxVideoDuration: 12,
|
|
222
231
|
preferredVideoFormat: null,
|
|
223
232
|
|
|
224
233
|
codeStripsOverlay: null,
|
|
@@ -350,6 +359,7 @@ export const resetState = () => {
|
|
|
350
359
|
state.blueprintsData = null;
|
|
351
360
|
state.anydocPages = [];
|
|
352
361
|
state.anydocPageControls = null;
|
|
362
|
+
state.anydocGuide = null;
|
|
353
363
|
state.packageScans = [];
|
|
354
364
|
state.packageFilename = null;
|
|
355
365
|
state.packageUploadId = null;
|
package/core/ui-renderer.js
CHANGED
|
@@ -163,6 +163,13 @@ export const renderVideoOverlayIfNeeded = () => {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
if (state.lensFlavor === 'anydocs' && state.anydocShowGuide && !state.anydocGuide) {
|
|
167
|
+
state.anydocGuide = createPrescriptionLabelGuide(
|
|
168
|
+
state.videoOverlay?.overlay || state.container,
|
|
169
|
+
{ text: state.anydocGuideText, id: 'veryfi-anydoc-guide' }
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
166
173
|
renderWatermarkIfNeeded();
|
|
167
174
|
};
|
|
168
175
|
|