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

Dat support #1381

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Dat support #1381

wants to merge 5 commits into from

Conversation

avaer
Copy link
Member

@avaer avaer commented Aug 6, 2019

Supports loading URLs from the dat:// protocol.

You can test it out with

exokit -x webvr dat://55861001e843ad2a0d0c1e1274c07cbc4fffa0a7cd83648741bc93c55c027acf/index.html
  • Ensures that all protocols get a :// after the protocol
  • Adds dat-fetch to the protocols list
  • Adds dat to the list f protocols to normalize

TODO:

  • Figure out how to get the Dat libraries to work without process.nextTick
  • Have the regex which detects protocols pull from the list of protocols in fetch.js?
  • Configure persistent storage for Dat archives

Closes #1213

Continuation of #1333.

src/fetch.js Outdated Show resolved Hide resolved
"debug": "ndb",
"install": "node ./scripts/preinstall.js && node-gyp configure --msvs_version=2017 && node-gyp rebuild",
"install": "node ./scripts/preinstall.js && node-gyp configure --msvs_version=2017 && node-gyp rebuild && npm run build-dat",
Copy link
Member Author

Choose a reason for hiding this comment

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

What does this trigger?

-- Would it be compatible with both the Android and the Magic Leap build toolchains?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This just builds up the browserify-ed bundle from the JS source.

Since browserify is just JS it should work on any platform without any hassle.

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 see, that makes sense.

Maybe we could put the output somewhere other than src in that case? That directory feels like it should only have checked-in source and we already have a build directory. 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

SGTM. Would just build/DatArchive.bundle.js work for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe build/js/DatArchive.bundle.js, so it doesn't get too messy with the other binary stuff there.

Capture 87

@avaer
Copy link
Member Author

avaer commented Aug 27, 2019

@RangerMauve How would storage be configured on the different platforms here?

For example, on Android and Magic Leap there are only certain locations that are writable, which is why we have the whole dataPath detection flow.

This PR looks good, but I think we need to ensure compat and across the platforms 👍.

@RangerMauve
Copy link
Collaborator

That's a great point regarding storage! I'm just finishing up bringing the DatArchive API to the SDK and I was thinking of bringing that in to replace node-dat-archive (also for perf reasons).

It's got an easy to use storageLocation parameter that we can use. Where should I store the data by default?

@avaer
Copy link
Member Author

avaer commented Aug 28, 2019

Where should I store the data by default?

We generally try to resolve the writable location as dataPath, which is passed through to window contexts.

If this is a thread-local parameter coming into DatArchive, it would need to be set once per thread.

@RangerMauve
Copy link
Collaborator

Cool, I'll check that out. I think I'll have time either tomorrow or on Sunday. 😁

@RangerMauve
Copy link
Collaborator

K, I updated it to use the SDK and got the bundle compiling into build/js/. It's currently using the default dat storage path so that archive created with the SDK will share storage when they're loaded in Exokit and vise versa.

@RangerMauve
Copy link
Collaborator

RangerMauve commented Sep 1, 2019

This might also bring exokit-web support since the SDK should Just Work™ on the web. 🤯

@RangerMauve
Copy link
Collaborator

Not sure if this is actually working at the moment though. Gonna test it next time I'm on my laptop. :P

@avaer
Copy link
Member Author

avaer commented Sep 1, 2019

This might also bring exokit-web support since the SDK should Just Work™ on the web.

Cool, does it just use a gateway automatically, or something else?

@RangerMauve
Copy link
Collaborator

Yeah! It's connecting to https://discoveryswarm.mauve.moe/

If you want I can help set up an exokit-specific one and configure it to connect there instead. (or whatever other configs we might need)

@avaer
Copy link
Member Author

avaer commented Sep 1, 2019

Yeah, would prefer not to have any third-party network dependencies. We have Exokit-specific domains we can use.

That would only matter for exokit-web though, right?

@RangerMauve
Copy link
Collaborator

Yeah, it's all configurable. Also the SDK will try to auto-detect a local discovery-swarm server if it exists (which gets bundled in dat-store for instance)

@avaer
Copy link
Member Author

avaer commented Sep 2, 2019

Where would we configure that in this code?

@RangerMauve
Copy link
Collaborator

Basically, we'll need to require dat-sdk/promise instead of dat-sdk/auto and then pass in the options into the factory. https://github.com/datproject/sdk/blob/master/index.js#L30

There's a swarmOpts object that gets passed into discovery-swarm-web and there you can specify a discovery field for the server you want to use.

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.

Support for custom protocols in resource loader
2 participants