Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 3207e3b

Browse files
authored
fix: dont include util.textencoder in the browser (#2919)
* fix: dont include util.textencoder in the browser node 10 only has textencoder inside util and not in the global var so we need to do the standard node/browser swap to avoid including node util in the browser * fix: fix object stat timeout test * fix: add interop gh branch
1 parent 9bc9625 commit 3207e3b

File tree

9 files changed

+16
-8
lines changed

9 files changed

+16
-8
lines changed

packages/interface-ipfs-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"ipfs-unixfs": "^1.0.0",
4242
"ipfs-utils": "^0.7.2",
4343
"ipld-dag-cbor": "^0.15.1",
44-
"ipld-dag-pb": "^0.18.2",
44+
"ipld-dag-pb": "^0.18.3",
4545
"is-ipfs": "^0.6.1",
4646
"it-all": "^1.0.1",
4747
"it-concat": "^1.0.0",

packages/interface-ipfs-core/src/object/stat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module.exports = (common, options) => {
6666
expect(err.message).to.equal('failed to get block for QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3MzzzzzZ: context deadline exceeded')
6767
}
6868

69-
expect(timeForRequest).to.not.lessThan(timeout - 0.1)
69+
expect(timeForRequest).to.not.lessThan(timeout - 1000)
7070
expect(timeForRequest).to.not.greaterThan(timeout + 1000)
7171
})
7272

packages/ipfs-http-client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"ipfs-block": "^0.8.1",
5050
"ipfs-utils": "^0.7.2",
5151
"ipld-dag-cbor": "^0.15.1",
52-
"ipld-dag-pb": "^0.18.2",
52+
"ipld-dag-pb": "^0.18.3",
5353
"ipld-raw": "^4.0.1",
5454
"iso-url": "^0.4.6",
5555
"it-tar": "^1.2.1",

packages/ipfs-mfs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"ipfs-unixfs-exporter": "^1.0.1",
7171
"ipfs-unixfs-importer": "^1.0.1",
7272
"ipfs-utils": "^0.7.0",
73-
"ipld-dag-pb": "^0.18.2",
73+
"ipld-dag-pb": "^0.18.3",
7474
"it-all": "^1.0.1",
7575
"it-last": "^1.0.1",
7676
"it-to-stream": "^0.1.1",

packages/ipfs-utils/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"Marcin Rataj <[email protected]>"
5555
],
5656
"browser": {
57-
"fs-extra": false
57+
"fs-extra": false,
58+
"./src/text-encoder.js": "./src/text-encoder.browser.js"
5859
}
5960
}

packages/ipfs-utils/src/http.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const fetch = require('node-fetch')
55
const merge = require('merge-options')
66
const { URL, URLSearchParams } = require('iso-url')
77
const global = require('./globalthis')
8+
const TextDecoder = require('./text-encoder')
89
const Request = global.Request
910
const AbortController = global.AbortController
1011

@@ -235,7 +236,6 @@ class HTTP {
235236
* @returns {AsyncGenerator<Object, void, any>}
236237
*/
237238
const ndjson = async function * (source) {
238-
const TextDecoder = globalThis.TextDecoder || require('util').TextDecoder
239239
const decoder = new TextDecoder()
240240
let buf = ''
241241

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict'
2+
3+
const global = require('./globalthis')
4+
5+
module.exports = global.TextDecoder
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
'use strict'
2+
module.exports = require('util').TextDecoder

packages/ipfs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"ipld": "^0.25.0",
108108
"ipld-bitcoin": "^0.3.0",
109109
"ipld-dag-cbor": "^0.15.1",
110-
"ipld-dag-pb": "^0.18.2",
110+
"ipld-dag-pb": "^0.18.3",
111111
"ipld-ethereum": "^4.0.0",
112112
"ipld-git": "^0.5.0",
113113
"ipld-raw": "^4.0.1",
@@ -182,7 +182,7 @@
182182
"go-ipfs-dep": "0.4.23-3",
183183
"hat": "0.0.3",
184184
"interface-ipfs-core": "^0.132.0",
185-
"ipfs-interop": "^1.0.0",
185+
"ipfs-interop": "ipfs/interop#fix/name-pubsub",
186186
"ipfsd-ctl": "^3.0.0",
187187
"it-first": "^1.0.1",
188188
"ncp": "^2.0.0",

0 commit comments

Comments
 (0)