https://github.com/rangermauve/dat-archive-web
DatArchive implementation for browsers that uses dat-gateway
https://github.com/rangermauve/dat-archive-web
Last synced: 21 days ago
JSON representation
DatArchive implementation for browsers that uses dat-gateway
- Host: GitHub
- URL: https://github.com/rangermauve/dat-archive-web
- Owner: RangerMauve
- License: mit
- Created: 2018-04-09T00:00:43.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-31T17:03:15.000Z (over 5 years ago)
- Last Synced: 2025-04-23T20:47:00.888Z (28 days ago)
- Language: JavaScript
- Homepage:
- Size: 471 KB
- Stars: 29
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**Note: This is being replaced by the [Dat SDK](https://github.com/datproject/sdk)**
# dat-archive-web
DatArchive implementation for browsers using [dat-js](https://github.com/datproject/dat-js#readme)```
npm install --save dat-archive-web
```Or
```html
```
## Example
```javascript
// After including the bundle in a script tag, or requiring itconst archive = new DatArchive('dat://87ed2e3b160f261a032af03921a3bd09227d0a4cde73466c17114816cae43336')
// Subscribe to network events
archive.addEventListener("download", ({bytes}) => console.log(`Downloaded ${bytes} bytes`))// Subscribe to file events
const emitter = archive.watch("/path/to/watch")
emitter.addEventListener("change", ({path}) => console.log(`file at path: ${path} changed!`))archive.readFile('/index.html')
.then((html) => console.log(html))
```## API
Implements the same interface as [DatArchive](https://beakerbrowser.com/docs/apis/dat.html) in Beaker with the following exceptions:
- `archive.diff()`, `archive.commit()`, and `archive.revert()` are not supported
- `DatArchive.selectArchive()` doesn't do filtering and looks crappy. Uses [window.prompt](https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt) API
- `DatArchive.resolveName()` doesn't work and DNS based urls aren't supported. Waiting for dat-js support# Features
- [x] Support most DatArchive methods
- [x] Public bridges used to replicate with non-browser network
- [x] Detect HTTP/HTTPS in gateway URL
- [x] Data stored in memory by default, unless it was created locally.
- [] Functional DatDNS support (via gateway)
- [x] Full support for versions (Needs testing, but code is there)
- [x] Forking (without preserving change feed)
- [x] DatArchive.selectArchive() Really rudimentary## Development
- This project uses the `standard` code style
- Run the example in node with `npm install && npm run example`
- Build the browserify bundle with `npm run build`