@nhtio/swarm 1.20250425.0 → 1.20260111.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-B7SDj7bo.js +93 -0
- package/{errors-j8BTGk4y.js.map → errors-B7SDj7bo.js.map} +1 -1
- package/errors-Bgn2zMF7.mjs +94 -0
- package/{errors-Cqo3rABf.mjs.map → errors-Bgn2zMF7.mjs.map} +1 -1
- package/errors.cjs +7 -1
- package/errors.cjs.map +1 -1
- package/errors.d.ts +71 -65
- package/errors.mjs +5 -5
- package/index.cjs +29795 -42
- package/index.cjs.map +1 -1
- package/index.d.ts +342 -14
- package/index.mjs +16447 -14828
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/types-tRl_KHbK.js +6 -0
- package/types-tRl_KHbK.js.map +1 -0
- package/types-wf-bHbgv.mjs +7 -0
- package/types-wf-bHbgv.mjs.map +1 -0
- package/types.d.ts +64 -40
- package/errors-Cqo3rABf.mjs +0 -89
- package/errors-j8BTGk4y.js +0 -4
- package/lib/browser.d.ts +0 -6
- package/lib/class_swarm.d.ts +0 -105
- package/lib/common.d.ts +0 -26
- package/lib/emitter.d.ts +0 -33
- package/lib/encryption.d.ts +0 -9
- package/lib/logger.d.ts +0 -67
- package/lib/symbols.d.ts +0 -6
- package/types-C0eRuyk9.js +0 -2
- package/types-C0eRuyk9.js.map +0 -1
- package/types-CBFnAS2P.mjs +0 -7
- package/types-CBFnAS2P.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-tRl_KHbK.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-wf-bHbgv.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/types.d.ts
CHANGED
|
@@ -1,40 +1,64 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The module which contains types for the library.
|
|
3
|
-
* @module @nhtio/swarm/types
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* An inteface which describes the information about the browser and operating system
|
|
7
|
-
*/
|
|
8
|
-
export interface BrowserInfo {
|
|
9
|
-
/**
|
|
10
|
-
* The name of the browser
|
|
11
|
-
*/
|
|
12
|
-
browserName: string;
|
|
13
|
-
/**
|
|
14
|
-
* The version of the browser
|
|
15
|
-
*/
|
|
16
|
-
browserVersion: string;
|
|
17
|
-
/**
|
|
18
|
-
* The name of the operating system
|
|
19
|
-
*/
|
|
20
|
-
osName: string;
|
|
21
|
-
/**
|
|
22
|
-
* The version of the operating system
|
|
23
|
-
*/
|
|
24
|
-
osVersion: string;
|
|
25
|
-
/**
|
|
26
|
-
* The type of platform i.e. desktop / mobile
|
|
27
|
-
*/
|
|
28
|
-
platformType: string;
|
|
29
|
-
/**
|
|
30
|
-
* The name of the browser engine
|
|
31
|
-
*/
|
|
32
|
-
engineName: string;
|
|
33
|
-
/**
|
|
34
|
-
* The version of the browser engine
|
|
35
|
-
*/
|
|
36
|
-
engineVersion: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type
|
|
40
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The module which contains types for the library.
|
|
3
|
+
* @module @nhtio/swarm/types
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* An inteface which describes the information about the browser and operating system
|
|
7
|
+
*/
|
|
8
|
+
export declare interface BrowserInfo {
|
|
9
|
+
/**
|
|
10
|
+
* The name of the browser
|
|
11
|
+
*/
|
|
12
|
+
browserName: string;
|
|
13
|
+
/**
|
|
14
|
+
* The version of the browser
|
|
15
|
+
*/
|
|
16
|
+
browserVersion: string;
|
|
17
|
+
/**
|
|
18
|
+
* The name of the operating system
|
|
19
|
+
*/
|
|
20
|
+
osName: string;
|
|
21
|
+
/**
|
|
22
|
+
* The version of the operating system
|
|
23
|
+
*/
|
|
24
|
+
osVersion: string;
|
|
25
|
+
/**
|
|
26
|
+
* The type of platform i.e. desktop / mobile
|
|
27
|
+
*/
|
|
28
|
+
platformType: string;
|
|
29
|
+
/**
|
|
30
|
+
* The name of the browser engine
|
|
31
|
+
*/
|
|
32
|
+
engineName: string;
|
|
33
|
+
/**
|
|
34
|
+
* The version of the browser engine
|
|
35
|
+
*/
|
|
36
|
+
engineVersion: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export declare type LogLevel = keyof typeof LogLevelStyles;
|
|
40
|
+
|
|
41
|
+
export declare const LogLevelStyles: {
|
|
42
|
+
EMERG: (text: string) => string[];
|
|
43
|
+
ALERT: (text: string) => string[];
|
|
44
|
+
CRIT: (text: string) => string[];
|
|
45
|
+
ERROR: (text: string) => string[];
|
|
46
|
+
WARNING: (text: string) => string[];
|
|
47
|
+
NOTICE: (text: string) => string[];
|
|
48
|
+
INFO: (text: string) => string[];
|
|
49
|
+
DEBUG: (text: string) => string[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export declare type RequestHandlerMap<Events extends TypedEventMap> = {
|
|
53
|
+
[K in keyof Events]: (...args: Events[K]) => any;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A map from event-names to the tuple of arguments
|
|
58
|
+
* that listeners for that event will receive.
|
|
59
|
+
*/
|
|
60
|
+
export declare interface TypedEventMap {
|
|
61
|
+
[event: string]: any[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { }
|
package/errors-Cqo3rABf.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
var u = Object.defineProperty;
|
|
2
|
-
var m = (e, r, t) => r in e ? u(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
-
var i = (e, r, t) => m(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
-
class n extends Error {
|
|
5
|
-
/**
|
|
6
|
-
* Creates a new SwarmError instance.
|
|
7
|
-
* @param message The error message.
|
|
8
|
-
* @param options The error options.
|
|
9
|
-
*/
|
|
10
|
-
constructor(t, s) {
|
|
11
|
-
const c = s ? { cause: s.cause } : {};
|
|
12
|
-
super(t, c);
|
|
13
|
-
/** @private */
|
|
14
|
-
i(this, "$__name");
|
|
15
|
-
/** @private */
|
|
16
|
-
i(this, "$__message");
|
|
17
|
-
const o = this.constructor;
|
|
18
|
-
if (Object.setPrototypeOf(this, o), this.$__name = o.name, this.$__message = t, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, o), this.stack && s && s.trim && s.trim > 0) {
|
|
19
|
-
const a = this.stack.split(`
|
|
20
|
-
`);
|
|
21
|
-
a.splice(0, s.trim), this.stack = a.join(`
|
|
22
|
-
`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
get name() {
|
|
26
|
-
return this.$__name;
|
|
27
|
-
}
|
|
28
|
-
get message() {
|
|
29
|
-
return this.$__message;
|
|
30
|
-
}
|
|
31
|
-
get [Symbol.toStringTag]() {
|
|
32
|
-
return this.constructor.name;
|
|
33
|
-
}
|
|
34
|
-
toString() {
|
|
35
|
-
return `${this.name}: ${this.message}`;
|
|
36
|
-
}
|
|
37
|
-
[Symbol.toPrimitive](t) {
|
|
38
|
-
switch (t) {
|
|
39
|
-
case "string":
|
|
40
|
-
return this.toString();
|
|
41
|
-
default:
|
|
42
|
-
return !0;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
static [Symbol.hasInstance](t) {
|
|
46
|
-
if (typeof t == "object" && t !== null || typeof t == "function") {
|
|
47
|
-
const s = Object.getPrototypeOf(t);
|
|
48
|
-
return s.name === this.name || s === this;
|
|
49
|
-
}
|
|
50
|
-
return !1;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
class l extends n {
|
|
54
|
-
constructor() {
|
|
55
|
-
super("Unable to setup instance because Service Workers are not supported in this environment");
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
class p extends n {
|
|
59
|
-
constructor() {
|
|
60
|
-
super(
|
|
61
|
-
"Unable to setup instance because another instance is already initialized in this context"
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
class h extends n {
|
|
66
|
-
constructor(r) {
|
|
67
|
-
super(`Request timed out while waiting for event "${String(r)}".`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
class g extends n {
|
|
71
|
-
constructor() {
|
|
72
|
-
super("An encryption key has not been provided at any point in the runtime.");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
76
|
-
__proto__: null,
|
|
77
|
-
AlreadyInitializedInContextError: p,
|
|
78
|
-
MissingEncryptionKey: g,
|
|
79
|
-
RequestTimeoutError: h,
|
|
80
|
-
UnsupportedEnvironmentError: l
|
|
81
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
82
|
-
export {
|
|
83
|
-
p as A,
|
|
84
|
-
g as M,
|
|
85
|
-
h as R,
|
|
86
|
-
l as U,
|
|
87
|
-
y as e
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=errors-Cqo3rABf.mjs.map
|
package/errors-j8BTGk4y.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var d=(e,r,t)=>r in e?h(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>d(e,typeof r!="symbol"?r+"":r,t);class n extends Error{constructor(t,s){const p=s?{cause:s.cause}:{};super(t,p);i(this,"$__name");i(this,"$__message");const o=this.constructor;if(Object.setPrototypeOf(this,o),this.$__name=o.name,this.$__message=t,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,o),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 n{constructor(){super("Unable to setup instance because Service Workers are not supported in this environment")}}class u extends n{constructor(){super("Unable to setup instance because another instance is already initialized in this context")}}class m extends n{constructor(r){super(`Request timed out while waiting for event "${String(r)}".`)}}class l extends n{constructor(){super("An encryption key has not been provided at any point in the runtime.")}}const y=Object.freeze(Object.defineProperty({__proto__:null,AlreadyInitializedInContextError:u,MissingEncryptionKey:l,RequestTimeoutError:m,UnsupportedEnvironmentError:c},Symbol.toStringTag,{value:"Module"}));exports.AlreadyInitializedInContextError=u;exports.MissingEncryptionKey=l;exports.RequestTimeoutError=m;exports.UnsupportedEnvironmentError=c;exports.errors=y;
|
|
4
|
-
//# sourceMappingURL=errors-j8BTGk4y.js.map
|
package/lib/browser.d.ts
DELETED
package/lib/class_swarm.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { TypedEventEmitter } from './emitter';
|
|
2
|
-
import type { TypedEventMap } from './emitter';
|
|
3
|
-
import type { Secret } from '@nhtio/swarm';
|
|
4
|
-
export type RequestHandlerMap<Events extends TypedEventMap> = {
|
|
5
|
-
[K in keyof Events]: (...args: Events[K]) => any;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* The class that provides peer communication between browser tabs and service workers
|
|
9
|
-
* @typeParam Events - The map of events and their arguments that can be emitted and listened to.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Swarm<Events extends TypedEventMap = TypedEventMap> extends TypedEventEmitter<Events> {
|
|
12
|
-
#private;
|
|
13
|
-
private static readonly INTERNAL_HEARTBEAT;
|
|
14
|
-
private static readonly INTERNAL_OBITUARY;
|
|
15
|
-
/** @private */
|
|
16
|
-
constructor(secret?: string | Secret<string>);
|
|
17
|
-
/**
|
|
18
|
-
* The ID of the current instance.
|
|
19
|
-
*/
|
|
20
|
-
get id(): string;
|
|
21
|
-
/**
|
|
22
|
-
* Whether this instance is the leader or not.
|
|
23
|
-
*/
|
|
24
|
-
get leader(): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Emit an event to all connected peers.
|
|
27
|
-
* @param event - The name of the event to emit.
|
|
28
|
-
* @param args - The arguments to pass to the event listeners.
|
|
29
|
-
* @typeParam E - The name of the event to emit.
|
|
30
|
-
*/
|
|
31
|
-
emit<E extends keyof Events>(event: E, ...args: Events[E]): this;
|
|
32
|
-
/**
|
|
33
|
-
* Subscribe to the leadership change event.
|
|
34
|
-
* @param cb - The callback function to be called when the leadership status changes.
|
|
35
|
-
*/
|
|
36
|
-
onLeadershipChange(cb: (is: boolean) => void): this;
|
|
37
|
-
/**
|
|
38
|
-
* Remove the leadership change event listener.
|
|
39
|
-
* @param cb - The callback function to be removed from the leadership change event.
|
|
40
|
-
*/
|
|
41
|
-
offLeadershipChange(cb: (is: boolean) => void): this;
|
|
42
|
-
/**
|
|
43
|
-
* Subscribe to the next occurance of a leadership change event.
|
|
44
|
-
* @param cb - The callback function to be called when the leadership status changes.
|
|
45
|
-
*/
|
|
46
|
-
onceLeadershipChange(cb: (is: boolean) => void): this;
|
|
47
|
-
/**
|
|
48
|
-
* Collect responses from all peers for a specific event.
|
|
49
|
-
* @param event The name of the event to collect responses for.
|
|
50
|
-
* @param args The arguments which will be passed to the event handler.
|
|
51
|
-
* @returns A promise that resolves with an array of responses from all peers.
|
|
52
|
-
* @typeParam R - The type of the response.
|
|
53
|
-
* @typeParam E - The name of the event to collect responses for.
|
|
54
|
-
*/
|
|
55
|
-
collect<R, E extends keyof Events = keyof Events>(event: E, ...args: Events[E]): Promise<R[]>;
|
|
56
|
-
/**
|
|
57
|
-
* Register a handler for a specific event which will respond to incoming messages which require a general response
|
|
58
|
-
* @param event The name of the event to listen for.
|
|
59
|
-
* @param handler The function to call when the event is emitted.
|
|
60
|
-
* @typeParam E - The name of the event to listen for.
|
|
61
|
-
*/
|
|
62
|
-
onCollect<E extends keyof Events>(event: E, handler: (...args: Events[E]) => ReturnType<RequestHandlerMap<Events>[E]>): this;
|
|
63
|
-
/**
|
|
64
|
-
* De-register a handler for a specific event which will respond to incoming messages which require a general response
|
|
65
|
-
* @param event The name of the event to listen for.
|
|
66
|
-
* @param handler The function to call when the event is emitted.
|
|
67
|
-
* @typeParam E - The name of the event to listen for.
|
|
68
|
-
*/
|
|
69
|
-
offCollect<E extends keyof Events>(event: E): this;
|
|
70
|
-
/**
|
|
71
|
-
* Request feedback from the leader for a specific event.
|
|
72
|
-
* @param event The name of the event to request feedback for.
|
|
73
|
-
* @param args The arguments to pass to the event handler.
|
|
74
|
-
* @returns A promise that resolves with the response from the event handler.
|
|
75
|
-
* @typeParam R - The type of the response.
|
|
76
|
-
* @typeParam E - The name of the event to request feedback for.
|
|
77
|
-
*/
|
|
78
|
-
request<R = any, E extends keyof Events = keyof Events>(event: E, ...args: Events[E]): Promise<R>;
|
|
79
|
-
/**
|
|
80
|
-
* Register a handler for a specific event which will respond to incoming messages which require a response from the leader
|
|
81
|
-
* @param event The name of the event to listen for.
|
|
82
|
-
* @param handler The function to call when the event is emitted.
|
|
83
|
-
* @typeParam E - The name of the event to listen for.
|
|
84
|
-
*/
|
|
85
|
-
onRequest<E extends keyof Events>(event: E, handler: (...args: Events[E]) => ReturnType<RequestHandlerMap<Events>[E]>): this;
|
|
86
|
-
/**
|
|
87
|
-
* De-register a handler for a specific event which will respond to incoming messages which require a response from the leader
|
|
88
|
-
* @param event The name of the event to listen for.
|
|
89
|
-
* @param handler The function to call when the event is emitted.
|
|
90
|
-
* @typeParam E - The name of the event to listen for.
|
|
91
|
-
*/
|
|
92
|
-
offRequest<E extends keyof Events>(event: E): this;
|
|
93
|
-
/**
|
|
94
|
-
* Set the timeout for waiting for a response from `request()` or `collect()`.
|
|
95
|
-
* @param timeout The timeout in milliseconds to wait for a response.
|
|
96
|
-
* @returns The current instance of the Swarm class for the current context.
|
|
97
|
-
*/
|
|
98
|
-
setAwaitResponseTimeout(timeout: number): this;
|
|
99
|
-
/**
|
|
100
|
-
* Retreive the current instance of the Swarm class for the current context.
|
|
101
|
-
* @typeParam Events - The map of events and their arguments that can be emitted and listened to.
|
|
102
|
-
* @returns The current instance of the Swarm class for the current context.
|
|
103
|
-
*/
|
|
104
|
-
static instance<Events extends TypedEventMap = TypedEventMap>(secret?: string | Secret<string>): Swarm<Events>;
|
|
105
|
-
}
|
package/lib/common.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns true if the environment is a browser tab
|
|
3
|
-
* @returns {boolean} - true if the environment is a browser tab
|
|
4
|
-
*/
|
|
5
|
-
export declare const isTabEnvironment: () => boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Returns true if the environment is a service worker
|
|
8
|
-
* @returns {boolean} - true if the environment is a service worker
|
|
9
|
-
*/
|
|
10
|
-
export declare const isWorkerEnvironment: () => boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Returns true if the environment is an SSR (Server-Side Rendering) environment
|
|
13
|
-
* @returns {boolean} - true if the environment is an SSR environment
|
|
14
|
-
*/
|
|
15
|
-
export declare const isSsrEnvironment: () => boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Return true if the environment is a Safari browser
|
|
18
|
-
* @returns {boolean} - true if the environment is a Safari browser
|
|
19
|
-
*/
|
|
20
|
-
export declare const isSafari: () => boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Return the global object for the current environment
|
|
23
|
-
* @returns An object representing the global scope
|
|
24
|
-
*/
|
|
25
|
-
export declare const getGlobal: () => Window | WorkerGlobalScope;
|
|
26
|
-
export declare const makeRandomId: (length: number) => string;
|
package/lib/emitter.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { TinyEmitter } from 'tiny-emitter';
|
|
2
|
-
/**
|
|
3
|
-
* A map from event-names to the tuple of arguments
|
|
4
|
-
* that listeners for that event will receive.
|
|
5
|
-
*/
|
|
6
|
-
export interface TypedEventMap {
|
|
7
|
-
[event: string]: any[];
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A strongly-typed Tiny Event Emitter.
|
|
11
|
-
*
|
|
12
|
-
* @template Events
|
|
13
|
-
* key = event name,
|
|
14
|
-
* value = tuple type of that event’s arguments
|
|
15
|
-
*/
|
|
16
|
-
export declare class TypedEventEmitter<Events extends TypedEventMap = TypedEventMap> extends TinyEmitter {
|
|
17
|
-
/**
|
|
18
|
-
* Subscribe to an event with a typed listener.
|
|
19
|
-
*/
|
|
20
|
-
on<E extends keyof Events>(event: E, listener: (...args: Events[E]) => void, ctx?: any): this;
|
|
21
|
-
/**
|
|
22
|
-
* Subscribe once to an event.
|
|
23
|
-
*/
|
|
24
|
-
once<E extends keyof Events>(event: E, listener: (...args: Events[E]) => void, ctx?: any): this;
|
|
25
|
-
/**
|
|
26
|
-
* Emit an event, enforcing that the args match Events[E].
|
|
27
|
-
*/
|
|
28
|
-
emit<E extends keyof Events>(event: E, ...args: Events[E]): this;
|
|
29
|
-
/**
|
|
30
|
-
* Remove a listener.
|
|
31
|
-
*/
|
|
32
|
-
off<E extends keyof Events>(event: E, listener?: (...args: Events[E]) => void): this;
|
|
33
|
-
}
|
package/lib/encryption.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export declare const LogLevelStyles: {
|
|
2
|
-
EMERG: (text: string) => string[];
|
|
3
|
-
ALERT: (text: string) => string[];
|
|
4
|
-
CRIT: (text: string) => string[];
|
|
5
|
-
ERROR: (text: string) => string[];
|
|
6
|
-
WARNING: (text: string) => string[];
|
|
7
|
-
NOTICE: (text: string) => string[];
|
|
8
|
-
INFO: (text: string) => string[];
|
|
9
|
-
DEBUG: (text: string) => string[];
|
|
10
|
-
};
|
|
11
|
-
export declare enum LogLevelValues {
|
|
12
|
-
EMERG = 0,
|
|
13
|
-
ALERT = 1,
|
|
14
|
-
CRIT = 2,
|
|
15
|
-
ERROR = 3,
|
|
16
|
-
WARNING = 4,
|
|
17
|
-
NOTICE = 5,
|
|
18
|
-
INFO = 6,
|
|
19
|
-
DEBUG = 7
|
|
20
|
-
}
|
|
21
|
-
export type LogLevel = keyof typeof LogLevelStyles | Lowercase<keyof typeof LogLevelStyles>;
|
|
22
|
-
declare const EnvironmentStyles: {
|
|
23
|
-
BROWSER: (text: string) => string[];
|
|
24
|
-
WORKER: (text: string) => string[];
|
|
25
|
-
SSR: (text: string) => string[];
|
|
26
|
-
UNKNOWN: (text: string) => string[];
|
|
27
|
-
};
|
|
28
|
-
export type Environment = keyof typeof EnvironmentStyles | Lowercase<keyof typeof EnvironmentStyles>;
|
|
29
|
-
export declare class Logger {
|
|
30
|
-
#private;
|
|
31
|
-
constructor(level?: LogLevelValues);
|
|
32
|
-
get level(): LogLevel;
|
|
33
|
-
set level(level: LogLevel);
|
|
34
|
-
EMERG(...args: any[]): void;
|
|
35
|
-
ALERT(...args: any[]): void;
|
|
36
|
-
CRIT(...args: any[]): void;
|
|
37
|
-
ERROR(...args: any[]): void;
|
|
38
|
-
WARNING(...args: any[]): void;
|
|
39
|
-
NOTICE(...args: any[]): void;
|
|
40
|
-
INFO(...args: any[]): void;
|
|
41
|
-
DEBUG(...args: any[]): void;
|
|
42
|
-
emerg(...args: any[]): void;
|
|
43
|
-
alert(...args: any[]): void;
|
|
44
|
-
crit(...args: any[]): void;
|
|
45
|
-
error(...args: any[]): void;
|
|
46
|
-
warning(...args: any[]): void;
|
|
47
|
-
notice(...args: any[]): void;
|
|
48
|
-
info(...args: any[]): void;
|
|
49
|
-
debug(...args: any[]): void;
|
|
50
|
-
}
|
|
51
|
-
export declare const getLogger: () => Logger;
|
|
52
|
-
/**
|
|
53
|
-
* Sets the log level for the logger.
|
|
54
|
-
* @param level - The log level to set. Can be one of the following:
|
|
55
|
-
* - `EMERG` or `emerg`
|
|
56
|
-
* - `ALERT` or `alert`
|
|
57
|
-
* - `CRIT` or `crit`
|
|
58
|
-
* - `ERROR` or `error`
|
|
59
|
-
* - `WARNING` or `warning`
|
|
60
|
-
* - `NOTICE` or `notice`
|
|
61
|
-
* - `INFO` or `info`
|
|
62
|
-
* - `DEBUG` or `debug`
|
|
63
|
-
*
|
|
64
|
-
* @remarks You can also set `window.SWARM_LOG_LEVEL` or `globalThis.SWARM_LOG_LEVEL` to the same values to set the log level globally before initializing any of the Swarm modules.
|
|
65
|
-
*/
|
|
66
|
-
export declare const setLogLevel: (level: LogLevel) => void;
|
|
67
|
-
export {};
|
package/lib/symbols.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const FOR_BROWSER: unique symbol;
|
|
2
|
-
export declare const FOR_WORKER: unique symbol;
|
|
3
|
-
export declare const FOR_SWARM: unique symbol;
|
|
4
|
-
export declare const FOR_LOGGER: unique symbol;
|
|
5
|
-
export declare const CAPTURE_REJECTION_SYMBOL: unique symbol;
|
|
6
|
-
export declare const FOR_ENCRYPTION: unique symbol;
|
package/types-C0eRuyk9.js
DELETED
package/types-C0eRuyk9.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-C0eRuyk9.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/types-CBFnAS2P.mjs
DELETED
package/types-CBFnAS2P.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-CBFnAS2P.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|