@@ -3,7 +3,7 @@ import { DAGBuilder, defaultDagBuilder } from './dag-builder/index.js'
33import { defaultTreeBuilder } from './tree-builder.js'
44import type { UnixFS , Mtime } from 'ipfs-unixfs'
55import type { CID , Version as CIDVersion } from 'multiformats/cid'
6- import type { Blockstore as InterfaceBlockstore } from 'interface-blockstore'
6+ import type { Blockstore } from 'interface-blockstore'
77import { ChunkValidator , defaultChunkValidator } from './dag-builder/validate-chunks.js'
88import { fixedSize } from './chunker/fixed-size.js'
99import type { Chunker } from './chunker/index.js'
@@ -17,7 +17,7 @@ import type { ProgressOptions } from 'progress-events'
1717export type ByteStream = AwaitIterable < Uint8Array >
1818export type ImportContent = ByteStream | Uint8Array
1919
20- export type Blockstore = Pick < InterfaceBlockstore , 'put' >
20+ export type WritableStorage = Pick < Blockstore , 'put' >
2121
2222export interface FileCandidate {
2323 path ?: string
@@ -73,8 +73,8 @@ export interface BufferImporterResult extends ImportResult {
7373}
7474
7575export interface HamtHashFn { ( value : Uint8Array ) : Promise < Uint8Array > }
76- export interface TreeBuilder { ( source : AsyncIterable < InProgressImportResult > , blockstore : Blockstore ) : AsyncIterable < ImportResult > }
77- export interface BufferImporter { ( file : File , blockstore : Blockstore ) : AsyncIterable < ( ) => Promise < BufferImporterResult > > }
76+ export interface TreeBuilder { ( source : AsyncIterable < InProgressImportResult > , blockstore : WritableStorage ) : AsyncIterable < ImportResult > }
77+ export interface BufferImporter { ( file : File , blockstore : WritableStorage ) : AsyncIterable < ( ) => Promise < BufferImporterResult > > }
7878
7979export type ImportProgressEvents =
8080 BufferImportProgressEvents
@@ -227,7 +227,7 @@ export type ImportCandidateStream = AsyncIterable<FileCandidate | DirectoryCandi
227227 * }
228228 * ```
229229 */
230- export async function * importer ( source : ImportCandidateStream , blockstore : Blockstore , options : ImporterOptions = { } ) : AsyncGenerator < ImportResult , void , unknown > {
230+ export async function * importer ( source : ImportCandidateStream , blockstore : WritableStorage , options : ImporterOptions = { } ) : AsyncGenerator < ImportResult , void , unknown > {
231231 let candidates : AsyncIterable < FileCandidate | DirectoryCandidate > | Iterable < FileCandidate | DirectoryCandidate >
232232
233233 if ( Symbol . asyncIterator in source || Symbol . iterator in source ) {
@@ -302,7 +302,7 @@ export async function * importer (source: ImportCandidateStream, blockstore: Blo
302302 * const entry = await importFile(input, blockstore)
303303 * ```
304304 */
305- export async function importFile ( content : FileCandidate , blockstore : Blockstore , options : ImporterOptions = { } ) : Promise < ImportResult > {
305+ export async function importFile ( content : FileCandidate , blockstore : WritableStorage , options : ImporterOptions = { } ) : Promise < ImportResult > {
306306 const result = await first ( importer ( [ content ] , blockstore , options ) )
307307
308308 if ( result == null ) {
@@ -333,7 +333,7 @@ export async function importFile (content: FileCandidate, blockstore: Blockstore
333333 * const entry = await importDirectory(input, blockstore)
334334 * ```
335335 */
336- export async function importDirectory ( content : DirectoryCandidate , blockstore : Blockstore , options : ImporterOptions = { } ) : Promise < ImportResult > {
336+ export async function importDirectory ( content : DirectoryCandidate , blockstore : WritableStorage , options : ImporterOptions = { } ) : Promise < ImportResult > {
337337 const result = await first ( importer ( [ content ] , blockstore , options ) )
338338
339339 if ( result == null ) {
@@ -361,7 +361,7 @@ export async function importDirectory (content: DirectoryCandidate, blockstore:
361361 * const entry = await importBytes(input, blockstore)
362362 * ```
363363 */
364- export async function importBytes ( buf : ImportContent , blockstore : Blockstore , options : ImporterOptions = { } ) : Promise < ImportResult > {
364+ export async function importBytes ( buf : ImportContent , blockstore : WritableStorage , options : ImporterOptions = { } ) : Promise < ImportResult > {
365365 return await importFile ( {
366366 content : buf
367367 } , blockstore , options )
@@ -388,7 +388,7 @@ export async function importBytes (buf: ImportContent, blockstore: Blockstore, o
388388 * const entry = await importByteStream(input, blockstore)
389389 * ```
390390 */
391- export async function importByteStream ( bufs : ByteStream , blockstore : Blockstore , options : ImporterOptions = { } ) : Promise < ImportResult > {
391+ export async function importByteStream ( bufs : ByteStream , blockstore : WritableStorage , options : ImporterOptions = { } ) : Promise < ImportResult > {
392392 return await importFile ( {
393393 content : bufs
394394 } , blockstore , options )
0 commit comments