@fireproof/vendor 1.0.4 → 1.1.0-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -97
- package/src/@web3-storage/pail/dist/src/batch/index.d.ts +1 -53
- package/src/@web3-storage/pail/dist/src/batch/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/batch/shard.d.ts +1 -1
- package/src/@web3-storage/pail/dist/src/batch/shard.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/block.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/block.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/clock/index.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/clock/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/crdt/batch/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/crdt/index.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/crdt/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/diff.d.ts +3 -3
- package/src/@web3-storage/pail/dist/src/diff.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/index.d.ts +1 -1
- package/src/@web3-storage/pail/dist/src/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/merge.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/shard.d.ts +4 -4
- package/src/@web3-storage/pail/dist/src/shard.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/tsconfig.tsbuildinfo +1 -1
- package/src/@web3-storage/pail/src/api.ts +1 -1
- package/src/@web3-storage/pail/src/clock/index.js +1 -1
- package/src/@web3-storage/pail/src/shard.js +1 -1
- package/src/@ipld/car/LICENSE +0 -4
- package/src/@ipld/car/README.md +0 -1132
- package/src/@ipld/car/dist/index.min.js +0 -5
- package/src/@ipld/car/dist/src/api.d.ts +0 -72
- package/src/@ipld/car/dist/src/api.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-decoder.d.ts +0 -67
- package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +0 -116
- package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-reader.d.ts +0 -31
- package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-writer.d.ts +0 -86
- package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/coding.d.ts +0 -49
- package/src/@ipld/car/dist/src/coding.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/decoder-common.d.ts +0 -43
- package/src/@ipld/car/dist/src/decoder-common.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/decoder.d.ts +0 -87
- package/src/@ipld/car/dist/src/decoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/encoder.d.ts +0 -17
- package/src/@ipld/car/dist/src/encoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/header-validator.d.ts +0 -5
- package/src/@ipld/car/dist/src/header-validator.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/index-browser.d.ts +0 -10
- package/src/@ipld/car/dist/src/index-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/index.d.ts +0 -11
- package/src/@ipld/car/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +0 -5
- package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexed-reader.d.ts +0 -152
- package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexer.d.ts +0 -95
- package/src/@ipld/car/dist/src/indexer.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/iterator-channel.d.ts +0 -7
- package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/iterator.d.ts +0 -174
- package/src/@ipld/car/dist/src/iterator.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/promise-fs-opts.d.ts +0 -30
- package/src/@ipld/car/dist/src/promise-fs-opts.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/reader-browser.d.ts +0 -151
- package/src/@ipld/car/dist/src/reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/reader.d.ts +0 -39
- package/src/@ipld/car/dist/src/reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/writer-browser.d.ts +0 -155
- package/src/@ipld/car/dist/src/writer-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/writer.d.ts +0 -44
- package/src/@ipld/car/dist/src/writer.d.ts.map +0 -1
- package/src/@ipld/car/src/api.ts +0 -90
- package/src/@ipld/car/src/buffer-decoder.js +0 -213
- package/src/@ipld/car/src/buffer-reader-browser.js +0 -144
- package/src/@ipld/car/src/buffer-reader.js +0 -51
- package/src/@ipld/car/src/buffer-writer.js +0 -286
- package/src/@ipld/car/src/coding.ts +0 -68
- package/src/@ipld/car/src/decoder-common.js +0 -82
- package/src/@ipld/car/src/decoder.js +0 -347
- package/src/@ipld/car/src/encoder.js +0 -76
- package/src/@ipld/car/src/header-validator.js +0 -214
- package/src/@ipld/car/src/header.ipldsch +0 -18
- package/src/@ipld/car/src/index-browser.js +0 -18
- package/src/@ipld/car/src/index.js +0 -21
- package/src/@ipld/car/src/indexed-reader-browser.js +0 -7
- package/src/@ipld/car/src/indexed-reader.js +0 -211
- package/src/@ipld/car/src/indexer.js +0 -130
- package/src/@ipld/car/src/iterator-channel.js +0 -91
- package/src/@ipld/car/src/iterator.js +0 -267
- package/src/@ipld/car/src/promise-fs-opts.js +0 -42
- package/src/@ipld/car/src/reader-browser.js +0 -194
- package/src/@ipld/car/src/reader.js +0 -53
- package/src/@ipld/car/src/writer-browser.js +0 -250
- package/src/@ipld/car/src/writer.js +0 -80
- package/src/@ipld/dag-cbor/LICENSE +0 -4
- package/src/@ipld/dag-cbor/README.md +0 -80
- package/src/@ipld/dag-cbor/dist/index.min.js +0 -3
- package/src/@ipld/dag-cbor/dist/src/index.d.ts +0 -67
- package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-cbor/src/index.js +0 -147
- package/src/@ipld/dag-json/LICENSE +0 -4
- package/src/@ipld/dag-json/README.md +0 -58
- package/src/@ipld/dag-json/dist/index.min.js +0 -3
- package/src/@ipld/dag-json/dist/src/index.d.ts +0 -12
- package/src/@ipld/dag-json/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-json/src/index.js +0 -291
- package/src/cborg/.github/dependabot.yml +0 -16
- package/src/cborg/.github/workflows/test-and-release.yml +0 -52
- package/src/cborg/CHANGELOG.md +0 -513
- package/src/cborg/LICENSE +0 -13
- package/src/cborg/README.md +0 -515
- package/src/cborg/bench/bench.js +0 -117
- package/src/cborg/bench/json.js +0 -124
- package/src/cborg/bench/package.json +0 -8
- package/src/cborg/cborg/bin.js +0 -189
- package/src/cborg/cborg/common.js +0 -28
- package/src/cborg/cborg/decode.js +0 -211
- package/src/cborg/cborg/diagnostic.js +0 -158
- package/src/cborg/cborg/diagnostic_test.js +0 -117
- package/src/cborg/cborg/encode.js +0 -466
- package/src/cborg/cborg/index.js +0 -33
- package/src/cborg/cborg/is.js +0 -106
- package/src/cborg/cborg/length.js +0 -62
- package/src/cborg/example-bytestrings.js +0 -180
- package/src/cborg/example-json.js +0 -6
- package/src/cborg/example.js +0 -5
- package/src/cborg/interface.ts +0 -59
- package/src/cborg/json/decode.js +0 -462
- package/src/cborg/json/encode.js +0 -302
- package/src/cborg/json/json.js +0 -4
- package/src/cborg/taglib.js +0 -75
- package/src/cborg/test/appendix_a.js +0 -647
- package/src/cborg/test/common.js +0 -18
- package/src/cborg/test/node-test-bin.js +0 -402
- package/src/cborg/test/noop-bin-test.js +0 -3
- package/src/cborg/test/test-0uint.js +0 -103
- package/src/cborg/test/test-1negint.js +0 -96
- package/src/cborg/test/test-2bytes.js +0 -198
- package/src/cborg/test/test-3string.js +0 -136
- package/src/cborg/test/test-4array.js +0 -93
- package/src/cborg/test/test-5map.js +0 -284
- package/src/cborg/test/test-6tag.js +0 -84
- package/src/cborg/test/test-7float.js +0 -131
- package/src/cborg/test/test-bl.js +0 -37
- package/src/cborg/test/test-cbor-vectors.js +0 -107
- package/src/cborg/test/test-decode-errors.js +0 -65
- package/src/cborg/test/test-fuzz.js +0 -42
- package/src/cborg/test/test-json.js +0 -219
- package/src/cborg/test/test-length.js +0 -65
- package/src/cborg/test/test-partial.js +0 -111
- package/src/cborg/tsconfig.json +0 -48
- package/src/cborg/types/cborg/decode.d.ts +0 -43
- package/src/cborg/types/cborg/decode.d.ts.map +0 -1
- package/src/cborg/types/cborg/encode.d.ts +0 -51
- package/src/cborg/types/cborg/encode.d.ts.map +0 -1
- package/src/cborg/types/cborg/index.d.ts +0 -26
- package/src/cborg/types/cborg/index.d.ts.map +0 -1
- package/src/cborg/types/cborg/is.d.ts +0 -6
- package/src/cborg/types/cborg/is.d.ts.map +0 -1
- package/src/cborg/types/example.d.ts +0 -2
- package/src/cborg/types/example.d.ts.map +0 -1
- package/src/cborg/types/interface.d.ts +0 -49
- package/src/cborg/types/interface.d.ts.map +0 -1
- package/src/cborg/types/json/decode.d.ts +0 -67
- package/src/cborg/types/json/decode.d.ts.map +0 -1
- package/src/cborg/types/json/encode.d.ts +0 -11
- package/src/cborg/types/json/encode.d.ts.map +0 -1
- package/src/cborg/types/json/json.d.ts +0 -6
- package/src/cborg/types/json/json.d.ts.map +0 -1
- package/src/cborg/types/taglib.d.ts +0 -18
- package/src/cborg/types/taglib.d.ts.map +0 -1
- package/src/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/cborg/types/utils/0uint.d.ts +0 -102
- package/src/cborg/types/utils/0uint.d.ts.map +0 -1
- package/src/cborg/types/utils/1negint.d.ts +0 -59
- package/src/cborg/types/utils/1negint.d.ts.map +0 -1
- package/src/cborg/types/utils/2bytes.d.ts +0 -69
- package/src/cborg/types/utils/2bytes.d.ts.map +0 -1
- package/src/cborg/types/utils/3string.d.ts +0 -46
- package/src/cborg/types/utils/3string.d.ts.map +0 -1
- package/src/cborg/types/utils/4array.d.ts +0 -66
- package/src/cborg/types/utils/4array.d.ts.map +0 -1
- package/src/cborg/types/utils/5map.d.ts +0 -66
- package/src/cborg/types/utils/5map.d.ts.map +0 -1
- package/src/cborg/types/utils/6tag.d.ts +0 -62
- package/src/cborg/types/utils/6tag.d.ts.map +0 -1
- package/src/cborg/types/utils/7float.d.ts +0 -60
- package/src/cborg/types/utils/7float.d.ts.map +0 -1
- package/src/cborg/types/utils/bl.d.ts +0 -26
- package/src/cborg/types/utils/bl.d.ts.map +0 -1
- package/src/cborg/types/utils/byte-utils.d.ts +0 -53
- package/src/cborg/types/utils/byte-utils.d.ts.map +0 -1
- package/src/cborg/types/utils/common.d.ts +0 -8
- package/src/cborg/types/utils/common.d.ts.map +0 -1
- package/src/cborg/types/utils/index.d.ts +0 -13
- package/src/cborg/types/utils/index.d.ts.map +0 -1
- package/src/cborg/types/utils/jump.d.ts +0 -16
- package/src/cborg/types/utils/jump.d.ts.map +0 -1
- package/src/cborg/types/utils/token.d.ts +0 -59
- package/src/cborg/types/utils/token.d.ts.map +0 -1
- package/src/cborg/utils/0uint.js +0 -229
- package/src/cborg/utils/1negint.js +0 -111
- package/src/cborg/utils/2bytes.js +0 -135
- package/src/cborg/utils/3string.js +0 -90
- package/src/cborg/utils/4array.js +0 -114
- package/src/cborg/utils/5map.js +0 -113
- package/src/cborg/utils/6tag.js +0 -81
- package/src/cborg/utils/7float.js +0 -310
- package/src/cborg/utils/bl.js +0 -124
- package/src/cborg/utils/byte-utils.js +0 -417
- package/src/cborg/utils/common.js +0 -11
- package/src/cborg/utils/index.js +0 -12
- package/src/cborg/utils/jump.js +0 -222
- package/src/cborg/utils/token.js +0 -76
- package/src/ipfs-unixfs-exporter/LICENSE +0 -4
- package/src/ipfs-unixfs-exporter/README.md +0 -105
- package/src/ipfs-unixfs-exporter/dist/index.min.js +0 -3
- package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
- package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
- package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
- package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/index.js +0 -197
- package/src/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
- package/src/ipfs-unixfs-exporter/src/errors.ts +0 -87
- package/src/ipfs-unixfs-exporter/src/index.ts +0 -498
- package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
- package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
- package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
- package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
- package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
- package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
- package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
package/src/cborg/json/encode.js
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
// never reference the file directly to ensure the
|
|
2
|
-
// indepency of the json module
|
|
3
|
-
import { encodeCustom } from "@fireproof/vendor/cborg"
|
|
4
|
-
import { Type, asU8A, fromString } from "@fireproof/vendor/cborg/utils"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {import('../interface').EncodeOptions} EncodeOptions
|
|
8
|
-
* @typedef {import('../interface').TokenTypeEncoder} TokenTypeEncoder
|
|
9
|
-
* @typedef {import('cborg/utils').Token} Token
|
|
10
|
-
* @typedef {import('cborg/utils').Bl} Bl
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {(buf: Bl, token: Token, opt: EncodeOptions) => void} action
|
|
15
|
-
* @returns {TokenTypeEncoder}
|
|
16
|
-
*/
|
|
17
|
-
function wrapCompareTokens (action) {
|
|
18
|
-
const wrapped = (/** @type {Bl} */ buf, /** @type {Token} */token, /** @type {EncodeOptions} */opt) => action(buf, token, opt)
|
|
19
|
-
/**
|
|
20
|
-
* @param {Token} tok1
|
|
21
|
-
* @param {Token} tok2
|
|
22
|
-
* @returns {number}
|
|
23
|
-
*/
|
|
24
|
-
wrapped.compareTokens = function compareTokens (tok1, tok2) {
|
|
25
|
-
return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : 0
|
|
26
|
-
}
|
|
27
|
-
return wrapped
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @returns {TokenTypeEncoder[]}
|
|
32
|
-
*/
|
|
33
|
-
function makeJSONEncoders () {
|
|
34
|
-
/** @type {TokenTypeEncoder[]} */
|
|
35
|
-
const encoders = []
|
|
36
|
-
/** @type {{type:Type,elements:number}[]} */
|
|
37
|
-
const inRecursive = []
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @param {Bl} buf
|
|
41
|
-
*/
|
|
42
|
-
function prefix (buf) {
|
|
43
|
-
const recurs = inRecursive[inRecursive.length - 1]
|
|
44
|
-
if (recurs) {
|
|
45
|
-
if (recurs.type.equals(Type.array)) {
|
|
46
|
-
recurs.elements++
|
|
47
|
-
if (recurs.elements !== 1) { // >first
|
|
48
|
-
buf.push([44]) // ','
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (recurs.type.equals(Type.map)) {
|
|
52
|
-
recurs.elements++
|
|
53
|
-
if (recurs.elements !== 1) { // >first
|
|
54
|
-
if (recurs.elements % 2 === 1) { // key
|
|
55
|
-
buf.push([44]) // ','
|
|
56
|
-
} else {
|
|
57
|
-
buf.push([58]) // ':'
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
encoders[Type.uint.major] = wrapCompareTokens((buf, token) => {
|
|
65
|
-
prefix(buf)
|
|
66
|
-
const is = String(token.value)
|
|
67
|
-
const isa = []
|
|
68
|
-
for (let i = 0; i < is.length; i++) {
|
|
69
|
-
isa[i] = is.charCodeAt(i)
|
|
70
|
-
}
|
|
71
|
-
buf.push(isa)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
encoders[Type.negint.major] = wrapCompareTokens((buf, token, opt) => {
|
|
75
|
-
encoders[Type.uint.major](buf, token, opt)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
encoders[Type.bytes.major] = wrapCompareTokens((_buf, _token, { encodeErrPrefix }) => {
|
|
79
|
-
throw new Error(`${encodeErrPrefix} unsupported type: Uint8Array`)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
encoders[Type.string.major] = wrapCompareTokens((buf, token) => {
|
|
83
|
-
prefix(buf)
|
|
84
|
-
const byts = fromString(JSON.stringify(token.value))
|
|
85
|
-
buf.push(byts.length > 32 ? asU8A(byts) : byts)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
encoders[Type.array.major] = wrapCompareTokens((buf, _token) => {
|
|
89
|
-
prefix(buf)
|
|
90
|
-
inRecursive.push({ type: Type.array, elements: 0 })
|
|
91
|
-
buf.push([91]) // '['
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
encoders[Type.map.major] = wrapCompareTokens((buf, _token) => {
|
|
95
|
-
prefix(buf)
|
|
96
|
-
inRecursive.push({ type: Type.map, elements: 0 })
|
|
97
|
-
buf.push([123]) // '{'
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
encoders[Type.tag.major] = wrapCompareTokens((_buf, _token) => {
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
encoders[Type.float.major] = wrapCompareTokens((buf, token, { encodeErrPrefix }) => {
|
|
104
|
-
if (token.type.equals(Type.break)) {
|
|
105
|
-
const recurs = inRecursive.pop()
|
|
106
|
-
if (recurs) {
|
|
107
|
-
if (recurs.type.equals(Type.array)) {
|
|
108
|
-
buf.push([93]) // ']'
|
|
109
|
-
} else if (recurs.type.equals(Type.map)) {
|
|
110
|
-
buf.push([125]) // '}'
|
|
111
|
-
/* c8 ignore next 3 */
|
|
112
|
-
} else {
|
|
113
|
-
throw new Error('Unexpected recursive type; this should not happen!')
|
|
114
|
-
}
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
/* c8 ignore next 2 */
|
|
118
|
-
throw new Error('Unexpected break; this should not happen!')
|
|
119
|
-
}
|
|
120
|
-
if (token.value === undefined) {
|
|
121
|
-
throw new Error(`${encodeErrPrefix} unsupported type: undefined`)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
prefix(buf)
|
|
125
|
-
if (token.type.equals(Type.true)) {
|
|
126
|
-
buf.push([116, 114, 117, 101]) // 'true'
|
|
127
|
-
return
|
|
128
|
-
} else if (token.type.equals(Type.false)) {
|
|
129
|
-
buf.push([102, 97, 108, 115, 101]) // 'false'
|
|
130
|
-
return
|
|
131
|
-
} else if (token.type.equals(Type.null)) {
|
|
132
|
-
buf.push([110, 117, 108, 108]) // 'null'
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// number
|
|
137
|
-
const is = String(token.value)
|
|
138
|
-
const isa = []
|
|
139
|
-
let dp = false
|
|
140
|
-
for (let i = 0; i < is.length; i++) {
|
|
141
|
-
isa[i] = is.charCodeAt(i)
|
|
142
|
-
if (!dp && (isa[i] === 46 || isa[i] === 101 || isa[i] === 69)) { // '[.eE]'
|
|
143
|
-
dp = true
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (!dp) { // need a decimal point for floats
|
|
147
|
-
isa.push(46) // '.'
|
|
148
|
-
isa.push(48) // '0'
|
|
149
|
-
}
|
|
150
|
-
buf.push(isa)
|
|
151
|
-
})
|
|
152
|
-
return encoders
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// The below code is mostly taken and modified from https://github.com/feross/buffer
|
|
156
|
-
// Licensed MIT. Copyright (c) Feross Aboukhadijeh
|
|
157
|
-
// function encodeUtf8 (string, byts) {
|
|
158
|
-
// let codePoint
|
|
159
|
-
// const length = string.length
|
|
160
|
-
// let leadSurrogate = null
|
|
161
|
-
|
|
162
|
-
// for (let i = 0; i < length; ++i) {
|
|
163
|
-
// codePoint = string.charCodeAt(i)
|
|
164
|
-
|
|
165
|
-
// // is surrogate component
|
|
166
|
-
// if (codePoint > 0xd7ff && codePoint < 0xe000) {
|
|
167
|
-
// // last char was a lead
|
|
168
|
-
// if (!leadSurrogate) {
|
|
169
|
-
// // no lead yet
|
|
170
|
-
// /* c8 ignore next 9 */
|
|
171
|
-
// if (codePoint > 0xdbff) {
|
|
172
|
-
// // unexpected trail
|
|
173
|
-
// byts.push(0xef, 0xbf, 0xbd)
|
|
174
|
-
// continue
|
|
175
|
-
// } else if (i + 1 === length) {
|
|
176
|
-
// // unpaired lead
|
|
177
|
-
// byts.push(0xef, 0xbf, 0xbd)
|
|
178
|
-
// continue
|
|
179
|
-
// }
|
|
180
|
-
|
|
181
|
-
// // valid lead
|
|
182
|
-
// leadSurrogate = codePoint
|
|
183
|
-
|
|
184
|
-
// continue
|
|
185
|
-
// }
|
|
186
|
-
|
|
187
|
-
// // 2 leads in a row
|
|
188
|
-
// /* c8 ignore next 5 */
|
|
189
|
-
// if (codePoint < 0xdc00) {
|
|
190
|
-
// byts.push(0xef, 0xbf, 0xbd)
|
|
191
|
-
// leadSurrogate = codePoint
|
|
192
|
-
// continue
|
|
193
|
-
// }
|
|
194
|
-
|
|
195
|
-
// // valid surrogate pair
|
|
196
|
-
// codePoint = (leadSurrogate - 0xd800 << 10 | codePoint - 0xdc00) + 0x10000
|
|
197
|
-
// /* c8 ignore next 4 */
|
|
198
|
-
// } else if (leadSurrogate) {
|
|
199
|
-
// // valid bmp char, but last char was a lead
|
|
200
|
-
// byts.push(0xef, 0xbf, 0xbd)
|
|
201
|
-
// }
|
|
202
|
-
|
|
203
|
-
// leadSurrogate = null
|
|
204
|
-
|
|
205
|
-
// // encode utf8
|
|
206
|
-
// if (codePoint < 0x80) {
|
|
207
|
-
// // special JSON escapes
|
|
208
|
-
// switch (codePoint) {
|
|
209
|
-
// case 8: // '\b'
|
|
210
|
-
// byts.push(92, 98) // '\\b'
|
|
211
|
-
// continue
|
|
212
|
-
// case 9: // '\t'
|
|
213
|
-
// byts.push(92, 116) // '\\t'
|
|
214
|
-
// continue
|
|
215
|
-
// case 10: // '\n'
|
|
216
|
-
// byts.push(92, 110) // '\\n'
|
|
217
|
-
// continue
|
|
218
|
-
// case 12: // '\f'
|
|
219
|
-
// byts.push(92, 102) // '\\f'
|
|
220
|
-
// continue
|
|
221
|
-
// case 13: // '\r'
|
|
222
|
-
// byts.push(92, 114) // '\\r'
|
|
223
|
-
// continue
|
|
224
|
-
// case 34: // '"'
|
|
225
|
-
// byts.push(92, 34) // '\\"'
|
|
226
|
-
// continue
|
|
227
|
-
// case 92: // '\\'
|
|
228
|
-
// byts.push(92, 92) // '\\\\'
|
|
229
|
-
// continue
|
|
230
|
-
// }
|
|
231
|
-
|
|
232
|
-
// byts.push(codePoint)
|
|
233
|
-
// } else if (codePoint < 0x800) {
|
|
234
|
-
// /* c8 ignore next 1 */
|
|
235
|
-
// byts.push(
|
|
236
|
-
// codePoint >> 0x6 | 0xc0,
|
|
237
|
-
// codePoint & 0x3f | 0x80
|
|
238
|
-
// )
|
|
239
|
-
// } else if (codePoint < 0x10000) {
|
|
240
|
-
// /* c8 ignore next 1 */
|
|
241
|
-
// byts.push(
|
|
242
|
-
// codePoint >> 0xc | 0xe0,
|
|
243
|
-
// codePoint >> 0x6 & 0x3f | 0x80,
|
|
244
|
-
// codePoint & 0x3f | 0x80
|
|
245
|
-
// )
|
|
246
|
-
// /* c8 ignore next 9 */
|
|
247
|
-
// } else if (codePoint < 0x110000) {
|
|
248
|
-
// byts.push(
|
|
249
|
-
// codePoint >> 0x12 | 0xf0,
|
|
250
|
-
// codePoint >> 0xc & 0x3f | 0x80,
|
|
251
|
-
// codePoint >> 0x6 & 0x3f | 0x80,
|
|
252
|
-
// codePoint & 0x3f | 0x80
|
|
253
|
-
// )
|
|
254
|
-
// } else {
|
|
255
|
-
// /* c8 ignore next 2 */
|
|
256
|
-
// throw new Error('Invalid code point')
|
|
257
|
-
// }
|
|
258
|
-
// }
|
|
259
|
-
// }
|
|
260
|
-
|
|
261
|
-
const encodeErrPrefix = 'JSON encode error:'
|
|
262
|
-
/**
|
|
263
|
-
* @param {(Token|Token[])[]} e1
|
|
264
|
-
* @param {(Token|Token[])[]} e2
|
|
265
|
-
* @returns {number}
|
|
266
|
-
*/
|
|
267
|
-
function mapSorter (e1, e2) {
|
|
268
|
-
if (Array.isArray(e1[0]) || Array.isArray(e2[0])) {
|
|
269
|
-
throw new Error(`${encodeErrPrefix} complex map keys are not supported`)
|
|
270
|
-
}
|
|
271
|
-
const keyToken1 = e1[0]
|
|
272
|
-
const keyToken2 = e2[0]
|
|
273
|
-
if (!keyToken1.type.equals(Type.string) || !keyToken2.type.equals(Type.string)) {
|
|
274
|
-
throw new Error(`${encodeErrPrefix} non-string map keys are not supported`)
|
|
275
|
-
}
|
|
276
|
-
if (keyToken1 < keyToken2) {
|
|
277
|
-
return -1
|
|
278
|
-
}
|
|
279
|
-
if (keyToken1 > keyToken2) {
|
|
280
|
-
return 1
|
|
281
|
-
}
|
|
282
|
-
/* c8 ignore next 1 */
|
|
283
|
-
throw new Error(`${encodeErrPrefix} unexpected duplicate map keys, this is not supported`)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const defaultEncodeOptions = {
|
|
287
|
-
addBreakTokens: true,
|
|
288
|
-
encodeErrPrefix,
|
|
289
|
-
mapSorter
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* @param {any} data
|
|
294
|
-
* @param {EncodeOptions} [options]
|
|
295
|
-
* @returns {Uint8Array}
|
|
296
|
-
*/
|
|
297
|
-
function encode (data, options) {
|
|
298
|
-
options = Object.assign({}, defaultEncodeOptions, options)
|
|
299
|
-
return encodeCustom(data, makeJSONEncoders(), options)
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export { encode }
|
package/src/cborg/json/json.js
DELETED
package/src/cborg/taglib.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// never reference the file directly to ensure the
|
|
2
|
-
// indepency of the json module
|
|
3
|
-
import { Token, Type } from "@fireproof/vendor/cborg/utils"
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
A collection of some standard CBOR tags.
|
|
7
|
-
|
|
8
|
-
There are no tags included by default in the cborg encoder or decoder, you have
|
|
9
|
-
to include them by passing options. `typeEncoders` for encode() and `tags` for
|
|
10
|
-
decode().
|
|
11
|
-
|
|
12
|
-
The encoders here can be included with these options (see the tests for how this
|
|
13
|
-
can be done), or as examples for writing additional tags. Additional standard
|
|
14
|
-
(and reasonable) tags may be added here by pull request.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/* TAG(2) Bignums https://tools.ietf.org/html/rfc8949#section-3.4.3 */
|
|
18
|
-
const neg1b = BigInt(-1)
|
|
19
|
-
const pos1b = BigInt(1)
|
|
20
|
-
const zerob = BigInt(0)
|
|
21
|
-
// const twob = BigInt(2)
|
|
22
|
-
const eightb = BigInt(8)
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {Uint8Array} bytes
|
|
26
|
-
* @returns {bigint}
|
|
27
|
-
*/
|
|
28
|
-
export function bigIntDecoder (bytes) {
|
|
29
|
-
// TODO: assert that `bytes` is a `Uint8Array`
|
|
30
|
-
let bi = zerob
|
|
31
|
-
for (let ii = 0; ii < bytes.length; ii++) {
|
|
32
|
-
bi = (bi << eightb) + BigInt(bytes[ii])
|
|
33
|
-
}
|
|
34
|
-
return bi
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @param {bigint} bi
|
|
39
|
-
* @returns {Uint8Array}
|
|
40
|
-
*/
|
|
41
|
-
function fromBigInt (bi) {
|
|
42
|
-
const buf = []
|
|
43
|
-
while (bi > 0) {
|
|
44
|
-
buf.unshift(Number(bi) & 0xff)
|
|
45
|
-
bi >>= eightb
|
|
46
|
-
}
|
|
47
|
-
return Uint8Array.from(buf)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// assuming that we're receiving a BigInt here, it should be registered for
|
|
51
|
-
// type 'bigint' for this to work.
|
|
52
|
-
const maxSafeBigInt = BigInt('18446744073709551615') // (twob ** BigInt(64)) - pos1b
|
|
53
|
-
const minSafeBigInt = BigInt('-18446744073709551616') // neg1b * (twob ** BigInt(64))
|
|
54
|
-
/**
|
|
55
|
-
* @param {bigint} obj
|
|
56
|
-
* @returns {Token[]|null}
|
|
57
|
-
*/
|
|
58
|
-
export function bigIntEncoder (obj) {
|
|
59
|
-
if (obj >= minSafeBigInt && obj <= maxSafeBigInt) {
|
|
60
|
-
return null // null = do it the standard way
|
|
61
|
-
}
|
|
62
|
-
return [
|
|
63
|
-
new Token(Type.tag, obj >= zerob ? 2 : 3),
|
|
64
|
-
new Token(Type.bytes, fromBigInt(obj >= zerob ? obj : obj * neg1b - pos1b))
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* TAG(3) Negative Bignums https://tools.ietf.org/html/rfc8949#section-3.4.3
|
|
70
|
-
* @param {Uint8Array} bytes
|
|
71
|
-
* @returns {bigint}
|
|
72
|
-
*/
|
|
73
|
-
export function bigNegIntDecoder (bytes) {
|
|
74
|
-
return neg1b - bigIntDecoder(bytes)
|
|
75
|
-
}
|