veryfi-lens-wasm 2.0.5-beta.2 → 2.0.5-beta.3

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.
@@ -221,7 +221,20 @@ export function createFileUpload(container, captureUploaded, onSubmit) {
221
221
  imagePreview.style.display = 'block';
222
222
 
223
223
  cropButton.style.display = 'none';
224
- submitButton.style.display = 'inline-block';
224
+
225
+ // Check if submit button should be shown based on enableSubmit setting
226
+ if (container.dataset.enableSubmit !== 'false') {
227
+ submitButton.style.display = 'inline-block';
228
+ } else {
229
+ // If submit is disabled, call the callback directly with the processed image
230
+ // Format the result to match the document flavor format
231
+ console.log("Submit disabled, returning processed image directly");
232
+ onSubmit({
233
+ image: processedImage,
234
+ // Add any other properties that might be expected
235
+ doc_type: 'receipt'
236
+ });
237
+ }
225
238
  } catch (error) {
226
239
  console.error('Error during image processing:', error);
227
240
  alert(`An error occurred: ${error.message}. Please try again or check your connection. If the problem persists, contact support.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfi-lens-wasm",
3
- "version": "2.0.5-beta.2",
3
+ "version": "2.0.5-beta.3",
4
4
  "description": "Lens For Web SDK with WASM",
5
5
  "main": "veryfi-lens.js",
6
6
  "type": "module",
package/veryfi-lens.js CHANGED
@@ -1933,6 +1933,7 @@ const VeryfiLens = (function () {
1933
1933
  showCamera: async (setter) => {
1934
1934
  try {
1935
1935
  state.debug_mode && console.log("Starting camera initialization");
1936
+ console.log(setter);
1936
1937
  setter && (state.resultSetter = setter);
1937
1938
 
1938
1939
  // Ensure container exists
@@ -1944,6 +1945,9 @@ const VeryfiLens = (function () {
1944
1945
  }
1945
1946
  }
1946
1947
 
1948
+ // Pass enableSubmit setting to container for use by components
1949
+ state.container.dataset.enableSubmit = state.enableSubmit.toString();
1950
+
1947
1951
  // Create core elements and verify success
1948
1952
  const elementsCreated = await createCoreElements();
1949
1953
 
@@ -1957,7 +1961,24 @@ const VeryfiLens = (function () {
1957
1961
  // Render appropriate UI elements based on lens flavor
1958
1962
  switch (state.lensFlavor) {
1959
1963
  case 'upload':
1960
- !state.fileUpload && (state.fileUpload = createFileUpload(state.container, captureUploaded, handleSubmit));
1964
+ !state.fileUpload && (state.fileUpload = createFileUpload(state.container, captureUploaded, (result) => {
1965
+ // Ensure consistent format for the result
1966
+ const formattedResult = typeof result === 'string'
1967
+ ? { image: result, doc_type: 'receipt' }
1968
+ : result;
1969
+
1970
+ // If enableSubmit is false, we'll get the image here directly after cropping
1971
+ if (!state.enableSubmit) {
1972
+ state.debug_mode && console.log("Submit disabled, handling image directly");
1973
+ if (state.resultSetter && typeof state.resultSetter === 'function') {
1974
+ state.resultSetter(formattedResult);
1975
+ }
1976
+ // Don't call handleSubmit here, just return the image
1977
+ } else {
1978
+ // Normal flow when enableSubmit is true
1979
+ handleSubmit(formattedResult.image);
1980
+ }
1981
+ }));
1961
1982
  // Add exit button for upload flavor
1962
1983
  if (state.exitButton) {
1963
1984
  createExitButton(state.container, {