simonw / datasette-lite

Datasette running in your browser using WebAssembly and Pyodide
https://lite.datasette.io
Apache License 2.0
329 stars 27 forks source link

Turn this into an offline enabled PWA #26

Open simonw opened 2 years ago

simonw commented 2 years ago

https://twitter.com/derjan/status/1521896354745921537

Is it a PWA that I can "install" and use offline?

No reason at all it shouldn't be able to do that.

For it to be useful I would need to implement "open file":

simonw commented 2 years ago

Very relevant example repository: https://github.com/mikeckennedy/pyscript-pwa-example

Here's the Service Worker that caches all of the necessary wheels: https://github.com/mikeckennedy/pyscript-pwa-example/blob/main/static/js/serviceWorker.js

simonw commented 2 years ago

I think step one here is going to be figuring out how to have Datasette Lite load all of its assets from the same domain it is hosted on, rather than pulling things from PyPI.

psychemedia commented 2 years ago

Could a Github Action handle the pulling of packages into a repo from a requirements file. And then use a template Github repository as a way for people to "install" a blank datasette-lite application to a new repo of their own repository that can then build a datasette-lite distribution from a relatively simple set of config files?

simonw commented 2 years ago

Yes, definitely. I think that's the way I want to go - my ideal for Datasette Lite is that it's entirely self-contained, so you can run it on a server (or on your laptop) without it loading anything at all from external servers.

I need to figure out how to have it load the various Python wheels it needs from a URL that I control first though.

psychemedia commented 2 years ago

Does piplite help there? I'm struggling to keep up with all various bits of JupyterLite glue, but I think that tries various fallbacks for where to look for things...

simonw commented 2 years ago

I think I've figured out how to do it: https://pyodide.org/en/stable/usage/loading-packages.html#installing-wheels-from-arbitrary-urls

Pure Python wheels can also be installed from any URL with micropip,

import micropip
micropip.install(
    'https://example.com/files/snowballstemmer-2.0.0-py2.py3-none-any.whl'
)

Micropip decides whether a file is a URL based on whether it ends in ".whl" or not.

westurner commented 1 year ago

Micropip or Mambalite or picomamba or Zig.

"Better integration with conda/conda-forge for building packages" https://github.com/pyodide/pyodide/issues/795

Emscripten-forge > Adding packages: https://github.com/emscripten-forge/recipes#adding-packages

westurner commented 1 year ago

"Progressive Web Apps:Going Offline" https://developers.google.com/codelabs/pwa-training/pwa03--going-offline#0 ( Sep 30, 2022 )