@rocicorp/zero 0.12.2025012601 → 0.12.2025012800
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/out/advanced.js +2 -2
- package/out/{chunk-F5QR3K72.js → chunk-424PT5DM.js} +1 -1
- package/out/{chunk-JZD6FXRT.js → chunk-MJYDJPXG.js} +37 -43
- package/out/{chunk-JZD6FXRT.js.map → chunk-MJYDJPXG.js.map} +3 -3
- package/out/{chunk-I5GSZARI.js → chunk-QAAJZ32T.js} +1 -1
- package/out/{chunk-I5GSZARI.js.map → chunk-QAAJZ32T.js.map} +1 -1
- package/out/datadog/src/mod.d.ts +1 -1
- package/out/react.js +1 -1
- package/out/react.js.map +1 -1
- package/out/replicache/src/btree/diff.d.ts +2 -2
- package/out/replicache/src/btree/node.d.ts +8 -8
- package/out/replicache/src/btree/read.d.ts +6 -6
- package/out/replicache/src/btree/write.d.ts +7 -7
- package/out/replicache/src/call-default-fetch.d.ts +1 -1
- package/out/replicache/src/config.d.ts +1 -1
- package/out/replicache/src/connection-loop-delegates.d.ts +2 -2
- package/out/replicache/src/connection-loop.d.ts +1 -1
- package/out/replicache/src/cookies.d.ts +2 -2
- package/out/replicache/src/dag/chunk.d.ts +1 -1
- package/out/replicache/src/dag/gc.d.ts +2 -2
- package/out/replicache/src/dag/key.d.ts +2 -2
- package/out/replicache/src/dag/lazy-store.d.ts +5 -5
- package/out/replicache/src/dag/store-impl.d.ts +5 -5
- package/out/replicache/src/dag/store.d.ts +3 -3
- package/out/replicache/src/dag/visitor.d.ts +3 -3
- package/out/replicache/src/db/commit.d.ts +8 -8
- package/out/replicache/src/db/index.d.ts +7 -7
- package/out/replicache/src/db/read.d.ts +8 -8
- package/out/replicache/src/db/rebase.d.ts +7 -7
- package/out/replicache/src/db/scan.d.ts +1 -1
- package/out/replicache/src/db/write.d.ts +14 -14
- package/out/replicache/src/filter-async-iterable.d.ts +1 -1
- package/out/replicache/src/format-version.d.ts +2 -2
- package/out/replicache/src/frozen-json.d.ts +2 -2
- package/out/replicache/src/get-default-puller.d.ts +1 -1
- package/out/replicache/src/get-default-pusher.d.ts +1 -1
- package/out/replicache/src/hash.d.ts +1 -1
- package/out/replicache/src/impl.d.ts +3 -3
- package/out/replicache/src/index-defs.d.ts +1 -1
- package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts +1 -1
- package/out/replicache/src/kv/idb-store.d.ts +1 -1
- package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
- package/out/replicache/src/kv/mem-store.d.ts +1 -1
- package/out/replicache/src/kv/read-impl.d.ts +2 -2
- package/out/replicache/src/kv/store.d.ts +1 -1
- package/out/replicache/src/kv/write-impl-base.d.ts +3 -3
- package/out/replicache/src/kv/write-impl.d.ts +3 -3
- package/out/replicache/src/merge-async-iterables.d.ts +1 -1
- package/out/replicache/src/mod.d.ts +36 -36
- package/out/replicache/src/mutation-recovery.d.ts +8 -8
- package/out/replicache/src/new-client-channel.d.ts +1 -1
- package/out/replicache/src/on-persist-channel.d.ts +1 -1
- package/out/replicache/src/patch-operation.d.ts +1 -1
- package/out/replicache/src/pending-mutations.d.ts +3 -3
- package/out/replicache/src/persist/client-gc.d.ts +3 -3
- package/out/replicache/src/persist/client-group-gc.d.ts +2 -2
- package/out/replicache/src/persist/client-groups.d.ts +5 -5
- package/out/replicache/src/persist/clients.d.ts +9 -9
- package/out/replicache/src/persist/collect-idb-databases.d.ts +3 -3
- package/out/replicache/src/persist/gather-mem-only-visitor.d.ts +4 -4
- package/out/replicache/src/persist/gather-not-cached-visitor.d.ts +5 -5
- package/out/replicache/src/persist/heartbeat.d.ts +3 -3
- package/out/replicache/src/persist/idb-databases-store.d.ts +1 -1
- package/out/replicache/src/persist/persist.d.ts +6 -6
- package/out/replicache/src/persist/refresh.d.ts +7 -7
- package/out/replicache/src/process-scheduler.d.ts +1 -1
- package/out/replicache/src/puller.d.ts +6 -6
- package/out/replicache/src/pusher.d.ts +3 -3
- package/out/replicache/src/replicache-impl.d.ts +12 -12
- package/out/replicache/src/replicache-options.d.ts +5 -5
- package/out/replicache/src/replicache.d.ts +10 -10
- package/out/replicache/src/scan-iterator.d.ts +6 -6
- package/out/replicache/src/scan-options.d.ts +2 -2
- package/out/replicache/src/subscriptions.d.ts +7 -7
- package/out/replicache/src/subscriptions.d.ts.map +1 -1
- package/out/replicache/src/sync/diff.d.ts +6 -6
- package/out/replicache/src/sync/ids.d.ts +1 -1
- package/out/replicache/src/sync/patch.d.ts +2 -2
- package/out/replicache/src/sync/pull.d.ts +11 -11
- package/out/replicache/src/sync/push.d.ts +4 -4
- package/out/replicache/src/sync/request-id.d.ts +1 -1
- package/out/replicache/src/transactions.d.ts +9 -9
- package/out/replicache/src/types.d.ts +5 -5
- package/out/shared/src/btree-set.js +1 -1
- package/out/shared/src/deep-clone.d.ts +1 -1
- package/out/shared/src/iterables.js +1 -1
- package/out/shared/src/json-schema.d.ts +1 -1
- package/out/shared/src/json-schema.js +3 -3
- package/out/shared/src/json.js +3 -3
- package/out/shared/src/options.d.ts +1 -1
- package/out/shared/src/options.js +3 -3
- package/out/shared/src/queue.js +1 -1
- package/out/shared/src/random-values.d.ts +1 -1
- package/out/shared/src/random-values.d.ts.map +1 -1
- package/out/shared/src/sleep.js +1 -1
- package/out/solid.js +3 -3
- package/out/solid.js.map +1 -1
- package/out/zero/src/advanced.d.ts +1 -1
- package/out/zero/src/build-schema.d.ts +1 -1
- package/out/zero/src/build-schema.js +1 -1
- package/out/zero/src/change-protocol.d.ts +1 -1
- package/out/zero/src/change-protocol.js +1 -1
- package/out/zero/src/cli.d.ts +1 -1
- package/out/zero/src/cli.js +1 -1
- package/out/zero/src/react.d.ts +1 -1
- package/out/zero/src/server/change-streamer.d.ts +1 -1
- package/out/zero/src/server/change-streamer.js +1 -1
- package/out/zero/src/server/main.d.ts +1 -1
- package/out/zero/src/server/main.js +1 -1
- package/out/zero/src/server/multi/main.d.ts +1 -1
- package/out/zero/src/server/multi/main.js +1 -1
- package/out/zero/src/server/replicator.d.ts +1 -1
- package/out/zero/src/server/replicator.js +1 -1
- package/out/zero/src/server/syncer.d.ts +1 -1
- package/out/zero/src/server/syncer.js +1 -1
- package/out/zero/src/solid.d.ts +1 -1
- package/out/zero/src/zero-cache-dev.js +3 -3
- package/out/zero/src/zero.d.ts +1 -1
- package/out/zero-advanced/src/mod.d.ts +8 -8
- package/out/zero-advanced/src/mod.d.ts.map +1 -1
- package/out/zero-cache/src/auth/jwt.d.ts +1 -1
- package/out/zero-cache/src/auth/load-schema.d.ts +3 -3
- package/out/zero-cache/src/auth/load-schema.d.ts.map +1 -1
- package/out/zero-cache/src/auth/load-schema.js +3 -3
- package/out/zero-cache/src/auth/load-schema.js.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.d.ts +2 -2
- package/out/zero-cache/src/auth/read-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js +3 -3
- package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts +5 -5
- package/out/zero-cache/src/auth/write-authorizer.js +14 -14
- package/out/zero-cache/src/config/zero-config.d.ts +2 -2
- package/out/zero-cache/src/config/zero-config.js +6 -6
- package/out/zero-cache/src/db/create.d.ts +1 -1
- package/out/zero-cache/src/db/create.js +1 -1
- package/out/zero-cache/src/db/lite-tables.d.ts +2 -2
- package/out/zero-cache/src/db/lite-tables.js +5 -5
- package/out/zero-cache/src/db/migration-lite.d.ts +2 -2
- package/out/zero-cache/src/db/migration-lite.js +4 -4
- package/out/zero-cache/src/db/migration.d.ts +2 -2
- package/out/zero-cache/src/db/migration.js +3 -3
- package/out/zero-cache/src/db/pg-to-lite.d.ts +2 -2
- package/out/zero-cache/src/db/pg-to-lite.js +5 -5
- package/out/zero-cache/src/db/short-lived-client.d.ts +1 -1
- package/out/zero-cache/src/db/short-lived-client.js +1 -1
- package/out/zero-cache/src/db/specs.d.ts +4 -4
- package/out/zero-cache/src/db/specs.js +3 -3
- package/out/zero-cache/src/db/statements.d.ts +2 -2
- package/out/zero-cache/src/db/statements.js +2 -2
- package/out/zero-cache/src/db/transaction-pool.d.ts +4 -4
- package/out/zero-cache/src/db/transaction-pool.js +3 -3
- package/out/zero-cache/src/server/change-streamer.d.ts +1 -1
- package/out/zero-cache/src/server/change-streamer.js +13 -13
- package/out/zero-cache/src/server/logging.d.ts +1 -1
- package/out/zero-cache/src/server/logging.js +2 -2
- package/out/zero-cache/src/server/main.d.ts +1 -1
- package/out/zero-cache/src/server/main.js +13 -13
- package/out/zero-cache/src/server/multi/config.d.ts +2 -2
- package/out/zero-cache/src/server/multi/config.js +3 -3
- package/out/zero-cache/src/server/multi/main.d.ts +1 -1
- package/out/zero-cache/src/server/multi/main.js +8 -8
- package/out/zero-cache/src/server/multi/runtime.js +1 -1
- package/out/zero-cache/src/server/multi/tenant-dispatcher.d.ts +2 -2
- package/out/zero-cache/src/server/multi/tenant-dispatcher.js +2 -2
- package/out/zero-cache/src/server/replicator.d.ts +1 -1
- package/out/zero-cache/src/server/replicator.js +10 -10
- package/out/zero-cache/src/server/syncer.d.ts +1 -1
- package/out/zero-cache/src/server/syncer.js +21 -21
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +8 -8
- package/out/zero-cache/src/services/change-source/pg/change-source.js +24 -24
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js +15 -15
- package/out/zero-cache/src/services/change-source/pg/lsn.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/pg/lsn.js +2 -2
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +3 -3
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +3 -3
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.js +3 -3
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +4 -4
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +7 -7
- package/out/zero-cache/src/services/change-source/pg/schema/validation.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/validation.js +4 -4
- package/out/zero-cache/src/services/change-source/pg/sync-schema.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/pg/sync-schema.js +3 -3
- package/out/zero-cache/src/services/change-source/protocol/current/control.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/control.js +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +14 -14
- package/out/zero-cache/src/services/change-source/protocol/current/data.js +3 -3
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +16 -16
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.js +4 -4
- package/out/zero-cache/src/services/change-source/protocol/current/mod.d.ts +6 -6
- package/out/zero-cache/src/services/change-source/protocol/current/mod.js +6 -6
- package/out/zero-cache/src/services/change-source/protocol/current/status.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/status.js +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/upstream.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/upstream.js +2 -2
- package/out/zero-cache/src/services/change-source/protocol/mod.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/protocol/mod.js +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +4 -4
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +7 -7
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts +6 -6
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +13 -13
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +10 -10
- package/out/zero-cache/src/services/change-streamer/change-streamer.js +3 -3
- package/out/zero-cache/src/services/change-streamer/forwarder.d.ts +2 -2
- package/out/zero-cache/src/services/change-streamer/forwarder.js +2 -2
- package/out/zero-cache/src/services/change-streamer/schema/init.d.ts +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/init.js +2 -2
- package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts +3 -3
- package/out/zero-cache/src/services/change-streamer/schema/tables.js +2 -2
- package/out/zero-cache/src/services/change-streamer/storer.d.ts +6 -6
- package/out/zero-cache/src/services/change-streamer/storer.js +9 -9
- package/out/zero-cache/src/services/change-streamer/subscriber.d.ts +5 -5
- package/out/zero-cache/src/services/change-streamer/subscriber.js +5 -5
- package/out/zero-cache/src/services/dispatcher/connect-params.d.ts +1 -1
- package/out/zero-cache/src/services/dispatcher/connect-params.js +3 -3
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.d.ts +2 -2
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.js +4 -4
- package/out/zero-cache/src/services/dispatcher/websocket-handoff.d.ts +2 -2
- package/out/zero-cache/src/services/dispatcher/websocket-handoff.js +3 -3
- package/out/zero-cache/src/services/http-service.d.ts +1 -1
- package/out/zero-cache/src/services/http-service.js +2 -2
- package/out/zero-cache/src/services/life-cycle.d.ts +2 -2
- package/out/zero-cache/src/services/life-cycle.js +2 -2
- package/out/zero-cache/src/services/limiter/sliding-window-limiter.js +1 -1
- package/out/zero-cache/src/services/litestream/commands.d.ts +1 -1
- package/out/zero-cache/src/services/litestream/commands.js +2 -2
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +8 -8
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +14 -14
- package/out/zero-cache/src/services/replicator/change-processor.d.ts +23 -0
- package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -0
- package/out/zero-cache/src/services/replicator/change-processor.js +415 -0
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -0
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts +5 -27
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js +9 -421
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/replicator/notifier.d.ts +2 -2
- package/out/zero-cache/src/services/replicator/notifier.js +1 -1
- package/out/zero-cache/src/services/replicator/replicator.d.ts +5 -5
- package/out/zero-cache/src/services/replicator/replicator.js +3 -3
- package/out/zero-cache/src/services/replicator/schema/change-log.d.ts +6 -6
- package/out/zero-cache/src/services/replicator/schema/change-log.js +4 -4
- package/out/zero-cache/src/services/replicator/schema/replication-state.d.ts +3 -3
- package/out/zero-cache/src/services/replicator/schema/replication-state.js +3 -3
- package/out/zero-cache/src/services/runner.d.ts +1 -1
- package/out/zero-cache/src/services/running-state.d.ts +1 -1
- package/out/zero-cache/src/services/running-state.js +2 -2
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +7 -7
- package/out/zero-cache/src/services/view-syncer/client-handler.js +9 -9
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +6 -6
- package/out/zero-cache/src/services/view-syncer/cvr-store.js +17 -17
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +6 -6
- package/out/zero-cache/src/services/view-syncer/cvr.js +8 -8
- package/out/zero-cache/src/services/view-syncer/database-storage.d.ts +2 -2
- package/out/zero-cache/src/services/view-syncer/database-storage.js +1 -1
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +1 -1
- package/out/zero-cache/src/services/view-syncer/key-columns.d.ts +2 -2
- package/out/zero-cache/src/services/view-syncer/key-columns.js +3 -3
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +6 -6
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +8 -8
- package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts +2 -2
- package/out/zero-cache/src/services/view-syncer/schema/cvr.js +4 -4
- package/out/zero-cache/src/services/view-syncer/schema/init.d.ts +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/init.js +2 -2
- package/out/zero-cache/src/services/view-syncer/schema/types.d.ts +12 -12
- package/out/zero-cache/src/services/view-syncer/schema/types.js +4 -4
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +5 -5
- package/out/zero-cache/src/services/view-syncer/snapshotter.js +12 -12
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +9 -9
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +20 -20
- package/out/zero-cache/src/types/bigint-json.d.ts +1 -1
- package/out/zero-cache/src/types/bigint-json.js +1 -1
- package/out/zero-cache/src/types/error-for-client.d.ts +1 -1
- package/out/zero-cache/src/types/lexi-version.js +2 -2
- package/out/zero-cache/src/types/lite.d.ts +4 -4
- package/out/zero-cache/src/types/lite.js +2 -2
- package/out/zero-cache/src/types/pg.d.ts +3 -3
- package/out/zero-cache/src/types/pg.js +2 -2
- package/out/zero-cache/src/types/row-key.d.ts +1 -1
- package/out/zero-cache/src/types/row-key.js +3 -3
- package/out/zero-cache/src/types/schema-versions.d.ts +1 -1
- package/out/zero-cache/src/types/schema-versions.js +2 -2
- package/out/zero-cache/src/types/streams.d.ts +2 -2
- package/out/zero-cache/src/types/streams.js +4 -4
- package/out/zero-cache/src/types/subscription.d.ts +1 -1
- package/out/zero-cache/src/types/timeout.js +1 -1
- package/out/zero-cache/src/workers/connection.d.ts +5 -5
- package/out/zero-cache/src/workers/connection.js +9 -9
- package/out/zero-cache/src/workers/replicator.d.ts +5 -5
- package/out/zero-cache/src/workers/replicator.js +4 -4
- package/out/zero-cache/src/workers/syncer.d.ts +8 -8
- package/out/zero-cache/src/workers/syncer.js +10 -10
- package/out/zero-client/src/client/context.d.ts +6 -6
- package/out/zero-client/src/client/crud.d.ts +6 -6
- package/out/zero-client/src/client/crud.d.ts.map +1 -1
- package/out/zero-client/src/client/keys.d.ts +2 -2
- package/out/zero-client/src/client/log-options.d.ts +2 -2
- package/out/zero-client/src/client/log-options.d.ts.map +1 -1
- package/out/zero-client/src/client/metrics.d.ts +2 -2
- package/out/zero-client/src/client/options.d.ts +3 -3
- package/out/zero-client/src/client/query-manager.d.ts +6 -6
- package/out/zero-client/src/client/reload-error-handler.d.ts +1 -1
- package/out/zero-client/src/client/replicache-types.d.ts +1 -1
- package/out/zero-client/src/client/server-error.d.ts +2 -2
- package/out/zero-client/src/client/server-option.d.ts +1 -1
- package/out/zero-client/src/client/zero-poke-handler.d.ts +4 -4
- package/out/zero-client/src/client/zero-poke-handler.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +12 -12
- package/out/zero-client/src/mod.d.ts +17 -17
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-client/src/util/socket.d.ts +1 -1
- package/out/zero-protocol/src/ast-hash.d.ts +1 -1
- package/out/zero-protocol/src/ast-hash.js +2 -2
- package/out/zero-protocol/src/ast.d.ts +2 -2
- package/out/zero-protocol/src/ast.js +5 -5
- package/out/zero-protocol/src/change-desired-queries.d.ts +3 -3
- package/out/zero-protocol/src/change-desired-queries.js +2 -2
- package/out/zero-protocol/src/clients-patch.d.ts +1 -1
- package/out/zero-protocol/src/clients-patch.js +1 -1
- package/out/zero-protocol/src/connect.d.ts +3 -3
- package/out/zero-protocol/src/connect.js +2 -2
- package/out/zero-protocol/src/data.d.ts +3 -3
- package/out/zero-protocol/src/data.js +2 -2
- package/out/zero-protocol/src/delete-clients.d.ts +1 -1
- package/out/zero-protocol/src/delete-clients.js +1 -1
- package/out/zero-protocol/src/down.d.ts +6 -6
- package/out/zero-protocol/src/down.js +7 -7
- package/out/zero-protocol/src/error.d.ts +1 -1
- package/out/zero-protocol/src/error.js +2 -2
- package/out/zero-protocol/src/mod.d.ts +14 -14
- package/out/zero-protocol/src/mod.js +14 -14
- package/out/zero-protocol/src/ping.d.ts +1 -1
- package/out/zero-protocol/src/ping.js +1 -1
- package/out/zero-protocol/src/poke.d.ts +9 -9
- package/out/zero-protocol/src/poke.js +5 -5
- package/out/zero-protocol/src/pong.d.ts +1 -1
- package/out/zero-protocol/src/pong.js +1 -1
- package/out/zero-protocol/src/primary-key.d.ts +1 -1
- package/out/zero-protocol/src/primary-key.js +1 -1
- package/out/zero-protocol/src/protocol-version.js +1 -1
- package/out/zero-protocol/src/pull.d.ts +1 -1
- package/out/zero-protocol/src/pull.js +2 -2
- package/out/zero-protocol/src/push.d.ts +26 -26
- package/out/zero-protocol/src/push.js +5 -5
- package/out/zero-protocol/src/queries-patch.d.ts +4 -4
- package/out/zero-protocol/src/queries-patch.js +2 -2
- package/out/zero-protocol/src/row-patch.d.ts +5 -5
- package/out/zero-protocol/src/row-patch.js +4 -4
- package/out/zero-protocol/src/up.d.ts +7 -7
- package/out/zero-protocol/src/up.js +7 -7
- package/out/zero-protocol/src/up.js.map +1 -1
- package/out/zero-protocol/src/version.d.ts +1 -1
- package/out/zero-protocol/src/version.js +1 -1
- package/out/zero-protocol/src/warm.d.ts +1 -1
- package/out/zero-protocol/src/warm.js +1 -1
- package/out/zero-react/src/mod.d.ts +8 -8
- package/out/zero-react/src/use-query.d.ts +4 -4
- package/out/zero-react/src/use-zero.d.ts +2 -2
- package/out/zero-schema/src/build-schema-options.d.ts +1 -1
- package/out/zero-schema/src/build-schema-options.js +1 -1
- package/out/zero-schema/src/build-schema.js +5 -5
- package/out/zero-schema/src/build-schema.js.map +1 -1
- package/out/zero-schema/src/builder/relationship-builder.d.ts +2 -2
- package/out/zero-schema/src/builder/schema-builder.d.ts +3 -3
- package/out/zero-schema/src/builder/schema-builder.js +1 -1
- package/out/zero-schema/src/builder/table-builder.d.ts +3 -3
- package/out/zero-schema/src/compiled-permissions.d.ts +18 -18
- package/out/zero-schema/src/compiled-permissions.js +2 -2
- package/out/zero-schema/src/mod.d.ts +4 -4
- package/out/zero-schema/src/mod.d.ts.map +1 -1
- package/out/zero-schema/src/permissions.d.ts +5 -5
- package/out/zero-schema/src/schema-config.d.ts +4 -4
- package/out/zero-schema/src/schema-config.d.ts.map +1 -1
- package/out/zero-schema/src/schema-config.js +4 -4
- package/out/zero-schema/src/schema-config.js.map +1 -1
- package/out/zero-schema/src/table-schema.d.ts +1 -1
- package/out/zero-solid/src/create-zero.d.ts +2 -2
- package/out/zero-solid/src/create-zero.d.ts.map +1 -1
- package/out/zero-solid/src/mod.d.ts +2 -2
- package/out/zero-solid/src/solid-view.d.ts +3 -3
- package/out/zero-solid/src/use-query.d.ts +3 -3
- package/out/zero-solid/src/use-query.d.ts.map +1 -1
- package/out/zero.js +3 -3
- package/out/zql/src/builder/builder.d.ts +7 -7
- package/out/zql/src/builder/builder.js +10 -10
- package/out/zql/src/builder/filter.d.ts +2 -2
- package/out/zql/src/builder/filter.js +2 -2
- package/out/zql/src/builder/like.d.ts +1 -1
- package/out/zql/src/builder/like.js +1 -1
- package/out/zql/src/ivm/array-view.d.ts +4 -4
- package/out/zql/src/ivm/array-view.js +2 -2
- package/out/zql/src/ivm/change.d.ts +2 -2
- package/out/zql/src/ivm/constraint.d.ts +2 -2
- package/out/zql/src/ivm/constraint.js +3 -3
- package/out/zql/src/ivm/data.d.ts +3 -3
- package/out/zql/src/ivm/data.js +1 -1
- package/out/zql/src/ivm/exists.d.ts +6 -6
- package/out/zql/src/ivm/exists.js +7 -7
- package/out/zql/src/ivm/fan-in.d.ts +6 -6
- package/out/zql/src/ivm/fan-in.js +4 -4
- package/out/zql/src/ivm/fan-out.d.ts +5 -5
- package/out/zql/src/ivm/filter-push.d.ts +3 -3
- package/out/zql/src/ivm/filter-push.d.ts.map +1 -1
- package/out/zql/src/ivm/filter-push.js +2 -2
- package/out/zql/src/ivm/filter-push.js.map +1 -1
- package/out/zql/src/ivm/filter.d.ts +5 -5
- package/out/zql/src/ivm/filter.js +2 -2
- package/out/zql/src/ivm/join.d.ts +7 -7
- package/out/zql/src/ivm/join.js +4 -4
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +3 -3
- package/out/zql/src/ivm/memory-source.d.ts +11 -11
- package/out/zql/src/ivm/memory-source.js +9 -9
- package/out/zql/src/ivm/memory-storage.d.ts +3 -3
- package/out/zql/src/ivm/operator.d.ts +7 -7
- package/out/zql/src/ivm/operator.js +1 -1
- package/out/zql/src/ivm/schema.d.ts +4 -4
- package/out/zql/src/ivm/skip.d.ts +6 -6
- package/out/zql/src/ivm/skip.js +2 -2
- package/out/zql/src/ivm/source.d.ts +3 -3
- package/out/zql/src/ivm/take.d.ts +6 -6
- package/out/zql/src/ivm/take.js +8 -8
- package/out/zql/src/ivm/view-apply-change.d.ts +3 -3
- package/out/zql/src/ivm/view-apply-change.js +2 -2
- package/out/zql/src/ivm/view.d.ts +4 -4
- package/out/zql/src/query/auth-query.d.ts +7 -7
- package/out/zql/src/query/auth-query.js +2 -2
- package/out/zql/src/query/dnf.d.ts +1 -1
- package/out/zql/src/query/dnf.js +2 -2
- package/out/zql/src/query/expression.d.ts +3 -4
- package/out/zql/src/query/expression.d.ts.map +1 -1
- package/out/zql/src/query/expression.js +2 -2
- package/out/zql/src/query/query-impl.d.ts +8 -8
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +7 -7
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query-internal.d.ts +4 -4
- package/out/zql/src/query/query.d.ts +7 -10
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/typed-view.d.ts +1 -1
- package/out/zqlite/src/db.js +2 -2
- package/out/zqlite/src/internal/statement-cache.d.ts +1 -1
- package/out/zqlite/src/internal/statement-cache.d.ts.map +1 -1
- package/out/zqlite/src/internal/statement-cache.js +1 -1
- package/out/zqlite/src/internal/statement-cache.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts +6 -6
- package/out/zqlite/src/table-source.js +11 -11
- package/package.json +4 -4
- /package/out/{chunk-F5QR3K72.js.map → chunk-424PT5DM.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../shared/src/asserts.ts", "../../shared/src/must.ts", "../../zql/src/ivm/view-apply-change.ts"],
|
|
4
|
-
"sourcesContent": ["export function assert(\n b: unknown,\n msg: string | (() => string) = 'Assertion failed',\n): asserts b {\n if (!b) {\n const msgStr = typeof msg === 'string' ? msg : msg();\n throw new Error(msgStr);\n }\n}\n\nexport function assertString(v: unknown): asserts v is string {\n assertType(v, 'string');\n}\n\nexport function assertNumber(v: unknown): asserts v is number {\n assertType(v, 'number');\n}\n\nexport function assertBoolean(v: unknown): asserts v is boolean {\n assertType(v, 'boolean');\n}\n\nfunction assertType(v: unknown, t: string) {\n if (typeof v !== t) {\n throwInvalidType(v, t);\n }\n}\n\nexport function assertObject(v: unknown): asserts v is Record<string, unknown> {\n if (v === null) {\n throwInvalidType(v, 'object');\n }\n assertType(v, 'object');\n}\n\nexport function assertArray(v: unknown): asserts v is unknown[] {\n if (!Array.isArray(v)) {\n throwInvalidType(v, 'array');\n }\n}\n\nexport function invalidType(v: unknown, t: string): string {\n let s = 'Invalid type: ';\n if (v === null || v === undefined) {\n s += v;\n } else {\n s += `${typeof v} \\`${v}\\``;\n }\n return s + `, expected ${t}`;\n}\n\nexport function throwInvalidType(v: unknown, t: string): never {\n throw new Error(invalidType(v, t));\n}\n\nexport function assertNotNull<T>(v: T | null): asserts v is T {\n if (v === null) {\n throw new Error('Expected non-null value');\n }\n}\n\nexport function assertUndefined<T>(\n v: T | undefined,\n msg = 'Expected undefined value',\n): asserts v is T {\n if (v !== undefined) {\n throw new Error(msg);\n }\n}\n\nexport function assertNotUndefined<T>(\n v: T | undefined,\n msg = 'Expected non undefined value',\n): asserts v is T {\n if (v === undefined) {\n throw new Error(msg);\n }\n}\n\nexport function assertInstanceof<T>(\n v: unknown,\n t: new (...args: unknown[]) => T,\n): asserts v is T {\n if (!(v instanceof t)) {\n throw new Error(`Expected instanceof ${t.name}`);\n }\n}\n\nexport function assertUint8Array(v: unknown): asserts v is Uint8Array {\n assertInstanceof(v, Uint8Array);\n}\n\nexport function unreachable(): never;\nexport function unreachable(v: never): never;\nexport function unreachable(_?: never): never {\n throw new Error('Unreachable');\n}\n\nexport function notImplemented(): never {\n throw new Error('Not implemented');\n}\n", "export function must<T>(v: T | undefined | null, msg?: string): T {\n // eslint-disable-next-line eqeqeq\n if (v == null) {\n throw new Error(msg ?? `Unexpected ${v} value`);\n }\n return v;\n}\n", "import {\n assert,\n assertArray,\n assertObject,\n assertUndefined,\n unreachable,\n} from '../../../shared/src/asserts.js';\nimport {must} from '../../../shared/src/must.js';\nimport type {Row} from '../../../zero-protocol/src/data.js';\nimport type {Change} from './change.js';\nimport type {Comparator, Node} from './data.js';\nimport type {SourceSchema} from './schema.js';\nimport type {Entry, EntryList, Format} from './view.js';\n\nexport function applyChange(\n parentEntry: Entry,\n change: Change,\n schema: SourceSchema,\n relationship: string,\n format: Format,\n) {\n if (schema.isHidden) {\n switch (change.type) {\n case 'add':\n case 'remove':\n for (const [relationship, children] of Object.entries(\n change.node.relationships,\n )) {\n const childSchema = must(schema.relationships[relationship]);\n for (const node of children) {\n applyChange(\n parentEntry,\n {type: change.type, node},\n childSchema,\n relationship,\n format,\n );\n }\n }\n return;\n case 'edit':\n // If hidden at this level it means that the hidden row was changed. If\n // the row was changed in such a way that it would change the\n // relationships then the edit would have been split into remove and\n // add.\n return;\n case 'child': {\n const childSchema = must(\n schema.relationships[change.child.relationshipName],\n );\n applyChange(\n parentEntry,\n change.child.change,\n childSchema,\n relationship,\n format,\n );\n return;\n }\n default:\n unreachable(change);\n }\n }\n\n const {singular, relationships: childFormats} = format;\n switch (change.type) {\n case 'add': {\n // TODO: Only create a new entry if we need to mutate the existing one.\n const newEntry: Entry = {\n ...change.node.row,\n };\n if (singular) {\n assertUndefined(\n parentEntry[relationship],\n 'single output already exists',\n );\n parentEntry[relationship] = newEntry;\n } else {\n const view = getChildEntryList(parentEntry, relationship);\n const {pos, found} = binarySearch(view, newEntry, schema.compareRows);\n assert(!found, 'node already exists');\n // @ts-expect-error view is readonly\n view.splice(pos, 0, newEntry);\n }\n for (const [relationship, children] of Object.entries(\n change.node.relationships,\n )) {\n // TODO: Is there a flag to make TypeScript complain that dictionary access might be undefined?\n const childSchema = must(schema.relationships[relationship]);\n const childFormat = childFormats[relationship];\n if (childFormat === undefined) {\n continue;\n }\n\n const newView = childFormat.singular ? undefined : ([] as EntryList);\n newEntry[relationship] = newView;\n for (const node of children) {\n applyChange(\n newEntry,\n {type: 'add', node},\n childSchema,\n relationship,\n childFormat,\n );\n }\n }\n break;\n }\n case 'remove': {\n if (singular) {\n assertObject(parentEntry[relationship]);\n parentEntry[relationship] = undefined;\n } else {\n const view = getChildEntryList(parentEntry, relationship);\n const {pos, found} = binarySearch(\n view,\n change.node.row,\n schema.compareRows,\n );\n assert(found, 'node does not exist');\n // @ts-expect-error view is readonly\n view.splice(pos, 1);\n }\n // Needed to ensure cleanup of operator state is fully done.\n drainStreams(change.node);\n break;\n }\n case 'child': {\n let existing: Entry;\n if (singular) {\n assertObject(parentEntry[relationship]);\n existing = parentEntry[relationship];\n } else {\n const view = getChildEntryList(parentEntry, relationship);\n const {pos, found} = binarySearch(view, change.row, schema.compareRows);\n assert(found, 'node does not exist');\n existing = view[pos];\n }\n\n const childSchema = must(\n schema.relationships[change.child.relationshipName],\n );\n const childFormat = format.relationships[change.child.relationshipName];\n if (childFormat !== undefined) {\n applyChange(\n existing,\n change.child.change,\n childSchema,\n change.child.relationshipName,\n childFormat,\n );\n }\n break;\n }\n case 'edit': {\n if (singular) {\n assertObject(parentEntry[relationship]);\n parentEntry[relationship] = {\n ...parentEntry[relationship],\n ...change.node.row,\n };\n } else {\n const view = parentEntry[relationship] as EntryList | undefined;\n assertArray(view);\n // If the order changed due to the edit, we need to remove and reinsert.\n if (schema.compareRows(change.oldNode.row, change.node.row) === 0) {\n const {pos, found} = binarySearch(\n view,\n change.oldNode.row,\n schema.compareRows,\n );\n assert(found, 'node does not exists');\n view[pos] = makeEntryPreserveRelationships(\n change.node.row,\n view[pos],\n schema.relationships,\n );\n } else {\n // Remove\n const {pos, found} = binarySearch(\n view,\n change.oldNode.row,\n schema.compareRows,\n );\n assert(found, 'node does not exists');\n const oldEntry = view[pos];\n view.splice(pos, 1);\n\n // Insert\n {\n const {pos, found} = binarySearch(\n view,\n change.node.row,\n schema.compareRows,\n );\n assert(!found, 'node already exists');\n view.splice(\n pos,\n 0,\n makeEntryPreserveRelationships(\n change.node.row,\n oldEntry,\n schema.relationships,\n ),\n );\n }\n }\n }\n break;\n }\n default:\n unreachable(change);\n }\n}\n\n// TODO: Do not return an object. It puts unnecessary pressure on the GC.\nfunction binarySearch(view: EntryList, target: Entry, comparator: Comparator) {\n let low = 0;\n let high = view.length - 1;\n while (low <= high) {\n const mid = (low + high) >>> 1;\n const comparison = comparator(view[mid] as Row, target as Row);\n if (comparison < 0) {\n low = mid + 1;\n } else if (comparison > 0) {\n high = mid - 1;\n } else {\n return {pos: mid, found: true};\n }\n }\n return {pos: low, found: false};\n}\n\nfunction makeEntryPreserveRelationships(\n row: Row,\n entry: Entry,\n relationships: {[key: string]: SourceSchema},\n): Entry {\n const result: Entry = {...row};\n for (const relationship in relationships) {\n assert(!(relationship in row), 'Relationship already exists');\n result[relationship] = entry[relationship];\n }\n return result;\n}\n\nfunction drainStreams(node: Node) {\n for (const stream of Object.values(node.relationships)) {\n for (const node of stream) {\n drainStreams(node);\n }\n }\n}\n\nfunction getChildEntryList(\n parentEntry: Entry,\n relationship: string,\n): EntryList {\n const view = parentEntry[relationship] as unknown;\n assertArray(view);\n return view as EntryList;\n}\n"],
|
|
4
|
+
"sourcesContent": ["export function assert(\n b: unknown,\n msg: string | (() => string) = 'Assertion failed',\n): asserts b {\n if (!b) {\n const msgStr = typeof msg === 'string' ? msg : msg();\n throw new Error(msgStr);\n }\n}\n\nexport function assertString(v: unknown): asserts v is string {\n assertType(v, 'string');\n}\n\nexport function assertNumber(v: unknown): asserts v is number {\n assertType(v, 'number');\n}\n\nexport function assertBoolean(v: unknown): asserts v is boolean {\n assertType(v, 'boolean');\n}\n\nfunction assertType(v: unknown, t: string) {\n if (typeof v !== t) {\n throwInvalidType(v, t);\n }\n}\n\nexport function assertObject(v: unknown): asserts v is Record<string, unknown> {\n if (v === null) {\n throwInvalidType(v, 'object');\n }\n assertType(v, 'object');\n}\n\nexport function assertArray(v: unknown): asserts v is unknown[] {\n if (!Array.isArray(v)) {\n throwInvalidType(v, 'array');\n }\n}\n\nexport function invalidType(v: unknown, t: string): string {\n let s = 'Invalid type: ';\n if (v === null || v === undefined) {\n s += v;\n } else {\n s += `${typeof v} \\`${v}\\``;\n }\n return s + `, expected ${t}`;\n}\n\nexport function throwInvalidType(v: unknown, t: string): never {\n throw new Error(invalidType(v, t));\n}\n\nexport function assertNotNull<T>(v: T | null): asserts v is T {\n if (v === null) {\n throw new Error('Expected non-null value');\n }\n}\n\nexport function assertUndefined<T>(\n v: T | undefined,\n msg = 'Expected undefined value',\n): asserts v is T {\n if (v !== undefined) {\n throw new Error(msg);\n }\n}\n\nexport function assertNotUndefined<T>(\n v: T | undefined,\n msg = 'Expected non undefined value',\n): asserts v is T {\n if (v === undefined) {\n throw new Error(msg);\n }\n}\n\nexport function assertInstanceof<T>(\n v: unknown,\n t: new (...args: unknown[]) => T,\n): asserts v is T {\n if (!(v instanceof t)) {\n throw new Error(`Expected instanceof ${t.name}`);\n }\n}\n\nexport function assertUint8Array(v: unknown): asserts v is Uint8Array {\n assertInstanceof(v, Uint8Array);\n}\n\nexport function unreachable(): never;\nexport function unreachable(v: never): never;\nexport function unreachable(_?: never): never {\n throw new Error('Unreachable');\n}\n\nexport function notImplemented(): never {\n throw new Error('Not implemented');\n}\n", "export function must<T>(v: T | undefined | null, msg?: string): T {\n // eslint-disable-next-line eqeqeq\n if (v == null) {\n throw new Error(msg ?? `Unexpected ${v} value`);\n }\n return v;\n}\n", "import {\n assert,\n assertArray,\n assertObject,\n assertUndefined,\n unreachable,\n} from '../../../shared/src/asserts.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport type {Change} from './change.ts';\nimport type {Comparator, Node} from './data.ts';\nimport type {SourceSchema} from './schema.ts';\nimport type {Entry, EntryList, Format} from './view.ts';\n\nexport function applyChange(\n parentEntry: Entry,\n change: Change,\n schema: SourceSchema,\n relationship: string,\n format: Format,\n) {\n if (schema.isHidden) {\n switch (change.type) {\n case 'add':\n case 'remove':\n for (const [relationship, children] of Object.entries(\n change.node.relationships,\n )) {\n const childSchema = must(schema.relationships[relationship]);\n for (const node of children) {\n applyChange(\n parentEntry,\n {type: change.type, node},\n childSchema,\n relationship,\n format,\n );\n }\n }\n return;\n case 'edit':\n // If hidden at this level it means that the hidden row was changed. If\n // the row was changed in such a way that it would change the\n // relationships then the edit would have been split into remove and\n // add.\n return;\n case 'child': {\n const childSchema = must(\n schema.relationships[change.child.relationshipName],\n );\n applyChange(\n parentEntry,\n change.child.change,\n childSchema,\n relationship,\n format,\n );\n return;\n }\n default:\n unreachable(change);\n }\n }\n\n const {singular, relationships: childFormats} = format;\n switch (change.type) {\n case 'add': {\n // TODO: Only create a new entry if we need to mutate the existing one.\n const newEntry: Entry = {\n ...change.node.row,\n };\n if (singular) {\n assertUndefined(\n parentEntry[relationship],\n 'single output already exists',\n );\n parentEntry[relationship] = newEntry;\n } else {\n const view = getChildEntryList(parentEntry, relationship);\n const {pos, found} = binarySearch(view, newEntry, schema.compareRows);\n assert(!found, 'node already exists');\n // @ts-expect-error view is readonly\n view.splice(pos, 0, newEntry);\n }\n for (const [relationship, children] of Object.entries(\n change.node.relationships,\n )) {\n // TODO: Is there a flag to make TypeScript complain that dictionary access might be undefined?\n const childSchema = must(schema.relationships[relationship]);\n const childFormat = childFormats[relationship];\n if (childFormat === undefined) {\n continue;\n }\n\n const newView = childFormat.singular ? undefined : ([] as EntryList);\n newEntry[relationship] = newView;\n for (const node of children) {\n applyChange(\n newEntry,\n {type: 'add', node},\n childSchema,\n relationship,\n childFormat,\n );\n }\n }\n break;\n }\n case 'remove': {\n if (singular) {\n assertObject(parentEntry[relationship]);\n parentEntry[relationship] = undefined;\n } else {\n const view = getChildEntryList(parentEntry, relationship);\n const {pos, found} = binarySearch(\n view,\n change.node.row,\n schema.compareRows,\n );\n assert(found, 'node does not exist');\n // @ts-expect-error view is readonly\n view.splice(pos, 1);\n }\n // Needed to ensure cleanup of operator state is fully done.\n drainStreams(change.node);\n break;\n }\n case 'child': {\n let existing: Entry;\n if (singular) {\n assertObject(parentEntry[relationship]);\n existing = parentEntry[relationship];\n } else {\n const view = getChildEntryList(parentEntry, relationship);\n const {pos, found} = binarySearch(view, change.row, schema.compareRows);\n assert(found, 'node does not exist');\n existing = view[pos];\n }\n\n const childSchema = must(\n schema.relationships[change.child.relationshipName],\n );\n const childFormat = format.relationships[change.child.relationshipName];\n if (childFormat !== undefined) {\n applyChange(\n existing,\n change.child.change,\n childSchema,\n change.child.relationshipName,\n childFormat,\n );\n }\n break;\n }\n case 'edit': {\n if (singular) {\n assertObject(parentEntry[relationship]);\n parentEntry[relationship] = {\n ...parentEntry[relationship],\n ...change.node.row,\n };\n } else {\n const view = parentEntry[relationship] as EntryList | undefined;\n assertArray(view);\n // If the order changed due to the edit, we need to remove and reinsert.\n if (schema.compareRows(change.oldNode.row, change.node.row) === 0) {\n const {pos, found} = binarySearch(\n view,\n change.oldNode.row,\n schema.compareRows,\n );\n assert(found, 'node does not exists');\n view[pos] = makeEntryPreserveRelationships(\n change.node.row,\n view[pos],\n schema.relationships,\n );\n } else {\n // Remove\n const {pos, found} = binarySearch(\n view,\n change.oldNode.row,\n schema.compareRows,\n );\n assert(found, 'node does not exists');\n const oldEntry = view[pos];\n view.splice(pos, 1);\n\n // Insert\n {\n const {pos, found} = binarySearch(\n view,\n change.node.row,\n schema.compareRows,\n );\n assert(!found, 'node already exists');\n view.splice(\n pos,\n 0,\n makeEntryPreserveRelationships(\n change.node.row,\n oldEntry,\n schema.relationships,\n ),\n );\n }\n }\n }\n break;\n }\n default:\n unreachable(change);\n }\n}\n\n// TODO: Do not return an object. It puts unnecessary pressure on the GC.\nfunction binarySearch(view: EntryList, target: Entry, comparator: Comparator) {\n let low = 0;\n let high = view.length - 1;\n while (low <= high) {\n const mid = (low + high) >>> 1;\n const comparison = comparator(view[mid] as Row, target as Row);\n if (comparison < 0) {\n low = mid + 1;\n } else if (comparison > 0) {\n high = mid - 1;\n } else {\n return {pos: mid, found: true};\n }\n }\n return {pos: low, found: false};\n}\n\nfunction makeEntryPreserveRelationships(\n row: Row,\n entry: Entry,\n relationships: {[key: string]: SourceSchema},\n): Entry {\n const result: Entry = {...row};\n for (const relationship in relationships) {\n assert(!(relationship in row), 'Relationship already exists');\n result[relationship] = entry[relationship];\n }\n return result;\n}\n\nfunction drainStreams(node: Node) {\n for (const stream of Object.values(node.relationships)) {\n for (const node of stream) {\n drainStreams(node);\n }\n }\n}\n\nfunction getChildEntryList(\n parentEntry: Entry,\n relationship: string,\n): EntryList {\n const view = parentEntry[relationship] as unknown;\n assertArray(view);\n return view as EntryList;\n}\n"],
|
|
5
5
|
"mappings": ";AAAO,SAAS,OACd,GACA,MAA+B,oBACpB;AACX,MAAI,CAAC,GAAG;AACN,UAAM,SAAS,OAAO,QAAQ,WAAW,MAAM,IAAI;AACnD,UAAM,IAAI,MAAM,MAAM;AAAA,EACxB;AACF;AAEO,SAAS,aAAa,GAAiC;AAC5D,aAAW,GAAG,QAAQ;AACxB;AAEO,SAAS,aAAa,GAAiC;AAC5D,aAAW,GAAG,QAAQ;AACxB;AAEO,SAAS,cAAc,GAAkC;AAC9D,aAAW,GAAG,SAAS;AACzB;AAEA,SAAS,WAAW,GAAY,GAAW;AACzC,MAAI,OAAO,MAAM,GAAG;AAClB,qBAAiB,GAAG,CAAC;AAAA,EACvB;AACF;AAEO,SAAS,aAAa,GAAkD;AAC7E,MAAI,MAAM,MAAM;AACd,qBAAiB,GAAG,QAAQ;AAAA,EAC9B;AACA,aAAW,GAAG,QAAQ;AACxB;AAEO,SAAS,YAAY,GAAoC;AAC9D,MAAI,CAAC,MAAM,QAAQ,CAAC,GAAG;AACrB,qBAAiB,GAAG,O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AI,MAAM,YAAY;AAAA,EAC3C;AACA,SAAO;AACT;AAEA,SAAS,aAAa,MAAY;AAChC,aAAW,UAAU,OAAO,OAAO,KAAK,aAAa,GAAG;AACtD,eAAWE,SAAQ,QAAQ;AACzB,mBAAaA,KAAI;AAAA,IACnB;AAAA,EACF;AACF;AAEA,SAAS,kBACP,aACA,cACW;AACX,QAAM,OAAO,YAAY,YAAY;AACrC,cAAY,IAAI;AAChB,SAAO;AACT;",
|
|
6
6
|
"names": ["relationship", "pos", "found", "node"]
|
|
7
7
|
}
|
package/out/datadog/src/mod.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DatadogLogSink, type DatadogLogSinkOptions, } from './datadog-log-sink.
|
|
1
|
+
export { DatadogLogSink, type DatadogLogSinkOptions, } from './datadog-log-sink.ts';
|
|
2
2
|
//# sourceMappingURL=mod.d.ts.map
|
package/out/react.js
CHANGED
package/out/react.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../zero-react/src/use-query.tsx", "../../shared/src/deep-clone.ts", "../../zero-react/src/use-zero.tsx"],
|
|
4
|
-
"sourcesContent": ["import {useSyncExternalStore} from 'react';\nimport {deepClone} from '../../shared/src/deep-clone.js';\nimport type {Immutable} from '../../shared/src/immutable.js';\nimport type {\n Query,\n ReadonlyJSONValue,\n Schema,\n TypedView,\n} from '../../zero-client/src/mod.js';\nimport type {AdvancedQuery} from '../../zql/src/query/query-internal.js';\nimport type {HumanReadable} from '../../zql/src/query/query.js';\nimport type {ResultType} from '../../zql/src/query/typed-view.js';\nimport {useZero} from './use-zero.js';\n\nexport type QueryResultDetails = Readonly<{\n type: ResultType;\n}>;\n\nexport type QueryResult<TReturn> = readonly [\n HumanReadable<TReturn>,\n QueryResultDetails,\n];\n\nexport function useQuery<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(\n q: Query<TSchema, TTable, TReturn>,\n enable: boolean = true,\n): QueryResult<TReturn> {\n const z = useZero();\n const view = viewStore.getView(\n z.clientID,\n q as AdvancedQuery<TSchema, TTable, TReturn>,\n enable && z.server !== null,\n );\n // https://react.dev/reference/react/useSyncExternalStore\n return useSyncExternalStore(\n view.subscribeReactInternals,\n view.getSnapshot,\n view.getSnapshot,\n );\n}\n\nconst emptyArray: unknown[] = [];\nconst disabledSubscriber = () => () => {};\n\nconst resultTypeUnknown = {type: 'unknown'} as const;\nconst resultTypeComplete = {type: 'complete'} as const;\n\nconst emptySnapshotSingularUnknown = [undefined, resultTypeUnknown] as const;\nconst emptySnapshotSingularComplete = [undefined, resultTypeComplete] as const;\nconst emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown] as const;\nconst emptySnapshotPluralComplete = [emptyArray, resultTypeComplete] as const;\n\nfunction getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TReturn> {\n return (\n singular ? emptySnapshotSingularUnknown : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n}\n\n/**\n * Returns a new snapshot or one of the empty predefined ones. Returning the\n * predefined ones is important to prevent unnecessary re-renders in React.\n */\nfunction getSnapshot<TReturn>(\n singular: boolean,\n data: HumanReadable<TReturn>,\n resultType: string,\n): QueryResult<TReturn> {\n if (singular && data === undefined) {\n return (resultType === 'complete'\n ? emptySnapshotSingularComplete\n : emptySnapshotSingularUnknown) as unknown as QueryResult<TReturn>;\n }\n\n if (!singular && (data as unknown[]).length === 0) {\n return (\n resultType === 'complete'\n ? emptySnapshotPluralComplete\n : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n }\n\n return [\n data,\n resultType === 'complete' ? resultTypeComplete : resultTypeUnknown,\n ];\n}\n\ndeclare const TESTING: boolean;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ViewWrapperAny = ViewWrapper<any, any, any>;\n\nconst allViews = new WeakMap<ViewStore, Map<string, ViewWrapperAny>>();\n\nexport function getAllViewsSizeForTesting(store: ViewStore): number {\n if (TESTING) {\n return allViews.get(store)?.size ?? 0;\n }\n return 0;\n}\n\n/**\n * A global store of all active views.\n *\n * React subscribes and unsubscribes to these views\n * via `useSyncExternalStore`.\n *\n * Managing views through `useEffect` or `useLayoutEffect` causes\n * inconsistencies because effects run after render.\n *\n * For example, if useQuery used use*Effect in the component below:\n * ```ts\n * function Foo({issueID}) {\n * const issue = useQuery(z.query.issue.where('id', issueID).one());\n * if (issue?.id !== undefined && issue.id !== issueID) {\n * console.log('MISMATCH!', issue.id, issueID);\n * }\n * }\n * ```\n *\n * `MISMATCH` will be printed whenever the `issueID` prop changes.\n *\n * This is because the component will render once with\n * the old state returned from `useQuery`. Then the effect inside\n * `useQuery` will run. The component will render again with the new\n * state. This inconsistent transition can cause unexpected results.\n *\n * Emulating `useEffect` via `useState` and `if` causes resource leaks.\n * That is:\n *\n * ```ts\n * function useQuery(q) {\n * const [oldHash, setOldHash] = useState();\n * if (hash(q) !== oldHash) {\n * // make new view\n * }\n *\n * useEffect(() => {\n * return () => view.destroy();\n * }, []);\n * }\n * ```\n *\n * I'm not sure why but in strict mode the cleanup function\n * fails to be called for the first instance of the view and only\n * cleans up later instances.\n *\n * Swapping `useState` to `useRef` has similar problems.\n */\nexport class ViewStore {\n #views = new Map<string, ViewWrapperAny>();\n\n constructor() {\n if (TESTING) {\n allViews.set(this, this.#views);\n }\n }\n\n getView<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n >(\n clientID: string,\n query: AdvancedQuery<TSchema, TTable, TReturn>,\n enabled: boolean,\n ): {\n getSnapshot: () => QueryResult<TReturn>;\n subscribeReactInternals: (internals: () => void) => () => void;\n } {\n if (!enabled) {\n return {\n getSnapshot: () => getDefaultSnapshot(query.format.singular),\n subscribeReactInternals: disabledSubscriber,\n };\n }\n\n const hash = query.hash() + clientID;\n let existing = this.#views.get(hash);\n if (!existing) {\n existing = new ViewWrapper(\n query,\n view => {\n const lastView = this.#views.get(hash);\n // I don't think this can happen\n // but lets guard against it so we don't\n // leak resources.\n if (lastView && lastView !== view) {\n throw new Error('View already exists');\n }\n this.#views.set(hash, view);\n },\n () => {\n this.#views.delete(hash);\n },\n ) as ViewWrapper<TSchema, TTable, TReturn>;\n this.#views.set(hash, existing);\n }\n return existing as ViewWrapper<TSchema, TTable, TReturn>;\n }\n}\n\nconst viewStore = new ViewStore();\n\n/**\n * This wraps and ref counts a view.\n *\n * The only signal we have from React as to whether or not it is\n * done with a view is when it calls `unsubscribe`.\n *\n * In non-strict-mode we can clean up the view as soon\n * as the listener count goes to 0.\n *\n * In strict-mode, the listener count will go to 0 then a\n * new listener for the same view is immediately added back.\n *\n * This is why the `onMaterialized` and `onDematerialized` callbacks exist --\n * they allow a view which React is still referencing to be added\n * back into the store when React re-subscribes to it.\n *\n * This wrapper also exists to deal with the various\n * `useSyncExternalStore` caveats that cause excessive\n * re-renders and materializations.\n *\n * See: https://react.dev/reference/react/useSyncExternalStore#caveats\n * Especially:\n * 1. The store snapshot returned by getSnapshot must be immutable. If the underlying store has mutable data, return a new immutable snapshot if the data has changed. Otherwise, return a cached last snapshot.\n * 2. If a different subscribe function is passed during a re-render, React will re-subscribe to the store using the newly passed subscribe function. You can prevent this by declaring subscribe outside the component.\n */\nclass ViewWrapper<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n> {\n #view: TypedView<HumanReadable<TReturn>> | undefined;\n readonly #onDematerialized;\n readonly #onMaterialized;\n readonly #query: AdvancedQuery<TSchema, TTable, TReturn>;\n #snapshot: QueryResult<TReturn>;\n #reactInternals: Set<() => void>;\n\n constructor(\n query: AdvancedQuery<TSchema, TTable, TReturn>,\n onMaterialized: (view: ViewWrapper<TSchema, TTable, TReturn>) => void,\n onDematerialized: () => void,\n ) {\n this.#snapshot = getDefaultSnapshot(query.format.singular);\n this.#onMaterialized = onMaterialized;\n this.#onDematerialized = onDematerialized;\n this.#reactInternals = new Set();\n this.#query = query;\n this.#materializeIfNeeded();\n }\n\n #onData = (\n snap: Immutable<HumanReadable<TReturn>>,\n resultType: ResultType,\n ) => {\n const data =\n snap === undefined\n ? snap\n : (deepClone(snap as ReadonlyJSONValue) as HumanReadable<TReturn>);\n this.#snapshot = getSnapshot(this.#query.format.singular, data, resultType);\n for (const internals of this.#reactInternals) {\n internals();\n }\n };\n\n #materializeIfNeeded = () => {\n if (this.#view) {\n return;\n }\n\n this.#view = this.#query.materialize();\n this.#view.addListener(this.#onData);\n\n this.#onMaterialized(this);\n };\n\n getSnapshot = () => this.#snapshot;\n\n subscribeReactInternals = (internals: () => void): (() => void) => {\n this.#reactInternals.add(internals);\n this.#materializeIfNeeded();\n return () => {\n this.#reactInternals.delete(internals);\n\n // only schedule a cleanup task if we have no listeners left\n if (this.#reactInternals.size === 0) {\n setTimeout(() => {\n // Someone re-registered a listener on this view before the timeout elapsed.\n // This happens often in strict-mode which forces a component\n // to mount, unmount, remount.\n if (this.#reactInternals.size > 0) {\n return;\n }\n // We already destroyed the view\n if (this.#view === undefined) {\n return;\n }\n this.#view?.destroy();\n this.#view = undefined;\n this.#onDematerialized();\n }, 10);\n }\n };\n };\n}\n", "import {hasOwn} from './has-own.js';\nimport type {JSONValue, ReadonlyJSONValue} from './json.js';\n\nexport function deepClone(value: ReadonlyJSONValue): JSONValue {\n const seen: Array<ReadonlyJSONValue> = [];\n return internalDeepClone(value, seen);\n}\n\nexport function internalDeepClone(\n value: ReadonlyJSONValue,\n seen: Array<ReadonlyJSONValue>,\n): JSONValue {\n switch (typeof value) {\n case 'boolean':\n case 'number':\n case 'string':\n case 'undefined':\n return value;\n case 'object': {\n if (value === null) {\n return null;\n }\n if (seen.includes(value)) {\n throw new Error('Cyclic object');\n }\n seen.push(value);\n if (Array.isArray(value)) {\n const rv = value.map(v => internalDeepClone(v, seen));\n seen.pop();\n return rv;\n }\n\n const obj: JSONValue = {};\n\n for (const k in value) {\n if (hasOwn(value, k)) {\n const v = (value as Record<string, ReadonlyJSONValue>)[k];\n if (v !== undefined) {\n obj[k] = internalDeepClone(v, seen);\n }\n }\n }\n seen.pop();\n return obj;\n }\n\n default:\n throw new Error(`Invalid type: ${typeof value}`);\n }\n}\n", "import {createContext, useContext} from 'react';\nimport type {Zero} from '../../zero-client/src/mod.js';\nimport type {Schema} from '../../zero-schema/src/mod.js';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nconst ZeroContext = createContext<unknown | undefined>(undefined);\n\nexport function useZero<S extends Schema>(): Zero<S> {\n const zero = useContext(ZeroContext);\n if (zero === undefined) {\n throw new Error('useZero must be used within a ZeroProvider');\n }\n return zero as Zero<S>;\n}\n\nexport function createUseZero<S extends Schema>() {\n return () => useZero<S>();\n}\n\nexport function ZeroProvider<S extends Schema>({\n children,\n zero,\n}: {\n children: React.ReactNode;\n zero: Zero<S>;\n}) {\n return <ZeroContext.Provider value={zero}>{children}</ZeroContext.Provider>;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import {useSyncExternalStore} from 'react';\nimport {deepClone} from '../../shared/src/deep-clone.ts';\nimport type {Immutable} from '../../shared/src/immutable.ts';\nimport type {\n Query,\n ReadonlyJSONValue,\n Schema,\n TypedView,\n} from '../../zero-client/src/mod.ts';\nimport type {AdvancedQuery} from '../../zql/src/query/query-internal.ts';\nimport type {HumanReadable} from '../../zql/src/query/query.ts';\nimport type {ResultType} from '../../zql/src/query/typed-view.ts';\nimport {useZero} from './use-zero.tsx';\n\nexport type QueryResultDetails = Readonly<{\n type: ResultType;\n}>;\n\nexport type QueryResult<TReturn> = readonly [\n HumanReadable<TReturn>,\n QueryResultDetails,\n];\n\nexport function useQuery<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(\n q: Query<TSchema, TTable, TReturn>,\n enable: boolean = true,\n): QueryResult<TReturn> {\n const z = useZero();\n const view = viewStore.getView(\n z.clientID,\n q as AdvancedQuery<TSchema, TTable, TReturn>,\n enable && z.server !== null,\n );\n // https://react.dev/reference/react/useSyncExternalStore\n return useSyncExternalStore(\n view.subscribeReactInternals,\n view.getSnapshot,\n view.getSnapshot,\n );\n}\n\nconst emptyArray: unknown[] = [];\nconst disabledSubscriber = () => () => {};\n\nconst resultTypeUnknown = {type: 'unknown'} as const;\nconst resultTypeComplete = {type: 'complete'} as const;\n\nconst emptySnapshotSingularUnknown = [undefined, resultTypeUnknown] as const;\nconst emptySnapshotSingularComplete = [undefined, resultTypeComplete] as const;\nconst emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown] as const;\nconst emptySnapshotPluralComplete = [emptyArray, resultTypeComplete] as const;\n\nfunction getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TReturn> {\n return (\n singular ? emptySnapshotSingularUnknown : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n}\n\n/**\n * Returns a new snapshot or one of the empty predefined ones. Returning the\n * predefined ones is important to prevent unnecessary re-renders in React.\n */\nfunction getSnapshot<TReturn>(\n singular: boolean,\n data: HumanReadable<TReturn>,\n resultType: string,\n): QueryResult<TReturn> {\n if (singular && data === undefined) {\n return (resultType === 'complete'\n ? emptySnapshotSingularComplete\n : emptySnapshotSingularUnknown) as unknown as QueryResult<TReturn>;\n }\n\n if (!singular && (data as unknown[]).length === 0) {\n return (\n resultType === 'complete'\n ? emptySnapshotPluralComplete\n : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n }\n\n return [\n data,\n resultType === 'complete' ? resultTypeComplete : resultTypeUnknown,\n ];\n}\n\ndeclare const TESTING: boolean;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ViewWrapperAny = ViewWrapper<any, any, any>;\n\nconst allViews = new WeakMap<ViewStore, Map<string, ViewWrapperAny>>();\n\nexport function getAllViewsSizeForTesting(store: ViewStore): number {\n if (TESTING) {\n return allViews.get(store)?.size ?? 0;\n }\n return 0;\n}\n\n/**\n * A global store of all active views.\n *\n * React subscribes and unsubscribes to these views\n * via `useSyncExternalStore`.\n *\n * Managing views through `useEffect` or `useLayoutEffect` causes\n * inconsistencies because effects run after render.\n *\n * For example, if useQuery used use*Effect in the component below:\n * ```ts\n * function Foo({issueID}) {\n * const issue = useQuery(z.query.issue.where('id', issueID).one());\n * if (issue?.id !== undefined && issue.id !== issueID) {\n * console.log('MISMATCH!', issue.id, issueID);\n * }\n * }\n * ```\n *\n * `MISMATCH` will be printed whenever the `issueID` prop changes.\n *\n * This is because the component will render once with\n * the old state returned from `useQuery`. Then the effect inside\n * `useQuery` will run. The component will render again with the new\n * state. This inconsistent transition can cause unexpected results.\n *\n * Emulating `useEffect` via `useState` and `if` causes resource leaks.\n * That is:\n *\n * ```ts\n * function useQuery(q) {\n * const [oldHash, setOldHash] = useState();\n * if (hash(q) !== oldHash) {\n * // make new view\n * }\n *\n * useEffect(() => {\n * return () => view.destroy();\n * }, []);\n * }\n * ```\n *\n * I'm not sure why but in strict mode the cleanup function\n * fails to be called for the first instance of the view and only\n * cleans up later instances.\n *\n * Swapping `useState` to `useRef` has similar problems.\n */\nexport class ViewStore {\n #views = new Map<string, ViewWrapperAny>();\n\n constructor() {\n if (TESTING) {\n allViews.set(this, this.#views);\n }\n }\n\n getView<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n >(\n clientID: string,\n query: AdvancedQuery<TSchema, TTable, TReturn>,\n enabled: boolean,\n ): {\n getSnapshot: () => QueryResult<TReturn>;\n subscribeReactInternals: (internals: () => void) => () => void;\n } {\n if (!enabled) {\n return {\n getSnapshot: () => getDefaultSnapshot(query.format.singular),\n subscribeReactInternals: disabledSubscriber,\n };\n }\n\n const hash = query.hash() + clientID;\n let existing = this.#views.get(hash);\n if (!existing) {\n existing = new ViewWrapper(\n query,\n view => {\n const lastView = this.#views.get(hash);\n // I don't think this can happen\n // but lets guard against it so we don't\n // leak resources.\n if (lastView && lastView !== view) {\n throw new Error('View already exists');\n }\n this.#views.set(hash, view);\n },\n () => {\n this.#views.delete(hash);\n },\n ) as ViewWrapper<TSchema, TTable, TReturn>;\n this.#views.set(hash, existing);\n }\n return existing as ViewWrapper<TSchema, TTable, TReturn>;\n }\n}\n\nconst viewStore = new ViewStore();\n\n/**\n * This wraps and ref counts a view.\n *\n * The only signal we have from React as to whether or not it is\n * done with a view is when it calls `unsubscribe`.\n *\n * In non-strict-mode we can clean up the view as soon\n * as the listener count goes to 0.\n *\n * In strict-mode, the listener count will go to 0 then a\n * new listener for the same view is immediately added back.\n *\n * This is why the `onMaterialized` and `onDematerialized` callbacks exist --\n * they allow a view which React is still referencing to be added\n * back into the store when React re-subscribes to it.\n *\n * This wrapper also exists to deal with the various\n * `useSyncExternalStore` caveats that cause excessive\n * re-renders and materializations.\n *\n * See: https://react.dev/reference/react/useSyncExternalStore#caveats\n * Especially:\n * 1. The store snapshot returned by getSnapshot must be immutable. If the underlying store has mutable data, return a new immutable snapshot if the data has changed. Otherwise, return a cached last snapshot.\n * 2. If a different subscribe function is passed during a re-render, React will re-subscribe to the store using the newly passed subscribe function. You can prevent this by declaring subscribe outside the component.\n */\nclass ViewWrapper<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n> {\n #view: TypedView<HumanReadable<TReturn>> | undefined;\n readonly #onDematerialized;\n readonly #onMaterialized;\n readonly #query: AdvancedQuery<TSchema, TTable, TReturn>;\n #snapshot: QueryResult<TReturn>;\n #reactInternals: Set<() => void>;\n\n constructor(\n query: AdvancedQuery<TSchema, TTable, TReturn>,\n onMaterialized: (view: ViewWrapper<TSchema, TTable, TReturn>) => void,\n onDematerialized: () => void,\n ) {\n this.#snapshot = getDefaultSnapshot(query.format.singular);\n this.#onMaterialized = onMaterialized;\n this.#onDematerialized = onDematerialized;\n this.#reactInternals = new Set();\n this.#query = query;\n this.#materializeIfNeeded();\n }\n\n #onData = (\n snap: Immutable<HumanReadable<TReturn>>,\n resultType: ResultType,\n ) => {\n const data =\n snap === undefined\n ? snap\n : (deepClone(snap as ReadonlyJSONValue) as HumanReadable<TReturn>);\n this.#snapshot = getSnapshot(this.#query.format.singular, data, resultType);\n for (const internals of this.#reactInternals) {\n internals();\n }\n };\n\n #materializeIfNeeded = () => {\n if (this.#view) {\n return;\n }\n\n this.#view = this.#query.materialize();\n this.#view.addListener(this.#onData);\n\n this.#onMaterialized(this);\n };\n\n getSnapshot = () => this.#snapshot;\n\n subscribeReactInternals = (internals: () => void): (() => void) => {\n this.#reactInternals.add(internals);\n this.#materializeIfNeeded();\n return () => {\n this.#reactInternals.delete(internals);\n\n // only schedule a cleanup task if we have no listeners left\n if (this.#reactInternals.size === 0) {\n setTimeout(() => {\n // Someone re-registered a listener on this view before the timeout elapsed.\n // This happens often in strict-mode which forces a component\n // to mount, unmount, remount.\n if (this.#reactInternals.size > 0) {\n return;\n }\n // We already destroyed the view\n if (this.#view === undefined) {\n return;\n }\n this.#view?.destroy();\n this.#view = undefined;\n this.#onDematerialized();\n }, 10);\n }\n };\n };\n}\n", "import {hasOwn} from './has-own.ts';\nimport type {JSONValue, ReadonlyJSONValue} from './json.ts';\n\nexport function deepClone(value: ReadonlyJSONValue): JSONValue {\n const seen: Array<ReadonlyJSONValue> = [];\n return internalDeepClone(value, seen);\n}\n\nexport function internalDeepClone(\n value: ReadonlyJSONValue,\n seen: Array<ReadonlyJSONValue>,\n): JSONValue {\n switch (typeof value) {\n case 'boolean':\n case 'number':\n case 'string':\n case 'undefined':\n return value;\n case 'object': {\n if (value === null) {\n return null;\n }\n if (seen.includes(value)) {\n throw new Error('Cyclic object');\n }\n seen.push(value);\n if (Array.isArray(value)) {\n const rv = value.map(v => internalDeepClone(v, seen));\n seen.pop();\n return rv;\n }\n\n const obj: JSONValue = {};\n\n for (const k in value) {\n if (hasOwn(value, k)) {\n const v = (value as Record<string, ReadonlyJSONValue>)[k];\n if (v !== undefined) {\n obj[k] = internalDeepClone(v, seen);\n }\n }\n }\n seen.pop();\n return obj;\n }\n\n default:\n throw new Error(`Invalid type: ${typeof value}`);\n }\n}\n", "import {createContext, useContext} from 'react';\nimport type {Zero} from '../../zero-client/src/mod.ts';\nimport type {Schema} from '../../zero-schema/src/mod.ts';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nconst ZeroContext = createContext<unknown | undefined>(undefined);\n\nexport function useZero<S extends Schema>(): Zero<S> {\n const zero = useContext(ZeroContext);\n if (zero === undefined) {\n throw new Error('useZero must be used within a ZeroProvider');\n }\n return zero as Zero<S>;\n}\n\nexport function createUseZero<S extends Schema>() {\n return () => useZero<S>();\n}\n\nexport function ZeroProvider<S extends Schema>({\n children,\n zero,\n}: {\n children: React.ReactNode;\n zero: Zero<S>;\n}) {\n return <ZeroContext.Provider value={zero}>{children}</ZeroContext.Provider>;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;AAAA,SAAQ,4BAA2B;;;ACG5B,SAAS,UAAU,OAAqC;AAC7D,QAAM,OAAiC,CAAC;AACxC,SAAO,kBAAkB,OAAO,IAAI;AACtC;AAEO,SAAS,kBACd,OACA,MACW;AACX,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK,UAAU;AACb,UAAI,UAAU,MAAM;AAClB,eAAO;AAAA,MACT;AACA,UAAI,KAAK,SAAS,KAAK,GAAG;AACxB,cAAM,IAAI,MAAM,eAAe;AAAA,MACjC;AACA,WAAK,KAAK,KAAK;AACf,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAM,KAAK,MAAM,IAAI,OAAK,kBAAkB,GAAG,IAAI,CAAC;AACpD,aAAK,IAAI;AACT,eAAO;AAAA,MACT;AAEA,YAAM,MAAiB,CAAC;AAExB,iBAAW,KAAK,OAAO;AACrB,YAAI,OAAO,OAAO,CAAC,GAAG;AACpB,gBAAM,IAAK,MAA4C,CAAC;AACxD,cAAI,MAAM,QAAW;AACnB,gBAAI,CAAC,IAAI,kBAAkB,GAAG,IAAI;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AACA,WAAK,IAAI;AACT,aAAO;AAAA,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,UAAM,OACJ,SAAS,SACL,OACC,UAAU,IAAyB;AAC1C,SAAK,YAAY,YAAY,KAAK,OAAO,OAAO,UAAU,MAAM,UAAU;AAC1E,eAAW,aAAa,KAAK,iBAAiB;AAC5C,gBAAU;AAAA,IACZ;AAAA,EACF;AAAA,EAEA,uBAAuB,MAAM;AAC3B,QAAI,KAAK,OAAO;AACd;AAAA,IACF;AAEA,SAAK,QAAQ,KAAK,OAAO,YAAY;AACrC,SAAK,MAAM,YAAY,KAAK,OAAO;AAEnC,SAAK,gBAAgB,IAAI;AAAA,EAC3B;AAAA,EAEA,cAAc,MAAM,KAAK;AAAA,EAEzB,0BAA0B,CAAC,cAAwC;AACjE,SAAK,gBAAgB,IAAI,SAAS;AAClC,SAAK,qBAAqB;AAC1B,WAAO,MAAM;AACX,WAAK,gBAAgB,OAAO,SAAS;AAGrC,UAAI,KAAK,gBAAgB,SAAS,GAAG;AACnC,mBAAW,MAAM;AAIf,cAAI,KAAK,gBAAgB,OAAO,GAAG;AACjC;AAAA,UACF;AAEA,cAAI,KAAK,UAAU,QAAW;AAC5B;AAAA,UACF;AACA,eAAK,OAAO,QAAQ;AACpB,eAAK,QAAQ;AACb,eAAK,kBAAkB;AAAA,QACzB,GAAG,EAAE;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InternalDiff } from './node.
|
|
2
|
-
import type { BTreeRead } from './read.
|
|
1
|
+
import type { InternalDiff } from './node.ts';
|
|
2
|
+
import type { BTreeRead } from './read.ts';
|
|
3
3
|
export declare function diff(oldMap: BTreeRead, newMap: BTreeRead): Promise<InternalDiff>;
|
|
4
4
|
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Enum } from '../../../shared/src/enum.
|
|
2
|
-
import { type ReadonlyJSONValue } from '../../../shared/src/json.
|
|
3
|
-
import type { IndexKey } from '../db/index.
|
|
4
|
-
import * as FormatVersion from '../format-version-enum.
|
|
5
|
-
import { type FrozenJSONValue, type FrozenTag } from '../frozen-json.
|
|
6
|
-
import { type Hash } from '../hash.
|
|
7
|
-
import type { BTreeRead } from './read.
|
|
8
|
-
import type { BTreeWrite } from './write.
|
|
1
|
+
import type { Enum } from '../../../shared/src/enum.ts';
|
|
2
|
+
import { type ReadonlyJSONValue } from '../../../shared/src/json.ts';
|
|
3
|
+
import type { IndexKey } from '../db/index.ts';
|
|
4
|
+
import * as FormatVersion from '../format-version-enum.ts';
|
|
5
|
+
import { type FrozenJSONValue, type FrozenTag } from '../frozen-json.ts';
|
|
6
|
+
import { type Hash } from '../hash.ts';
|
|
7
|
+
import type { BTreeRead } from './read.ts';
|
|
8
|
+
import type { BTreeWrite } from './write.ts';
|
|
9
9
|
type FormatVersion = Enum<typeof FormatVersion>;
|
|
10
10
|
export type Entry<V> = readonly [key: string, value: V, sizeOfEntry: number];
|
|
11
11
|
export declare const NODE_LEVEL = 0;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Enum } from '../../../shared/src/enum.
|
|
2
|
-
import type { Read } from '../dag/store.
|
|
3
|
-
import * as FormatVersion from '../format-version-enum.
|
|
4
|
-
import type { FrozenJSONValue } from '../frozen-json.
|
|
5
|
-
import { type Hash } from '../hash.
|
|
6
|
-
import { DataNodeImpl, type Entry, type InternalDiff, type InternalDiffOperation, InternalNodeImpl } from './node.
|
|
1
|
+
import type { Enum } from '../../../shared/src/enum.ts';
|
|
2
|
+
import type { Read } from '../dag/store.ts';
|
|
3
|
+
import * as FormatVersion from '../format-version-enum.ts';
|
|
4
|
+
import type { FrozenJSONValue } from '../frozen-json.ts';
|
|
5
|
+
import { type Hash } from '../hash.ts';
|
|
6
|
+
import { DataNodeImpl, type Entry, type InternalDiff, type InternalDiffOperation, InternalNodeImpl } from './node.ts';
|
|
7
7
|
type FormatVersion = Enum<typeof FormatVersion>;
|
|
8
8
|
/**
|
|
9
9
|
* The size of the header of a node. (If we had compile time
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Enum } from '../../../shared/src/enum.
|
|
2
|
-
import type { Write } from '../dag/store.
|
|
3
|
-
import * as FormatVersion from '../format-version-enum.
|
|
4
|
-
import type { FrozenJSONValue } from '../frozen-json.
|
|
5
|
-
import { type Hash } from '../hash.
|
|
6
|
-
import { DataNodeImpl, type Entry, InternalNodeImpl } from './node.
|
|
7
|
-
import { BTreeRead } from './read.
|
|
1
|
+
import type { Enum } from '../../../shared/src/enum.ts';
|
|
2
|
+
import type { Write } from '../dag/store.ts';
|
|
3
|
+
import * as FormatVersion from '../format-version-enum.ts';
|
|
4
|
+
import type { FrozenJSONValue } from '../frozen-json.ts';
|
|
5
|
+
import { type Hash } from '../hash.ts';
|
|
6
|
+
import { DataNodeImpl, type Entry, InternalNodeImpl } from './node.ts';
|
|
7
|
+
import { BTreeRead } from './read.ts';
|
|
8
8
|
type FormatVersion = Enum<typeof FormatVersion>;
|
|
9
9
|
export declare class BTreeWrite extends BTreeRead {
|
|
10
10
|
#private;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ConnectionLoopDelegate } from './connection-loop.
|
|
2
|
-
import type { ReplicacheImpl } from './replicache-impl.
|
|
1
|
+
import type { ConnectionLoopDelegate } from './connection-loop.ts';
|
|
2
|
+
import type { ReplicacheImpl } from './replicache-impl.ts';
|
|
3
3
|
declare class ConnectionLoopDelegateImpl {
|
|
4
4
|
readonly rep: ReplicacheImpl;
|
|
5
5
|
readonly invokeSend: () => Promise<boolean>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LogContext } from '@rocicorp/logger';
|
|
2
|
-
import type { DocumentVisibilityWatcher } from '../../shared/src/document-visible.
|
|
2
|
+
import type { DocumentVisibilityWatcher } from '../../shared/src/document-visible.ts';
|
|
3
3
|
export declare const DEBOUNCE_DELAY_MS = 10;
|
|
4
4
|
export declare const MIN_DELAY_MS = 30;
|
|
5
5
|
export declare const MAX_DELAY_MS = 60000;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ReadonlyJSONValue } from '../../shared/src/json.
|
|
2
|
-
import type { FrozenJSONValue } from './frozen-json.
|
|
1
|
+
import { type ReadonlyJSONValue } from '../../shared/src/json.ts';
|
|
2
|
+
import type { FrozenJSONValue } from './frozen-json.ts';
|
|
3
3
|
/**
|
|
4
4
|
* A cookie is a value that is used to determine the order of snapshots. It
|
|
5
5
|
* needs to be comparable. This can be a `string`, `number` or if you want to
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MaybePromise } from '../../../shared/src/types.
|
|
2
|
-
import { type Hash } from '../hash.
|
|
1
|
+
import type { MaybePromise } from '../../../shared/src/types.ts';
|
|
2
|
+
import { type Hash } from '../hash.ts';
|
|
3
3
|
export type HeadChange = {
|
|
4
4
|
new: Hash | undefined;
|
|
5
5
|
old: Hash | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Hash } from '../hash.
|
|
2
|
-
import * as KeyType from './key-type-enum.
|
|
1
|
+
import { type Hash } from '../hash.ts';
|
|
2
|
+
import * as KeyType from './key-type-enum.ts';
|
|
3
3
|
export declare function chunkDataKey(hash: Hash): string;
|
|
4
4
|
export declare function chunkMetaKey(hash: Hash): string;
|
|
5
5
|
export declare function chunkRefCountKey(hash: Hash): string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { MaybePromise } from '../../../shared/src/types.
|
|
2
|
-
import type { Hash } from '../hash.
|
|
3
|
-
import { Chunk, type ChunkHasher, type Refs } from './chunk.
|
|
4
|
-
import { type HeadChange, type RefCountUpdatesDelegate } from './gc.
|
|
5
|
-
import { type Read, type Store, type Write } from './store.
|
|
1
|
+
import type { MaybePromise } from '../../../shared/src/types.ts';
|
|
2
|
+
import type { Hash } from '../hash.ts';
|
|
3
|
+
import { Chunk, type ChunkHasher, type Refs } from './chunk.ts';
|
|
4
|
+
import { type HeadChange, type RefCountUpdatesDelegate } from './gc.ts';
|
|
5
|
+
import { type Read, type Store, type Write } from './store.ts';
|
|
6
6
|
/**
|
|
7
7
|
* Dag Store which lazily loads values from a source store and then caches
|
|
8
8
|
* them in an LRU cache. The memory cache for chunks from the source store
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type Hash } from '../hash.
|
|
2
|
-
import type { Read as KVRead, Store as KVStore, Write as KVWrite } from '../kv/store.
|
|
3
|
-
import { Chunk, type ChunkHasher, type Refs } from './chunk.
|
|
4
|
-
import { type RefCountUpdatesDelegate } from './gc.
|
|
5
|
-
import { type Read, type Store, type Write } from './store.
|
|
1
|
+
import { type Hash } from '../hash.ts';
|
|
2
|
+
import type { Read as KVRead, Store as KVStore, Write as KVWrite } from '../kv/store.ts';
|
|
3
|
+
import { Chunk, type ChunkHasher, type Refs } from './chunk.ts';
|
|
4
|
+
import { type RefCountUpdatesDelegate } from './gc.ts';
|
|
5
|
+
import { type Read, type Store, type Write } from './store.ts';
|
|
6
6
|
export declare class StoreImpl implements Store {
|
|
7
7
|
#private;
|
|
8
8
|
constructor(kv: KVStore, chunkHasher: ChunkHasher, assertValidHash: (hash: Hash) => void);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Hash } from '../hash.
|
|
2
|
-
import type { Release } from '../with-transactions.
|
|
3
|
-
import type { Chunk, Refs } from './chunk.
|
|
1
|
+
import type { Hash } from '../hash.ts';
|
|
2
|
+
import type { Release } from '../with-transactions.ts';
|
|
3
|
+
import type { Chunk, Refs } from './chunk.ts';
|
|
4
4
|
export interface Store {
|
|
5
5
|
read(): Promise<Read>;
|
|
6
6
|
write(): Promise<Write>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Hash } from '../hash.
|
|
2
|
-
import type { Chunk } from './chunk.
|
|
3
|
-
import type { MustGetChunk } from './store.
|
|
1
|
+
import type { Hash } from '../hash.ts';
|
|
2
|
+
import type { Chunk } from './chunk.ts';
|
|
3
|
+
import type { MustGetChunk } from './store.ts';
|
|
4
4
|
/**
|
|
5
5
|
* A visitor walks the DAG starting at a given root and visits each chunk.
|
|
6
6
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type FrozenCookie } from '../cookies.
|
|
2
|
-
import { type Chunk, type CreateChunk, type Refs } from '../dag/chunk.
|
|
3
|
-
import { type MustGetChunk, type Read } from '../dag/store.
|
|
4
|
-
import { type FrozenJSONValue, type FrozenTag } from '../frozen-json.
|
|
5
|
-
import { type Hash } from '../hash.
|
|
6
|
-
import type { IndexDefinition } from '../index-defs.
|
|
7
|
-
import type { ClientID } from '../sync/ids.
|
|
8
|
-
import * as MetaType from './meta-type-enum.
|
|
1
|
+
import { type FrozenCookie } from '../cookies.ts';
|
|
2
|
+
import { type Chunk, type CreateChunk, type Refs } from '../dag/chunk.ts';
|
|
3
|
+
import { type MustGetChunk, type Read } from '../dag/store.ts';
|
|
4
|
+
import { type FrozenJSONValue, type FrozenTag } from '../frozen-json.ts';
|
|
5
|
+
import { type Hash } from '../hash.ts';
|
|
6
|
+
import type { IndexDefinition } from '../index-defs.ts';
|
|
7
|
+
import type { ClientID } from '../sync/ids.ts';
|
|
8
|
+
import * as MetaType from './meta-type-enum.ts';
|
|
9
9
|
export declare const DEFAULT_HEAD_NAME = "main";
|
|
10
10
|
export declare function commitIsLocalDD31(commit: Commit<Meta>): commit is Commit<LocalMetaDD31>;
|
|
11
11
|
export declare function commitIsLocal(commit: Commit<Meta>): commit is Commit<LocalMetaDD31>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { LogContext } from '@rocicorp/logger';
|
|
2
|
-
import type { Enum } from '../../../shared/src/enum.
|
|
3
|
-
import type { BTreeRead } from '../btree/read.
|
|
4
|
-
import type { BTreeWrite } from '../btree/write.
|
|
5
|
-
import type { FrozenJSONValue } from '../frozen-json.
|
|
6
|
-
import type { Hash } from '../hash.
|
|
7
|
-
import type { IndexRecord } from './commit.
|
|
8
|
-
import * as IndexOperation from './index-operation-enum.
|
|
2
|
+
import type { Enum } from '../../../shared/src/enum.ts';
|
|
3
|
+
import type { BTreeRead } from '../btree/read.ts';
|
|
4
|
+
import type { BTreeWrite } from '../btree/write.ts';
|
|
5
|
+
import type { FrozenJSONValue } from '../frozen-json.ts';
|
|
6
|
+
import type { Hash } from '../hash.ts';
|
|
7
|
+
import type { IndexRecord } from './commit.ts';
|
|
8
|
+
import * as IndexOperation from './index-operation-enum.ts';
|
|
9
9
|
type IndexOperation = Enum<typeof IndexOperation>;
|
|
10
10
|
export declare class IndexRead<BTree = BTreeRead> {
|
|
11
11
|
readonly meta: IndexRecord;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Enum } from '../../../shared/src/enum.
|
|
2
|
-
import { BTreeRead } from '../btree/read.
|
|
3
|
-
import type { Read as DagRead } from '../dag/store.
|
|
4
|
-
import * as FormatVersion from '../format-version-enum.
|
|
5
|
-
import type { FrozenJSONValue } from '../frozen-json.
|
|
6
|
-
import type { Hash } from '../hash.
|
|
7
|
-
import { Commit, type Meta } from './commit.
|
|
8
|
-
import { IndexRead } from './index.
|
|
1
|
+
import type { Enum } from '../../../shared/src/enum.ts';
|
|
2
|
+
import { BTreeRead } from '../btree/read.ts';
|
|
3
|
+
import type { Read as DagRead } from '../dag/store.ts';
|
|
4
|
+
import * as FormatVersion from '../format-version-enum.ts';
|
|
5
|
+
import type { FrozenJSONValue } from '../frozen-json.ts';
|
|
6
|
+
import type { Hash } from '../hash.ts';
|
|
7
|
+
import { Commit, type Meta } from './commit.ts';
|
|
8
|
+
import { IndexRead } from './index.ts';
|
|
9
9
|
type FormatVersion = Enum<typeof FormatVersion>;
|
|
10
10
|
export declare class Read {
|
|
11
11
|
#private;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { LogContext } from '@rocicorp/logger';
|
|
2
|
-
import type { Enum } from '../../../shared/src/enum.
|
|
3
|
-
import type { Write as DagWrite } from '../dag/store.
|
|
4
|
-
import * as FormatVersion from '../format-version-enum.
|
|
5
|
-
import type { Hash } from '../hash.
|
|
6
|
-
import type { ClientID } from '../sync/ids.
|
|
7
|
-
import type { MutatorDefs } from '../types.
|
|
8
|
-
import { Commit, type LocalMeta, type Meta } from './commit.
|
|
2
|
+
import type { Enum } from '../../../shared/src/enum.ts';
|
|
3
|
+
import type { Write as DagWrite } from '../dag/store.ts';
|
|
4
|
+
import * as FormatVersion from '../format-version-enum.ts';
|
|
5
|
+
import type { Hash } from '../hash.ts';
|
|
6
|
+
import type { ClientID } from '../sync/ids.ts';
|
|
7
|
+
import type { MutatorDefs } from '../types.ts';
|
|
8
|
+
import { Commit, type LocalMeta, type Meta } from './commit.ts';
|
|
9
9
|
type FormatVersion = Enum<typeof FormatVersion>;
|
|
10
10
|
export declare function rebaseMutationAndPutCommit(mutation: Commit<LocalMeta>, dagWrite: DagWrite, basis: Hash, mutators: MutatorDefs, lc: LogContext, mutationClientID: ClientID, formatVersion: FormatVersion): Promise<Commit<Meta>>;
|
|
11
11
|
export declare function rebaseMutationAndCommit(mutation: Commit<LocalMeta>, dagWrite: DagWrite, basis: Hash, headName: string, mutators: MutatorDefs, lc: LogContext, mutationClientID: ClientID, formatVersion: FormatVersion): Promise<Hash>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { LogContext } from '@rocicorp/logger';
|
|
2
|
-
import type { Enum } from '../../../shared/src/enum.
|
|
3
|
-
import { BTreeRead } from '../btree/read.
|
|
4
|
-
import { BTreeWrite } from '../btree/write.
|
|
5
|
-
import type { FrozenCookie } from '../cookies.
|
|
6
|
-
import type { Write as DagWrite } from '../dag/store.
|
|
7
|
-
import * as FormatVersion from '../format-version-enum.
|
|
8
|
-
import type { FrozenJSONValue } from '../frozen-json.
|
|
9
|
-
import { type Hash } from '../hash.
|
|
10
|
-
import type { DiffComputationConfig } from '../sync/diff.
|
|
11
|
-
import { DiffsMap } from '../sync/diff.
|
|
12
|
-
import type { ClientID } from '../sync/ids.
|
|
13
|
-
import { Commit, type Meta as CommitMeta } from './commit.
|
|
14
|
-
import { IndexWrite } from './index.
|
|
15
|
-
import { Read } from './read.
|
|
2
|
+
import type { Enum } from '../../../shared/src/enum.ts';
|
|
3
|
+
import { BTreeRead } from '../btree/read.ts';
|
|
4
|
+
import { BTreeWrite } from '../btree/write.ts';
|
|
5
|
+
import type { FrozenCookie } from '../cookies.ts';
|
|
6
|
+
import type { Write as DagWrite } from '../dag/store.ts';
|
|
7
|
+
import * as FormatVersion from '../format-version-enum.ts';
|
|
8
|
+
import type { FrozenJSONValue } from '../frozen-json.ts';
|
|
9
|
+
import { type Hash } from '../hash.ts';
|
|
10
|
+
import type { DiffComputationConfig } from '../sync/diff.ts';
|
|
11
|
+
import { DiffsMap } from '../sync/diff.ts';
|
|
12
|
+
import type { ClientID } from '../sync/ids.ts';
|
|
13
|
+
import { Commit, type Meta as CommitMeta } from './commit.ts';
|
|
14
|
+
import { IndexWrite } from './index.ts';
|
|
15
|
+
import { Read } from './read.ts';
|
|
16
16
|
type FormatVersion = Enum<typeof FormatVersion>;
|
|
17
17
|
export declare class Write extends Read {
|
|
18
18
|
#private;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Enum } from '../../shared/src/enum.
|
|
2
|
-
import * as FormatVersion from './format-version-enum.
|
|
1
|
+
import type { Enum } from '../../shared/src/enum.ts';
|
|
2
|
+
import * as FormatVersion from './format-version-enum.ts';
|
|
3
3
|
type FormatVersion = Enum<typeof FormatVersion>;
|
|
4
4
|
export declare function parseReplicacheFormatVersion(v: number): FormatVersion;
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ReadonlyJSONValue } from '../../shared/src/json.
|
|
2
|
-
import type { Cookie, FrozenCookie } from './cookies.
|
|
1
|
+
import type { ReadonlyJSONValue } from '../../shared/src/json.ts';
|
|
2
|
+
import type { Cookie, FrozenCookie } from './cookies.ts';
|
|
3
3
|
declare const frozenJSONTag: unique symbol;
|
|
4
4
|
/**
|
|
5
5
|
* Used to mark a type as having been frozen.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { PatchOperationInternal } from './patch-operation.
|
|
2
|
-
export { ReplicacheImpl, type ReplicacheImplOptions } from './replicache-impl.
|
|
3
|
-
export type { PokeInternal } from './types.
|
|
1
|
+
export type { PatchOperationInternal } from './patch-operation.ts';
|
|
2
|
+
export { ReplicacheImpl, type ReplicacheImplOptions } from './replicache-impl.ts';
|
|
3
|
+
export type { PokeInternal } from './types.ts';
|
|
4
4
|
//# sourceMappingURL=impl.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LogContext } from '@rocicorp/logger';
|
|
2
|
-
import type { Read, Store, Write } from './store.
|
|
2
|
+
import type { Read, Store, Write } from './store.ts';
|
|
3
3
|
/**
|
|
4
4
|
* This store uses an {@link IDBStore} by default. If the {@link IDBStore} fails
|
|
5
5
|
* to open the DB with an exception that matches
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idb-store.d.ts","sourceRoot":"","sources":["../../../../../replicache/src/kv/idb-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"idb-store.d.ts","sourceRoot":"","sources":["../../../../../replicache/src/kv/idb-store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,YAAY,CAAC;AAMnD,qBAAa,QAAS,YAAW,KAAK;;gBAKxB,IAAI,EAAE,MAAM;IAIxB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;IAIjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B,IAAI,MAAM,IAAI,OAAO,CAEpB;CAwDF;AA0GD;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,IAAI,SAAsB;CAC3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Read, Store, Write } from './store.
|
|
1
|
+
import type { Read, Store, Write } from './store.ts';
|
|
2
2
|
export declare function clearAllNamedMemStoresForTesting(): void;
|
|
3
3
|
export declare function dropMemStore(name: string): Promise<void>;
|
|
4
4
|
export declare function hasMemStore(name: string): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FrozenJSONValue } from '../frozen-json.
|
|
2
|
-
import type { Read } from './store.
|
|
1
|
+
import type { FrozenJSONValue } from '../frozen-json.ts';
|
|
2
|
+
import type { Read } from './store.ts';
|
|
3
3
|
export declare class ReadImpl implements Read {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(map: Map<string, FrozenJSONValue>, release: () => void);
|