Compare commits

..

No commits in common. "v0.0.2-develop.7" and "v0.0.2-develop.6" have entirely different histories.

4 changed files with 29 additions and 48 deletions

View File

@ -1,5 +1,3 @@
## [0.0.2-develop.7](https://git.lumeweb.com/LumeWeb/hyperswarm-web/compare/v0.0.2-develop.6...v0.0.2-develop.7) (2023-07-03)
## [0.0.2-develop.6](https://git.lumeweb.com/LumeWeb/hyperswarm-web/compare/v0.0.2-develop.5...v0.0.2-develop.6) (2023-07-02)
## [0.0.2-develop.5](https://git.lumeweb.com/LumeWeb/hyperswarm-web/compare/v0.0.2-develop.4...v0.0.2-develop.5) (2023-07-01)

49
npm-shrinkwrap.json generated
View File

@ -1,18 +1,17 @@
{
"name": "@lumeweb/hyperswarm-web",
"version": "0.0.2-develop.7",
"version": "0.0.2-develop.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/hyperswarm-web",
"version": "0.0.2-develop.7",
"version": "0.0.2-develop.6",
"dependencies": {
"@hyperswarm/dht-relay": "^0.4.1",
"@lumeweb/kernel-peer-discovery-client": "^0.0.2-develop.5",
"@lumeweb/libkernel": "0.1.0-develop.7",
"async-mutex": "^0.4.0",
"emittery": "^1.0.1",
"eventemitter2": "^6.4.9",
"hyperswarm": "^4.5.1",
"random-number-csprng": "^1.0.2"
@ -1850,6 +1849,17 @@
"@noble/hashes": "^1.3.1"
}
},
"node_modules/@lumeweb/kernel-peer-discovery-client/node_modules/emittery": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/emittery/-/emittery-1.0.1.tgz",
"integrity": "sha512-2ID6FdrMD9KDLldGesP6317G78K7km/kMcwItRtVFva7I/cSEOIaLpewaUb+YLXVwdAp3Ctfxh/V5zIl1sj7dQ==",
"engines": {
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sindresorhus/emittery?sponsor=1"
}
},
"node_modules/@lumeweb/kernel-peer-discovery-client/node_modules/sodium-native": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-3.4.1.tgz",
@ -5923,11 +5933,12 @@
"peer": true
},
"node_modules/emittery": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/emittery/-/emittery-1.0.1.tgz",
"integrity": "sha512-2ID6FdrMD9KDLldGesP6317G78K7km/kMcwItRtVFva7I/cSEOIaLpewaUb+YLXVwdAp3Ctfxh/V5zIl1sj7dQ==",
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz",
"integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==",
"peer": true,
"engines": {
"node": ">=14.16"
"node": ">=12"
},
"funding": {
"url": "https://github.com/sindresorhus/emittery?sponsor=1"
@ -9324,18 +9335,6 @@
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/jest-runner/node_modules/emittery": {
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz",
"integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==",
"peer": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sindresorhus/emittery?sponsor=1"
}
},
"node_modules/jest-runtime": {
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.5.0.tgz",
@ -9468,18 +9467,6 @@
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/jest-watcher/node_modules/emittery": {
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz",
"integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==",
"peer": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sindresorhus/emittery?sponsor=1"
}
},
"node_modules/jest-worker": {
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.5.0.tgz",

View File

@ -1,7 +1,7 @@
{
"name": "@lumeweb/hyperswarm-web",
"type": "module",
"version": "0.0.2-develop.7",
"version": "0.0.2-develop.6",
"main": "lib/index.js",
"repository": {
"type": "git",
@ -30,7 +30,6 @@
"@lumeweb/kernel-peer-discovery-client": "^0.0.2-develop.5",
"@lumeweb/libkernel": "0.1.0-develop.7",
"async-mutex": "^0.4.0",
"emittery": "^1.0.1",
"eventemitter2": "^6.4.9",
"hyperswarm": "^4.5.1",
"random-number-csprng": "^1.0.2"

View File

@ -10,11 +10,11 @@ import type {
// @ts-ignore
import Hyperswarm from "hyperswarm";
import randomNumber from "random-number-csprng";
import EventEmitter, { OnOptions } from "eventemitter2";
import { Mutex } from "async-mutex";
import { logErr } from "@lumeweb/libkernel";
import Emittery from "emittery";
export default class HyperswarmWeb extends Emittery {
export default class HyperswarmWeb extends EventEmitter.default {
private _options: any;
private _discovery: PeerDiscoveryClient;
private _queuedEmActions: [string, any][] = [];
@ -75,7 +75,6 @@ export default class HyperswarmWeb extends Emittery {
this._relays.clear();
}
// @ts-ignore
on(
eventName: string | symbol,
listener: (...args: any[]) => void,
@ -86,8 +85,9 @@ export default class HyperswarmWeb extends Emittery {
onSelf(
eventName: string | symbol,
listener: (...args: any[]) => void,
options?: boolean | OnOptions,
): Hyperswarm {
return super.on(eventName, listener);
return super.on(eventName, listener, options);
}
addListener(
@ -97,7 +97,6 @@ export default class HyperswarmWeb extends Emittery {
return this.on(eventName, listener);
}
// @ts-ignore
off(
eventName: string | symbol,
listener: (...args: any[]) => void,
@ -119,16 +118,14 @@ export default class HyperswarmWeb extends Emittery {
return this.off(eventName, listener);
}
// @ts-ignore
emit(eventName: string | symbol, ...args: any[]): boolean {
return this._processOrQueueAction("emit", ...arguments);
}
async emitSelf(eventName: string | symbol, ...args: any): Promise<void> {
return super.emit(eventName, { ...args });
emitSelf(eventName: string | symbol, ...args: any[]): boolean {
return super.emit(eventName, ...args);
}
// @ts-ignore
once(eventName: string | symbol, listener: (...args: any[]) => void): this {
return this._processOrQueueAction("once", ...arguments);
}
@ -219,10 +216,10 @@ export default class HyperswarmWeb extends Emittery {
keyPair: this._options.keyPair,
});
this._activeRelay.dht._protocol._stream.once("close", async () => {
this._activeRelay.dht._protocol._stream.once("close", () => {
this._activeRelay = undefined;
this._ready = false;
await this.emitSelf("close");
this.emitSelf("close");
});
} while (relays.length > 0 && !this._activeRelay);
}
@ -232,14 +229,14 @@ export default class HyperswarmWeb extends Emittery {
throw new Error("Failed to find an available relay");
}
await this.emitSelf("init");
this.emitSelf("init");
this._processQueuedActions();
await this._activeRelay.dht.ready();
this._connectionMutex.release();
this._ready = true;
await this.emit("ready");
this.emit("ready");
}
private async isServerAvailable(connection: string): Promise<boolean> {