*Update dist
This commit is contained in:
parent
281121b7cc
commit
e61bd06454
|
@ -6,6 +6,7 @@ export default class HyperswarmWeb extends EventEmitter {
|
|||
private _relays;
|
||||
private _activeRelay;
|
||||
private _discovery;
|
||||
private _queuedEmActions;
|
||||
constructor(opts?: any);
|
||||
ready(): Promise<void>;
|
||||
private ensureConnection;
|
||||
|
@ -21,5 +22,7 @@ export default class HyperswarmWeb extends EventEmitter {
|
|||
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
emit(eventName: string | symbol, ...args: any[]): boolean;
|
||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
private _processOrQueueAction;
|
||||
private _processQueuedActions;
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAW5C,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,YAAY;IACrD,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,UAAU,CAAsB;gBAC5B,IAAI,GAAE,GAAQ;IAO1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAIR,gBAAgB;YAgDhB,iBAAiB;IAYzB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ7D,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAEY,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAUpC,WAAW,IAAI,IAAI;IAI1B,EAAE,CACA,SAAS,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AM,EAAE,MAAM,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ7D,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAEY,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAUpC,WAAW,IAAI,IAAI;IAI1B,EAAE,CACA,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GACjC,UAAU;IAGb,WAAW,CACT,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GACjC,IAAI;IAIP,GAAG,CACD,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GACjC,UAAU;IAIb,cAAc,CACZ,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GACjC,IAAI;IAGP,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;IAIzD,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;IAI1E,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,qBAAqB;CAO9B"}
|
|
@ -11,6 +11,7 @@ export default class HyperswarmWeb extends EventEmitter {
|
|||
_relays = new Set();
|
||||
_activeRelay;
|
||||
_discovery;
|
||||
_queuedEmActions = [];
|
||||
constructor(opts = {}) {
|
||||
super();
|
||||
opts.custodial = false;
|
||||
|
@ -52,6 +53,7 @@ export default class HyperswarmWeb extends EventEmitter {
|
|||
if (!this._activeRelay) {
|
||||
throw new Error("Failed to find an available relay");
|
||||
}
|
||||
this._processQueuedActions();
|
||||
await this._activeRelay.dht.ready();
|
||||
}
|
||||
async isServerAvailable(connection) {
|
||||
|
@ -89,21 +91,34 @@ export default class HyperswarmWeb extends EventEmitter {
|
|||
this._relays.clear();
|
||||
}
|
||||
on(eventName, listener) {
|
||||
return this._activeRelay?.on(eventName, listener);
|
||||
return this._processOrQueueAction("on", arguments);
|
||||
}
|
||||
addListener(eventName, listener) {
|
||||
return this.on(eventName, listener);
|
||||
}
|
||||
off(eventName, listener) {
|
||||
return this._activeRelay?.off(eventName, listener);
|
||||
return this._processOrQueueAction("off", arguments);
|
||||
}
|
||||
removeListener(eventName, listener) {
|
||||
return this.on(eventName, listener);
|
||||
return this.off(eventName, listener);
|
||||
}
|
||||
emit(eventName, ...args) {
|
||||
return this._activeRelay?.emit(eventName, ...args);
|
||||
return this._processOrQueueAction("emit", arguments);
|
||||
}
|
||||
once(eventName, listener) {
|
||||
return this._activeRelay?.once(eventName, listener);
|
||||
return this._processOrQueueAction("once", arguments);
|
||||
}
|
||||
_processOrQueueAction(method, ...args) {
|
||||
if (this._activeRelay) {
|
||||
return this._activeRelay[method](...args);
|
||||
}
|
||||
this._queuedEmActions.push([method, args]);
|
||||
return this;
|
||||
}
|
||||
_processQueuedActions() {
|
||||
for (const action of this._queuedEmActions) {
|
||||
this._activeRelay[action[0]](...action[1]);
|
||||
}
|
||||
this._queuedEmActions = [];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue