WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.58k stars 226 forks source link

Offline mode (PWA) #133

Open danielbachhuber opened 1 year ago

danielbachhuber commented 1 year ago

Please use the project scoping PR to discuss this feature

Network access on contributor days is always problematic.

Once we have something like https://github.com/WordPress/wordpress-playground/issues/104, it would be helpful to have offline support for WordPress Playground. This way, a new contributor could download WordPress Playground once and then be able to use it for the rest of the day.

adamziel commented 1 year ago

If WordPress Playground was a Progressive Web App, it could be:

Technically, this would require downloading all the WordPress assets that are currently now hosted on the server. Doing it in the background in idle time after the initial paint should be fine.

bgrgicak commented 4 months ago

@adamziel I will explore this one and see if I can make any progress on it.

bgrgicak commented 4 months ago

I started by adding the Vite PWA plugin and configuring it. The next step is to enable offline support and ensure it works in development and production.

bgrgicak commented 4 months ago

Playground loads only a part of WordPress on the first load. Other files are loaded as needed, we will need to find a way to preload all files for full offline support.

adamziel commented 2 months ago

The offline mode mostly works when we shipping a full, zipped WordPress release. That's what the PR previewer does, e.g. try previewing this PR. We could add a separate offline mode very easily just by using that full zip bundle and caching it in the Service Worker.

bgrgicak commented 1 month ago

After some discussion with @WordPress/playground-maintainers we create a list of tasks that should add offline and PWA support:

bgrgicak commented 1 month ago

Should Playground use browser storage and support networking as the default option when installed?

If yes, it would be great for us to add a site switcher because we can't modify the url.

adamziel commented 1 month ago

Should Playground use browser storage and support networking as the default option when installed?

It would be handy, yes, but it's not a blocker.

brandonpayton commented 1 month ago

Flush cache when Playground updates

I wasn't able to get to this today but plan to look at this tomorrow if you don't tackle it first, @bgrgicak.

bgrgicak commented 1 month ago

@adamziel has a PR for CLI offline support https://github.com/WordPress/wordpress-playground/pull/1523

bgrgicak commented 3 weeks ago

In a future iteration of offline support, we could add a background check to see if there were any updates to Playground and update the cache with the latest version of Playground.

Today this will work on reload, but mobile and desktop apps aren't usually reloaded.

bgrgicak commented 2 weeks ago

I got offline support to work in the browser. Here is a list of all open PR that are required to make it work.

bgrgicak commented 1 week ago

Please share any future comments in this PR