@fireproof/vendor 0.0.0-smoke → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +155 -8
- package/src/@ipld/car/{car/README.md → README.md} +229 -175
- package/src/@ipld/car/dist/src/reader.d.ts.map +1 -0
- package/src/@ipld/car/{car/src → src}/reader.js +19 -2
- package/src/cborg/cborg/{lib/bin.js → bin.js} +2 -2
- package/src/cborg/cborg/common.js +28 -0
- package/{patched/cborg/lib → src/cborg/cborg}/decode.js +24 -22
- package/src/cborg/cborg/{lib/diagnostic.js → diagnostic.js} +6 -4
- package/{patched/cborg/lib → src/cborg/cborg}/diagnostic_test.js +1 -1
- package/src/cborg/cborg/{lib/encode.js → encode.js} +23 -21
- package/{patched/cborg/cborg.js → src/cborg/cborg/index.js} +12 -10
- package/src/cborg/cborg/{lib/length.js → length.js} +3 -2
- package/{patched → src}/cborg/interface.ts +7 -4
- package/src/cborg/{cborg/lib/json → json}/decode.js +25 -25
- package/src/cborg/{cborg/lib/json → json}/encode.js +19 -16
- package/src/cborg/{cborg/package.json → package.json} +15 -11
- package/src/cborg/{cborg/taglib.js → taglib.js} +3 -1
- package/src/cborg/{cborg/test → test}/common.js +1 -1
- package/{patched → src}/cborg/test/noop-bin-test.js +1 -1
- package/{patched → src}/cborg/test/test-0uint.js +2 -2
- package/src/cborg/{cborg/test → test}/test-1negint.js +2 -2
- package/src/cborg/{cborg/test → test}/test-2bytes.js +2 -2
- package/src/cborg/{cborg/test → test}/test-3string.js +2 -2
- package/{patched → src}/cborg/test/test-4array.js +2 -2
- package/{patched → src}/cborg/test/test-5map.js +2 -2
- package/src/cborg/{cborg/test → test}/test-6tag.js +2 -3
- package/{patched → src}/cborg/test/test-7float.js +2 -2
- package/{patched → src}/cborg/test/test-bl.js +1 -1
- package/src/cborg/{cborg/test → test}/test-cbor-vectors.js +2 -2
- package/src/cborg/{cborg/test → test}/test-decode-errors.js +2 -2
- package/{patched → src}/cborg/test/test-fuzz.js +1 -1
- package/src/cborg/{cborg/test → test}/test-json.js +25 -25
- package/{patched → src}/cborg/test/test-length.js +3 -3
- package/src/cborg/{cborg/test → test}/test-partial.js +2 -2
- package/src/cborg/{cborg/tsconfig.json → tsconfig.json} +5 -2
- package/{patched/cborg/types/lib → src/cborg/types/cborg}/decode.d.ts +5 -3
- package/src/cborg/types/cborg/decode.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/cborg}/encode.d.ts +4 -3
- package/src/cborg/types/cborg/encode.d.ts.map +1 -0
- package/src/cborg/types/cborg/index.d.ts +26 -0
- package/src/cborg/types/cborg/index.d.ts.map +1 -0
- package/src/cborg/types/cborg/is.d.ts.map +1 -0
- package/src/cborg/{cborg/types → types}/interface.d.ts +6 -4
- package/src/cborg/types/interface.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types}/json/decode.d.ts +7 -7
- package/src/cborg/types/json/decode.d.ts.map +1 -0
- package/src/cborg/types/json/encode.d.ts +11 -0
- package/src/cborg/types/json/encode.d.ts.map +1 -0
- package/src/cborg/types/json/json.d.ts.map +1 -0
- package/{patched → src}/cborg/types/taglib.d.ts +1 -1
- package/{patched → src}/cborg/types/taglib.d.ts.map +1 -1
- package/src/cborg/types/tsconfig.tsbuildinfo +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/0uint.d.ts +6 -4
- package/src/cborg/types/utils/0uint.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/1negint.d.ts +4 -3
- package/src/cborg/types/utils/1negint.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/2bytes.d.ts +5 -4
- package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/3string.d.ts +1 -1
- package/src/cborg/types/utils/3string.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/4array.d.ts +3 -2
- package/src/cborg/types/utils/4array.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/5map.d.ts +3 -2
- package/src/cborg/types/utils/5map.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/6tag.d.ts +4 -3
- package/src/cborg/types/utils/6tag.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/7float.d.ts +2 -2
- package/src/cborg/types/utils/7float.d.ts.map +1 -0
- package/src/cborg/types/utils/bl.d.ts.map +1 -0
- package/src/cborg/types/utils/byte-utils.d.ts.map +1 -0
- package/src/cborg/types/utils/common.d.ts +8 -0
- package/src/cborg/types/utils/common.d.ts.map +1 -0
- package/src/cborg/types/utils/index.d.ts +13 -0
- package/src/cborg/types/utils/index.d.ts.map +1 -0
- package/src/cborg/types/utils/jump.d.ts +16 -0
- package/src/cborg/types/utils/jump.d.ts.map +1 -0
- package/src/cborg/types/utils/token.d.ts.map +1 -0
- package/src/cborg/{cborg/lib → utils}/0uint.js +16 -14
- package/src/cborg/{cborg/lib → utils}/1negint.js +5 -5
- package/src/cborg/{cborg/lib → utils}/2bytes.js +16 -14
- package/src/cborg/{cborg/lib → utils}/3string.js +4 -4
- package/src/cborg/{cborg/lib → utils}/4array.js +7 -6
- package/{patched/cborg/lib → src/cborg/utils}/5map.js +6 -6
- package/{patched/cborg/lib → src/cborg/utils}/6tag.js +4 -3
- package/src/cborg/{cborg/lib → utils}/7float.js +23 -21
- package/{patched/cborg/lib → src/cborg/utils}/bl.js +1 -1
- package/src/cborg/utils/common.js +11 -0
- package/src/cborg/utils/index.js +12 -0
- package/src/cborg/utils/jump.js +222 -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-APACHE +0 -5
- package/patched/@ipld/dag-json/LICENSE-MIT +0 -19
- package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
- 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/cborg-4.2.7.tgz +0 -0
- package/patched/cborg/example-json.js +0 -6
- package/patched/cborg/example.js +0 -5
- 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/7float.js +0 -308
- package/patched/cborg/lib/bin.js +0 -189
- package/patched/cborg/lib/common.js +0 -27
- package/patched/cborg/lib/diagnostic.js +0 -156
- package/patched/cborg/lib/encode.js +0 -464
- package/patched/cborg/lib/json/decode.js +0 -462
- package/patched/cborg/lib/json/encode.js +0 -299
- package/patched/cborg/lib/jump.js +0 -209
- package/patched/cborg/lib/length.js +0 -61
- 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/common.js +0 -18
- 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-6tag.js +0 -85
- 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-json.js +0 -219
- 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/interface.d.ts +0 -47
- package/patched/cborg/types/interface.d.ts.map +0 -1
- package/patched/cborg/types/lib/0uint.d.ts.map +0 -1
- 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.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.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.map +0 -1
- 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.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.map +0 -1
- package/patched/cborg/types/lib/is.d.ts.map +0 -1
- 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.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.map +0 -1
- package/patched/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/@ipld/car/car/dist/src/reader.d.ts.map +0 -1
- package/src/@ipld/car/car/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-json/dag-json/README.md +0 -58
- 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/@web3-storage/pail/pail/node_modules/.bin/pail +0 -17
- 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/interface.ts +0 -56
- package/src/cborg/cborg/lib/5map.js +0 -113
- package/src/cborg/cborg/lib/6tag.js +0 -80
- 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_test.js +0 -117
- package/src/cborg/cborg/lib/is.js +0 -106
- package/src/cborg/cborg/lib/json/json.js +0 -4
- package/src/cborg/cborg/lib/jump.js +0 -209
- package/src/cborg/cborg/lib/token.js +0 -76
- package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
- package/src/cborg/cborg/test/appendix_a.js +0 -647
- 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-4array.js +0 -93
- package/src/cborg/cborg/test/test-5map.js +0 -284
- 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-fuzz.js +0 -42
- package/src/cborg/cborg/test/test-length.js +0 -65
- 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.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.map +0 -1
- 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.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.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/{patched/@ipld/dag-json → src/@ipld/car}/LICENSE +0 -0
- /package/src/@ipld/car/{car/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/api.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/api.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-decoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-decoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-writer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-writer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/coding.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/coding.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder-common.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder-common.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/encoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/encoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/header-validator.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/header-validator.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator-channel.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator-channel.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/package.json → package.json} +0 -0
- /package/src/@ipld/car/{car/src → src}/api.ts +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-decoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-reader.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-writer.js +0 -0
- /package/src/@ipld/car/{car/src → src}/coding.ts +0 -0
- /package/src/@ipld/car/{car/src → src}/decoder-common.js +0 -0
- /package/src/@ipld/car/{car/src → src}/decoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/encoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/header-validator.js +0 -0
- /package/src/@ipld/car/{car/src → src}/header.ipldsch +0 -0
- /package/src/@ipld/car/{car/src → src}/index-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/index.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexed-reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexed-reader.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexer.js +0 -0
- /package/src/@ipld/car/{car/src → src}/iterator-channel.js +0 -0
- /package/src/@ipld/car/{car/src → src}/iterator.js +0 -0
- /package/src/@ipld/car/{car/src → src}/reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/writer-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/writer.js +0 -0
- /package/src/@ipld/{car/car → dag-cbor}/LICENSE +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/README.md → README.md} +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/package.json → package.json} +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/src → src}/index.js +0 -0
- /package/src/@ipld/{dag-cbor/dag-cbor → dag-json}/LICENSE +0 -0
- /package/{patched → src}/@ipld/dag-json/README.md +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/src/index.d.ts.map +0 -0
- /package/{patched → src}/@ipld/dag-json/package.json +0 -0
- /package/src/@ipld/dag-json/{dag-json/src → src}/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/LICENSE.md → LICENSE.md} +0 -0
- /package/src/@web3-storage/pail/{pail/README.md → README.md} +0 -0
- /package/src/@web3-storage/pail/{pail/cli.js → cli.js} +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/shard.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/shard.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/block.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/block.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/diff.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/diff.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/merge.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/merge.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/shard.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/shard.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/tsconfig.tsbuildinfo +0 -0
- /package/src/@web3-storage/pail/{pail/package.json → package.json} +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/shard.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/block.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/diff.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/merge.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/shard.js +0 -0
- /package/{patched → src}/cborg/.github/dependabot.yml +0 -0
- /package/{patched → src}/cborg/.github/workflows/test-and-release.yml +0 -0
- /package/{patched → src}/cborg/CHANGELOG.md +0 -0
- /package/{patched → src}/cborg/LICENSE +0 -0
- /package/{patched → src}/cborg/README.md +0 -0
- /package/{patched → src}/cborg/bench/bench.js +0 -0
- /package/{patched → src}/cborg/bench/json.js +0 -0
- /package/{patched → src}/cborg/bench/package.json +0 -0
- /package/{patched/cborg/lib → src/cborg/cborg}/is.js +0 -0
- /package/{patched → src}/cborg/example-bytestrings.js +0 -0
- /package/src/cborg/{cborg/example-json.js → example-json.js} +0 -0
- /package/src/cborg/{cborg/example.js → example.js} +0 -0
- /package/{patched/cborg/lib → src/cborg}/json/json.js +0 -0
- /package/{patched → src}/cborg/test/appendix_a.js +0 -0
- /package/{patched → src}/cborg/test/node-test-bin.js +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/cborg}/is.d.ts +0 -0
- /package/{patched → src}/cborg/types/example.d.ts +0 -0
- /package/{patched → src}/cborg/types/example.d.ts.map +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types}/json/json.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/bl.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/byte-utils.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/token.d.ts +0 -0
- /package/{patched/cborg/lib → src/cborg/utils}/byte-utils.js +0 -0
- /package/{patched/cborg/lib → src/cborg/utils}/token.js +0 -0
- /package/src/{@ipld/dag-json/dag-json → ipfs-unixfs-exporter}/LICENSE +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/README.md → README.md} +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/index.min.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/typedoc-urls.json +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/package.json → package.json} +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/errors.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/dag-cbor.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/dag-json.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/identity.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/json.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/raw.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/directory.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/file.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/raw.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/extract-data-from-block.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/find-cid-in-shard.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/resolve-object-path.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/validate-offset-and-length.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/reader.js"],"names":[],"mappings":";AA6BA;;;GAGG;AACH;IACE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,mBARW,GAAG,QAAQ,CAAC,UAAU,GAAG,MAAM,cAG/B,UAAU,GAGR,QAAQ,KAAK,CAAC,CAiB1B;CACF;AAED,8BAA4B;oBAnEf,OAAO,OAAO,EAAE,KAAK;yBACrB,OAAO,OAAO,EAAE,UAAU;6BAC1B,OAAO,OAAO,EAAE,SAAS;8CALQ,qBAAqB;eAFpD,IAAI"}
|
|
@@ -8,7 +8,24 @@ import { CarReader as BrowserCarReader } from './reader-browser.js'
|
|
|
8
8
|
* @typedef {import('./api').CarReader} CarReaderIface
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @description not happy with typing here, but it's needed for the `promisify(fs.read)` function.
|
|
13
|
+
* @type {any}
|
|
14
|
+
*/
|
|
15
|
+
let _fsReadFn
|
|
16
|
+
/**
|
|
17
|
+
* @description This function is needed not to initialize the `fs.read` on load time. To run in cf workers without polyfill.
|
|
18
|
+
* @param {number} fd
|
|
19
|
+
* @param {Uint8Array} buffer
|
|
20
|
+
* @param {number} offset
|
|
21
|
+
* @param {number} length
|
|
22
|
+
* @param {number} position
|
|
23
|
+
* @returns {Promise<{ bytesRead: number, buffer: Uint8Array }>}
|
|
24
|
+
*/
|
|
25
|
+
function fsread (fd, buffer, offset, length, position) {
|
|
26
|
+
_fsReadFn = _fsReadFn || promisify(fs.read)
|
|
27
|
+
return _fsReadFn(fd, buffer, offset, length, position)
|
|
28
|
+
}
|
|
12
29
|
|
|
13
30
|
/**
|
|
14
31
|
* @class
|
|
@@ -53,4 +70,4 @@ export class CarReader extends BrowserCarReader {
|
|
|
53
70
|
}
|
|
54
71
|
}
|
|
55
72
|
|
|
56
|
-
export const __browser =
|
|
73
|
+
export const __browser = !fs
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import process from 'process'
|
|
4
|
-
import { decode, encode } from
|
|
4
|
+
import { decode, encode } from "@fireproof/vendor/cborg"
|
|
5
5
|
import { tokensToDiagnostic, fromDiag } from './diagnostic.js'
|
|
6
|
-
import { fromHex as _fromHex, toHex } from '
|
|
6
|
+
import { fromHex as _fromHex, toHex } from 'cborg/utils'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {number} code
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// const decodeErrPrefix = 'CBOR decode error:'
|
|
2
|
+
// const encodeErrPrefix = 'CBOR encode error:'
|
|
3
|
+
|
|
4
|
+
const uintMinorPrefixBytes = []
|
|
5
|
+
uintMinorPrefixBytes[23] = 1
|
|
6
|
+
uintMinorPrefixBytes[24] = 2
|
|
7
|
+
uintMinorPrefixBytes[25] = 3
|
|
8
|
+
uintMinorPrefixBytes[26] = 5
|
|
9
|
+
uintMinorPrefixBytes[27] = 9
|
|
10
|
+
|
|
11
|
+
// /**
|
|
12
|
+
// * @param {Uint8Array} data
|
|
13
|
+
// * @param {number} pos
|
|
14
|
+
// * @param {number} need
|
|
15
|
+
// * @param {string} decodeErrPrefix
|
|
16
|
+
// */
|
|
17
|
+
// function assertEnoughData (data, pos, need, decodeErrPrefix) {
|
|
18
|
+
// if (data.length - pos < need) {
|
|
19
|
+
// throw new Error(`${decodeErrPrefix} not enough data for type`)
|
|
20
|
+
// }
|
|
21
|
+
// }
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
// decodeErrPrefix,
|
|
25
|
+
// encodeErrPrefix,
|
|
26
|
+
uintMinorPrefixBytes
|
|
27
|
+
// assertEnoughData
|
|
28
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Type } from './token.js'
|
|
3
|
-
import { jump, quick } from './jump.js'
|
|
1
|
+
import { jump, quick, Type } from 'cborg/utils'
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
|
-
* @typedef {import('
|
|
4
|
+
* @typedef {import('cborg/utils').Token} Token
|
|
7
5
|
* @typedef {import('../interface').DecodeOptions} DecodeOptions
|
|
8
6
|
* @typedef {import('../interface').DecodeTokenizer} DecodeTokenizer
|
|
7
|
+
* @typedef {import('../interface').DecodeFunction} DecodeFunction
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
|
-
const defaultDecodeOptions = {
|
|
10
|
+
const /** @type {DecodeOptions} */defaultDecodeOptions = {
|
|
12
11
|
strict: false,
|
|
13
12
|
allowIndefinite: true,
|
|
14
13
|
allowUndefined: true,
|
|
15
|
-
allowBigInt: true
|
|
14
|
+
allowBigInt: true,
|
|
15
|
+
decodeErrPrefix: 'CBOR decode error:'
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -23,10 +23,11 @@ class Tokeniser {
|
|
|
23
23
|
* @param {Uint8Array} data
|
|
24
24
|
* @param {DecodeOptions} options
|
|
25
25
|
*/
|
|
26
|
-
constructor (data, options
|
|
26
|
+
constructor (data, options) {
|
|
27
27
|
this._pos = 0
|
|
28
28
|
this.data = data
|
|
29
29
|
this.options = options
|
|
30
|
+
this.jump = jump(options.decodeErrPrefix)
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
pos () {
|
|
@@ -41,11 +42,11 @@ class Tokeniser {
|
|
|
41
42
|
const byt = this.data[this._pos]
|
|
42
43
|
let token = quick[byt]
|
|
43
44
|
if (token === undefined) {
|
|
44
|
-
const decoder = jump[byt]
|
|
45
|
+
const decoder = this.jump[byt]
|
|
45
46
|
/* c8 ignore next 4 */
|
|
46
47
|
// if we're here then there's something wrong with our jump or quick lists!
|
|
47
48
|
if (!decoder) {
|
|
48
|
-
throw new Error(`${decodeErrPrefix} no decoder for major type ${byt >>> 5} (byte 0x${byt.toString(16).padStart(2, '0')})`)
|
|
49
|
+
throw new Error(`${this.options.decodeErrPrefix} no decoder for major type ${byt >>> 5} (byte 0x${byt.toString(16).padStart(2, '0')})`)
|
|
49
50
|
}
|
|
50
51
|
const minor = byt & 31
|
|
51
52
|
token = decoder(this.data, this._pos, minor, this.options)
|
|
@@ -74,10 +75,10 @@ function tokenToArray (token, tokeniser, options) {
|
|
|
74
75
|
// normal end to indefinite length array
|
|
75
76
|
break
|
|
76
77
|
}
|
|
77
|
-
throw new Error(`${decodeErrPrefix} got unexpected break to lengthed array`)
|
|
78
|
+
throw new Error(`${options.decodeErrPrefix} got unexpected break to lengthed array`)
|
|
78
79
|
}
|
|
79
80
|
if (value === DONE) {
|
|
80
|
-
throw new Error(`${decodeErrPrefix} found array but not enough entries (got ${i}, expected ${token.value})`)
|
|
81
|
+
throw new Error(`${options.decodeErrPrefix} found array but not enough entries (got ${i}, expected ${token.value})`)
|
|
81
82
|
}
|
|
82
83
|
arr[i] = value
|
|
83
84
|
}
|
|
@@ -101,23 +102,23 @@ function tokenToMap (token, tokeniser, options) {
|
|
|
101
102
|
// normal end to indefinite length map
|
|
102
103
|
break
|
|
103
104
|
}
|
|
104
|
-
throw new Error(`${decodeErrPrefix} got unexpected break to lengthed map`)
|
|
105
|
+
throw new Error(`${options.decodeErrPrefix} got unexpected break to lengthed map`)
|
|
105
106
|
}
|
|
106
107
|
if (key === DONE) {
|
|
107
|
-
throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no key], expected ${token.value})`)
|
|
108
|
+
throw new Error(`${options.decodeErrPrefix} found map but not enough entries (got ${i} [no key], expected ${token.value})`)
|
|
108
109
|
}
|
|
109
110
|
if (useMaps !== true && typeof key !== 'string') {
|
|
110
|
-
throw new Error(`${decodeErrPrefix} non-string keys not supported (got ${typeof key})`)
|
|
111
|
+
throw new Error(`${options.decodeErrPrefix} non-string keys not supported (got ${typeof key})`)
|
|
111
112
|
}
|
|
112
113
|
if (options.rejectDuplicateMapKeys === true) {
|
|
113
114
|
// @ts-ignore
|
|
114
115
|
if ((useMaps && m.has(key)) || (!useMaps && (key in obj))) {
|
|
115
|
-
throw new Error(`${decodeErrPrefix} found repeat map key "${key}"`)
|
|
116
|
+
throw new Error(`${options.decodeErrPrefix} found repeat map key "${key}"`)
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
const value = tokensToObject(tokeniser, options)
|
|
119
120
|
if (value === DONE) {
|
|
120
|
-
throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no value], expected ${token.value})`)
|
|
121
|
+
throw new Error(`${options.decodeErrPrefix} found map but not enough entries (got ${i} [no value], expected ${token.value})`)
|
|
121
122
|
}
|
|
122
123
|
if (useMaps) {
|
|
123
124
|
// @ts-ignore TODO reconsider this .. maybe needs to be strict about key types
|
|
@@ -166,7 +167,7 @@ function tokensToObject (tokeniser, options) {
|
|
|
166
167
|
const tagged = tokensToObject(tokeniser, options)
|
|
167
168
|
return options.tags[token.value](tagged)
|
|
168
169
|
}
|
|
169
|
-
throw new Error(`${decodeErrPrefix} tag not supported (${token.value})`)
|
|
170
|
+
throw new Error(`${options.decodeErrPrefix} tag not supported (${token.value})`)
|
|
170
171
|
}
|
|
171
172
|
/* c8 ignore next */
|
|
172
173
|
throw new Error('unsupported')
|
|
@@ -178,17 +179,17 @@ function tokensToObject (tokeniser, options) {
|
|
|
178
179
|
* @returns {[any, Uint8Array]}
|
|
179
180
|
*/
|
|
180
181
|
function decodeFirst (data, options) {
|
|
182
|
+
options = Object.assign({}, defaultDecodeOptions, options)
|
|
181
183
|
if (!(data instanceof Uint8Array)) {
|
|
182
|
-
throw new Error(`${decodeErrPrefix} data to decode must be a Uint8Array`)
|
|
184
|
+
throw new Error(`${options.decodeErrPrefix} data to decode must be a Uint8Array`)
|
|
183
185
|
}
|
|
184
|
-
options = Object.assign({}, defaultDecodeOptions, options)
|
|
185
186
|
const tokeniser = options.tokenizer || new Tokeniser(data, options)
|
|
186
187
|
const decoded = tokensToObject(tokeniser, options)
|
|
187
188
|
if (decoded === DONE) {
|
|
188
|
-
throw new Error(`${decodeErrPrefix} did not find any content to decode`)
|
|
189
|
+
throw new Error(`${options.decodeErrPrefix} did not find any content to decode`)
|
|
189
190
|
}
|
|
190
191
|
if (decoded === BREAK) {
|
|
191
|
-
throw new Error(`${decodeErrPrefix} got unexpected break`)
|
|
192
|
+
throw new Error(`${options.decodeErrPrefix} got unexpected break`)
|
|
192
193
|
}
|
|
193
194
|
return [decoded, data.subarray(tokeniser.pos())]
|
|
194
195
|
}
|
|
@@ -199,9 +200,10 @@ function decodeFirst (data, options) {
|
|
|
199
200
|
* @returns {any}
|
|
200
201
|
*/
|
|
201
202
|
function decode (data, options) {
|
|
203
|
+
options = Object.assign({}, defaultDecodeOptions, options)
|
|
202
204
|
const [decoded, remainder] = decodeFirst(data, options)
|
|
203
205
|
if (remainder.length > 0) {
|
|
204
|
-
throw new Error(`${decodeErrPrefix} too many terminals, data makes no sense`)
|
|
206
|
+
throw new Error(`${options.decodeErrPrefix} too many terminals, data makes no sense:${remainder.length}`)
|
|
205
207
|
}
|
|
206
208
|
return decoded
|
|
207
209
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Tokeniser } from './decode.js'
|
|
2
|
-
import { Type } from '
|
|
3
|
-
import { toHex, fromHex } from './byte-utils.js'
|
|
4
|
-
import { uintBoundaries } from './0uint.js'
|
|
2
|
+
import { uintBoundaries, toHex, fromHex, Type } from 'cborg/utils'
|
|
5
3
|
|
|
6
4
|
const utf8Encoder = new TextEncoder()
|
|
7
5
|
const utf8Decoder = new TextDecoder()
|
|
@@ -11,7 +9,11 @@ const utf8Decoder = new TextDecoder()
|
|
|
11
9
|
* @param {number} [width]
|
|
12
10
|
*/
|
|
13
11
|
function * tokensToDiagnostic (inp, width = 100) {
|
|
14
|
-
const tokeniser = new Tokeniser(inp, {
|
|
12
|
+
const tokeniser = new Tokeniser(inp, {
|
|
13
|
+
decodeErrPrefix: 'Diagnostic decode error: ',
|
|
14
|
+
retainStringBytes: true,
|
|
15
|
+
allowBigInt: true
|
|
16
|
+
})
|
|
15
17
|
let pos = 0
|
|
16
18
|
const indent = []
|
|
17
19
|
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { is } from './is.js'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import { encodeFloat } from './7float.js'
|
|
2
|
+
import {
|
|
3
|
+
Token, Type, Bl,
|
|
4
|
+
quickEncodeToken,
|
|
5
|
+
asU8A,
|
|
6
|
+
encodeUint,
|
|
7
|
+
encodeNegint,
|
|
8
|
+
encodeBytes,
|
|
9
|
+
encodeString,
|
|
10
|
+
encodeArray,
|
|
11
|
+
encodeMap,
|
|
12
|
+
encodeTag,
|
|
13
|
+
encodeFloat
|
|
14
|
+
} from 'cborg/utils'
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* @typedef {import('../interface').EncodeOptions} EncodeOptions
|
|
@@ -27,7 +26,9 @@ import { encodeFloat } from './7float.js'
|
|
|
27
26
|
const defaultEncodeOptions = {
|
|
28
27
|
float64: false,
|
|
29
28
|
mapSorter,
|
|
30
|
-
quickEncodeToken
|
|
29
|
+
quickEncodeToken,
|
|
30
|
+
encodeErrPrefix: 'CBOR encode error:'
|
|
31
|
+
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/** @returns {TokenTypeEncoder[]} */
|
|
@@ -77,9 +78,10 @@ class Ref {
|
|
|
77
78
|
/**
|
|
78
79
|
* @param {Reference|undefined} stack
|
|
79
80
|
* @param {object|any[]} obj
|
|
81
|
+
* @param {EncodeOptions} options
|
|
80
82
|
* @returns {Reference}
|
|
81
83
|
*/
|
|
82
|
-
static createCheck (stack, obj) {
|
|
84
|
+
static createCheck (stack, obj, { encodeErrPrefix }) {
|
|
83
85
|
if (stack && stack.includes(obj)) {
|
|
84
86
|
throw new Error(`${encodeErrPrefix} object contains circular references`)
|
|
85
87
|
}
|
|
@@ -221,7 +223,7 @@ const typeEncoders = {
|
|
|
221
223
|
}
|
|
222
224
|
return simpleTokens.emptyArray
|
|
223
225
|
}
|
|
224
|
-
refStack = Ref.createCheck(refStack, obj)
|
|
226
|
+
refStack = Ref.createCheck(refStack, obj, options)
|
|
225
227
|
const entries = []
|
|
226
228
|
let i = 0
|
|
227
229
|
for (const e of obj) {
|
|
@@ -252,7 +254,7 @@ const typeEncoders = {
|
|
|
252
254
|
}
|
|
253
255
|
return simpleTokens.emptyMap
|
|
254
256
|
}
|
|
255
|
-
refStack = Ref.createCheck(refStack, obj)
|
|
257
|
+
refStack = Ref.createCheck(refStack, obj, options)
|
|
256
258
|
/** @type {TokenOrNestedTokens[]} */
|
|
257
259
|
const entries = []
|
|
258
260
|
let i = 0
|
|
@@ -278,11 +280,11 @@ for (const typ of 'Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt6
|
|
|
278
280
|
|
|
279
281
|
/**
|
|
280
282
|
* @param {any} obj
|
|
281
|
-
* @param {EncodeOptions}
|
|
283
|
+
* @param {EncodeOptions} options
|
|
282
284
|
* @param {Reference} [refStack]
|
|
283
285
|
* @returns {TokenOrNestedTokens}
|
|
284
286
|
*/
|
|
285
|
-
function objectToTokens (obj, options
|
|
287
|
+
function objectToTokens (obj, options, refStack) {
|
|
286
288
|
const typ = is(obj)
|
|
287
289
|
const customTypeEncoder = (options && options.typeEncoders && /** @type {OptionalTypeEncoder} */ options.typeEncoders[typ]) || typeEncoders[typ]
|
|
288
290
|
if (typeof customTypeEncoder === 'function') {
|
|
@@ -293,7 +295,7 @@ function objectToTokens (obj, options = {}, refStack) {
|
|
|
293
295
|
}
|
|
294
296
|
const typeEncoder = typeEncoders[typ]
|
|
295
297
|
if (!typeEncoder) {
|
|
296
|
-
throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`)
|
|
298
|
+
throw new Error(`${options.encodeErrPrefix} unsupported type: ${typ}`)
|
|
297
299
|
}
|
|
298
300
|
return typeEncoder(obj, typ, options, refStack)
|
|
299
301
|
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { encode } from './
|
|
2
|
-
import { decode, decodeFirst, Tokeniser, tokensToObject } from './
|
|
3
|
-
import { Token, Type } from '
|
|
1
|
+
import { encode } from './encode.js'
|
|
2
|
+
import { decode, decodeFirst, Tokeniser, tokensToObject } from './decode.js'
|
|
3
|
+
import { Token, Type } from 'cborg/utils'
|
|
4
4
|
|
|
5
5
|
// is this needed for the json module and other independ encoders
|
|
6
|
-
export { encodeCustom } from './
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
6
|
+
export { encodeCustom } from './encode.js'
|
|
7
|
+
// export { asU8A, fromString, decodeCodePointsArray } from './utils/byte-utils.js'
|
|
8
|
+
// export { quickEncodeToken } from './utils/jump.js'
|
|
9
|
+
// export { encodeErrPrefix, decodeErrPrefix } from './lib/common.js'
|
|
10
|
+
// export { makeCborEncoders, objectToTokens } from './lib/encode.js'
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Export the types that were present in the original manual cborg.d.ts
|
|
12
|
-
* @typedef {import('
|
|
14
|
+
* @typedef {import('../interface').TagDecoder} TagDecoder
|
|
13
15
|
* There was originally just `TypeEncoder` so don't break types by renaming or not exporting
|
|
14
|
-
* @typedef {import('
|
|
15
|
-
* @typedef {import('
|
|
16
|
-
* @typedef {import('
|
|
16
|
+
* @typedef {import('../interface').OptionalTypeEncoder} TypeEncoder
|
|
17
|
+
* @typedef {import('../interface').DecodeOptions} DecodeOptions
|
|
18
|
+
* @typedef {import('../interface').EncodeOptions} EncodeOptions
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
21
|
export {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { makeCborEncoders, objectToTokens } from './encode.js'
|
|
2
|
-
import { quickEncodeToken } from '
|
|
2
|
+
import { quickEncodeToken } from 'cborg/utils'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import('../interface').EncodeOptions} EncodeOptions
|
|
@@ -12,7 +12,8 @@ const cborEncoders = makeCborEncoders()
|
|
|
12
12
|
/** @type {EncodeOptions} */
|
|
13
13
|
const defaultEncodeOptions = {
|
|
14
14
|
float64: false,
|
|
15
|
-
quickEncodeToken
|
|
15
|
+
quickEncodeToken,
|
|
16
|
+
encodeErrPrefix: 'CBOR encode error: '
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Token } from '
|
|
2
|
-
import { Bl } from './lib/bl'
|
|
1
|
+
import type { Token, Bl } from 'cborg/utils'
|
|
3
2
|
|
|
4
3
|
export type TokenOrNestedTokens = Token | Token[] | TokenOrNestedTokens[]
|
|
5
4
|
|
|
@@ -14,12 +13,14 @@ export type OptionalTypeEncoder = (data: any, typ: string, options: EncodeOption
|
|
|
14
13
|
export type StrictTypeEncoder = (data: any, typ: string, options: EncodeOptions, refStack?: Reference) => TokenOrNestedTokens
|
|
15
14
|
|
|
16
15
|
export type TokenTypeEncoder = {
|
|
17
|
-
(buf: Bl, token: Token, options
|
|
16
|
+
(buf: Bl, token: Token, options: EncodeOptions): void;
|
|
18
17
|
compareTokens(t1: Token, t2: Token): number;
|
|
19
18
|
// TODO: make this non-optional as a breaking change and remove the throw in length.js
|
|
20
|
-
encodedSize?(token: Token, options
|
|
19
|
+
encodedSize?(token: Token, options: EncodeOptions): number;
|
|
21
20
|
}
|
|
22
21
|
|
|
22
|
+
export type DecodeFunction = (data:Uint8Array, pos:number, minor:number, options:DecodeOptions) => any
|
|
23
|
+
|
|
23
24
|
export type MapSorter = (e1: (Token | Token[])[], e2: (Token | Token[])[]) => number
|
|
24
25
|
|
|
25
26
|
export type QuickEncodeToken = (token: Token) => Uint8Array | undefined
|
|
@@ -45,6 +46,7 @@ export interface DecodeOptions {
|
|
|
45
46
|
retainStringBytes?: boolean
|
|
46
47
|
tags?: TagDecoder[],
|
|
47
48
|
tokenizer?: DecodeTokenizer
|
|
49
|
+
decodeErrPrefix: string
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export interface EncodeOptions {
|
|
@@ -53,4 +55,5 @@ export interface EncodeOptions {
|
|
|
53
55
|
mapSorter?: MapSorter,
|
|
54
56
|
quickEncodeToken?: QuickEncodeToken,
|
|
55
57
|
typeEncoders?: { [typeName: string]: OptionalTypeEncoder }
|
|
58
|
+
encodeErrPrefix: string
|
|
56
59
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
// never reference the file directly to ensure the
|
|
2
2
|
// indepency of the json module
|
|
3
3
|
import { decode as _decode, decodeFirst as _decodeFirst } from "@fireproof/vendor/cborg"
|
|
4
|
-
import { Token, Type } from
|
|
5
|
-
import { decodeCodePointsArray } from "@fireproof/vendor/cborg"
|
|
6
|
-
import { decodeErrPrefix } from "@fireproof/vendor/cborg"
|
|
4
|
+
import { Token, Type, decodeCodePointsArray } from 'cborg/utils'
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
|
-
* @typedef {import('
|
|
10
|
-
* @typedef {import('
|
|
7
|
+
* @typedef {import('../interface').DecodeOptions} DecodeOptions
|
|
8
|
+
* @typedef {import('../interface').DecodeTokenizer} DecodeTokenizer
|
|
11
9
|
*/
|
|
12
10
|
|
|
13
11
|
/**
|
|
@@ -18,7 +16,7 @@ class Tokenizer {
|
|
|
18
16
|
* @param {Uint8Array} data
|
|
19
17
|
* @param {DecodeOptions} options
|
|
20
18
|
*/
|
|
21
|
-
constructor (data, options
|
|
19
|
+
constructor (data, options) {
|
|
22
20
|
this._pos = 0
|
|
23
21
|
this.data = data
|
|
24
22
|
this.options = options
|
|
@@ -65,11 +63,11 @@ class Tokenizer {
|
|
|
65
63
|
*/
|
|
66
64
|
expect (str) {
|
|
67
65
|
if (this.data.length - this._pos < str.length) {
|
|
68
|
-
throw new Error(`${decodeErrPrefix} unexpected end of input at position ${this._pos}`)
|
|
66
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected end of input at position ${this._pos}`)
|
|
69
67
|
}
|
|
70
68
|
for (let i = 0; i < str.length; i++) {
|
|
71
69
|
if (this.data[this._pos++] !== str[i]) {
|
|
72
|
-
throw new Error(`${decodeErrPrefix} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...str)}'`)
|
|
70
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...str)}'`)
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
}
|
|
@@ -109,11 +107,11 @@ class Tokenizer {
|
|
|
109
107
|
}
|
|
110
108
|
swallow([48, 49, 50, 51, 52, 53, 54, 55, 56, 57]) // DIGIT
|
|
111
109
|
if (negative && this._pos === startPos + 1) {
|
|
112
|
-
throw new Error(`${decodeErrPrefix} unexpected token at position ${this._pos}`)
|
|
110
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected token at position ${this._pos}`)
|
|
113
111
|
}
|
|
114
112
|
if (!this.done() && this.ch() === 46) { // '.'
|
|
115
113
|
if (float) {
|
|
116
|
-
throw new Error(`${decodeErrPrefix} unexpected token at position ${this._pos}`)
|
|
114
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected token at position ${this._pos}`)
|
|
117
115
|
}
|
|
118
116
|
float = true
|
|
119
117
|
this._pos++
|
|
@@ -146,7 +144,7 @@ class Tokenizer {
|
|
|
146
144
|
/* c8 ignore next 4 */
|
|
147
145
|
if (this.ch() !== 34) { // '"'
|
|
148
146
|
// this would be a programming error
|
|
149
|
-
throw new Error(`${decodeErrPrefix} unexpected character at position ${this._pos}; this shouldn't happen`)
|
|
147
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected character at position ${this._pos}; this shouldn't happen`)
|
|
150
148
|
}
|
|
151
149
|
this._pos++
|
|
152
150
|
|
|
@@ -170,7 +168,7 @@ class Tokenizer {
|
|
|
170
168
|
|
|
171
169
|
const readu4 = () => {
|
|
172
170
|
if (this._pos + 4 >= this.data.length) {
|
|
173
|
-
throw new Error(`${decodeErrPrefix} unexpected end of unicode escape sequence at position ${this._pos}`)
|
|
171
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected end of unicode escape sequence at position ${this._pos}`)
|
|
174
172
|
}
|
|
175
173
|
let u4 = 0
|
|
176
174
|
for (let i = 0; i < 4; i++) {
|
|
@@ -182,7 +180,7 @@ class Tokenizer {
|
|
|
182
180
|
} else if (ch >= 65 && ch <= 70) { // 'A' && 'F'
|
|
183
181
|
ch = ch - 65 + 10
|
|
184
182
|
} else {
|
|
185
|
-
throw new Error(`${decodeErrPrefix} unexpected unicode escape character at position ${this._pos}`)
|
|
183
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected unicode escape character at position ${this._pos}`)
|
|
186
184
|
}
|
|
187
185
|
u4 = u4 * 16 + ch
|
|
188
186
|
this._pos++
|
|
@@ -198,7 +196,7 @@ class Tokenizer {
|
|
|
198
196
|
let bytesPerSequence = (firstByte > 0xef) ? 4 : (firstByte > 0xdf) ? 3 : (firstByte > 0xbf) ? 2 : 1
|
|
199
197
|
|
|
200
198
|
if (this._pos + bytesPerSequence > this.data.length) {
|
|
201
|
-
throw new Error(`${decodeErrPrefix} unexpected unicode sequence at position ${this._pos}`)
|
|
199
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected unicode sequence at position ${this._pos}`)
|
|
202
200
|
}
|
|
203
201
|
|
|
204
202
|
let secondByte, thirdByte, fourthByte, tempCodePoint
|
|
@@ -269,7 +267,7 @@ class Tokenizer {
|
|
|
269
267
|
case 92: // '\'
|
|
270
268
|
this._pos++
|
|
271
269
|
if (this.done()) {
|
|
272
|
-
throw new Error(`${decodeErrPrefix} unexpected string termination at position ${this._pos}`)
|
|
270
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected string termination at position ${this._pos}`)
|
|
273
271
|
}
|
|
274
272
|
ch1 = this.ch()
|
|
275
273
|
this._pos++
|
|
@@ -299,7 +297,7 @@ class Tokenizer {
|
|
|
299
297
|
chars.push(readu4())
|
|
300
298
|
break
|
|
301
299
|
default:
|
|
302
|
-
throw new Error(`${decodeErrPrefix} unexpected string escape character at position ${this._pos}`)
|
|
300
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected string escape character at position ${this._pos}`)
|
|
303
301
|
}
|
|
304
302
|
break
|
|
305
303
|
case 34: // '"'
|
|
@@ -307,7 +305,7 @@ class Tokenizer {
|
|
|
307
305
|
return new Token(Type.string, decodeCodePointsArray(chars), this._pos - startPos)
|
|
308
306
|
default:
|
|
309
307
|
if (ch < 32) { // ' '
|
|
310
|
-
throw new Error(`${decodeErrPrefix} invalid control character at position ${this._pos}`)
|
|
308
|
+
throw new Error(`${this.options.decodeErrPrefix} invalid control character at position ${this._pos}`)
|
|
311
309
|
} else if (ch < 0x80) {
|
|
312
310
|
chars.push(ch)
|
|
313
311
|
this._pos++
|
|
@@ -317,7 +315,7 @@ class Tokenizer {
|
|
|
317
315
|
}
|
|
318
316
|
}
|
|
319
317
|
|
|
320
|
-
throw new Error(`${decodeErrPrefix} unexpected end of string at position ${this._pos}`)
|
|
318
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected end of string at position ${this._pos}`)
|
|
321
319
|
}
|
|
322
320
|
|
|
323
321
|
/**
|
|
@@ -358,7 +356,7 @@ class Tokenizer {
|
|
|
358
356
|
case 57: // '9'
|
|
359
357
|
return this.parseNumber()
|
|
360
358
|
default:
|
|
361
|
-
throw new Error(`${decodeErrPrefix} unexpected character at position ${this._pos}`)
|
|
359
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected character at position ${this._pos}`)
|
|
362
360
|
}
|
|
363
361
|
}
|
|
364
362
|
|
|
@@ -379,7 +377,7 @@ class Tokenizer {
|
|
|
379
377
|
return new Token(Type.break, undefined, 1)
|
|
380
378
|
}
|
|
381
379
|
if (this.ch() !== 44) { // ','
|
|
382
|
-
throw new Error(`${decodeErrPrefix} unexpected character at position ${this._pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`)
|
|
380
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected character at position ${this._pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`)
|
|
383
381
|
}
|
|
384
382
|
this._pos++
|
|
385
383
|
this.modeStack.push('array-value')
|
|
@@ -406,7 +404,7 @@ class Tokenizer {
|
|
|
406
404
|
return new Token(Type.break, undefined, 1)
|
|
407
405
|
}
|
|
408
406
|
if (this.ch() !== 44) { // ','
|
|
409
|
-
throw new Error(`${decodeErrPrefix} unexpected character at position ${this._pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`)
|
|
407
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected character at position ${this._pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`)
|
|
410
408
|
}
|
|
411
409
|
this._pos++
|
|
412
410
|
this.skipWhitespace()
|
|
@@ -420,7 +418,7 @@ class Tokenizer {
|
|
|
420
418
|
const token = this.parseString()
|
|
421
419
|
this.skipWhitespace()
|
|
422
420
|
if (this.ch() !== 58) { // ':'
|
|
423
|
-
throw new Error(`${decodeErrPrefix} unexpected character at position ${this._pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`)
|
|
421
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected character at position ${this._pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`)
|
|
424
422
|
}
|
|
425
423
|
this._pos++
|
|
426
424
|
this.modeStack.push('obj-value')
|
|
@@ -434,7 +432,7 @@ class Tokenizer {
|
|
|
434
432
|
}
|
|
435
433
|
/* c8 ignore next 2 */
|
|
436
434
|
default:
|
|
437
|
-
throw new Error(`${decodeErrPrefix} unexpected parse state at position ${this._pos}; this shouldn't happen`)
|
|
435
|
+
throw new Error(`${this.options.decodeErrPrefix} unexpected parse state at position ${this._pos}; this shouldn't happen`)
|
|
438
436
|
}
|
|
439
437
|
}
|
|
440
438
|
}
|
|
@@ -445,7 +443,8 @@ class Tokenizer {
|
|
|
445
443
|
* @returns {any}
|
|
446
444
|
*/
|
|
447
445
|
function decode (data, options) {
|
|
448
|
-
options =
|
|
446
|
+
options = { decodeErrPrefix: 'JSON decode error:', ...options }
|
|
447
|
+
options.tokenizer = options.tokenizer || new Tokenizer(data, options)
|
|
449
448
|
return _decode(data, options)
|
|
450
449
|
}
|
|
451
450
|
|
|
@@ -455,7 +454,8 @@ function decode (data, options) {
|
|
|
455
454
|
* @returns {[any, Uint8Array]}
|
|
456
455
|
*/
|
|
457
456
|
function decodeFirst (data, options) {
|
|
458
|
-
options =
|
|
457
|
+
options = { decodeErrPrefix: 'JSON decode error:', ...options }
|
|
458
|
+
options.tokenizer = options.tokenizer || new Tokenizer(data, options)
|
|
459
459
|
return _decodeFirst(data, options)
|
|
460
460
|
}
|
|
461
461
|
|