@fireproof/vendor 0.0.0-smoke → 0.0.2-dev-test
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/merge-package.ts +207 -0
- package/p-limit/index.d.ts +81 -0
- package/p-limit/index.js +104 -0
- package/p-limit/index.test-d.ts +19 -0
- package/p-limit/license +9 -0
- package/p-limit/package.json +59 -0
- package/p-limit/readme.md +128 -0
- package/p-limit/test.js +241 -0
- package/package.json +12 -9
- package/to-esm-transform.ts +42 -0
- package/patched/@ipld/dag-json/.github/dependabot.yml +0 -11
- package/patched/@ipld/dag-json/.github/workflows/js-test-and-release.yml +0 -28
- package/patched/@ipld/dag-json/CHANGELOG.md +0 -202
- package/patched/@ipld/dag-json/LICENSE +0 -4
- package/patched/@ipld/dag-json/LICENSE-APACHE +0 -5
- package/patched/@ipld/dag-json/LICENSE-MIT +0 -19
- package/patched/@ipld/dag-json/README.md +0 -58
- package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
- package/patched/@ipld/dag-json/package.json +0 -173
- package/patched/@ipld/dag-json/src/index.js +0 -291
- package/patched/@ipld/dag-json/test/test-basics.spec.js +0 -290
- package/patched/@ipld/dag-json/test/ts-use/package.json +0 -11
- package/patched/@ipld/dag-json/test/ts-use/src/main.ts +0 -54
- package/patched/@ipld/dag-json/test/ts-use/tsconfig.json +0 -9
- package/patched/@ipld/dag-json/tsconfig.json +0 -14
- package/patched/cborg/.github/dependabot.yml +0 -16
- package/patched/cborg/.github/workflows/test-and-release.yml +0 -52
- package/patched/cborg/CHANGELOG.md +0 -513
- package/patched/cborg/LICENSE +0 -13
- package/patched/cborg/README.md +0 -515
- package/patched/cborg/bench/bench.js +0 -117
- package/patched/cborg/bench/json.js +0 -124
- package/patched/cborg/bench/package.json +0 -8
- package/patched/cborg/cborg-4.2.7.tgz +0 -0
- package/patched/cborg/cborg.js +0 -31
- package/patched/cborg/example-bytestrings.js +0 -180
- package/patched/cborg/example-json.js +0 -6
- package/patched/cborg/example.js +0 -5
- package/patched/cborg/interface.ts +0 -56
- package/patched/cborg/lib/0uint.js +0 -227
- package/patched/cborg/lib/1negint.js +0 -111
- package/patched/cborg/lib/2bytes.js +0 -133
- package/patched/cborg/lib/3string.js +0 -90
- package/patched/cborg/lib/4array.js +0 -113
- package/patched/cborg/lib/5map.js +0 -113
- package/patched/cborg/lib/6tag.js +0 -80
- package/patched/cborg/lib/7float.js +0 -308
- package/patched/cborg/lib/bin.js +0 -189
- package/patched/cborg/lib/bl.js +0 -124
- package/patched/cborg/lib/byte-utils.js +0 -417
- package/patched/cborg/lib/common.js +0 -27
- package/patched/cborg/lib/decode.js +0 -209
- package/patched/cborg/lib/diagnostic.js +0 -156
- package/patched/cborg/lib/diagnostic_test.js +0 -117
- package/patched/cborg/lib/encode.js +0 -464
- package/patched/cborg/lib/is.js +0 -106
- package/patched/cborg/lib/json/decode.js +0 -462
- package/patched/cborg/lib/json/encode.js +0 -299
- package/patched/cborg/lib/json/json.js +0 -4
- package/patched/cborg/lib/jump.js +0 -209
- package/patched/cborg/lib/length.js +0 -61
- package/patched/cborg/lib/token.js +0 -76
- package/patched/cborg/package.json +0 -169
- package/patched/cborg/pnpm-lock.yaml +0 -6096
- package/patched/cborg/taglib.js +0 -73
- package/patched/cborg/test/appendix_a.js +0 -647
- package/patched/cborg/test/common.js +0 -18
- package/patched/cborg/test/node-test-bin.js +0 -402
- package/patched/cborg/test/noop-bin-test.js +0 -3
- package/patched/cborg/test/test-0uint.js +0 -103
- package/patched/cborg/test/test-1negint.js +0 -96
- package/patched/cborg/test/test-2bytes.js +0 -198
- package/patched/cborg/test/test-3string.js +0 -136
- package/patched/cborg/test/test-4array.js +0 -93
- package/patched/cborg/test/test-5map.js +0 -284
- package/patched/cborg/test/test-6tag.js +0 -85
- package/patched/cborg/test/test-7float.js +0 -131
- package/patched/cborg/test/test-bl.js +0 -37
- package/patched/cborg/test/test-cbor-vectors.js +0 -107
- package/patched/cborg/test/test-decode-errors.js +0 -65
- package/patched/cborg/test/test-fuzz.js +0 -42
- package/patched/cborg/test/test-json.js +0 -219
- package/patched/cborg/test/test-length.js +0 -65
- package/patched/cborg/test/test-partial.js +0 -111
- package/patched/cborg/tsconfig.json +0 -45
- package/patched/cborg/types/cborg.d.ts +0 -28
- package/patched/cborg/types/cborg.d.ts.map +0 -1
- package/patched/cborg/types/example.d.ts +0 -2
- package/patched/cborg/types/example.d.ts.map +0 -1
- package/patched/cborg/types/interface.d.ts +0 -47
- package/patched/cborg/types/interface.d.ts.map +0 -1
- package/patched/cborg/types/lib/0uint.d.ts +0 -100
- package/patched/cborg/types/lib/0uint.d.ts.map +0 -1
- package/patched/cborg/types/lib/1negint.d.ts +0 -58
- package/patched/cborg/types/lib/1negint.d.ts.map +0 -1
- package/patched/cborg/types/lib/2bytes.d.ts +0 -68
- package/patched/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/patched/cborg/types/lib/3string.d.ts +0 -46
- package/patched/cborg/types/lib/3string.d.ts.map +0 -1
- package/patched/cborg/types/lib/4array.d.ts +0 -65
- package/patched/cborg/types/lib/4array.d.ts.map +0 -1
- package/patched/cborg/types/lib/5map.d.ts +0 -65
- package/patched/cborg/types/lib/5map.d.ts.map +0 -1
- package/patched/cborg/types/lib/6tag.d.ts +0 -61
- package/patched/cborg/types/lib/6tag.d.ts.map +0 -1
- package/patched/cborg/types/lib/7float.d.ts +0 -60
- package/patched/cborg/types/lib/7float.d.ts.map +0 -1
- package/patched/cborg/types/lib/bin.d.ts +0 -4
- package/patched/cborg/types/lib/bin.d.ts.map +0 -1
- package/patched/cborg/types/lib/bl.d.ts +0 -26
- package/patched/cborg/types/lib/bl.d.ts.map +0 -1
- package/patched/cborg/types/lib/byte-utils.d.ts +0 -53
- package/patched/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/patched/cborg/types/lib/common.d.ts +0 -10
- package/patched/cborg/types/lib/common.d.ts.map +0 -1
- package/patched/cborg/types/lib/decode.d.ts +0 -41
- package/patched/cborg/types/lib/decode.d.ts.map +0 -1
- package/patched/cborg/types/lib/diagnostic.d.ts +0 -12
- package/patched/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/patched/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/patched/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/patched/cborg/types/lib/encode.d.ts +0 -50
- package/patched/cborg/types/lib/encode.d.ts.map +0 -1
- package/patched/cborg/types/lib/is.d.ts +0 -6
- package/patched/cborg/types/lib/is.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/decode.d.ts +0 -67
- package/patched/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/encode.d.ts +0 -11
- package/patched/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/patched/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/json.d.ts +0 -6
- package/patched/cborg/types/lib/json/json.d.ts.map +0 -1
- package/patched/cborg/types/lib/jump.d.ts +0 -12
- package/patched/cborg/types/lib/jump.d.ts.map +0 -1
- package/patched/cborg/types/lib/length.d.ts +0 -27
- package/patched/cborg/types/lib/length.d.ts.map +0 -1
- package/patched/cborg/types/lib/token.d.ts +0 -59
- package/patched/cborg/types/lib/token.d.ts.map +0 -1
- package/patched/cborg/types/taglib.d.ts +0 -18
- package/patched/cborg/types/taglib.d.ts.map +0 -1
- package/patched/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/@ipld/car/car/LICENSE +0 -4
- package/src/@ipld/car/car/README.md +0 -1078
- package/src/@ipld/car/car/dist/index.min.js +0 -5
- package/src/@ipld/car/car/dist/src/api.d.ts +0 -72
- package/src/@ipld/car/car/dist/src/api.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts +0 -67
- package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts +0 -116
- package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/buffer-reader.d.ts +0 -31
- package/src/@ipld/car/car/dist/src/buffer-reader.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/buffer-writer.d.ts +0 -86
- package/src/@ipld/car/car/dist/src/buffer-writer.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/coding.d.ts +0 -49
- package/src/@ipld/car/car/dist/src/coding.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/decoder-common.d.ts +0 -43
- package/src/@ipld/car/car/dist/src/decoder-common.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/decoder.d.ts +0 -87
- package/src/@ipld/car/car/dist/src/decoder.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/encoder.d.ts +0 -17
- package/src/@ipld/car/car/dist/src/encoder.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/header-validator.d.ts +0 -5
- package/src/@ipld/car/car/dist/src/header-validator.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/index-browser.d.ts +0 -10
- package/src/@ipld/car/car/dist/src/index-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/index.d.ts +0 -11
- package/src/@ipld/car/car/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts +0 -5
- package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/indexed-reader.d.ts +0 -152
- package/src/@ipld/car/car/dist/src/indexed-reader.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/indexer.d.ts +0 -95
- package/src/@ipld/car/car/dist/src/indexer.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/iterator-channel.d.ts +0 -7
- package/src/@ipld/car/car/dist/src/iterator-channel.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/iterator.d.ts +0 -174
- package/src/@ipld/car/car/dist/src/iterator.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/reader-browser.d.ts +0 -151
- package/src/@ipld/car/car/dist/src/reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/reader.d.ts +0 -35
- package/src/@ipld/car/car/dist/src/reader.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/writer-browser.d.ts +0 -155
- package/src/@ipld/car/car/dist/src/writer-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/writer.d.ts +0 -45
- package/src/@ipld/car/car/dist/src/writer.d.ts.map +0 -1
- package/src/@ipld/car/car/node_modules/.bin/cborg +0 -17
- package/src/@ipld/car/car/package.json +0 -235
- package/src/@ipld/car/car/src/api.ts +0 -90
- package/src/@ipld/car/car/src/buffer-decoder.js +0 -213
- package/src/@ipld/car/car/src/buffer-reader-browser.js +0 -144
- package/src/@ipld/car/car/src/buffer-reader.js +0 -51
- package/src/@ipld/car/car/src/buffer-writer.js +0 -286
- package/src/@ipld/car/car/src/coding.ts +0 -68
- package/src/@ipld/car/car/src/decoder-common.js +0 -82
- package/src/@ipld/car/car/src/decoder.js +0 -347
- package/src/@ipld/car/car/src/encoder.js +0 -76
- package/src/@ipld/car/car/src/header-validator.js +0 -214
- package/src/@ipld/car/car/src/header.ipldsch +0 -18
- package/src/@ipld/car/car/src/index-browser.js +0 -18
- package/src/@ipld/car/car/src/index.js +0 -21
- package/src/@ipld/car/car/src/indexed-reader-browser.js +0 -7
- package/src/@ipld/car/car/src/indexed-reader.js +0 -211
- package/src/@ipld/car/car/src/indexer.js +0 -130
- package/src/@ipld/car/car/src/iterator-channel.js +0 -91
- package/src/@ipld/car/car/src/iterator.js +0 -267
- package/src/@ipld/car/car/src/reader-browser.js +0 -194
- package/src/@ipld/car/car/src/reader.js +0 -56
- package/src/@ipld/car/car/src/writer-browser.js +0 -250
- package/src/@ipld/car/car/src/writer.js +0 -84
- package/src/@ipld/dag-cbor/dag-cbor/LICENSE +0 -4
- package/src/@ipld/dag-cbor/dag-cbor/README.md +0 -80
- package/src/@ipld/dag-cbor/dag-cbor/dist/index.min.js +0 -3
- package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts +0 -67
- package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-cbor/dag-cbor/package.json +0 -171
- package/src/@ipld/dag-cbor/dag-cbor/src/index.js +0 -147
- package/src/@ipld/dag-json/dag-json/LICENSE +0 -4
- package/src/@ipld/dag-json/dag-json/README.md +0 -58
- package/src/@ipld/dag-json/dag-json/dist/index.min.js +0 -3
- package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts +0 -12
- package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-json/dag-json/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-json/dag-json/package.json +0 -173
- package/src/@ipld/dag-json/dag-json/src/index.js +0 -291
- package/src/@web3-storage/pail/pail/LICENSE.md +0 -232
- package/src/@web3-storage/pail/pail/README.md +0 -84
- package/src/@web3-storage/pail/pail/cli.js +0 -218
- package/src/@web3-storage/pail/pail/dist/src/api.d.ts +0 -59
- package/src/@web3-storage/pail/pail/dist/src/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts +0 -31
- package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts +0 -75
- package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts +0 -3
- package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/block.d.ts +0 -35
- package/src/@web3-storage/pail/pail/dist/src/block.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts +0 -10
- package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts +0 -48
- package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts +0 -26
- package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts +0 -11
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts +0 -5
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts +0 -9
- package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/diff.d.ts +0 -13
- package/src/@web3-storage/pail/pail/dist/src/diff.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/index.d.ts +0 -10
- package/src/@web3-storage/pail/pail/dist/src/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/merge.d.ts +0 -5
- package/src/@web3-storage/pail/pail/dist/src/merge.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/shard.d.ts +0 -43
- package/src/@web3-storage/pail/pail/dist/src/shard.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/tsconfig.tsbuildinfo +0 -1
- package/src/@web3-storage/pail/pail/node_modules/.bin/pail +0 -17
- package/src/@web3-storage/pail/pail/package.json +0 -173
- package/src/@web3-storage/pail/pail/src/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/api.ts +0 -90
- package/src/@web3-storage/pail/pail/src/batch/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/batch/api.ts +0 -59
- package/src/@web3-storage/pail/pail/src/batch/index.js +0 -258
- package/src/@web3-storage/pail/pail/src/batch/shard.js +0 -13
- package/src/@web3-storage/pail/pail/src/block.js +0 -75
- package/src/@web3-storage/pail/pail/src/clock/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/clock/api.ts +0 -12
- package/src/@web3-storage/pail/pail/src/clock/index.js +0 -182
- package/src/@web3-storage/pail/pail/src/crdt/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/crdt/api.ts +0 -33
- package/src/@web3-storage/pail/pail/src/crdt/batch/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/crdt/batch/api.ts +0 -30
- package/src/@web3-storage/pail/pail/src/crdt/batch/index.js +0 -155
- package/src/@web3-storage/pail/pail/src/crdt/index.js +0 -354
- package/src/@web3-storage/pail/pail/src/diff.js +0 -151
- package/src/@web3-storage/pail/pail/src/index.js +0 -406
- package/src/@web3-storage/pail/pail/src/merge.js +0 -43
- package/src/@web3-storage/pail/pail/src/shard.js +0 -180
- package/src/cborg/cborg/.github/dependabot.yml +0 -16
- package/src/cborg/cborg/.github/workflows/test-and-release.yml +0 -52
- package/src/cborg/cborg/CHANGELOG.md +0 -513
- package/src/cborg/cborg/LICENSE +0 -13
- package/src/cborg/cborg/README.md +0 -515
- package/src/cborg/cborg/bench/bench.js +0 -117
- package/src/cborg/cborg/bench/json.js +0 -124
- package/src/cborg/cborg/bench/package.json +0 -8
- package/src/cborg/cborg/cborg.js +0 -31
- package/src/cborg/cborg/example-bytestrings.js +0 -180
- package/src/cborg/cborg/example-json.js +0 -6
- package/src/cborg/cborg/example.js +0 -5
- package/src/cborg/cborg/interface.ts +0 -56
- package/src/cborg/cborg/lib/0uint.js +0 -227
- package/src/cborg/cborg/lib/1negint.js +0 -111
- package/src/cborg/cborg/lib/2bytes.js +0 -133
- package/src/cborg/cborg/lib/3string.js +0 -90
- package/src/cborg/cborg/lib/4array.js +0 -113
- package/src/cborg/cborg/lib/5map.js +0 -113
- package/src/cborg/cborg/lib/6tag.js +0 -80
- package/src/cborg/cborg/lib/7float.js +0 -308
- package/src/cborg/cborg/lib/bin.js +0 -189
- package/src/cborg/cborg/lib/bl.js +0 -124
- package/src/cborg/cborg/lib/byte-utils.js +0 -417
- package/src/cborg/cborg/lib/common.js +0 -27
- package/src/cborg/cborg/lib/decode.js +0 -209
- package/src/cborg/cborg/lib/diagnostic.js +0 -156
- package/src/cborg/cborg/lib/diagnostic_test.js +0 -117
- package/src/cborg/cborg/lib/encode.js +0 -464
- package/src/cborg/cborg/lib/is.js +0 -106
- package/src/cborg/cborg/lib/json/decode.js +0 -462
- package/src/cborg/cborg/lib/json/encode.js +0 -299
- package/src/cborg/cborg/lib/json/json.js +0 -4
- package/src/cborg/cborg/lib/jump.js +0 -209
- package/src/cborg/cborg/lib/length.js +0 -61
- package/src/cborg/cborg/lib/token.js +0 -76
- package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
- package/src/cborg/cborg/package.json +0 -168
- package/src/cborg/cborg/taglib.js +0 -73
- package/src/cborg/cborg/test/appendix_a.js +0 -647
- package/src/cborg/cborg/test/common.js +0 -18
- package/src/cborg/cborg/test/node-test-bin.js +0 -402
- package/src/cborg/cborg/test/noop-bin-test.js +0 -3
- package/src/cborg/cborg/test/test-0uint.js +0 -103
- package/src/cborg/cborg/test/test-1negint.js +0 -96
- package/src/cborg/cborg/test/test-2bytes.js +0 -198
- package/src/cborg/cborg/test/test-3string.js +0 -136
- package/src/cborg/cborg/test/test-4array.js +0 -93
- package/src/cborg/cborg/test/test-5map.js +0 -284
- package/src/cborg/cborg/test/test-6tag.js +0 -85
- package/src/cborg/cborg/test/test-7float.js +0 -131
- package/src/cborg/cborg/test/test-bl.js +0 -37
- package/src/cborg/cborg/test/test-cbor-vectors.js +0 -107
- package/src/cborg/cborg/test/test-decode-errors.js +0 -65
- package/src/cborg/cborg/test/test-fuzz.js +0 -42
- package/src/cborg/cborg/test/test-json.js +0 -219
- package/src/cborg/cborg/test/test-length.js +0 -65
- package/src/cborg/cborg/test/test-partial.js +0 -111
- package/src/cborg/cborg/tsconfig.json +0 -45
- package/src/cborg/cborg/types/cborg.d.ts +0 -28
- package/src/cborg/cborg/types/cborg.d.ts.map +0 -1
- package/src/cborg/cborg/types/example.d.ts +0 -2
- package/src/cborg/cborg/types/example.d.ts.map +0 -1
- package/src/cborg/cborg/types/interface.d.ts +0 -47
- package/src/cborg/cborg/types/interface.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/0uint.d.ts +0 -100
- package/src/cborg/cborg/types/lib/0uint.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/1negint.d.ts +0 -58
- package/src/cborg/cborg/types/lib/1negint.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/2bytes.d.ts +0 -68
- package/src/cborg/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/3string.d.ts +0 -46
- package/src/cborg/cborg/types/lib/3string.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/4array.d.ts +0 -65
- package/src/cborg/cborg/types/lib/4array.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/5map.d.ts +0 -65
- package/src/cborg/cborg/types/lib/5map.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/6tag.d.ts +0 -61
- package/src/cborg/cborg/types/lib/6tag.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/7float.d.ts +0 -60
- package/src/cborg/cborg/types/lib/7float.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/bin.d.ts +0 -4
- package/src/cborg/cborg/types/lib/bin.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/bl.d.ts +0 -26
- package/src/cborg/cborg/types/lib/bl.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/byte-utils.d.ts +0 -53
- package/src/cborg/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/common.d.ts +0 -10
- package/src/cborg/cborg/types/lib/common.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/decode.d.ts +0 -41
- package/src/cborg/cborg/types/lib/decode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/diagnostic.d.ts +0 -12
- package/src/cborg/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/encode.d.ts +0 -50
- package/src/cborg/cborg/types/lib/encode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/is.d.ts +0 -6
- package/src/cborg/cborg/types/lib/is.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/decode.d.ts +0 -67
- package/src/cborg/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/encode.d.ts +0 -11
- package/src/cborg/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/json.d.ts +0 -6
- package/src/cborg/cborg/types/lib/json/json.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/jump.d.ts +0 -12
- package/src/cborg/cborg/types/lib/jump.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/length.d.ts +0 -27
- package/src/cborg/cborg/types/lib/length.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/token.d.ts +0 -59
- package/src/cborg/cborg/types/lib/token.d.ts.map +0 -1
- package/src/cborg/cborg/types/taglib.d.ts +0 -18
- package/src/cborg/cborg/types/taglib.d.ts.map +0 -1
- package/src/cborg/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/LICENSE +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/README.md +0 -105
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/index.min.js +0 -3
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js +0 -197
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/package.json +0 -180
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/errors.ts +0 -87
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/index.ts +0 -498
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import * as CBOR from "@fireproof/vendor/@ipld/dag-cbor"
|
|
2
|
-
import { Token, Type } from "@fireproof/vendor/cborg"
|
|
3
|
-
import { tokensToLength } from "@fireproof/vendor/cborg/length"
|
|
4
|
-
import varint from 'varint'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {import('./api').CID} CID
|
|
8
|
-
* @typedef {import('./api').Block} Block
|
|
9
|
-
* @typedef {import('./api').CarBufferWriter} Writer
|
|
10
|
-
* @typedef {import('./api').CarBufferWriterOptions} Options
|
|
11
|
-
* @typedef {import('./coding').CarEncoder} CarEncoder
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A simple CAR writer that writes to a pre-allocated buffer.
|
|
16
|
-
*
|
|
17
|
-
* @class
|
|
18
|
-
* @name CarBufferWriter
|
|
19
|
-
* @implements {Writer}
|
|
20
|
-
*/
|
|
21
|
-
class CarBufferWriter {
|
|
22
|
-
/**
|
|
23
|
-
* @param {Uint8Array} bytes
|
|
24
|
-
* @param {number} headerSize
|
|
25
|
-
*/
|
|
26
|
-
constructor (bytes, headerSize) {
|
|
27
|
-
/** @readonly */
|
|
28
|
-
this.bytes = bytes
|
|
29
|
-
this.byteOffset = headerSize
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @readonly
|
|
33
|
-
* @type {CID[]}
|
|
34
|
-
*/
|
|
35
|
-
this.roots = []
|
|
36
|
-
this.headerSize = headerSize
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Add a root to this writer, to be used to create a header when the CAR is
|
|
41
|
-
* finalized with {@link CarBufferWriter.close `close()`}
|
|
42
|
-
*
|
|
43
|
-
* @param {CID} root
|
|
44
|
-
* @param {{resize?:boolean}} [options]
|
|
45
|
-
* @returns {CarBufferWriter}
|
|
46
|
-
*/
|
|
47
|
-
addRoot (root, options) {
|
|
48
|
-
addRoot(this, root, options)
|
|
49
|
-
return this
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
|
|
54
|
-
* Throws if there is not enough capacity.
|
|
55
|
-
*
|
|
56
|
-
* @param {Block} block - A `{ cid:CID, bytes:Uint8Array }` pair.
|
|
57
|
-
* @returns {CarBufferWriter}
|
|
58
|
-
*/
|
|
59
|
-
write (block) {
|
|
60
|
-
addBlock(this, block)
|
|
61
|
-
return this
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Finalize the CAR and return it as a `Uint8Array`.
|
|
66
|
-
*
|
|
67
|
-
* @param {object} [options]
|
|
68
|
-
* @param {boolean} [options.resize]
|
|
69
|
-
* @returns {Uint8Array}
|
|
70
|
-
*/
|
|
71
|
-
close (options) {
|
|
72
|
-
return close(this, options)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @param {CarBufferWriter} writer
|
|
78
|
-
* @param {CID} root
|
|
79
|
-
* @param {{resize?:boolean}} [options]
|
|
80
|
-
*/
|
|
81
|
-
export const addRoot = (writer, root, options = {}) => {
|
|
82
|
-
const { resize = false } = options
|
|
83
|
-
const { bytes, headerSize, byteOffset, roots } = writer
|
|
84
|
-
writer.roots.push(root)
|
|
85
|
-
const size = headerLength(writer)
|
|
86
|
-
// If there is not enough space for the new root
|
|
87
|
-
if (size > headerSize) {
|
|
88
|
-
// Check if we root would fit if we were to resize the head.
|
|
89
|
-
if (size - headerSize + byteOffset < bytes.byteLength) {
|
|
90
|
-
// If resize is enabled resize head
|
|
91
|
-
if (resize) {
|
|
92
|
-
resizeHeader(writer, size)
|
|
93
|
-
// otherwise remove head and throw an error suggesting to resize
|
|
94
|
-
} else {
|
|
95
|
-
roots.pop()
|
|
96
|
-
throw new RangeError(`Header of size ${headerSize} has no capacity for new root ${root}.
|
|
97
|
-
However there is a space in the buffer and you could call addRoot(root, { resize: root }) to resize header to make a space for this root.`)
|
|
98
|
-
}
|
|
99
|
-
// If head would not fit even with resize pop new root and throw error
|
|
100
|
-
} else {
|
|
101
|
-
roots.pop()
|
|
102
|
-
throw new RangeError(`Buffer has no capacity for a new root ${root}`)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Calculates number of bytes required for storing given block in CAR. Useful in
|
|
109
|
-
* estimating size of an `ArrayBuffer` for the `CarBufferWriter`.
|
|
110
|
-
*
|
|
111
|
-
* @name CarBufferWriter.blockLength(Block)
|
|
112
|
-
* @param {Block} block
|
|
113
|
-
* @returns {number}
|
|
114
|
-
*/
|
|
115
|
-
export const blockLength = ({ cid, bytes }) => {
|
|
116
|
-
const size = cid.bytes.byteLength + bytes.byteLength
|
|
117
|
-
return varint.encodingLength(size) + size
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @param {CarBufferWriter} writer
|
|
122
|
-
* @param {Block} block
|
|
123
|
-
*/
|
|
124
|
-
export const addBlock = (writer, { cid, bytes }) => {
|
|
125
|
-
const byteLength = cid.bytes.byteLength + bytes.byteLength
|
|
126
|
-
const size = varint.encode(byteLength)
|
|
127
|
-
if (writer.byteOffset + size.length + byteLength > writer.bytes.byteLength) {
|
|
128
|
-
throw new RangeError('Buffer has no capacity for this block')
|
|
129
|
-
} else {
|
|
130
|
-
writeBytes(writer, size)
|
|
131
|
-
writeBytes(writer, cid.bytes)
|
|
132
|
-
writeBytes(writer, bytes)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* @param {CarBufferWriter} writer
|
|
138
|
-
* @param {object} [options]
|
|
139
|
-
* @param {boolean} [options.resize]
|
|
140
|
-
*/
|
|
141
|
-
export const close = (writer, options = {}) => {
|
|
142
|
-
const { resize = false } = options
|
|
143
|
-
const { roots, bytes, byteOffset, headerSize } = writer
|
|
144
|
-
|
|
145
|
-
const headerBytes = CBOR.encode({ version: 1, roots })
|
|
146
|
-
const varintBytes = varint.encode(headerBytes.length)
|
|
147
|
-
|
|
148
|
-
const size = varintBytes.length + headerBytes.byteLength
|
|
149
|
-
const offset = headerSize - size
|
|
150
|
-
|
|
151
|
-
// If header size estimate was accurate we just write header and return
|
|
152
|
-
// view into buffer.
|
|
153
|
-
if (offset === 0) {
|
|
154
|
-
writeHeader(writer, varintBytes, headerBytes)
|
|
155
|
-
return bytes.subarray(0, byteOffset)
|
|
156
|
-
// If header was overestimated and `{resize: true}` is passed resize header
|
|
157
|
-
} else if (resize) {
|
|
158
|
-
resizeHeader(writer, size)
|
|
159
|
-
writeHeader(writer, varintBytes, headerBytes)
|
|
160
|
-
return bytes.subarray(0, writer.byteOffset)
|
|
161
|
-
} else {
|
|
162
|
-
throw new RangeError(`Header size was overestimated.
|
|
163
|
-
You can use close({ resize: true }) to resize header`)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* @param {CarBufferWriter} writer
|
|
169
|
-
* @param {number} byteLength
|
|
170
|
-
*/
|
|
171
|
-
export const resizeHeader = (writer, byteLength) => {
|
|
172
|
-
const { bytes, headerSize } = writer
|
|
173
|
-
// Move data section to a new offset
|
|
174
|
-
bytes.set(bytes.subarray(headerSize, writer.byteOffset), byteLength)
|
|
175
|
-
// Update header size & byteOffset
|
|
176
|
-
writer.byteOffset += byteLength - headerSize
|
|
177
|
-
writer.headerSize = byteLength
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @param {CarBufferWriter} writer
|
|
182
|
-
* @param {number[]|Uint8Array} bytes
|
|
183
|
-
*/
|
|
184
|
-
|
|
185
|
-
const writeBytes = (writer, bytes) => {
|
|
186
|
-
writer.bytes.set(bytes, writer.byteOffset)
|
|
187
|
-
writer.byteOffset += bytes.length
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* @param {{bytes:Uint8Array}} writer
|
|
191
|
-
* @param {number[]} varint
|
|
192
|
-
* @param {Uint8Array} header
|
|
193
|
-
*/
|
|
194
|
-
const writeHeader = ({ bytes }, varint, header) => {
|
|
195
|
-
bytes.set(varint)
|
|
196
|
-
bytes.set(header, varint.length)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const headerPreludeTokens = [
|
|
200
|
-
new Token(Type.map, 2),
|
|
201
|
-
new Token(Type.string, 'version'),
|
|
202
|
-
new Token(Type.uint, 1),
|
|
203
|
-
new Token(Type.string, 'roots')
|
|
204
|
-
]
|
|
205
|
-
|
|
206
|
-
const CID_TAG = new Token(Type.tag, 42)
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Calculates header size given the array of byteLength for roots.
|
|
210
|
-
*
|
|
211
|
-
* @name CarBufferWriter.calculateHeaderLength(rootLengths)
|
|
212
|
-
* @param {number[]} rootLengths
|
|
213
|
-
* @returns {number}
|
|
214
|
-
*/
|
|
215
|
-
export const calculateHeaderLength = (rootLengths) => {
|
|
216
|
-
const tokens = [...headerPreludeTokens]
|
|
217
|
-
tokens.push(new Token(Type.array, rootLengths.length))
|
|
218
|
-
for (const rootLength of rootLengths) {
|
|
219
|
-
tokens.push(CID_TAG)
|
|
220
|
-
tokens.push(new Token(Type.bytes, { length: rootLength + 1 }))
|
|
221
|
-
}
|
|
222
|
-
const length = tokensToLength(tokens) // no options needed here because we have simple tokens
|
|
223
|
-
return varint.encodingLength(length) + length
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Calculates header size given the array of roots.
|
|
228
|
-
*
|
|
229
|
-
* @name CarBufferWriter.headerLength({ roots })
|
|
230
|
-
* @param {object} options
|
|
231
|
-
* @param {CID[]} options.roots
|
|
232
|
-
* @returns {number}
|
|
233
|
-
*/
|
|
234
|
-
export const headerLength = ({ roots }) =>
|
|
235
|
-
calculateHeaderLength(roots.map(cid => cid.bytes.byteLength))
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Estimates header size given a count of the roots and the expected byte length
|
|
239
|
-
* of the root CIDs. The default length works for a standard CIDv1 with a
|
|
240
|
-
* single-byte multihash code, such as SHA2-256 (i.e. the most common CIDv1).
|
|
241
|
-
*
|
|
242
|
-
* @name CarBufferWriter.estimateHeaderLength(rootCount[, rootByteLength])
|
|
243
|
-
* @param {number} rootCount
|
|
244
|
-
* @param {number} [rootByteLength]
|
|
245
|
-
* @returns {number}
|
|
246
|
-
*/
|
|
247
|
-
export const estimateHeaderLength = (rootCount, rootByteLength = 36) =>
|
|
248
|
-
calculateHeaderLength(new Array(rootCount).fill(rootByteLength))
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Creates synchronous CAR writer that can be used to encode blocks into a given
|
|
252
|
-
* buffer. Optionally you could pass `byteOffset` and `byteLength` to specify a
|
|
253
|
-
* range inside buffer to write into. If car file is going to have `roots` you
|
|
254
|
-
* need to either pass them under `options.roots` (from which header size will
|
|
255
|
-
* be calculated) or provide `options.headerSize` to allocate required space
|
|
256
|
-
* in the buffer. You may also provide known `roots` and `headerSize` to
|
|
257
|
-
* allocate space for the roots that may not be known ahead of time.
|
|
258
|
-
*
|
|
259
|
-
* Note: Incorrect `headerSize` may lead to copying bytes inside a buffer
|
|
260
|
-
* which will have a negative impact on performance.
|
|
261
|
-
*
|
|
262
|
-
* @name CarBufferWriter.createWriter(buffer[, options])
|
|
263
|
-
* @param {ArrayBuffer} buffer
|
|
264
|
-
* @param {object} [options]
|
|
265
|
-
* @param {CID[]} [options.roots]
|
|
266
|
-
* @param {number} [options.byteOffset]
|
|
267
|
-
* @param {number} [options.byteLength]
|
|
268
|
-
* @param {number} [options.headerSize]
|
|
269
|
-
* @returns {CarBufferWriter}
|
|
270
|
-
*/
|
|
271
|
-
export const createWriter = (buffer, options = {}) => {
|
|
272
|
-
const {
|
|
273
|
-
roots = [],
|
|
274
|
-
byteOffset = 0,
|
|
275
|
-
byteLength = buffer.byteLength,
|
|
276
|
-
headerSize = headerLength({ roots })
|
|
277
|
-
} = options
|
|
278
|
-
const bytes = new Uint8Array(buffer, byteOffset, byteLength)
|
|
279
|
-
|
|
280
|
-
const writer = new CarBufferWriter(bytes, headerSize)
|
|
281
|
-
for (const root of roots) {
|
|
282
|
-
writer.addRoot(root)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return writer
|
|
286
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { Block, BlockIndex } from './api.js'
|
|
2
|
-
import type { CID } from 'multiformats/cid'
|
|
3
|
-
|
|
4
|
-
export interface CarEncoder {
|
|
5
|
-
setRoots(roots: CID[]): Promise<void>
|
|
6
|
-
|
|
7
|
-
writeBlock(block: Block): Promise<void>
|
|
8
|
-
|
|
9
|
-
close(): Promise<void>
|
|
10
|
-
|
|
11
|
-
version(): number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface IteratorChannel_Writer<T> {
|
|
15
|
-
write(chunk: T): Promise<void>
|
|
16
|
-
end(): Promise<void>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface IteratorChannel<T> {
|
|
20
|
-
writer: IteratorChannel_Writer<T>
|
|
21
|
-
|
|
22
|
-
iterator: AsyncIterator<T>
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface CarHeader {
|
|
26
|
-
version: 1
|
|
27
|
-
roots: CID[]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface CarV2FixedHeader {
|
|
31
|
-
characteristics: [bigint, bigint]
|
|
32
|
-
dataOffset: number
|
|
33
|
-
dataSize: number
|
|
34
|
-
indexOffset: number
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface CarV2Header extends CarV2FixedHeader {
|
|
38
|
-
version: 2
|
|
39
|
-
roots: CID[]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface CarDecoder {
|
|
43
|
-
header(): Promise<CarHeader | CarV2Header>
|
|
44
|
-
|
|
45
|
-
blocks(): AsyncGenerator<Block>
|
|
46
|
-
|
|
47
|
-
blocksIndex(): AsyncGenerator<BlockIndex>
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface Seekable {
|
|
51
|
-
seek(length: number): void
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface BytesReader extends Seekable {
|
|
55
|
-
upTo(length: number): Promise<Uint8Array>
|
|
56
|
-
|
|
57
|
-
exactly(length: number, seek?: boolean): Promise<Uint8Array>
|
|
58
|
-
|
|
59
|
-
pos: number
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface BytesBufferReader extends Seekable {
|
|
63
|
-
upTo(length: number): Uint8Array
|
|
64
|
-
|
|
65
|
-
exactly(length: number, seek?: boolean): Uint8Array
|
|
66
|
-
|
|
67
|
-
pos: number
|
|
68
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import varint from 'varint'
|
|
2
|
-
|
|
3
|
-
export const CIDV0_BYTES = {
|
|
4
|
-
SHA2_256: 0x12,
|
|
5
|
-
LENGTH: 0x20,
|
|
6
|
-
DAG_PB: 0x70
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const V2_HEADER_LENGTH = /* characteristics */ 16 /* v1 offset */ + 8 /* v1 size */ + 8 /* index offset */ + 8
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Decodes varint and seeks the buffer
|
|
13
|
-
*
|
|
14
|
-
* ```js
|
|
15
|
-
* // needs bytes to be read first
|
|
16
|
-
* const bytes = reader.upTo(8) // maybe async
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param {Uint8Array} bytes
|
|
20
|
-
* @param {import('./coding').Seekable} seeker
|
|
21
|
-
* @returns {number}
|
|
22
|
-
*/
|
|
23
|
-
export function decodeVarint (bytes, seeker) {
|
|
24
|
-
if (!bytes.length) {
|
|
25
|
-
throw new Error('Unexpected end of data')
|
|
26
|
-
}
|
|
27
|
-
const i = varint.decode(bytes)
|
|
28
|
-
seeker.seek(/** @type {number} */(varint.decode.bytes))
|
|
29
|
-
return i
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Decode v2 header
|
|
34
|
-
*
|
|
35
|
-
* ```js
|
|
36
|
-
* // needs bytes to be read first
|
|
37
|
-
* const bytes = reader.exactly(V2_HEADER_LENGTH, true) // maybe async
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @param {Uint8Array} bytes
|
|
41
|
-
* @returns {import('./coding').CarV2FixedHeader}
|
|
42
|
-
*/
|
|
43
|
-
export function decodeV2Header (bytes) {
|
|
44
|
-
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
45
|
-
let offset = 0
|
|
46
|
-
const header = {
|
|
47
|
-
version: 2,
|
|
48
|
-
/** @type {[bigint, bigint]} */
|
|
49
|
-
characteristics: [
|
|
50
|
-
dv.getBigUint64(offset, true),
|
|
51
|
-
dv.getBigUint64(offset += 8, true)
|
|
52
|
-
],
|
|
53
|
-
dataOffset: Number(dv.getBigUint64(offset += 8, true)),
|
|
54
|
-
dataSize: Number(dv.getBigUint64(offset += 8, true)),
|
|
55
|
-
indexOffset: Number(dv.getBigUint64(offset += 8, true))
|
|
56
|
-
}
|
|
57
|
-
return header
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Checks the length of the multihash to be read afterwards
|
|
62
|
-
*
|
|
63
|
-
* ```js
|
|
64
|
-
* // needs bytes to be read first
|
|
65
|
-
* const bytes = reader.upTo(8) // maybe async
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @param {Uint8Array} bytes
|
|
69
|
-
*/
|
|
70
|
-
export function getMultihashLength (bytes) {
|
|
71
|
-
// | code | length | .... |
|
|
72
|
-
// where both code and length are varints, so we have to decode
|
|
73
|
-
// them first before we can know total length
|
|
74
|
-
|
|
75
|
-
varint.decode(bytes) // code
|
|
76
|
-
const codeLength = /** @type {number} */(varint.decode.bytes)
|
|
77
|
-
const length = varint.decode(bytes.subarray(varint.decode.bytes))
|
|
78
|
-
const lengthLength = /** @type {number} */(varint.decode.bytes)
|
|
79
|
-
const mhLength = codeLength + lengthLength + length
|
|
80
|
-
|
|
81
|
-
return mhLength
|
|
82
|
-
}
|