hrgdavor / jscadui

MIT License
30 stars 9 forks source link

local jscad.app does not allow for drag&drop as https://jscad.app does #85

Closed Hermann-SW closed 9 months ago

Hermann-SW commented 9 months ago

On x86 64bit Ubuntu 22.04 I have node/npm versions v20.11.0/10.2.4. I cloned jscadui repo, did "npm i" in top level directory, and "npm start" in "apps/jscad-web". Works, and I can access with https://7950x:5120 in browsers (chromium and firefox). Unlike https://jscad.app drag&drop does not work with local jscad.app. When I move mouse cursor during drag&drop attempt over local jscad.app, the whole broswer display gets grey. When I then release the mouse for drop, "Error: service worker unavailable" shows up at bottom of browser window.

What is needed to make developer jscad.app drag&drop to work?

P.S: Display gets grey for https://jscad.app as well, but when dropping it gets bright again and new model is displayed without error message.

Hermann-SW commented 9 months ago

I opened developertools, cleared console, did drag&drop to local jscad.app. These messages appeared:

Error: service worker unavailable
    nh fs-provider.js:130
    Kp main.js:56
    ondrop main.js:74
    EventHandlerNonNull* main.js:68
main.js:105:12
Error: service worker unavailable
    nh fs-provider.js:130
    Kp main.js:56
    ondrop main.js:74
    EventHandlerNonNull* main.js:68
main.js:87:12

@hrgdavor Can I start service worker somehow?

hrgdavor commented 9 months ago

service worker should work over http on 127.0.0.1/localhost ... it works for me on windows for example on chrome.

otherwise it needs https://

https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API

Quote:

Service workers only run over HTTPS, for security reasons. Most significantly, HTTP connections are susceptible to malicious code injection by man in the middle attacks, and such attacks could be worse if allowed access to these powerful APIs. In Firefox, service worker APIs are also hidden and cannot be used when the user is in private browsing mode.

Quote: note:

On Firefox, for testing you can run service workers over HTTP (insecurely); simply check the Enable Service Workers over HTTP (when toolbox is open) option in the Firefox Devtools options/gear menu.

Hermann-SW commented 9 months ago

@hrgdavor Thanks, I enabled service workers in devtools of firefox running on same machine as local jscad.app. That made drag&drop working over http://localhost:5120 ! But changing the dropped file does not trigger update of display as it does for https://jscad.app :-(

So only local openjscad.xyz server works as it should, so that after a file is dropped and changed later, the changed model is rendered automatically ...

P.S: Just tested drag&drop with chromium and firefox on 64bit Raspberry PiOS against https://jscad.app . Only chromium rerenders when the file gets changed later, firefox does not rerender on file change :-(

So neither chromium (missing service workers) nor firefox (missing rerender on later file change after enabling service workers in devtools) allow for drag+drop with automatic rerender on later file change with local jscad.js — that would have been a good developing setup.

hrgdavor commented 9 months ago

sadly, firefox does not work for that setup on any platform. When we check for lastModified it always returns the initial timastamp.

Hermann-SW commented 9 months ago

@hrgdavor Thank you for clarification. I verified that local jscad.app drag&drop with update on file change works on x86 Ubuntu with chromium webbrowser. Chromium does not have a problem with http only connection (nmp start in jscadui repo does not provide https). So the only issue is that Firefox has a problem (you might want to create an issue against firefox?) Since local jscad.app has no problem, closing this issue now.

hrgdavor commented 7 months ago

uploading a video of refreshing based on changes in package.json

https://github.com/hrgdavor/jscadui/assets/2480762/63821c2d-3b2c-45cb-816a-b99f2f0e24fe