@leofcoin/peernet 1.1.45 → 1.1.46
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.
|
@@ -8,55 +8,55 @@ globalThis.debug = text => {
|
|
|
8
8
|
if (globalThis.DEBUG) console.log('\x1b[34m\x1b[1m%s', text, '\x1b[0m'); // bright blue
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
class LittlePubSub {
|
|
12
|
-
subscribers = {};
|
|
13
|
-
verbose;
|
|
14
|
-
constructor(verbose
|
|
15
|
-
this.verbose = verbose;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (typeof context === 'undefined') {
|
|
19
|
-
context = handler;
|
|
20
|
-
}
|
|
21
|
-
return context;
|
|
22
|
-
}
|
|
23
|
-
hasSubscribers(event) {
|
|
24
|
-
return this.subscribers[event] ? true : false;
|
|
25
|
-
}
|
|
26
|
-
subscribe(event, handler, context) {
|
|
27
|
-
if (!this.hasSubscribers(event))
|
|
28
|
-
this.subscribers[event] = { handlers: [], value: undefined };
|
|
29
|
-
context = this
|
|
30
|
-
this.subscribers[event].handlers.push(handler.bind(context));
|
|
31
|
-
}
|
|
32
|
-
unsubscribe(event, handler, context) {
|
|
33
|
-
if (!this.hasSubscribers(event))
|
|
34
|
-
return;
|
|
35
|
-
context = this
|
|
36
|
-
const index = this.subscribers[event].handlers.indexOf(handler.bind(context));
|
|
37
|
-
this.subscribers[event].handlers.splice(index);
|
|
38
|
-
if (this.subscribers[event].handlers.length === 0)
|
|
39
|
-
delete this.subscribers[event];
|
|
40
|
-
}
|
|
41
|
-
publish(event, change) {
|
|
42
|
-
if (!this.hasSubscribers(event))
|
|
43
|
-
return;
|
|
44
|
-
if (this.verbose || this.subscribers[event]
|
|
45
|
-
this.subscribers[event].value = change;
|
|
46
|
-
this.subscribers[event].handlers.forEach((handler) => {
|
|
47
|
-
handler(change, this.subscribers[event].value);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
once(event) {
|
|
52
|
-
return new Promise((resolve) => {
|
|
53
|
-
const cb = (value) => {
|
|
54
|
-
this.unsubscribe(event, cb);
|
|
55
|
-
resolve(value);
|
|
56
|
-
};
|
|
57
|
-
this.subscribe(event, cb);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
11
|
+
class LittlePubSub {
|
|
12
|
+
subscribers = {};
|
|
13
|
+
verbose;
|
|
14
|
+
constructor(verbose) {
|
|
15
|
+
this.verbose = verbose;
|
|
16
|
+
}
|
|
17
|
+
_handleContext(handler, context) {
|
|
18
|
+
if (typeof context === 'undefined') {
|
|
19
|
+
context = handler;
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
hasSubscribers(event) {
|
|
24
|
+
return this.subscribers[event] ? true : false;
|
|
25
|
+
}
|
|
26
|
+
subscribe(event, handler, context) {
|
|
27
|
+
if (!this.hasSubscribers(event))
|
|
28
|
+
this.subscribers[event] = { handlers: [], value: undefined };
|
|
29
|
+
context = this._handleContext(handler, context);
|
|
30
|
+
this.subscribers[event].handlers.push(handler.bind(context));
|
|
31
|
+
}
|
|
32
|
+
unsubscribe(event, handler, context) {
|
|
33
|
+
if (!this.hasSubscribers(event))
|
|
34
|
+
return;
|
|
35
|
+
context = this._handleContext(handler, context);
|
|
36
|
+
const index = this.subscribers[event].handlers.indexOf(handler.bind(context));
|
|
37
|
+
this.subscribers[event].handlers.splice(index);
|
|
38
|
+
if (this.subscribers[event].handlers.length === 0)
|
|
39
|
+
delete this.subscribers[event];
|
|
40
|
+
}
|
|
41
|
+
publish(event, change) {
|
|
42
|
+
if (!this.hasSubscribers(event))
|
|
43
|
+
return;
|
|
44
|
+
if (this.verbose || this.subscribers[event]?.value !== change) {
|
|
45
|
+
this.subscribers[event].value = change;
|
|
46
|
+
this.subscribers[event].handlers.forEach((handler) => {
|
|
47
|
+
handler(change, this.subscribers[event].value);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
once(event) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
const cb = (value) => {
|
|
54
|
+
this.unsubscribe(event, cb);
|
|
55
|
+
resolve(value);
|
|
56
|
+
};
|
|
57
|
+
this.subscribe(event, cb);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// base-x encoding / decoding
|
|
@@ -691,6 +691,8 @@ var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
|
|
|
691
691
|
|
|
692
692
|
var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
|
|
693
693
|
|
|
694
|
+
bn$1.exports;
|
|
695
|
+
|
|
694
696
|
(function (module) {
|
|
695
697
|
(function (module, exports) {
|
|
696
698
|
|
|
@@ -7149,6 +7151,8 @@ var utils$o = {};
|
|
|
7149
7151
|
|
|
7150
7152
|
var bn = {exports: {}};
|
|
7151
7153
|
|
|
7154
|
+
bn.exports;
|
|
7155
|
+
|
|
7152
7156
|
(function (module) {
|
|
7153
7157
|
(function (module, exports) {
|
|
7154
7158
|
|
|
@@ -20174,7 +20178,7 @@ class Identity {
|
|
|
20174
20178
|
globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
|
|
20175
20179
|
}
|
|
20176
20180
|
else {
|
|
20177
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
20181
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-b203939f.js');
|
|
20178
20182
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
20179
20183
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
20180
20184
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -20345,7 +20349,7 @@ class Peernet {
|
|
|
20345
20349
|
this.root = options.root;
|
|
20346
20350
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
20347
20351
|
// FolderMessageResponse
|
|
20348
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
20352
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-7138679c.js');
|
|
20349
20353
|
/**
|
|
20350
20354
|
* proto Object containing protos
|
|
20351
20355
|
* @type {Object}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-4dde5a19.js';
|
|
2
2
|
import './value-157ab062.js';
|