@fireproof/core 0.20.0-dev-preview-63 → 0.20.1-dev-preview-01

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 (408) hide show
  1. package/deno/index.d.ts +7 -0
  2. package/deno/index.js +66 -0
  3. package/deno/index.js.map +1 -0
  4. package/deno/metafile-esm.json +1 -0
  5. package/deno.json +2 -2
  6. package/index.cjs +7268 -0
  7. package/index.cjs.map +1 -0
  8. package/index.d.cts +2742 -0
  9. package/index.d.ts +2742 -15
  10. package/index.js +7267 -14
  11. package/index.js.map +1 -1
  12. package/indexeddb/index.cjs +218 -0
  13. package/indexeddb/index.cjs.map +1 -0
  14. package/indexeddb/index.d.cts +30 -0
  15. package/indexeddb/index.d.ts +30 -0
  16. package/indexeddb/index.js +195 -0
  17. package/indexeddb/index.js.map +1 -0
  18. package/indexeddb/metafile-cjs.json +1 -0
  19. package/indexeddb/metafile-esm.json +1 -0
  20. package/metafile-cjs.json +1 -0
  21. package/metafile-esm.json +1 -0
  22. package/node/index.cjs +97 -0
  23. package/node/index.cjs.map +1 -0
  24. package/node/index.d.cts +7 -0
  25. package/node/index.d.ts +7 -0
  26. package/node/index.js +64 -0
  27. package/node/index.js.map +1 -0
  28. package/node/metafile-cjs.json +1 -0
  29. package/node/metafile-esm.json +1 -0
  30. package/package.json +17 -20
  31. package/react/index.cjs +298 -0
  32. package/react/index.cjs.map +1 -0
  33. package/react/{img-file.d.ts → index.d.cts} +53 -6
  34. package/react/index.d.ts +336 -4
  35. package/react/index.js +264 -3
  36. package/react/index.js.map +1 -1
  37. package/react/metafile-cjs.json +1 -0
  38. package/react/metafile-esm.json +1 -0
  39. package/tests/blockstore/loader.test.ts +1 -1
  40. package/tests/blockstore/store.test.ts +4 -9
  41. package/tests/fireproof/attachable.test.ts +3 -3
  42. package/tests/react/use-fireproof-db-switch.test.tsx +91 -0
  43. package/tests/react/use-fireproof-stability.test.tsx +145 -0
  44. package/tests/www/gallery.html +132 -0
  45. package/tests/www/iife.html +42 -0
  46. package/tests/www/todo-aws.html +232 -0
  47. package/tests/www/todo-ipfs.html +213 -0
  48. package/tests/www/todo-local.html +214 -0
  49. package/tests/www/todo-netlify.html +227 -0
  50. package/tests/www/todo.html +254 -0
  51. package/apply-head-queue.d.ts +0 -18
  52. package/apply-head-queue.d.ts.map +0 -1
  53. package/apply-head-queue.js +0 -47
  54. package/apply-head-queue.js.map +0 -1
  55. package/blockstore/attachable-store.d.ts +0 -17
  56. package/blockstore/attachable-store.d.ts.map +0 -1
  57. package/blockstore/attachable-store.js +0 -295
  58. package/blockstore/attachable-store.js.map +0 -1
  59. package/blockstore/commit-queue.d.ts +0 -12
  60. package/blockstore/commit-queue.d.ts.map +0 -1
  61. package/blockstore/commit-queue.js +0 -52
  62. package/blockstore/commit-queue.js.map +0 -1
  63. package/blockstore/commitor.d.ts +0 -21
  64. package/blockstore/commitor.d.ts.map +0 -1
  65. package/blockstore/commitor.js +0 -104
  66. package/blockstore/commitor.js.map +0 -1
  67. package/blockstore/connect-raw.d.ts +0 -2
  68. package/blockstore/connect-raw.d.ts.map +0 -1
  69. package/blockstore/connect-raw.js +0 -2
  70. package/blockstore/connect-raw.js.map +0 -1
  71. package/blockstore/connection-base.d.ts +0 -2
  72. package/blockstore/connection-base.d.ts.map +0 -1
  73. package/blockstore/connection-base.js +0 -2
  74. package/blockstore/connection-base.js.map +0 -1
  75. package/blockstore/encrypt-helpers.d.ts +0 -2
  76. package/blockstore/encrypt-helpers.d.ts.map +0 -1
  77. package/blockstore/encrypt-helpers.js +0 -2
  78. package/blockstore/encrypt-helpers.js.map +0 -1
  79. package/blockstore/fp-envelope.d.ts +0 -32
  80. package/blockstore/fp-envelope.d.ts.map +0 -1
  81. package/blockstore/fp-envelope.js +0 -14
  82. package/blockstore/fp-envelope.js.map +0 -1
  83. package/blockstore/gateway.d.ts +0 -20
  84. package/blockstore/gateway.d.ts.map +0 -1
  85. package/blockstore/gateway.js +0 -2
  86. package/blockstore/gateway.js.map +0 -1
  87. package/blockstore/index.d.ts +0 -16
  88. package/blockstore/index.d.ts.map +0 -1
  89. package/blockstore/index.js +0 -16
  90. package/blockstore/index.js.map +0 -1
  91. package/blockstore/interceptor-gateway.d.ts +0 -29
  92. package/blockstore/interceptor-gateway.d.ts.map +0 -1
  93. package/blockstore/interceptor-gateway.js +0 -137
  94. package/blockstore/interceptor-gateway.js.map +0 -1
  95. package/blockstore/loader-helpers.d.ts +0 -4
  96. package/blockstore/loader-helpers.d.ts.map +0 -1
  97. package/blockstore/loader-helpers.js +0 -16
  98. package/blockstore/loader-helpers.js.map +0 -1
  99. package/blockstore/loader.d.ts +0 -45
  100. package/blockstore/loader.d.ts.map +0 -1
  101. package/blockstore/loader.js +0 -352
  102. package/blockstore/loader.js.map +0 -1
  103. package/blockstore/register-store-protocol.d.ts +0 -22
  104. package/blockstore/register-store-protocol.d.ts.map +0 -1
  105. package/blockstore/register-store-protocol.js +0 -114
  106. package/blockstore/register-store-protocol.js.map +0 -1
  107. package/blockstore/serde-gateway.d.ts +0 -78
  108. package/blockstore/serde-gateway.d.ts.map +0 -1
  109. package/blockstore/serde-gateway.js +0 -2
  110. package/blockstore/serde-gateway.js.map +0 -1
  111. package/blockstore/store-factory.d.ts +0 -11
  112. package/blockstore/store-factory.d.ts.map +0 -1
  113. package/blockstore/store-factory.js +0 -105
  114. package/blockstore/store-factory.js.map +0 -1
  115. package/blockstore/store-remote.d.ts +0 -2
  116. package/blockstore/store-remote.d.ts.map +0 -1
  117. package/blockstore/store-remote.js +0 -2
  118. package/blockstore/store-remote.js.map +0 -1
  119. package/blockstore/store.d.ts +0 -82
  120. package/blockstore/store.d.ts.map +0 -1
  121. package/blockstore/store.js +0 -438
  122. package/blockstore/store.js.map +0 -1
  123. package/blockstore/task-manager.d.ts +0 -19
  124. package/blockstore/task-manager.d.ts.map +0 -1
  125. package/blockstore/task-manager.js +0 -50
  126. package/blockstore/task-manager.js.map +0 -1
  127. package/blockstore/transaction.d.ts +0 -64
  128. package/blockstore/transaction.d.ts.map +0 -1
  129. package/blockstore/transaction.js +0 -249
  130. package/blockstore/transaction.js.map +0 -1
  131. package/blockstore/types.d.ts +0 -400
  132. package/blockstore/types.d.ts.map +0 -1
  133. package/blockstore/types.js +0 -55
  134. package/blockstore/types.js.map +0 -1
  135. package/blockstore/uri-interceptor.d.ts +0 -19
  136. package/blockstore/uri-interceptor.d.ts.map +0 -1
  137. package/blockstore/uri-interceptor.js +0 -61
  138. package/blockstore/uri-interceptor.js.map +0 -1
  139. package/bundle-not-impl.d.ts +0 -2
  140. package/bundle-not-impl.d.ts.map +0 -1
  141. package/bundle-not-impl.js +0 -4
  142. package/bundle-not-impl.js.map +0 -1
  143. package/cli/main.js +0 -26114
  144. package/context.d.ts +0 -7
  145. package/context.d.ts.map +0 -1
  146. package/context.js +0 -15
  147. package/context.js.map +0 -1
  148. package/crdt-clock.d.ts +0 -27
  149. package/crdt-clock.d.ts.map +0 -1
  150. package/crdt-clock.js +0 -140
  151. package/crdt-clock.js.map +0 -1
  152. package/crdt-helpers.d.ts +0 -16
  153. package/crdt-helpers.d.ts.map +0 -1
  154. package/crdt-helpers.js +0 -316
  155. package/crdt-helpers.js.map +0 -1
  156. package/crdt.d.ts +0 -34
  157. package/crdt.d.ts.map +0 -1
  158. package/crdt.js +0 -131
  159. package/crdt.js.map +0 -1
  160. package/database.d.ts +0 -34
  161. package/database.d.ts.map +0 -1
  162. package/database.js +0 -121
  163. package/database.js.map +0 -1
  164. package/index.d.ts.map +0 -1
  165. package/indexer-helpers.d.ts +0 -69
  166. package/indexer-helpers.d.ts.map +0 -1
  167. package/indexer-helpers.js +0 -135
  168. package/indexer-helpers.js.map +0 -1
  169. package/indexer.d.ts +0 -25
  170. package/indexer.d.ts.map +0 -1
  171. package/indexer.js +0 -231
  172. package/indexer.js.map +0 -1
  173. package/ledger.d.ts +0 -56
  174. package/ledger.d.ts.map +0 -1
  175. package/ledger.js +0 -224
  176. package/ledger.js.map +0 -1
  177. package/protocols/cloud/http-connection.d.ts +0 -25
  178. package/protocols/cloud/http-connection.d.ts.map +0 -1
  179. package/protocols/cloud/http-connection.js +0 -153
  180. package/protocols/cloud/http-connection.js.map +0 -1
  181. package/protocols/cloud/index.d.ts +0 -10
  182. package/protocols/cloud/index.d.ts.map +0 -1
  183. package/protocols/cloud/index.js +0 -10
  184. package/protocols/cloud/index.js.map +0 -1
  185. package/protocols/cloud/msg-raw-connection-base.d.ts +0 -16
  186. package/protocols/cloud/msg-raw-connection-base.d.ts.map +0 -1
  187. package/protocols/cloud/msg-raw-connection-base.js +0 -22
  188. package/protocols/cloud/msg-raw-connection-base.js.map +0 -1
  189. package/protocols/cloud/msg-types-data.d.ts +0 -36
  190. package/protocols/cloud/msg-types-data.d.ts.map +0 -1
  191. package/protocols/cloud/msg-types-data.js +0 -38
  192. package/protocols/cloud/msg-types-data.js.map +0 -1
  193. package/protocols/cloud/msg-types-meta.d.ts +0 -41
  194. package/protocols/cloud/msg-types-meta.d.ts.map +0 -1
  195. package/protocols/cloud/msg-types-meta.js +0 -98
  196. package/protocols/cloud/msg-types-meta.js.map +0 -1
  197. package/protocols/cloud/msg-types-wal.d.ts +0 -33
  198. package/protocols/cloud/msg-types-wal.d.ts.map +0 -1
  199. package/protocols/cloud/msg-types-wal.js +0 -38
  200. package/protocols/cloud/msg-types-wal.js.map +0 -1
  201. package/protocols/cloud/msg-types.d.ts +0 -279
  202. package/protocols/cloud/msg-types.d.ts.map +0 -1
  203. package/protocols/cloud/msg-types.js +0 -278
  204. package/protocols/cloud/msg-types.js.map +0 -1
  205. package/protocols/cloud/msger.d.ts +0 -79
  206. package/protocols/cloud/msger.d.ts.map +0 -1
  207. package/protocols/cloud/msger.js +0 -198
  208. package/protocols/cloud/msger.js.map +0 -1
  209. package/protocols/cloud/ws-connection.d.ts +0 -29
  210. package/protocols/cloud/ws-connection.d.ts.map +0 -1
  211. package/protocols/cloud/ws-connection.js +0 -163
  212. package/protocols/cloud/ws-connection.js.map +0 -1
  213. package/protocols/index.d.ts +0 -2
  214. package/protocols/index.d.ts.map +0 -1
  215. package/protocols/index.js +0 -2
  216. package/protocols/index.js.map +0 -1
  217. package/react/img-file.d.ts.map +0 -1
  218. package/react/img-file.js +0 -58
  219. package/react/img-file.js.map +0 -1
  220. package/react/index.d.ts.map +0 -1
  221. package/react/types.d.ts +0 -43
  222. package/react/types.d.ts.map +0 -1
  223. package/react/types.js +0 -2
  224. package/react/types.js.map +0 -1
  225. package/react/use-all-docs.d.ts +0 -4
  226. package/react/use-all-docs.d.ts.map +0 -1
  227. package/react/use-all-docs.js +0 -19
  228. package/react/use-all-docs.js.map +0 -1
  229. package/react/use-changes.d.ts +0 -4
  230. package/react/use-changes.d.ts.map +0 -1
  231. package/react/use-changes.js +0 -19
  232. package/react/use-changes.js.map +0 -1
  233. package/react/use-document.d.ts +0 -4
  234. package/react/use-document.d.ts.map +0 -1
  235. package/react/use-document.js +0 -99
  236. package/react/use-document.js.map +0 -1
  237. package/react/use-fireproof.d.ts +0 -6
  238. package/react/use-fireproof.d.ts.map +0 -1
  239. package/react/use-fireproof.js +0 -15
  240. package/react/use-fireproof.js.map +0 -1
  241. package/react/use-live-query.d.ts +0 -4
  242. package/react/use-live-query.d.ts.map +0 -1
  243. package/react/use-live-query.js +0 -38
  244. package/react/use-live-query.js.map +0 -1
  245. package/react/utils.d.ts +0 -2
  246. package/react/utils.d.ts.map +0 -1
  247. package/react/utils.js +0 -4
  248. package/react/utils.js.map +0 -1
  249. package/runtime/files.d.ts +0 -12
  250. package/runtime/files.d.ts.map +0 -1
  251. package/runtime/files.js +0 -29
  252. package/runtime/files.js.map +0 -1
  253. package/runtime/gateways/cloud/gateway.d.ts +0 -44
  254. package/runtime/gateways/cloud/gateway.d.ts.map +0 -1
  255. package/runtime/gateways/cloud/gateway.js +0 -496
  256. package/runtime/gateways/cloud/gateway.js.map +0 -1
  257. package/runtime/gateways/def-serde-gateway.d.ts +0 -19
  258. package/runtime/gateways/def-serde-gateway.d.ts.map +0 -1
  259. package/runtime/gateways/def-serde-gateway.js +0 -73
  260. package/runtime/gateways/def-serde-gateway.js.map +0 -1
  261. package/runtime/gateways/file/deno/deno-filesystem.d.ts +0 -27
  262. package/runtime/gateways/file/deno/deno-filesystem.d.ts.map +0 -1
  263. package/runtime/gateways/file/deno/deno-filesystem.js +0 -51
  264. package/runtime/gateways/file/deno/deno-filesystem.js.map +0 -1
  265. package/runtime/gateways/file/deno/get-sys-file-system.d.ts +0 -4
  266. package/runtime/gateways/file/deno/get-sys-file-system.d.ts.map +0 -1
  267. package/runtime/gateways/file/deno/get-sys-file-system.js +0 -11
  268. package/runtime/gateways/file/deno/get-sys-file-system.js.map +0 -1
  269. package/runtime/gateways/file/deno/index.d.ts +0 -2
  270. package/runtime/gateways/file/deno/index.d.ts.map +0 -1
  271. package/runtime/gateways/file/deno/index.js +0 -2
  272. package/runtime/gateways/file/deno/index.js.map +0 -1
  273. package/runtime/gateways/file/gateway-impl.d.ts +0 -18
  274. package/runtime/gateways/file/gateway-impl.d.ts.map +0 -1
  275. package/runtime/gateways/file/gateway-impl.js +0 -121
  276. package/runtime/gateways/file/gateway-impl.js.map +0 -1
  277. package/runtime/gateways/file/index.d.ts +0 -3
  278. package/runtime/gateways/file/index.d.ts.map +0 -1
  279. package/runtime/gateways/file/index.js +0 -3
  280. package/runtime/gateways/file/index.js.map +0 -1
  281. package/runtime/gateways/file/key-bag-file.d.ts +0 -19
  282. package/runtime/gateways/file/key-bag-file.d.ts.map +0 -1
  283. package/runtime/gateways/file/key-bag-file.js +0 -40
  284. package/runtime/gateways/file/key-bag-file.js.map +0 -1
  285. package/runtime/gateways/file/node/get-sys-file-system.d.ts +0 -4
  286. package/runtime/gateways/file/node/get-sys-file-system.d.ts.map +0 -1
  287. package/runtime/gateways/file/node/get-sys-file-system.js +0 -11
  288. package/runtime/gateways/file/node/get-sys-file-system.js.map +0 -1
  289. package/runtime/gateways/file/node/index.d.ts +0 -2
  290. package/runtime/gateways/file/node/index.d.ts.map +0 -1
  291. package/runtime/gateways/file/node/index.js +0 -2
  292. package/runtime/gateways/file/node/index.js.map +0 -1
  293. package/runtime/gateways/file/node/node-filesystem.d.ts +0 -32
  294. package/runtime/gateways/file/node/node-filesystem.d.ts.map +0 -1
  295. package/runtime/gateways/file/node/node-filesystem.js +0 -37
  296. package/runtime/gateways/file/node/node-filesystem.js.map +0 -1
  297. package/runtime/gateways/file/node/to-array-buffer.d.ts +0 -2
  298. package/runtime/gateways/file/node/to-array-buffer.d.ts.map +0 -1
  299. package/runtime/gateways/file/node/to-array-buffer.js +0 -12
  300. package/runtime/gateways/file/node/to-array-buffer.js.map +0 -1
  301. package/runtime/gateways/file/sys-file-system-factory.d.ts +0 -4
  302. package/runtime/gateways/file/sys-file-system-factory.d.ts.map +0 -1
  303. package/runtime/gateways/file/sys-file-system-factory.js +0 -13
  304. package/runtime/gateways/file/sys-file-system-factory.js.map +0 -1
  305. package/runtime/gateways/file/utils.d.ts +0 -5
  306. package/runtime/gateways/file/utils.d.ts.map +0 -1
  307. package/runtime/gateways/file/utils.js +0 -27
  308. package/runtime/gateways/file/utils.js.map +0 -1
  309. package/runtime/gateways/file/version.d.ts +0 -2
  310. package/runtime/gateways/file/version.d.ts.map +0 -1
  311. package/runtime/gateways/file/version.js +0 -2
  312. package/runtime/gateways/file/version.js.map +0 -1
  313. package/runtime/gateways/fp-envelope-serialize.d.ts +0 -50
  314. package/runtime/gateways/fp-envelope-serialize.d.ts.map +0 -1
  315. package/runtime/gateways/fp-envelope-serialize.js +0 -141
  316. package/runtime/gateways/fp-envelope-serialize.js.map +0 -1
  317. package/runtime/gateways/index.d.ts +0 -6
  318. package/runtime/gateways/index.d.ts.map +0 -1
  319. package/runtime/gateways/index.js +0 -6
  320. package/runtime/gateways/index.js.map +0 -1
  321. package/runtime/gateways/indexeddb/gateway-impl.d.ts +0 -22
  322. package/runtime/gateways/indexeddb/gateway-impl.d.ts.map +0 -1
  323. package/runtime/gateways/indexeddb/gateway-impl.js +0 -147
  324. package/runtime/gateways/indexeddb/gateway-impl.js.map +0 -1
  325. package/runtime/gateways/indexeddb/index.d.ts +0 -6
  326. package/runtime/gateways/indexeddb/index.d.ts.map +0 -1
  327. package/runtime/gateways/indexeddb/index.js +0 -6
  328. package/runtime/gateways/indexeddb/index.js.map +0 -1
  329. package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts +0 -15
  330. package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts.map +0 -1
  331. package/runtime/gateways/indexeddb/key-bag-indexeddb.js +0 -42
  332. package/runtime/gateways/indexeddb/key-bag-indexeddb.js.map +0 -1
  333. package/runtime/gateways/indexeddb-version.d.ts +0 -2
  334. package/runtime/gateways/indexeddb-version.d.ts.map +0 -1
  335. package/runtime/gateways/indexeddb-version.js +0 -2
  336. package/runtime/gateways/indexeddb-version.js.map +0 -1
  337. package/runtime/gateways/memory/gateway.d.ts +0 -18
  338. package/runtime/gateways/memory/gateway.d.ts.map +0 -1
  339. package/runtime/gateways/memory/gateway.js +0 -58
  340. package/runtime/gateways/memory/gateway.js.map +0 -1
  341. package/runtime/gateways/memory/version.d.ts +0 -2
  342. package/runtime/gateways/memory/version.d.ts.map +0 -1
  343. package/runtime/gateways/memory/version.js +0 -2
  344. package/runtime/gateways/memory/version.js.map +0 -1
  345. package/runtime/index.d.ts +0 -13
  346. package/runtime/index.d.ts.map +0 -1
  347. package/runtime/index.js +0 -13
  348. package/runtime/index.js.map +0 -1
  349. package/runtime/key-bag-memory.d.ts +0 -12
  350. package/runtime/key-bag-memory.d.ts.map +0 -1
  351. package/runtime/key-bag-memory.js +0 -23
  352. package/runtime/key-bag-memory.js.map +0 -1
  353. package/runtime/key-bag.d.ts +0 -85
  354. package/runtime/key-bag.d.ts.map +0 -1
  355. package/runtime/key-bag.js +0 -415
  356. package/runtime/key-bag.js.map +0 -1
  357. package/runtime/keyed-crypto.d.ts +0 -19
  358. package/runtime/keyed-crypto.d.ts.map +0 -1
  359. package/runtime/keyed-crypto.js +0 -192
  360. package/runtime/keyed-crypto.js.map +0 -1
  361. package/runtime/memory-sys-container.d.ts +0 -2
  362. package/runtime/memory-sys-container.d.ts.map +0 -1
  363. package/runtime/memory-sys-container.js +0 -2
  364. package/runtime/memory-sys-container.js.map +0 -1
  365. package/runtime/meta-key-hack.d.ts +0 -42
  366. package/runtime/meta-key-hack.d.ts.map +0 -1
  367. package/runtime/meta-key-hack.js +0 -201
  368. package/runtime/meta-key-hack.js.map +0 -1
  369. package/runtime/sts-service/index.d.ts +0 -40
  370. package/runtime/sts-service/index.d.ts.map +0 -1
  371. package/runtime/sts-service/index.js +0 -102
  372. package/runtime/sts-service/index.js.map +0 -1
  373. package/runtime/sys-container.d.ts +0 -2
  374. package/runtime/sys-container.d.ts.map +0 -1
  375. package/runtime/sys-container.js +0 -2
  376. package/runtime/sys-container.js.map +0 -1
  377. package/runtime/wait-pr-multiformats/block.d.ts +0 -47
  378. package/runtime/wait-pr-multiformats/block.d.ts.map +0 -1
  379. package/runtime/wait-pr-multiformats/block.js +0 -64
  380. package/runtime/wait-pr-multiformats/block.js.map +0 -1
  381. package/runtime/wait-pr-multiformats/codec-interface.d.ts +0 -29
  382. package/runtime/wait-pr-multiformats/codec-interface.d.ts.map +0 -1
  383. package/runtime/wait-pr-multiformats/codec-interface.js +0 -2
  384. package/runtime/wait-pr-multiformats/codec-interface.js.map +0 -1
  385. package/runtime/wait-pr-multiformats/index.d.ts +0 -3
  386. package/runtime/wait-pr-multiformats/index.d.ts.map +0 -1
  387. package/runtime/wait-pr-multiformats/index.js +0 -3
  388. package/runtime/wait-pr-multiformats/index.js.map +0 -1
  389. package/types.d.ts +0 -427
  390. package/types.d.ts.map +0 -1
  391. package/types.js +0 -54
  392. package/types.js.map +0 -1
  393. package/use-fireproof/index.d.ts +0 -3
  394. package/use-fireproof/index.d.ts.map +0 -1
  395. package/use-fireproof/index.js +0 -3
  396. package/use-fireproof/index.js.map +0 -1
  397. package/utils.d.ts +0 -36
  398. package/utils.d.ts.map +0 -1
  399. package/utils.js +0 -379
  400. package/utils.js.map +0 -1
  401. package/version.d.ts +0 -2
  402. package/version.d.ts.map +0 -1
  403. package/version.js +0 -4
  404. package/version.js.map +0 -1
  405. package/write-queue.d.ts +0 -9
  406. package/write-queue.d.ts.map +0 -1
  407. package/write-queue.js +0 -70
  408. package/write-queue.js.map +0 -1
@@ -1,295 +0,0 @@
1
- import { KeyedResolvOnce, isCoerceURI, URI } from "@adviser/cement";
2
- import { DataAndMetaAndWalAndBaseStore, PARAM } from "../types.js";
3
- import { toStoreRuntime } from "./store-factory.js";
4
- import { MetaActiveStore, WALActiveStore, FileActiveStore, CarActiveStore, } from "./types.js";
5
- import { ensureURIDefaults, toSortedArray } from "../utils.js";
6
- class AttachedImpl {
7
- constructor(gws, stores, unreg) {
8
- this.gatewayUrls = gws;
9
- this.stores = new DataAndMetaAndWalAndBaseStore(stores);
10
- this.unreg = unreg;
11
- }
12
- async detach() {
13
- const toClose = [this.stores.car.close(), this.stores.file.close(), this.stores.meta.close()];
14
- if (this.stores.wal) {
15
- toClose.push(this.stores.wal.close());
16
- }
17
- await Promise.all(toClose);
18
- this.unreg();
19
- }
20
- status() {
21
- return "attached";
22
- }
23
- }
24
- class FileActiveStoreImpl extends FileActiveStore {
25
- constructor(ref, active, attached) {
26
- super();
27
- this.ref = ref;
28
- this.active = active;
29
- this.xattached = attached;
30
- }
31
- local() {
32
- return this.xattached.local();
33
- }
34
- remotes() {
35
- return this.xattached.remotes();
36
- }
37
- }
38
- class CarActiveStoreImpl extends CarActiveStore {
39
- constructor(ref, active, attached) {
40
- super();
41
- this.ref = ref;
42
- this.active = active;
43
- this.xattached = attached;
44
- }
45
- local() {
46
- return this.xattached.local();
47
- }
48
- remotes() {
49
- return [this.active, ...this.xattached.remotes().filter((i) => i !== this.active)];
50
- }
51
- }
52
- class CarAttachedStoresImpl {
53
- constructor(attached) {
54
- this.attached = attached;
55
- }
56
- local() {
57
- return this.attached.local().active.car;
58
- }
59
- remotes() {
60
- return this.attached.remotes().map(({ active }) => active.car);
61
- }
62
- }
63
- class FileAttachedStoresImpl {
64
- constructor(attached) {
65
- this.attached = attached;
66
- }
67
- local() {
68
- return this.attached.local().active.file;
69
- }
70
- remotes() {
71
- return this.attached.remotes().map(({ active }) => active.file);
72
- }
73
- }
74
- class MetaActiveStoreImpl extends MetaActiveStore {
75
- constructor(ref, active, attached) {
76
- super();
77
- this.ref = ref;
78
- this.active = active;
79
- this.xattached = attached;
80
- }
81
- local() {
82
- return this.xattached.local();
83
- }
84
- remotes() {
85
- return [this.active, ...this.xattached.remotes().filter((i) => i !== this.active)];
86
- }
87
- }
88
- class MetaAttachedStoresImpl {
89
- constructor(attached) {
90
- this.attached = attached;
91
- }
92
- local() {
93
- return this.attached.local().active.meta;
94
- }
95
- remotes() {
96
- return this.attached.remotes().map(({ active }) => active.meta);
97
- }
98
- }
99
- class WALActiveStoreImpl extends WALActiveStore {
100
- constructor(ref, active, attached) {
101
- super();
102
- this.ref = ref;
103
- this.active = active;
104
- this.xattached = attached;
105
- }
106
- local() {
107
- return this.xattached.local();
108
- }
109
- remotes() {
110
- return this.xattached.remotes();
111
- }
112
- }
113
- class WALAttachedStoresImpl {
114
- constructor(attached) {
115
- this.attached = attached;
116
- }
117
- local() {
118
- return this.attached.local().active.wal;
119
- }
120
- remotes() {
121
- return (this.attached
122
- .remotes()
123
- .filter(({ active }) => active.wal)
124
- .map(({ active }) => active.wal));
125
- }
126
- }
127
- class ActiveStoreImpl {
128
- constructor(active, attached) {
129
- this.active = active;
130
- this.xattached = attached;
131
- }
132
- local() {
133
- return this.xattached.local();
134
- }
135
- remotes() {
136
- return this.xattached.remotes();
137
- }
138
- baseStores() {
139
- const bs = [this.active.car, this.active.file, this.active.meta];
140
- if (this.active.wal) {
141
- bs.push(this.active.wal);
142
- }
143
- return bs;
144
- }
145
- carStore() {
146
- return new CarActiveStoreImpl(this, this.active.car, new CarAttachedStoresImpl(this.xattached));
147
- }
148
- fileStore() {
149
- return new FileActiveStoreImpl(this, this.active.file, new FileAttachedStoresImpl(this.xattached));
150
- }
151
- metaStore() {
152
- return new MetaActiveStoreImpl(this, this.active.meta, new MetaAttachedStoresImpl(this.xattached));
153
- }
154
- walStore() {
155
- if (!this.active.wal) {
156
- throw this.xattached.loadable.sthis.logger.Error().Msg("wal store not set").AsError();
157
- }
158
- return new WALActiveStoreImpl(this, this.active.wal, new WALAttachedStoresImpl(this.xattached));
159
- }
160
- }
161
- function isLoadable(unknown) {
162
- return !!unknown.sthis && !!unknown.attachedStores;
163
- }
164
- export async function createAttachedStores(urlOrGup, arOrLoadable, name = "local") {
165
- let ar;
166
- if (!isLoadable(arOrLoadable)) {
167
- ar = arOrLoadable;
168
- }
169
- else {
170
- ar = arOrLoadable.attachedStores;
171
- }
172
- let gup;
173
- if (!urlOrGup) {
174
- throw new Error("urlOrGup is required");
175
- }
176
- if (isCoerceURI(urlOrGup)) {
177
- const url = urlOrGup;
178
- gup = {
179
- car: { url },
180
- file: { url },
181
- meta: { url },
182
- wal: { url },
183
- };
184
- }
185
- else {
186
- gup = urlOrGup;
187
- }
188
- return await ar.attach({
189
- name,
190
- prepare: async () => gup,
191
- });
192
- }
193
- export class AttachedRemotesImpl {
194
- constructor(loadable) {
195
- this._remotes = new KeyedResolvOnce();
196
- this.loadable = loadable;
197
- }
198
- forRemotes(action) {
199
- return Promise.all(this.remotes().map((i) => action(i))).then(() => undefined);
200
- }
201
- remotes() {
202
- return this._remotes
203
- .values()
204
- .filter(({ value }) => value.isOk() && !value.Ok().stores.wal)
205
- .map(({ value }) => value.Ok().stores)
206
- .map((i) => this.activate(i));
207
- }
208
- local() {
209
- if (!this._local) {
210
- throw this.loadable.sthis.logger.Error().Msg("local store not set").AsError();
211
- }
212
- return new ActiveStoreImpl(this._local.stores, this);
213
- }
214
- activate(store) {
215
- if (isCoerceURI(store)) {
216
- const activateUrl = URI.from(store);
217
- let maxScore = 0;
218
- let maxStore;
219
- for (const { value } of this._remotes.values()) {
220
- if (value.isErr()) {
221
- continue;
222
- }
223
- for (const url of value.Ok().stores.baseStores.map((i) => i.url())) {
224
- const mr = url.match(activateUrl);
225
- if (mr.score > maxScore) {
226
- maxScore = mr.score;
227
- maxStore = value.Ok().stores;
228
- }
229
- }
230
- }
231
- if (!maxStore) {
232
- throw this.loadable.sthis.logger.Error().Url(activateUrl).Msg("no store found").AsError();
233
- }
234
- store = maxStore;
235
- }
236
- return new ActiveStoreImpl(store, this);
237
- }
238
- async detach() {
239
- await Promise.all(this._remotes.values().map(async ({ value: rvalue }) => {
240
- if (rvalue.isOk()) {
241
- await rvalue.Ok().detach();
242
- }
243
- }));
244
- }
245
- async attach(attached) {
246
- const gwp = await attached.prepare();
247
- const gws = {
248
- car: {
249
- ...gwp.car,
250
- url: ensureURIDefaults(this.loadable.sthis, { name: attached.name, local: this._local?.gatewayUrls.car.url.getParam(PARAM.NAME) }, undefined, URI.from(gwp.car.url), "car"),
251
- },
252
- file: {
253
- ...gwp.file,
254
- url: ensureURIDefaults(this.loadable.sthis, { name: attached.name, local: this._local?.gatewayUrls.file.url.getParam(PARAM.NAME) }, undefined, URI.from(gwp.file.url), "file", { file: true }),
255
- },
256
- meta: {
257
- ...gwp.meta,
258
- url: ensureURIDefaults(this.loadable.sthis, { name: attached.name, local: this._local?.gatewayUrls.meta.url.getParam(PARAM.NAME) }, undefined, URI.from(gwp.meta.url), "meta"),
259
- },
260
- wal: gwp.wal
261
- ? {
262
- ...gwp.wal,
263
- url: ensureURIDefaults(this.loadable.sthis, { name: attached.name, local: this._local?.gatewayUrls.wal?.url.getParam(PARAM.NAME) }, undefined, URI.from(gwp.wal.url), "wal"),
264
- }
265
- : undefined,
266
- };
267
- const key = JSON.stringify(toSortedArray({
268
- carUrl: gws.car.url.toString(),
269
- filesUrl: gws.file.url.toString(),
270
- metaUrl: gws.meta.url.toString(),
271
- walUrl: gws.wal?.url.toString(),
272
- }));
273
- return this._remotes.get(key).once(async () => {
274
- const rt = toStoreRuntime(this.loadable.sthis);
275
- const result = new AttachedImpl(gws, await rt.makeStores({
276
- byStore: gws,
277
- loader: this.loadable,
278
- }), () => {
279
- this._remotes.unget(key);
280
- });
281
- if (result.stores.wal) {
282
- if (this._local) {
283
- throw this.loadable.sthis.logger
284
- .Error()
285
- .Any({ urls: result.gatewayUrls })
286
- .Msg("local store could only set once")
287
- .AsError();
288
- }
289
- this._local = result;
290
- }
291
- return result;
292
- });
293
- }
294
- }
295
- //# sourceMappingURL=attachable-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachable-store.js","sourceRoot":"","sources":["../../../../src/blockstore/attachable-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAa,WAAW,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAA8D,6BAA6B,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/H,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EASL,eAAe,EACf,cAAc,EAKd,eAAe,EACf,cAAc,GAKf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,YAAY;IAIhB,YAAY,GAAgB,EAAE,MAA8B,EAAE,KAAY;QACxE,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,CAAC,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IACD,KAAK,CAAC,MAAM;QACV,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC9F,IAAI,IAAI,CAAC,MAAM,CAAC,G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AM,EAAE,IAAI,CAAC,QAAQ;aACtB,CAAC,EACF,GAAG,EAAE;gBACH,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC,CACF,CAAC;YACF,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;gBACtB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;oBAChB,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM;yBAC7B,KAAK,EAAE;yBACP,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;yBACjC,GAAG,CAAC,iCAAiC,CAAC;yBACtC,OAAO,EAAE,CAAC;gBACf,CAAC;gBACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACvB,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,12 +0,0 @@
1
- import { Future } from "@adviser/cement";
2
- type QueueFunction<T = void> = () => Promise<T>;
3
- export declare class CommitQueue<T = void> {
4
- readonly queue: QueueFunction<void>[];
5
- processing: boolean;
6
- readonly _waitIdleItems: Set<Future<void>>;
7
- waitIdle(): Promise<void>;
8
- enqueue(fn: QueueFunction<T>): Promise<T>;
9
- processNext(): void;
10
- }
11
- export {};
12
- //# sourceMappingURL=commit-queue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commit-queue.d.ts","sourceRoot":"","sources":["../../../../src/blockstore/commit-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,KAAK,aAAa,CAAC,CAAC,GAAG,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhD,qBAAa,WAAW,CAAC,CAAC,GAAG,IAAI;IAC/B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAM;IAC3C,UAAU,UAAS;IAEnB,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAA2B;IACrE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IASnB,OAAO,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAmB/C,WAAW;CAgBZ"}
@@ -1,52 +0,0 @@
1
- import { Future } from "@adviser/cement";
2
- export class CommitQueue {
3
- constructor() {
4
- this.queue = [];
5
- this.processing = false;
6
- this._waitIdleItems = new Set();
7
- }
8
- waitIdle() {
9
- if (this.queue.length === 0 && !this.processing) {
10
- return Promise.resolve();
11
- }
12
- const fn = new Future();
13
- this._waitIdleItems.add(fn);
14
- return fn.asPromise();
15
- }
16
- async enqueue(fn) {
17
- return new Promise((resolve, reject) => {
18
- const queueFn = async () => {
19
- try {
20
- resolve(await fn());
21
- }
22
- catch (e) {
23
- reject(e);
24
- }
25
- finally {
26
- this.processing = false;
27
- this.processNext();
28
- }
29
- };
30
- this.queue.push(queueFn);
31
- if (!this.processing) {
32
- this.processNext();
33
- }
34
- });
35
- }
36
- processNext() {
37
- if (this.queue.length > 0 && !this.processing) {
38
- this.processing = true;
39
- const queueFn = this.queue.shift();
40
- if (queueFn) {
41
- queueFn().finally(() => {
42
- });
43
- }
44
- }
45
- if (this.queue.length === 0 && !this.processing) {
46
- const toResolve = Array.from(this._waitIdleItems);
47
- this._waitIdleItems.clear();
48
- toResolve.map((fn) => fn.resolve());
49
- }
50
- }
51
- }
52
- //# sourceMappingURL=commit-queue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commit-queue.js","sourceRoot":"","sources":["../../../../src/blockstore/commit-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,MAAM,OAAO,WAAW;IAAxB;QACW,UAAK,GAA0B,EAAE,CAAC;QAC3C,eAAU,GAAG,KAAK,CAAC;QAEV,mBAAc,GAA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AAC;gBACZ,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBAEvB,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClD,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;YAC5B,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF"}
@@ -1,21 +0,0 @@
1
- import { CarTransaction } from "../types.js";
2
- import { AnyLink, CarGroup, CarHeader, CarLog, CarStore, CommitOpts, FileStore, MetaStore, TransactionMeta, WALStore } from "./types.js";
3
- import { AsyncBlockEncoder } from "../runtime/wait-pr-multiformats/codec-interface.js";
4
- export declare function createCarFile(encoder: AsyncBlockEncoder<24, Uint8Array>, cid: AnyLink, t: CarTransaction): Promise<{
5
- cid: AnyLink;
6
- bytes: Uint8Array;
7
- }>;
8
- export declare function commitFiles(fileStore: FileStore, walStore: WALStore, t: CarTransaction, done: TransactionMeta): Promise<CarGroup>;
9
- export interface CommitParams {
10
- readonly encoder: AsyncBlockEncoder<24, Uint8Array>;
11
- readonly carLog: CarLog;
12
- readonly carStore: CarStore;
13
- readonly WALStore: WALStore;
14
- readonly metaStore: MetaStore;
15
- readonly threshold?: number;
16
- }
17
- export declare function commit<T>(params: CommitParams, t: CarTransaction, done: T, opts?: CommitOpts): Promise<{
18
- cgrp: CarGroup;
19
- header: CarHeader<T>;
20
- }>;
21
- //# sourceMappingURL=commitor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commitor.d.ts","sourceRoot":"","sources":["../../../../src/blockstore/commitor.ts"],"names":[],"mappings":"AAAA,OAAO,EA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@
1
- import { toCIDBlock, } from "./types.js";
2
- import * as CBW from "@ipld/car/buffer-writer";
3
- import { encode } from "../runtime/wait-pr-multiformats/block.js";
4
- import * as dagCodec from "@ipld/dag-cbor";
5
- import { CarTransactionImpl } from "./transaction.js";
6
- import { sha256 } from "multiformats/hashes/sha2";
7
- async function encodeCarFile(roots, t, codec) {
8
- let size = 0;
9
- const headerSize = CBW.headerLength({ roots });
10
- size += headerSize;
11
- for await (const { cid, bytes } of t.entries()) {
12
- size += CBW.blockLength({ cid, bytes });
13
- }
14
- const buffer = new Uint8Array(size);
15
- const writer = CBW.createWriter(buffer.buffer, { headerSize });
16
- for (const r of roots) {
17
- writer.addRoot(r);
18
- }
19
- for await (const { cid, bytes } of t.entries()) {
20
- writer.write({ cid, bytes });
21
- }
22
- writer.close();
23
- return await encode({ value: writer.bytes, hasher: sha256, codec });
24
- }
25
- export async function createCarFile(encoder, cid, t) {
26
- return encodeCarFile([cid], t, encoder);
27
- }
28
- export async function commitFiles(fileStore, walStore, t, done) {
29
- const { files: roots } = makeFileCarHeader(done);
30
- const cids = [];
31
- const codec = await fileStore.keyedCrypto().then((i) => i.codec());
32
- const cars = await prepareCarFilesFiles(codec, roots, t);
33
- for (const car of cars) {
34
- const { cid, bytes } = car;
35
- await fileStore.save({ cid, bytes });
36
- await walStore.enqueueFile(cid);
37
- cids.push(cid);
38
- }
39
- return cids;
40
- }
41
- function makeFileCarHeader(result) {
42
- const files = [];
43
- for (const [, meta] of Object.entries(result.files || {})) {
44
- if (meta && typeof meta === "object" && "cid" in meta && meta !== null) {
45
- files.push(meta.cid);
46
- }
47
- }
48
- return { ...result, files };
49
- }
50
- async function prepareCarFilesFiles(encoder, roots, t) {
51
- return [await encodeCarFile(roots, t, encoder)];
52
- }
53
- function makeCarHeader(meta, cars, compact = false) {
54
- const coreHeader = compact
55
- ? { cars: [], compact: cars.asArray() }
56
- : { cars: cars.asArray(), compact: [] };
57
- return { ...coreHeader, meta };
58
- }
59
- async function encodeCarHeader(fp) {
60
- return (await encode({
61
- value: { fp },
62
- hasher: sha256,
63
- codec: dagCodec,
64
- }));
65
- }
66
- export async function commit(params, t, done, opts = { noLoader: false, compact: false }) {
67
- const fp = makeCarHeader(done, params.carLog, !!opts.compact);
68
- const rootBlock = await encodeCarHeader(fp);
69
- const cars = await prepareCarFiles(params.encoder, params.threshold, rootBlock, t);
70
- const cids = [];
71
- for (const car of cars) {
72
- const { cid, bytes } = car;
73
- await params.carStore.save({ cid, bytes });
74
- cids.push(cid);
75
- }
76
- const newDbMeta = { cars: cids };
77
- await params.WALStore.enqueue(newDbMeta, opts);
78
- await params.metaStore.save(newDbMeta);
79
- return { cgrp: cids, header: fp };
80
- }
81
- async function prepareCarFiles(encoder, threshold, rootBlock, t) {
82
- const carFiles = [];
83
- threshold = threshold || 16 * 65536;
84
- let clonedt = new CarTransactionImpl(t.parent, { add: false, noLoader: false });
85
- clonedt.putSync(rootBlock.cid, rootBlock.bytes);
86
- let newsize = CBW.blockLength(toCIDBlock(rootBlock));
87
- let cidRootBlock = rootBlock;
88
- for await (const { cid, bytes } of t.entries()) {
89
- newsize += CBW.blockLength(toCIDBlock({ cid: cid, bytes }));
90
- if (newsize >= threshold) {
91
- carFiles.push(await createCarFile(encoder, cidRootBlock.cid, clonedt));
92
- clonedt = new CarTransactionImpl(t.parent, { add: false, noLoader: false });
93
- clonedt.putSync(cid, bytes);
94
- cidRootBlock = { cid, bytes };
95
- newsize = CBW.blockLength(toCIDBlock({ cid, bytes }));
96
- }
97
- else {
98
- clonedt.putSync(cid, bytes);
99
- }
100
- }
101
- carFiles.push(await createCarFile(encoder, cidRootBlock.cid, clonedt));
102
- return carFiles;
103
- }
104
- //# sourceMappingURL=commitor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commitor.js","sourceRoot":"","sources":["../../../../src/blockstore/commitor.ts"],"names":[],"mappings":"AACA,OAAO,EAaL,UAAU,GAGX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,GAAG,MAA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AM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QAE/C,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAE5D,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;YACzB,QAAQ,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YACvE,OAAO,GAAG,IAAI,kBAAkB,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YAC5E,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAC5B,YAAY,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;YAC9B,OAAO,GAAG,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=connect-raw.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-raw.d.ts","sourceRoot":"","sources":["../../../../src/blockstore/connect-raw.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=connect-raw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-raw.js","sourceRoot":"","sources":["../../../../src/blockstore/connect-raw.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=connection-base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-base.d.ts","sourceRoot":"","sources":["../../../../src/blockstore/connection-base.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=connection-base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-base.js","sourceRoot":"","sources":["../../../../src/blockstore/connection-base.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=encrypt-helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encrypt-helpers.d.ts","sourceRoot":"","sources":["../../../../src/blockstore/encrypt-helpers.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=encrypt-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encrypt-helpers.js","sourceRoot":"","sources":["../../../../src/blockstore/encrypt-helpers.ts"],"names":[],"mappings":""}
@@ -1,32 +0,0 @@
1
- import { CID } from "multiformats";
2
- import { DbMetaEvent, WALState } from "./types.js";
3
- import { Result } from "@adviser/cement";
4
- export declare const FPEnvelopeTypes: {
5
- readonly CAR: "car";
6
- readonly FILE: "file";
7
- readonly META: "meta";
8
- readonly WAL: "wal";
9
- };
10
- export type FPEnvelopeType = (typeof FPEnvelopeTypes)[keyof typeof FPEnvelopeTypes];
11
- export interface FPEnvelope<T> {
12
- readonly type: FPEnvelopeType;
13
- readonly payload: T;
14
- }
15
- export interface FPEnvelopeCar extends FPEnvelope<Uint8Array> {
16
- readonly type: typeof FPEnvelopeTypes.CAR;
17
- }
18
- export interface FPEnvelopeFile extends FPEnvelope<Uint8Array> {
19
- readonly type: typeof FPEnvelopeTypes.FILE;
20
- }
21
- export interface FPEnvelopeMeta extends FPEnvelope<DbMetaEvent[]> {
22
- readonly type: typeof FPEnvelopeTypes.META;
23
- }
24
- export interface FPWALCarsOps {
25
- readonly cars: CID[];
26
- }
27
- export interface FPEnvelopeWAL extends FPEnvelope<WALState> {
28
- readonly type: typeof FPEnvelopeTypes.WAL;
29
- }
30
- export declare function Car2FPMsg(fpcar: Uint8Array): Result<FPEnvelopeCar>;
31
- export declare function File2FPMsg(fpfile: Uint8Array): Result<FPEnvelopeFile>;
32
- //# sourceMappingURL=fp-envelope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fp-envelope.d.ts","sourceRoot":"","sources":["../../../../src/blockstore/fp-envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,eAAO,MAAM,eAAe;;;;;CAKlB,CAAC;AAWX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AASpF,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,aAAc,SAAQ,UAAU,CAAC,UAAU,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,OAAO,eAAe,CAAC,GAAG,CAAC;CAC3C;AAED,MAAM,WAAW,cAAe,SAAQ,UAAU,CAAC,UAAU,CAAC;IAC5D,QAAQ,CAAC,IAAI,EAAE,OAAO,eAAe,CAAC,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,cAAe,SAAQ,UAAU,CAAC,WAAW,EAAE,CAAC;IAC/D,QAAQ,CAAC,IAAI,EAAE,OAAO,eAAe,CAAC,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;CACtB;AAMD,MAAM,WAAW,aAAc,SAAQ,UAAU,CAAC,QAAQ,CAAC;IACzD,QAAQ,CAAC,IAAI,EAAE,OAAO,eAAe,CAAC,GAAG,CAAC;CAC3C;AAmDD,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAElE;AAUD,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,CAErE"}
@@ -1,14 +0,0 @@
1
- import { Result } from "@adviser/cement";
2
- export const FPEnvelopeTypes = {
3
- CAR: "car",
4
- FILE: "file",
5
- META: "meta",
6
- WAL: "wal",
7
- };
8
- export function Car2FPMsg(fpcar) {
9
- return Result.Ok({ type: FPEnvelopeTypes.CAR, payload: fpcar });
10
- }
11
- export function File2FPMsg(fpfile) {
12
- return Result.Ok({ type: FPEnvelopeTypes.FILE, payload: fpfile });
13
- }
14
- //# sourceMappingURL=fp-envelope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fp-envelope.js","sourceRoot":"","sources":["../../../../src/blockstore/fp-envelope.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACF,CAAC;AAkGX,MAAM,UAAU,SAAS,CAAC,KAAiB;IACzC,OAAO,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAClE,CAAC;AAUD,MAAM,UAAU,UAAU,CAAC,MAAkB;IAC3C,OAAO,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AACpE,CAAC"}