RangerMauve / discovery-swarm-web

Abstracts away discovery-swarm interaction with WebRTC and a websocket gateway.
MIT License
43 stars 9 forks source link

use npm published `discovery-swarm-webrtc` instead of github #7

Open 100ideas opened 5 years ago

100ideas commented 5 years ago

discovery-swarm-web depends on

"@geut/discovery-swarm-webrtc": "github:geut/discovery-swarm-webrtc#sub-signalhub",

which as you can see is being loaded via npm/yarn's "github:/" syntax.

the sub-signalhub branch of discovery-swarm-webrtc lists its package version number as 1.0.1. This version appears to be hosted on npm.

Some environments (browser prototyping IDEs in particular) don't have npm/yarn toolchains that can fetch packages via github:<user>/<repo>. Unless its necessary, it would be easier in some browser-based dev environments to test client-side dat features that depend on discovery-swarm if this dependency was loaded from npm.

"@geut/discovery-swarm-webrtc": "v1.0.1",

That said, I realize @geut/discovery-swarm-webrtc is changing a lot right now and if the v2 branch will be compatible again in the future with discovery-swarm-web then I guess just wait until then to change things.

tinchoz49 commented 5 years ago

Hi @100ideas !

The new version of discovery-swarm-webrtc change a lot internally:

But the API is pretty much the same. It should be easier to upgrade discovery-swarm-web I will take a look if I can help with a PR. @RangerMauve are you agree?

RangerMauve commented 5 years ago

@tinchoz49 I'm up for a PR to this repo, but I also think that getting a hyperswarm-web together would be important for the near future so we can release the Dat2 stuff in the SDK and stuff. :o

tinchoz49 commented 5 years ago

I also think that getting a hyperswarm-web together would be important for the near future so we can release the Dat2 stuff in the SDK and stuff

Absolutely, it would be the next step.

100ideas commented 5 years ago

thanks for the updates. I will keep an eye on both.

juliangruber commented 5 years ago

The sub-signalhub branch has been deleted so this module currently doesn't install.

tinchoz49 commented 5 years ago

Thanks @juliangruber for reporting that, sorry everyone, it was my fault. I already restore that branch and I will try to update discovery-swarm-web to the last version.

tinchoz49 commented 4 years ago

@100ideas how are you?

We update the discovery-swarm-webrtc, it should be working now with the last version.

100ideas commented 4 years ago

How should I go about testing the new version in a client-side toy react app?

I wanted to use dat-sdk, but specifying it seemed to force yarn to choose an older version of discovery-swarm-web that doesn't have the updated @geut/discovery-swarm-webrtc version.

  1. dat-sdk@0.3.5 depends on hyperdiscovery@10.1.0.

  2. hyperdiscovery@10.1.0 depends on discovery-swarm-web@^1.3.0 (which resolves to discovery-swarm-web@^1.4.1)

  3. discovery-swarm-web@^1.4.1 depends on:

so specifying dat-sdk ends requiring two different versions of discovery-swarm-web & hyperdiscovery

Will hyperdiscovery@10.1.0 work with discovery-swarm-web@^2.0.0? If so, package.json for hyperdiscovery should be updated.

I don't need to use dat-sdk, I am just looking forward to it. I'll try some other way of testing client side.


torchy:~/d/d/d/react-dqegh1 on image
$ yarn why @geut/discovery-swarm-webrtc
yarn why v1.17.3
[1/4] 🤔  Why do we have the module "@geut/discovery-swarm-webrtc"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@geut/discovery-swarm-webrtc@1.0.1"
info Reasons this module exists
   - "dat-sdk#hyperdiscovery#discovery-swarm-web" depends on it
   - Hoisted from "dat-sdk#hyperdiscovery#discovery-swarm-web#@geut#discovery-swarm-webrtc"
info Disk size without dependencies: "20KB"
info Disk size with unique dependencies: "232KB"
info Disk size with transitive dependencies: "12.55MB"
info Number of shared dependencies: 20
✨  Done in 0.87s.

torchy:~/d/d/d/react-dqegh1 on image
$ yarn why discovery-swarm-web
yarn why v1.17.3
[1/4] 🤔  Why do we have the module "discovery-swarm-web"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "discovery-swarm-web@1.4.1"
info Reasons this module exists
   - "dat-sdk#hyperdiscovery" depends on it
   - Hoisted from "dat-sdk#hyperdiscovery#discovery-swarm-web"
info Disk size without dependencies: "52KB"
info Disk size with unique dependencies: "1.26MB"
info Disk size with transitive dependencies: "26.5MB"
info Number of shared dependencies: 72
✨  Done in 0.96s.

torchy:~/d/d/d/react-dqegh1 on image
$ yarn why hyperdiscovery
yarn why v1.17.3
[1/4] 🤔  Why do we have the module "hyperdiscovery"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "hyperdiscovery@9.0.2"
info Has been hoisted to "hyperdiscovery"
info Reasons this module exists
   - Hoisted from "dat-sdk#hyperdiscovery#discovery-swarm-web#hyperdiscovery"
   - Hoisted from "dat-sdk#hyperdiscovery#discovery-swarm-web#discovery-swarm-stream#hyperdiscovery"
info Disk size without dependencies: "32KB"
info Disk size with unique dependencies: "376KB"
info Disk size with transitive dependencies: "4MB"
info Number of shared dependencies: 34
=> Found "dat-sdk#hyperdiscovery@10.1.0"
info This module exists because "dat-sdk" depends on it.
info Disk size without dependencies: "52KB"
info Disk size with unique dependencies: "448KB"
info Disk size with transitive dependencies: "26.55MB"
info Number of shared dependencies: 68
✨  Done in 0.95s.
100ideas commented 4 years ago

fyi I set up a web sandbox to mess with discovery-swarm-web@2.0.0 here: https://runkit.com/100ideas/discovery-swarm-web-2-0-0

100ideas commented 4 years ago

ok I put together a toy app to play with dat-sdk. was originally hoping to get it working in a browser IDE.

I forked the repos mentioned above and upgraded the deps to use discovery-swarm-web@2.0.0 and hyperdiscovery@10.0.1. seems to be working.

I am looking forward to the isomorphic + standardized + multiwriter dat api under development in dat-sdk, but I actually found it more confusing to use - wasn't sure how to configure DatArchive idiomatically to fetch all updates from the (hyperdrive) archive and subscribe to changes. I got it working but it feels hacky. Feedback appreciated.

tinchoz49 commented 4 years ago

I love mobx :smile: !

So I think we should start by updating hyperdiscovery too. I will do it this weekend.

RangerMauve commented 4 years ago

Just published 10.2.0 of hyperdiscovery with the latest discovery-swarm-web! I'll get it into the SDK in a sec. 💜

RangerMauve commented 4 years ago

Published new SDK as well https://github.com/datproject/sdk/releases/tag/v0.3.6

100ideas commented 4 years ago

Nice! I'll update the demo and give it a try in a day or two hopefully.


me asking over at https://gitter.im/datproject/discussions?at=5dc39f582f8a0343574d7d42:

@RangerMauve Thanks! (re keeping dat-sdk DatArchive synced and dom reacting to changes).

My approach was to attach an event handler to the 'sync' event, debounce it (gets called like 50+ times right away), then recursively readdir() and readFile() to crawl the archive file tree. I've been assuming 'sync' gets called when the archive finishes getting incoming updates (not true?)

if I were to poll with .download as you suggested, should I do that for every file/dir or just root of hyperdrive fs tree?

... @100ideas Not sure about sync off the top of my head. I think so? If you invoke .download('/') it'll recursively download all the contents for you.