Comparing version 2.0.0-rc2 to 2.0.0-rc3
@@ -8,11 +8,2 @@ "use strict"; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -126,20 +117,18 @@ exports.CONN = void 0; | ||
} | ||
startScheduler() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this._db.loaded(); | ||
if (this.ssb.connScheduler) { | ||
this.ssb.connScheduler.start(); | ||
} | ||
else { | ||
setTimeout(() => { | ||
if (this.ssb.connScheduler) { | ||
this.ssb.connScheduler.start(); | ||
} | ||
else { | ||
console.error('There is no ConnScheduler! ' + | ||
'The CONN plugin will remain in manual mode.'); | ||
} | ||
}, 100); | ||
} | ||
}); | ||
async startScheduler() { | ||
await this._db.loaded(); | ||
if (this.ssb.connScheduler) { | ||
this.ssb.connScheduler.start(); | ||
} | ||
else { | ||
setTimeout(() => { | ||
if (this.ssb.connScheduler) { | ||
this.ssb.connScheduler.start(); | ||
} | ||
else { | ||
console.error('There is no ConnScheduler! ' + | ||
'The CONN plugin will remain in manual mode.'); | ||
} | ||
}, 100); | ||
} | ||
} | ||
@@ -146,0 +135,0 @@ stopScheduler() { |
@@ -70,3 +70,7 @@ "use strict"; | ||
const peers = Array.from(this.conn.db().entries()).map(([address, data]) => { | ||
return Object.assign(Object.assign({}, data), { address, state: this.conn.hub().getState(address) }); | ||
return { | ||
...data, | ||
address, | ||
state: this.conn.hub().getState(address), | ||
}; | ||
}); | ||
@@ -76,3 +80,8 @@ for (const [address, data] of this.conn.hub().entries()) { | ||
const [, parsed] = validateAddr(address); | ||
peers.push(Object.assign(Object.assign(Object.assign({}, data), parsed), { address, source: inferSource(address) })); | ||
peers.push({ | ||
...data, | ||
...parsed, | ||
address, | ||
source: inferSource(address), | ||
}); | ||
} | ||
@@ -87,3 +96,3 @@ } | ||
if (data.key === addr) { | ||
return Object.assign(Object.assign({}, data), { address }); | ||
return { ...data, address }; | ||
} | ||
@@ -98,3 +107,7 @@ } | ||
else { | ||
return Object.assign({ address: addressString, state: this.conn.hub().getState(addressString) }, peer); | ||
return { | ||
address: addressString, | ||
state: this.conn.hub().getState(addressString), | ||
...peer, | ||
}; | ||
} | ||
@@ -116,3 +129,3 @@ }; | ||
const dbData = (_b = this.conn.db().get(addressString)) !== null && _b !== void 0 ? _b : {}; | ||
const data = Object.assign(Object.assign({}, dbData), stagedData); | ||
const data = { ...dbData, ...stagedData }; | ||
this.conn.connect(addressString, data, cb); | ||
@@ -160,3 +173,7 @@ }; | ||
type: 'discover', | ||
peer: Object.assign(Object.assign({}, parsed), { state: this.conn.hub().getState(addressString), source: source !== null && source !== void 0 ? source : 'manual' }), | ||
peer: { | ||
...parsed, | ||
state: this.conn.hub().getState(addressString), | ||
source: source !== null && source !== void 0 ? source : 'manual', | ||
}, | ||
source: source !== null && source !== void 0 ? source : 'manual', | ||
@@ -212,7 +229,17 @@ }); | ||
onConnectingFailed(ev) { | ||
const peer = Object.assign({ state: ev.type, address: ev.address, key: ev.key }, this.conn.db().get(ev.address)); | ||
const peer = { | ||
state: ev.type, | ||
address: ev.address, | ||
key: ev.key, | ||
...this.conn.db().get(ev.address), | ||
}; | ||
this.notify({ type: 'connect-failure', peer }); | ||
} | ||
onConnected(ev) { | ||
const peer = Object.assign({ state: ev.type, address: ev.address, key: ev.key }, this.conn.db().get(ev.address)); | ||
const peer = { | ||
state: ev.type, | ||
address: ev.address, | ||
key: ev.key, | ||
...this.conn.db().get(ev.address), | ||
}; | ||
if (!this.conn.db().has(ev.address)) | ||
@@ -223,3 +250,8 @@ peer.source = inferSource(ev.address); | ||
onDisconnected(ev) { | ||
const peer = Object.assign({ state: ev.type, address: ev.address, key: ev.key }, this.conn.db().get(ev.address)); | ||
const peer = { | ||
state: ev.type, | ||
address: ev.address, | ||
key: ev.key, | ||
...this.conn.db().get(ev.address), | ||
}; | ||
this.notify({ type: 'disconnect', peer }); | ||
@@ -226,0 +258,0 @@ } |
@@ -17,3 +17,3 @@ "use strict"; | ||
return ({ | ||
ping: Object.assign(Object.assign({}, ((_a = prev.ping) !== null && _a !== void 0 ? _a : {})), { fail: true }), | ||
ping: { ...((_a = prev.ping) !== null && _a !== void 0 ? _a : {}), fail: true }, | ||
}); | ||
@@ -34,3 +34,3 @@ }); | ||
const dbData = db.get(address); | ||
hub.update(address, Object.assign(Object.assign({}, dbData), stagedData)); | ||
hub.update(address, { ...dbData, ...stagedData }); | ||
} | ||
@@ -57,3 +57,3 @@ function onConnectingFailed(ev) { | ||
const dbData = db.get(address); | ||
hub.update(address, Object.assign(Object.assign({}, dbData), stagedData)); | ||
hub.update(address, { ...dbData, ...stagedData }); | ||
if (ev.details.isClient) | ||
@@ -60,0 +60,0 @@ setupPing(address, ev.details.rpc); |
{ | ||
"name": "ssb-conn", | ||
"description": "SSB plugin for establishing and managing peer connections", | ||
"version": "2.0.0-rc2", | ||
"version": "2.0.0-rc3", | ||
"homepage": "https://github.com/staltz/ssb-conn", | ||
@@ -13,3 +13,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"debug": "~4.2.0", | ||
"debug": "^4.3.0", | ||
"has-network2": ">=0.0.3", | ||
@@ -24,10 +24,10 @@ "ip": "^1.1.5", | ||
"secret-stack-decorators": "1.1.0", | ||
"ssb-conn-db": "~0.3.3", | ||
"ssb-conn-hub": "~0.2.7", | ||
"ssb-conn-query": "~0.4.6", | ||
"ssb-conn-staging": "~0.1.0", | ||
"ssb-ref": "^2.14.2", | ||
"ssb-typescript": "^2.1.0", | ||
"ssb-conn-db": "~1.0.0", | ||
"ssb-conn-hub": "~1.0.0", | ||
"ssb-conn-query": "~1.0.0", | ||
"ssb-conn-staging": "~1.0.0", | ||
"ssb-ref": "^2.14.3", | ||
"ssb-typescript": "^2.2.0", | ||
"statistics": "^3.3.0", | ||
"zii": "~1.1.0" | ||
"zii": "~1.1.1" | ||
}, | ||
@@ -40,9 +40,9 @@ "peerDependencies": { | ||
"cont": "^1.0.3", | ||
"secret-stack": "^6.3.1", | ||
"secret-stack": "^6.3.2", | ||
"ssb-caps": "~1.1.0", | ||
"ssb-lan": "~0.2.0", | ||
"ssb-server": "~16.0.1", | ||
"ssb-db2": "1.7.0", | ||
"tape": "^5.0.1", | ||
"typescript": "4.0.3" | ||
"ssb-db2": "1.17.2", | ||
"tape": "^5.2.0", | ||
"typescript": "4.2.2" | ||
}, | ||
@@ -49,0 +49,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1289
69085
+ Addedatomic-file-rw@0.3.0(transitive)
+ Addedssb-conn-db@1.0.5(transitive)
+ Addedssb-conn-hub@1.0.0(transitive)
+ Addedssb-conn-query@1.0.0(transitive)
+ Addedssb-conn-staging@1.0.0(transitive)
- Removedatomic-file@2.1.1(transitive)
- Removeddebug@4.1.14.2.0(transitive)
- Removedflumecodec@0.0.1(transitive)
- Removedlevel-codec@6.2.0(transitive)
- Removedms@2.1.2(transitive)
- Removedssb-conn-db@0.3.3(transitive)
- Removedssb-conn-hub@0.2.7(transitive)
- Removedssb-conn-query@0.4.6(transitive)
- Removedssb-conn-staging@0.1.0(transitive)
Updateddebug@^4.3.0
Updatedssb-conn-db@~1.0.0
Updatedssb-conn-hub@~1.0.0
Updatedssb-conn-query@~1.0.0
Updatedssb-conn-staging@~1.0.0
Updatedssb-ref@^2.14.3
Updatedssb-typescript@^2.2.0
Updatedzii@~1.1.1