@fireproof/core 0.20.5-dev-preview-1 → 0.20.5-dev-preview-3
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/apply-head-queue.d.ts +18 -0
- package/apply-head-queue.d.ts.map +1 -0
- package/apply-head-queue.js +47 -0
- package/apply-head-queue.js.map +1 -0
- package/blockstore/attachable-store.d.ts +19 -0
- package/blockstore/attachable-store.d.ts.map +1 -0
- package/blockstore/attachable-store.js +316 -0
- package/blockstore/attachable-store.js.map +1 -0
- package/blockstore/commit-queue.d.ts +17 -0
- package/blockstore/commit-queue.d.ts.map +1 -0
- package/blockstore/commit-queue.js +60 -0
- package/blockstore/commit-queue.js.map +1 -0
- package/blockstore/commitor.d.ts +21 -0
- package/blockstore/commitor.d.ts.map +1 -0
- package/blockstore/commitor.js +95 -0
- package/blockstore/commitor.js.map +1 -0
- package/blockstore/connect-raw.d.ts +2 -0
- package/blockstore/connect-raw.d.ts.map +1 -0
- package/blockstore/connect-raw.js +2 -0
- package/blockstore/connect-raw.js.map +1 -0
- package/blockstore/connection-base.d.ts +2 -0
- package/blockstore/connection-base.d.ts.map +1 -0
- package/blockstore/connection-base.js +2 -0
- package/blockstore/connection-base.js.map +1 -0
- package/blockstore/encrypt-helpers.d.ts +2 -0
- package/blockstore/encrypt-helpers.d.ts.map +1 -0
- package/blockstore/encrypt-helpers.js +2 -0
- package/blockstore/encrypt-helpers.js.map +1 -0
- package/blockstore/fp-envelope.d.ts +32 -0
- package/blockstore/fp-envelope.d.ts.map +1 -0
- package/blockstore/fp-envelope.js +14 -0
- package/blockstore/fp-envelope.js.map +1 -0
- package/blockstore/gateway.d.ts +20 -0
- package/blockstore/gateway.d.ts.map +1 -0
- package/blockstore/gateway.js +2 -0
- package/blockstore/gateway.js.map +1 -0
- package/blockstore/index.d.ts +16 -0
- package/blockstore/index.d.ts.map +1 -0
- package/blockstore/index.js +16 -0
- package/blockstore/index.js.map +1 -0
- package/blockstore/interceptor-gateway.d.ts +29 -0
- package/blockstore/interceptor-gateway.d.ts.map +1 -0
- package/blockstore/interceptor-gateway.js +137 -0
- package/blockstore/interceptor-gateway.js.map +1 -0
- package/blockstore/loader-helpers.d.ts +10 -0
- package/blockstore/loader-helpers.d.ts.map +1 -0
- package/blockstore/loader-helpers.js +115 -0
- package/blockstore/loader-helpers.js.map +1 -0
- package/blockstore/loader.d.ts +61 -0
- package/blockstore/loader.d.ts.map +1 -0
- package/blockstore/loader.js +494 -0
- package/blockstore/loader.js.map +1 -0
- package/blockstore/register-store-protocol.d.ts +22 -0
- package/blockstore/register-store-protocol.d.ts.map +1 -0
- package/blockstore/register-store-protocol.js +114 -0
- package/blockstore/register-store-protocol.js.map +1 -0
- package/blockstore/serde-gateway.d.ts +78 -0
- package/blockstore/serde-gateway.d.ts.map +1 -0
- package/blockstore/serde-gateway.js +2 -0
- package/blockstore/serde-gateway.js.map +1 -0
- package/blockstore/store-factory.d.ts +11 -0
- package/blockstore/store-factory.d.ts.map +1 -0
- package/blockstore/store-factory.js +104 -0
- package/blockstore/store-factory.js.map +1 -0
- package/blockstore/store-remote.d.ts +2 -0
- package/blockstore/store-remote.d.ts.map +1 -0
- package/blockstore/store-remote.js +2 -0
- package/blockstore/store-remote.js.map +1 -0
- package/blockstore/store.d.ts +86 -0
- package/blockstore/store.d.ts.map +1 -0
- package/blockstore/store.js +439 -0
- package/blockstore/store.js.map +1 -0
- package/blockstore/task-manager.d.ts +19 -0
- package/blockstore/task-manager.d.ts.map +1 -0
- package/blockstore/task-manager.js +50 -0
- package/blockstore/task-manager.js.map +1 -0
- package/blockstore/transaction.d.ts +62 -0
- package/blockstore/transaction.d.ts.map +1 -0
- package/blockstore/transaction.js +261 -0
- package/blockstore/transaction.js.map +1 -0
- package/blockstore/types.d.ts +508 -0
- package/blockstore/types.d.ts.map +1 -0
- package/blockstore/types.js +83 -0
- package/blockstore/types.js.map +1 -0
- package/blockstore/uri-interceptor.d.ts +19 -0
- package/blockstore/uri-interceptor.d.ts.map +1 -0
- package/blockstore/uri-interceptor.js +61 -0
- package/blockstore/uri-interceptor.js.map +1 -0
- package/bundle-not-impl.d.ts +2 -0
- package/bundle-not-impl.d.ts.map +1 -0
- package/bundle-not-impl.js +4 -0
- package/bundle-not-impl.js.map +1 -0
- package/cli/main.js +26616 -0
- package/crdt-clock.d.ts +27 -0
- package/crdt-clock.d.ts.map +1 -0
- package/crdt-clock.js +138 -0
- package/crdt-clock.js.map +1 -0
- package/crdt-helpers.d.ts +19 -0
- package/crdt-helpers.d.ts.map +1 -0
- package/crdt-helpers.js +332 -0
- package/crdt-helpers.js.map +1 -0
- package/crdt.d.ts +41 -0
- package/crdt.d.ts.map +1 -0
- package/crdt.js +164 -0
- package/crdt.js.map +1 -0
- package/database.d.ts +34 -0
- package/database.d.ts.map +1 -0
- package/database.js +124 -0
- package/database.js.map +1 -0
- package/deno.json +2 -2
- package/index.d.ts +15 -2741
- package/index.d.ts.map +1 -0
- package/index.js +14 -7274
- package/index.js.map +1 -1
- package/indexer-helpers.d.ts +69 -0
- package/indexer-helpers.d.ts.map +1 -0
- package/indexer-helpers.js +136 -0
- package/indexer-helpers.js.map +1 -0
- package/indexer.d.ts +24 -0
- package/indexer.d.ts.map +1 -0
- package/indexer.js +230 -0
- package/indexer.js.map +1 -0
- package/ledger.d.ts +55 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +234 -0
- package/ledger.js.map +1 -0
- package/package.json +26 -17
- package/protocols/cloud/http-connection.d.ts +25 -0
- package/protocols/cloud/http-connection.d.ts.map +1 -0
- package/protocols/cloud/http-connection.js +153 -0
- package/protocols/cloud/http-connection.js.map +1 -0
- package/protocols/cloud/index.d.ts +10 -0
- package/protocols/cloud/index.d.ts.map +1 -0
- package/protocols/cloud/index.js +10 -0
- package/protocols/cloud/index.js.map +1 -0
- package/protocols/cloud/msg-raw-connection-base.d.ts +16 -0
- package/protocols/cloud/msg-raw-connection-base.d.ts.map +1 -0
- package/protocols/cloud/msg-raw-connection-base.js +22 -0
- package/protocols/cloud/msg-raw-connection-base.js.map +1 -0
- package/protocols/cloud/msg-types-data.d.ts +36 -0
- package/protocols/cloud/msg-types-data.d.ts.map +1 -0
- package/protocols/cloud/msg-types-data.js +38 -0
- package/protocols/cloud/msg-types-data.js.map +1 -0
- package/protocols/cloud/msg-types-meta.d.ts +41 -0
- package/protocols/cloud/msg-types-meta.d.ts.map +1 -0
- package/protocols/cloud/msg-types-meta.js +98 -0
- package/protocols/cloud/msg-types-meta.js.map +1 -0
- package/protocols/cloud/msg-types-wal.d.ts +33 -0
- package/protocols/cloud/msg-types-wal.d.ts.map +1 -0
- package/protocols/cloud/msg-types-wal.js +38 -0
- package/protocols/cloud/msg-types-wal.js.map +1 -0
- package/protocols/cloud/msg-types.d.ts +282 -0
- package/protocols/cloud/msg-types.d.ts.map +1 -0
- package/protocols/cloud/msg-types.js +278 -0
- package/protocols/cloud/msg-types.js.map +1 -0
- package/protocols/cloud/msger.d.ts +79 -0
- package/protocols/cloud/msger.d.ts.map +1 -0
- package/protocols/cloud/msger.js +198 -0
- package/protocols/cloud/msger.js.map +1 -0
- package/protocols/cloud/ws-connection.d.ts +29 -0
- package/protocols/cloud/ws-connection.d.ts.map +1 -0
- package/protocols/cloud/ws-connection.js +166 -0
- package/protocols/cloud/ws-connection.js.map +1 -0
- package/protocols/index.d.ts +2 -0
- package/protocols/index.d.ts.map +1 -0
- package/protocols/index.js +2 -0
- package/protocols/index.js.map +1 -0
- package/react/create-attach.d.ts +6 -0
- package/react/create-attach.d.ts.map +1 -0
- package/react/create-attach.js +75 -0
- package/react/create-attach.js.map +1 -0
- package/react/{index.d.cts → img-file.d.ts} +6 -53
- package/react/img-file.d.ts.map +1 -0
- package/react/img-file.js +57 -0
- package/react/img-file.js.map +1 -0
- package/react/index.d.ts +5 -336
- package/react/index.d.ts.map +1 -0
- package/react/index.js +4 -358
- package/react/index.js.map +1 -1
- package/react/types.d.ts +71 -0
- package/react/types.d.ts.map +1 -0
- package/react/types.js +2 -0
- package/react/types.js.map +1 -0
- package/react/use-all-docs.d.ts +4 -0
- package/react/use-all-docs.d.ts.map +1 -0
- package/react/use-all-docs.js +25 -0
- package/react/use-all-docs.js.map +1 -0
- package/react/use-attach.d.ts +6 -0
- package/react/use-attach.d.ts.map +1 -0
- package/react/use-attach.js +75 -0
- package/react/use-attach.js.map +1 -0
- package/react/use-changes.d.ts +4 -0
- package/react/use-changes.d.ts.map +1 -0
- package/react/use-changes.js +19 -0
- package/react/use-changes.js.map +1 -0
- package/react/use-document.d.ts +4 -0
- package/react/use-document.d.ts.map +1 -0
- package/react/use-document.js +109 -0
- package/react/use-document.js.map +1 -0
- package/react/use-fireproof.d.ts +6 -0
- package/react/use-fireproof.d.ts.map +1 -0
- package/react/use-fireproof.js +20 -0
- package/react/use-fireproof.js.map +1 -0
- package/react/use-live-query.d.ts +4 -0
- package/react/use-live-query.d.ts.map +1 -0
- package/react/use-live-query.js +27 -0
- package/react/use-live-query.js.map +1 -0
- package/runtime/files.d.ts +12 -0
- package/runtime/files.d.ts.map +1 -0
- package/runtime/files.js +29 -0
- package/runtime/files.js.map +1 -0
- package/runtime/gateways/cloud/gateway.d.ts +42 -0
- package/runtime/gateways/cloud/gateway.d.ts.map +1 -0
- package/runtime/gateways/cloud/gateway.js +528 -0
- package/runtime/gateways/cloud/gateway.js.map +1 -0
- package/runtime/gateways/cloud/index.d.ts +3 -0
- package/runtime/gateways/cloud/index.d.ts.map +1 -0
- package/runtime/gateways/cloud/index.js +3 -0
- package/runtime/gateways/cloud/index.js.map +1 -0
- package/runtime/gateways/cloud/to-cloud.d.ts +46 -0
- package/runtime/gateways/cloud/to-cloud.d.ts.map +1 -0
- package/runtime/gateways/cloud/to-cloud.js +159 -0
- package/runtime/gateways/cloud/to-cloud.js.map +1 -0
- package/runtime/gateways/def-serde-gateway.d.ts +18 -0
- package/runtime/gateways/def-serde-gateway.d.ts.map +1 -0
- package/runtime/gateways/def-serde-gateway.js +89 -0
- package/runtime/gateways/def-serde-gateway.js.map +1 -0
- package/runtime/gateways/file/deno/deno-filesystem.d.ts +27 -0
- package/runtime/gateways/file/deno/deno-filesystem.d.ts.map +1 -0
- package/runtime/gateways/file/deno/deno-filesystem.js +52 -0
- package/runtime/gateways/file/deno/deno-filesystem.js.map +1 -0
- package/runtime/gateways/file/deno/get-sys-file-system.d.ts +4 -0
- package/runtime/gateways/file/deno/get-sys-file-system.d.ts.map +1 -0
- package/runtime/gateways/file/deno/get-sys-file-system.js +11 -0
- package/runtime/gateways/file/deno/get-sys-file-system.js.map +1 -0
- package/runtime/gateways/file/deno/index.d.ts +2 -0
- package/runtime/gateways/file/deno/index.d.ts.map +1 -0
- package/runtime/gateways/file/deno/index.js +2 -0
- package/runtime/gateways/file/deno/index.js.map +1 -0
- package/runtime/gateways/file/gateway-impl.d.ts +18 -0
- package/runtime/gateways/file/gateway-impl.d.ts.map +1 -0
- package/runtime/gateways/file/gateway-impl.js +121 -0
- package/runtime/gateways/file/gateway-impl.js.map +1 -0
- package/runtime/gateways/file/index.d.ts +3 -0
- package/runtime/gateways/file/index.d.ts.map +1 -0
- package/runtime/gateways/file/index.js +3 -0
- package/runtime/gateways/file/index.js.map +1 -0
- package/runtime/gateways/file/key-bag-file.d.ts +19 -0
- package/runtime/gateways/file/key-bag-file.d.ts.map +1 -0
- package/runtime/gateways/file/key-bag-file.js +40 -0
- package/runtime/gateways/file/key-bag-file.js.map +1 -0
- package/runtime/gateways/file/node/get-sys-file-system.d.ts +4 -0
- package/runtime/gateways/file/node/get-sys-file-system.d.ts.map +1 -0
- package/runtime/gateways/file/node/get-sys-file-system.js +11 -0
- package/runtime/gateways/file/node/get-sys-file-system.js.map +1 -0
- package/runtime/gateways/file/node/index.d.ts +2 -0
- package/runtime/gateways/file/node/index.d.ts.map +1 -0
- package/runtime/gateways/file/node/index.js +2 -0
- package/runtime/gateways/file/node/index.js.map +1 -0
- package/runtime/gateways/file/node/node-filesystem.d.ts +32 -0
- package/runtime/gateways/file/node/node-filesystem.d.ts.map +1 -0
- package/runtime/gateways/file/node/node-filesystem.js +33 -0
- package/runtime/gateways/file/node/node-filesystem.js.map +1 -0
- package/runtime/gateways/file/node/to-array-buffer.d.ts +2 -0
- package/runtime/gateways/file/node/to-array-buffer.d.ts.map +1 -0
- package/runtime/gateways/file/node/to-array-buffer.js +12 -0
- package/runtime/gateways/file/node/to-array-buffer.js.map +1 -0
- package/runtime/gateways/file/sys-file-system-factory.d.ts +4 -0
- package/runtime/gateways/file/sys-file-system-factory.d.ts.map +1 -0
- package/runtime/gateways/file/sys-file-system-factory.js +13 -0
- package/runtime/gateways/file/sys-file-system-factory.js.map +1 -0
- package/runtime/gateways/file/utils.d.ts +5 -0
- package/runtime/gateways/file/utils.d.ts.map +1 -0
- package/runtime/gateways/file/utils.js +27 -0
- package/runtime/gateways/file/utils.js.map +1 -0
- package/runtime/gateways/file/version.d.ts +2 -0
- package/runtime/gateways/file/version.d.ts.map +1 -0
- package/runtime/gateways/file/version.js +2 -0
- package/runtime/gateways/file/version.js.map +1 -0
- package/runtime/gateways/fp-envelope-serialize.d.ts +50 -0
- package/runtime/gateways/fp-envelope-serialize.d.ts.map +1 -0
- package/runtime/gateways/fp-envelope-serialize.js +141 -0
- package/runtime/gateways/fp-envelope-serialize.js.map +1 -0
- package/runtime/gateways/index.d.ts +6 -0
- package/runtime/gateways/index.d.ts.map +1 -0
- package/runtime/gateways/index.js +6 -0
- package/runtime/gateways/index.js.map +1 -0
- package/runtime/gateways/indexeddb/gateway-impl.d.ts +22 -0
- package/runtime/gateways/indexeddb/gateway-impl.d.ts.map +1 -0
- package/runtime/gateways/indexeddb/gateway-impl.js +147 -0
- package/runtime/gateways/indexeddb/gateway-impl.js.map +1 -0
- package/runtime/gateways/indexeddb/index.d.ts +6 -0
- package/runtime/gateways/indexeddb/index.d.ts.map +1 -0
- package/runtime/gateways/indexeddb/index.js +6 -0
- package/runtime/gateways/indexeddb/index.js.map +1 -0
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts +15 -0
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts.map +1 -0
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js +42 -0
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js.map +1 -0
- package/runtime/gateways/indexeddb-version.d.ts +2 -0
- package/runtime/gateways/indexeddb-version.d.ts.map +1 -0
- package/runtime/gateways/indexeddb-version.js +2 -0
- package/runtime/gateways/indexeddb-version.js.map +1 -0
- package/runtime/gateways/memory/gateway.d.ts +18 -0
- package/runtime/gateways/memory/gateway.d.ts.map +1 -0
- package/runtime/gateways/memory/gateway.js +73 -0
- package/runtime/gateways/memory/gateway.js.map +1 -0
- package/runtime/gateways/memory/version.d.ts +2 -0
- package/runtime/gateways/memory/version.d.ts.map +1 -0
- package/runtime/gateways/memory/version.js +2 -0
- package/runtime/gateways/memory/version.js.map +1 -0
- package/runtime/index.d.ts +13 -0
- package/runtime/index.d.ts.map +1 -0
- package/runtime/index.js +13 -0
- package/runtime/index.js.map +1 -0
- package/runtime/key-bag-memory.d.ts +12 -0
- package/runtime/key-bag-memory.d.ts.map +1 -0
- package/runtime/key-bag-memory.js +23 -0
- package/runtime/key-bag-memory.js.map +1 -0
- package/runtime/key-bag.d.ts +85 -0
- package/runtime/key-bag.d.ts.map +1 -0
- package/runtime/key-bag.js +411 -0
- package/runtime/key-bag.js.map +1 -0
- package/runtime/keyed-crypto.d.ts +19 -0
- package/runtime/keyed-crypto.d.ts.map +1 -0
- package/runtime/keyed-crypto.js +192 -0
- package/runtime/keyed-crypto.js.map +1 -0
- package/runtime/memory-sys-container.d.ts +2 -0
- package/runtime/memory-sys-container.d.ts.map +1 -0
- package/runtime/memory-sys-container.js +2 -0
- package/runtime/memory-sys-container.js.map +1 -0
- package/runtime/meta-key-hack.d.ts +42 -0
- package/runtime/meta-key-hack.d.ts.map +1 -0
- package/runtime/meta-key-hack.js +201 -0
- package/runtime/meta-key-hack.js.map +1 -0
- package/runtime/sts-service/index.d.ts +40 -0
- package/runtime/sts-service/index.d.ts.map +1 -0
- package/runtime/sts-service/index.js +102 -0
- package/runtime/sts-service/index.js.map +1 -0
- package/runtime/sys-container.d.ts +2 -0
- package/runtime/sys-container.d.ts.map +1 -0
- package/runtime/sys-container.js +2 -0
- package/runtime/sys-container.js.map +1 -0
- package/runtime/wait-pr-multiformats/block.d.ts +47 -0
- package/runtime/wait-pr-multiformats/block.d.ts.map +1 -0
- package/runtime/wait-pr-multiformats/block.js +64 -0
- package/runtime/wait-pr-multiformats/block.js.map +1 -0
- package/runtime/wait-pr-multiformats/codec-interface.d.ts +29 -0
- package/runtime/wait-pr-multiformats/codec-interface.d.ts.map +1 -0
- package/runtime/wait-pr-multiformats/codec-interface.js +2 -0
- package/runtime/wait-pr-multiformats/codec-interface.js.map +1 -0
- package/runtime/wait-pr-multiformats/index.d.ts +3 -0
- package/runtime/wait-pr-multiformats/index.d.ts.map +1 -0
- package/runtime/wait-pr-multiformats/index.js +3 -0
- package/runtime/wait-pr-multiformats/index.js.map +1 -0
- package/tests/blockstore/interceptor-gateway.test.ts +10 -9
- package/tests/blockstore/keyed-crypto.test.ts +2 -2
- package/tests/blockstore/loader.test.ts +68 -51
- package/tests/blockstore/standalone.test.ts +152 -0
- package/tests/blockstore/store.test.ts +16 -9
- package/tests/blockstore/transaction.test.ts +19 -16
- package/tests/fireproof/all-gateway.test.ts +12 -27
- package/tests/fireproof/attachable.test.ts +426 -97
- package/tests/fireproof/crdt.test.ts +23 -0
- package/tests/fireproof/database.test.ts +13 -12
- package/tests/fireproof/fireproof.test.ts +2 -5
- package/tests/fireproof/indexer.test.ts +4 -0
- package/tests/helpers.ts +30 -14
- package/tests/react/img-file.test.tsx +0 -9
- package/tests/react/use-fireproof-stability.test.tsx +5 -5
- package/tests/react/use-fireproof.test.tsx +18 -13
- package/tests/runtime/meta-key-hack.test.ts +7 -6
- package/tests/setup.indexeddb.ts +0 -9
- package/types.d.ts +460 -0
- package/types.d.ts.map +1 -0
- package/types.js +60 -0
- package/types.js.map +1 -0
- package/use-fireproof/iframe-strategy.d.ts +13 -0
- package/use-fireproof/iframe-strategy.d.ts.map +1 -0
- package/use-fireproof/iframe-strategy.js +83 -0
- package/use-fireproof/iframe-strategy.js.map +1 -0
- package/use-fireproof/index.d.ts +10 -0
- package/use-fireproof/index.d.ts.map +1 -0
- package/use-fireproof/index.js +16 -0
- package/use-fireproof/index.js.map +1 -0
- package/use-fireproof/redirect-strategy.d.ts +8 -0
- package/use-fireproof/redirect-strategy.d.ts.map +1 -0
- package/use-fireproof/redirect-strategy.js +31 -0
- package/use-fireproof/redirect-strategy.js.map +1 -0
- package/utils.d.ts +45 -0
- package/utils.d.ts.map +1 -0
- package/utils.js +406 -0
- package/utils.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/write-queue.d.ts +9 -0
- package/write-queue.d.ts.map +1 -0
- package/write-queue.js +70 -0
- package/write-queue.js.map +1 -0
- package/deno/index.d.ts +0 -7
- package/deno/index.js +0 -67
- package/deno/index.js.map +0 -1
- package/deno/metafile-esm.json +0 -1
- package/index.cjs +0 -7275
- package/index.cjs.map +0 -1
- package/index.d.cts +0 -2741
- package/indexeddb/index.cjs +0 -218
- package/indexeddb/index.cjs.map +0 -1
- package/indexeddb/index.d.cts +0 -30
- package/indexeddb/index.d.ts +0 -30
- package/indexeddb/index.js +0 -195
- package/indexeddb/index.js.map +0 -1
- package/indexeddb/metafile-cjs.json +0 -1
- package/indexeddb/metafile-esm.json +0 -1
- package/metafile-cjs.json +0 -1
- package/metafile-esm.json +0 -1
- package/node/index.cjs +0 -93
- package/node/index.cjs.map +0 -1
- package/node/index.d.cts +0 -7
- package/node/index.d.ts +0 -7
- package/node/index.js +0 -60
- package/node/index.js.map +0 -1
- package/node/metafile-cjs.json +0 -1
- package/node/metafile-esm.json +0 -1
- package/react/index.cjs +0 -392
- package/react/index.cjs.map +0 -1
- package/react/metafile-cjs.json +0 -1
- package/react/metafile-esm.json +0 -1
- package/tests/www/gallery.html +0 -132
- package/tests/www/iife.html +0 -42
- package/tests/www/todo-aws.html +0 -232
- package/tests/www/todo-ipfs.html +0 -213
- package/tests/www/todo-local.html +0 -214
- package/tests/www/todo-netlify.html +0 -227
- package/tests/www/todo.html +0 -254
package/react/index.cjs
DELETED
@@ -1,392 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
|
30
|
-
// src/react/index.ts
|
31
|
-
var index_exports = {};
|
32
|
-
__export(index_exports, {
|
33
|
-
FireproofCtx: () => FireproofCtx,
|
34
|
-
ImgFile: () => ImgFile,
|
35
|
-
useFireproof: () => useFireproof
|
36
|
-
});
|
37
|
-
module.exports = __toCommonJS(index_exports);
|
38
|
-
|
39
|
-
// src/react/use-fireproof.ts
|
40
|
-
var import_core = require("@fireproof/core");
|
41
|
-
var import_react5 = require("react");
|
42
|
-
|
43
|
-
// src/react/use-document.ts
|
44
|
-
var import_react = require("react");
|
45
|
-
|
46
|
-
// src/react/utils.ts
|
47
|
-
function deepClone(value) {
|
48
|
-
return (structuredClone ?? ((v) => JSON.parse(JSON.stringify(v))))(value);
|
49
|
-
}
|
50
|
-
|
51
|
-
// src/react/use-document.ts
|
52
|
-
function createUseDocument(database) {
|
53
|
-
return function useDocument(initialDocOrFn) {
|
54
|
-
const updateHappenedRef = (0, import_react.useRef)(false);
|
55
|
-
let initialDoc;
|
56
|
-
if (typeof initialDocOrFn === "function") {
|
57
|
-
initialDoc = initialDocOrFn();
|
58
|
-
} else {
|
59
|
-
initialDoc = initialDocOrFn ?? {};
|
60
|
-
}
|
61
|
-
const originalInitialDoc = (0, import_react.useMemo)(() => deepClone({ ...initialDoc }), []);
|
62
|
-
const [doc, setDoc] = (0, import_react.useState)(initialDoc);
|
63
|
-
const refresh = (0, import_react.useCallback)(async () => {
|
64
|
-
if (doc._id) {
|
65
|
-
try {
|
66
|
-
const gotDoc = await database.get(doc._id);
|
67
|
-
setDoc(gotDoc);
|
68
|
-
} catch {
|
69
|
-
setDoc(initialDoc);
|
70
|
-
}
|
71
|
-
} else {
|
72
|
-
setDoc(initialDoc);
|
73
|
-
}
|
74
|
-
}, [doc._id]);
|
75
|
-
const save = (0, import_react.useCallback)(
|
76
|
-
async (existingDoc) => {
|
77
|
-
updateHappenedRef.current = false;
|
78
|
-
const toSave = existingDoc ?? doc;
|
79
|
-
const res = await database.put(toSave);
|
80
|
-
if (!updateHappenedRef.current && !doc._id && !existingDoc) {
|
81
|
-
setDoc((d) => ({ ...d, _id: res.id }));
|
82
|
-
}
|
83
|
-
return res;
|
84
|
-
},
|
85
|
-
[doc]
|
86
|
-
);
|
87
|
-
const remove = (0, import_react.useCallback)(
|
88
|
-
async (existingDoc) => {
|
89
|
-
const id = existingDoc?._id ?? doc._id;
|
90
|
-
if (!id) throw database.logger.Error().Msg(`Document must have an _id to be removed`).AsError();
|
91
|
-
const gotDoc = await database.get(id).catch(() => void 0);
|
92
|
-
if (!gotDoc) throw database.logger.Error().Str("id", id).Msg(`Document not found`).AsError();
|
93
|
-
const res = await database.del(id);
|
94
|
-
setDoc(initialDoc);
|
95
|
-
return res;
|
96
|
-
},
|
97
|
-
[doc, initialDoc]
|
98
|
-
);
|
99
|
-
const merge = (0, import_react.useCallback)((newDoc) => {
|
100
|
-
updateHappenedRef.current = true;
|
101
|
-
setDoc((prev) => ({ ...prev, ...newDoc }));
|
102
|
-
}, []);
|
103
|
-
const replace = (0, import_react.useCallback)((newDoc) => {
|
104
|
-
updateHappenedRef.current = true;
|
105
|
-
setDoc(newDoc);
|
106
|
-
}, []);
|
107
|
-
const reset = (0, import_react.useCallback)(() => {
|
108
|
-
updateHappenedRef.current = true;
|
109
|
-
setDoc({ ...originalInitialDoc });
|
110
|
-
}, [originalInitialDoc]);
|
111
|
-
const updateDoc = (0, import_react.useCallback)(
|
112
|
-
(newDoc, opts = { replace: false, reset: false }) => {
|
113
|
-
if (!newDoc) {
|
114
|
-
return opts.reset ? reset() : refresh();
|
115
|
-
}
|
116
|
-
return opts.replace ? replace(newDoc) : merge(newDoc);
|
117
|
-
},
|
118
|
-
[refresh, reset, replace, merge]
|
119
|
-
);
|
120
|
-
(0, import_react.useEffect)(() => {
|
121
|
-
if (!doc._id) return;
|
122
|
-
return database.subscribe((changes) => {
|
123
|
-
if (updateHappenedRef.current) {
|
124
|
-
return;
|
125
|
-
}
|
126
|
-
if (changes.find((c) => c._id === doc._id)) {
|
127
|
-
void refresh();
|
128
|
-
}
|
129
|
-
}, true);
|
130
|
-
}, [doc._id, refresh]);
|
131
|
-
(0, import_react.useEffect)(() => {
|
132
|
-
void refresh();
|
133
|
-
}, [refresh]);
|
134
|
-
const submit = (0, import_react.useCallback)(
|
135
|
-
async (e) => {
|
136
|
-
if (e?.preventDefault) e.preventDefault();
|
137
|
-
await save();
|
138
|
-
reset();
|
139
|
-
},
|
140
|
-
[save, reset]
|
141
|
-
);
|
142
|
-
const apiObject = {
|
143
|
-
doc: { ...doc },
|
144
|
-
merge,
|
145
|
-
replace,
|
146
|
-
reset,
|
147
|
-
refresh,
|
148
|
-
save,
|
149
|
-
remove,
|
150
|
-
submit
|
151
|
-
};
|
152
|
-
const tuple = [{ ...doc }, updateDoc, save, remove, reset, refresh];
|
153
|
-
Object.assign(apiObject, tuple);
|
154
|
-
Object.defineProperty(apiObject, Symbol.iterator, {
|
155
|
-
enumerable: false,
|
156
|
-
value: function* () {
|
157
|
-
yield* tuple;
|
158
|
-
}
|
159
|
-
});
|
160
|
-
return apiObject;
|
161
|
-
};
|
162
|
-
}
|
163
|
-
|
164
|
-
// src/react/use-live-query.ts
|
165
|
-
var import_react2 = require("react");
|
166
|
-
function createUseLiveQuery(database) {
|
167
|
-
return function useLiveQuery(mapFn, query = {}, initialRows = []) {
|
168
|
-
const [result, setResult] = (0, import_react2.useState)({
|
169
|
-
docs: initialRows.map((r) => r.doc).filter((r) => !!r),
|
170
|
-
rows: initialRows
|
171
|
-
});
|
172
|
-
const queryString = (0, import_react2.useMemo)(() => JSON.stringify(query), [query]);
|
173
|
-
const mapFnString = (0, import_react2.useMemo)(() => mapFn.toString(), [mapFn]);
|
174
|
-
const refreshRows = (0, import_react2.useCallback)(async () => {
|
175
|
-
const res = await database.query(mapFn, query);
|
176
|
-
setResult({
|
177
|
-
docs: res.rows.map((r) => r.doc).filter((r) => !!r),
|
178
|
-
rows: res.rows
|
179
|
-
});
|
180
|
-
}, [database, mapFnString, queryString]);
|
181
|
-
(0, import_react2.useEffect)(() => {
|
182
|
-
refreshRows();
|
183
|
-
const unsubscribe = database.subscribe(refreshRows);
|
184
|
-
return () => {
|
185
|
-
unsubscribe();
|
186
|
-
};
|
187
|
-
}, [database, refreshRows]);
|
188
|
-
return result;
|
189
|
-
};
|
190
|
-
}
|
191
|
-
|
192
|
-
// src/react/use-all-docs.ts
|
193
|
-
var import_react3 = require("react");
|
194
|
-
function createUseAllDocs(database) {
|
195
|
-
return function useAllDocs(query = {}) {
|
196
|
-
const [result, setResult] = (0, import_react3.useState)({
|
197
|
-
docs: []
|
198
|
-
});
|
199
|
-
const queryString = (0, import_react3.useMemo)(() => JSON.stringify(query), [query]);
|
200
|
-
const refreshRows = (0, import_react3.useCallback)(async () => {
|
201
|
-
const res = await database.allDocs(query);
|
202
|
-
setResult({
|
203
|
-
...res,
|
204
|
-
docs: res.rows.map((r) => r.value)
|
205
|
-
});
|
206
|
-
}, [database, queryString]);
|
207
|
-
(0, import_react3.useEffect)(() => {
|
208
|
-
refreshRows();
|
209
|
-
const unsubscribe = database.subscribe(refreshRows);
|
210
|
-
return () => {
|
211
|
-
unsubscribe();
|
212
|
-
};
|
213
|
-
}, [database, refreshRows]);
|
214
|
-
return result;
|
215
|
-
};
|
216
|
-
}
|
217
|
-
|
218
|
-
// src/react/use-changes.ts
|
219
|
-
var import_react4 = require("react");
|
220
|
-
function createUseChanges(database) {
|
221
|
-
return function useChanges(since = [], opts = {}) {
|
222
|
-
const [result, setResult] = (0, import_react4.useState)({
|
223
|
-
docs: []
|
224
|
-
});
|
225
|
-
const queryString = (0, import_react4.useMemo)(() => JSON.stringify(opts), [opts]);
|
226
|
-
const refreshRows = (0, import_react4.useCallback)(async () => {
|
227
|
-
const res = await database.changes(since, opts);
|
228
|
-
setResult({ ...res, docs: res.rows.map((r) => r.value) });
|
229
|
-
}, [since, queryString]);
|
230
|
-
(0, import_react4.useEffect)(() => {
|
231
|
-
refreshRows();
|
232
|
-
return database.subscribe(refreshRows);
|
233
|
-
}, [refreshRows]);
|
234
|
-
return result;
|
235
|
-
};
|
236
|
-
}
|
237
|
-
|
238
|
-
// src/react/use-fireproof.ts
|
239
|
-
var FireproofCtx = {};
|
240
|
-
function createLazyDatabase(name, config = {}) {
|
241
|
-
let _database = null;
|
242
|
-
const _subscribers = /* @__PURE__ */ new Set();
|
243
|
-
const getDatabase = () => {
|
244
|
-
if (!_database) {
|
245
|
-
_database = (0, import_core.fireproof)(name, config);
|
246
|
-
_database.subscribe((changes) => {
|
247
|
-
_subscribers.forEach((subscriber) => subscriber(changes));
|
248
|
-
}, true);
|
249
|
-
}
|
250
|
-
return _database;
|
251
|
-
};
|
252
|
-
const isWriteOperation = (method) => {
|
253
|
-
return ["put", "bulk", "del", "create", "transact"].includes(method);
|
254
|
-
};
|
255
|
-
return new Proxy({}, {
|
256
|
-
get(target, prop, receiver) {
|
257
|
-
if (prop === "constructor") {
|
258
|
-
return { name: "Database" };
|
259
|
-
}
|
260
|
-
if (prop === "name") {
|
261
|
-
return name;
|
262
|
-
}
|
263
|
-
if (typeof prop === "string" || typeof prop === "symbol") {
|
264
|
-
if (prop === "get") {
|
265
|
-
return async function get(id) {
|
266
|
-
const db = getDatabase();
|
267
|
-
return db.get(id);
|
268
|
-
};
|
269
|
-
}
|
270
|
-
if (prop === "query" || prop === "allDocs") {
|
271
|
-
return async function query(...args) {
|
272
|
-
const db = getDatabase();
|
273
|
-
const method = db[prop];
|
274
|
-
return method.apply(db, args);
|
275
|
-
};
|
276
|
-
}
|
277
|
-
if (prop === "put") {
|
278
|
-
return async function put(doc) {
|
279
|
-
const db = getDatabase();
|
280
|
-
return db.put(doc);
|
281
|
-
};
|
282
|
-
}
|
283
|
-
if (prop === "bulk") {
|
284
|
-
return async function bulk(docs) {
|
285
|
-
const db = getDatabase();
|
286
|
-
return db.bulk(docs);
|
287
|
-
};
|
288
|
-
}
|
289
|
-
if (prop === "subscribe") {
|
290
|
-
return function subscribe(callback) {
|
291
|
-
_subscribers.add(callback);
|
292
|
-
getDatabase();
|
293
|
-
return () => _subscribers.delete(callback);
|
294
|
-
};
|
295
|
-
}
|
296
|
-
if (prop === "close" || prop === "destroy") {
|
297
|
-
return async function() {
|
298
|
-
if (_database) {
|
299
|
-
const method = _database[prop];
|
300
|
-
return method.call(_database);
|
301
|
-
}
|
302
|
-
return Promise.resolve();
|
303
|
-
};
|
304
|
-
}
|
305
|
-
return function(...args) {
|
306
|
-
if (isWriteOperation(prop)) {
|
307
|
-
const db = getDatabase();
|
308
|
-
const method = db[prop];
|
309
|
-
if (typeof method === "function") {
|
310
|
-
return method.apply(db, args);
|
311
|
-
}
|
312
|
-
return void 0;
|
313
|
-
}
|
314
|
-
if (_database) {
|
315
|
-
const method = _database[prop];
|
316
|
-
if (typeof method === "function") {
|
317
|
-
return method.apply(_database, args);
|
318
|
-
}
|
319
|
-
return void 0;
|
320
|
-
}
|
321
|
-
return function noOp() {
|
322
|
-
};
|
323
|
-
};
|
324
|
-
}
|
325
|
-
return Reflect.get(target, prop, receiver);
|
326
|
-
}
|
327
|
-
});
|
328
|
-
}
|
329
|
-
function useFireproof(name = "useFireproof", config = {}) {
|
330
|
-
return (0, import_react5.useMemo)(() => {
|
331
|
-
const database = typeof name === "string" ? createLazyDatabase(name, config) : name;
|
332
|
-
const useDocument = createUseDocument(database);
|
333
|
-
const useLiveQuery = createUseLiveQuery(database);
|
334
|
-
const useAllDocs = createUseAllDocs(database);
|
335
|
-
const useChanges = createUseChanges(database);
|
336
|
-
return { database, useLiveQuery, useDocument, useAllDocs, useChanges };
|
337
|
-
}, [name, JSON.stringify(config)]);
|
338
|
-
}
|
339
|
-
|
340
|
-
// src/react/img-file.ts
|
341
|
-
var import_react6 = __toESM(require("react"), 1);
|
342
|
-
var { URL } = globalThis;
|
343
|
-
function isFile(obj) {
|
344
|
-
return "type" in obj && "size" in obj && "stream" in obj && typeof obj.stream === "function";
|
345
|
-
}
|
346
|
-
function isFileMeta(obj) {
|
347
|
-
return "type" in obj && "size" in obj && "file" in obj && typeof obj.file === "function";
|
348
|
-
}
|
349
|
-
function ImgFile({ file, meta, ...imgProps }) {
|
350
|
-
const [imgDataUrl, setImgDataUrl] = (0, import_react6.useState)("");
|
351
|
-
const fileData = file || meta;
|
352
|
-
(0, import_react6.useEffect)(() => {
|
353
|
-
if (!fileData) return;
|
354
|
-
const loadFile = async () => {
|
355
|
-
let fileObj = null;
|
356
|
-
let fileType = "";
|
357
|
-
switch (true) {
|
358
|
-
case isFile(fileData):
|
359
|
-
fileObj = fileData;
|
360
|
-
fileType = fileData.type;
|
361
|
-
break;
|
362
|
-
case isFileMeta(fileData):
|
363
|
-
fileType = fileData.type;
|
364
|
-
fileObj = await fileData.file?.() || null;
|
365
|
-
break;
|
366
|
-
}
|
367
|
-
if (fileObj && /image/.test(fileType)) {
|
368
|
-
const src = URL.createObjectURL(fileObj);
|
369
|
-
setImgDataUrl(src);
|
370
|
-
return () => URL.revokeObjectURL(src);
|
371
|
-
}
|
372
|
-
};
|
373
|
-
let isMounted = true;
|
374
|
-
let cleanup;
|
375
|
-
loadFile().then((result) => {
|
376
|
-
if (isMounted) {
|
377
|
-
cleanup = result;
|
378
|
-
} else if (result) {
|
379
|
-
result();
|
380
|
-
}
|
381
|
-
});
|
382
|
-
return () => {
|
383
|
-
isMounted = false;
|
384
|
-
if (cleanup) cleanup();
|
385
|
-
};
|
386
|
-
}, [fileData]);
|
387
|
-
return imgDataUrl ? import_react6.default.createElement("img", {
|
388
|
-
src: imgDataUrl,
|
389
|
-
...imgProps
|
390
|
-
}) : null;
|
391
|
-
}
|
392
|
-
//# sourceMappingURL=index.cjs.map
|
package/react/index.cjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/react/index.ts","../../../src/react/use-fireproof.ts","../../../src/react/use-document.ts","../../../src/react/utils.ts","../../../src/react/use-live-query.ts","../../../src/react/use-all-docs.ts","../../../src/react/use-changes.ts","../../../src/react/img-file.ts"],"sourcesContent":["export { FireproofCtx, useFireproof } from \"./use-fireproof.js\";\nexport * from \"./types.js\";\nexport * from \"./img-file.js\";\n","import type { ConfigOpts, Database, DocSet, DocTypes } from \"@fireproof/core\";\nimport { fireproof } from \"@fireproof/core\";\nimport { useMemo } from \"react\";\nimport type { UseFireproof } from \"./types.js\";\nimport { createUseDocument } from \"./use-document.js\";\nimport { createUseLiveQuery } from \"./use-live-query.js\";\nimport { createUseAllDocs } from \"./use-all-docs.js\";\nimport { createUseChanges } from \"./use-changes.js\";\n\n/**\n * @deprecated Use the `useFireproof` hook instead\n */\nexport const FireproofCtx = {} as UseFireproof;\n\n/**\n *\n * ## Summary\n *\n * React hook to create a custom-named Fireproof database and provides the utility hooks to query against it.\n *\n * ## Usage\n * ```tsx\n * const { database, useLiveQuery, useDocument } = useFireproof(\"dbname\");\n * const { database, useLiveQuery, useDocument } = useFireproof(\"dbname\", { ...options });\n * ```\n *\n *\n */\n/**\n * Creates a proxy database that only initializes the actual database on first write operation\n */\nfunction createLazyDatabase(name: string, config: ConfigOpts = {}): Database {\n let _database: Database | null = null;\n const _subscribers = new Set<(changes: unknown[]) => void>();\n\n // Initialize the database only when needed\n const getDatabase = (): Database => {\n if (!_database) {\n _database = fireproof(name, config);\n\n // Set up real subscription forwarding\n _database.subscribe((changes) => {\n _subscribers.forEach((subscriber) => subscriber(changes));\n }, true);\n }\n return _database;\n };\n\n // Detect write operations that should trigger database initialization\n const isWriteOperation = (method: string): boolean => {\n return [\"put\", \"bulk\", \"del\", \"create\", \"transact\"].includes(method);\n };\n\n // Create a proxy to intercept all database method calls\n return new Proxy<Database>({} as Database, {\n get(target, prop, receiver) {\n // Handle constructor name for type checking\n if (prop === \"constructor\") {\n return { name: \"Database\" };\n }\n\n // Handle name property\n if (prop === \"name\") {\n return name;\n }\n\n // Return a function that will initialize the database if it's a write operation\n if (typeof prop === \"string\" || typeof prop === \"symbol\") {\n // Handle get method to open DB and fetch\n if (prop === \"get\") {\n return async function get(id: string) {\n const db = getDatabase();\n return db.get(id);\n };\n }\n\n // Handle query methods: open DB and query\n if (prop === \"query\" || prop === \"allDocs\") {\n return async function query(...args: unknown[]) {\n const db = getDatabase();\n // Bind to ensure correct 'this' context for database methods\n const method = (db as unknown as Record<string, (...methodArgs: unknown[]) => unknown>)[prop as string];\n return method.apply(db, args);\n };\n }\n\n // Handle put to make sure it triggers database initialization\n if (prop === \"put\") {\n return async function put<T extends DocTypes>(doc: DocSet<T>) {\n // Always initialize the database for put operations\n const db = getDatabase();\n return db.put(doc);\n };\n }\n\n // Handle bulk operation\n if (prop === \"bulk\") {\n return async function bulk(docs: Record<string, unknown>[]) {\n // Always initialize the database for bulk operations\n const db = getDatabase();\n return db.bulk(docs);\n };\n }\n\n // Handle subscribe method to collect subscribers even before DB is initialized\n if (prop === \"subscribe\") {\n return function subscribe(callback: (changes: unknown[]) => void) {\n // Store locally so aggregator can dispatch before DB exists\n _subscribers.add(callback);\n\n // Ensure DB is initialised (sets up the aggregator once)\n getDatabase();\n\n // Return an unsubscribe that removes the callback from the local set\n return () => _subscribers.delete(callback);\n };\n }\n\n // Handle close and destroy methods\n if (prop === \"close\" || prop === \"destroy\") {\n return async function () {\n if (_database) {\n const method = _database[prop] as () => Promise<unknown>;\n return method.call(_database);\n }\n return Promise.resolve();\n };\n }\n\n // For all other methods\n return function (...args: unknown[]) {\n // Always initialize database for write operations\n if (isWriteOperation(prop as string)) {\n const db = getDatabase();\n // Use type assertion to call method safely\n const method = (db as unknown as Record<string, (...methodArgs: unknown[]) => unknown>)[prop as string];\n if (typeof method === \"function\") {\n return method.apply(db, args);\n }\n return undefined;\n }\n\n // For read operations, only use the database if it's already initialized\n if (_database) {\n // Use type assertion to call method safely\n const method = (_database as unknown as Record<string, (...methodArgs: unknown[]) => unknown>)[prop as string];\n if (typeof method === \"function\") {\n return method.apply(_database, args);\n }\n return undefined;\n }\n\n // Return appropriate no-op responses for other methods\n return function noOp() {\n /* no-op */\n };\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n });\n}\n\n/**\n * React hook to create a Fireproof database with lazy initialization\n *\n * @param name The name of the database or an existing database instance\n * @param config Configuration options for the database\n * @returns UseFireproof object with database and hooks\n */\nexport function useFireproof(name: string | Database = \"useFireproof\", config: ConfigOpts = {}): UseFireproof {\n // Use useMemo to ensure stable references across renders\n return useMemo(() => {\n // If the user passed an existing database instance, use it directly\n // Otherwise create a lazy database that only initializes on first write\n const database = typeof name === \"string\" ? createLazyDatabase(name, config) : name;\n\n const useDocument = createUseDocument(database);\n const useLiveQuery = createUseLiveQuery(database);\n const useAllDocs = createUseAllDocs(database);\n const useChanges = createUseChanges(database);\n\n return { database, useLiveQuery, useDocument, useAllDocs, useChanges };\n }, [name, JSON.stringify(config)]); // Only recreate if name or stringified config changes\n}\n\n// Export types\nexport type {\n LiveQueryResult,\n UseDocumentResult,\n AllDocsResult,\n ChangesResult,\n UseDocument,\n UseLiveQuery,\n UseAllDocs,\n UseChanges,\n UseFireproof,\n} from \"./types.js\";\n","import { useCallback, useEffect, useMemo, useState, useRef } from \"react\";\nimport type { DocSet, DocTypes, DocWithId, Database } from \"@fireproof/core\";\nimport { deepClone } from \"./utils.js\";\nimport type { DeleteDocFn, StoreDocFn, UseDocumentInitialDocOrFn, UseDocumentResult } from \"./types.js\";\n\n/**\n * Implementation of the useDocument hook\n */\nexport function createUseDocument(database: Database) {\n return function useDocument<T extends DocTypes>(initialDocOrFn?: UseDocumentInitialDocOrFn<T>): UseDocumentResult<T> {\n const updateHappenedRef = useRef(false);\n let initialDoc: DocSet<T>;\n if (typeof initialDocOrFn === \"function\") {\n initialDoc = initialDocOrFn();\n } else {\n initialDoc = initialDocOrFn ?? ({} as T);\n }\n\n const originalInitialDoc = useMemo(() => deepClone({ ...initialDoc }), []);\n\n const [doc, setDoc] = useState(initialDoc);\n\n const refresh = useCallback(async () => {\n if (doc._id) {\n try {\n const gotDoc = await database.get<T>(doc._id);\n setDoc(gotDoc);\n } catch {\n setDoc(initialDoc);\n }\n } else {\n setDoc(initialDoc);\n }\n }, [doc._id]);\n\n const save: StoreDocFn<T> = useCallback(\n async (existingDoc) => {\n updateHappenedRef.current = false;\n const toSave = existingDoc ?? doc;\n const res = await database.put(toSave);\n\n if (!updateHappenedRef.current && !doc._id && !existingDoc) {\n setDoc((d) => ({ ...d, _id: res.id }));\n }\n\n return res;\n },\n [doc],\n );\n\n const remove: DeleteDocFn<T> = useCallback(\n async (existingDoc) => {\n const id = existingDoc?._id ?? doc._id;\n if (!id) throw database.logger.Error().Msg(`Document must have an _id to be removed`).AsError();\n const gotDoc = await database.get<T>(id).catch(() => undefined);\n if (!gotDoc) throw database.logger.Error().Str(\"id\", id).Msg(`Document not found`).AsError();\n const res = await database.del(id);\n setDoc(initialDoc);\n return res;\n },\n [doc, initialDoc],\n );\n\n // New granular update methods\n const merge = useCallback((newDoc: Partial<T>) => {\n updateHappenedRef.current = true;\n setDoc((prev) => ({ ...prev, ...newDoc }));\n }, []);\n\n const replace = useCallback((newDoc: T) => {\n updateHappenedRef.current = true;\n setDoc(newDoc);\n }, []);\n\n const reset = useCallback(() => {\n updateHappenedRef.current = true;\n setDoc({ ...originalInitialDoc });\n }, [originalInitialDoc]);\n\n // Legacy-compatible updateDoc\n const updateDoc = useCallback(\n (newDoc?: DocSet<T>, opts = { replace: false, reset: false }) => {\n if (!newDoc) {\n return opts.reset ? reset() : refresh();\n }\n return opts.replace ? replace(newDoc as T) : merge(newDoc);\n },\n [refresh, reset, replace, merge],\n );\n\n useEffect(() => {\n if (!doc._id) return;\n return database.subscribe((changes) => {\n if (updateHappenedRef.current) {\n return;\n }\n if (changes.find((c) => c._id === doc._id)) {\n void refresh();\n }\n }, true);\n }, [doc._id, refresh]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const submit = useCallback(\n async (e?: Event) => {\n if (e?.preventDefault) e.preventDefault();\n await save();\n reset();\n },\n [save, reset],\n );\n\n // Primary Object API with both new and legacy methods\n const apiObject = {\n doc: { ...doc } as DocWithId<T>,\n merge,\n replace,\n reset,\n refresh,\n save,\n remove,\n submit,\n };\n\n // Make the object properly iterable\n const tuple = [{ ...doc }, updateDoc, save, remove, reset, refresh];\n Object.assign(apiObject, tuple);\n Object.defineProperty(apiObject, Symbol.iterator, {\n enumerable: false,\n value: function* () {\n yield* tuple;\n },\n });\n\n return apiObject as UseDocumentResult<T>;\n };\n}\n","/**\n * Deep clone a value\n */\nexport function deepClone<T>(value: T): T {\n return (structuredClone ?? ((v: T) => JSON.parse(JSON.stringify(v))))(value);\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { DocFragment, DocTypes, DocWithId, IndexKeyType, IndexRow, MapFn, Database } from \"@fireproof/core\";\nimport type { LiveQueryResult } from \"./types.js\";\n\n/**\n * Implementation of the useLiveQuery hook\n */\nexport function createUseLiveQuery(database: Database) {\n return function useLiveQuery<T extends DocTypes, K extends IndexKeyType = string, R extends DocFragment = T>(\n mapFn: MapFn<T> | string,\n query = {},\n initialRows: IndexRow<K, T, R>[] = [],\n ): LiveQueryResult<T, K, R> {\n const [result, setResult] = useState<LiveQueryResult<T, K, R>>({\n docs: initialRows.map((r) => r.doc).filter((r): r is DocWithId<T> => !!r),\n rows: initialRows,\n });\n\n const queryString = useMemo(() => JSON.stringify(query), [query]);\n const mapFnString = useMemo(() => mapFn.toString(), [mapFn]);\n\n const refreshRows = useCallback(async () => {\n const res = await database.query<K, T, R>(mapFn, query);\n setResult({\n docs: res.rows.map((r) => r.doc).filter((r): r is DocWithId<T> => !!r),\n rows: res.rows,\n });\n }, [database, mapFnString, queryString]);\n\n useEffect(() => {\n refreshRows();\n const unsubscribe = database.subscribe(refreshRows);\n return () => {\n unsubscribe();\n };\n }, [database, refreshRows]);\n\n return result;\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { AllDocsQueryOpts, DocTypes, DocWithId, Database } from \"@fireproof/core\";\nimport type { AllDocsResult } from \"./types.js\";\n\n/**\n * Implementation of the useAllDocs hook\n */\nexport function createUseAllDocs(database: Database) {\n return function useAllDocs<T extends DocTypes>(query: AllDocsQueryOpts = {}): AllDocsResult<T> {\n const [result, setResult] = useState<AllDocsResult<T>>({\n docs: [],\n });\n\n const queryString = useMemo(() => JSON.stringify(query), [query]);\n\n const refreshRows = useCallback(async () => {\n const res = await database.allDocs<T>(query);\n setResult({\n ...res,\n docs: res.rows.map((r) => r.value as DocWithId<T>),\n });\n }, [database, queryString]);\n\n useEffect(() => {\n refreshRows();\n const unsubscribe = database.subscribe(refreshRows);\n return () => {\n unsubscribe();\n };\n }, [database, refreshRows]);\n\n return result;\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { ChangesOptions, ClockHead, DocTypes, DocWithId, Database } from \"@fireproof/core\";\nimport type { ChangesResult } from \"./types.js\";\n\n/**\n * Implementation of the useChanges hook\n */\nexport function createUseChanges(database: Database) {\n return function useChanges<T extends DocTypes>(since: ClockHead = [], opts: ChangesOptions = {}): ChangesResult<T> {\n const [result, setResult] = useState<ChangesResult<T>>({\n docs: [],\n });\n\n const queryString = useMemo(() => JSON.stringify(opts), [opts]);\n\n const refreshRows = useCallback(async () => {\n const res = await database.changes<T>(since, opts);\n setResult({ ...res, docs: res.rows.map((r) => r.value as DocWithId<T>) });\n }, [since, queryString]);\n\n useEffect(() => {\n refreshRows(); // Initial data fetch\n return database.subscribe(refreshRows);\n }, [refreshRows]);\n\n return result;\n };\n}\n","import { DocFileMeta } from \"@fireproof/core\";\nimport React, { useState, useEffect, ImgHTMLAttributes } from \"react\";\n\nconst { URL } = globalThis;\n\n// Union type to support both direct File objects and metadata objects\ntype FileType = File | DocFileMeta;\n\ninterface ImgFileProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, \"src\"> {\n file?: FileType;\n /**\n * @deprecated Use 'file' instead. This is for internal use only to support legacy code.\n * @internal\n */\n meta?: FileType;\n}\n\n// Helper function to determine if the object is a File-like object\nfunction isFile(obj: FileType): obj is File {\n return \"type\" in obj && \"size\" in obj && \"stream\" in obj && typeof obj.stream === \"function\";\n}\n\n// Helper function to determine if the object is a DocFileMeta\nfunction isFileMeta(obj: FileType): obj is DocFileMeta {\n return \"type\" in obj && \"size\" in obj && \"file\" in obj && typeof obj.file === \"function\";\n}\n\nexport function ImgFile({ file, meta, ...imgProps }: ImgFileProps) {\n const [imgDataUrl, setImgDataUrl] = useState(\"\");\n\n // Use meta as fallback if file is not provided (for backward compatibility)\n const fileData = file || meta;\n\n useEffect(() => {\n if (!fileData) return;\n\n const loadFile = async () => {\n let fileObj: File | null = null;\n let fileType = \"\";\n\n switch (true) {\n case isFile(fileData):\n fileObj = fileData;\n fileType = fileData.type;\n break;\n case isFileMeta(fileData):\n fileType = fileData.type;\n fileObj = (await fileData.file?.()) || null;\n break;\n }\n\n if (fileObj && /image/.test(fileType)) {\n const src = URL.createObjectURL(fileObj);\n setImgDataUrl(src);\n return () => URL.revokeObjectURL(src);\n }\n };\n\n let isMounted = true;\n let cleanup: (() => void) | undefined;\n\n loadFile().then((result) => {\n if (isMounted) {\n cleanup = result;\n } else if (result) {\n result();\n }\n });\n\n return () => {\n isMounted = false;\n if (cleanup) cleanup();\n };\n }, [fileData]);\n\n return imgDataUrl\n ? React.createElement(\"img\", {\n src: imgDataUrl,\n ...imgProps,\n })\n : null;\n}\n\nexport default ImgFile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kBAA0B;AAC1B,IAAAA,gBAAwB;;;ACFxB,mBAAkE;;;ACG3D,SAAS,UAAa,OAAa;AACxC,UAAQ,oBAAoB,CAAC,MAAS,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC,IAAI,KAAK;AAC7E;;;ADGO,SAAS,kBAAkB,UAAoB;AACpD,SAAO,SAAS,YAAgC,gBAAqE;AACnH,UAAM,wBAAoB,qBAAO,KAAK;AACtC,QAAI;AACJ,QAAI,OAAO,mBAAmB,YAAY;AACxC,mBAAa,eAAe;AAAA,IAC9B,OAAO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B,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,kBAAY;AACZ,UAAI,QAAS,SAAQ;AAAA,IACvB;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO,aACH,cAAAC,QAAM,cAAc,OAAO;AAAA,IACzB,KAAK;AAAA,IACL,GAAG;AAAA,EACL,CAAC,IACD;AACN;","names":["import_react","import_react","import_react","import_react","import_react","React"]}
|
package/react/metafile-cjs.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"inputs":{"src/react/utils.ts":{"bytes":156,"imports":[],"format":"esm"},"src/react/use-document.ts":{"bytes":4064,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/react/utils.ts","kind":"import-statement","original":"./utils.js"}],"format":"esm"},"src/react/use-live-query.ts":{"bytes":1403,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/use-all-docs.ts":{"bytes":1021,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/use-changes.ts":{"bytes":974,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/use-fireproof.ts":{"bytes":7004,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/react/use-document.ts","kind":"import-statement","original":"./use-document.js"},{"path":"src/react/use-live-query.ts","kind":"import-statement","original":"./use-live-query.js"},{"path":"src/react/use-all-docs.ts","kind":"import-statement","original":"./use-all-docs.js"},{"path":"src/react/use-changes.ts","kind":"import-statement","original":"./use-changes.js"}],"format":"esm"},"src/react/types.ts":{"bytes":2407,"imports":[],"format":"esm"},"src/react/img-file.ts":{"bytes":2248,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/index.ts":{"bytes":124,"imports":[{"path":"src/react/use-fireproof.ts","kind":"import-statement","original":"./use-fireproof.js"},{"path":"src/react/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/react/img-file.ts","kind":"import-statement","original":"./img-file.js"}],"format":"esm"}},"outputs":{"dist/fireproof-core/react/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":26029},"dist/fireproof-core/react/index.cjs":{"imports":[{"path":"@fireproof/core","kind":"require-call","external":true},{"path":"react","kind":"require-call","external":true},{"path":"react","kind":"require-call","external":true},{"path":"react","kind":"require-call","external":true},{"path":"react","kind":"require-call","external":true},{"path":"react","kind":"require-call","external":true},{"path":"react","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/react/index.ts","inputs":{"src/react/index.ts":{"bytesInOutput":197},"src/react/use-fireproof.ts":{"bytesInOutput":3313},"src/react/use-document.ts":{"bytesInOutput":3565},"src/react/utils.ts":{"bytesInOutput":107},"src/react/use-live-query.ts":{"bytesInOutput":993},"src/react/use-all-docs.ts":{"bytesInOutput":765},"src/react/use-changes.ts":{"bytesInOutput":679},"src/react/img-file.ts":{"bytesInOutput":1499}},"bytes":12799}}}
|
package/react/metafile-esm.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"inputs":{"src/react/utils.ts":{"bytes":156,"imports":[],"format":"esm"},"src/react/use-document.ts":{"bytes":4064,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/react/utils.ts","kind":"import-statement","original":"./utils.js"}],"format":"esm"},"src/react/use-live-query.ts":{"bytes":1403,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/use-all-docs.ts":{"bytes":1021,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/use-changes.ts":{"bytes":974,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/use-fireproof.ts":{"bytes":7004,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/react/use-document.ts","kind":"import-statement","original":"./use-document.js"},{"path":"src/react/use-live-query.ts","kind":"import-statement","original":"./use-live-query.js"},{"path":"src/react/use-all-docs.ts","kind":"import-statement","original":"./use-all-docs.js"},{"path":"src/react/use-changes.ts","kind":"import-statement","original":"./use-changes.js"}],"format":"esm"},"src/react/types.ts":{"bytes":2407,"imports":[],"format":"esm"},"src/react/img-file.ts":{"bytes":2248,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/index.ts":{"bytes":124,"imports":[{"path":"src/react/use-fireproof.ts","kind":"import-statement","original":"./use-fireproof.js"},{"path":"src/react/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/react/img-file.ts","kind":"import-statement","original":"./img-file.js"}],"format":"esm"}},"outputs":{"dist/fireproof-core/react/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":26069},"dist/fireproof-core/react/index.js":{"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["FireproofCtx","ImgFile","useFireproof"],"entryPoint":"src/react/index.ts","inputs":{"src/react/use-fireproof.ts":{"bytesInOutput":3284},"src/react/use-document.ts":{"bytesInOutput":3369},"src/react/utils.ts":{"bytesInOutput":107},"src/react/use-live-query.ts":{"bytesInOutput":987},"src/react/use-all-docs.ts":{"bytesInOutput":777},"src/react/use-changes.ts":{"bytesInOutput":691},"src/react/index.ts":{"bytesInOutput":0},"src/react/img-file.ts":{"bytesInOutput":1476}},"bytes":11006}}}
|
package/tests/www/gallery.html
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8" />
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
|
-
<title>Fireproof Uploads</title>
|
7
|
-
<script src="./fireproof.iife.js?cache=94"></script>
|
8
|
-
<script type="text/javascript">
|
9
|
-
function testApp() {
|
10
|
-
const { fireproof, connect } = Fireproof;
|
11
|
-
let dbName;
|
12
|
-
let db;
|
13
|
-
let cx;
|
14
|
-
|
15
|
-
let dbUnsubscribe = false;
|
16
|
-
|
17
|
-
function setupDb(name) {
|
18
|
-
if (dbUnsubscribe) {
|
19
|
-
dbUnsubscribe();
|
20
|
-
}
|
21
|
-
dbName = name;
|
22
|
-
db = fireproof(name);
|
23
|
-
window.db = db;
|
24
|
-
|
25
|
-
cx = db.connect("jchris+files-30@fireproof.storage", "todo-test");
|
26
|
-
window.cx = cx;
|
27
|
-
|
28
|
-
dbUnsubscribe = db.subscribe(redraw);
|
29
|
-
return db;
|
30
|
-
}
|
31
|
-
|
32
|
-
let doing;
|
33
|
-
const redraw = async () => {
|
34
|
-
if (doing) {
|
35
|
-
return doing;
|
36
|
-
}
|
37
|
-
doing = draw().finally(() => (doing = null));
|
38
|
-
return doing;
|
39
|
-
};
|
40
|
-
|
41
|
-
const draw = async () => {
|
42
|
-
const result = await db.query("_id", { descending: true, limit: 10 });
|
43
|
-
document.querySelector("ul").innerHTML = "";
|
44
|
-
for (const row of result.rows) {
|
45
|
-
const doc = row.doc;
|
46
|
-
if (doc._publicFiles) {
|
47
|
-
const li = document.querySelector("ul").appendChild(document.createElement("li"));
|
48
|
-
li.appendChild(document.createElement("span")).innerText = row.key;
|
49
|
-
li.appendChild(document.createElement("br"));
|
50
|
-
for (const file of Object.keys(doc._publicFiles)) {
|
51
|
-
(async () => {
|
52
|
-
const meta = doc._publicFiles[file];
|
53
|
-
if (meta.file && /image/.test(meta.type)) {
|
54
|
-
const src = URL.createObjectURL(await meta.file());
|
55
|
-
const img = document.createElement("img");
|
56
|
-
img.src = src;
|
57
|
-
img.height = 100;
|
58
|
-
img.onload = () => {
|
59
|
-
URL.revokeObjectURL(img.src);
|
60
|
-
};
|
61
|
-
|
62
|
-
console.log("url", meta.url);
|
63
|
-
li.appendChild(img);
|
64
|
-
}
|
65
|
-
})();
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
};
|
70
|
-
|
71
|
-
async function changeList(e) {
|
72
|
-
e.preventDefault();
|
73
|
-
const input = document.querySelector("#list");
|
74
|
-
dbName = input.value;
|
75
|
-
history.pushState(null, "", location.pathname + "?db=" + encodeURIComponent(dbName));
|
76
|
-
setupDb(dbName);
|
77
|
-
|
78
|
-
redraw();
|
79
|
-
}
|
80
|
-
window.changeList = changeList;
|
81
|
-
|
82
|
-
async function openDashboard(e) {
|
83
|
-
db.openDashboard();
|
84
|
-
}
|
85
|
-
window.openDashboard = openDashboard;
|
86
|
-
|
87
|
-
function handleFiles() {
|
88
|
-
const fileList = this.files;
|
89
|
-
const doc = {
|
90
|
-
_publicFiles: {},
|
91
|
-
};
|
92
|
-
for (const file of fileList) {
|
93
|
-
doc._publicFiles[file.name] = file;
|
94
|
-
}
|
95
|
-
const ok = db.put(doc);
|
96
|
-
}
|
97
|
-
|
98
|
-
async function initialize() {
|
99
|
-
ps = new URLSearchParams(location.search);
|
100
|
-
const listQ = ps.get("db");
|
101
|
-
setupDb(listQ || "hello-world");
|
102
|
-
const input = document.querySelector("#list");
|
103
|
-
input.value = dbName;
|
104
|
-
|
105
|
-
const inputElement = document.getElementById("files-up");
|
106
|
-
inputElement.addEventListener("change", handleFiles, false);
|
107
|
-
db.subscribe(draw);
|
108
|
-
draw();
|
109
|
-
}
|
110
|
-
|
111
|
-
window.onload = initialize;
|
112
|
-
}
|
113
|
-
testApp();
|
114
|
-
</script>
|
115
|
-
</head>
|
116
|
-
|
117
|
-
<body>
|
118
|
-
List:
|
119
|
-
<input title="gallery" type="text" name="list" id="list" />
|
120
|
-
<button onclick="changeList(event)">Change Gallery</button>
|
121
|
-
<button onclick="openDashboard(event)">🔥 Import to Dashboard</button>
|
122
|
-
<h3>Files</h3>
|
123
|
-
<p>
|
124
|
-
Data is stored locally and encrypted before upload to S3. This is a demo so the encryption key is not managed securely. Read
|
125
|
-
more about <a href="https://use-fireproof.com/docs/ledger-api/replication">Fireproof replication options.</a> You can also see
|
126
|
-
a demo without images but <a href="https://fireproof.storage/s3up-test.html">with compaction and refresh buttons.</a>
|
127
|
-
</p>
|
128
|
-
<label for="files-up"><strong>Drop files:</strong></label>
|
129
|
-
<input accept="image/*" title="save to Fireproof" type="file" id="files-up" multiple />
|
130
|
-
<ul></ul>
|
131
|
-
</body>
|
132
|
-
</html>
|
package/tests/www/iife.html
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8" />
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
|
-
<title>Fireproof Test</title>
|
7
|
-
<script src="./fireproof.iife.js"></script>
|
8
|
-
<script type="text/javascript">
|
9
|
-
function testApp() {
|
10
|
-
const db = Fireproof.fireproof("iife-test", { persistIndexes: true });
|
11
|
-
|
12
|
-
const draw = async () => {
|
13
|
-
const result = await db.query("sort", { includeDocs: true });
|
14
|
-
document.querySelector("ul").innerHTML = "";
|
15
|
-
for (const row of result.rows) {
|
16
|
-
document.querySelector("ul").appendChild(document.createElement("li")).innerText = JSON.stringify(row.doc);
|
17
|
-
}
|
18
|
-
};
|
19
|
-
|
20
|
-
async function initialize() {
|
21
|
-
console.log("initialize");
|
22
|
-
db.subscribe(draw);
|
23
|
-
draw();
|
24
|
-
}
|
25
|
-
|
26
|
-
async function onButtonClick(e) {
|
27
|
-
e.preventDefault();
|
28
|
-
console.log("put");
|
29
|
-
const ok = await db.put({ sort: Math.random(), test: "test" });
|
30
|
-
console.log("ok", ok.id);
|
31
|
-
}
|
32
|
-
window.onButtonClick = onButtonClick;
|
33
|
-
window.onload = initialize;
|
34
|
-
}
|
35
|
-
testApp();
|
36
|
-
</script>
|
37
|
-
</head>
|
38
|
-
<body>
|
39
|
-
<button onclick="onButtonClick(event)">Click to Run</button>
|
40
|
-
<ul></ul>
|
41
|
-
</body>
|
42
|
-
</html>
|