Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: precached webui works in offline mode #782

Merged
merged 6 commits into from
Oct 17, 2019
Merged

Conversation

lidel
Copy link
Member

@lidel lidel commented Oct 4, 2019

This PR adds precache logic for Web UI which is executed when IPFS API client (or full node) starts.
The main purpose is to make Web UI load instantly in Brave and work in offline environments.

closes #765, closes #682, part of #716 🦁

How does it work?

During the build .tar archives are placed in add-on/dist/precache.
This makes them available to fetch over *-extension://{extension-id}/dist/precache/* URLs.
Right now we have only one archive: a 22MB file with release version of Web UI.

When IPFS client starts, preache logic is executed:

  1. read Web UI CID from Companion's config
  2. check if local repo contains mentioned CID.
    • if it is present, finish
    • if missing, continue to the next step
  3. precache asynchronously:
    • fetch TAR archive from *-extension://{extension-id}/dist/precache/*.tar
    • pass entire directory tree as unpacked streams to ipfs.add
    • confirm produced CID is matching the one from step (1)

Checklist

  • add TAR to precache dir in Chromium bundle
  • async import of TAR archives
  • build script extracts webui CID from state.js#L9
    (keeps a single place to update instead of two)

Known Issues

@@ -25,7 +25,6 @@ const chromeDefaultOpts = {
Swarm: [
// optional ws-star signaling provides a backup for non-LAN peer discovery
// (this will be removed when autorelay and DHT are stable in js-ipfs)
'/dns4/ws-star1.par.dwebops.pub.com/tcp/443/wss/p2p-websocket-star',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was just a dev alias for ws-star.discovery.libp2p.io

lidel added 3 commits October 15, 2019 13:53
For now we add a TAR with Web UI as a PoC.
Next step is to make it more generic. There should be a list of CIDs
that should be recursively precached and added to node during the boot.
- async import of TAR archives
- streaming where possible
- makes webui open instantly in Chromium

Known Issue: /api/v0/add does not work with latest js-ipfs,
needs to be addressed before merging this to master.
@lidel lidel force-pushed the feat/offline-webui branch from 15f2be7 to 073f058 Compare October 15, 2019 12:03
@lidel lidel force-pushed the feat/offline-webui branch 2 times, most recently from ce27b0a to e5572f8 Compare October 16, 2019 11:17
@lidel lidel force-pushed the feat/offline-webui branch 2 times, most recently from 6aac086 to 625a826 Compare October 16, 2019 13:45
@lidel lidel requested review from autonome and hugomrdias October 16, 2019 13:51
@lidel lidel marked this pull request as ready for review October 16, 2019 13:52
@lidel lidel merged commit 0679e3e into master Oct 17, 2019
@lidel lidel deleted the feat/offline-webui branch October 17, 2019 22:21
@autonome
Copy link

autonome commented Oct 17, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Brave: Web UI should be available instantly Ensure blessed Web UI is pinned
3 participants