@fireproof/vendor 1.0.4 → 1.1.0-dev
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 +4 -97
- package/src/@web3-storage/pail/dist/src/batch/index.d.ts +1 -53
- package/src/@web3-storage/pail/dist/src/batch/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/batch/shard.d.ts +1 -1
- package/src/@web3-storage/pail/dist/src/batch/shard.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/block.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/block.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/clock/index.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/clock/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/crdt/batch/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/crdt/index.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/crdt/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/diff.d.ts +3 -3
- package/src/@web3-storage/pail/dist/src/diff.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/index.d.ts +1 -1
- package/src/@web3-storage/pail/dist/src/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/merge.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/shard.d.ts +4 -4
- package/src/@web3-storage/pail/dist/src/shard.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/tsconfig.tsbuildinfo +1 -1
- package/src/@web3-storage/pail/src/api.ts +1 -1
- package/src/@web3-storage/pail/src/clock/index.js +1 -1
- package/src/@web3-storage/pail/src/shard.js +1 -1
- package/src/@ipld/car/LICENSE +0 -4
- package/src/@ipld/car/README.md +0 -1132
- package/src/@ipld/car/dist/index.min.js +0 -5
- package/src/@ipld/car/dist/src/api.d.ts +0 -72
- package/src/@ipld/car/dist/src/api.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-decoder.d.ts +0 -67
- package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +0 -116
- package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-reader.d.ts +0 -31
- package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-writer.d.ts +0 -86
- package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/coding.d.ts +0 -49
- package/src/@ipld/car/dist/src/coding.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/decoder-common.d.ts +0 -43
- package/src/@ipld/car/dist/src/decoder-common.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/decoder.d.ts +0 -87
- package/src/@ipld/car/dist/src/decoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/encoder.d.ts +0 -17
- package/src/@ipld/car/dist/src/encoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/header-validator.d.ts +0 -5
- package/src/@ipld/car/dist/src/header-validator.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/index-browser.d.ts +0 -10
- package/src/@ipld/car/dist/src/index-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/index.d.ts +0 -11
- package/src/@ipld/car/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +0 -5
- package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexed-reader.d.ts +0 -152
- package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexer.d.ts +0 -95
- package/src/@ipld/car/dist/src/indexer.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/iterator-channel.d.ts +0 -7
- package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/iterator.d.ts +0 -174
- package/src/@ipld/car/dist/src/iterator.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/promise-fs-opts.d.ts +0 -30
- package/src/@ipld/car/dist/src/promise-fs-opts.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/reader-browser.d.ts +0 -151
- package/src/@ipld/car/dist/src/reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/reader.d.ts +0 -39
- package/src/@ipld/car/dist/src/reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/writer-browser.d.ts +0 -155
- package/src/@ipld/car/dist/src/writer-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/writer.d.ts +0 -44
- package/src/@ipld/car/dist/src/writer.d.ts.map +0 -1
- package/src/@ipld/car/src/api.ts +0 -90
- package/src/@ipld/car/src/buffer-decoder.js +0 -213
- package/src/@ipld/car/src/buffer-reader-browser.js +0 -144
- package/src/@ipld/car/src/buffer-reader.js +0 -51
- package/src/@ipld/car/src/buffer-writer.js +0 -286
- package/src/@ipld/car/src/coding.ts +0 -68
- package/src/@ipld/car/src/decoder-common.js +0 -82
- package/src/@ipld/car/src/decoder.js +0 -347
- package/src/@ipld/car/src/encoder.js +0 -76
- package/src/@ipld/car/src/header-validator.js +0 -214
- package/src/@ipld/car/src/header.ipldsch +0 -18
- package/src/@ipld/car/src/index-browser.js +0 -18
- package/src/@ipld/car/src/index.js +0 -21
- package/src/@ipld/car/src/indexed-reader-browser.js +0 -7
- package/src/@ipld/car/src/indexed-reader.js +0 -211
- package/src/@ipld/car/src/indexer.js +0 -130
- package/src/@ipld/car/src/iterator-channel.js +0 -91
- package/src/@ipld/car/src/iterator.js +0 -267
- package/src/@ipld/car/src/promise-fs-opts.js +0 -42
- package/src/@ipld/car/src/reader-browser.js +0 -194
- package/src/@ipld/car/src/reader.js +0 -53
- package/src/@ipld/car/src/writer-browser.js +0 -250
- package/src/@ipld/car/src/writer.js +0 -80
- package/src/@ipld/dag-cbor/LICENSE +0 -4
- package/src/@ipld/dag-cbor/README.md +0 -80
- package/src/@ipld/dag-cbor/dist/index.min.js +0 -3
- package/src/@ipld/dag-cbor/dist/src/index.d.ts +0 -67
- package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-cbor/src/index.js +0 -147
- package/src/@ipld/dag-json/LICENSE +0 -4
- package/src/@ipld/dag-json/README.md +0 -58
- package/src/@ipld/dag-json/dist/index.min.js +0 -3
- package/src/@ipld/dag-json/dist/src/index.d.ts +0 -12
- package/src/@ipld/dag-json/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-json/src/index.js +0 -291
- package/src/cborg/.github/dependabot.yml +0 -16
- package/src/cborg/.github/workflows/test-and-release.yml +0 -52
- package/src/cborg/CHANGELOG.md +0 -513
- package/src/cborg/LICENSE +0 -13
- package/src/cborg/README.md +0 -515
- package/src/cborg/bench/bench.js +0 -117
- package/src/cborg/bench/json.js +0 -124
- package/src/cborg/bench/package.json +0 -8
- package/src/cborg/cborg/bin.js +0 -189
- package/src/cborg/cborg/common.js +0 -28
- package/src/cborg/cborg/decode.js +0 -211
- package/src/cborg/cborg/diagnostic.js +0 -158
- package/src/cborg/cborg/diagnostic_test.js +0 -117
- package/src/cborg/cborg/encode.js +0 -466
- package/src/cborg/cborg/index.js +0 -33
- package/src/cborg/cborg/is.js +0 -106
- package/src/cborg/cborg/length.js +0 -62
- package/src/cborg/example-bytestrings.js +0 -180
- package/src/cborg/example-json.js +0 -6
- package/src/cborg/example.js +0 -5
- package/src/cborg/interface.ts +0 -59
- package/src/cborg/json/decode.js +0 -462
- package/src/cborg/json/encode.js +0 -302
- package/src/cborg/json/json.js +0 -4
- package/src/cborg/taglib.js +0 -75
- package/src/cborg/test/appendix_a.js +0 -647
- package/src/cborg/test/common.js +0 -18
- package/src/cborg/test/node-test-bin.js +0 -402
- package/src/cborg/test/noop-bin-test.js +0 -3
- package/src/cborg/test/test-0uint.js +0 -103
- package/src/cborg/test/test-1negint.js +0 -96
- package/src/cborg/test/test-2bytes.js +0 -198
- package/src/cborg/test/test-3string.js +0 -136
- package/src/cborg/test/test-4array.js +0 -93
- package/src/cborg/test/test-5map.js +0 -284
- package/src/cborg/test/test-6tag.js +0 -84
- package/src/cborg/test/test-7float.js +0 -131
- package/src/cborg/test/test-bl.js +0 -37
- package/src/cborg/test/test-cbor-vectors.js +0 -107
- package/src/cborg/test/test-decode-errors.js +0 -65
- package/src/cborg/test/test-fuzz.js +0 -42
- package/src/cborg/test/test-json.js +0 -219
- package/src/cborg/test/test-length.js +0 -65
- package/src/cborg/test/test-partial.js +0 -111
- package/src/cborg/tsconfig.json +0 -48
- package/src/cborg/types/cborg/decode.d.ts +0 -43
- package/src/cborg/types/cborg/decode.d.ts.map +0 -1
- package/src/cborg/types/cborg/encode.d.ts +0 -51
- package/src/cborg/types/cborg/encode.d.ts.map +0 -1
- package/src/cborg/types/cborg/index.d.ts +0 -26
- package/src/cborg/types/cborg/index.d.ts.map +0 -1
- package/src/cborg/types/cborg/is.d.ts +0 -6
- package/src/cborg/types/cborg/is.d.ts.map +0 -1
- package/src/cborg/types/example.d.ts +0 -2
- package/src/cborg/types/example.d.ts.map +0 -1
- package/src/cborg/types/interface.d.ts +0 -49
- package/src/cborg/types/interface.d.ts.map +0 -1
- package/src/cborg/types/json/decode.d.ts +0 -67
- package/src/cborg/types/json/decode.d.ts.map +0 -1
- package/src/cborg/types/json/encode.d.ts +0 -11
- package/src/cborg/types/json/encode.d.ts.map +0 -1
- package/src/cborg/types/json/json.d.ts +0 -6
- package/src/cborg/types/json/json.d.ts.map +0 -1
- package/src/cborg/types/taglib.d.ts +0 -18
- package/src/cborg/types/taglib.d.ts.map +0 -1
- package/src/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/cborg/types/utils/0uint.d.ts +0 -102
- package/src/cborg/types/utils/0uint.d.ts.map +0 -1
- package/src/cborg/types/utils/1negint.d.ts +0 -59
- package/src/cborg/types/utils/1negint.d.ts.map +0 -1
- package/src/cborg/types/utils/2bytes.d.ts +0 -69
- package/src/cborg/types/utils/2bytes.d.ts.map +0 -1
- package/src/cborg/types/utils/3string.d.ts +0 -46
- package/src/cborg/types/utils/3string.d.ts.map +0 -1
- package/src/cborg/types/utils/4array.d.ts +0 -66
- package/src/cborg/types/utils/4array.d.ts.map +0 -1
- package/src/cborg/types/utils/5map.d.ts +0 -66
- package/src/cborg/types/utils/5map.d.ts.map +0 -1
- package/src/cborg/types/utils/6tag.d.ts +0 -62
- package/src/cborg/types/utils/6tag.d.ts.map +0 -1
- package/src/cborg/types/utils/7float.d.ts +0 -60
- package/src/cborg/types/utils/7float.d.ts.map +0 -1
- package/src/cborg/types/utils/bl.d.ts +0 -26
- package/src/cborg/types/utils/bl.d.ts.map +0 -1
- package/src/cborg/types/utils/byte-utils.d.ts +0 -53
- package/src/cborg/types/utils/byte-utils.d.ts.map +0 -1
- package/src/cborg/types/utils/common.d.ts +0 -8
- package/src/cborg/types/utils/common.d.ts.map +0 -1
- package/src/cborg/types/utils/index.d.ts +0 -13
- package/src/cborg/types/utils/index.d.ts.map +0 -1
- package/src/cborg/types/utils/jump.d.ts +0 -16
- package/src/cborg/types/utils/jump.d.ts.map +0 -1
- package/src/cborg/types/utils/token.d.ts +0 -59
- package/src/cborg/types/utils/token.d.ts.map +0 -1
- package/src/cborg/utils/0uint.js +0 -229
- package/src/cborg/utils/1negint.js +0 -111
- package/src/cborg/utils/2bytes.js +0 -135
- package/src/cborg/utils/3string.js +0 -90
- package/src/cborg/utils/4array.js +0 -114
- package/src/cborg/utils/5map.js +0 -113
- package/src/cborg/utils/6tag.js +0 -81
- package/src/cborg/utils/7float.js +0 -310
- package/src/cborg/utils/bl.js +0 -124
- package/src/cborg/utils/byte-utils.js +0 -417
- package/src/cborg/utils/common.js +0 -11
- package/src/cborg/utils/index.js +0 -12
- package/src/cborg/utils/jump.js +0 -222
- package/src/cborg/utils/token.js +0 -76
- package/src/ipfs-unixfs-exporter/LICENSE +0 -4
- package/src/ipfs-unixfs-exporter/README.md +0 -105
- package/src/ipfs-unixfs-exporter/dist/index.min.js +0 -3
- package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
- package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
- package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
- package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/index.js +0 -197
- package/src/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
- package/src/ipfs-unixfs-exporter/src/errors.ts +0 -87
- package/src/ipfs-unixfs-exporter/src/index.ts +0 -498
- package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
- package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
- package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
- package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
- package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
- package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
- package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
*
|
|
4
|
-
* The UnixFS Exporter provides a means to read DAGs from a blockstore given a CID.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
*
|
|
8
|
-
* ```js
|
|
9
|
-
* // import a file and export it again
|
|
10
|
-
* import { importer } from 'ipfs-unixfs-importer'
|
|
11
|
-
* import { exporter } from 'ipfs-unixfs-exporter'
|
|
12
|
-
* import { MemoryBlockstore } from 'blockstore-core/memory'
|
|
13
|
-
*
|
|
14
|
-
* // Should contain the blocks we are trying to export
|
|
15
|
-
* const blockstore = new MemoryBlockstore()
|
|
16
|
-
* const files = []
|
|
17
|
-
*
|
|
18
|
-
* for await (const file of importer([{
|
|
19
|
-
* path: '/foo/bar.txt',
|
|
20
|
-
* content: new Uint8Array([0, 1, 2, 3])
|
|
21
|
-
* }], blockstore)) {
|
|
22
|
-
* files.push(file)
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* console.info(files[0].cid) // Qmbaz
|
|
26
|
-
*
|
|
27
|
-
* const entry = await exporter(files[0].cid, blockstore)
|
|
28
|
-
*
|
|
29
|
-
* console.info(entry.cid) // Qmqux
|
|
30
|
-
* console.info(entry.path) // Qmbaz/foo/bar.txt
|
|
31
|
-
* console.info(entry.name) // bar.txt
|
|
32
|
-
* console.info(entry.unixfs.fileSize()) // 4
|
|
33
|
-
*
|
|
34
|
-
* // stream content from unixfs node
|
|
35
|
-
* const size = entry.unixfs.fileSize()
|
|
36
|
-
* const bytes = new Uint8Array(size)
|
|
37
|
-
* let offset = 0
|
|
38
|
-
*
|
|
39
|
-
* for await (const buf of entry.content()) {
|
|
40
|
-
* bytes.set(buf, offset)
|
|
41
|
-
* offset += chunk.length
|
|
42
|
-
* }
|
|
43
|
-
*
|
|
44
|
-
* console.info(bytes) // 0, 1, 2, 3
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
import { CID } from 'multiformats/cid';
|
|
48
|
-
import type { PBNode } from '@ipld/dag-pb';
|
|
49
|
-
import type { Bucket } from 'hamt-sharding';
|
|
50
|
-
import type { Blockstore } from 'interface-blockstore';
|
|
51
|
-
import type { UnixFS } from 'ipfs-unixfs';
|
|
52
|
-
import type { ProgressOptions, ProgressEvent } from 'progress-events';
|
|
53
|
-
export * from './errors.js';
|
|
54
|
-
export interface ExportProgress {
|
|
55
|
-
/**
|
|
56
|
-
* How many bytes of the file have been read
|
|
57
|
-
*/
|
|
58
|
-
bytesRead: bigint;
|
|
59
|
-
/**
|
|
60
|
-
* How many bytes of the file will be read - n.b. this may be
|
|
61
|
-
* smaller than `fileSize` if `offset`/`length` have been
|
|
62
|
-
* specified
|
|
63
|
-
*/
|
|
64
|
-
totalBytes: bigint;
|
|
65
|
-
/**
|
|
66
|
-
* The size of the file being read - n.b. this may be
|
|
67
|
-
* larger than `total` if `offset`/`length` has been
|
|
68
|
-
* specified
|
|
69
|
-
*/
|
|
70
|
-
fileSize: bigint;
|
|
71
|
-
}
|
|
72
|
-
export interface ExportWalk {
|
|
73
|
-
cid: CID;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Progress events emitted by the exporter
|
|
77
|
-
*/
|
|
78
|
-
export type ExporterProgressEvents = ProgressEvent<'unixfs:exporter:progress:unixfs:file', ExportProgress> | ProgressEvent<'unixfs:exporter:progress:unixfs:raw', ExportProgress> | ProgressEvent<'unixfs:exporter:progress:raw', ExportProgress> | ProgressEvent<'unixfs:exporter:progress:identity', ExportProgress> | ProgressEvent<'unixfs:exporter:walk:file', ExportWalk> | ProgressEvent<'unixfs:exporter:walk:directory', ExportWalk> | ProgressEvent<'unixfs:exporter:walk:hamt-sharded-directory', ExportWalk> | ProgressEvent<'unixfs:exporter:walk:raw', ExportWalk>;
|
|
79
|
-
export interface ExporterOptions extends ProgressOptions<ExporterProgressEvents> {
|
|
80
|
-
/**
|
|
81
|
-
* An optional offset to start reading at.
|
|
82
|
-
*
|
|
83
|
-
* If the CID resolves to a file this will be a byte offset within that file,
|
|
84
|
-
* otherwise if it's a directory it will be a directory entry offset within
|
|
85
|
-
* the directory listing. (default: undefined)
|
|
86
|
-
*/
|
|
87
|
-
offset?: number;
|
|
88
|
-
/**
|
|
89
|
-
* An optional length to read.
|
|
90
|
-
*
|
|
91
|
-
* If the CID resolves to a file this will be the number of bytes read from
|
|
92
|
-
* the file, otherwise if it's a directory it will be the number of directory
|
|
93
|
-
* entries read from the directory listing. (default: undefined)
|
|
94
|
-
*/
|
|
95
|
-
length?: number;
|
|
96
|
-
/**
|
|
97
|
-
* This signal can be used to abort any long-lived operations such as fetching
|
|
98
|
-
* blocks from the network. (default: undefined)
|
|
99
|
-
*/
|
|
100
|
-
signal?: AbortSignal;
|
|
101
|
-
/**
|
|
102
|
-
* When a DAG layer is encountered, all child nodes are loaded in parallel but
|
|
103
|
-
* processed as they arrive. This allows us to load sibling nodes in advance
|
|
104
|
-
* of yielding their bytes. Pass a value here to control the number of blocks
|
|
105
|
-
* loaded in parallel. If a strict depth-first traversal is required, this
|
|
106
|
-
* value should be set to `1`, otherwise the traversal order will tend to
|
|
107
|
-
* resemble a breadth-first fan-out and yield a have stable ordering.
|
|
108
|
-
* (default: undefined)
|
|
109
|
-
*/
|
|
110
|
-
blockReadConcurrency?: number;
|
|
111
|
-
}
|
|
112
|
-
export interface Exportable<T> {
|
|
113
|
-
/**
|
|
114
|
-
* A disambiguator to allow TypeScript to work out the type of the entry.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
*
|
|
118
|
-
* ```TypeScript
|
|
119
|
-
* if (entry.type === 'file') {
|
|
120
|
-
* // access UnixFSFile properties safely
|
|
121
|
-
* }
|
|
122
|
-
*
|
|
123
|
-
* if (entry.type === 'directory') {
|
|
124
|
-
* // access UnixFSDirectory properties safely
|
|
125
|
-
* }
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
type: 'file' | 'directory' | 'object' | 'raw' | 'identity';
|
|
129
|
-
/**
|
|
130
|
-
* The name of the entry
|
|
131
|
-
*/
|
|
132
|
-
name: string;
|
|
133
|
-
/**
|
|
134
|
-
* The path of the entry within the DAG in which it was encountered
|
|
135
|
-
*/
|
|
136
|
-
path: string;
|
|
137
|
-
/**
|
|
138
|
-
* The CID of the entry
|
|
139
|
-
*/
|
|
140
|
-
cid: CID;
|
|
141
|
-
/**
|
|
142
|
-
* How far down the DAG the entry is
|
|
143
|
-
*/
|
|
144
|
-
depth: number;
|
|
145
|
-
/**
|
|
146
|
-
* The size of the entry
|
|
147
|
-
*/
|
|
148
|
-
size: bigint;
|
|
149
|
-
/**
|
|
150
|
-
* @example File content
|
|
151
|
-
*
|
|
152
|
-
* When `entry` is a file or a `raw` node, `offset` and/or `length` arguments can be passed to `entry.content()` to return slices of data:
|
|
153
|
-
*
|
|
154
|
-
* ```javascript
|
|
155
|
-
* const length = 5
|
|
156
|
-
* const data = new Uint8Array(length)
|
|
157
|
-
* let offset = 0
|
|
158
|
-
*
|
|
159
|
-
* for await (const chunk of entry.content({
|
|
160
|
-
* offset: 0,
|
|
161
|
-
* length
|
|
162
|
-
* })) {
|
|
163
|
-
* data.set(chunk, offset)
|
|
164
|
-
* offset += chunk.length
|
|
165
|
-
* }
|
|
166
|
-
*
|
|
167
|
-
* // `data` contains the first 5 bytes of the file
|
|
168
|
-
* return data
|
|
169
|
-
* ```
|
|
170
|
-
*
|
|
171
|
-
* @example Directory content
|
|
172
|
-
*
|
|
173
|
-
* If `entry` is a directory, passing `offset` and/or `length` to `entry.content()` will limit the number of files returned from the directory.
|
|
174
|
-
*
|
|
175
|
-
* ```javascript
|
|
176
|
-
* const entries = []
|
|
177
|
-
*
|
|
178
|
-
* for await (const entry of dir.content({
|
|
179
|
-
* offset: 0,
|
|
180
|
-
* length: 5
|
|
181
|
-
* })) {
|
|
182
|
-
* entries.push(entry)
|
|
183
|
-
* }
|
|
184
|
-
*
|
|
185
|
-
* // `entries` contains the first 5 files/directories in the directory
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
content(options?: ExporterOptions): AsyncGenerator<T, void, unknown>;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* If the entry is a file, `entry.content()` returns an async iterator that yields one or more Uint8Arrays containing the file content:
|
|
192
|
-
*
|
|
193
|
-
* ```javascript
|
|
194
|
-
* if (entry.type === 'file') {
|
|
195
|
-
* for await (const chunk of entry.content()) {
|
|
196
|
-
* // chunk is a Buffer
|
|
197
|
-
* }
|
|
198
|
-
* }
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
export interface UnixFSFile extends Exportable<Uint8Array> {
|
|
202
|
-
type: 'file';
|
|
203
|
-
unixfs: UnixFS;
|
|
204
|
-
node: PBNode;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* If the entry is a directory, `entry.content()` returns further `entry` objects:
|
|
208
|
-
*
|
|
209
|
-
* ```javascript
|
|
210
|
-
* if (entry.type === 'directory') {
|
|
211
|
-
* for await (const entry of dir.content()) {
|
|
212
|
-
* console.info(entry.name)
|
|
213
|
-
* }
|
|
214
|
-
* }
|
|
215
|
-
* ```
|
|
216
|
-
*/
|
|
217
|
-
export interface UnixFSDirectory extends Exportable<UnixFSEntry> {
|
|
218
|
-
type: 'directory';
|
|
219
|
-
unixfs: UnixFS;
|
|
220
|
-
node: PBNode;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Entries with a `dag-cbor` or `dag-json` codec {@link CID} return JavaScript object entries
|
|
224
|
-
*/
|
|
225
|
-
export interface ObjectNode extends Exportable<any> {
|
|
226
|
-
type: 'object';
|
|
227
|
-
node: Uint8Array;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Entries with a `raw` codec {@link CID} return raw entries.
|
|
231
|
-
*
|
|
232
|
-
* `entry.content()` returns an async iterator that yields a buffer containing the node content:
|
|
233
|
-
*
|
|
234
|
-
* ```javascript
|
|
235
|
-
* for await (const chunk of entry.content()) {
|
|
236
|
-
* // chunk is a Buffer
|
|
237
|
-
* }
|
|
238
|
-
* ```
|
|
239
|
-
*
|
|
240
|
-
* Unless you an options object containing `offset` and `length` keys as an argument to `entry.content()`, `chunk` will be equal to `entry.node`.
|
|
241
|
-
*/
|
|
242
|
-
export interface RawNode extends Exportable<Uint8Array> {
|
|
243
|
-
type: 'raw';
|
|
244
|
-
node: Uint8Array;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Entries with a `identity` codec {@link CID} return identity entries.
|
|
248
|
-
*
|
|
249
|
-
* These are entries where the data payload is stored in the CID itself,
|
|
250
|
-
* otherwise they are identical to {@link RawNode}s.
|
|
251
|
-
*/
|
|
252
|
-
export interface IdentityNode extends Exportable<Uint8Array> {
|
|
253
|
-
type: 'identity';
|
|
254
|
-
node: Uint8Array;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* A UnixFSEntry is a representation of the types of node that can be
|
|
258
|
-
* encountered in a DAG.
|
|
259
|
-
*/
|
|
260
|
-
export type UnixFSEntry = UnixFSFile | UnixFSDirectory | ObjectNode | RawNode | IdentityNode;
|
|
261
|
-
export interface NextResult {
|
|
262
|
-
cid: CID;
|
|
263
|
-
name: string;
|
|
264
|
-
path: string;
|
|
265
|
-
toResolve: string[];
|
|
266
|
-
}
|
|
267
|
-
export interface ResolveResult {
|
|
268
|
-
entry: UnixFSEntry;
|
|
269
|
-
next?: NextResult;
|
|
270
|
-
}
|
|
271
|
-
export interface Resolve {
|
|
272
|
-
(cid: CID, name: string, path: string, toResolve: string[], depth: number, blockstore: ReadableStorage, options: ExporterOptions): Promise<ResolveResult>;
|
|
273
|
-
}
|
|
274
|
-
export interface Resolver {
|
|
275
|
-
(cid: CID, name: string, path: string, toResolve: string[], resolve: Resolve, depth: number, blockstore: ReadableStorage, options: ExporterOptions): Promise<ResolveResult>;
|
|
276
|
-
}
|
|
277
|
-
export type UnixfsV1FileContent = AsyncIterable<Uint8Array> | Iterable<Uint8Array>;
|
|
278
|
-
export type UnixfsV1DirectoryContent = AsyncIterable<UnixFSEntry> | Iterable<UnixFSEntry>;
|
|
279
|
-
export type UnixfsV1Content = UnixfsV1FileContent | UnixfsV1DirectoryContent;
|
|
280
|
-
export interface UnixfsV1Resolver {
|
|
281
|
-
(cid: CID, node: PBNode, unixfs: UnixFS, path: string, resolve: Resolve, depth: number, blockstore: ReadableStorage): (options: ExporterOptions) => UnixfsV1Content;
|
|
282
|
-
}
|
|
283
|
-
export interface ShardTraversalContext {
|
|
284
|
-
hamtDepth: number;
|
|
285
|
-
rootBucket: Bucket<boolean>;
|
|
286
|
-
lastBucket: Bucket<boolean>;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* A subset of the {@link Blockstore} interface that just contains the get
|
|
290
|
-
* method.
|
|
291
|
-
*/
|
|
292
|
-
export type ReadableStorage = Pick<Blockstore, 'get'>;
|
|
293
|
-
/**
|
|
294
|
-
* Returns an async iterator that yields entries for all segments in a path
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
*
|
|
298
|
-
* ```javascript
|
|
299
|
-
* import { walkPath } from 'ipfs-unixfs-exporter'
|
|
300
|
-
*
|
|
301
|
-
* const entries = []
|
|
302
|
-
*
|
|
303
|
-
* for await (const entry of walkPath('Qmfoo/foo/bar/baz.txt', blockstore)) {
|
|
304
|
-
* entries.push(entry)
|
|
305
|
-
* }
|
|
306
|
-
*
|
|
307
|
-
* // entries contains 4x `entry` objects
|
|
308
|
-
* ```
|
|
309
|
-
*/
|
|
310
|
-
export declare function walkPath(path: string | CID, blockstore: ReadableStorage, options?: ExporterOptions): AsyncGenerator<UnixFSEntry, void, any>;
|
|
311
|
-
/**
|
|
312
|
-
* Uses the given blockstore instance to fetch an IPFS node by a CID or path.
|
|
313
|
-
*
|
|
314
|
-
* Returns a {@link Promise} which resolves to a {@link UnixFSEntry}.
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
*
|
|
318
|
-
* ```typescript
|
|
319
|
-
* import { exporter } from 'ipfs-unixfs-exporter'
|
|
320
|
-
* import { CID } from 'multiformats/cid'
|
|
321
|
-
*
|
|
322
|
-
* const cid = CID.parse('QmFoo')
|
|
323
|
-
*
|
|
324
|
-
* const entry = await exporter(cid, blockstore, {
|
|
325
|
-
* signal: AbortSignal.timeout(50000)
|
|
326
|
-
* })
|
|
327
|
-
*
|
|
328
|
-
* if (entry.type === 'file') {
|
|
329
|
-
* for await (const chunk of entry.content()) {
|
|
330
|
-
* // chunk is a Uint8Array
|
|
331
|
-
* }
|
|
332
|
-
* }
|
|
333
|
-
* ```
|
|
334
|
-
*/
|
|
335
|
-
export declare function exporter(path: string | CID, blockstore: ReadableStorage, options?: ExporterOptions): Promise<UnixFSEntry>;
|
|
336
|
-
/**
|
|
337
|
-
* Returns an async iterator that yields all entries beneath a given CID or IPFS
|
|
338
|
-
* path, as well as the containing directory.
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
*
|
|
342
|
-
* ```typescript
|
|
343
|
-
* import { recursive } from 'ipfs-unixfs-exporter'
|
|
344
|
-
*
|
|
345
|
-
* const entries = []
|
|
346
|
-
*
|
|
347
|
-
* for await (const child of recursive('Qmfoo/foo/bar', blockstore)) {
|
|
348
|
-
* entries.push(entry)
|
|
349
|
-
* }
|
|
350
|
-
*
|
|
351
|
-
* // entries contains all children of the `Qmfoo/foo/bar` directory and it's children
|
|
352
|
-
* ```
|
|
353
|
-
*/
|
|
354
|
-
export declare function recursive(path: string | CID, blockstore: ReadableStorage, options?: ExporterOptions): AsyncGenerator<UnixFSEntry, void, any>;
|
|
355
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA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3B,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;CAC5B;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;AA0CrD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAwB,QAAQ,CAAE,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,GAAE,eAAoB,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,CA8BxJ;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,QAAQ,CAAE,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAQpI;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAwB,SAAS,CAAE,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,GAAE,eAAoB,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,CA4BzJ"}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
*
|
|
4
|
-
* The UnixFS Exporter provides a means to read DAGs from a blockstore given a CID.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
*
|
|
8
|
-
* ```js
|
|
9
|
-
* // import a file and export it again
|
|
10
|
-
* import { importer } from 'ipfs-unixfs-importer'
|
|
11
|
-
* import { exporter } from 'ipfs-unixfs-exporter'
|
|
12
|
-
* import { MemoryBlockstore } from 'blockstore-core/memory'
|
|
13
|
-
*
|
|
14
|
-
* // Should contain the blocks we are trying to export
|
|
15
|
-
* const blockstore = new MemoryBlockstore()
|
|
16
|
-
* const files = []
|
|
17
|
-
*
|
|
18
|
-
* for await (const file of importer([{
|
|
19
|
-
* path: '/foo/bar.txt',
|
|
20
|
-
* content: new Uint8Array([0, 1, 2, 3])
|
|
21
|
-
* }], blockstore)) {
|
|
22
|
-
* files.push(file)
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* console.info(files[0].cid) // Qmbaz
|
|
26
|
-
*
|
|
27
|
-
* const entry = await exporter(files[0].cid, blockstore)
|
|
28
|
-
*
|
|
29
|
-
* console.info(entry.cid) // Qmqux
|
|
30
|
-
* console.info(entry.path) // Qmbaz/foo/bar.txt
|
|
31
|
-
* console.info(entry.name) // bar.txt
|
|
32
|
-
* console.info(entry.unixfs.fileSize()) // 4
|
|
33
|
-
*
|
|
34
|
-
* // stream content from unixfs node
|
|
35
|
-
* const size = entry.unixfs.fileSize()
|
|
36
|
-
* const bytes = new Uint8Array(size)
|
|
37
|
-
* let offset = 0
|
|
38
|
-
*
|
|
39
|
-
* for await (const buf of entry.content()) {
|
|
40
|
-
* bytes.set(buf, offset)
|
|
41
|
-
* offset += chunk.length
|
|
42
|
-
* }
|
|
43
|
-
*
|
|
44
|
-
* console.info(bytes) // 0, 1, 2, 3
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
import last from 'it-last';
|
|
48
|
-
import { CID } from 'multiformats/cid';
|
|
49
|
-
import { BadPathError, NotFoundError } from './errors.js';
|
|
50
|
-
import resolve from './resolvers/index.js';
|
|
51
|
-
export * from './errors.js';
|
|
52
|
-
const toPathComponents = (path = '') => {
|
|
53
|
-
// split on / unless escaped with \
|
|
54
|
-
return (path
|
|
55
|
-
.trim()
|
|
56
|
-
.match(/([^\\^/]|\\\/)+/g) ?? [])
|
|
57
|
-
.filter(Boolean);
|
|
58
|
-
};
|
|
59
|
-
const cidAndRest = (path) => {
|
|
60
|
-
if (path instanceof Uint8Array) {
|
|
61
|
-
return {
|
|
62
|
-
cid: CID.decode(path),
|
|
63
|
-
toResolve: []
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
const cid = CID.asCID(path);
|
|
67
|
-
if (cid != null) {
|
|
68
|
-
return {
|
|
69
|
-
cid,
|
|
70
|
-
toResolve: []
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
if (typeof path === 'string') {
|
|
74
|
-
if (path.indexOf('/ipfs/') === 0) {
|
|
75
|
-
path = path.substring(6);
|
|
76
|
-
}
|
|
77
|
-
const output = toPathComponents(path);
|
|
78
|
-
return {
|
|
79
|
-
cid: CID.parse(output[0]),
|
|
80
|
-
toResolve: output.slice(1)
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
throw new BadPathError(`Unknown path type ${path}`);
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Returns an async iterator that yields entries for all segments in a path
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
*
|
|
90
|
-
* ```javascript
|
|
91
|
-
* import { walkPath } from 'ipfs-unixfs-exporter'
|
|
92
|
-
*
|
|
93
|
-
* const entries = []
|
|
94
|
-
*
|
|
95
|
-
* for await (const entry of walkPath('Qmfoo/foo/bar/baz.txt', blockstore)) {
|
|
96
|
-
* entries.push(entry)
|
|
97
|
-
* }
|
|
98
|
-
*
|
|
99
|
-
* // entries contains 4x `entry` objects
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
export async function* walkPath(path, blockstore, options = {}) {
|
|
103
|
-
let { cid, toResolve } = cidAndRest(path);
|
|
104
|
-
let name = cid.toString();
|
|
105
|
-
let entryPath = name;
|
|
106
|
-
const startingDepth = toResolve.length;
|
|
107
|
-
while (true) {
|
|
108
|
-
const result = await resolve(cid, name, entryPath, toResolve, startingDepth, blockstore, options);
|
|
109
|
-
if (result.entry == null && result.next == null) {
|
|
110
|
-
throw new NotFoundError(`Could not resolve ${path}`);
|
|
111
|
-
}
|
|
112
|
-
if (result.entry != null) {
|
|
113
|
-
yield result.entry;
|
|
114
|
-
}
|
|
115
|
-
if (result.next == null) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
// resolve further parts
|
|
119
|
-
toResolve = result.next.toResolve;
|
|
120
|
-
cid = result.next.cid;
|
|
121
|
-
name = result.next.name;
|
|
122
|
-
entryPath = result.next.path;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Uses the given blockstore instance to fetch an IPFS node by a CID or path.
|
|
127
|
-
*
|
|
128
|
-
* Returns a {@link Promise} which resolves to a {@link UnixFSEntry}.
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
*
|
|
132
|
-
* ```typescript
|
|
133
|
-
* import { exporter } from 'ipfs-unixfs-exporter'
|
|
134
|
-
* import { CID } from 'multiformats/cid'
|
|
135
|
-
*
|
|
136
|
-
* const cid = CID.parse('QmFoo')
|
|
137
|
-
*
|
|
138
|
-
* const entry = await exporter(cid, blockstore, {
|
|
139
|
-
* signal: AbortSignal.timeout(50000)
|
|
140
|
-
* })
|
|
141
|
-
*
|
|
142
|
-
* if (entry.type === 'file') {
|
|
143
|
-
* for await (const chunk of entry.content()) {
|
|
144
|
-
* // chunk is a Uint8Array
|
|
145
|
-
* }
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
export async function exporter(path, blockstore, options = {}) {
|
|
150
|
-
const result = await last(walkPath(path, blockstore, options));
|
|
151
|
-
if (result == null) {
|
|
152
|
-
throw new NotFoundError(`Could not resolve ${path}`);
|
|
153
|
-
}
|
|
154
|
-
return result;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Returns an async iterator that yields all entries beneath a given CID or IPFS
|
|
158
|
-
* path, as well as the containing directory.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
*
|
|
162
|
-
* ```typescript
|
|
163
|
-
* import { recursive } from 'ipfs-unixfs-exporter'
|
|
164
|
-
*
|
|
165
|
-
* const entries = []
|
|
166
|
-
*
|
|
167
|
-
* for await (const child of recursive('Qmfoo/foo/bar', blockstore)) {
|
|
168
|
-
* entries.push(entry)
|
|
169
|
-
* }
|
|
170
|
-
*
|
|
171
|
-
* // entries contains all children of the `Qmfoo/foo/bar` directory and it's children
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
export async function* recursive(path, blockstore, options = {}) {
|
|
175
|
-
const node = await exporter(path, blockstore, options);
|
|
176
|
-
if (node == null) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
yield node;
|
|
180
|
-
if (node.type === 'directory') {
|
|
181
|
-
for await (const child of recurse(node, options)) {
|
|
182
|
-
yield child;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
async function* recurse(node, options) {
|
|
186
|
-
for await (const file of node.content(options)) {
|
|
187
|
-
yield file;
|
|
188
|
-
if (file instanceof Uint8Array) {
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
if (file.type === 'directory') {
|
|
192
|
-
yield* recurse(file, options);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAO1C,cAAc,aAAa,CAAA;AA+Q3B,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAY,EAAE;IACvD,mCAAmC;IACnC,OAAO,CAAC,IAAI;SACT,IAAI,EAAE;SACN,KAAK,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,OAAO,CAAC,CAAA;AACpB,CAAC,CAAA;AAED,MAAM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C/G,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IAEtD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,OAAM;IACR,CAAC;IAED,MAAM,IAAI,CAAA;IAEV,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC9B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;YACjD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;IAED,KAAK,SAAU,CAAC,CAAC,OAAO,CAAE,IAAqB,EAAE,OAAwB;QACvE,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,CAAA;YAEV,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;gBAC/B,SAAQ;YACV,CAAC;YAED,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC9B,KAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dag-cbor.d.ts","sourceRoot":"","sources":["../../../src/resolvers/dag-cbor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,QAAA,MAAM,OAAO,EAAE,QAKd,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as dagCbor from "@fireproof/vendor/@ipld/dag-cbor";
|
|
2
|
-
import { resolveObjectPath } from '../utils/resolve-object-path.js';
|
|
3
|
-
const resolve = async (cid, name, path, toResolve, resolve, depth, blockstore, options) => {
|
|
4
|
-
const block = await blockstore.get(cid, options);
|
|
5
|
-
const object = dagCbor.decode(block);
|
|
6
|
-
return resolveObjectPath(object, block, cid, name, path, toResolve, depth);
|
|
7
|
-
};
|
|
8
|
-
export default resolve;
|
|
9
|
-
//# sourceMappingURL=dag-cbor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dag-cbor.js","sourceRoot":"","sources":["../../../src/resolvers/dag-cbor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAGnE,MAAM,OAAO,GAAa,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;IAClG,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAM,KAAK,CAAC,CAAA;IAEzC,OAAO,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;AAC5E,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dag-json.d.ts","sourceRoot":"","sources":["../../../src/resolvers/dag-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,QAAA,MAAM,OAAO,EAAE,QAKd,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as dagJson from "@fireproof/vendor/@ipld/dag-json";
|
|
2
|
-
import { resolveObjectPath } from '../utils/resolve-object-path.js';
|
|
3
|
-
const resolve = async (cid, name, path, toResolve, resolve, depth, blockstore, options) => {
|
|
4
|
-
const block = await blockstore.get(cid, options);
|
|
5
|
-
const object = dagJson.decode(block);
|
|
6
|
-
return resolveObjectPath(object, block, cid, name, path, toResolve, depth);
|
|
7
|
-
};
|
|
8
|
-
export default resolve;
|
|
9
|
-
//# sourceMappingURL=dag-json.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dag-json.js","sourceRoot":"","sources":["../../../src/resolvers/dag-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAGnE,MAAM,OAAO,GAAa,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;IAClG,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAM,KAAK,CAAC,CAAA;IAEzC,OAAO,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;AAC5E,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/resolvers/identity.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAmB,QAAQ,EAAkB,MAAM,aAAa,CAAA;AAuB5E,QAAA,MAAM,OAAO,EAAE,QAkBd,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as mh from 'multiformats/hashes/digest';
|
|
2
|
-
import { CustomProgressEvent } from 'progress-events';
|
|
3
|
-
import { NotFoundError } from '../errors.js';
|
|
4
|
-
import extractDataFromBlock from '../utils/extract-data-from-block.js';
|
|
5
|
-
import validateOffsetAndLength from '../utils/validate-offset-and-length.js';
|
|
6
|
-
const rawContent = (node) => {
|
|
7
|
-
async function* contentGenerator(options = {}) {
|
|
8
|
-
const { start, end } = validateOffsetAndLength(node.length, options.offset, options.length);
|
|
9
|
-
const buf = extractDataFromBlock(node, 0n, start, end);
|
|
10
|
-
options.onProgress?.(new CustomProgressEvent('unixfs:exporter:progress:identity', {
|
|
11
|
-
bytesRead: BigInt(buf.byteLength),
|
|
12
|
-
totalBytes: end - start,
|
|
13
|
-
fileSize: BigInt(node.byteLength)
|
|
14
|
-
}));
|
|
15
|
-
yield buf;
|
|
16
|
-
}
|
|
17
|
-
return contentGenerator;
|
|
18
|
-
};
|
|
19
|
-
const resolve = async (cid, name, path, toResolve, resolve, depth, blockstore, options) => {
|
|
20
|
-
if (toResolve.length > 0) {
|
|
21
|
-
throw new NotFoundError(`No link named ${path} found in raw node ${cid}`);
|
|
22
|
-
}
|
|
23
|
-
const buf = mh.decode(cid.multihash.bytes);
|
|
24
|
-
return {
|
|
25
|
-
entry: {
|
|
26
|
-
type: 'identity',
|
|
27
|
-
name,
|
|
28
|
-
path,
|
|
29
|
-
cid,
|
|
30
|
-
content: rawContent(buf.digest),
|
|
31
|
-
depth,
|
|
32
|
-
size: BigInt(buf.digest.length),
|
|
33
|
-
node: buf.digest
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export default resolve;
|
|
38
|
-
//# sourceMappingURL=identity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/resolvers/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,oBAAoB,MAAM,qCAAqC,CAAA;A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