mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Fix browser compatibility
This commit is contained in:
parent
ed5d8b0a0e
commit
81284c1b16
@ -11,6 +11,9 @@ examples/
|
||||
# Don't distribute source maps
|
||||
dist/*.map
|
||||
|
||||
# Don't distribute the debug build
|
||||
dist/orbitdb.debug.js
|
||||
|
||||
# Don't distribute screenshot
|
||||
# See examples at https://github.com/orbitdb/orbit-db
|
||||
screenshots/
|
||||
|
@ -19,13 +19,7 @@ module.exports = {
|
||||
target: 'web',
|
||||
devtool: 'none',
|
||||
node: {
|
||||
console: false,
|
||||
Buffer: true,
|
||||
process: 'mock',
|
||||
},
|
||||
externals: {
|
||||
fs: '{}',
|
||||
mkdirp: '{}',
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
@ -40,9 +34,6 @@ module.exports = {
|
||||
'node_modules',
|
||||
path.resolve(__dirname, '../node_modules')
|
||||
],
|
||||
alias: {
|
||||
leveldown: 'level-js',
|
||||
},
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: [
|
||||
|
12
dist/es5/OrbitDB.js
vendored
12
dist/es5/OrbitDB.js
vendored
@ -56,7 +56,7 @@ var OrbitDB = function () {
|
||||
this.stores = {};
|
||||
this.types = validTypes;
|
||||
this.directory = directory || './orbitdb';
|
||||
this.keystore = new Keystore(path.join(this.directory, this.id, '/keystore'));
|
||||
this.keystore = Keystore.create(path.join(this.directory, this.id, '/keystore'));
|
||||
this.key = this.keystore.getKey(this.id) || this.keystore.createKey(this.id);
|
||||
}
|
||||
|
||||
@ -407,11 +407,8 @@ var OrbitDB = function () {
|
||||
}, {
|
||||
key: '_saveDBManifest',
|
||||
value: async function _saveDBManifest(directory, dbAddress) {
|
||||
var cache = await this._loadCache(directory, dbAddress
|
||||
// let localData = Object.assign({}, cache.get(dbAddress.toString()), {
|
||||
// manifest: dbAddress.root
|
||||
// })
|
||||
);await cache.set(path.join(dbAddress.toString(), '_manifest'), dbAddress.root);
|
||||
var cache = await this._loadCache(directory, dbAddress);
|
||||
await cache.set(path.join(dbAddress.toString(), '_manifest'), dbAddress.root);
|
||||
logger.debug('Saved manifest to IPFS as \'' + dbAddress.root + '\'');
|
||||
}
|
||||
}, {
|
||||
@ -421,7 +418,8 @@ var OrbitDB = function () {
|
||||
try {
|
||||
cache = await Cache.load(directory, dbAddress);
|
||||
} catch (e) {
|
||||
logger.warn("Couldn't load Cache:", e);
|
||||
console.log(e);
|
||||
logger.error("Couldn't load Cache:", e);
|
||||
}
|
||||
|
||||
return cache;
|
||||
|
2
dist/orbitdb.min.js
vendored
2
dist/orbitdb.min.js
vendored
File diff suppressed because one or more lines are too long
@ -10,8 +10,16 @@
|
||||
minified distribution builds (in '../lib')
|
||||
*/
|
||||
|
||||
const IPFS = require('ipfs')
|
||||
const OrbitDB = require('../../../src/OrbitDB')
|
||||
// Import IPFS module
|
||||
import IPFS from 'ipfs'
|
||||
|
||||
// Import OrbitDB module from 'orbit-db', eg. directory to its package.json
|
||||
import OrbitDB from '../../..'
|
||||
|
||||
// When 'orbit-db' was installed from npm, use with:
|
||||
// import OrbitDB from 'orbit-db'
|
||||
|
||||
// Example main code
|
||||
const example = require('../example')
|
||||
|
||||
// Call the start function and pass in the
|
||||
|
@ -87,7 +87,8 @@ const main = (IPFS, ORBITDB) => {
|
||||
let maxTotal = 0, loaded = 0
|
||||
db.events.on('load.progress', (address, hash, entry, progress, total) => {
|
||||
loaded ++
|
||||
maxTotal = Math.max.apply(null, [maxTotal, progress, 0])
|
||||
maxTotal = Math.max.apply(null, [progress, maxTotal, progress, 0])
|
||||
total = Math.max.apply(null, [progress, maxTotal, total, 0])
|
||||
statusElm.innerHTML = `Loading database... ${maxTotal} / ${total}`
|
||||
})
|
||||
|
||||
|
849
package-lock.json
generated
849
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -11,21 +11,17 @@
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"browser": {
|
||||
"fs-pull-blob-store": "idb-pull-blob-store"
|
||||
},
|
||||
"main": "src/OrbitDB.js",
|
||||
"dependencies": {
|
||||
"level": "^2.1.0",
|
||||
"logplease": "^1.2.14",
|
||||
"multihashes": "^0.4.12",
|
||||
"orbit-db-cache": "~0.1.0",
|
||||
"orbit-db-counterstore": "~1.1.0",
|
||||
"orbit-db-docstore": "~1.1.0",
|
||||
"orbit-db-eventstore": "~1.1.0",
|
||||
"orbit-db-feedstore": "~1.1.0",
|
||||
"orbit-db-keystore": "~0.0.2",
|
||||
"orbit-db-kvstore": "~1.1.0",
|
||||
"orbit-db-cache": "~0.2.0",
|
||||
"orbit-db-counterstore": "~1.2.0",
|
||||
"orbit-db-docstore": "~1.2.0",
|
||||
"orbit-db-eventstore": "~1.2.0",
|
||||
"orbit-db-feedstore": "~1.2.0",
|
||||
"orbit-db-keystore": "~0.1.0",
|
||||
"orbit-db-kvstore": "~1.2.0",
|
||||
"orbit-db-pubsub": "~0.3.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -41,7 +37,7 @@
|
||||
"p-each-series": "^1.0.0",
|
||||
"p-map-series": "^1.0.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"uglifyjs-webpack-plugin": "~1.1.0",
|
||||
"uglifyjs-webpack-plugin": "^1.1.4",
|
||||
"webpack": "^3.8.1"
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -29,7 +29,7 @@ class OrbitDB {
|
||||
this.stores = {}
|
||||
this.types = validTypes
|
||||
this.directory = directory || './orbitdb'
|
||||
this.keystore = new Keystore(path.join(this.directory, this.id, '/keystore'))
|
||||
this.keystore = Keystore.create(path.join(this.directory, this.id, '/keystore'))
|
||||
this.key = this.keystore.getKey(this.id) || this.keystore.createKey(this.id)
|
||||
}
|
||||
|
||||
@ -304,9 +304,6 @@ class OrbitDB {
|
||||
// Save the database locally
|
||||
async _saveDBManifest (directory, dbAddress) {
|
||||
const cache = await this._loadCache(directory, dbAddress)
|
||||
// let localData = Object.assign({}, cache.get(dbAddress.toString()), {
|
||||
// manifest: dbAddress.root
|
||||
// })
|
||||
await cache.set(path.join(dbAddress.toString(), '_manifest'), dbAddress.root)
|
||||
logger.debug(`Saved manifest to IPFS as '${dbAddress.root}'`)
|
||||
}
|
||||
@ -316,7 +313,8 @@ class OrbitDB {
|
||||
try {
|
||||
cache = await Cache.load(directory, dbAddress)
|
||||
} catch (e) {
|
||||
logger.warn("Couldn't load Cache:", e)
|
||||
console.log(e)
|
||||
logger.error("Couldn't load Cache:", e)
|
||||
}
|
||||
|
||||
return cache
|
||||
|
@ -101,14 +101,13 @@ describe('orbit-db - Create & Open', function() {
|
||||
})
|
||||
|
||||
it('saves the database locally', async () => {
|
||||
console.log(localDataPath)
|
||||
assert.equal(fs.existsSync(localDataPath), true)
|
||||
})
|
||||
|
||||
it('saves database manifest reference locally', async () => {
|
||||
const manifestHash = db.address.root
|
||||
const address = db.address.toString()
|
||||
levelup(leveldown(localDataPath), (err, db) => {
|
||||
levelup(localDataPath, (err, db) => {
|
||||
if (err) {
|
||||
assert.equal(err, null)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user