This project serves as a reference for developers looking to use quadstore in web browsers.
The webpack.config.js
file contains the reference configuration for Webpack
5.x that is used to transform dist/bundle.js
(initially produced by the
TypeScript compiler) into an actual bundle ready for use in browsers as an ES
module.
The bundle contains quadstore, the quadstore-comunica SPARQL query
engine, the browser-level backend for persistent storage via IndexedDB and
rdf-data-factory, an implementation of the RDF/JS DataFactory
interface.
package | version |
---|---|
quadstore |
14.0.0 |
quadstore-comunica |
5.0.0 |
browser-level |
2.0.0 |
rdf-data-factory |
1.1.2 |
The static/index.html
page and associated dist/main.js
script provide a
small demonstration of how to use all of the above.
The bundle file is also served at https://cdn.jsdelivr.net/gh/quadstorejs/quadstore-browser/dist/bundle.js and can be used in webpages as follows:
<script type="module">
import {
Quadstore,
Engine,
BrowserLevel,
DataFactory,
} from 'https://cdn.jsdelivr.net/gh/quadstorejs/quadstore-browser/dist/bundle.js';
const backend = new BrowserLevel('quadstore');
const dataFactory = new DataFactory();
const store = new Quadstore({ backend, dataFactory });
const engine = new Engine(store);
await store.open();
await store.clear();
await store.put(dataFactory.quad(dataFactory.namedNode('ex://s'), dataFactory.namedNode('ex://p'), dataFactory.namedNode('ex://o')));
const stream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o }`);
stream.on('data', console.log);
</script>
npm install
npm run build
Issues should be reported in quadstore's issue tracker.