@leofcoin/peernet 1.1.36 → 1.1.37

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.
@@ -1,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './peernet-2d11823c.js';
1
+ import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './peernet-c51c19dd.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  function commonjsRequire(path) {
@@ -41023,6 +41023,8 @@ class P2PTClient extends P2PT {
41023
41023
 
41024
41024
  }
41025
41025
 
41026
+ #que = new Map()
41027
+
41026
41028
  bw = {
41027
41029
  up: 0,
41028
41030
  down: 0
@@ -41051,8 +41053,22 @@ class P2PTClient extends P2PT {
41051
41053
  });
41052
41054
 
41053
41055
  this.on('peerconnect', async (peer) => {
41054
- this.#discovered[peer.id] = await new P2PTPeer(peer, this);
41056
+ if (!this.#discovered[peer.id]) this.#discovered[peer.id] = await new P2PTPeer(peer, this);
41055
41057
  if (this.#discovered[peer.id].connected) pubsub.publish('peer:discovered', this.#discovered[peer.id]);
41058
+
41059
+ if (this.#que.has(peer.id)) {
41060
+ const set = this.#que.get(peer.id);
41061
+
41062
+ for (const item of set) {
41063
+ if (this.#discovered[peer.id]?.connected) {
41064
+ this.#discovered[peer.id]?._handleMessage(new Uint8Array(Object.values(item.data)), item.id, item.from);
41065
+ this.bw.down += item.data.length || item.data.byteLength;
41066
+ set.delete(item);
41067
+ }
41068
+ }
41069
+ if (set.size === 0) this.#que.delete(peer.id);
41070
+ else this.#que.set(peer.id, set);
41071
+ }
41056
41072
  });
41057
41073
 
41058
41074
  this.on('peerclose', async (peer) => {
@@ -41063,14 +41079,18 @@ class P2PTClient extends P2PT {
41063
41079
  });
41064
41080
 
41065
41081
  this.on('msg', async (peer, data, id, from) => {
41066
- const hasPeer = this.#discovered[peer.id];
41067
- if (!hasPeer) this.#discovered[peer.id] = await new P2PTPeer(peer, this);
41068
-
41069
- if (this.#discovered[peer.id].connected) {
41082
+ if (!this.#discovered[peer.id]) {
41083
+ if (this.#que.has(peer.id)) {
41084
+ const set = this.#que.get(peer.id);
41085
+ set.add({peer, data, id, from});
41086
+ this.#que.set(peer.id, set);
41087
+ } else {
41088
+ this.#que.set(peer.id, new Set([{peer, data, id, from}]));
41089
+ }
41090
+ } else if (this.#discovered[peer.id]?.connected) {
41070
41091
  this.#discovered[peer.id]?._handleMessage(new Uint8Array(Object.values(data)), id, from);
41071
41092
  this.bw.down += data.length || data.byteLength;
41072
41093
  }
41073
-
41074
41094
  });
41075
41095
 
41076
41096
  this.on('data', async (peer, data) => {
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-2d11823c.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-c51c19dd.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './peernet-2d11823c.js';
1
+ import { F as FormatInterface } from './peernet-c51c19dd.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  var proto$b = {
@@ -20183,7 +20183,7 @@ class Identity {
20183
20183
  globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
20184
20184
  }
20185
20185
  else {
20186
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-f2f8db5e.js');
20186
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-897eebb9.js');
20187
20187
  const { identity, accounts } = await importee.default(password, this.network);
20188
20188
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
20189
20189
  await globalThis.walletStore.put('version', String(1));
@@ -20354,7 +20354,7 @@ class Peernet {
20354
20354
  this.root = options.root;
20355
20355
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
20356
20356
  // FolderMessageResponse
20357
- } = await import(/* webpackChunkName: "messages" */ './messages-fc7c059d.js');
20357
+ } = await import(/* webpackChunkName: "messages" */ './messages-d4613b80.js');
20358
20358
  /**
20359
20359
  * proto Object containing protos
20360
20360
  * @type {Object}
@@ -20433,7 +20433,7 @@ class Peernet {
20433
20433
  if (this.#starting || this.#started)
20434
20434
  return;
20435
20435
  this.#starting = true;
20436
- const importee = await import('./client-c3673dc8.js');
20436
+ const importee = await import('./client-fdce8059.js');
20437
20437
  /**
20438
20438
  * @access public
20439
20439
  * @type {PeernetClient}
@@ -1,2 +1,2 @@
1
- export { P as default } from './peernet-2d11823c.js';
1
+ export { P as default } from './peernet-c51c19dd.js';
2
2
  import './value-157ab062.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "1.1.36",
3
+ "version": "1.1.37",
4
4
  "description": "",
5
5
  "main": "src/peernet.js",
6
6
  "exports": {