webpeerjs 0.0.8 → 0.0.9

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/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "webpeerjs",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Simple peer-to-peer with IPFS",
5
5
  "main": "./dist/umd/webpeerjs.js",
6
- "module": "./dist/esm/webpeerjs.js",
6
+ "module": "./src/webpeerjs.js",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/esm/webpeerjs.js",
9
+ "import": "./src/webpeerjs.js",
10
10
  "require": "./dist/umd/webpeerjs.js"
11
11
  }
12
12
  },
13
13
  "files": [
14
14
  "dist/",
15
- "src/",
15
+ "src/",
16
16
  "LICENSE"
17
17
  ],
18
18
  "scripts": {
@@ -20,12 +20,10 @@
20
20
  "dev": "vite serve test",
21
21
  "eslint": "eslint ./src",
22
22
  "eslint:fix": "eslint ./src --fix",
23
-
24
23
  "removedir": "node -e \"var fs = require('fs'); try{process.argv.slice(1).map((fpath) => fs.rmdirSync(fpath, { recursive: true }))}catch(err){console.log(`Dist not found`)}; process.exit(0);\"",
25
24
  "build-all": "tsc -p config/tsconfig-rollup.json && rollup -c temp/config/rollup.config.build.js && echo {\"type\": \"commonjs\"}>dist\\umd\\package.json && echo {\"type\": \"module\"}>dist\\esm\\package.json",
26
25
  "build-types": "tsc -p config/tsconfig-esm.json",
27
26
  "build": "npm run removedir dist temp && npm run build-all && npm run build-types",
28
-
29
27
  "test": "echo \"Error: no test specified\" && exit 1"
30
28
  },
31
29
  "repository": {
@@ -36,9 +34,9 @@
36
34
  "p2p",
37
35
  "ipfs",
38
36
  "peer",
39
- "peer to peer",
40
- "decentralized",
41
- "browser to browser"
37
+ "peer to peer",
38
+ "decentralized",
39
+ "browser to browser"
42
40
  ],
43
41
  "author": {
44
42
  "name": "Nuzulul Zulkarnain",
@@ -61,20 +59,19 @@
61
59
  "@libp2p/pubsub-peer-discovery": "^10.0.2",
62
60
  "@libp2p/simple-metrics": "^1.0.2",
63
61
  "@libp2p/webtransport": "^4.0.32",
64
- "@multiformats/multiaddr": "^12.2.3",
65
62
  "datastore-idb": "^2.1.9",
66
63
  "libp2p": "^1.6.0"
67
64
  },
68
65
  "devDependencies": {
69
66
  "@eslint/js": "^9.4.0",
70
- "eslint": "^9.4.0",
71
- "globals": "^15.3.0",
72
- "vite": "^5.2.11",
73
67
  "@rollup/plugin-commonjs": "^25.0.8",
74
68
  "@rollup/plugin-node-resolve": "^15.2.3",
75
69
  "@rollup/plugin-typescript": "^11.1.6",
70
+ "eslint": "^9.4.0",
71
+ "globals": "^15.3.0",
76
72
  "rollup": "^4.18.0",
77
73
  "tslib": "^2.6.2",
78
- "typescript": "^5.4.5"
74
+ "typescript": "^5.4.5",
75
+ "vite": "^5.2.11"
79
76
  }
80
77
  }
package/src/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const prefix = 'webpeerjs'
2
2
  export const CONFIG_PREFIX = prefix
3
- export const CONFIG_PROTOCOL = '/'+prefix+'/0.0.1'
3
+ export const CONFIG_PROTOCOL = '/'+prefix+'/1.0.0'
4
4
  export const CONFIG_BLOCKSTORE_PATH = prefix+'-blockstore'
5
5
  export const CONFIG_DATASTORE_PATH = prefix+'-datastore'
6
6
  export const CONFIG_DBSTORE_PATH = prefix+'-dbstore'
package/src/utils.js CHANGED
@@ -1,11 +1,24 @@
1
1
  import * as config from './config'
2
-
3
2
  import { Peer as PBPeer } from './peer'
4
-
5
3
  import { Key } from 'interface-datastore'
6
-
7
4
  import { sha256 } from 'multiformats/hashes/sha2'
5
+ import { multiaddr } from '@multiformats/multiaddr'
6
+ import { pipe } from 'it-pipe'
7
+ import { lpStream } from 'it-length-prefixed-stream'
8
+ import * as lp from 'it-length-prefixed'
9
+ import map from 'it-map'
10
+
11
+ export { Key }
12
+
13
+ export { multiaddr }
8
14
 
15
+ export { pipe }
16
+
17
+ export { lpStream }
18
+
19
+ export { lp }
20
+
21
+ export { map }
9
22
 
10
23
 
11
24
  const prefix = config.CONFIG_PREFIX
@@ -35,8 +48,6 @@ export async function first(farr){
35
48
  }
36
49
  }
37
50
 
38
- export {Key}
39
-
40
51
  //Add id to pupsub message
41
52
  export async function msgIdFnStrictNoSign(msg){
42
53
  var enc = new TextEncoder()
@@ -142,16 +153,16 @@ export function metrics(data){
142
153
  fail = errors+timeouts
143
154
  const treshold = errors+timeouts+stats.open+stats.pending
144
155
 
145
- if(treshold>40){
156
+ if(treshold>30){
146
157
  //console.log(`Treeshold hit : ${treshold}`)
147
158
  }
148
159
 
149
- if(fail>40){
160
+ if(fail>30){
150
161
  //console.log(`Open : ${stats.open} , Pending : ${stats.pending} , Succes : ${totals.success} , Fail : ${fail} `)
151
162
 
152
163
  }
153
164
 
154
- if ((fail-lastfailtreshold)>40){
165
+ if ((fail-lastfailtreshold)>30){
155
166
  if(isDialEnabled){
156
167
  isDialEnabled = false
157
168
  const str = JSON.stringify({isDialEnabled,fail,lastfailtreshold})