@fireproof/core 0.20.0-dev-preview-63 → 0.20.1-dev-preview-01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno/index.d.ts +7 -0
- package/deno/index.js +66 -0
- package/deno/index.js.map +1 -0
- package/deno/metafile-esm.json +1 -0
- package/deno.json +2 -2
- package/index.cjs +7268 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +2742 -0
- package/index.d.ts +2742 -15
- package/index.js +7267 -14
- package/index.js.map +1 -1
- package/indexeddb/index.cjs +218 -0
- package/indexeddb/index.cjs.map +1 -0
- package/indexeddb/index.d.cts +30 -0
- package/indexeddb/index.d.ts +30 -0
- package/indexeddb/index.js +195 -0
- package/indexeddb/index.js.map +1 -0
- package/indexeddb/metafile-cjs.json +1 -0
- package/indexeddb/metafile-esm.json +1 -0
- package/metafile-cjs.json +1 -0
- package/metafile-esm.json +1 -0
- package/node/index.cjs +97 -0
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +7 -0
- package/node/index.d.ts +7 -0
- package/node/index.js +64 -0
- package/node/index.js.map +1 -0
- package/node/metafile-cjs.json +1 -0
- package/node/metafile-esm.json +1 -0
- package/package.json +17 -20
- package/react/index.cjs +298 -0
- package/react/index.cjs.map +1 -0
- package/react/{img-file.d.ts → index.d.cts} +53 -6
- package/react/index.d.ts +336 -4
- package/react/index.js +264 -3
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -0
- package/react/metafile-esm.json +1 -0
- package/tests/blockstore/loader.test.ts +1 -1
- package/tests/blockstore/store.test.ts +4 -9
- package/tests/fireproof/attachable.test.ts +3 -3
- package/tests/react/use-fireproof-db-switch.test.tsx +91 -0
- package/tests/react/use-fireproof-stability.test.tsx +145 -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 +254 -0
- package/apply-head-queue.d.ts +0 -18
- package/apply-head-queue.d.ts.map +0 -1
- package/apply-head-queue.js +0 -47
- package/apply-head-queue.js.map +0 -1
- package/blockstore/attachable-store.d.ts +0 -17
- package/blockstore/attachable-store.d.ts.map +0 -1
- package/blockstore/attachable-store.js +0 -295
- package/blockstore/attachable-store.js.map +0 -1
- package/blockstore/commit-queue.d.ts +0 -12
- package/blockstore/commit-queue.d.ts.map +0 -1
- package/blockstore/commit-queue.js +0 -52
- package/blockstore/commit-queue.js.map +0 -1
- package/blockstore/commitor.d.ts +0 -21
- package/blockstore/commitor.d.ts.map +0 -1
- package/blockstore/commitor.js +0 -104
- package/blockstore/commitor.js.map +0 -1
- package/blockstore/connect-raw.d.ts +0 -2
- package/blockstore/connect-raw.d.ts.map +0 -1
- package/blockstore/connect-raw.js +0 -2
- package/blockstore/connect-raw.js.map +0 -1
- package/blockstore/connection-base.d.ts +0 -2
- package/blockstore/connection-base.d.ts.map +0 -1
- package/blockstore/connection-base.js +0 -2
- package/blockstore/connection-base.js.map +0 -1
- package/blockstore/encrypt-helpers.d.ts +0 -2
- package/blockstore/encrypt-helpers.d.ts.map +0 -1
- package/blockstore/encrypt-helpers.js +0 -2
- package/blockstore/encrypt-helpers.js.map +0 -1
- package/blockstore/fp-envelope.d.ts +0 -32
- package/blockstore/fp-envelope.d.ts.map +0 -1
- package/blockstore/fp-envelope.js +0 -14
- package/blockstore/fp-envelope.js.map +0 -1
- package/blockstore/gateway.d.ts +0 -20
- package/blockstore/gateway.d.ts.map +0 -1
- package/blockstore/gateway.js +0 -2
- package/blockstore/gateway.js.map +0 -1
- package/blockstore/index.d.ts +0 -16
- package/blockstore/index.d.ts.map +0 -1
- package/blockstore/index.js +0 -16
- package/blockstore/index.js.map +0 -1
- package/blockstore/interceptor-gateway.d.ts +0 -29
- package/blockstore/interceptor-gateway.d.ts.map +0 -1
- package/blockstore/interceptor-gateway.js +0 -137
- package/blockstore/interceptor-gateway.js.map +0 -1
- package/blockstore/loader-helpers.d.ts +0 -4
- package/blockstore/loader-helpers.d.ts.map +0 -1
- package/blockstore/loader-helpers.js +0 -16
- package/blockstore/loader-helpers.js.map +0 -1
- package/blockstore/loader.d.ts +0 -45
- package/blockstore/loader.d.ts.map +0 -1
- package/blockstore/loader.js +0 -352
- package/blockstore/loader.js.map +0 -1
- package/blockstore/register-store-protocol.d.ts +0 -22
- package/blockstore/register-store-protocol.d.ts.map +0 -1
- package/blockstore/register-store-protocol.js +0 -114
- package/blockstore/register-store-protocol.js.map +0 -1
- package/blockstore/serde-gateway.d.ts +0 -78
- package/blockstore/serde-gateway.d.ts.map +0 -1
- package/blockstore/serde-gateway.js +0 -2
- package/blockstore/serde-gateway.js.map +0 -1
- package/blockstore/store-factory.d.ts +0 -11
- package/blockstore/store-factory.d.ts.map +0 -1
- package/blockstore/store-factory.js +0 -105
- package/blockstore/store-factory.js.map +0 -1
- package/blockstore/store-remote.d.ts +0 -2
- package/blockstore/store-remote.d.ts.map +0 -1
- package/blockstore/store-remote.js +0 -2
- package/blockstore/store-remote.js.map +0 -1
- package/blockstore/store.d.ts +0 -82
- package/blockstore/store.d.ts.map +0 -1
- package/blockstore/store.js +0 -438
- package/blockstore/store.js.map +0 -1
- package/blockstore/task-manager.d.ts +0 -19
- package/blockstore/task-manager.d.ts.map +0 -1
- package/blockstore/task-manager.js +0 -50
- package/blockstore/task-manager.js.map +0 -1
- package/blockstore/transaction.d.ts +0 -64
- package/blockstore/transaction.d.ts.map +0 -1
- package/blockstore/transaction.js +0 -249
- package/blockstore/transaction.js.map +0 -1
- package/blockstore/types.d.ts +0 -400
- package/blockstore/types.d.ts.map +0 -1
- package/blockstore/types.js +0 -55
- package/blockstore/types.js.map +0 -1
- package/blockstore/uri-interceptor.d.ts +0 -19
- package/blockstore/uri-interceptor.d.ts.map +0 -1
- package/blockstore/uri-interceptor.js +0 -61
- package/blockstore/uri-interceptor.js.map +0 -1
- package/bundle-not-impl.d.ts +0 -2
- package/bundle-not-impl.d.ts.map +0 -1
- package/bundle-not-impl.js +0 -4
- package/bundle-not-impl.js.map +0 -1
- package/cli/main.js +0 -26114
- package/context.d.ts +0 -7
- package/context.d.ts.map +0 -1
- package/context.js +0 -15
- package/context.js.map +0 -1
- package/crdt-clock.d.ts +0 -27
- package/crdt-clock.d.ts.map +0 -1
- package/crdt-clock.js +0 -140
- package/crdt-clock.js.map +0 -1
- package/crdt-helpers.d.ts +0 -16
- package/crdt-helpers.d.ts.map +0 -1
- package/crdt-helpers.js +0 -316
- package/crdt-helpers.js.map +0 -1
- package/crdt.d.ts +0 -34
- package/crdt.d.ts.map +0 -1
- package/crdt.js +0 -131
- package/crdt.js.map +0 -1
- package/database.d.ts +0 -34
- package/database.d.ts.map +0 -1
- package/database.js +0 -121
- package/database.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/indexer-helpers.d.ts +0 -69
- package/indexer-helpers.d.ts.map +0 -1
- package/indexer-helpers.js +0 -135
- package/indexer-helpers.js.map +0 -1
- package/indexer.d.ts +0 -25
- package/indexer.d.ts.map +0 -1
- package/indexer.js +0 -231
- package/indexer.js.map +0 -1
- package/ledger.d.ts +0 -56
- package/ledger.d.ts.map +0 -1
- package/ledger.js +0 -224
- package/ledger.js.map +0 -1
- package/protocols/cloud/http-connection.d.ts +0 -25
- package/protocols/cloud/http-connection.d.ts.map +0 -1
- package/protocols/cloud/http-connection.js +0 -153
- package/protocols/cloud/http-connection.js.map +0 -1
- package/protocols/cloud/index.d.ts +0 -10
- package/protocols/cloud/index.d.ts.map +0 -1
- package/protocols/cloud/index.js +0 -10
- package/protocols/cloud/index.js.map +0 -1
- package/protocols/cloud/msg-raw-connection-base.d.ts +0 -16
- package/protocols/cloud/msg-raw-connection-base.d.ts.map +0 -1
- package/protocols/cloud/msg-raw-connection-base.js +0 -22
- package/protocols/cloud/msg-raw-connection-base.js.map +0 -1
- package/protocols/cloud/msg-types-data.d.ts +0 -36
- package/protocols/cloud/msg-types-data.d.ts.map +0 -1
- package/protocols/cloud/msg-types-data.js +0 -38
- package/protocols/cloud/msg-types-data.js.map +0 -1
- package/protocols/cloud/msg-types-meta.d.ts +0 -41
- package/protocols/cloud/msg-types-meta.d.ts.map +0 -1
- package/protocols/cloud/msg-types-meta.js +0 -98
- package/protocols/cloud/msg-types-meta.js.map +0 -1
- package/protocols/cloud/msg-types-wal.d.ts +0 -33
- package/protocols/cloud/msg-types-wal.d.ts.map +0 -1
- package/protocols/cloud/msg-types-wal.js +0 -38
- package/protocols/cloud/msg-types-wal.js.map +0 -1
- package/protocols/cloud/msg-types.d.ts +0 -279
- package/protocols/cloud/msg-types.d.ts.map +0 -1
- package/protocols/cloud/msg-types.js +0 -278
- package/protocols/cloud/msg-types.js.map +0 -1
- package/protocols/cloud/msger.d.ts +0 -79
- package/protocols/cloud/msger.d.ts.map +0 -1
- package/protocols/cloud/msger.js +0 -198
- package/protocols/cloud/msger.js.map +0 -1
- package/protocols/cloud/ws-connection.d.ts +0 -29
- package/protocols/cloud/ws-connection.d.ts.map +0 -1
- package/protocols/cloud/ws-connection.js +0 -163
- package/protocols/cloud/ws-connection.js.map +0 -1
- package/protocols/index.d.ts +0 -2
- package/protocols/index.d.ts.map +0 -1
- package/protocols/index.js +0 -2
- package/protocols/index.js.map +0 -1
- package/react/img-file.d.ts.map +0 -1
- package/react/img-file.js +0 -58
- package/react/img-file.js.map +0 -1
- package/react/index.d.ts.map +0 -1
- package/react/types.d.ts +0 -43
- package/react/types.d.ts.map +0 -1
- package/react/types.js +0 -2
- package/react/types.js.map +0 -1
- package/react/use-all-docs.d.ts +0 -4
- package/react/use-all-docs.d.ts.map +0 -1
- package/react/use-all-docs.js +0 -19
- package/react/use-all-docs.js.map +0 -1
- package/react/use-changes.d.ts +0 -4
- package/react/use-changes.d.ts.map +0 -1
- package/react/use-changes.js +0 -19
- package/react/use-changes.js.map +0 -1
- package/react/use-document.d.ts +0 -4
- package/react/use-document.d.ts.map +0 -1
- package/react/use-document.js +0 -99
- package/react/use-document.js.map +0 -1
- package/react/use-fireproof.d.ts +0 -6
- package/react/use-fireproof.d.ts.map +0 -1
- package/react/use-fireproof.js +0 -15
- package/react/use-fireproof.js.map +0 -1
- package/react/use-live-query.d.ts +0 -4
- package/react/use-live-query.d.ts.map +0 -1
- package/react/use-live-query.js +0 -38
- package/react/use-live-query.js.map +0 -1
- package/react/utils.d.ts +0 -2
- package/react/utils.d.ts.map +0 -1
- package/react/utils.js +0 -4
- package/react/utils.js.map +0 -1
- package/runtime/files.d.ts +0 -12
- package/runtime/files.d.ts.map +0 -1
- package/runtime/files.js +0 -29
- package/runtime/files.js.map +0 -1
- package/runtime/gateways/cloud/gateway.d.ts +0 -44
- package/runtime/gateways/cloud/gateway.d.ts.map +0 -1
- package/runtime/gateways/cloud/gateway.js +0 -496
- package/runtime/gateways/cloud/gateway.js.map +0 -1
- package/runtime/gateways/def-serde-gateway.d.ts +0 -19
- package/runtime/gateways/def-serde-gateway.d.ts.map +0 -1
- package/runtime/gateways/def-serde-gateway.js +0 -73
- package/runtime/gateways/def-serde-gateway.js.map +0 -1
- package/runtime/gateways/file/deno/deno-filesystem.d.ts +0 -27
- package/runtime/gateways/file/deno/deno-filesystem.d.ts.map +0 -1
- package/runtime/gateways/file/deno/deno-filesystem.js +0 -51
- package/runtime/gateways/file/deno/deno-filesystem.js.map +0 -1
- package/runtime/gateways/file/deno/get-sys-file-system.d.ts +0 -4
- package/runtime/gateways/file/deno/get-sys-file-system.d.ts.map +0 -1
- package/runtime/gateways/file/deno/get-sys-file-system.js +0 -11
- package/runtime/gateways/file/deno/get-sys-file-system.js.map +0 -1
- package/runtime/gateways/file/deno/index.d.ts +0 -2
- package/runtime/gateways/file/deno/index.d.ts.map +0 -1
- package/runtime/gateways/file/deno/index.js +0 -2
- package/runtime/gateways/file/deno/index.js.map +0 -1
- package/runtime/gateways/file/gateway-impl.d.ts +0 -18
- package/runtime/gateways/file/gateway-impl.d.ts.map +0 -1
- package/runtime/gateways/file/gateway-impl.js +0 -121
- package/runtime/gateways/file/gateway-impl.js.map +0 -1
- package/runtime/gateways/file/index.d.ts +0 -3
- package/runtime/gateways/file/index.d.ts.map +0 -1
- package/runtime/gateways/file/index.js +0 -3
- package/runtime/gateways/file/index.js.map +0 -1
- package/runtime/gateways/file/key-bag-file.d.ts +0 -19
- package/runtime/gateways/file/key-bag-file.d.ts.map +0 -1
- package/runtime/gateways/file/key-bag-file.js +0 -40
- package/runtime/gateways/file/key-bag-file.js.map +0 -1
- package/runtime/gateways/file/node/get-sys-file-system.d.ts +0 -4
- package/runtime/gateways/file/node/get-sys-file-system.d.ts.map +0 -1
- package/runtime/gateways/file/node/get-sys-file-system.js +0 -11
- package/runtime/gateways/file/node/get-sys-file-system.js.map +0 -1
- package/runtime/gateways/file/node/index.d.ts +0 -2
- package/runtime/gateways/file/node/index.d.ts.map +0 -1
- package/runtime/gateways/file/node/index.js +0 -2
- package/runtime/gateways/file/node/index.js.map +0 -1
- package/runtime/gateways/file/node/node-filesystem.d.ts +0 -32
- package/runtime/gateways/file/node/node-filesystem.d.ts.map +0 -1
- package/runtime/gateways/file/node/node-filesystem.js +0 -37
- package/runtime/gateways/file/node/node-filesystem.js.map +0 -1
- package/runtime/gateways/file/node/to-array-buffer.d.ts +0 -2
- package/runtime/gateways/file/node/to-array-buffer.d.ts.map +0 -1
- package/runtime/gateways/file/node/to-array-buffer.js +0 -12
- package/runtime/gateways/file/node/to-array-buffer.js.map +0 -1
- package/runtime/gateways/file/sys-file-system-factory.d.ts +0 -4
- package/runtime/gateways/file/sys-file-system-factory.d.ts.map +0 -1
- package/runtime/gateways/file/sys-file-system-factory.js +0 -13
- package/runtime/gateways/file/sys-file-system-factory.js.map +0 -1
- package/runtime/gateways/file/utils.d.ts +0 -5
- package/runtime/gateways/file/utils.d.ts.map +0 -1
- package/runtime/gateways/file/utils.js +0 -27
- package/runtime/gateways/file/utils.js.map +0 -1
- package/runtime/gateways/file/version.d.ts +0 -2
- package/runtime/gateways/file/version.d.ts.map +0 -1
- package/runtime/gateways/file/version.js +0 -2
- package/runtime/gateways/file/version.js.map +0 -1
- package/runtime/gateways/fp-envelope-serialize.d.ts +0 -50
- package/runtime/gateways/fp-envelope-serialize.d.ts.map +0 -1
- package/runtime/gateways/fp-envelope-serialize.js +0 -141
- package/runtime/gateways/fp-envelope-serialize.js.map +0 -1
- package/runtime/gateways/index.d.ts +0 -6
- package/runtime/gateways/index.d.ts.map +0 -1
- package/runtime/gateways/index.js +0 -6
- package/runtime/gateways/index.js.map +0 -1
- package/runtime/gateways/indexeddb/gateway-impl.d.ts +0 -22
- package/runtime/gateways/indexeddb/gateway-impl.d.ts.map +0 -1
- package/runtime/gateways/indexeddb/gateway-impl.js +0 -147
- package/runtime/gateways/indexeddb/gateway-impl.js.map +0 -1
- package/runtime/gateways/indexeddb/index.d.ts +0 -6
- package/runtime/gateways/indexeddb/index.d.ts.map +0 -1
- package/runtime/gateways/indexeddb/index.js +0 -6
- package/runtime/gateways/indexeddb/index.js.map +0 -1
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts +0 -15
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts.map +0 -1
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js +0 -42
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js.map +0 -1
- package/runtime/gateways/indexeddb-version.d.ts +0 -2
- package/runtime/gateways/indexeddb-version.d.ts.map +0 -1
- package/runtime/gateways/indexeddb-version.js +0 -2
- package/runtime/gateways/indexeddb-version.js.map +0 -1
- package/runtime/gateways/memory/gateway.d.ts +0 -18
- package/runtime/gateways/memory/gateway.d.ts.map +0 -1
- package/runtime/gateways/memory/gateway.js +0 -58
- package/runtime/gateways/memory/gateway.js.map +0 -1
- package/runtime/gateways/memory/version.d.ts +0 -2
- package/runtime/gateways/memory/version.d.ts.map +0 -1
- package/runtime/gateways/memory/version.js +0 -2
- package/runtime/gateways/memory/version.js.map +0 -1
- package/runtime/index.d.ts +0 -13
- package/runtime/index.d.ts.map +0 -1
- package/runtime/index.js +0 -13
- package/runtime/index.js.map +0 -1
- package/runtime/key-bag-memory.d.ts +0 -12
- package/runtime/key-bag-memory.d.ts.map +0 -1
- package/runtime/key-bag-memory.js +0 -23
- package/runtime/key-bag-memory.js.map +0 -1
- package/runtime/key-bag.d.ts +0 -85
- package/runtime/key-bag.d.ts.map +0 -1
- package/runtime/key-bag.js +0 -415
- package/runtime/key-bag.js.map +0 -1
- package/runtime/keyed-crypto.d.ts +0 -19
- package/runtime/keyed-crypto.d.ts.map +0 -1
- package/runtime/keyed-crypto.js +0 -192
- package/runtime/keyed-crypto.js.map +0 -1
- package/runtime/memory-sys-container.d.ts +0 -2
- package/runtime/memory-sys-container.d.ts.map +0 -1
- package/runtime/memory-sys-container.js +0 -2
- package/runtime/memory-sys-container.js.map +0 -1
- package/runtime/meta-key-hack.d.ts +0 -42
- package/runtime/meta-key-hack.d.ts.map +0 -1
- package/runtime/meta-key-hack.js +0 -201
- package/runtime/meta-key-hack.js.map +0 -1
- package/runtime/sts-service/index.d.ts +0 -40
- package/runtime/sts-service/index.d.ts.map +0 -1
- package/runtime/sts-service/index.js +0 -102
- package/runtime/sts-service/index.js.map +0 -1
- package/runtime/sys-container.d.ts +0 -2
- package/runtime/sys-container.d.ts.map +0 -1
- package/runtime/sys-container.js +0 -2
- package/runtime/sys-container.js.map +0 -1
- package/runtime/wait-pr-multiformats/block.d.ts +0 -47
- package/runtime/wait-pr-multiformats/block.d.ts.map +0 -1
- package/runtime/wait-pr-multiformats/block.js +0 -64
- package/runtime/wait-pr-multiformats/block.js.map +0 -1
- package/runtime/wait-pr-multiformats/codec-interface.d.ts +0 -29
- package/runtime/wait-pr-multiformats/codec-interface.d.ts.map +0 -1
- package/runtime/wait-pr-multiformats/codec-interface.js +0 -2
- package/runtime/wait-pr-multiformats/codec-interface.js.map +0 -1
- package/runtime/wait-pr-multiformats/index.d.ts +0 -3
- package/runtime/wait-pr-multiformats/index.d.ts.map +0 -1
- package/runtime/wait-pr-multiformats/index.js +0 -3
- package/runtime/wait-pr-multiformats/index.js.map +0 -1
- package/types.d.ts +0 -427
- package/types.d.ts.map +0 -1
- package/types.js +0 -54
- package/types.js.map +0 -1
- package/use-fireproof/index.d.ts +0 -3
- package/use-fireproof/index.d.ts.map +0 -1
- package/use-fireproof/index.js +0 -3
- package/use-fireproof/index.js.map +0 -1
- package/utils.d.ts +0 -36
- package/utils.d.ts.map +0 -1
- package/utils.js +0 -379
- package/utils.js.map +0 -1
- package/version.d.ts +0 -2
- package/version.d.ts.map +0 -1
- package/version.js +0 -4
- package/version.js.map +0 -1
- package/write-queue.d.ts +0 -9
- package/write-queue.d.ts.map +0 -1
- package/write-queue.js +0 -70
- package/write-queue.js.map +0 -1
package/react/use-changes.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
2
|
-
export function createUseChanges(database) {
|
3
|
-
return function useChanges(since = [], opts = {}) {
|
4
|
-
const [result, setResult] = useState({
|
5
|
-
docs: [],
|
6
|
-
});
|
7
|
-
const queryString = useMemo(() => JSON.stringify(opts), [opts]);
|
8
|
-
const refreshRows = useCallback(async () => {
|
9
|
-
const res = await database.changes(since, opts);
|
10
|
-
setResult({ ...res, docs: res.rows.map((r) => r.value) });
|
11
|
-
}, [since, queryString]);
|
12
|
-
useEffect(() => {
|
13
|
-
refreshRows();
|
14
|
-
return database.subscribe(refreshRows);
|
15
|
-
}, [refreshRows]);
|
16
|
-
return result;
|
17
|
-
};
|
18
|
-
}
|
19
|
-
//# sourceMappingURL=use-changes.js.map
|
package/react/use-changes.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-changes.js","sourceRoot":"","sources":["../../../../src/react/use-changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAOlE,MAAM,UAAU,gBAAgB,CAAC,QAAkB;IACjD,OAAO,SAAS,UAAU,CAAqB,QAAmB,EAAE,EAAE,OAAuB,EAAE;QAC7F,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAmB;YACrD,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAEhE,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;YACzC,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,CAAC,CAAC;YACnD,SAAS,CAAC,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAqB,CAAC,EAAE,CAAC,CAAC;QAC5E,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;QAEzB,SAAS,CAAC,GAAG,EAAE;YACb,WAAW,EAAE,CAAC;YACd,OAAO,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;QAElB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
package/react/use-document.d.ts
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
import type { DocTypes, Database } from "@fireproof/core";
|
2
|
-
import type { UseDocumentInitialDocOrFn, UseDocumentResult } from "./types.js";
|
3
|
-
export declare function createUseDocument(database: Database): <T extends DocTypes>(initialDocOrFn?: UseDocumentInitialDocOrFn<T>) => UseDocumentResult<T>;
|
4
|
-
//# sourceMappingURL=use-document.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-document.d.ts","sourceRoot":"","sources":["../../../../src/react/use-document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,QAAQ,EAAa,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,KAAK,EAA2B,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKxG,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,IAGtB,CAAC,SAAS,QAAQ,EAAE,iBAAiB,yBAAyB,CAAC,CAAC,CAAC,KAAG,iBAAiB,CAAC,CAAC,CAAC,CAyHrH"}
|
package/react/use-document.js
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState, useRef } from "react";
|
2
|
-
import { deepClone } from "./utils.js";
|
3
|
-
export function createUseDocument(database) {
|
4
|
-
const updateHappenedRef = useRef(false);
|
5
|
-
return function useDocument(initialDocOrFn) {
|
6
|
-
let initialDoc;
|
7
|
-
if (typeof initialDocOrFn === "function") {
|
8
|
-
initialDoc = initialDocOrFn();
|
9
|
-
}
|
10
|
-
else {
|
11
|
-
initialDoc = initialDocOrFn ?? {};
|
12
|
-
}
|
13
|
-
const originalInitialDoc = useMemo(() => deepClone({ ...initialDoc }), []);
|
14
|
-
const [doc, setDoc] = useState(initialDoc);
|
15
|
-
const refresh = useCallback(async () => {
|
16
|
-
const gotDoc = doc._id ? await database.get(doc._id).catch(() => initialDoc) : initialDoc;
|
17
|
-
setDoc(gotDoc);
|
18
|
-
}, [doc._id]);
|
19
|
-
const save = useCallback(async (existingDoc) => {
|
20
|
-
updateHappenedRef.current = false;
|
21
|
-
const toSave = existingDoc ?? doc;
|
22
|
-
const res = await database.put(toSave);
|
23
|
-
if (!updateHappenedRef.current && !doc._id && !existingDoc) {
|
24
|
-
setDoc((d) => ({ ...d, _id: res.id }));
|
25
|
-
}
|
26
|
-
return res;
|
27
|
-
}, [doc]);
|
28
|
-
const remove = useCallback(async (existingDoc) => {
|
29
|
-
const id = existingDoc?._id ?? doc._id;
|
30
|
-
if (!id)
|
31
|
-
throw database.logger.Error().Msg(`Document must have an _id to be removed`).AsError();
|
32
|
-
const gotDoc = await database.get(id).catch(() => undefined);
|
33
|
-
if (!gotDoc)
|
34
|
-
throw database.logger.Error().Str("id", id).Msg(`Document not found`).AsError();
|
35
|
-
const res = await database.del(id);
|
36
|
-
setDoc(initialDoc);
|
37
|
-
return res;
|
38
|
-
}, [doc, initialDoc]);
|
39
|
-
const merge = useCallback((newDoc) => {
|
40
|
-
updateHappenedRef.current = true;
|
41
|
-
setDoc((prev) => ({ ...prev, ...newDoc }));
|
42
|
-
}, []);
|
43
|
-
const replace = useCallback((newDoc) => {
|
44
|
-
updateHappenedRef.current = true;
|
45
|
-
setDoc(newDoc);
|
46
|
-
}, []);
|
47
|
-
const reset = useCallback(() => {
|
48
|
-
updateHappenedRef.current = true;
|
49
|
-
setDoc({ ...originalInitialDoc });
|
50
|
-
}, [originalInitialDoc]);
|
51
|
-
const updateDoc = useCallback((newDoc, opts = { replace: false, reset: false }) => {
|
52
|
-
if (!newDoc) {
|
53
|
-
return opts.reset ? reset() : refresh();
|
54
|
-
}
|
55
|
-
return opts.replace ? replace(newDoc) : merge(newDoc);
|
56
|
-
}, [refresh, reset, replace, merge]);
|
57
|
-
useEffect(() => {
|
58
|
-
if (!doc._id)
|
59
|
-
return;
|
60
|
-
return database.subscribe((changes) => {
|
61
|
-
if (updateHappenedRef.current) {
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
if (changes.find((c) => c._id === doc._id)) {
|
65
|
-
void refresh();
|
66
|
-
}
|
67
|
-
}, true);
|
68
|
-
}, [doc._id, refresh]);
|
69
|
-
useEffect(() => {
|
70
|
-
void refresh();
|
71
|
-
}, [refresh]);
|
72
|
-
const submit = useCallback(async (e) => {
|
73
|
-
if (e?.preventDefault)
|
74
|
-
e.preventDefault();
|
75
|
-
await save();
|
76
|
-
reset();
|
77
|
-
}, [save, reset]);
|
78
|
-
const apiObject = {
|
79
|
-
doc: { ...doc },
|
80
|
-
merge,
|
81
|
-
replace,
|
82
|
-
reset,
|
83
|
-
refresh,
|
84
|
-
save,
|
85
|
-
remove,
|
86
|
-
submit,
|
87
|
-
};
|
88
|
-
const tuple = [{ ...doc }, updateDoc, save, remove, reset, refresh];
|
89
|
-
Object.assign(apiObject, tuple);
|
90
|
-
Object.defineProperty(apiObject, Symbol.iterator, {
|
91
|
-
enumerable: false,
|
92
|
-
value: function* () {
|
93
|
-
yield* tuple;
|
94
|
-
},
|
95
|
-
});
|
96
|
-
return apiObject;
|
97
|
-
};
|
98
|
-
}
|
99
|
-
//# sourceMappingURL=use-document.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-document.js","sourceRoot":"","sources":["../../../../src/react/use-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMvC,MAAM,UAAU,iBAAiB,CAAC,QAAkB;IAClD,MAAM,iBAAiB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAExC,OAAO,SAAS,WAAW,CAAqB,cAA6C;QAC3F,IAAI,UAAqB,CAAC;QAC1B,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;YACzC,UAAU,GAAG,cAAc,EAAE,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,cAAc,IAAK,EAAQ,CAAC;QAC3C,CAAC;QAED,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAE3E,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;QAE3C,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;YACrC,MAAM,MAAM,GAAG,GAAG,CAAC,G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AAK,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE;YAChD,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,QAAQ,CAAC;gBACd,KAAK,CAAC,CAAC,KAAK,CAAC;YACf,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,SAAiC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC"}
|
package/react/use-fireproof.d.ts
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
import type { ConfigOpts, Database } from "@fireproof/core";
|
2
|
-
import type { UseFireproof } from "./types.js";
|
3
|
-
export declare const FireproofCtx: UseFireproof;
|
4
|
-
export declare function useFireproof(name?: string | Database, config?: ConfigOpts): UseFireproof;
|
5
|
-
export type { LiveQueryResult, UseDocumentResult, AllDocsResult, ChangesResult, UseDocument, UseLiveQuery, UseAllDocs, UseChanges, UseFireproof, } from "./types.js";
|
6
|
-
//# sourceMappingURL=use-fireproof.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-fireproof.d.ts","sourceRoot":"","sources":["../../../../src/react/use-fireproof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS/C,eAAO,MAAM,YAAY,EAAS,YAAY,CAAC;AA0B/C,wBAAgB,YAAY,CAAC,IAAI,GAAE,MAAM,GAAG,QAAyB,EAAE,MAAM,GAAE,UAAe,GAAG,YAAY,CAS5G;AAGD,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC"}
|
package/react/use-fireproof.js
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import { fireproof } from "@fireproof/core";
|
2
|
-
import { createUseDocument } from "./use-document.js";
|
3
|
-
import { createUseLiveQuery } from "./use-live-query.js";
|
4
|
-
import { createUseAllDocs } from "./use-all-docs.js";
|
5
|
-
import { createUseChanges } from "./use-changes.js";
|
6
|
-
export const FireproofCtx = {};
|
7
|
-
export function useFireproof(name = "useFireproof", config = {}) {
|
8
|
-
const database = typeof name === "string" ? fireproof(name, config) : name;
|
9
|
-
const useDocument = createUseDocument(database);
|
10
|
-
const useLiveQuery = createUseLiveQuery(database);
|
11
|
-
const useAllDocs = createUseAllDocs(database);
|
12
|
-
const useChanges = createUseChanges(database);
|
13
|
-
return { database, useLiveQuery, useDocument, useAllDocs, useChanges };
|
14
|
-
}
|
15
|
-
//# sourceMappingURL=use-fireproof.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-fireproof.js","sourceRoot":"","sources":["../../../../src/react/use-fireproof.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAKpD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAkB,CAAC;AA0B/C,MAAM,UAAU,YAAY,CAAC,OAA0B,cAAc,EAAE,SAAqB,EAAE;IAC5F,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3E,MAAM,WAAW,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AACzE,CAAC"}
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import type { DocFragment, DocTypes, IndexKeyType, IndexRow, MapFn, Database } from "@fireproof/core";
|
2
|
-
import type { LiveQueryResult } from "./types.js";
|
3
|
-
export declare function createUseLiveQuery(database: Database): <T extends DocTypes, K extends IndexKeyType = string, R extends DocFragment = T>(mapFn: MapFn<T> | string, query?: {}, initialRows?: IndexRow<K, T, R>[]) => LiveQueryResult<T, K, R>;
|
4
|
-
//# sourceMappingURL=use-live-query.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-live-query.d.ts","sourceRoot":"","sources":["../../../../src/react/use-live-query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAa,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACjH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,IACtB,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,YAAY,GAAG,MAAM,EAAE,CAAC,SAAS,WAAW,GAAG,CAAC,EACzG,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,EACxB,UAAU,EACV,cAAa,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAO,KACpC,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAsC5B"}
|
package/react/use-live-query.js
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
2
|
-
export function createUseLiveQuery(database) {
|
3
|
-
return function useLiveQuery(mapFn, query = {}, initialRows = []) {
|
4
|
-
const [result, setResult] = useState(() => {
|
5
|
-
const docs = initialRows.map((r) => r.doc).filter((r) => !!r);
|
6
|
-
return {
|
7
|
-
rows: initialRows,
|
8
|
-
docs,
|
9
|
-
length: docs.length,
|
10
|
-
map: (fn) => docs.map(fn),
|
11
|
-
filter: (fn) => docs.filter(fn),
|
12
|
-
forEach: (fn) => docs.forEach(fn),
|
13
|
-
[Symbol.iterator]: () => docs[Symbol.iterator](),
|
14
|
-
};
|
15
|
-
});
|
16
|
-
const queryString = useMemo(() => JSON.stringify(query), [query]);
|
17
|
-
const mapFnString = useMemo(() => mapFn.toString(), [mapFn]);
|
18
|
-
const refreshRows = useCallback(async () => {
|
19
|
-
const res = await database.query(mapFn, query);
|
20
|
-
const docs = res.rows.map((r) => r.doc).filter((r) => !!r);
|
21
|
-
setResult({
|
22
|
-
...res,
|
23
|
-
docs,
|
24
|
-
length: docs.length,
|
25
|
-
map: (fn) => docs.map(fn),
|
26
|
-
filter: (fn) => docs.filter(fn),
|
27
|
-
forEach: (fn) => docs.forEach(fn),
|
28
|
-
[Symbol.iterator]: () => docs[Symbol.iterator](),
|
29
|
-
});
|
30
|
-
}, [mapFnString, queryString]);
|
31
|
-
useEffect(() => {
|
32
|
-
refreshRows();
|
33
|
-
return database.subscribe(refreshRows);
|
34
|
-
}, [refreshRows]);
|
35
|
-
return result;
|
36
|
-
};
|
37
|
-
}
|
38
|
-
//# sourceMappingURL=use-live-query.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"use-live-query.js","sourceRoot":"","sources":["../../../../src/react/use-live-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OA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AM,QAAQ,CAAC,KAAK,CAAU,KAAK,EAAE,KAAK,CAAC,CAAC;YACxD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAmB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAqB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9F,SAAS,CAAC;gBACR,GAAG,GAAG;gBACN,IAAI;gBACJ,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,GAAG,EAAE,CAAI,EAAoE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9F,MAAM,EAAE,CAAC,EAA0E,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACvG,OAAO,EAAE,CAAC,EAAuE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBACtG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;aACrB,CAAC,CAAC;QACjC,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;QAE/B,SAAS,CAAC,GAAG,EAAE;YACb,WAAW,EAAE,CAAC;YACd,OAAO,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;QAElB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
package/react/utils.d.ts
DELETED
package/react/utils.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/react/utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAExC"}
|
package/react/utils.js
DELETED
package/react/utils.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/react/utils.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,SAAS,CAAI,KAAQ;IACnC,OAAO,CAAC,eAAe,IAAI,CAAC,CAAC,CAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC/E,CAAC"}
|
package/runtime/files.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import { DocFileMeta } from "../types.js";
|
2
|
-
import { AnyLink, AnyBlock } from "../blockstore/index.js";
|
3
|
-
import { Result } from "@adviser/cement";
|
4
|
-
export declare function encodeFile(blob: Blob): Promise<{
|
5
|
-
cid: AnyLink;
|
6
|
-
blocks: AnyBlock[];
|
7
|
-
}>;
|
8
|
-
export interface BlockGetter {
|
9
|
-
get(cid: AnyLink): Promise<Uint8Array>;
|
10
|
-
}
|
11
|
-
export declare function decodeFile(blocks: unknown, cid: AnyLink, meta: DocFileMeta): Promise<Result<File>>;
|
12
|
-
//# sourceMappingURL=files.d.ts.map
|
package/runtime/files.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../src/runtime/files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAoB,MAAM,EAAa,MAAM,iBAAiB,CAAC;AAKtE,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,CAe1F;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACxC;AAUD,wBAAsB,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAkBxG"}
|
package/runtime/files.js
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
import * as raw from "multiformats/codecs/raw";
|
2
|
-
import { CID } from "multiformats/cid";
|
3
|
-
import { sha256 as hasher } from "multiformats/hashes/sha2";
|
4
|
-
import { exception2Result, Result, top_uint8 } from "@adviser/cement";
|
5
|
-
export async function encodeFile(blob) {
|
6
|
-
const data = await top_uint8(blob);
|
7
|
-
const bytes = raw.encode(data);
|
8
|
-
const hash = await hasher.digest(bytes);
|
9
|
-
const cid = CID.create(1, raw.code, hash);
|
10
|
-
const block = { cid, bytes };
|
11
|
-
return { cid, blocks: [block] };
|
12
|
-
}
|
13
|
-
function isHasBlockAGet(obj) {
|
14
|
-
return typeof obj.get === "function";
|
15
|
-
}
|
16
|
-
export async function decodeFile(blocks, cid, meta) {
|
17
|
-
if (!isHasBlockAGet(blocks)) {
|
18
|
-
return Result.Err(new Error("Invalid block storage"));
|
19
|
-
}
|
20
|
-
return exception2Result(async () => {
|
21
|
-
const bytes = await blocks.get(cid);
|
22
|
-
const data = raw.decode(bytes);
|
23
|
-
return new File([data], "file", {
|
24
|
-
type: meta.type,
|
25
|
-
lastModified: meta.lastModified || 0,
|
26
|
-
});
|
27
|
-
});
|
28
|
-
}
|
29
|
-
//# sourceMappingURL=files.js.map
|
package/runtime/files.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../../src/runtime/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAG/C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CA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AAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,CAAC;SACrC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import { Result, URI, Logger, MatchResult, ResolveOnce, CoerceURI } from "@adviser/cement";
|
2
|
-
import type { Attachable, SuperThis } from "../../../types.js";
|
3
|
-
import { MsgConnected, MsgConnectedAuth } from "../../../protocols/cloud/msger.js";
|
4
|
-
import { SerdeGateway, SerdeGatewayCtx, SerdeGetResult, UnsubscribeResult, VoidResult } from "../../../blockstore/serde-gateway.js";
|
5
|
-
import { FPEnvelope, FPEnvelopeMeta } from "../../../blockstore/fp-envelope.js";
|
6
|
-
type ConnectedSerdeGatewayCtx = SerdeGatewayCtx & {
|
7
|
-
conn: AuthedConnection;
|
8
|
-
};
|
9
|
-
export interface StoreTypeGateway {
|
10
|
-
get: <S>(ctx: ConnectedSerdeGatewayCtx, url: URI) => Promise<SerdeGetResult<S>>;
|
11
|
-
put: <T>(ctx: ConnectedSerdeGatewayCtx, url: URI, body: FPEnvelope<T>) => Promise<VoidResult>;
|
12
|
-
delete: (ctx: ConnectedSerdeGatewayCtx, url: URI) => Promise<VoidResult>;
|
13
|
-
}
|
14
|
-
interface ConnectionItem {
|
15
|
-
readonly uri: URI;
|
16
|
-
readonly matchRes: MatchResult;
|
17
|
-
readonly connection: ResolveOnce<Result<MsgConnected>>;
|
18
|
-
readonly trackPuts: Set<string>;
|
19
|
-
}
|
20
|
-
interface AuthedConnection {
|
21
|
-
readonly conn: Result<MsgConnectedAuth>;
|
22
|
-
readonly citem: ConnectionItem;
|
23
|
-
}
|
24
|
-
export declare class FireproofCloudGateway implements SerdeGateway {
|
25
|
-
#private;
|
26
|
-
readonly logger: Logger;
|
27
|
-
readonly sthis: SuperThis;
|
28
|
-
constructor(sthis: SuperThis);
|
29
|
-
buildUrl(ctx: SerdeGatewayCtx, baseUrl: URI, key: string): Promise<Result<URI>>;
|
30
|
-
start(ctx: SerdeGatewayCtx, uri: URI): Promise<Result<URI>>;
|
31
|
-
get<S>(ctx: SerdeGatewayCtx, uri: URI): Promise<SerdeGetResult<S>>;
|
32
|
-
put<T>(ctx: SerdeGatewayCtx, uri: URI, body: FPEnvelope<T>): Promise<VoidResult>;
|
33
|
-
delete(ctx: SerdeGatewayCtx, uri: URI): Promise<VoidResult>;
|
34
|
-
close(ctx: SerdeGatewayCtx, uri: URI): Promise<VoidResult>;
|
35
|
-
getCloudConnection(uri: URI): Promise<Result<MsgConnectedAuth>>;
|
36
|
-
getCloudConnectionItem(uri: URI): Promise<AuthedConnection>;
|
37
|
-
subscribe(ctx: SerdeGatewayCtx, url: URI, callback: (meta: FPEnvelopeMeta) => Promise<void>): Promise<UnsubscribeResult>;
|
38
|
-
destroy(ctx: SerdeGatewayCtx, uri: URI): Promise<VoidResult>;
|
39
|
-
getPlain(): Promise<Result<Uint8Array>>;
|
40
|
-
}
|
41
|
-
export declare function registerFireproofCloudStoreProtocol(protocol?: string): () => void;
|
42
|
-
export declare function toCloud(url: CoerceURI): Attachable;
|
43
|
-
export {};
|
44
|
-
//# sourceMappingURL=gateway.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../../../../../src/runtime/gateways/cloud/gateway.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,GAAG,EAGH,MAAM,EAEN,WAAW,EACX,WAAW,EAEX,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAoB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAejF,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAA0B,MAAM,mCAAmC,CAAC;AAU3G,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEpI,OAAO,EAAE,UAAU,EAAE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