@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,90 +0,0 @@
|
|
|
1
|
-
import { Link, UnknownLink, BlockView, Block, Version } from 'multiformats'
|
|
2
|
-
import { sha256 } from 'multiformats/hashes/sha2'
|
|
3
|
-
import * as dagCBOR from "@fireproof/vendor/@ipld/dag-cbor"
|
|
4
|
-
|
|
5
|
-
export { Link, UnknownLink, BlockView, Block, Version }
|
|
6
|
-
|
|
7
|
-
export type ShardEntryValueValue = UnknownLink
|
|
8
|
-
|
|
9
|
-
export type ShardEntryLinkValue = [ShardLink]
|
|
10
|
-
|
|
11
|
-
export type ShardEntryLinkAndValueValue = [ShardLink, UnknownLink]
|
|
12
|
-
|
|
13
|
-
export type ShardValueEntry = [key: string, value: ShardEntryValueValue]
|
|
14
|
-
|
|
15
|
-
export type ShardLinkEntry = [key: string, value: ShardEntryLinkValue | ShardEntryLinkAndValueValue]
|
|
16
|
-
|
|
17
|
-
/** Single key/value entry within a shard. */
|
|
18
|
-
export type ShardEntry = [key: string, value: ShardEntryValueValue | ShardEntryLinkValue | ShardEntryLinkAndValueValue]
|
|
19
|
-
|
|
20
|
-
export interface Shard extends ShardConfig {
|
|
21
|
-
entries: ShardEntry[]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type ShardLink = Link<Shard, typeof dagCBOR.code, typeof sha256.code, 1>
|
|
25
|
-
|
|
26
|
-
export interface ShardBlockView extends BlockView<Shard, typeof dagCBOR.code, typeof sha256.code, 1> {}
|
|
27
|
-
|
|
28
|
-
export interface ShardDiff {
|
|
29
|
-
additions: ShardBlockView[]
|
|
30
|
-
removals: ShardBlockView[]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface BlockFetcher {
|
|
34
|
-
get<T = unknown, C extends number = number, A extends number = number, V extends Version = 1> (link: Link<T, C, A, V>):
|
|
35
|
-
Promise<Block<T, C, A, V> | undefined>
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface ShardConfig {
|
|
39
|
-
/** Shard compatibility version. */
|
|
40
|
-
version: number
|
|
41
|
-
/**
|
|
42
|
-
* Characters allowed in keys, referring to a known character set.
|
|
43
|
-
* e.g. "ascii" refers to the printable ASCII characters in the code range 32-126.
|
|
44
|
-
*/
|
|
45
|
-
keyChars: string
|
|
46
|
-
/** Max key size in bytes - default 4096 bytes. */
|
|
47
|
-
maxKeySize: number
|
|
48
|
-
/** The key prefix from the root to this shard. */
|
|
49
|
-
prefix: string
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type ShardOptions = Partial<ShardConfig>
|
|
53
|
-
|
|
54
|
-
export interface KeyPrefixOption {
|
|
55
|
-
/** Filter results to entries with keys prefixed with this string. */
|
|
56
|
-
prefix: string
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export type KeyRangeOption =
|
|
60
|
-
| KeyLowerBoundRangeOption
|
|
61
|
-
| KeyUpperBoundRangeOption
|
|
62
|
-
| (KeyLowerBoundRangeOption & KeyUpperBoundRangeOption)
|
|
63
|
-
|
|
64
|
-
export type KeyLowerBoundRangeOption =
|
|
65
|
-
| KeyLowerBoundRangeExclusiveOption
|
|
66
|
-
| KeyLowerBoundRangeInclusiveOption
|
|
67
|
-
|
|
68
|
-
export interface KeyLowerBoundRangeExclusiveOption {
|
|
69
|
-
gt: string
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface KeyLowerBoundRangeInclusiveOption {
|
|
73
|
-
gte: string
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export type KeyUpperBoundRangeOption =
|
|
77
|
-
| KeyUpperBoundRangeExclusiveOption
|
|
78
|
-
| KeyUpperBoundRangeInclusiveOption
|
|
79
|
-
|
|
80
|
-
export interface KeyUpperBoundRangeExclusiveOption {
|
|
81
|
-
lt: string
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface KeyUpperBoundRangeInclusiveOption {
|
|
85
|
-
lte: string
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type EntriesOptions =
|
|
89
|
-
| KeyPrefixOption
|
|
90
|
-
| KeyRangeOption
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UnknownLink,
|
|
3
|
-
ShardLink,
|
|
4
|
-
ShardDiff,
|
|
5
|
-
ShardEntry,
|
|
6
|
-
ShardEntryValueValue,
|
|
7
|
-
ShardEntryLinkValue,
|
|
8
|
-
ShardEntryLinkAndValueValue,
|
|
9
|
-
ShardConfig,
|
|
10
|
-
ShardOptions,
|
|
11
|
-
ShardBlockView,
|
|
12
|
-
BlockFetcher
|
|
13
|
-
} from '../api.js'
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
UnknownLink,
|
|
17
|
-
ShardLink,
|
|
18
|
-
ShardDiff,
|
|
19
|
-
ShardEntry,
|
|
20
|
-
ShardEntryValueValue,
|
|
21
|
-
ShardEntryLinkValue,
|
|
22
|
-
ShardEntryLinkAndValueValue,
|
|
23
|
-
ShardConfig,
|
|
24
|
-
ShardOptions,
|
|
25
|
-
ShardBlockView,
|
|
26
|
-
BlockFetcher
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface BatcherShard extends ShardConfig {
|
|
30
|
-
base?: ShardBlockView
|
|
31
|
-
entries: BatcherShardEntry[]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface BatcherShardInit extends ShardOptions {
|
|
35
|
-
base?: ShardBlockView
|
|
36
|
-
entries?: BatcherShardEntry[]
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type BatcherShardEntry = [
|
|
40
|
-
key: string,
|
|
41
|
-
value: ShardEntryValueValue | ShardEntryLinkValue | ShardEntryLinkAndValueValue | ShardEntryShardValue | ShardEntryShardAndValueValue
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
export type ShardEntryShardValue = [BatcherShard]
|
|
45
|
-
|
|
46
|
-
export type ShardEntryShardAndValueValue = [BatcherShard, UnknownLink]
|
|
47
|
-
|
|
48
|
-
export interface Batcher {
|
|
49
|
-
/**
|
|
50
|
-
* Put a value (a CID) for the given key. If the key exists it's value is
|
|
51
|
-
* overwritten.
|
|
52
|
-
*/
|
|
53
|
-
put (key: string, value: UnknownLink): Promise<void>
|
|
54
|
-
/**
|
|
55
|
-
* Encode all altered shards in the batch and return the new root CID and
|
|
56
|
-
* difference blocks.
|
|
57
|
-
*/
|
|
58
|
-
commit (): Promise<{ root: ShardLink } & ShardDiff>
|
|
59
|
-
}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import * as API from './api.js'
|
|
3
|
-
import { ShardFetcher, isPrintableASCII } from '../shard.js'
|
|
4
|
-
import * as Shard from '../shard.js'
|
|
5
|
-
import * as BatcherShard from './shard.js'
|
|
6
|
-
|
|
7
|
-
/** @implements {API.Batcher} */
|
|
8
|
-
class Batcher {
|
|
9
|
-
#committed = false
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {object} init
|
|
13
|
-
* @param {API.BlockFetcher} init.blocks Block storage.
|
|
14
|
-
* @param {API.BatcherShardEntry[]} init.entries The entries in this shard.
|
|
15
|
-
* @param {string} init.prefix Key prefix.
|
|
16
|
-
* @param {number} init.version Shard compatibility version.
|
|
17
|
-
* @param {string} init.keyChars Characters allowed in keys, referring to a known character set.
|
|
18
|
-
* @param {number} init.maxKeySize Max key size in bytes.
|
|
19
|
-
* @param {API.ShardBlockView} init.base Original shard this batcher is based on.
|
|
20
|
-
*/
|
|
21
|
-
constructor ({ blocks, entries, prefix, version, keyChars, maxKeySize, base }) {
|
|
22
|
-
this.blocks = blocks
|
|
23
|
-
this.prefix = prefix
|
|
24
|
-
this.entries = [...entries]
|
|
25
|
-
this.base = base
|
|
26
|
-
this.version = version
|
|
27
|
-
this.keyChars = keyChars
|
|
28
|
-
this.maxKeySize = maxKeySize
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @param {string} key The key of the value to put.
|
|
33
|
-
* @param {API.UnknownLink} value The value to put.
|
|
34
|
-
* @returns {Promise<void>}
|
|
35
|
-
*/
|
|
36
|
-
async put (key, value) {
|
|
37
|
-
if (this.#committed) throw new BatchCommittedError()
|
|
38
|
-
return put(this.blocks, this, key, value)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async commit () {
|
|
42
|
-
if (this.#committed) throw new BatchCommittedError()
|
|
43
|
-
this.#committed = true
|
|
44
|
-
return commit(this)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {object} init
|
|
49
|
-
* @param {API.BlockFetcher} init.blocks Block storage.
|
|
50
|
-
* @param {API.ShardLink} init.link CID of the shard block.
|
|
51
|
-
*/
|
|
52
|
-
static async create ({ blocks, link }) {
|
|
53
|
-
const shards = new ShardFetcher(blocks)
|
|
54
|
-
const base = await shards.get(link)
|
|
55
|
-
return new Batcher({ blocks, base, ...base.value })
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @param {API.BlockFetcher} blocks
|
|
61
|
-
* @param {API.BatcherShard} shard
|
|
62
|
-
* @param {string} key The key of the value to put.
|
|
63
|
-
* @param {API.UnknownLink} value The value to put.
|
|
64
|
-
* @returns {Promise<void>}
|
|
65
|
-
*/
|
|
66
|
-
export const put = async (blocks, shard, key, value) => {
|
|
67
|
-
if (shard.keyChars !== Shard.KeyCharsASCII) {
|
|
68
|
-
throw new Error(`unsupported key character set: ${shard.keyChars}`)
|
|
69
|
-
}
|
|
70
|
-
if (!isPrintableASCII(key)) {
|
|
71
|
-
throw new Error('key contains non-ASCII characters')
|
|
72
|
-
}
|
|
73
|
-
// ensure utf8 encoded key is smaller than max
|
|
74
|
-
if (new TextEncoder().encode(key).length > shard.maxKeySize) {
|
|
75
|
-
throw new Error(`UTF-8 encoded key exceeds max size of ${shard.maxKeySize} bytes`)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const shards = new ShardFetcher(blocks)
|
|
79
|
-
const dest = await traverse(shards, shard, key)
|
|
80
|
-
if (dest.shard !== shard) {
|
|
81
|
-
shard = dest.shard
|
|
82
|
-
key = dest.key
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** @type {API.BatcherShardEntry} */
|
|
86
|
-
let entry = [dest.key, value]
|
|
87
|
-
let targetEntries = [...dest.shard.entries]
|
|
88
|
-
|
|
89
|
-
for (const [i, e] of targetEntries.entries()) {
|
|
90
|
-
const [k, v] = e
|
|
91
|
-
|
|
92
|
-
// is this just a replace?
|
|
93
|
-
if (k === dest.key) break
|
|
94
|
-
|
|
95
|
-
// do we need to shard this entry?
|
|
96
|
-
const shortest = k.length < dest.key.length ? k : dest.key
|
|
97
|
-
const other = shortest === k ? dest.key : k
|
|
98
|
-
let common = ''
|
|
99
|
-
for (const char of shortest) {
|
|
100
|
-
const next = common + char
|
|
101
|
-
if (!other.startsWith(next)) break
|
|
102
|
-
common = next
|
|
103
|
-
}
|
|
104
|
-
if (common.length) {
|
|
105
|
-
/** @type {API.ShardEntry[]} */
|
|
106
|
-
let entries = []
|
|
107
|
-
|
|
108
|
-
// if the existing entry key or new key is equal to the common prefix,
|
|
109
|
-
// then the existing value / new value needs to persist in the parent
|
|
110
|
-
// shard. Otherwise they persist in this new shard.
|
|
111
|
-
if (common !== dest.key) {
|
|
112
|
-
entries = Shard.putEntry(entries, [dest.key.slice(common.length), value])
|
|
113
|
-
}
|
|
114
|
-
if (common !== k) {
|
|
115
|
-
entries = Shard.putEntry(entries, asShardEntry([k.slice(common.length), v]))
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
let child = BatcherShard.create({
|
|
119
|
-
...Shard.configure(dest.shard),
|
|
120
|
-
prefix: dest.shard.prefix + common,
|
|
121
|
-
entries
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
// need to spread as access by index does not consider utf-16 surrogates
|
|
125
|
-
const commonChars = [...common]
|
|
126
|
-
|
|
127
|
-
// create parent shards for each character of the common prefix
|
|
128
|
-
for (let i = commonChars.length - 1; i > 0; i--) {
|
|
129
|
-
/** @type {API.ShardEntryShardValue | API.ShardEntryShardAndValueValue} */
|
|
130
|
-
let parentValue
|
|
131
|
-
// if the first iteration and the existing entry key is equal to the
|
|
132
|
-
// common prefix, then existing value needs to persist in this parent
|
|
133
|
-
if (i === commonChars.length - 1 && common === k) {
|
|
134
|
-
if (Array.isArray(v)) throw new Error('found a shard link when expecting a value')
|
|
135
|
-
parentValue = [child, v]
|
|
136
|
-
} else if (i === commonChars.length - 1 && common === dest.key) {
|
|
137
|
-
parentValue = [child, value]
|
|
138
|
-
} else {
|
|
139
|
-
parentValue = [child]
|
|
140
|
-
}
|
|
141
|
-
const parent = BatcherShard.create({
|
|
142
|
-
...Shard.configure(dest.shard),
|
|
143
|
-
prefix: dest.shard.prefix + commonChars.slice(0, i).join(''),
|
|
144
|
-
entries: [[commonChars[i], parentValue]]
|
|
145
|
-
})
|
|
146
|
-
child = parent
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// remove the sharded entry
|
|
150
|
-
targetEntries.splice(i, 1)
|
|
151
|
-
|
|
152
|
-
// create the entry that will be added to target
|
|
153
|
-
if (commonChars.length === 1 && common === k) {
|
|
154
|
-
if (Array.isArray(v)) throw new Error('found a shard link when expecting a value')
|
|
155
|
-
entry = [commonChars[0], [child, v]]
|
|
156
|
-
} else if (commonChars.length === 1 && common === dest.key) {
|
|
157
|
-
entry = [commonChars[0], [child, value]]
|
|
158
|
-
} else {
|
|
159
|
-
entry = [commonChars[0], [child]]
|
|
160
|
-
}
|
|
161
|
-
break
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
shard.entries = Shard.putEntry(asShardEntries(targetEntries), asShardEntry(entry))
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Traverse from the passed shard through to the correct shard for the passed
|
|
170
|
-
* key.
|
|
171
|
-
*
|
|
172
|
-
* @param {ShardFetcher} shards
|
|
173
|
-
* @param {API.BatcherShard} shard
|
|
174
|
-
* @param {string} key
|
|
175
|
-
* @returns {Promise<{ shard: API.BatcherShard, key: string }>}
|
|
176
|
-
*/
|
|
177
|
-
export const traverse = async (shards, shard, key) => {
|
|
178
|
-
for (let i = 0; i < shard.entries.length; i++) {
|
|
179
|
-
const [k, v] = shard.entries[i]
|
|
180
|
-
if (key <= k) break
|
|
181
|
-
if (key.startsWith(k) && Array.isArray(v)) {
|
|
182
|
-
if (Shard.isShardLink(v[0])) {
|
|
183
|
-
const blk = await shards.get(v[0])
|
|
184
|
-
const batcher = BatcherShard.create({ base: blk, ...blk.value })
|
|
185
|
-
shard.entries[i] = [k, v[1] == null ? [batcher] : [batcher, v[1]]]
|
|
186
|
-
return traverse(shards, batcher, key.slice(k.length))
|
|
187
|
-
}
|
|
188
|
-
return traverse(shards, v[0], key.slice(k.length))
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return { shard, key }
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Encode all altered shards in the batch and return the new root CID and
|
|
196
|
-
* difference blocks.
|
|
197
|
-
*
|
|
198
|
-
* @param {API.BatcherShard} shard
|
|
199
|
-
*/
|
|
200
|
-
export const commit = async shard => {
|
|
201
|
-
/** @type {API.ShardBlockView[]} */
|
|
202
|
-
const additions = []
|
|
203
|
-
/** @type {API.ShardBlockView[]} */
|
|
204
|
-
const removals = []
|
|
205
|
-
|
|
206
|
-
/** @type {API.ShardEntry[]} */
|
|
207
|
-
const entries = []
|
|
208
|
-
for (const entry of shard.entries) {
|
|
209
|
-
if (Array.isArray(entry[1]) && !Shard.isShardLink(entry[1][0])) {
|
|
210
|
-
const result = await commit(entry[1][0])
|
|
211
|
-
entries.push([
|
|
212
|
-
entry[0],
|
|
213
|
-
entry[1][1] == null ? [result.root] : [result.root, entry[1][1]]
|
|
214
|
-
])
|
|
215
|
-
additions.push(...result.additions)
|
|
216
|
-
removals.push(...result.removals)
|
|
217
|
-
} else {
|
|
218
|
-
entries.push(asShardEntry(entry))
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const block = await Shard.encodeBlock(Shard.withEntries(entries, shard))
|
|
223
|
-
additions.push(block)
|
|
224
|
-
|
|
225
|
-
if (shard.base && shard.base.cid.toString() === block.cid.toString()) {
|
|
226
|
-
return { root: block.cid, additions: [], removals: [] }
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (shard.base) removals.push(shard.base)
|
|
230
|
-
|
|
231
|
-
return { root: block.cid, additions, removals }
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/** @param {API.BatcherShardEntry[]} entries */
|
|
235
|
-
const asShardEntries = entries => /** @type {API.ShardEntry[]} */ (entries)
|
|
236
|
-
|
|
237
|
-
/** @param {API.BatcherShardEntry} entry */
|
|
238
|
-
const asShardEntry = entry => /** @type {API.ShardEntry} */ (entry)
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* @param {API.BlockFetcher} blocks Bucket block storage.
|
|
242
|
-
* @param {API.ShardLink} root CID of the root shard block.
|
|
243
|
-
* @returns {Promise<API.Batcher>}
|
|
244
|
-
*/
|
|
245
|
-
export const create = (blocks, root) => Batcher.create({ blocks, link: root })
|
|
246
|
-
|
|
247
|
-
export class BatchCommittedError extends Error {
|
|
248
|
-
/**
|
|
249
|
-
* @param {string} [message]
|
|
250
|
-
* @param {ErrorOptions} [options]
|
|
251
|
-
*/
|
|
252
|
-
constructor (message, options) {
|
|
253
|
-
super(message ?? 'batch already committed', options)
|
|
254
|
-
this.code = BatchCommittedError.code
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
static code = 'ERR_BATCH_COMMITTED'
|
|
258
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import * as API from './api.js'
|
|
3
|
-
import { configure } from '../shard.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {API.BatcherShardInit} [init]
|
|
7
|
-
* @returns {API.BatcherShard}
|
|
8
|
-
*/
|
|
9
|
-
export const create = init => ({
|
|
10
|
-
base: init?.base,
|
|
11
|
-
entries: [...(init?.entries ?? [])],
|
|
12
|
-
...configure(init)
|
|
13
|
-
})
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import * as API from './api.js'
|
|
3
|
-
import { parse } from 'multiformats/link'
|
|
4
|
-
|
|
5
|
-
/** @implements {API.BlockFetcher} */
|
|
6
|
-
export class MemoryBlockstore {
|
|
7
|
-
/** @type {Map<string, Uint8Array>} */
|
|
8
|
-
#blocks = new Map()
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {Array<import('multiformats').Block>} [blocks]
|
|
12
|
-
*/
|
|
13
|
-
constructor (blocks) {
|
|
14
|
-
if (blocks) {
|
|
15
|
-
this.#blocks = new Map(blocks.map(b => [b.cid.toString(), b.bytes]))
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** @type {API.BlockFetcher['get']} */
|
|
20
|
-
async get (cid) {
|
|
21
|
-
const bytes = this.#blocks.get(cid.toString())
|
|
22
|
-
if (!bytes) return
|
|
23
|
-
return { cid, bytes }
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {API.UnknownLink} cid
|
|
28
|
-
* @param {Uint8Array} bytes
|
|
29
|
-
*/
|
|
30
|
-
async put (cid, bytes) {
|
|
31
|
-
this.#blocks.set(cid.toString(), bytes)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {API.UnknownLink} cid
|
|
36
|
-
* @param {Uint8Array} bytes
|
|
37
|
-
*/
|
|
38
|
-
putSync (cid, bytes) {
|
|
39
|
-
this.#blocks.set(cid.toString(), bytes)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** @param {API.UnknownLink} cid */
|
|
43
|
-
async delete (cid) {
|
|
44
|
-
this.#blocks.delete(cid.toString())
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** @param {API.UnknownLink} cid */
|
|
48
|
-
deleteSync (cid) {
|
|
49
|
-
this.#blocks.delete(cid.toString())
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
* entries () {
|
|
53
|
-
for (const [str, bytes] of this.#blocks) {
|
|
54
|
-
yield { cid: parse(str), bytes }
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export class MultiBlockFetcher {
|
|
60
|
-
/** @type {API.BlockFetcher[]} */
|
|
61
|
-
#fetchers
|
|
62
|
-
|
|
63
|
-
/** @param {API.BlockFetcher[]} fetchers */
|
|
64
|
-
constructor (...fetchers) {
|
|
65
|
-
this.#fetchers = fetchers
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** @type {API.BlockFetcher['get']} */
|
|
69
|
-
async get (link) {
|
|
70
|
-
for (const f of this.#fetchers) {
|
|
71
|
-
const v = await f.get(link)
|
|
72
|
-
if (v) return v
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Link, BlockView } from 'multiformats'
|
|
2
|
-
|
|
3
|
-
export { BlockFetcher } from '../api.js'
|
|
4
|
-
|
|
5
|
-
export type EventLink<T> = Link<EventView<T>>
|
|
6
|
-
|
|
7
|
-
export interface EventView<T> {
|
|
8
|
-
parents: EventLink<T>[]
|
|
9
|
-
data: T
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface EventBlockView<T> extends BlockView<EventView<T>> {}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Block, encode, decode } from 'multiformats/block'
|
|
2
|
-
import { sha256 } from 'multiformats/hashes/sha2'
|
|
3
|
-
import * as cbor from "@fireproof/vendor/@ipld/dag-cbor"
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
import * as API from './api.js'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Advance the clock by adding an event.
|
|
9
|
-
*
|
|
10
|
-
* @template T
|
|
11
|
-
* @param {API.BlockFetcher} blocks Block storage.
|
|
12
|
-
* @param {API.EventLink<T>[]} head The head of the clock.
|
|
13
|
-
* @param {API.EventLink<T>} event The event to add.
|
|
14
|
-
*/
|
|
15
|
-
export const advance = async (blocks, head, event) => {
|
|
16
|
-
const events = new EventFetcher(blocks)
|
|
17
|
-
const headmap = new Map(head.map(cid => [cid.toString(), cid]))
|
|
18
|
-
if (headmap.has(event.toString())) return head
|
|
19
|
-
|
|
20
|
-
// does event contain the clock?
|
|
21
|
-
let changed = false
|
|
22
|
-
for (const cid of head) {
|
|
23
|
-
if (await contains(events, event, cid)) {
|
|
24
|
-
headmap.delete(cid.toString())
|
|
25
|
-
headmap.set(event.toString(), event)
|
|
26
|
-
changed = true
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (changed) {
|
|
30
|
-
return [...headmap.values()]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// does clock contain the event?
|
|
34
|
-
for (const p of head) {
|
|
35
|
-
if (await contains(events, p, event)) {
|
|
36
|
-
return head
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return head.concat(event)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @template T
|
|
45
|
-
* @extends {Block<API.EventView<T>, typeof cbor.code, typeof sha256.code, 1>}
|
|
46
|
-
* @implements {API.EventBlockView<T>}
|
|
47
|
-
*/
|
|
48
|
-
export class EventBlock extends Block {
|
|
49
|
-
/**
|
|
50
|
-
* @param {object} config
|
|
51
|
-
* @param {API.EventLink<T>} config.cid
|
|
52
|
-
* @param {Event} config.value
|
|
53
|
-
* @param {Uint8Array} config.bytes
|
|
54
|
-
* @param {string} config.prefix
|
|
55
|
-
*/
|
|
56
|
-
constructor ({ cid, value, bytes, prefix }) {
|
|
57
|
-
// @ts-expect-error
|
|
58
|
-
super({ cid, value, bytes })
|
|
59
|
-
this.prefix = prefix
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @template T
|
|
64
|
-
* @param {T} data
|
|
65
|
-
* @param {API.EventLink<T>[]} [parents]
|
|
66
|
-
*/
|
|
67
|
-
static create (data, parents) {
|
|
68
|
-
return encodeEventBlock({ data, parents: parents ?? [] })
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** @template T */
|
|
73
|
-
export class EventFetcher {
|
|
74
|
-
/** @param {API.BlockFetcher} blocks */
|
|
75
|
-
constructor (blocks) {
|
|
76
|
-
/** @private */
|
|
77
|
-
this._blocks = blocks
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @param {API.EventLink<T>} link
|
|
82
|
-
* @returns {Promise<API.EventBlockView<T>>}
|
|
83
|
-
*/
|
|
84
|
-
async get (link) {
|
|
85
|
-
const block = await this._blocks.get(link)
|
|
86
|
-
if (!block) throw new Error(`missing block: ${link}`)
|
|
87
|
-
return decodeEventBlock(block.bytes)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @template T
|
|
93
|
-
* @param {API.EventView<T>} value
|
|
94
|
-
* @returns {Promise<API.EventBlockView<T>>}
|
|
95
|
-
*/
|
|
96
|
-
export const encodeEventBlock = async (value) => {
|
|
97
|
-
// TODO: sort parents
|
|
98
|
-
const { cid, bytes } = await encode({ value, codec: cbor, hasher: sha256 })
|
|
99
|
-
// @ts-expect-error
|
|
100
|
-
return new Block({ cid, value, bytes })
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @template T
|
|
105
|
-
* @param {Uint8Array} bytes
|
|
106
|
-
* @returns {Promise<API.EventBlockView<T>>}
|
|
107
|
-
*/
|
|
108
|
-
export const decodeEventBlock = async (bytes) => {
|
|
109
|
-
const { cid, value } = await decode({ bytes, codec: cbor, hasher: sha256 })
|
|
110
|
-
// @ts-expect-error
|
|
111
|
-
return new Block({ cid, value, bytes })
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Returns true if event "a" contains event "b". Breadth first search.
|
|
116
|
-
* @template T
|
|
117
|
-
* @param {EventFetcher<T>} events
|
|
118
|
-
* @param {API.EventLink<T>} a
|
|
119
|
-
* @param {API.EventLink<T>} b
|
|
120
|
-
*/
|
|
121
|
-
const contains = async (events, a, b) => {
|
|
122
|
-
if (a.toString() === b.toString()) return true
|
|
123
|
-
const [{ value: aevent }, { value: bevent }] = await Promise.all([events.get(a), events.get(b)])
|
|
124
|
-
const links = [...aevent.parents]
|
|
125
|
-
const seen = new Set()
|
|
126
|
-
while (links.length) {
|
|
127
|
-
const link = links.shift()
|
|
128
|
-
if (!link) break
|
|
129
|
-
if (link.toString() === b.toString()) return true
|
|
130
|
-
// if any of b's parents are this link, then b cannot exist in any of the
|
|
131
|
-
// tree below, since that would create a cycle.
|
|
132
|
-
if (bevent.parents.some(p => link.toString() === p.toString())) continue
|
|
133
|
-
if (seen.has(link.toString())) continue
|
|
134
|
-
seen.add(link.toString())
|
|
135
|
-
const { value: event } = await events.get(link)
|
|
136
|
-
links.push(...event.parents)
|
|
137
|
-
}
|
|
138
|
-
return false
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* @template T
|
|
143
|
-
* @param {API.BlockFetcher} blocks Block storage.
|
|
144
|
-
* @param {API.EventLink<T>[]} head
|
|
145
|
-
* @param {object} [options]
|
|
146
|
-
* @param {(b: API.EventBlockView<T>) => string} [options.renderNodeLabel]
|
|
147
|
-
*/
|
|
148
|
-
export const vis = async function * (blocks, head, options = {}) {
|
|
149
|
-
const renderNodeLabel = options.renderNodeLabel ?? (b => shortLink(b.cid))
|
|
150
|
-
const events = new EventFetcher(blocks)
|
|
151
|
-
yield 'digraph clock {'
|
|
152
|
-
yield ' node [shape=point fontname="Courier"]; head;'
|
|
153
|
-
const hevents = await Promise.all(head.map(link => events.get(link)))
|
|
154
|
-
/** @type {import('multiformats').Link<API.EventView<any>>[]} */
|
|
155
|
-
const links = []
|
|
156
|
-
const nodes = new Set()
|
|
157
|
-
for (const e of hevents) {
|
|
158
|
-
nodes.add(e.cid.toString())
|
|
159
|
-
yield ` node [shape=oval fontname="Courier"]; ${e.cid} [label="${renderNodeLabel(e)}"];`
|
|
160
|
-
yield ` head -> ${e.cid};`
|
|
161
|
-
for (const p of e.value.parents) {
|
|
162
|
-
yield ` ${e.cid} -> ${p};`
|
|
163
|
-
}
|
|
164
|
-
links.push(...e.value.parents)
|
|
165
|
-
}
|
|
166
|
-
while (links.length) {
|
|
167
|
-
const link = links.shift()
|
|
168
|
-
if (!link) break
|
|
169
|
-
if (nodes.has(link.toString())) continue
|
|
170
|
-
nodes.add(link.toString())
|
|
171
|
-
const block = await events.get(link)
|
|
172
|
-
yield ` node [shape=oval]; ${link} [label="${renderNodeLabel(block)}" fontname="Courier"];`
|
|
173
|
-
for (const p of block.value.parents) {
|
|
174
|
-
yield ` ${link} -> ${p};`
|
|
175
|
-
}
|
|
176
|
-
links.push(...block.value.parents)
|
|
177
|
-
}
|
|
178
|
-
yield '}'
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** @param {import('multiformats').UnknownLink} l */
|
|
182
|
-
const shortLink = l => `${String(l).slice(0, 4)}..${String(l).slice(-4)}`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|