Dynamsoft / Dynamic-Web-TWAIN

Dynamic Web TWAIN for package managers
Other
66 stars 24 forks source link

Error after updating npm package to 17.3.1 #29

Closed lyubomirr closed 1 year ago

lyubomirr commented 1 year ago

Hello, I am using the 'dwt' npm package version 17.2.4 in my Angular projects and everything works fine. When I update the package to 17.3.1 an error appears when I try to scan:

ERROR (1) "Cannot read properties of undefined (reading 'closeAll')" {err: TypeError: Cannot read properties of undefined (reading 'closeAll'), name: TypeError, url: http://localhost:4200/order/214a7cac-c29a-403b-a3d9-268fd7e845c7/details, userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36, userAgentLang: bg-BG, userAgentPlatform: MacIntel, stackTrace: TypeError: Cannot read properties of undefined (reading 'closeAll'), at http://localhost:4200/node_modules_dwt_dist_dynamsoft_webtwain_min_mjs.js:25687:246, at b.getScripts (http://localhost:4200/node_modules_dwt_dist_dynamsoft_webtwain_min_mjs.js:7450:19), at _ (http://localhost:4200/node_modules_dwt_dist_dynamsoft_webtwain_min_mjs.js:25685:637), at http://localhost:4200/node_modules_dwt_dist_dynamsoft_webtwain_min_mjs.js:26226:65, at Object.U (http://localhost:4200/node_modules_dwt_dist_dynamsoft_webtwain_min_mjs.js:5611:11), at f.I.DWT.CreateDWTObjectEx (http://localhost:4200/node_modules_dwt_dist_dynamsoft_webtwain_min_mjs.js:26224:17), at http://localhost:4200/main.js:27541:36, at ZoneDelegate.invoke (http://localhost:4200/polyfills.js:7560:158), at Object.onInvoke (http://localhost:4200/vendor.js:128605:25), at ZoneDelegate.invoke (http://localhost:4200/polyfills.js:7560:46), _userId: a2696a7e-d7b5-4bfa-9c0d-24025a3ea628}

I have remove the spinners and backdrops and also I'm not using the default viewer (I suspect it has something to do with that). These are my configurations:

this.Dynamsoft.DWT.UseDefaultViewer = false;
this.Dynamsoft.DWT.OnWebTwainPreExecute = () => {};
this.Dynamsoft.DWT.OnWebTwainPostExecute = () => {};
(this.Dynamsoft as any).OnWebTwainNotFoundOnMacCallback = () => {};
(this.Dynamsoft as any).OnWebTwainNotFoundOnWindowsCallback = () => {};
(this.Dynamsoft as any).OnWebTwainNotFoundOnLinuxCallback = () => {};
(this.Dynamsoft as any).OnRemoteWebTwainNotFoundCallback = () => {};
lunaaaw commented 1 year ago

We cannot reproduce your issue, could you please share the sample project?

lyubomirr commented 1 year ago

https://github.com/lyubomirr/web-twain-demo - here it is

lunaaaw commented 1 year ago

Thanks! It seems to be our bug, please modify your code as follows, and we will fix it in our next release.

private initialize(): Promise { return new Promise((resolve, reject) => { import('dwt').then( (dynamsoftModule: any) => { this.Dynamsoft = dynamsoftModule.default; this.setup();

lyubomirr commented 1 year ago

Thanks for the fast respose! I just have one question, the code you've send seems the same, what is the difference? Or the problem lies within the code you have sent?

lunaaaw commented 1 year ago

Sorry, I missed some lines

private initialize(): Promise { return new Promise((resolve, reject) => { import('dwt').then( (dynamsoftModule: any) => { this.Dynamsoft = dynamsoftModule.default; this.setup(); this.Dynamsoft.DWT.Containers=[{WebTwainId: AppComponent.WebTwainId,ContainerId:"dwtcontrolContainer",Width:0,Height:0}] this.Dynamsoft.DWT.RegisterEvent("OnWebTwainReady",()=>{ this.webTwainInstance = this.Dynamsoft.DWT.GetWebTwain("dwtcontrolContainer") resolve() }) this.Dynamsoft.DWT.Load() }, (err) => reject(err) ); }); }

lyubomirr commented 1 year ago

Thanks.