@nhtio/swarm 1.20250424.0 → 1.20251110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{errors-BsRN4TW4.mjs → errors-Cqo3rABf.mjs} +26 -19
- package/{errors-BsRN4TW4.mjs.map → errors-Cqo3rABf.mjs.map} +1 -1
- package/errors-j8BTGk4y.js +4 -0
- package/{errors-DTZFdRbq.js.map → errors-j8BTGk4y.js.map} +1 -1
- package/errors.cjs +1 -1
- package/errors.d.ts +6 -0
- package/errors.mjs +4 -3
- package/index.cjs +47 -2
- package/index.cjs.map +1 -1
- package/index.d.ts +2 -0
- package/index.mjs +27553 -907
- package/index.mjs.map +1 -1
- package/lib/class_swarm.d.ts +5 -4
- package/lib/common.d.ts +1 -0
- package/lib/encryption.d.ts +9 -0
- package/lib/logger.d.ts +1 -1
- package/lib/symbols.d.ts +1 -0
- package/package.json +1 -1
- package/types.d.ts +1 -0
- package/errors-DTZFdRbq.js +0 -4
package/lib/class_swarm.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { TypedEventEmitter } from '
|
|
2
|
-
import type { TypedEventMap } from '
|
|
1
|
+
import { TypedEventEmitter } from './emitter';
|
|
2
|
+
import type { TypedEventMap } from './emitter';
|
|
3
|
+
import type { Secret } from '@nhtio/swarm';
|
|
3
4
|
export type RequestHandlerMap<Events extends TypedEventMap> = {
|
|
4
5
|
[K in keyof Events]: (...args: Events[K]) => any;
|
|
5
6
|
};
|
|
@@ -12,7 +13,7 @@ export declare class Swarm<Events extends TypedEventMap = TypedEventMap> extends
|
|
|
12
13
|
private static readonly INTERNAL_HEARTBEAT;
|
|
13
14
|
private static readonly INTERNAL_OBITUARY;
|
|
14
15
|
/** @private */
|
|
15
|
-
constructor();
|
|
16
|
+
constructor(secret?: string | Secret<string>);
|
|
16
17
|
/**
|
|
17
18
|
* The ID of the current instance.
|
|
18
19
|
*/
|
|
@@ -100,5 +101,5 @@ export declare class Swarm<Events extends TypedEventMap = TypedEventMap> extends
|
|
|
100
101
|
* @typeParam Events - The map of events and their arguments that can be emitted and listened to.
|
|
101
102
|
* @returns The current instance of the Swarm class for the current context.
|
|
102
103
|
*/
|
|
103
|
-
static instance<Events extends TypedEventMap = TypedEventMap>(): Swarm<Events>;
|
|
104
|
+
static instance<Events extends TypedEventMap = TypedEventMap>(secret?: string | Secret<string>): Swarm<Events>;
|
|
104
105
|
}
|
package/lib/common.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const isTabEnvironment: () => boolean;
|
|
|
8
8
|
* @returns {boolean} - true if the environment is a service worker
|
|
9
9
|
*/
|
|
10
10
|
export declare const isWorkerEnvironment: () => boolean;
|
|
11
|
+
export declare const isWebWorkerEnvironment: () => boolean;
|
|
11
12
|
/**
|
|
12
13
|
* Returns true if the environment is an SSR (Server-Side Rendering) environment
|
|
13
14
|
* @returns {boolean} - true if the environment is an SSR environment
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Encryption } from '@nhtio/web-encryption';
|
|
2
|
+
import { Secret } from '@nhtio/swarm';
|
|
3
|
+
export declare const getEncryption: (secret?: string | Secret<string>) => Encryption;
|
|
4
|
+
/**
|
|
5
|
+
* Set the pre-shared key used to ensure that any data shared between nodes in the swarm is encrypted and namespaced.
|
|
6
|
+
* @param secret The pre-shared key to use
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const setPSK: (secret: string | Secret<string>) => void;
|
package/lib/logger.d.ts
CHANGED
package/lib/symbols.d.ts
CHANGED
package/package.json
CHANGED
package/types.d.ts
CHANGED
package/errors-DTZFdRbq.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var p=(r,e,t)=>e in r?h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>p(r,typeof e!="symbol"?e+"":e,t);class i extends Error{constructor(t,s){const l=s?{cause:s.cause}:{};super(t,l);o(this,"$__name");o(this,"$__message");const n=this.constructor;if(Object.setPrototypeOf(this,n),this.$__name=n.name,this.$__message=t,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,n),this.stack&&s&&s.trim&&s.trim>0){const a=this.stack.split(`
|
|
2
|
-
`);a.splice(0,s.trim),this.stack=a.join(`
|
|
3
|
-
`)}}get name(){return this.$__name}get message(){return this.$__message}get[Symbol.toStringTag](){return this.constructor.name}toString(){return`${this.name}: ${this.message}`}[Symbol.toPrimitive](t){switch(t){case"string":return this.toString();default:return!0}}static[Symbol.hasInstance](t){if(typeof t=="object"&&t!==null||typeof t=="function"){const s=Object.getPrototypeOf(t);return s.name===this.name||s===this}return!1}}class c extends i{constructor(){super("Unable to setup instance because Service Workers are not supported in this environment")}}class u extends i{constructor(){super("Unable to setup instance because another instance is already initialized in this context")}}class m extends i{constructor(e){super(`Request timed out while waiting for event "${String(e)}".`)}}const d=Object.freeze(Object.defineProperty({__proto__:null,AlreadyInitializedInContextError:u,RequestTimeoutError:m,UnsupportedEnvironmentError:c},Symbol.toStringTag,{value:"Module"}));exports.AlreadyInitializedInContextError=u;exports.RequestTimeoutError=m;exports.UnsupportedEnvironmentError=c;exports.errors=d;
|
|
4
|
-
//# sourceMappingURL=errors-DTZFdRbq.js.map
|