bigcartel / dugway

Easily build and test Big Cartel themes.
https://developers.bigcartel.com/api/themes
MIT License
149 stars 22 forks source link

Service Worker/PWA Installable #177

Closed PixlRainbow closed 3 years ago

PixlRainbow commented 3 years ago

I'd like to be able to give customers the option to install shops as Progressive Web Apps, directly from the store webpage. The base requirements to get a browser to allow this to happen are:

  1. web manifest file containing valid thumbnail images and app names (OK, can be added with custom theme and hosted externally)
  2. HTTPS (OK, BigCartel has HTTPS)
  3. service worker that has a valid fetch handler ( ! )

Normally, I would just have added this as custom theme JavaScript code and hosted it externally, but the problem is that for security reasons web browsers do not allow websites to load service worker scripts from a different domain than the webpage itself, which means BigCartel must be the one to host a common service worker script, unless I do some proxy+DNS shenanigans to give the appearance of serving the script from the same domain.

I'm not sure if this is the correct place to file this issue however, so apologies for the inconvenience caused, though I can offer to do a PR if you'd like

brettchalupa commented 3 years ago

@PixlRainbow thanks for opening up this issue. It sounds like what you and anyone else interested in doing this needs is the ability to upload and reference non-inline JS files in a custom theme, with web manifest files and images being potentially useful too.

We aren't currently working on this exact functionality within our Big Cartel workflow for themes, but we are currently working on improving our Customize Design experience for sellers and custom theme developers like yourself with an openness to ideas like this.

I've captured your request in our list of ideas and requests for what we can improve, thank you for sharing your needs in such detail.

I'm going to close this issue since it's not immediately actionable, but feel free to share more thoughts or ideas in this GH Issue if you have them.

PixlRainbow commented 3 years ago

I was thinking more along the lines of there being just a single common service worker script, that can be optionally pulled by inline JavaScript with navigator.serviceWorker.register('/network.js'), kind of like how there is currently a single common theme.js that provides API functionality for all themes. It would not have to do very much -- it would only need to cache an "you are offline" error page and passthrough everything else, and it would still meet the requirement to trigger an installation offer.

brettchalupa commented 3 years ago

@PixlRainbow that makes sense and is much simpler! I'll capture this simpler version too as an idea for expansion, thanks again.