-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: use Helia's blockBroker interface #406
Changes from all commits
6f29b4d
73cfbe6
c2fa4ad
dd05dcd
57fe725
e18328b
3b5f578
5a035a1
d05498b
252c6fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,39 @@ const DagNodeIcon = ({ type, ...props }) => ( | |
</svg> | ||
) | ||
|
||
/** | ||
* replace bigint or other non-JSON-serializable values with appropriate values for the react-inspector | ||
* Note that data for some blocks (e.g. bafyreicnokmhmrnlp2wjhyk2haep4tqxiptwfrp2rrs7rzq7uk766chqvq) currently do not | ||
* look like NormalizedDagNode['data'] | ||
* | ||
* @param {import('../../types').NormalizedDagNode['data']} data | ||
*/ | ||
const getObjectInspectorData = (data) => { | ||
if (data == null) return data | ||
if (data.blockSizes != null) { | ||
data.blockSizes = data.blockSizes.map(Number) | ||
} | ||
return data | ||
} | ||
Comment on lines
+82
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed since the unixfs update uses bigint now. |
||
|
||
/** | ||
* @param {object} props | ||
* @param {import('react-i18next').TFunction} props.t | ||
* @param {boolean} props.tReady | ||
* @param {string} props.className | ||
* @param {string} props.type | ||
* @param {string} props.cid | ||
* @param {string} props.localPath | ||
* @param {bigint} props.size | ||
* @param {import('../../types').NormalizedDagNode['data']} props.data | ||
* @param {object[]} props.links | ||
* @param {string} props.format | ||
* @param {Function} props.onLinkClick | ||
* @param {string} props.gatewayUrl | ||
* @param {string} props.publicGatewayUrl | ||
*/ | ||
const ObjectInfo = ({ t, tReady, className, type, cid, localPath, size, data, links, format, onLinkClick, gatewayUrl, publicGatewayUrl, ...props }) => { | ||
Comment on lines
+97
to
113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some types |
||
if (!tReady) return null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is always true in testing, but may not always be in prod. |
||
const isUnixFs = format === 'unixfs' && data.type && ['directory', 'file'].some(x => x === data.type) | ||
let nodeStyleType = type | ||
|
||
|
@@ -130,7 +162,7 @@ const ObjectInfo = ({ t, tReady, className, type, cid, localPath, size, data, li | |
<div className='dt dt--fixed pt2'> | ||
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */} | ||
<label className='dtc silver tracked ttu f7' style={{ width: 48 }}>Size</label> | ||
<div className='dtc truncate charcoal monospace'>{humansize(size)}</div> | ||
<div className='dtc truncate charcoal monospace'>{humansize(Number(size))}</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bigint conversion |
||
</div> | ||
)} | ||
<div className='dt dt--fixed pt2'> | ||
|
@@ -151,7 +183,7 @@ const ObjectInfo = ({ t, tReady, className, type, cid, localPath, size, data, li | |
? null | ||
: ( | ||
<div className='pa3 mt2 bg-white f5 nl3 nr3 mh0-l'> | ||
<ObjectInspector showMaxKeys={100} data={data} theme={objectInspectorTheme} expandPaths={toExpandPathsNotation(localPath)} /> | ||
<ObjectInspector showMaxKeys={100} data={getObjectInspectorData(data)} theme={objectInspectorTheme} expandPaths={toExpandPathsNotation(localPath)} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bigint conversion |
||
</div> | ||
)} | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,16 @@ | |
*/ | ||
declare module 'stream-to-it' { | ||
interface toIterable { | ||
source: <T>(stream: ReadableStream<T>) => AsyncIterable<T> | ||
source<T>(stream: ReadableStream<T>): AsyncIterable<T> | ||
} | ||
const toIterable: toIterable | ||
export default toIterable | ||
} | ||
|
||
interface OldIpldFormat { | ||
util: { | ||
serialize: (obj: unknown) => Promise<Uint8Array> | ||
deserialize: (bytes: Uint8Array) => Promise<unknown> | ||
serialize(obj: unknown): Promise<Uint8Array> | ||
deserialize(bytes: Uint8Array): Promise<unknown> | ||
|
||
codec: number | ||
defaultHashAlg: number | ||
|
@@ -21,8 +21,8 @@ interface OldIpldFormat { | |
} | ||
codec: number | ||
resolver: { | ||
resolve: (bytes: Uint8Array, path: string) => Promise<unknown> | ||
tree: (bytes: Uint8Array) => Promise<unknown> | ||
resolve(bytes: Uint8Array, path: string): Promise<unknown> | ||
tree(bytes: Uint8Array): Promise<unknown> | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eslint-config-ipfs auto lint updates |
||
defaultHashAlg: number | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,12 @@ export default async function codecImporter<T extends CodecDataTypes = CodecData | |
case 'dag-cbor': | ||
return import('@ipld/dag-cbor') | ||
case 'dag-pb': | ||
// @ts-expect-error - return types need normalizing | ||
return import('@ipld/dag-pb') | ||
case 'git-raw': | ||
return { | ||
decode: (await import('ipld-git')).default.util.deserialize | ||
} | ||
case 'raw': | ||
// @ts-expect-error - return types need normalizing | ||
Comment on lines
-16
to
-23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yay, better types. |
||
return import('multiformats/codecs/raw') | ||
case 'json': | ||
return import('multiformats/codecs/json') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ import { ensureLeadingSlash } from './helpers' | |
import type { ResolveType } from '../types' | ||
|
||
interface CodecWrapper<DecodedType = any> { | ||
decode: (bytes: Uint8Array) => DecodedType | ||
resolve: (path: string, bytes: Uint8Array) => Promise<ResolveType<DecodedType>> | ||
decode(bytes: Uint8Array): DecodedType | ||
resolve(path: string, bytes: Uint8Array): Promise<ResolveType<DecodedType>> | ||
} | ||
Comment on lines
10
to
13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eslint-config-ipfs auto lint updates |
||
|
||
interface DecodeFn<T = any> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fixes an issue where doInitHelia was being called on every page load.