@fireproof/core 0.19.5-dev → 0.19.8-dev-alldocs
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/{chunk-QHSXUST7.js → chunk-5UFCF36O.js} +3 -3
 - package/{chunk-HCXR2M5B.js → chunk-DG6XSV44.js} +175 -7
 - package/chunk-DG6XSV44.js.map +1 -0
 - package/{chunk-H3A2HMMM.js → chunk-OWQAHX2V.js} +2 -2
 - package/chunk-OWQAHX2V.js.map +1 -0
 - package/{chunk-7OGPZSGT.js → chunk-PRQHQG4I.js} +2 -2
 - package/index.cjs +248 -191
 - package/index.cjs.map +1 -1
 - package/index.d.cts +174 -68
 - package/index.d.ts +174 -68
 - package/index.global.js +24688 -0
 - package/index.global.js.map +1 -0
 - package/index.js +60 -127
 - package/index.js.map +1 -1
 - package/metafile-cjs.json +1 -1
 - package/metafile-esm.json +1 -1
 - package/metafile-iife.json +1 -0
 - package/{node-sys-container-E7LADX2Z.js → node-sys-container-TTGEC66A.js} +2 -2
 - package/package.json +1 -1
 - package/{sqlite-data-store-YS4U7AQ4.js → sqlite-data-store-MA55LVQE.js} +4 -4
 - package/{sqlite-meta-store-FJZSZG4R.js → sqlite-meta-store-UNQKVYRM.js} +4 -4
 - package/{sqlite-wal-store-6JZ4URNS.js → sqlite-wal-store-KVUOC4PO.js} +4 -4
 - package/{store-file-HMHPQTUV.js → store-file-WD746RSY.js} +3 -3
 - package/{store-indexdb-MRVZG4OG.js → store-indexdb-NG45BU3Q.js} +4 -4
 - package/{store-sql-5XMJ5OWJ.js → store-sql-QVFNIGND.js} +7 -69
 - package/store-sql-QVFNIGND.js.map +1 -0
 - package/tests/blockstore/loader.test.ts +265 -0
 - package/tests/blockstore/store.test.ts +164 -0
 - package/tests/blockstore/transaction.test.ts +121 -0
 - package/tests/fireproof/config.test.ts +212 -0
 - package/tests/fireproof/crdt.test.ts +434 -0
 - package/tests/fireproof/database.test.ts +466 -0
 - package/tests/fireproof/fireproof.test.ts +602 -0
 - package/tests/fireproof/hello.test.ts +54 -0
 - package/tests/fireproof/indexer.test.ts +389 -0
 - package/tests/helpers.ts +81 -0
 - package/tests/react/useFireproof.test.tsx +19 -0
 - package/tests/www/gallery.html +132 -0
 - package/tests/www/iife.html +42 -0
 - package/tests/www/todo-aws.html +232 -0
 - package/tests/www/todo-ipfs.html +213 -0
 - package/tests/www/todo-local.html +214 -0
 - package/tests/www/todo-netlify.html +227 -0
 - package/tests/www/todo.html +236 -0
 - package/chunk-H3A2HMMM.js.map +0 -1
 - package/chunk-HCXR2M5B.js.map +0 -1
 - package/store-sql-5XMJ5OWJ.js.map +0 -1
 - /package/{chunk-QHSXUST7.js.map → chunk-5UFCF36O.js.map} +0 -0
 - /package/{chunk-7OGPZSGT.js.map → chunk-PRQHQG4I.js.map} +0 -0
 - /package/{node-sys-container-E7LADX2Z.js.map → node-sys-container-TTGEC66A.js.map} +0 -0
 - /package/{sqlite-data-store-YS4U7AQ4.js.map → sqlite-data-store-MA55LVQE.js.map} +0 -0
 - /package/{sqlite-meta-store-FJZSZG4R.js.map → sqlite-meta-store-UNQKVYRM.js.map} +0 -0
 - /package/{sqlite-wal-store-6JZ4URNS.js.map → sqlite-wal-store-KVUOC4PO.js.map} +0 -0
 - /package/{store-file-HMHPQTUV.js.map → store-file-WD746RSY.js.map} +0 -0
 - /package/{store-indexdb-MRVZG4OG.js.map → store-indexdb-NG45BU3Q.js.map} +0 -0
 
    
        package/index.js
    CHANGED
    
    | 
         @@ -1,27 +1,30 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            import {
         
     | 
| 
       2 
2 
     | 
    
         
             
              guardVersion
         
     | 
| 
       3 
     | 
    
         
            -
            } from "./chunk- 
     | 
| 
      
 3 
     | 
    
         
            +
            } from "./chunk-5UFCF36O.js";
         
     | 
| 
       4 
4 
     | 
    
         
             
            import {
         
     | 
| 
       5 
5 
     | 
    
         
             
              NotFoundError,
         
     | 
| 
       6 
6 
     | 
    
         
             
              isNotFoundError
         
     | 
| 
       7 
7 
     | 
    
         
             
            } from "./chunk-VZGT7ZYP.js";
         
     | 
| 
       8 
8 
     | 
    
         
             
            import {
         
     | 
| 
       9 
9 
     | 
    
         
             
              dataDir,
         
     | 
| 
      
 10 
     | 
    
         
            +
              decodeFile,
         
     | 
| 
      
 11 
     | 
    
         
            +
              encodeFile,
         
     | 
| 
       10 
12 
     | 
    
         
             
              ensureLogger,
         
     | 
| 
       11 
13 
     | 
    
         
             
              exception2Result,
         
     | 
| 
       12 
14 
     | 
    
         
             
              exceptionWrapper,
         
     | 
| 
       13 
15 
     | 
    
         
             
              getKey,
         
     | 
| 
       14 
16 
     | 
    
         
             
              getName,
         
     | 
| 
       15 
17 
     | 
    
         
             
              getStore,
         
     | 
| 
       16 
     | 
    
         
            -
              runtime_exports
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
              runtime_exports,
         
     | 
| 
      
 19 
     | 
    
         
            +
              toCryptoOpts
         
     | 
| 
      
 20 
     | 
    
         
            +
            } from "./chunk-DG6XSV44.js";
         
     | 
| 
       18 
21 
     | 
    
         
             
            import {
         
     | 
| 
       19 
22 
     | 
    
         
             
              SysContainer,
         
     | 
| 
       20 
23 
     | 
    
         
             
              __export,
         
     | 
| 
       21 
24 
     | 
    
         
             
              falsyToUndef,
         
     | 
| 
       22 
25 
     | 
    
         
             
              isFalsy,
         
     | 
| 
       23 
26 
     | 
    
         
             
              throwFalsy
         
     | 
| 
       24 
     | 
    
         
            -
            } from "./chunk- 
     | 
| 
      
 27 
     | 
    
         
            +
            } from "./chunk-OWQAHX2V.js";
         
     | 
| 
       25 
28 
     | 
    
         | 
| 
       26 
29 
     | 
    
         
             
            // src/database.ts
         
     | 
| 
       27 
30 
     | 
    
         
             
            import { uuidv7 } from "uuidv7";
         
     | 
| 
         @@ -274,72 +277,6 @@ var ConnectREST = class extends ConnectionBase { 
     | 
|
| 
       274 
277 
     | 
    
         
             
            // src/blockstore/store-factory.ts
         
     | 
| 
       275 
278 
     | 
    
         
             
            import { KeyedResolvOnce } from "@adviser/cement";
         
     | 
| 
       276 
279 
     | 
    
         | 
| 
       277 
     | 
    
         
            -
            // src/runtime/files.ts
         
     | 
| 
       278 
     | 
    
         
            -
            import * as UnixFS from "@ipld/unixfs";
         
     | 
| 
       279 
     | 
    
         
            -
            import * as raw from "multiformats/codecs/raw";
         
     | 
| 
       280 
     | 
    
         
            -
            import { withMaxChunkSize } from "@ipld/unixfs/file/chunker/fixed";
         
     | 
| 
       281 
     | 
    
         
            -
            import { withWidth } from "@ipld/unixfs/file/layout/balanced";
         
     | 
| 
       282 
     | 
    
         
            -
            import { exporter } from "ipfs-unixfs-exporter";
         
     | 
| 
       283 
     | 
    
         
            -
            var queuingStrategy = UnixFS.withCapacity();
         
     | 
| 
       284 
     | 
    
         
            -
            var settings = UnixFS.configure({
         
     | 
| 
       285 
     | 
    
         
            -
              fileChunkEncoder: raw,
         
     | 
| 
       286 
     | 
    
         
            -
              smallFileEncoder: raw,
         
     | 
| 
       287 
     | 
    
         
            -
              chunker: withMaxChunkSize(1024 * 1024),
         
     | 
| 
       288 
     | 
    
         
            -
              fileLayout: withWidth(1024)
         
     | 
| 
       289 
     | 
    
         
            -
            });
         
     | 
| 
       290 
     | 
    
         
            -
            async function collect(collectable) {
         
     | 
| 
       291 
     | 
    
         
            -
              const chunks = [];
         
     | 
| 
       292 
     | 
    
         
            -
              await collectable.pipeTo(
         
     | 
| 
       293 
     | 
    
         
            -
                new WritableStream({
         
     | 
| 
       294 
     | 
    
         
            -
                  write(chunk) {
         
     | 
| 
       295 
     | 
    
         
            -
                    chunks.push(chunk);
         
     | 
| 
       296 
     | 
    
         
            -
                  }
         
     | 
| 
       297 
     | 
    
         
            -
                })
         
     | 
| 
       298 
     | 
    
         
            -
              );
         
     | 
| 
       299 
     | 
    
         
            -
              return chunks;
         
     | 
| 
       300 
     | 
    
         
            -
            }
         
     | 
| 
       301 
     | 
    
         
            -
            async function encodeFile(blob) {
         
     | 
| 
       302 
     | 
    
         
            -
              const readable = createFileEncoderStream(blob);
         
     | 
| 
       303 
     | 
    
         
            -
              const blocks = await collect(readable);
         
     | 
| 
       304 
     | 
    
         
            -
              return { cid: blocks.at(-1).cid, blocks };
         
     | 
| 
       305 
     | 
    
         
            -
            }
         
     | 
| 
       306 
     | 
    
         
            -
            async function decodeFile(blocks, cid, meta) {
         
     | 
| 
       307 
     | 
    
         
            -
              const entry = await exporter(cid.toString(), blocks, { length: meta.size });
         
     | 
| 
       308 
     | 
    
         
            -
              const chunks = [];
         
     | 
| 
       309 
     | 
    
         
            -
              for await (const chunk of entry.content()) {
         
     | 
| 
       310 
     | 
    
         
            -
                chunks.push(chunk);
         
     | 
| 
       311 
     | 
    
         
            -
              }
         
     | 
| 
       312 
     | 
    
         
            -
              return new File(chunks, entry.name, { type: meta.type, lastModified: 0 });
         
     | 
| 
       313 
     | 
    
         
            -
            }
         
     | 
| 
       314 
     | 
    
         
            -
            function createFileEncoderStream(blob) {
         
     | 
| 
       315 
     | 
    
         
            -
              const { readable, writable } = new TransformStream({}, queuingStrategy);
         
     | 
| 
       316 
     | 
    
         
            -
              const unixfsWriter = UnixFS.createWriter({ writable, settings });
         
     | 
| 
       317 
     | 
    
         
            -
              const fileBuilder = new UnixFSFileBuilder("", blob);
         
     | 
| 
       318 
     | 
    
         
            -
              void (async () => {
         
     | 
| 
       319 
     | 
    
         
            -
                await fileBuilder.finalize(unixfsWriter);
         
     | 
| 
       320 
     | 
    
         
            -
                await unixfsWriter.close();
         
     | 
| 
       321 
     | 
    
         
            -
              })();
         
     | 
| 
       322 
     | 
    
         
            -
              return readable;
         
     | 
| 
       323 
     | 
    
         
            -
            }
         
     | 
| 
       324 
     | 
    
         
            -
            var UnixFSFileBuilder = class {
         
     | 
| 
       325 
     | 
    
         
            -
              #file;
         
     | 
| 
       326 
     | 
    
         
            -
              constructor(name, file) {
         
     | 
| 
       327 
     | 
    
         
            -
                this.name = name;
         
     | 
| 
       328 
     | 
    
         
            -
                this.#file = file;
         
     | 
| 
       329 
     | 
    
         
            -
              }
         
     | 
| 
       330 
     | 
    
         
            -
              async finalize(writer) {
         
     | 
| 
       331 
     | 
    
         
            -
                const unixfsFileWriter = UnixFS.createFileWriter(writer);
         
     | 
| 
       332 
     | 
    
         
            -
                await this.#file.stream().pipeTo(
         
     | 
| 
       333 
     | 
    
         
            -
                  new WritableStream({
         
     | 
| 
       334 
     | 
    
         
            -
                    async write(chunk) {
         
     | 
| 
       335 
     | 
    
         
            -
                      await unixfsFileWriter.write(chunk);
         
     | 
| 
       336 
     | 
    
         
            -
                    }
         
     | 
| 
       337 
     | 
    
         
            -
                  })
         
     | 
| 
       338 
     | 
    
         
            -
                );
         
     | 
| 
       339 
     | 
    
         
            -
                return await unixfsFileWriter.close();
         
     | 
| 
       340 
     | 
    
         
            -
              }
         
     | 
| 
       341 
     | 
    
         
            -
            };
         
     | 
| 
       342 
     | 
    
         
            -
             
     | 
| 
       343 
280 
     | 
    
         
             
            // src/blockstore/store.ts
         
     | 
| 
       344 
281 
     | 
    
         
             
            import pLimit2 from "p-limit";
         
     | 
| 
       345 
282 
     | 
    
         
             
            import { format, parse } from "@ipld/dag-json";
         
     | 
| 
         @@ -358,7 +295,7 @@ function toCIDBlock(block) { 
     | 
|
| 
       358 
295 
     | 
    
         
             
            // src/blockstore/loader-helpers.ts
         
     | 
| 
       359 
296 
     | 
    
         
             
            import { encode, decode } from "multiformats/block";
         
     | 
| 
       360 
297 
     | 
    
         
             
            import { sha256 as hasher } from "multiformats/hashes/sha2";
         
     | 
| 
       361 
     | 
    
         
            -
            import * as  
     | 
| 
      
 298 
     | 
    
         
            +
            import * as raw from "multiformats/codecs/raw";
         
     | 
| 
       362 
299 
     | 
    
         
             
            import * as CBW from "@ipld/car/buffer-writer";
         
     | 
| 
       363 
300 
     | 
    
         
             
            import * as codec from "@ipld/dag-cbor";
         
     | 
| 
       364 
301 
     | 
    
         
             
            async function encodeCarFile(roots, t) {
         
     | 
| 
         @@ -377,7 +314,7 @@ async function encodeCarFile(roots, t) { 
     | 
|
| 
       377 
314 
     | 
    
         
             
                writer.write({ cid, bytes });
         
     | 
| 
       378 
315 
     | 
    
         
             
              }
         
     | 
| 
       379 
316 
     | 
    
         
             
              writer.close();
         
     | 
| 
       380 
     | 
    
         
            -
              return await encode({ value: writer.bytes, hasher, codec:  
     | 
| 
      
 317 
     | 
    
         
            +
              return await encode({ value: writer.bytes, hasher, codec: raw });
         
     | 
| 
       381 
318 
     | 
    
         
             
            }
         
     | 
| 
       382 
319 
     | 
    
         
             
            async function encodeCarHeader(fp) {
         
     | 
| 
       383 
320 
     | 
    
         
             
              return await encode({
         
     | 
| 
         @@ -410,7 +347,7 @@ import { create, load } from "prolly-trees/cid-set"; 
     | 
|
| 
       410 
347 
     | 
    
         | 
| 
       411 
348 
     | 
    
         
             
            // src/blockstore/encrypt-codec.ts
         
     | 
| 
       412 
349 
     | 
    
         
             
            import { CID } from "multiformats";
         
     | 
| 
       413 
     | 
    
         
            -
            function makeCodec(ilogger,  
     | 
| 
      
 350 
     | 
    
         
            +
            function makeCodec(ilogger, crypto, randomBytes) {
         
     | 
| 
       414 
351 
     | 
    
         
             
              const logger = ensureLogger(ilogger, "makeCodec");
         
     | 
| 
       415 
352 
     | 
    
         
             
              const enc32 = (value) => {
         
     | 
| 
       416 
353 
     | 
    
         
             
                value = +value;
         
     | 
| 
         @@ -444,7 +381,7 @@ function makeCodec(ilogger, crypto2, randomBytes2) { 
     | 
|
| 
       444 
381 
     | 
    
         
             
              };
         
     | 
| 
       445 
382 
     | 
    
         
             
              const code = 3145728 + 1337;
         
     | 
| 
       446 
383 
     | 
    
         
             
              async function subtleKey(key) {
         
     | 
| 
       447 
     | 
    
         
            -
                return await  
     | 
| 
      
 384 
     | 
    
         
            +
                return await crypto.importKey(
         
     | 
| 
       448 
385 
     | 
    
         
             
                  "raw",
         
     | 
| 
       449 
386 
     | 
    
         
             
                  // raw or jwk
         
     | 
| 
       450 
387 
     | 
    
         
             
                  key,
         
     | 
| 
         @@ -458,7 +395,7 @@ function makeCodec(ilogger, crypto2, randomBytes2) { 
     | 
|
| 
       458 
395 
     | 
    
         
             
              const decrypt = async ({ key, value }) => {
         
     | 
| 
       459 
396 
     | 
    
         
             
                const { bytes: inBytes, iv } = value;
         
     | 
| 
       460 
397 
     | 
    
         
             
                const cryKey = await subtleKey(key);
         
     | 
| 
       461 
     | 
    
         
            -
                const deBytes = await  
     | 
| 
      
 398 
     | 
    
         
            +
                const deBytes = await crypto.decrypt(
         
     | 
| 
       462 
399 
     | 
    
         
             
                  {
         
     | 
| 
       463 
400 
     | 
    
         
             
                    name: "AES-GCM",
         
     | 
| 
       464 
401 
     | 
    
         
             
                    iv,
         
     | 
| 
         @@ -474,11 +411,11 @@ function makeCodec(ilogger, crypto2, randomBytes2) { 
     | 
|
| 
       474 
411 
     | 
    
         
             
              };
         
     | 
| 
       475 
412 
     | 
    
         
             
              const encrypt = async ({ key, cid, bytes }) => {
         
     | 
| 
       476 
413 
     | 
    
         
             
                const len = enc32(cid.bytes.byteLength);
         
     | 
| 
       477 
     | 
    
         
            -
                const iv =  
     | 
| 
      
 414 
     | 
    
         
            +
                const iv = randomBytes(12);
         
     | 
| 
       478 
415 
     | 
    
         
             
                const msg = concat([len, cid.bytes, bytes]);
         
     | 
| 
       479 
416 
     | 
    
         
             
                try {
         
     | 
| 
       480 
417 
     | 
    
         
             
                  const cryKey = await subtleKey(key);
         
     | 
| 
       481 
     | 
    
         
            -
                  const deBytes = await  
     | 
| 
      
 418 
     | 
    
         
            +
                  const deBytes = await crypto.encrypt(
         
     | 
| 
       482 
419 
     | 
    
         
             
                    {
         
     | 
| 
       483 
420 
     | 
    
         
             
                      name: "AES-GCM",
         
     | 
| 
       484 
421 
     | 
    
         
             
                      iv,
         
     | 
| 
         @@ -506,8 +443,8 @@ function carLogIncludesGroup(list, cidMatch) { 
     | 
|
| 
       506 
443 
     | 
    
         
             
                return cid.toString() === cidMatch.toString();
         
     | 
| 
       507 
444 
     | 
    
         
             
              });
         
     | 
| 
       508 
445 
     | 
    
         
             
            }
         
     | 
| 
       509 
     | 
    
         
            -
            function makeEncDec(logger,  
     | 
| 
       510 
     | 
    
         
            -
              const codec4 = makeCodec(logger,  
     | 
| 
      
 446 
     | 
    
         
            +
            function makeEncDec(logger, crypto, randomBytes) {
         
     | 
| 
      
 447 
     | 
    
         
            +
              const codec4 = makeCodec(logger, crypto, randomBytes);
         
     | 
| 
       511 
448 
     | 
    
         
             
              const encrypt = async function* ({
         
     | 
| 
       512 
449 
     | 
    
         
             
                get: get2,
         
     | 
| 
       513 
450 
     | 
    
         
             
                cids,
         
     | 
| 
         @@ -600,7 +537,7 @@ function hexStringToUint8Array(hexString) { 
     | 
|
| 
       600 
537 
     | 
    
         
             
              }
         
     | 
| 
       601 
538 
     | 
    
         
             
              return uint8Array;
         
     | 
| 
       602 
539 
     | 
    
         
             
            }
         
     | 
| 
       603 
     | 
    
         
            -
            async function encryptedEncodeCarFile(logger,  
     | 
| 
      
 540 
     | 
    
         
            +
            async function encryptedEncodeCarFile(logger, crypto, key, rootCid, t) {
         
     | 
| 
       604 
541 
     | 
    
         
             
              const encryptionKey = hexStringToUint8Array(key);
         
     | 
| 
       605 
542 
     | 
    
         
             
              const encryptedBlocks = new MemoryBlockstore2();
         
     | 
| 
       606 
543 
     | 
    
         
             
              const cidsToEncrypt = [];
         
     | 
| 
         @@ -610,7 +547,7 @@ async function encryptedEncodeCarFile(logger, crypto2, key, rootCid, t) { 
     | 
|
| 
       610 
547 
     | 
    
         
             
                if (!g) throw logger.Error().Ref("cid", cid).Int("bytes", bytes.length).Msg("missing cid block").AsError();
         
     | 
| 
       611 
548 
     | 
    
         
             
              }
         
     | 
| 
       612 
549 
     | 
    
         
             
              let last = null;
         
     | 
| 
       613 
     | 
    
         
            -
              const { encrypt } = makeEncDec(logger,  
     | 
| 
      
 550 
     | 
    
         
            +
              const { encrypt } = makeEncDec(logger, crypto, crypto.randomBytes);
         
     | 
| 
       614 
551 
     | 
    
         
             
              for await (const block of encrypt({
         
     | 
| 
       615 
552 
     | 
    
         
             
                cids: cidsToEncrypt,
         
     | 
| 
       616 
553 
     | 
    
         
             
                get: t.get.bind(t),
         
     | 
| 
         @@ -627,17 +564,17 @@ async function encryptedEncodeCarFile(logger, crypto2, key, rootCid, t) { 
     | 
|
| 
       627 
564 
     | 
    
         
             
              const encryptedCar = await encodeCarFile([last.cid], encryptedBlocks);
         
     | 
| 
       628 
565 
     | 
    
         
             
              return encryptedCar;
         
     | 
| 
       629 
566 
     | 
    
         
             
            }
         
     | 
| 
       630 
     | 
    
         
            -
            async function decodeEncryptedCar(logger,  
     | 
| 
      
 567 
     | 
    
         
            +
            async function decodeEncryptedCar(logger, crypto, key, reader) {
         
     | 
| 
       631 
568 
     | 
    
         
             
              const roots = await reader.getRoots();
         
     | 
| 
       632 
569 
     | 
    
         
             
              const root3 = roots[0];
         
     | 
| 
       633 
     | 
    
         
            -
              return await decodeCarBlocks(logger,  
     | 
| 
      
 570 
     | 
    
         
            +
              return await decodeCarBlocks(logger, crypto, root3, reader.get.bind(reader), key);
         
     | 
| 
       634 
571 
     | 
    
         
             
            }
         
     | 
| 
       635 
     | 
    
         
            -
            async function decodeCarBlocks(logger,  
     | 
| 
      
 572 
     | 
    
         
            +
            async function decodeCarBlocks(logger, crypto, root3, get2, keyMaterial) {
         
     | 
| 
       636 
573 
     | 
    
         
             
              const decryptionKeyUint8 = hexStringToUint8Array(keyMaterial);
         
     | 
| 
       637 
574 
     | 
    
         
             
              const decryptionKey = decryptionKeyUint8.buffer.slice(0, decryptionKeyUint8.byteLength);
         
     | 
| 
       638 
575 
     | 
    
         
             
              const decryptedBlocks = new MemoryBlockstore2();
         
     | 
| 
       639 
576 
     | 
    
         
             
              let last = null;
         
     | 
| 
       640 
     | 
    
         
            -
              const { decrypt } = makeEncDec(logger,  
     | 
| 
      
 577 
     | 
    
         
            +
              const { decrypt } = makeEncDec(logger, crypto, crypto.randomBytes);
         
     | 
| 
       641 
578 
     | 
    
         
             
              for await (const block of decrypt({
         
     | 
| 
       642 
579 
     | 
    
         
             
                root: root3,
         
     | 
| 
       643 
580 
     | 
    
         
             
                get: get2,
         
     | 
| 
         @@ -655,30 +592,6 @@ async function decodeCarBlocks(logger, crypto2, root3, get2, keyMaterial) { 
     | 
|
| 
       655 
592 
     | 
    
         | 
| 
       656 
593 
     | 
    
         
             
            // src/blockstore/transaction.ts
         
     | 
| 
       657 
594 
     | 
    
         
             
            import { MemoryBlockstore as MemoryBlockstore3 } from "@web3-storage/pail/block";
         
     | 
| 
       658 
     | 
    
         
            -
             
     | 
| 
       659 
     | 
    
         
            -
            // src/runtime/crypto.ts
         
     | 
| 
       660 
     | 
    
         
            -
            function randomBytes(size) {
         
     | 
| 
       661 
     | 
    
         
            -
              const bytes = new Uint8Array(size);
         
     | 
| 
       662 
     | 
    
         
            -
              if (size > 0) {
         
     | 
| 
       663 
     | 
    
         
            -
                crypto.getRandomValues(bytes);
         
     | 
| 
       664 
     | 
    
         
            -
              }
         
     | 
| 
       665 
     | 
    
         
            -
              return bytes;
         
     | 
| 
       666 
     | 
    
         
            -
            }
         
     | 
| 
       667 
     | 
    
         
            -
            function digestSHA256(data) {
         
     | 
| 
       668 
     | 
    
         
            -
              return Promise.resolve(crypto.subtle.digest("SHA-256", data));
         
     | 
| 
       669 
     | 
    
         
            -
            }
         
     | 
| 
       670 
     | 
    
         
            -
            function toCryptoOpts(cryptoOpts = {}) {
         
     | 
| 
       671 
     | 
    
         
            -
              const opts = {
         
     | 
| 
       672 
     | 
    
         
            -
                importKey: cryptoOpts.importKey || crypto.subtle.importKey.bind(crypto.subtle),
         
     | 
| 
       673 
     | 
    
         
            -
                encrypt: cryptoOpts.encrypt || crypto.subtle.encrypt.bind(crypto.subtle),
         
     | 
| 
       674 
     | 
    
         
            -
                decrypt: cryptoOpts.decrypt || crypto.subtle.decrypt.bind(crypto.subtle),
         
     | 
| 
       675 
     | 
    
         
            -
                randomBytes: cryptoOpts.randomBytes || randomBytes,
         
     | 
| 
       676 
     | 
    
         
            -
                digestSHA256: cryptoOpts.digestSHA256 || digestSHA256
         
     | 
| 
       677 
     | 
    
         
            -
              };
         
     | 
| 
       678 
     | 
    
         
            -
              return opts;
         
     | 
| 
       679 
     | 
    
         
            -
            }
         
     | 
| 
       680 
     | 
    
         
            -
             
     | 
| 
       681 
     | 
    
         
            -
            // src/blockstore/transaction.ts
         
     | 
| 
       682 
595 
     | 
    
         
             
            var CarTransaction = class extends MemoryBlockstore3 {
         
     | 
| 
       683 
596 
     | 
    
         
             
              constructor(parent, opts = { add: true }) {
         
     | 
| 
       684 
597 
     | 
    
         
             
                super();
         
     | 
| 
         @@ -1688,16 +1601,34 @@ function toURL(pathOrUrl, isIndex) { 
     | 
|
| 
       1688 
1601 
     | 
    
         
             
                return ensureIsIndex(url, isIndex);
         
     | 
| 
       1689 
1602 
     | 
    
         
             
              }
         
     | 
| 
       1690 
1603 
     | 
    
         
             
            }
         
     | 
| 
      
 1604 
     | 
    
         
            +
            var storeFactory = /* @__PURE__ */ new Map();
         
     | 
| 
      
 1605 
     | 
    
         
            +
            function ensureName(name, url) {
         
     | 
| 
      
 1606 
     | 
    
         
            +
              if (!url.searchParams.has("name")) {
         
     | 
| 
      
 1607 
     | 
    
         
            +
                url.searchParams.set("name", name);
         
     | 
| 
      
 1608 
     | 
    
         
            +
              }
         
     | 
| 
      
 1609 
     | 
    
         
            +
            }
         
     | 
| 
       1691 
1610 
     | 
    
         
             
            function buildURL(optURL, loader) {
         
     | 
| 
       1692 
1611 
     | 
    
         
             
              const storeOpts = loader.ebOpts.store;
         
     | 
| 
       1693 
     | 
    
         
            -
               
     | 
| 
      
 1612 
     | 
    
         
            +
              const obuItem = Array.from(storeFactory.values()).find((items) => items.overrideBaseURL);
         
     | 
| 
      
 1613 
     | 
    
         
            +
              let obuUrl;
         
     | 
| 
      
 1614 
     | 
    
         
            +
              if (obuItem && obuItem.overrideBaseURL) {
         
     | 
| 
      
 1615 
     | 
    
         
            +
                obuUrl = new URL(obuItem.overrideBaseURL);
         
     | 
| 
      
 1616 
     | 
    
         
            +
              }
         
     | 
| 
      
 1617 
     | 
    
         
            +
              return toURL(optURL || obuUrl || dataDir(loader.name, storeOpts.stores?.base), storeOpts.isIndex);
         
     | 
| 
       1694 
1618 
     | 
    
         
             
            }
         
     | 
| 
       1695 
     | 
    
         
            -
            var storeFactory = /* @__PURE__ */ new Map();
         
     | 
| 
       1696 
1619 
     | 
    
         
             
            function registerStoreProtocol(item) {
         
     | 
| 
       1697 
1620 
     | 
    
         
             
              if (storeFactory.has(item.protocol)) {
         
     | 
| 
       1698 
1621 
     | 
    
         
             
                throw new Error(`protocol ${item.protocol} already registered`);
         
     | 
| 
       1699 
1622 
     | 
    
         
             
              }
         
     | 
| 
      
 1623 
     | 
    
         
            +
              if (item.overrideBaseURL) {
         
     | 
| 
      
 1624 
     | 
    
         
            +
                Array.from(storeFactory.values()).forEach((items) => {
         
     | 
| 
      
 1625 
     | 
    
         
            +
                  items.overrideBaseURL = void 0;
         
     | 
| 
      
 1626 
     | 
    
         
            +
                });
         
     | 
| 
      
 1627 
     | 
    
         
            +
              }
         
     | 
| 
       1700 
1628 
     | 
    
         
             
              storeFactory.set(item.protocol, item);
         
     | 
| 
      
 1629 
     | 
    
         
            +
              return () => {
         
     | 
| 
      
 1630 
     | 
    
         
            +
                storeFactory.delete(item.protocol);
         
     | 
| 
      
 1631 
     | 
    
         
            +
              };
         
     | 
| 
       1701 
1632 
     | 
    
         
             
            }
         
     | 
| 
       1702 
1633 
     | 
    
         
             
            function runStoreFactory(url, logger, run) {
         
     | 
| 
       1703 
1634 
     | 
    
         
             
              const item = storeFactory.get(url.protocol);
         
     | 
| 
         @@ -1716,6 +1647,7 @@ function loadDataGateway(url, logger) { 
     | 
|
| 
       1716 
1647 
     | 
    
         
             
            var onceDataStoreFactory = new KeyedResolvOnce();
         
     | 
| 
       1717 
1648 
     | 
    
         
             
            async function dataStoreFactory(loader) {
         
     | 
| 
       1718 
1649 
     | 
    
         
             
              const url = buildURL(loader.ebOpts.store.stores?.data, loader);
         
     | 
| 
      
 1650 
     | 
    
         
            +
              ensureName(loader.name, url);
         
     | 
| 
       1719 
1651 
     | 
    
         
             
              const logger = ensureLogger(loader.logger, "dataStoreFactory", { url: url.toString() });
         
     | 
| 
       1720 
1652 
     | 
    
         
             
              url.searchParams.set("store", "data");
         
     | 
| 
       1721 
1653 
     | 
    
         
             
              return onceDataStoreFactory.get(url.toString()).once(async () => {
         
     | 
| 
         @@ -1735,15 +1667,14 @@ function loadMetaGateway(url, logger) { 
     | 
|
| 
       1735 
1667 
     | 
    
         
             
            var onceMetaStoreFactory = new KeyedResolvOnce();
         
     | 
| 
       1736 
1668 
     | 
    
         
             
            async function metaStoreFactory(loader) {
         
     | 
| 
       1737 
1669 
     | 
    
         
             
              const url = buildURL(loader.ebOpts.store.stores?.meta, loader);
         
     | 
| 
      
 1670 
     | 
    
         
            +
              ensureName(loader.name, url);
         
     | 
| 
       1738 
1671 
     | 
    
         
             
              const logger = ensureLogger(loader.logger, "metaStoreFactory", { url: () => url.toString() });
         
     | 
| 
       1739 
1672 
     | 
    
         
             
              url.searchParams.set("store", "meta");
         
     | 
| 
       1740 
1673 
     | 
    
         
             
              return onceMetaStoreFactory.get(url.toString()).once(async () => {
         
     | 
| 
       1741 
1674 
     | 
    
         
             
                logger.Debug().Str("protocol", url.protocol).Msg("pre-protocol switch");
         
     | 
| 
       1742 
1675 
     | 
    
         
             
                const gateway = await loadMetaGateway(url, logger);
         
     | 
| 
       1743 
1676 
     | 
    
         
             
                const store = new MetaStore(loader.name, url, loader.logger, gateway);
         
     | 
| 
       1744 
     | 
    
         
            -
                logger.Debug().Msg("pre-start");
         
     | 
| 
       1745 
1677 
     | 
    
         
             
                await store.start();
         
     | 
| 
       1746 
     | 
    
         
            -
                logger.Debug().Msg("post-start");
         
     | 
| 
       1747 
1678 
     | 
    
         
             
                return store;
         
     | 
| 
       1748 
1679 
     | 
    
         
             
              });
         
     | 
| 
       1749 
1680 
     | 
    
         
             
            }
         
     | 
| 
         @@ -1756,6 +1687,7 @@ function loadWalGateway(url, logger) { 
     | 
|
| 
       1756 
1687 
     | 
    
         
             
            var onceRemoteWalFactory = new KeyedResolvOnce();
         
     | 
| 
       1757 
1688 
     | 
    
         
             
            async function remoteWalFactory(loader) {
         
     | 
| 
       1758 
1689 
     | 
    
         
             
              const url = buildURL(loader.ebOpts.store.stores?.meta, loader);
         
     | 
| 
      
 1690 
     | 
    
         
            +
              ensureName(loader.name, url);
         
     | 
| 
       1759 
1691 
     | 
    
         
             
              const logger = ensureLogger(loader.logger, "remoteWalFactory", { url: url.toString() });
         
     | 
| 
       1760 
1692 
     | 
    
         
             
              url.searchParams.set("store", "wal");
         
     | 
| 
       1761 
1693 
     | 
    
         
             
              return onceRemoteWalFactory.get(url.toString()).once(async () => {
         
     | 
| 
         @@ -1797,57 +1729,57 @@ function toStoreRuntime(opts, ilogger) { 
     | 
|
| 
       1797 
1729 
     | 
    
         
             
            registerStoreProtocol({
         
     | 
| 
       1798 
1730 
     | 
    
         
             
              protocol: "file:",
         
     | 
| 
       1799 
1731 
     | 
    
         
             
              data: async (logger) => {
         
     | 
| 
       1800 
     | 
    
         
            -
                const { FileDataGateway } = await import("./store-file- 
     | 
| 
      
 1732 
     | 
    
         
            +
                const { FileDataGateway } = await import("./store-file-WD746RSY.js");
         
     | 
| 
       1801 
1733 
     | 
    
         
             
                return new FileDataGateway(logger);
         
     | 
| 
       1802 
1734 
     | 
    
         
             
              },
         
     | 
| 
       1803 
1735 
     | 
    
         
             
              meta: async (logger) => {
         
     | 
| 
       1804 
     | 
    
         
            -
                const { FileMetaGateway } = await import("./store-file- 
     | 
| 
      
 1736 
     | 
    
         
            +
                const { FileMetaGateway } = await import("./store-file-WD746RSY.js");
         
     | 
| 
       1805 
1737 
     | 
    
         
             
                return new FileMetaGateway(logger);
         
     | 
| 
       1806 
1738 
     | 
    
         
             
              },
         
     | 
| 
       1807 
1739 
     | 
    
         
             
              wal: async (logger) => {
         
     | 
| 
       1808 
     | 
    
         
            -
                const { FileWALGateway } = await import("./store-file- 
     | 
| 
      
 1740 
     | 
    
         
            +
                const { FileWALGateway } = await import("./store-file-WD746RSY.js");
         
     | 
| 
       1809 
1741 
     | 
    
         
             
                return new FileWALGateway(logger);
         
     | 
| 
       1810 
1742 
     | 
    
         
             
              },
         
     | 
| 
       1811 
1743 
     | 
    
         
             
              test: async (logger) => {
         
     | 
| 
       1812 
     | 
    
         
            -
                const { FileTestStore } = await import("./store-file- 
     | 
| 
      
 1744 
     | 
    
         
            +
                const { FileTestStore } = await import("./store-file-WD746RSY.js");
         
     | 
| 
       1813 
1745 
     | 
    
         
             
                return new FileTestStore(logger);
         
     | 
| 
       1814 
1746 
     | 
    
         
             
              }
         
     | 
| 
       1815 
1747 
     | 
    
         
             
            });
         
     | 
| 
       1816 
1748 
     | 
    
         
             
            registerStoreProtocol({
         
     | 
| 
       1817 
1749 
     | 
    
         
             
              protocol: "indexdb:",
         
     | 
| 
       1818 
1750 
     | 
    
         
             
              data: async (logger) => {
         
     | 
| 
       1819 
     | 
    
         
            -
                const { IndexDBDataGateway } = await import("./store-indexdb- 
     | 
| 
      
 1751 
     | 
    
         
            +
                const { IndexDBDataGateway } = await import("./store-indexdb-NG45BU3Q.js");
         
     | 
| 
       1820 
1752 
     | 
    
         
             
                return new IndexDBDataGateway(logger);
         
     | 
| 
       1821 
1753 
     | 
    
         
             
              },
         
     | 
| 
       1822 
1754 
     | 
    
         
             
              meta: async (logger) => {
         
     | 
| 
       1823 
     | 
    
         
            -
                const { IndexDBMetaGateway } = await import("./store-indexdb- 
     | 
| 
      
 1755 
     | 
    
         
            +
                const { IndexDBMetaGateway } = await import("./store-indexdb-NG45BU3Q.js");
         
     | 
| 
       1824 
1756 
     | 
    
         
             
                return new IndexDBMetaGateway(logger);
         
     | 
| 
       1825 
1757 
     | 
    
         
             
              },
         
     | 
| 
       1826 
1758 
     | 
    
         
             
              wal: async (logger) => {
         
     | 
| 
       1827 
     | 
    
         
            -
                const { IndexDBMetaGateway } = await import("./store-indexdb- 
     | 
| 
      
 1759 
     | 
    
         
            +
                const { IndexDBMetaGateway } = await import("./store-indexdb-NG45BU3Q.js");
         
     | 
| 
       1828 
1760 
     | 
    
         
             
                return new IndexDBMetaGateway(logger);
         
     | 
| 
       1829 
1761 
     | 
    
         
             
              },
         
     | 
| 
       1830 
1762 
     | 
    
         
             
              test: async (logger) => {
         
     | 
| 
       1831 
     | 
    
         
            -
                const { IndexDBTestStore } = await import("./store-indexdb- 
     | 
| 
      
 1763 
     | 
    
         
            +
                const { IndexDBTestStore } = await import("./store-indexdb-NG45BU3Q.js");
         
     | 
| 
       1832 
1764 
     | 
    
         
             
                return new IndexDBTestStore(logger);
         
     | 
| 
       1833 
1765 
     | 
    
         
             
              }
         
     | 
| 
       1834 
1766 
     | 
    
         
             
            });
         
     | 
| 
       1835 
1767 
     | 
    
         
             
            registerStoreProtocol({
         
     | 
| 
       1836 
1768 
     | 
    
         
             
              protocol: "sqlite:",
         
     | 
| 
       1837 
1769 
     | 
    
         
             
              data: async (logger) => {
         
     | 
| 
       1838 
     | 
    
         
            -
                const { SQLDataGateway } = await import("./store-sql- 
     | 
| 
      
 1770 
     | 
    
         
            +
                const { SQLDataGateway } = await import("./store-sql-QVFNIGND.js");
         
     | 
| 
       1839 
1771 
     | 
    
         
             
                return new SQLDataGateway(logger);
         
     | 
| 
       1840 
1772 
     | 
    
         
             
              },
         
     | 
| 
       1841 
1773 
     | 
    
         
             
              meta: async (logger) => {
         
     | 
| 
       1842 
     | 
    
         
            -
                const { SQLMetaGateway } = await import("./store-sql- 
     | 
| 
      
 1774 
     | 
    
         
            +
                const { SQLMetaGateway } = await import("./store-sql-QVFNIGND.js");
         
     | 
| 
       1843 
1775 
     | 
    
         
             
                return new SQLMetaGateway(logger);
         
     | 
| 
       1844 
1776 
     | 
    
         
             
              },
         
     | 
| 
       1845 
1777 
     | 
    
         
             
              wal: async (logger) => {
         
     | 
| 
       1846 
     | 
    
         
            -
                const { SQLWalGateway } = await import("./store-sql- 
     | 
| 
      
 1778 
     | 
    
         
            +
                const { SQLWalGateway } = await import("./store-sql-QVFNIGND.js");
         
     | 
| 
       1847 
1779 
     | 
    
         
             
                return new SQLWalGateway(logger);
         
     | 
| 
       1848 
1780 
     | 
    
         
             
              },
         
     | 
| 
       1849 
1781 
     | 
    
         
             
              test: async (logger) => {
         
     | 
| 
       1850 
     | 
    
         
            -
                const { SQLTestStore } = await import("./store-sql- 
     | 
| 
      
 1782 
     | 
    
         
            +
                const { SQLTestStore } = await import("./store-sql-QVFNIGND.js");
         
     | 
| 
       1851 
1783 
     | 
    
         
             
                return new SQLTestStore(logger);
         
     | 
| 
       1852 
1784 
     | 
    
         
             
              }
         
     | 
| 
       1853 
1785 
     | 
    
         
             
            });
         
     | 
| 
         @@ -2795,7 +2727,7 @@ var Database = class { 
     | 
|
| 
       2795 
2727 
     | 
    
         
             
                }));
         
     | 
| 
       2796 
2728 
     | 
    
         
             
                return { rows, clock: head };
         
     | 
| 
       2797 
2729 
     | 
    
         
             
              }
         
     | 
| 
       2798 
     | 
    
         
            -
              async allDocs() {
         
     | 
| 
      
 2730 
     | 
    
         
            +
              async allDocs(opts = {}) {
         
     | 
| 
       2799 
2731 
     | 
    
         
             
                await this.ready();
         
     | 
| 
       2800 
2732 
     | 
    
         
             
                const { result, head } = await this._crdt.allDocs();
         
     | 
| 
       2801 
2733 
     | 
    
         
             
                const rows = result.map(({ id: key, value, del }) => ({
         
     | 
| 
         @@ -2898,7 +2830,7 @@ function makeName(fnString) { 
     | 
|
| 
       2898 
2830 
     | 
    
         | 
| 
       2899 
2831 
     | 
    
         
             
            // src/version.ts
         
     | 
| 
       2900 
2832 
     | 
    
         
             
            var PACKAGE_VERSION = Object.keys({
         
     | 
| 
       2901 
     | 
    
         
            -
              "0. 
     | 
| 
      
 2833 
     | 
    
         
            +
              "0.0.0-dev": "xxxx"
         
     | 
| 
       2902 
2834 
     | 
    
         
             
            })[0];
         
     | 
| 
       2903 
2835 
     | 
    
         
             
            export {
         
     | 
| 
       2904 
2836 
     | 
    
         
             
              CRDT,
         
     | 
| 
         @@ -2918,6 +2850,7 @@ export { 
     | 
|
| 
       2918 
2850 
     | 
    
         
             
              index,
         
     | 
| 
       2919 
2851 
     | 
    
         
             
              isFalsy,
         
     | 
| 
       2920 
2852 
     | 
    
         
             
              runtime_exports as rt,
         
     | 
| 
      
 2853 
     | 
    
         
            +
              runtime_exports as runtime,
         
     | 
| 
       2921 
2854 
     | 
    
         
             
              throwFalsy
         
     | 
| 
       2922 
2855 
     | 
    
         
             
            };
         
     | 
| 
       2923 
2856 
     | 
    
         
             
            //# sourceMappingURL=index.js.map
         
     |