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

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

Open
100ideas opened this issue Sep 17, 2019 · 14 comments
Open

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

100ideas opened this issue Sep 17, 2019 · 14 comments

Comments

@100ideas
Copy link

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
Copy link
Collaborator

Hi @100ideas !

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

  • we are using mmst to minimize connections.
  • we replaced the signalhub in favor of simple-signal.

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
Copy link
Owner

@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
Copy link
Collaborator

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
Copy link
Author

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

@juliangruber
Copy link

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

@tinchoz49
Copy link
Collaborator

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
Copy link
Collaborator

@100ideas how are you?

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

@100ideas
Copy link
Author

100ideas commented Nov 5, 2019

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
Copy link
Author

100ideas commented Nov 5, 2019

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 added a commit to 100ideas/dat-sdk that referenced this issue Nov 5, 2019
trying to use `dat-sdk` on stackblitz but its "turbo" npm resolver is choking on a github import in a dependant package.json

`dat-sdk` -> `hyperdiscovery` -> `discovery-swarm-web@<2.0.0` (https://github.com/RangerMauve/discovery-swarm-web/blob/a50131cb169e6e190bc2ee750342f3a40a3df590/package.json)

not sure how else to override so forked `dat-sdk` & `hyperdiscovery` to hack package.jsons

RangerMauve/discovery-swarm-web#7
100ideas added a commit to 100ideas/dat-sdk that referenced this issue Nov 5, 2019
trying to use `dat-sdk` on stackblitz but its "turbo" npm resolver is choking on a github import in a dependant package.json

`dat-sdk` -> `hyperdiscovery` -> `discovery-swarm-web@<2.0.0` (https://github.com/RangerMauve/discovery-swarm-web/blob/a50131cb169e6e190bc2ee750342f3a40a3df590/package.json)

testing if stackblitz can handle github package.json imports in dependant packages like 

```js
// probably not since this is similar to what is not working in discovery-swarm-web@1.4.1
"hyperdiscovery": "github:100ideas/hyperdiscovery"

// docs say this works
"hyperdiscovery": "https://github.com/100ideas/hyperdiscovery"
```

not sure how else to override so forked `dat-sdk` & `hyperdiscovery` to hack package.jsons

RangerMauve/discovery-swarm-web#7
@100ideas
Copy link
Author

100ideas commented Nov 5, 2019

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
Copy link
Collaborator

I love mobx 😄 !

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

@RangerMauve
Copy link
Owner

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

@RangerMauve
Copy link
Owner

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

@100ideas
Copy link
Author

100ideas commented Nov 7, 2019

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

  • @100ideas update your demo
  • ask about using archive.download(path) vs registering callback w/ 'sync' event that triggers crawl (readdir() + readFile()) of archive fs
    • guess .download is a smarter choice?
  • test and report back here

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.

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

No branches or pull requests

4 participants