@fireproof/vendor 1.1.1 → 1.2.0

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.
Files changed (302) hide show
  1. package/package.json +109 -19
  2. package/src/@ipld/car/LICENSE +4 -0
  3. package/src/@ipld/car/README.md +1132 -0
  4. package/src/@ipld/car/dist/index.min.js +5 -0
  5. package/src/@ipld/car/dist/src/api.d.ts +72 -0
  6. package/src/@ipld/car/dist/src/api.d.ts.map +1 -0
  7. package/src/@ipld/car/dist/src/buffer-decoder.d.ts +67 -0
  8. package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +1 -0
  9. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +116 -0
  10. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +1 -0
  11. package/src/@ipld/car/dist/src/buffer-reader.d.ts +31 -0
  12. package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +1 -0
  13. package/src/@ipld/car/dist/src/buffer-writer.d.ts +86 -0
  14. package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +1 -0
  15. package/src/@ipld/car/dist/src/coding.d.ts +49 -0
  16. package/src/@ipld/car/dist/src/coding.d.ts.map +1 -0
  17. package/src/@ipld/car/dist/src/decoder-common.d.ts +43 -0
  18. package/src/@ipld/car/dist/src/decoder-common.d.ts.map +1 -0
  19. package/src/@ipld/car/dist/src/decoder.d.ts +87 -0
  20. package/src/@ipld/car/dist/src/decoder.d.ts.map +1 -0
  21. package/src/@ipld/car/dist/src/encoder.d.ts +17 -0
  22. package/src/@ipld/car/dist/src/encoder.d.ts.map +1 -0
  23. package/src/@ipld/car/dist/src/header-validator.d.ts +5 -0
  24. package/src/@ipld/car/dist/src/header-validator.d.ts.map +1 -0
  25. package/src/@ipld/car/dist/src/index-browser.d.ts +10 -0
  26. package/src/@ipld/car/dist/src/index-browser.d.ts.map +1 -0
  27. package/src/@ipld/car/dist/src/index.d.ts +11 -0
  28. package/src/@ipld/car/dist/src/index.d.ts.map +1 -0
  29. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +5 -0
  30. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +1 -0
  31. package/src/@ipld/car/dist/src/indexed-reader.d.ts +152 -0
  32. package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +1 -0
  33. package/src/@ipld/car/dist/src/indexer.d.ts +95 -0
  34. package/src/@ipld/car/dist/src/indexer.d.ts.map +1 -0
  35. package/src/@ipld/car/dist/src/iterator-channel.d.ts +7 -0
  36. package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +1 -0
  37. package/src/@ipld/car/dist/src/iterator.d.ts +174 -0
  38. package/src/@ipld/car/dist/src/iterator.d.ts.map +1 -0
  39. package/src/@ipld/car/dist/src/promise-fs-opts.d.ts +28 -0
  40. package/src/@ipld/car/dist/src/promise-fs-opts.d.ts.map +1 -0
  41. package/src/@ipld/car/dist/src/reader-browser.d.ts +151 -0
  42. package/src/@ipld/car/dist/src/reader-browser.d.ts.map +1 -0
  43. package/src/@ipld/car/dist/src/reader.d.ts +40 -0
  44. package/src/@ipld/car/dist/src/reader.d.ts.map +1 -0
  45. package/src/@ipld/car/dist/src/writer-browser.d.ts +155 -0
  46. package/src/@ipld/car/dist/src/writer-browser.d.ts.map +1 -0
  47. package/src/@ipld/car/dist/src/writer.d.ts +45 -0
  48. package/src/@ipld/car/dist/src/writer.d.ts.map +1 -0
  49. package/src/@ipld/car/src/api.ts +90 -0
  50. package/src/@ipld/car/src/buffer-decoder.js +213 -0
  51. package/src/@ipld/car/src/buffer-reader-browser.js +144 -0
  52. package/src/@ipld/car/src/buffer-reader.js +51 -0
  53. package/src/@ipld/car/src/buffer-writer.js +286 -0
  54. package/src/@ipld/car/src/coding.ts +68 -0
  55. package/src/@ipld/car/src/decoder-common.js +82 -0
  56. package/src/@ipld/car/src/decoder.js +347 -0
  57. package/src/@ipld/car/src/encoder.js +76 -0
  58. package/src/@ipld/car/src/header-validator.js +214 -0
  59. package/src/@ipld/car/src/header.ipldsch +18 -0
  60. package/src/@ipld/car/src/index-browser.js +18 -0
  61. package/src/@ipld/car/src/index.js +21 -0
  62. package/src/@ipld/car/src/indexed-reader-browser.js +7 -0
  63. package/src/@ipld/car/src/indexed-reader.js +211 -0
  64. package/src/@ipld/car/src/indexer.js +130 -0
  65. package/src/@ipld/car/src/iterator-channel.js +91 -0
  66. package/src/@ipld/car/src/iterator.js +267 -0
  67. package/src/@ipld/car/src/promise-fs-opts.js +46 -0
  68. package/src/@ipld/car/src/reader-browser.js +194 -0
  69. package/src/@ipld/car/src/reader.js +54 -0
  70. package/src/@ipld/car/src/writer-browser.js +250 -0
  71. package/src/@ipld/car/src/writer.js +81 -0
  72. package/src/@ipld/dag-cbor/LICENSE +4 -0
  73. package/src/@ipld/dag-cbor/README.md +80 -0
  74. package/src/@ipld/dag-cbor/dist/index.min.js +3 -0
  75. package/src/@ipld/dag-cbor/dist/src/index.d.ts +67 -0
  76. package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +1 -0
  77. package/src/@ipld/dag-cbor/src/index.js +147 -0
  78. package/src/@ipld/dag-json/LICENSE +4 -0
  79. package/src/@ipld/dag-json/README.md +58 -0
  80. package/src/@ipld/dag-json/dist/index.min.js +3 -0
  81. package/src/@ipld/dag-json/dist/src/index.d.ts +12 -0
  82. package/src/@ipld/dag-json/dist/src/index.d.ts.map +1 -0
  83. package/src/@ipld/dag-json/src/index.js +291 -0
  84. package/src/@web3-storage/pail/dist/src/batch/index.d.ts +53 -1
  85. package/src/@web3-storage/pail/dist/src/batch/index.d.ts.map +1 -1
  86. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts +1 -1
  87. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts.map +1 -1
  88. package/src/@web3-storage/pail/dist/src/block.d.ts +2 -2
  89. package/src/@web3-storage/pail/dist/src/block.d.ts.map +1 -1
  90. package/src/@web3-storage/pail/dist/src/clock/index.d.ts +2 -2
  91. package/src/@web3-storage/pail/dist/src/clock/index.d.ts.map +1 -1
  92. package/src/@web3-storage/pail/dist/src/crdt/batch/index.d.ts.map +1 -1
  93. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts +2 -2
  94. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts.map +1 -1
  95. package/src/@web3-storage/pail/dist/src/diff.d.ts +3 -3
  96. package/src/@web3-storage/pail/dist/src/diff.d.ts.map +1 -1
  97. package/src/@web3-storage/pail/dist/src/index.d.ts +1 -1
  98. package/src/@web3-storage/pail/dist/src/index.d.ts.map +1 -1
  99. package/src/@web3-storage/pail/dist/src/merge.d.ts.map +1 -1
  100. package/src/@web3-storage/pail/dist/src/shard.d.ts +4 -4
  101. package/src/@web3-storage/pail/dist/src/shard.d.ts.map +1 -1
  102. package/src/@web3-storage/pail/dist/tsconfig.tsbuildinfo +1 -1
  103. package/src/@web3-storage/pail/src/api.ts +1 -1
  104. package/src/@web3-storage/pail/src/clock/index.js +1 -1
  105. package/src/@web3-storage/pail/src/shard.js +1 -1
  106. package/src/cborg/.github/dependabot.yml +16 -0
  107. package/src/cborg/.github/workflows/test-and-release.yml +52 -0
  108. package/src/cborg/CHANGELOG.md +513 -0
  109. package/src/cborg/LICENSE +13 -0
  110. package/src/cborg/README.md +515 -0
  111. package/src/cborg/bench/bench.js +117 -0
  112. package/src/cborg/bench/json.js +124 -0
  113. package/src/cborg/bench/package.json +8 -0
  114. package/src/cborg/cborg/bin.js +189 -0
  115. package/src/cborg/cborg/common.js +28 -0
  116. package/src/cborg/cborg/decode.js +211 -0
  117. package/src/cborg/cborg/diagnostic.js +158 -0
  118. package/src/cborg/cborg/diagnostic_test.js +117 -0
  119. package/src/cborg/cborg/encode.js +466 -0
  120. package/src/cborg/cborg/index.js +33 -0
  121. package/src/cborg/cborg/is.js +106 -0
  122. package/src/cborg/cborg/length.js +62 -0
  123. package/src/cborg/example-bytestrings.js +180 -0
  124. package/src/cborg/example-json.js +6 -0
  125. package/src/cborg/example.js +5 -0
  126. package/src/cborg/interface.ts +59 -0
  127. package/src/cborg/json/decode.js +462 -0
  128. package/src/cborg/json/encode.js +302 -0
  129. package/src/cborg/json/json.js +4 -0
  130. package/src/cborg/taglib.js +75 -0
  131. package/src/cborg/test/appendix_a.js +647 -0
  132. package/src/cborg/test/common.js +18 -0
  133. package/src/cborg/test/node-test-bin.js +402 -0
  134. package/src/cborg/test/noop-bin-test.js +3 -0
  135. package/src/cborg/test/test-0uint.js +103 -0
  136. package/src/cborg/test/test-1negint.js +96 -0
  137. package/src/cborg/test/test-2bytes.js +198 -0
  138. package/src/cborg/test/test-3string.js +136 -0
  139. package/src/cborg/test/test-4array.js +93 -0
  140. package/src/cborg/test/test-5map.js +284 -0
  141. package/src/cborg/test/test-6tag.js +84 -0
  142. package/src/cborg/test/test-7float.js +131 -0
  143. package/src/cborg/test/test-bl.js +37 -0
  144. package/src/cborg/test/test-cbor-vectors.js +107 -0
  145. package/src/cborg/test/test-decode-errors.js +65 -0
  146. package/src/cborg/test/test-fuzz.js +42 -0
  147. package/src/cborg/test/test-json.js +219 -0
  148. package/src/cborg/test/test-length.js +65 -0
  149. package/src/cborg/test/test-partial.js +111 -0
  150. package/src/cborg/tsconfig.json +48 -0
  151. package/src/cborg/types/cborg/decode.d.ts +43 -0
  152. package/src/cborg/types/cborg/decode.d.ts.map +1 -0
  153. package/src/cborg/types/cborg/encode.d.ts +51 -0
  154. package/src/cborg/types/cborg/encode.d.ts.map +1 -0
  155. package/src/cborg/types/cborg/index.d.ts +26 -0
  156. package/src/cborg/types/cborg/index.d.ts.map +1 -0
  157. package/src/cborg/types/cborg/is.d.ts +6 -0
  158. package/src/cborg/types/cborg/is.d.ts.map +1 -0
  159. package/src/cborg/types/example.d.ts +2 -0
  160. package/src/cborg/types/example.d.ts.map +1 -0
  161. package/src/cborg/types/interface.d.ts +49 -0
  162. package/src/cborg/types/interface.d.ts.map +1 -0
  163. package/src/cborg/types/json/decode.d.ts +67 -0
  164. package/src/cborg/types/json/decode.d.ts.map +1 -0
  165. package/src/cborg/types/json/encode.d.ts +11 -0
  166. package/src/cborg/types/json/encode.d.ts.map +1 -0
  167. package/src/cborg/types/json/json.d.ts +6 -0
  168. package/src/cborg/types/json/json.d.ts.map +1 -0
  169. package/src/cborg/types/taglib.d.ts +18 -0
  170. package/src/cborg/types/taglib.d.ts.map +1 -0
  171. package/src/cborg/types/tsconfig.tsbuildinfo +1 -0
  172. package/src/cborg/types/utils/0uint.d.ts +102 -0
  173. package/src/cborg/types/utils/0uint.d.ts.map +1 -0
  174. package/src/cborg/types/utils/1negint.d.ts +59 -0
  175. package/src/cborg/types/utils/1negint.d.ts.map +1 -0
  176. package/src/cborg/types/utils/2bytes.d.ts +69 -0
  177. package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
  178. package/src/cborg/types/utils/3string.d.ts +46 -0
  179. package/src/cborg/types/utils/3string.d.ts.map +1 -0
  180. package/src/cborg/types/utils/4array.d.ts +66 -0
  181. package/src/cborg/types/utils/4array.d.ts.map +1 -0
  182. package/src/cborg/types/utils/5map.d.ts +66 -0
  183. package/src/cborg/types/utils/5map.d.ts.map +1 -0
  184. package/src/cborg/types/utils/6tag.d.ts +62 -0
  185. package/src/cborg/types/utils/6tag.d.ts.map +1 -0
  186. package/src/cborg/types/utils/7float.d.ts +60 -0
  187. package/src/cborg/types/utils/7float.d.ts.map +1 -0
  188. package/src/cborg/types/utils/bl.d.ts +26 -0
  189. package/src/cborg/types/utils/bl.d.ts.map +1 -0
  190. package/src/cborg/types/utils/byte-utils.d.ts +53 -0
  191. package/src/cborg/types/utils/byte-utils.d.ts.map +1 -0
  192. package/src/cborg/types/utils/common.d.ts +8 -0
  193. package/src/cborg/types/utils/common.d.ts.map +1 -0
  194. package/src/cborg/types/utils/index.d.ts +13 -0
  195. package/src/cborg/types/utils/index.d.ts.map +1 -0
  196. package/src/cborg/types/utils/jump.d.ts +16 -0
  197. package/src/cborg/types/utils/jump.d.ts.map +1 -0
  198. package/src/cborg/types/utils/token.d.ts +59 -0
  199. package/src/cborg/types/utils/token.d.ts.map +1 -0
  200. package/src/cborg/utils/0uint.js +229 -0
  201. package/src/cborg/utils/1negint.js +111 -0
  202. package/src/cborg/utils/2bytes.js +135 -0
  203. package/src/cborg/utils/3string.js +90 -0
  204. package/src/cborg/utils/4array.js +114 -0
  205. package/src/cborg/utils/5map.js +113 -0
  206. package/src/cborg/utils/6tag.js +81 -0
  207. package/src/cborg/utils/7float.js +310 -0
  208. package/src/cborg/utils/bl.js +124 -0
  209. package/src/cborg/utils/byte-utils.js +417 -0
  210. package/src/cborg/utils/common.js +11 -0
  211. package/src/cborg/utils/index.js +12 -0
  212. package/src/cborg/utils/jump.js +222 -0
  213. package/src/cborg/utils/token.js +76 -0
  214. package/src/ipfs-unixfs-exporter/LICENSE +4 -0
  215. package/src/ipfs-unixfs-exporter/README.md +105 -0
  216. package/src/ipfs-unixfs-exporter/dist/index.min.js +3 -0
  217. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +57 -0
  218. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +1 -0
  219. package/src/ipfs-unixfs-exporter/dist/src/errors.js +73 -0
  220. package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +1 -0
  221. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +355 -0
  222. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +1 -0
  223. package/src/ipfs-unixfs-exporter/dist/src/index.js +197 -0
  224. package/src/ipfs-unixfs-exporter/dist/src/index.js.map +1 -0
  225. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +4 -0
  226. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +1 -0
  227. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +9 -0
  228. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +1 -0
  229. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +4 -0
  230. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +1 -0
  231. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +9 -0
  232. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +1 -0
  233. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +4 -0
  234. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +1 -0
  235. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +38 -0
  236. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +1 -0
  237. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +4 -0
  238. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +1 -0
  239. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +30 -0
  240. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +1 -0
  241. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +4 -0
  242. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +1 -0
  243. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +9 -0
  244. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +1 -0
  245. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +4 -0
  246. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +1 -0
  247. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +37 -0
  248. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +1 -0
  249. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +4 -0
  250. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +1 -0
  251. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +29 -0
  252. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +1 -0
  253. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +4 -0
  254. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +1 -0
  255. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +153 -0
  256. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +1 -0
  257. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +4 -0
  258. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +1 -0
  259. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +59 -0
  260. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +1 -0
  261. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +4 -0
  262. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +1 -0
  263. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +25 -0
  264. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +1 -0
  265. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +4 -0
  266. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +1 -0
  267. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +104 -0
  268. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +1 -0
  269. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +3 -0
  270. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +1 -0
  271. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +20 -0
  272. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +1 -0
  273. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +6 -0
  274. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +1 -0
  275. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +116 -0
  276. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +1 -0
  277. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +4 -0
  278. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +1 -0
  279. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +57 -0
  280. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +1 -0
  281. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +6 -0
  282. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +1 -0
  283. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +30 -0
  284. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +1 -0
  285. package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +58 -0
  286. package/src/ipfs-unixfs-exporter/src/errors.ts +87 -0
  287. package/src/ipfs-unixfs-exporter/src/index.ts +498 -0
  288. package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +12 -0
  289. package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +12 -0
  290. package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +49 -0
  291. package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +35 -0
  292. package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +12 -0
  293. package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +49 -0
  294. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +39 -0
  295. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +198 -0
  296. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +76 -0
  297. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +37 -0
  298. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +121 -0
  299. package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +24 -0
  300. package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +149 -0
  301. package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +62 -0
  302. package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +38 -0
@@ -0,0 +1,151 @@
1
+ /**
2
+ * @private
3
+ * @param {BytesReader} reader
4
+ * @returns {Promise<CarReader>}
5
+ */
6
+ export function decodeReaderComplete(reader: BytesReader): Promise<CarReader>;
7
+ /**
8
+ * @typedef {import('multiformats').CID} CID
9
+ * @typedef {import('./api').Block} Block
10
+ * @typedef {import('./api').CarReader} CarReaderIface
11
+ * @typedef {import('./coding').BytesReader} BytesReader
12
+ * @typedef {import('./coding').CarHeader} CarHeader
13
+ * @typedef {import('./coding').CarV2Header} CarV2Header
14
+ */
15
+ /**
16
+ * Provides blockstore-like access to a CAR.
17
+ *
18
+ * Implements the `RootsReader` interface:
19
+ * {@link CarReader.getRoots `getRoots()`}. And the `BlockReader` interface:
20
+ * {@link CarReader.get `get()`}, {@link CarReader.has `has()`},
21
+ * {@link CarReader.blocks `blocks()`} (defined as a `BlockIterator`) and
22
+ * {@link CarReader.cids `cids()`} (defined as a `CIDIterator`).
23
+ *
24
+ * Load this class with either `import { CarReader } from '@ipld/car/reader'`
25
+ * (`const { CarReader } = require('@ipld/car/reader')`). Or
26
+ * `import { CarReader } from '@ipld/car'` (`const { CarReader } = require('@ipld/car')`).
27
+ * The former will likely result in smaller bundle sizes where this is
28
+ * important.
29
+ *
30
+ * @name CarReader
31
+ * @class
32
+ * @implements {CarReaderIface}
33
+ * @property {number} version The version number of the CAR referenced by this
34
+ * reader (should be `1` or `2`).
35
+ */
36
+ export class CarReader implements CarReaderIface {
37
+ /**
38
+ * Instantiate a {@link CarReader} from a `Uint8Array` blob. This performs a
39
+ * decode fully in memory and maintains the decoded state in memory for full
40
+ * access to the data via the `CarReader` API.
41
+ *
42
+ * @async
43
+ * @static
44
+ * @memberof CarReader
45
+ * @param {Uint8Array} bytes
46
+ * @returns {Promise<CarReader>}
47
+ */
48
+ static fromBytes(bytes: Uint8Array): Promise<CarReader>;
49
+ /**
50
+ * Instantiate a {@link CarReader} from a `AsyncIterable<Uint8Array>`, such as
51
+ * a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
52
+ * This performs a decode fully in memory and maintains the decoded state in
53
+ * memory for full access to the data via the `CarReader` API.
54
+ *
55
+ * Care should be taken for large archives; this API may not be appropriate
56
+ * where memory is a concern or the archive is potentially larger than the
57
+ * amount of memory that the runtime can handle.
58
+ *
59
+ * @async
60
+ * @static
61
+ * @memberof CarReader
62
+ * @param {AsyncIterable<Uint8Array>} asyncIterable
63
+ * @returns {Promise<CarReader>}
64
+ */
65
+ static fromIterable(asyncIterable: AsyncIterable<Uint8Array>): Promise<CarReader>;
66
+ /**
67
+ * @constructs CarReader
68
+ * @param {CarHeader|CarV2Header} header
69
+ * @param {Block[]} blocks
70
+ */
71
+ constructor(header: CarHeader | CarV2Header, blocks: Block[]);
72
+ _header: import("./coding").CarHeader | import("./coding").CarV2Header;
73
+ _blocks: import("./api").Block[];
74
+ _keys: string[];
75
+ /**
76
+ * @property
77
+ * @memberof CarReader
78
+ * @instance
79
+ */
80
+ get version(): 1 | 2;
81
+ /**
82
+ * Get the list of roots defined by the CAR referenced by this reader. May be
83
+ * zero or more `CID`s.
84
+ *
85
+ * @function
86
+ * @memberof CarReader
87
+ * @instance
88
+ * @async
89
+ * @returns {Promise<CID[]>}
90
+ */
91
+ getRoots(): Promise<CID[]>;
92
+ /**
93
+ * Check whether a given `CID` exists within the CAR referenced by this
94
+ * reader.
95
+ *
96
+ * @function
97
+ * @memberof CarReader
98
+ * @instance
99
+ * @async
100
+ * @param {CID} key
101
+ * @returns {Promise<boolean>}
102
+ */
103
+ has(key: CID): Promise<boolean>;
104
+ /**
105
+ * Fetch a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) from the CAR
106
+ * referenced by this reader matching the provided `CID`. In the case where
107
+ * the provided `CID` doesn't exist within the CAR, `undefined` will be
108
+ * returned.
109
+ *
110
+ * @function
111
+ * @memberof CarReader
112
+ * @instance
113
+ * @async
114
+ * @param {CID} key
115
+ * @returns {Promise<Block | undefined>}
116
+ */
117
+ get(key: CID): Promise<Block | undefined>;
118
+ /**
119
+ * Returns a `BlockIterator` (`AsyncIterable<Block>`) that iterates over all
120
+ * of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within
121
+ * the CAR referenced by this reader.
122
+ *
123
+ * @function
124
+ * @memberof CarReader
125
+ * @instance
126
+ * @async
127
+ * @generator
128
+ * @returns {AsyncGenerator<Block>}
129
+ */
130
+ blocks(): AsyncGenerator<Block>;
131
+ /**
132
+ * Returns a `CIDIterator` (`AsyncIterable<CID>`) that iterates over all of
133
+ * the `CID`s contained within the CAR referenced by this reader.
134
+ *
135
+ * @function
136
+ * @memberof CarReader
137
+ * @instance
138
+ * @async
139
+ * @generator
140
+ * @returns {AsyncGenerator<CID>}
141
+ */
142
+ cids(): AsyncGenerator<CID>;
143
+ }
144
+ export const __browser: true;
145
+ export type CID = import('multiformats').CID;
146
+ export type Block = import('./api').Block;
147
+ export type CarReaderIface = import('./api').CarReader;
148
+ export type BytesReader = import('./coding').BytesReader;
149
+ export type CarHeader = import('./coding').CarHeader;
150
+ export type CarV2Header = import('./coding').CarV2Header;
151
+ //# sourceMappingURL=reader-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader-browser.d.ts","sourceRoot":"","sources":["../../src/reader-browser.js"],"names":[],"mappings":"AAiLA;;;;GAIG;AACH,6CAHW,WAAW,GACT,QAAQ,SAAS,CAAC,CAW9B;AA7LD;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAuGE;;;;;;;;;;OAUG;IACH,wBAHW,UAAU,GACR,QAAQ,SAAS,CAAC,CAO9B;IAED;;;;;;;;;;;;;;;OAeG;IACH,mCAHW,cAAc,UAAU,CAAC,GACvB,QAAQ,SAAS,CAAC,CAO9B;IA7ID;;;;OAIG;IACH,oBAHW,SAAS,GAAC,WAAW,UACrB,KAAK,EAAE,EAMjB;IAHC,uEAAqB;IACrB,iCAAqB;IACrB,gBAAgD;IAGlD;;;;OAIG;IACH,qBAEC;IAED;;;;;;;;;OASG;IACH,YAFa,QAAQ,GAAG,EAAE,CAAC,CAI1B;IAED;;;;;;;;;;OAUG;IACH,SAHW,GAAG,GACD,QAAQ,OAAO,CAAC,CAI5B;IAED;;;;;;;;;;;;OAYG;IACH,SAHW,GAAG,GACD,QAAQ,KAAK,GAAG,SAAS,CAAC,CAKtC;IAED;;;;;;;;;;;OAWG;IACH,UAFa,eAAe,KAAK,CAAC,CAMjC;IAED;;;;;;;;;;OAUG;IACH,QAFa,eAAe,GAAG,CAAC,CAM/B;CA0CF;AAkBD,6BAA6B;kBA9LhB,OAAO,cAAc,EAAE,GAAG;oBAC1B,OAAO,OAAO,EAAE,KAAK;6BACrB,OAAO,OAAO,EAAE,SAAS;0BACzB,OAAO,UAAU,EAAE,WAAW;wBAC9B,OAAO,UAAU,EAAE,SAAS;0BAC5B,OAAO,UAAU,EAAE,WAAW"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @typedef {import('./api').Block} Block
3
+ * @typedef {import('./api').BlockIndex} BlockIndex
4
+ * @typedef {import('./api').CarReader} CarReaderIface
5
+ * @typedef {import('fs').promises.FileHandle} FileHandle
6
+ */
7
+ /**
8
+ * @class
9
+ * @implements {CarReaderIface}
10
+ */
11
+ export class CarReader extends BrowserCarReader implements CarReaderIface {
12
+ /**
13
+ * Reads a block directly from a file descriptor for an open CAR file. This
14
+ * function is **only available in Node.js** and not a browser environment.
15
+ *
16
+ * This function can be used in connection with {@link CarIndexer} which emits
17
+ * the `BlockIndex` objects that are required by this function.
18
+ *
19
+ * The user is responsible for opening and closing the file used in this call.
20
+ *
21
+ * @async
22
+ * @static
23
+ * @memberof CarReader
24
+ * @param {FileHandle | number} fd - A file descriptor from the
25
+ * Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
26
+ * from `fs.promises.open()`.
27
+ * @param {BlockIndex} blockIndex - An index pointing to the location of the
28
+ * Block required. This `BlockIndex` should take the form:
29
+ * `{cid:CID, blockLength:number, blockOffset:number}`.
30
+ * @returns {Promise<Block>} A `{ cid:CID, bytes:Uint8Array }` pair.
31
+ */
32
+ static readRaw(fd: FileHandle | number, blockIndex: BlockIndex): Promise<Block>;
33
+ }
34
+ export const __browser: boolean;
35
+ export type Block = import('./api').Block;
36
+ export type BlockIndex = import('./api').BlockIndex;
37
+ export type CarReaderIface = import('./api').CarReader;
38
+ export type FileHandle = import('fs').promises.FileHandle;
39
+ import { CarReader as BrowserCarReader } from './reader-browser.js';
40
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/reader.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH;;;GAGG;AACH;IACE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,mBARW,UAAU,GAAG,MAAM,cAGnB,UAAU,GAGR,QAAQ,KAAK,CAAC,CAiB1B;CACF;AAED,gCAA+B;oBAjDlB,OAAO,OAAO,EAAE,KAAK;yBACrB,OAAO,OAAO,EAAE,UAAU;6BAC1B,OAAO,OAAO,EAAE,SAAS;yBACzB,OAAO,IAAI,EAAE,QAAQ,CAAC,UAAU;8CANC,qBAAqB"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @typedef {import('./api').Block} Block
3
+ * @typedef {import('./api').BlockWriter} BlockWriter
4
+ * @typedef {import('./api').WriterChannel} WriterChannel
5
+ * @typedef {import('./coding').CarEncoder} CarEncoder
6
+ * @typedef {import('./coding').IteratorChannel<Uint8Array>} IteratorChannel
7
+ */
8
+ /**
9
+ * Provides a writer interface for the creation of CAR files.
10
+ *
11
+ * Creation of a `CarWriter` involves the instatiation of an input / output pair
12
+ * in the form of a `WriterChannel`, which is a
13
+ * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair. These two
14
+ * components form what can be thought of as a stream-like interface. The
15
+ * `writer` component (an instantiated `CarWriter`), has methods to
16
+ * {@link CarWriter.put `put()`} new blocks and {@link CarWriter.put `close()`}
17
+ * the writing operation (finalising the CAR archive). The `out` component is
18
+ * an `AsyncIterable` that yields the bytes of the archive. This can be
19
+ * redirected to a file or other sink. In Node.js, you can use the
20
+ * [`Readable.from()`](https://nodejs.org/api/stream.html#stream_stream_readable_from_iterable_options)
21
+ * API to convert this to a standard Node.js stream, or it can be directly fed
22
+ * to a
23
+ * [`stream.pipeline()`](https://nodejs.org/api/stream.html#stream_stream_pipeline_source_transforms_destination_callback).
24
+ *
25
+ * The channel will provide a form of backpressure. The `Promise` from a
26
+ * `write()` won't resolve until the resulting data is drained from the `out`
27
+ * iterable.
28
+ *
29
+ * It is also possible to ignore the `Promise` from `write()` calls and allow
30
+ * the generated data to queue in memory. This should be avoided for large CAR
31
+ * archives of course due to the memory costs and potential for memory overflow.
32
+ *
33
+ * Load this class with either
34
+ * `import { CarWriter } from '@ipld/car/writer'`
35
+ * (`const { CarWriter } = require('@ipld/car/writer')`). Or
36
+ * `import { CarWriter } from '@ipld/car'`
37
+ * (`const { CarWriter } = require('@ipld/car')`). The former will likely
38
+ * result in smaller bundle sizes where this is important.
39
+ *
40
+ * @name CarWriter
41
+ * @class
42
+ * @implements {BlockWriter}
43
+ */
44
+ export class CarWriter implements BlockWriter {
45
+ /**
46
+ * Create a new CAR writer "channel" which consists of a
47
+ * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
48
+ *
49
+ * @async
50
+ * @static
51
+ * @memberof CarWriter
52
+ * @param {CID[] | CID | void} roots
53
+ * @returns {WriterChannel} The channel takes the form of
54
+ * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
55
+ */
56
+ static create(roots: CID[] | CID | void): WriterChannel;
57
+ /**
58
+ * Create a new CAR appender "channel" which consists of a
59
+ * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
60
+ * This appender does not consider roots and does not produce a CAR header.
61
+ * It is designed to append blocks to an _existing_ CAR archive. It is
62
+ * expected that `out` will be concatenated onto the end of an existing
63
+ * archive that already has a properly formatted header.
64
+ *
65
+ * @async
66
+ * @static
67
+ * @memberof CarWriter
68
+ * @returns {WriterChannel} The channel takes the form of
69
+ * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
70
+ */
71
+ static createAppender(): WriterChannel;
72
+ /**
73
+ * Update the list of roots in the header of an existing CAR as represented
74
+ * in a Uint8Array.
75
+ *
76
+ * This operation is an _overwrite_, the total length of the CAR will not be
77
+ * modified. A rejection will occur if the new header will not be the same
78
+ * length as the existing header, in which case the CAR will not be modified.
79
+ * It is the responsibility of the user to ensure that the roots being
80
+ * replaced encode as the same length as the new roots.
81
+ *
82
+ * The byte array passed in an argument will be modified and also returned
83
+ * upon successful modification.
84
+ *
85
+ * @async
86
+ * @static
87
+ * @memberof CarWriter
88
+ * @param {Uint8Array} bytes
89
+ * @param {CID[]} roots - A new list of roots to replace the existing list in
90
+ * the CAR header. The new header must take up the same number of bytes as the
91
+ * existing header, so the roots should collectively be the same byte length
92
+ * as the existing roots.
93
+ * @returns {Promise<Uint8Array>}
94
+ */
95
+ static updateRootsInBytes(bytes: Uint8Array, roots: CID[]): Promise<Uint8Array>;
96
+ /**
97
+ * @param {CID[]} roots
98
+ * @param {CarEncoder} encoder
99
+ */
100
+ constructor(roots: CID[], encoder: CarEncoder);
101
+ _encoder: import("./coding").CarEncoder;
102
+ /** @type {Promise<void>} */
103
+ _mutex: Promise<void>;
104
+ _ended: boolean;
105
+ /**
106
+ * Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
107
+ *
108
+ * @function
109
+ * @memberof CarWriter
110
+ * @instance
111
+ * @async
112
+ * @param {Block} block - A `{ cid:CID, bytes:Uint8Array }` pair.
113
+ * @returns {Promise<void>} The returned promise will only resolve once the
114
+ * bytes this block generates are written to the `out` iterable.
115
+ */
116
+ put(block: Block): Promise<void>;
117
+ /**
118
+ * Finalise the CAR archive and signal that the `out` iterable should end once
119
+ * any remaining bytes are written.
120
+ *
121
+ * @function
122
+ * @memberof CarWriter
123
+ * @instance
124
+ * @async
125
+ * @returns {Promise<void>}
126
+ */
127
+ close(): Promise<void>;
128
+ /**
129
+ * Returns the version number of the CAR file being written
130
+ *
131
+ * @returns {number}
132
+ */
133
+ version(): number;
134
+ }
135
+ /**
136
+ * @class
137
+ * @implements {AsyncIterable<Uint8Array>}
138
+ */
139
+ export class CarWriterOut implements AsyncIterable<Uint8Array> {
140
+ /**
141
+ * @param {AsyncIterator<Uint8Array>} iterator
142
+ */
143
+ constructor(iterator: AsyncIterator<Uint8Array>);
144
+ _iterator: AsyncIterator<Uint8Array, any, undefined>;
145
+ _iterating: boolean | undefined;
146
+ [Symbol.asyncIterator](): AsyncIterator<Uint8Array, any, undefined>;
147
+ }
148
+ export const __browser: true;
149
+ export type Block = import('./api').Block;
150
+ export type BlockWriter = import('./api').BlockWriter;
151
+ export type WriterChannel = import('./api').WriterChannel;
152
+ export type CarEncoder = import('./coding').CarEncoder;
153
+ export type IteratorChannel = import('./coding').IteratorChannel<Uint8Array>;
154
+ import { CID } from 'multiformats/cid';
155
+ //# sourceMappingURL=writer-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-browser.d.ts","sourceRoot":"","sources":["../../src/writer-browser.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;IAkEE;;;;;;;;;;OAUG;IACH,qBAJW,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,GAChB,aAAa,CASzB;IAED;;;;;;;;;;;;;OAaG;IACH,yBAHa,aAAa,CASzB;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,iCAPW,UAAU,SACV,GAAG,EAAE,GAIH,QAAQ,UAAU,CAAC,CAW/B;IA1ID;;;OAGG;IACH,mBAHW,GAAG,EAAE,WACL,UAAU,EAOpB;IAJC,wCAAuB;IACvB,4BAA4B;IAC5B,QADW,QAAQ,IAAI,CAAC,CACa;IACrC,gBAAmB;IAGrB;;;;;;;;;;OAUG;IACH,WAJW,KAAK,GACH,QAAQ,IAAI,CAAC,CAgBzB;IAED;;;;;;;;;OASG;IACH,SAFa,QAAQ,IAAI,CAAC,CASzB;IAED;;;;OAIG;IACH,WAFa,MAAM,CAIlB;CA4EF;AAED;;;GAGG;AACH,mDAF8B,UAAU;IAGtC;;OAEG;IACH,sBAFW,cAAc,UAAU,CAAC,EAInC;IADC,qDAAyB;IAOzB,gCAAsB;IAJxB,oEAMC;CACF;AAuCD,6BAA6B;oBAnPhB,OAAO,OAAO,EAAE,KAAK;0BACrB,OAAO,OAAO,EAAE,WAAW;4BAC3B,OAAO,OAAO,EAAE,aAAa;yBAC7B,OAAO,UAAU,EAAE,UAAU;8BAC7B,OAAO,UAAU,EAAE,eAAe,CAAC,UAAU,CAAC;oBAVvC,kBAAkB"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @typedef {import('multiformats/cid').CID} CID
3
+ * @typedef {import('./api').BlockWriter} BlockWriter
4
+ * @typedef {import('fs').promises.FileHandle} FileHandle
5
+ */
6
+ /**
7
+ * @class
8
+ * @implements {BlockWriter}
9
+ */
10
+ export class CarWriter extends BrowserCarWriter implements BlockWriter {
11
+ /**
12
+ * Update the list of roots in the header of an existing CAR file. The first
13
+ * argument must be a file descriptor for CAR file that is open in read and
14
+ * write mode (not append), e.g. `fs.open` or `fs.promises.open` with `'r+'`
15
+ * mode.
16
+ *
17
+ * This operation is an _overwrite_, the total length of the CAR will not be
18
+ * modified. A rejection will occur if the new header will not be the same
19
+ * length as the existing header, in which case the CAR will not be modified.
20
+ * It is the responsibility of the user to ensure that the roots being
21
+ * replaced encode as the same length as the new roots.
22
+ *
23
+ * This function is **only available in Node.js** and not a browser
24
+ * environment.
25
+ *
26
+ * @async
27
+ * @static
28
+ * @memberof CarWriter
29
+ * @param {FileHandle | number} fd - A file descriptor from the
30
+ * Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
31
+ * from `fs.promises.open()`.
32
+ * @param {CID[]} roots - A new list of roots to replace the existing list in
33
+ * the CAR header. The new header must take up the same number of bytes as the
34
+ * existing header, so the roots should collectively be the same byte length
35
+ * as the existing roots.
36
+ * @returns {Promise<void>}
37
+ */
38
+ static updateRootsInFile(fd: FileHandle | number, roots: CID[]): Promise<void>;
39
+ }
40
+ export const __browser: boolean;
41
+ export type CID = import('multiformats/cid').CID;
42
+ export type BlockWriter = import('./api').BlockWriter;
43
+ export type FileHandle = import('fs').promises.FileHandle;
44
+ import { CarWriter as BrowserCarWriter } from './writer-browser.js';
45
+ //# sourceMappingURL=writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/writer.js"],"names":[],"mappings":"AAKA;;;;GAIG;AAEH;;;GAGG;AACH;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,6BATW,UAAU,GAAG,MAAM,SAGnB,GAAG,EAAE,GAIH,QAAQ,IAAI,CAAC,CAoCzB;CACF;AAED,gCAA+B;kBA1ElB,OAAO,kBAAkB,EAAE,GAAG;0BAC9B,OAAO,OAAO,EAAE,WAAW;yBAC3B,OAAO,IAAI,EAAE,QAAQ,CAAC,UAAU;8CALC,qBAAqB"}
@@ -0,0 +1,90 @@
1
+ import type { CID } from 'multiformats/cid'
2
+
3
+ /**
4
+ * Literally any `Iterable` (async or regular).
5
+ */
6
+ export type AwaitIterable<T> = Iterable<T> | AsyncIterable<T>
7
+
8
+ export type { CID }
9
+ /* Generic types for interfacing with block storage */
10
+
11
+ export interface Block {
12
+ cid: CID
13
+ bytes: Uint8Array
14
+ }
15
+
16
+ export interface BlockHeader {
17
+ cid: CID
18
+ length: number
19
+ blockLength: number
20
+ }
21
+
22
+ export interface BlockIndex extends BlockHeader {
23
+ offset: number
24
+ blockOffset: number
25
+ }
26
+
27
+ export interface RootsReader {
28
+ version: number
29
+ getRoots(): Promise<CID[]>
30
+ }
31
+
32
+ export interface RootsBufferReader {
33
+ version: number
34
+ getRoots(): CID[]
35
+ }
36
+
37
+ export interface BlockIterator extends AsyncIterable<Block> {}
38
+
39
+ export interface CIDIterator extends AsyncIterable<CID> {}
40
+
41
+ export interface BlockReader {
42
+ has(key: CID): Promise<boolean>
43
+ get(key: CID): Promise<Block | undefined>
44
+ blocks(): BlockIterator
45
+ cids(): CIDIterator
46
+ }
47
+
48
+ export interface BlockBufferReader {
49
+ has(key: CID): boolean
50
+ get(key: CID): Block | undefined
51
+ blocks(): Iterable<Block>
52
+ cids(): Iterable<CID>
53
+ }
54
+
55
+ export interface BlockWriter {
56
+ put(block: Block): Promise<void>
57
+ close(): Promise<void>
58
+ version(): number
59
+ }
60
+
61
+ export interface CarBufferWriter {
62
+ addRoot(root: CID, options?: { resize?: boolean }): CarBufferWriter
63
+ write(block: Block): CarBufferWriter
64
+ close(options?: { resize?: boolean }): Uint8Array
65
+ }
66
+
67
+ export interface CarBufferWriterOptions {
68
+ roots?: CID[] // defaults to []
69
+ byteOffset?: number // defaults to 0
70
+ byteLength?: number // defaults to buffer.byteLength
71
+
72
+ headerSize?: number // defaults to size needed for provided roots
73
+ }
74
+
75
+ export interface WriterChannel {
76
+ writer: BlockWriter
77
+ out: AsyncIterable<Uint8Array>
78
+ }
79
+
80
+ export interface CarReader extends BlockReader, RootsReader {}
81
+ export interface CarBufferReader extends BlockBufferReader, RootsBufferReader {}
82
+
83
+ /* Specific implementations for CAR block storage */
84
+
85
+ /*
86
+ export interface CarBlockIterator extends BlockIterator, RootsReader {}
87
+ export interface CarCIDIterator extends CIDIterator, RootsReader {}
88
+ export interface CarIndexer extends AsyncIterable<BlockIndex>, RootsReader {}
89
+ export interface CarWriter extends BlockWriter {}
90
+ */