@@ -18,7 +15,7 @@ function renderOutput (output: string | JSX.Element, err: string): JSX.Element {
if (typeof output === 'string') {
return (
- {output != null && (
+ {output.length > 0 && (
{`${output}`}
@@ -30,7 +27,7 @@ function renderOutput (output: string | JSX.Element, err: string): JSX.Element {
return output
}
-function loadingIndicator (message: string): JSX.Element {
+function loadingIndicator(message: string): JSX.Element {
return (
Loading... {message}
@@ -38,7 +35,7 @@ function loadingIndicator (message: string): JSX.Element {
)
}
-function App (): JSX.Element {
+function App(): JSX.Element {
const [path, setPath] = useState
('')
const [output, setOutput] = useState('')
const [err, setErr] = useState('')
@@ -77,7 +74,6 @@ function App (): JSX.Element {
setSuccess(JSON.stringify(json, null, 2))
} catch (err) {
setError((err as Error).message)
-
}
}, [])
@@ -93,10 +89,6 @@ function App (): JSX.Element {
}, [])
const onFetchJson = useCallback(async () => {
- if (path == null) {
- setError('Invalid path')
- return
- }
try {
setLoading('Fetching json response...')
const resp = await verifiedFetch(path)
@@ -104,14 +96,9 @@ function App (): JSX.Element {
} catch (err) {
setError((err as Error).message)
}
-
}, [path, handleJsonType])
const onFetchImage = useCallback(async () => {
- if (path == null) {
- setError('Invalid path')
- return
- }
try {
setLoading('Fetching image response...')
const resp = await verifiedFetch(path)
@@ -122,10 +109,6 @@ function App (): JSX.Element {
}, [path, handleImageType])
const onFetchFile = useCallback(async () => {
- if (path == null) {
- setError('Invalid path')
- return
- }
try {
setLoading('Fetching content to download...')
const resp = await verifiedFetch(path)
@@ -184,9 +167,18 @@ function App (): JSX.Element {
{/* Left */}
-
- Verified Retrieval with @helia/verified-fetch
-
+
+
+
+
+
+ Verified Retrieval with @helia/verified-fetch
+
+
@@ -194,7 +186,9 @@ function App (): JSX.Element {
type="text"
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="ipfs://... or ipns://"
- onChange={(e) => { setPath(e.target.value) }}
+ onChange={(e) => {
+ setPath(e.target.value)
+ }}
value={path}
/>
diff --git a/examples/helia-browser-react-verified-fetch/tailwind.config.js b/examples/helia-browser-react-verified-fetch/tailwind.config.js
deleted file mode 100644
index 7141e452..00000000
--- a/examples/helia-browser-react-verified-fetch/tailwind.config.js
+++ /dev/null
@@ -1,8 +0,0 @@
-/** @type {import('tailwindcss').Config} */
-export default {
- content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
- theme: {
- extend: {},
- },
- plugins: [],
-}
From 2ac6a7543dec30e04c741931b910efac2309b5b1 Mon Sep 17 00:00:00 2001
From: Daniel N <2color@users.noreply.github.com>
Date: Fri, 9 Feb 2024 12:47:07 +0100
Subject: [PATCH 05/23] chore: rename folder
---
.../.gitignore | 0
.../README.md | 0
.../index.html | 0
.../package.json | 4 ++--
.../src/App.tsx | 0
.../src/constants.ts | 0
.../src/main.tsx | 0
.../tsconfig.json | 0
.../tsconfig.node.json | 0
.../vite.config.ts | 0
10 files changed, 2 insertions(+), 2 deletions(-)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/.gitignore (100%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/README.md (100%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/index.html (100%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/package.json (87%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/src/App.tsx (100%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/src/constants.ts (100%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/src/main.tsx (100%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/tsconfig.json (100%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/tsconfig.node.json (100%)
rename examples/{helia-browser-react-verified-fetch => helia-browser-verified-fetch}/vite.config.ts (100%)
diff --git a/examples/helia-browser-react-verified-fetch/.gitignore b/examples/helia-browser-verified-fetch/.gitignore
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/.gitignore
rename to examples/helia-browser-verified-fetch/.gitignore
diff --git a/examples/helia-browser-react-verified-fetch/README.md b/examples/helia-browser-verified-fetch/README.md
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/README.md
rename to examples/helia-browser-verified-fetch/README.md
diff --git a/examples/helia-browser-react-verified-fetch/index.html b/examples/helia-browser-verified-fetch/index.html
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/index.html
rename to examples/helia-browser-verified-fetch/index.html
diff --git a/examples/helia-browser-react-verified-fetch/package.json b/examples/helia-browser-verified-fetch/package.json
similarity index 87%
rename from examples/helia-browser-react-verified-fetch/package.json
rename to examples/helia-browser-verified-fetch/package.json
index 264172fc..4600ba98 100644
--- a/examples/helia-browser-react-verified-fetch/package.json
+++ b/examples/helia-browser-verified-fetch/package.json
@@ -1,5 +1,5 @@
{
- "name": "helia-browser-react-verified-fetch",
+ "name": "helia-browser-verified-fetch",
"private": true,
"version": "0.0.0",
"type": "module",
@@ -19,6 +19,6 @@
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^4.2.1",
"typescript": "^5.2.2",
- "vite": "^5.0.8"
+ "vite": "^5.0.11"
}
}
diff --git a/examples/helia-browser-react-verified-fetch/src/App.tsx b/examples/helia-browser-verified-fetch/src/App.tsx
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/src/App.tsx
rename to examples/helia-browser-verified-fetch/src/App.tsx
diff --git a/examples/helia-browser-react-verified-fetch/src/constants.ts b/examples/helia-browser-verified-fetch/src/constants.ts
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/src/constants.ts
rename to examples/helia-browser-verified-fetch/src/constants.ts
diff --git a/examples/helia-browser-react-verified-fetch/src/main.tsx b/examples/helia-browser-verified-fetch/src/main.tsx
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/src/main.tsx
rename to examples/helia-browser-verified-fetch/src/main.tsx
diff --git a/examples/helia-browser-react-verified-fetch/tsconfig.json b/examples/helia-browser-verified-fetch/tsconfig.json
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/tsconfig.json
rename to examples/helia-browser-verified-fetch/tsconfig.json
diff --git a/examples/helia-browser-react-verified-fetch/tsconfig.node.json b/examples/helia-browser-verified-fetch/tsconfig.node.json
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/tsconfig.node.json
rename to examples/helia-browser-verified-fetch/tsconfig.node.json
diff --git a/examples/helia-browser-react-verified-fetch/vite.config.ts b/examples/helia-browser-verified-fetch/vite.config.ts
similarity index 100%
rename from examples/helia-browser-react-verified-fetch/vite.config.ts
rename to examples/helia-browser-verified-fetch/vite.config.ts
From 1d7541cbc6c77d51db80657c4df5bf2c3e86d019 Mon Sep 17 00:00:00 2001
From: Daniel N <2color@users.noreply.github.com>
Date: Fri, 9 Feb 2024 14:08:06 +0100
Subject: [PATCH 06/23] chore: add test
---
.../helia-browser-verified-fetch/package.json | 6 ++++-
.../helia-browser-verified-fetch/src/App.tsx | 9 ++++---
.../test/index.spec.js | 27 +++++++++++++++++++
3 files changed, 37 insertions(+), 5 deletions(-)
create mode 100644 examples/helia-browser-verified-fetch/test/index.spec.js
diff --git a/examples/helia-browser-verified-fetch/package.json b/examples/helia-browser-verified-fetch/package.json
index 4600ba98..74bc55ad 100644
--- a/examples/helia-browser-verified-fetch/package.json
+++ b/examples/helia-browser-verified-fetch/package.json
@@ -4,9 +4,11 @@
"version": "0.0.0",
"type": "module",
"scripts": {
+ "clean": "rimraf ./dist",
"dev": "vite",
"build": "tsc && vite build",
- "preview": "vite preview"
+ "preview": "vite preview",
+ "test": "npm run build && test-browser-example test"
},
"dependencies": {
"@helia/verified-fetch": "next",
@@ -15,10 +17,12 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
+ "@playwright/test": "^1.31.2",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^4.2.1",
"typescript": "^5.2.2",
+ "test-ipfs-example": "^1.0.0",
"vite": "^5.0.11"
}
}
diff --git a/examples/helia-browser-verified-fetch/src/App.tsx b/examples/helia-browser-verified-fetch/src/App.tsx
index 0c458530..a06aabf4 100644
--- a/examples/helia-browser-verified-fetch/src/App.tsx
+++ b/examples/helia-browser-verified-fetch/src/App.tsx
@@ -184,6 +184,7 @@ function App(): JSX.Element {
{
@@ -193,28 +194,28 @@ function App(): JSX.Element {
/>
-
From c715238066d3c0ed70779e03106565a37bbd14d1 Mon Sep 17 00:00:00 2001
From: Daniel N <2color@users.noreply.github.com>
Date: Thu, 14 Mar 2024 15:17:31 +0100
Subject: [PATCH 14/23] chore: bump verified fetch version
---
examples/helia-browser-verified-fetch/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/helia-browser-verified-fetch/package.json b/examples/helia-browser-verified-fetch/package.json
index 28e9031c..acf024e2 100644
--- a/examples/helia-browser-verified-fetch/package.json
+++ b/examples/helia-browser-verified-fetch/package.json
@@ -11,7 +11,7 @@
"test": "vite build -c ./test/vite.config.js && test-browser-example test"
},
"dependencies": {
- "@helia/verified-fetch": "^1.0.1",
+ "@helia/verified-fetch": "^1.1.2",
"@sgtpooki/file-type": "^1.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
From 26de16f9d7a61e86148be4f4a9fa0c2e064a03c3 Mon Sep 17 00:00:00 2001
From: Daniel N <2color@users.noreply.github.com>
Date: Tue, 19 Mar 2024 13:45:01 +0100
Subject: [PATCH 15/23] fix: add aborting functionality
---
.../helia-browser-verified-fetch/src/App.tsx | 61 ++++++++++++++++---
.../src/constants.ts | 3 -
2 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/examples/helia-browser-verified-fetch/src/App.tsx b/examples/helia-browser-verified-fetch/src/App.tsx
index 8f2727f5..c5a6d7db 100644
--- a/examples/helia-browser-verified-fetch/src/App.tsx
+++ b/examples/helia-browser-verified-fetch/src/App.tsx
@@ -40,6 +40,7 @@ function App(): JSX.Element {
const [output, setOutput] = useState('')
const [err, setErr] = useState('')
const [loading, setLoadingTo] = useState(null)
+ const [controller, setController] = useState(null)
const setSuccess = useCallback((message: string | JSX.Element) => {
setOutput(message)
@@ -79,6 +80,7 @@ function App(): JSX.Element {
const handleVideoType = useCallback(async (resp: Response) => {
try {
+ controller?.abort() // abort any ongoing requests
setLoading('Waiting for full video data...')
const blob = await resp.blob()
const url = URL.createObjectURL(blob)
@@ -90,28 +92,47 @@ function App(): JSX.Element {
const onFetchJson = useCallback(async () => {
try {
+ if(controller) {
+ console.log('aborting', controller)
+ controller.abort() // abort any ongoing requests
+ }
+
setLoading('Fetching json response...')
- const resp = await verifiedFetch(path)
+ const ctl = new AbortController()
+ setController(ctl)
+ const resp = await verifiedFetch(path, { signal: ctl.signal })
await handleJsonType(resp)
} catch (err) {
- setError((err as Error).message)
+ // Don't render AbortErrors since they are user intiated
+ if(err instanceof Error && err.name !== 'AbortError') {
+ setError(err.message)
+ }
}
}, [path, handleJsonType])
const onFetchImage = useCallback(async () => {
try {
+ controller?.abort() // abort any ongoing requests
setLoading('Fetching image response...')
- const resp = await verifiedFetch(path)
+ const ctl = new AbortController()
+ setController(ctl)
+ const resp = await verifiedFetch(path, { signal: ctl.signal })
await handleImageType(resp)
} catch (err) {
- setError((err as Error).message)
+ // Don't render AbortErrors since they are user intiated
+ if(err instanceof Error && err.name !== 'AbortError') {
+ setError(err.message)
+ }
}
}, [path, handleImageType])
const onFetchFile = useCallback(async () => {
try {
+ controller?.abort() // abort any ongoing requests
setLoading('Fetching content to download...')
- const resp = await verifiedFetch(path)
+ const ctl = new AbortController()
+ setController(ctl)
+ const resp = await verifiedFetch(path, { signal: ctl.signal })
const blob = await resp.blob()
const url = URL.createObjectURL(blob)
const downloadLink = document.createElement('a')
@@ -120,18 +141,32 @@ function App(): JSX.Element {
setSuccess('') // clear output
downloadLink.click()
} catch (err) {
- setError((err as Error).message)
+ // Don't render AbortErrors since they are user intiated
+ if(err instanceof Error && err.name !== 'AbortError') {
+ setError(err.message)
+ }
}
}, [path])
+ const onAbort = useCallback(async () => {
+ if(controller != null) {
+ controller.abort('Rqeuest aborted')
+ setLoadingTo(null)
+ }
+ }, [controller])
+
const onFetchAuto = useCallback(async () => {
if (path == null) {
setError('Invalid path')
return
}
try {
+ controller?.abort() // abort any ongoing requests
setLoading('Fetching auto content...')
- const resp = await verifiedFetch(path)
+ const ctl = new AbortController()
+ setController(ctl)
+ const resp = await verifiedFetch(path, { signal: ctl.signal })
+ console.log('onFetchAuto: got resp ', resp)
const buffer = await resp.clone().arrayBuffer()
let contentType = (await fileTypeFromBuffer(new Uint8Array(buffer)))?.mime
if (!contentType) {
@@ -157,7 +192,10 @@ function App(): JSX.Element {
setError(`Unknown content-type: ${contentType}`)
}
} catch (err) {
- setError((err as Error).message)
+ // Don't render AbortErrors since they are user intiated
+ if(err instanceof Error && err.name !== 'AbortError') {
+ setError(err.message)
+ }
}
}, [path, handleImageType, handleJsonType, handleVideoType])
@@ -220,6 +258,13 @@ function App(): JSX.Element {
>
๐ Fetch auto
+
{helpText}
diff --git a/examples/helia-browser-verified-fetch/src/constants.ts b/examples/helia-browser-verified-fetch/src/constants.ts
index 5b34cafc..2f939f7d 100644
--- a/examples/helia-browser-verified-fetch/src/constants.ts
+++ b/examples/helia-browser-verified-fetch/src/constants.ts
@@ -12,9 +12,6 @@ ipfs://bagaaieracglt4ey6qsxtvzqsgwnsw3b6p2tb7nmx5wdgxur2zia7q6nnzh7q
UnixFS JSON ๐
ipfs://bafybeia5ci747h54m2ybc4rf6yqdtm6nzdisxv57pk66fgubjsnnja6wq4
-dag-cbor ๐
-ipfs://bafyreicnokmhmrnlp2wjhyk2haep4tqxiptwfrp2rrs7rzq7uk766chqvq
-
dag-json ๐
ipfs://baguqeerasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea
From 4098ac318d6954d247f92b6de8e1535e7203e3d5 Mon Sep 17 00:00:00 2001
From: Daniel N <2color@users.noreply.github.com>
Date: Mon, 25 Mar 2024 18:17:03 +0100
Subject: [PATCH 16/23] fix: handle abort error
---
.../helia-browser-verified-fetch/package.json | 2 +-
.../helia-browser-verified-fetch/src/App.tsx | 28 +++++++++++++------
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/examples/helia-browser-verified-fetch/package.json b/examples/helia-browser-verified-fetch/package.json
index acf024e2..adce59db 100644
--- a/examples/helia-browser-verified-fetch/package.json
+++ b/examples/helia-browser-verified-fetch/package.json
@@ -11,7 +11,7 @@
"test": "vite build -c ./test/vite.config.js && test-browser-example test"
},
"dependencies": {
- "@helia/verified-fetch": "^1.1.2",
+ "@helia/verified-fetch": "^1.3.1",
"@sgtpooki/file-type": "^1.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
diff --git a/examples/helia-browser-verified-fetch/src/App.tsx b/examples/helia-browser-verified-fetch/src/App.tsx
index c5a6d7db..ae88b16f 100644
--- a/examples/helia-browser-verified-fetch/src/App.tsx
+++ b/examples/helia-browser-verified-fetch/src/App.tsx
@@ -102,9 +102,12 @@ function App(): JSX.Element {
setController(ctl)
const resp = await verifiedFetch(path, { signal: ctl.signal })
await handleJsonType(resp)
- } catch (err) {
+ } catch (err: any) {
+ if(err?.code === 'ABORT_ERR') {
+ return
+ }
// Don't render AbortErrors since they are user intiated
- if(err instanceof Error && err.name !== 'AbortError') {
+ if(err instanceof Error) {
setError(err.message)
}
}
@@ -118,9 +121,12 @@ function App(): JSX.Element {
setController(ctl)
const resp = await verifiedFetch(path, { signal: ctl.signal })
await handleImageType(resp)
- } catch (err) {
+ } catch (err: any) {
+ if(err?.code === 'ABORT_ERR') {
+ return
+ }
// Don't render AbortErrors since they are user intiated
- if(err instanceof Error && err.name !== 'AbortError') {
+ if(err instanceof Error) {
setError(err.message)
}
}
@@ -140,9 +146,12 @@ function App(): JSX.Element {
downloadLink.download = 'download'
setSuccess('') // clear output
downloadLink.click()
- } catch (err) {
+ } catch (err: any) {
+ if(err?.code === 'ABORT_ERR') {
+ return
+ }
// Don't render AbortErrors since they are user intiated
- if(err instanceof Error && err.name !== 'AbortError') {
+ if(err instanceof Error) {
setError(err.message)
}
}
@@ -191,9 +200,12 @@ function App(): JSX.Element {
default:
setError(`Unknown content-type: ${contentType}`)
}
- } catch (err) {
+ } catch (err: any) {
+ if(err?.code === 'ABORT_ERR') {
+ return
+ }
// Don't render AbortErrors since they are user intiated
- if(err instanceof Error && err.name !== 'AbortError') {
+ if(err instanceof Error) {
setError(err.message)
}
}
From c4c2228ae0fce7fe1a49dfb2fefa26880827e04f Mon Sep 17 00:00:00 2001
From: Daniel N <2color@users.noreply.github.com>
Date: Wed, 27 Mar 2024 14:07:09 +0100
Subject: [PATCH 17/23] feat: add ability to fetch as dag-json
---
.../helia-browser-verified-fetch/package.json | 1 +
.../helia-browser-verified-fetch/src/App.tsx | 80 +++++++------------
.../src/Output.tsx | 44 ++++++++++
.../src/constants.ts | 3 +
.../test/index.spec.js | 2 +-
5 files changed, 80 insertions(+), 50 deletions(-)
create mode 100644 examples/helia-browser-verified-fetch/src/Output.tsx
diff --git a/examples/helia-browser-verified-fetch/package.json b/examples/helia-browser-verified-fetch/package.json
index adce59db..078d6795 100644
--- a/examples/helia-browser-verified-fetch/package.json
+++ b/examples/helia-browser-verified-fetch/package.json
@@ -5,6 +5,7 @@
"type": "module",
"scripts": {
"clean": "rimraf ./dist",
+ "start": "vite",
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
diff --git a/examples/helia-browser-verified-fetch/src/App.tsx b/examples/helia-browser-verified-fetch/src/App.tsx
index ae88b16f..df90e67f 100644
--- a/examples/helia-browser-verified-fetch/src/App.tsx
+++ b/examples/helia-browser-verified-fetch/src/App.tsx
@@ -2,38 +2,8 @@ import { verifiedFetch } from '@helia/verified-fetch'
import { fileTypeFromBuffer } from '@sgtpooki/file-type'
import { useCallback, useState } from 'react'
import { helpText } from './constants'
+import { Loading, Output } from './Output'
-function renderOutput(output: string | JSX.Element, err: string): JSX.Element {
- if (err.length > 0) {
- return (
-
- )
- }
-
- if (typeof output === 'string') {
- return (
-
- {output.length > 0 && (
-
- {`${output}`}
-
- )}
-
- )
- }
-
- return output
-}
-
-function loadingIndicator(message: string): JSX.Element {
- return (
-
- )
-}
function App(): JSX.Element {
const [path, setPath] = useState
('')
@@ -54,7 +24,7 @@ function App(): JSX.Element {
}, [])
const setLoading = useCallback((message: string) => {
setErr('')
- setLoadingTo(loadingIndicator(message))
+ setLoadingTo()
}, [])
const handleImageType = useCallback(async (resp: Response) => {
@@ -90,23 +60,24 @@ function App(): JSX.Element {
}
}, [])
- const onFetchJson = useCallback(async () => {
+ const onFetchJson = useCallback(async (jsonType: `json` | `dag-json` = 'json') => {
try {
- if(controller) {
- console.log('aborting', controller)
- controller.abort() // abort any ongoing requests
- }
-
- setLoading('Fetching json response...')
+ controller?.abort() // abort any ongoing requests
+ setLoading(`Fetching ${jsonType} response...`)
const ctl = new AbortController()
setController(ctl)
- const resp = await verifiedFetch(path, { signal: ctl.signal })
+ const resp = await verifiedFetch(path, {
+ signal: ctl.signal,
+ headers: {
+ 'accept': jsonType === 'json' ? 'application/json' : 'application/vnd.ipld.dag-json',
+ }
+ })
await handleJsonType(resp)
} catch (err: any) {
+ // TODO: simplify AbortErr handling to use err.name once https://github.com/libp2p/js-libp2p/pull/2446 is merged
if(err?.code === 'ABORT_ERR') {
return
}
- // Don't render AbortErrors since they are user intiated
if(err instanceof Error) {
setError(err.message)
}
@@ -164,6 +135,11 @@ function App(): JSX.Element {
}
}, [controller])
+
+ const onPathChange = useCallback(async (e: React.ChangeEvent) => {
+ setPath(e.target.value)
+ }, [])
+
const onFetchAuto = useCallback(async () => {
if (path == null) {
setError('Invalid path')
@@ -171,11 +147,10 @@ function App(): JSX.Element {
}
try {
controller?.abort() // abort any ongoing requests
- setLoading('Fetching auto content...')
+ setLoading('Fetching with automatic content detection...')
const ctl = new AbortController()
setController(ctl)
const resp = await verifiedFetch(path, { signal: ctl.signal })
- console.log('onFetchAuto: got resp ', resp)
const buffer = await resp.clone().arrayBuffer()
let contentType = (await fileTypeFromBuffer(new Uint8Array(buffer)))?.mime
if (!contentType) {
@@ -183,7 +158,7 @@ function App(): JSX.Element {
// see if we can parse as json
await resp.clone().json()
contentType = 'application/json'
- } catch (err) {
+ } catch (err) {
// ignore
}
}
@@ -237,18 +212,23 @@ function App(): JSX.Element {
id="ipfs-path"
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="ipfs://... or ipns://"
- onChange={(e) => {
- setPath(e.target.value)
- }}
+ onChange={onPathChange}
value={path}
/>
+
{/* Left */}
{/* Right */}
- {renderOutput(loading ?? output, err)}
+