neodynamic / JSPrintManager

Advanced Client-side Printing & Scanning Solution for Javascript
https://www.neodynamic.com/products/printing/js-print-manager/
252 stars 137 forks source link

Getting error in React version "jsprintmanager": "^5.0.3", #55

Open developers-veintestech opened 1 year ago

developers-veintestech commented 1 year ago

I am getting undefined for JSPM `

import * as JSPM from 'jsprintmanager' componentDidMount() { JSPM.JSPrintManager.Caller = this; //get client installed scanners JSPM.JSPrintManager.getScanners().then(function (scannersList) { JSPM.JSPrintManager.Caller.setScannerDevices(scannersList); }); }

` image

developers-veintestech commented 1 year ago

I am getting undefined for JSPM `

import * as JSPM from 'jsprintmanager' componentDidMount() { JSPM.JSPrintManager.Caller = this; //get client installed scanners JSPM.JSPrintManager.getScanners().then(function (scannersList) { JSPM.JSPrintManager.Caller.setScannerDevices(scannersList); }); }

` image

JSPM has the object but showing undefined in the dom so I added the console log to confirm that Source of error is this function JSPM.JSPrintManager.getScanners().then(function (scannersList) {}) getting this error "t.WS is undefined" Stack trace : ./node_modules/jsprintmanager/JSPrintManager.js/</</<[8]</n.getScanners/<@http://localhost:3000/ATLASNextGen/static/js/170.chunk.js:1307:11 ./node_modules/jsprintmanager/JSPrintManager.js/</</<[8]</n.getScanners@http://localhost:3000/ATLASNextGen/static/js/170.chunk.js:1306:16 componentDidMount@http://localhost:3000/ATLASNextGen/63.1af6fba35a68870c8687.hot-update.js:201:67 commitLifeCycles@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:123146:28 commitLayoutEffects@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:125874:27 callCallback@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:106550:18 invokeGuardedCallbackDev@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:106599:20 invokeGuardedCallback@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:106659:35 commitRootImpl@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:125608:34 unstable_runWithPriority@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:202820:16 runWithPriority$1@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:113956:14 commitRoot@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:125451:24 performSyncWorkOnRoot@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:124793:17 ./node_modules/react-dom/cjs/react-dom.development.js/flushSyncCallbackQueueImpl/<@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:114010:30 unstable_runWithPriority@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:202820:16 runWithPriority$1@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:113956:14 flushSyncCallbackQueueImpl@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:114005:30 flushSyncCallbackQueue@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:113993:7 flushSync@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:124932:11 scheduleRefresh@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:126862:18 attach/renderer.scheduleRefresh@moz-extension://754bb1af-b866-49f6-b026-dc77671f190a/build/react_devtools_backend.js:6578:16 ./node_modules/react-refresh/cjs/react-refresh-runtime.development.js/performReactRefresh/<@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:146386:21 performReactRefresh@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:146375:30 ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js/createDebounceUpdate/enqueueUpdate/refreshTimeout<@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:2866:17 setTimeout handler*enqueueUpdate@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:2864:24 ./src/components/shared/neodynamic-scanner.js/neo-scanner.js/<@http://localhost:3000/ATLASNextGen/63.1af6fba35a68870c8687.hot-update.js:1179:33 ./src/components/shared/neodynamic-scanner.js/neo-scanner.js@http://localhost:3000/ATLASNextGen/63.1af6fba35a68870c8687.hot-update.js:1201:30 __webpack_require__@http://localhost:3000/ATLASNextGen/static/js/bundle.js:857:31 hotApplyInternal@http://localhost:3000/ATLASNextGen/static/js/bundle.js:750:33 hotApply@http://localhost:3000/ATLASNextGen/static/js/bundle.js:412:19 hotUpdateDownloaded/<@http://localhost:3000/ATLASNextGen/static/js/bundle.js:387:22 promise callback*hotUpdateDownloaded@http://localhost:3000/ATLASNextGen/static/js/bundle.js:386:15 hotAddUpdateChunk@http://localhost:3000/ATLASNextGen/static/js/bundle.js:362:13 webpackHotUpdateCallback@http://localhost:3000/ATLASNextGen/static/js/bundle.js:58:29 @http://localhost:3000/ATLASNextGen/63.1af6fba35a68870c8687.hot-update.js:1:17

image

developers-veintestech commented 1 year ago

I am getting undefined for JSPM import * as JSPM from 'jsprintmanager' componentDidMount() { JSPM.JSPrintManager.Caller = this; //get client installed scanners JSPM.JSPrintManager.getScanners().then(function (scannersList) { JSPM.JSPrintManager.Caller.setScannerDevices(scannersList); }); } image

JSPM has the object but showing undefined in the dom so I added the console log to confirm that Source of error is this function JSPM.JSPrintManager.getScanners().then(function (scannersList) {}) getting this error "t.WS is undefined" Stack trace : ./node_modules/jsprintmanager/JSPrintManager.js/</</<[8]</n.getScanners/<@http://localhost:3000/ATLASNextGen/static/js/170.chunk.js:1307:11 ./node_modules/jsprintmanager/JSPrintManager.js/</</<[8]</n.getScanners@http://localhost:3000/ATLASNextGen/static/js/170.chunk.js:1306:16 componentDidMount@http://localhost:3000/ATLASNextGen/63.1af6fba35a68870c8687.hot-update.js:201:67 commitLifeCycles@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:123146:28 commitLayoutEffects@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:125874:27 callCallback@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:106550:18 invokeGuardedCallbackDev@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:106599:20 invokeGuardedCallback@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:106659:35 commitRootImpl@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:125608:34 unstable_runWithPriority@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:202820:16 runWithPriority$1@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:113956:14 commitRoot@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:125451:24 performSyncWorkOnRoot@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:124793:17 ./node_modules/react-dom/cjs/react-dom.development.js/flushSyncCallbackQueueImpl/<@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:114010:30 unstable_runWithPriority@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:202820:16 runWithPriority$1@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:113956:14 flushSyncCallbackQueueImpl@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:114005:30 flushSyncCallbackQueue@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:113993:7 flushSync@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:124932:11 scheduleRefresh@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:126862:18 attach/renderer.scheduleRefresh@moz-extension://754bb1af-b866-49f6-b026-dc77671f190a/build/react_devtools_backend.js:6578:16 ./node_modules/react-refresh/cjs/react-refresh-runtime.development.js/performReactRefresh/<@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:146386:21 performReactRefresh@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:146375:30 ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js/createDebounceUpdate/enqueueUpdate/refreshTimeout<@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:2866:17 setTimeout handler*enqueueUpdate@http://localhost:3000/ATLASNextGen/static/js/vendors~main.chunk.js:2864:24 ./src/components/shared/neodynamic-scanner.js/neo-scanner.js/<@http://localhost:3000/ATLASNextGen/63.1af6fba35a68870c8687.hot-update.js:1179:33 ./src/components/shared/neodynamic-scanner.js/neo-scanner.js@http://localhost:3000/ATLASNextGen/63.1af6fba35a68870c8687.hot-update.js:1201:30 __webpack_require__@http://localhost:3000/ATLASNextGen/static/js/bundle.js:857:31 hotApplyInternal@http://localhost:3000/ATLASNextGen/static/js/bundle.js:750:33 hotApply@http://localhost:3000/ATLASNextGen/static/js/bundle.js:412:19 hotUpdateDownloaded/<@http://localhost:3000/ATLASNextGen/static/js/bundle.js:387:22 promise callback*hotUpdateDownloaded@http://localhost:3000/ATLASNextGen/static/js/bundle.js:386:15 hotAddUpdateChunk@http://localhost:3000/ATLASNextGen/static/js/bundle.js:362:13 webpackHotUpdateCallback@http://localhost:3000/ATLASNextGen/static/js/bundle.js:58:29 @http://localhost:3000/ATLASNextGen/63.1af6fba35a68870c8687.hot-update.js:1:17

image

I found the issue. the latest code is not updated in this repo. it was a web socket issue, web socket wasn't ready `componentDidMount() { JSPM.JSPrintManager.auto_reconnect = true; JSPM.JSPrintManager.start(); JSPM.JSPrintManager.Caller = this; //get client-installed scanners

    JSPM.JSPrintManager.WS.onStatusChanged = () => {
        if (this.jspmWSStatus()) {
            //get scanners
            JSPM.JSPrintManager.getScanners().then((scannersList) => {
                this.setScannerDevices(scannersList)
            });
        }
    };

}

jspmWSStatus = () => {
    if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Open)
        return true;
    else if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Closed) {
        console.warn('JSPrintManager (JSPM) is not installed or not running! Download JSPM Client App from https://neodynamic.com/downloads/jspm');
        return false;
    }
    else if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Blocked) {
        alert('JSPM has blocked this website!');
        return false;
    }
}

`