@rocicorp/zero 1.10.0-canary.23 → 1.10.0-canary.25
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/analyze-query/src/bin-analyze.js +1 -1
- package/out/analyze-query/src/bin-analyze.js.map +1 -1
- package/out/replicache/src/btree/read.d.ts +1 -12
- package/out/replicache/src/btree/read.d.ts.map +1 -1
- package/out/replicache/src/btree/read.js +12 -24
- package/out/replicache/src/btree/read.js.map +1 -1
- package/out/replicache/src/dag/gc.d.ts.map +1 -1
- package/out/replicache/src/dag/gc.js +1 -2
- package/out/replicache/src/dag/gc.js.map +1 -1
- package/out/replicache/src/dag/store-impl.d.ts +2 -12
- package/out/replicache/src/dag/store-impl.d.ts.map +1 -1
- package/out/replicache/src/dag/store-impl.js +8 -22
- package/out/replicache/src/dag/store-impl.js.map +1 -1
- package/out/replicache/src/db/rebase.d.ts +2 -14
- package/out/replicache/src/db/rebase.d.ts.map +1 -1
- package/out/replicache/src/db/rebase.js +5 -27
- package/out/replicache/src/db/rebase.js.map +1 -1
- package/out/replicache/src/db/write.js.map +1 -1
- package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -1
- package/out/replicache/src/kv/expo-sqlite/store.js +5 -28
- package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts +5 -15
- package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts.map +1 -1
- package/out/replicache/src/kv/idb-store-with-mem-fallback.js +25 -25
- package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +1 -1
- package/out/replicache/src/kv/idb-store.d.ts +0 -9
- package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
- package/out/replicache/src/kv/idb-store.js +2 -14
- package/out/replicache/src/kv/idb-store.js.map +1 -1
- package/out/replicache/src/kv/mem-store.d.ts +0 -1
- package/out/replicache/src/kv/mem-store.d.ts.map +1 -1
- package/out/replicache/src/kv/mem-store.js +0 -3
- package/out/replicache/src/kv/mem-store.js.map +1 -1
- package/out/replicache/src/kv/op-sqlite/store.d.ts.map +1 -1
- package/out/replicache/src/kv/op-sqlite/store.js +1 -1
- package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
- package/out/replicache/src/kv/sqlite-store.d.ts +1 -13
- package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
- package/out/replicache/src/kv/sqlite-store.js +4 -49
- package/out/replicache/src/kv/sqlite-store.js.map +1 -1
- package/out/replicache/src/kv/store.d.ts +0 -6
- package/out/replicache/src/kv/store.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.d.ts +5 -10
- package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.js +9 -16
- package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
- package/out/replicache/src/persist/persist.d.ts.map +1 -1
- package/out/replicache/src/persist/persist.js +5 -12
- package/out/replicache/src/persist/persist.js.map +1 -1
- package/out/replicache/src/persist/refresh.js +2 -6
- package/out/replicache/src/persist/refresh.js.map +1 -1
- package/out/replicache/src/replicache-impl.d.ts +3 -14
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/replicache/src/replicache-impl.js +11 -118
- package/out/replicache/src/replicache-impl.js.map +1 -1
- package/out/replicache/src/replicache-options.d.ts +0 -9
- package/out/replicache/src/replicache-options.d.ts.map +1 -1
- package/out/replicache/src/transactions.d.ts.map +1 -1
- package/out/replicache/src/transactions.js +1 -1
- package/out/replicache/src/transactions.js.map +1 -1
- package/out/shared/src/arrays.js +15 -1
- package/out/shared/src/arrays.js.map +1 -1
- package/out/shared/src/base64.d.ts +19 -0
- package/out/shared/src/base64.d.ts.map +1 -0
- package/out/shared/src/base64.js +40 -0
- package/out/shared/src/base64.js.map +1 -0
- package/out/shared/src/error.d.ts +0 -11
- package/out/shared/src/error.d.ts.map +1 -1
- package/out/shared/src/error.js +1 -35
- package/out/shared/src/error.js.map +1 -1
- package/out/shared/src/hash.d.ts +0 -1
- package/out/shared/src/hash.d.ts.map +1 -1
- package/out/shared/src/hash.js +10 -87
- package/out/shared/src/hash.js.map +1 -1
- package/out/shared/src/iterables.d.ts +0 -2
- package/out/shared/src/iterables.d.ts.map +1 -1
- package/out/shared/src/iterables.js +1 -18
- package/out/shared/src/iterables.js.map +1 -1
- package/out/shared/src/json.d.ts.map +1 -1
- package/out/shared/src/json.js +2 -2
- package/out/shared/src/json.js.map +1 -1
- package/out/shared/src/map.d.ts +2 -7
- package/out/shared/src/map.d.ts.map +1 -1
- package/out/shared/src/map.js.map +1 -1
- package/out/shared/src/packed-boolean-map.d.ts +7 -0
- package/out/shared/src/packed-boolean-map.d.ts.map +1 -0
- package/out/shared/src/packed-boolean-map.js +36 -0
- package/out/shared/src/packed-boolean-map.js.map +1 -0
- package/out/shared/src/ring-buffer.d.ts +0 -8
- package/out/shared/src/ring-buffer.d.ts.map +1 -1
- package/out/shared/src/ring-buffer.js +1 -22
- package/out/shared/src/ring-buffer.js.map +1 -1
- package/out/z2s/src/compiler.js +1 -1
- package/out/zero/package.js +3 -2
- package/out/zero/package.js.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +2 -27
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +28 -114
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/custom-queries/transform-query.js +1 -1
- package/out/zero-cache/src/db/create.d.ts.map +1 -1
- package/out/zero-cache/src/db/create.js +1 -4
- package/out/zero-cache/src/db/create.js.map +1 -1
- package/out/zero-cache/src/db/lite-tables.d.ts +2 -10
- package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
- package/out/zero-cache/src/db/lite-tables.js +3 -8
- package/out/zero-cache/src/db/lite-tables.js.map +1 -1
- package/out/zero-cache/src/db/specs.d.ts +0 -41
- package/out/zero-cache/src/db/specs.d.ts.map +1 -1
- package/out/zero-cache/src/db/specs.js +3 -30
- package/out/zero-cache/src/db/specs.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +4 -13
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.d.ts +2 -18
- package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.js +9 -23
- package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
- package/out/zero-cache/src/server/main.d.ts.map +1 -1
- package/out/zero-cache/src/server/main.js +1 -8
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/mutator.js +0 -2
- package/out/zero-cache/src/server/mutator.js.map +1 -1
- package/out/zero-cache/src/server/reaper.d.ts.map +1 -1
- package/out/zero-cache/src/server/reaper.js +0 -2
- package/out/zero-cache/src/server/reaper.js.map +1 -1
- package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/server/replicator.js +2 -8
- package/out/zero-cache/src/server/replicator.js.map +1 -1
- package/out/zero-cache/src/server/runner/zero-dispatcher.d.ts.map +1 -1
- package/out/zero-cache/src/server/runner/zero-dispatcher.js +0 -3
- package/out/zero-cache/src/server/runner/zero-dispatcher.js.map +1 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +0 -2
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
- package/out/zero-cache/src/services/analyze.js +2 -3
- package/out/zero-cache/src/services/analyze.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/common/backfill-manager.js +1 -14
- package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
- package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js +3 -15
- package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +1 -11
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js +2 -21
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +0 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js +7 -8
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +229 -1513
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +2 -2
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +6 -15
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +20 -137
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.js +13 -82
- package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +21 -128
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +5 -5
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +0 -2
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +0 -3
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +0 -3
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +1 -3
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +0 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.js +3 -8
- package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
- package/out/zero-cache/src/services/litestream/config-v5.yml +1 -15
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +0 -5
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +1 -7
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts +87 -87
- package/out/zero-cache/src/services/mutagen/pusher.js +2 -3
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.js +16 -16
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js +0 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +2 -27
- package/out/zero-cache/src/services/replicator/write-worker-client.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker-client.js +2 -3
- package/out/zero-cache/src/services/replicator/write-worker-client.js.map +1 -1
- package/out/zero-cache/src/services/replicator/write-worker.js +5 -24
- package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
- package/out/zero-cache/src/services/run-ast.d.ts +0 -12
- package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
- package/out/zero-cache/src/services/run-ast.js +15 -27
- package/out/zero-cache/src/services/run-ast.js.map +1 -1
- package/out/zero-cache/src/services/runner.d.ts.map +1 -1
- package/out/zero-cache/src/services/runner.js +1 -1
- package/out/zero-cache/src/services/runner.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +0 -45
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +1 -133
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +1 -14
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +4 -30
- package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +1 -1
- package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js +2 -2
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +1 -2
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +18 -33
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/query-covering.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +1 -4
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js +3 -9
- package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +1 -11
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +90 -470
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/processes.d.ts +0 -32
- package/out/zero-cache/src/types/processes.d.ts.map +1 -1
- package/out/zero-cache/src/types/processes.js +4 -43
- package/out/zero-cache/src/types/processes.js.map +1 -1
- package/out/zero-cache/src/types/profiler.d.ts +0 -12
- package/out/zero-cache/src/types/profiler.d.ts.map +1 -1
- package/out/zero-cache/src/types/profiler.js +1 -46
- package/out/zero-cache/src/types/profiler.js.map +1 -1
- package/out/zero-cache/src/workers/connect-params.d.ts +17 -1
- package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connect-params.js +21 -1
- package/out/zero-cache/src/workers/connect-params.js.map +1 -1
- package/out/zero-cache/src/workers/connection.d.ts +4 -4
- package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connection.js +8 -8
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/replicator.d.ts +0 -1
- package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/workers/replicator.js +2 -4
- package/out/zero-cache/src/workers/replicator.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js +16 -21
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer.js +1 -10
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/connection-manager.d.ts +0 -20
- package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/connection-manager.js +13 -77
- package/out/zero-client/src/client/connection-manager.js.map +1 -1
- package/out/zero-client/src/client/connection-status-enum.d.ts +0 -2
- package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
- package/out/zero-client/src/client/connection-status-enum.js +1 -3
- package/out/zero-client/src/client/connection-status-enum.js.map +1 -1
- package/out/zero-client/src/client/connection.d.ts +0 -6
- package/out/zero-client/src/client/connection.d.ts.map +1 -1
- package/out/zero-client/src/client/connection.js +1 -2
- package/out/zero-client/src/client/connection.js.map +1 -1
- package/out/zero-client/src/client/context.d.ts +2 -27
- package/out/zero-client/src/client/context.d.ts.map +1 -1
- package/out/zero-client/src/client/context.js +1 -112
- package/out/zero-client/src/client/context.js.map +1 -1
- package/out/zero-client/src/client/custom.js +2 -2
- package/out/zero-client/src/client/custom.js.map +1 -1
- package/out/zero-client/src/client/error.js +1 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.js +2 -2
- package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
- package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
- package/out/zero-client/src/client/ivm-branch.js +3 -20
- package/out/zero-client/src/client/ivm-branch.js.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.js +1 -1
- package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
- package/out/zero-client/src/client/mutator-proxy.d.ts.map +1 -1
- package/out/zero-client/src/client/mutator-proxy.js +1 -2
- package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
- package/out/zero-client/src/client/options.d.ts +0 -3
- package/out/zero-client/src/client/options.d.ts.map +1 -1
- package/out/zero-client/src/client/options.js.map +1 -1
- package/out/zero-client/src/client/query-manager.d.ts +0 -2
- package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/query-manager.js +9 -48
- package/out/zero-client/src/client/query-manager.js.map +1 -1
- package/out/zero-client/src/client/version.js +1 -1
- package/out/zero-client/src/client/zero-rep.d.ts +0 -1
- package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
- package/out/zero-client/src/client/zero-rep.js +6 -9
- package/out/zero-client/src/client/zero-rep.js.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +3 -18
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +36 -123
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-client/src/types/query-result.d.ts +0 -2
- package/out/zero-client/src/types/query-result.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.d.ts +1 -64
- package/out/zero-protocol/src/ast.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.js +51 -223
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/connect.d.ts +16 -0
- package/out/zero-protocol/src/connect.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.js +27 -1
- package/out/zero-protocol/src/connect.js.map +1 -1
- package/out/zero-protocol/src/error.d.ts +1 -1
- package/out/zero-protocol/src/feature-flag-enum.d.ts +7 -0
- package/out/zero-protocol/src/feature-flag-enum.d.ts.map +1 -0
- package/out/zero-protocol/src/feature-flag-enum.js +7 -0
- package/out/zero-protocol/src/feature-flag-enum.js.map +1 -0
- package/out/zero-protocol/src/feature-flag.d.ts +5 -0
- package/out/zero-protocol/src/feature-flag.d.ts.map +1 -0
- package/out/zero-protocol/src/poke.d.ts +11 -4
- package/out/zero-protocol/src/poke.d.ts.map +1 -1
- package/out/zero-protocol/src/poke.js +3 -2
- package/out/zero-protocol/src/poke.js.map +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts +30 -6
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.js +1 -1
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/query-hash.d.ts +2 -7
- package/out/zero-protocol/src/query-hash.d.ts.map +1 -1
- package/out/zero-protocol/src/query-hash.js +9 -12
- package/out/zero-protocol/src/query-hash.js.map +1 -1
- package/out/zero-react/src/use-query.d.ts +4 -5
- package/out/zero-react/src/use-query.d.ts.map +1 -1
- package/out/zero-react/src/use-query.js +9 -86
- package/out/zero-react/src/use-query.js.map +1 -1
- package/out/zero-solid/src/solid-view.d.ts +0 -17
- package/out/zero-solid/src/solid-view.d.ts.map +1 -1
- package/out/zero-solid/src/solid-view.js +1 -39
- package/out/zero-solid/src/solid-view.js.map +1 -1
- package/out/zero-solid/src/use-query.js +3 -5
- package/out/zero-solid/src/use-query.js.map +1 -1
- package/out/zql/src/builder/debug-delegate.d.ts +1 -6
- package/out/zql/src/builder/debug-delegate.d.ts.map +1 -1
- package/out/zql/src/builder/debug-delegate.js +2 -14
- package/out/zql/src/builder/debug-delegate.js.map +1 -1
- package/out/zql/src/ivm/array-view.d.ts +0 -29
- package/out/zql/src/ivm/array-view.d.ts.map +1 -1
- package/out/zql/src/ivm/array-view.js +12 -63
- package/out/zql/src/ivm/array-view.js.map +1 -1
- package/out/zql/src/ivm/cap.d.ts.map +1 -1
- package/out/zql/src/ivm/cap.js +3 -5
- package/out/zql/src/ivm/cap.js.map +1 -1
- package/out/zql/src/ivm/data.d.ts.map +1 -1
- package/out/zql/src/ivm/data.js +3 -8
- package/out/zql/src/ivm/data.js.map +1 -1
- package/out/zql/src/ivm/exists.d.ts +1 -1
- package/out/zql/src/ivm/exists.d.ts.map +1 -1
- package/out/zql/src/ivm/exists.js +1 -1
- package/out/zql/src/ivm/exists.js.map +1 -1
- package/out/zql/src/ivm/fan-in.d.ts +2 -2
- package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-in.js +5 -6
- package/out/zql/src/ivm/fan-in.js.map +1 -1
- package/out/zql/src/ivm/fan-out.d.ts +2 -2
- package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-out.js.map +1 -1
- package/out/zql/src/ivm/filter-operators.d.ts +4 -4
- package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
- package/out/zql/src/ivm/filter-operators.js +8 -10
- package/out/zql/src/ivm/filter-operators.js.map +1 -1
- package/out/zql/src/ivm/filter.d.ts +2 -2
- package/out/zql/src/ivm/filter.d.ts.map +1 -1
- package/out/zql/src/ivm/filter.js +4 -7
- package/out/zql/src/ivm/filter.js.map +1 -1
- package/out/zql/src/ivm/flipped-join.js +2 -2
- package/out/zql/src/ivm/flipped-join.js.map +1 -1
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +1 -1
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +4 -6
- package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts +3 -15
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +19 -40
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/take.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +4 -3
- package/out/zql/src/ivm/take.js.map +1 -1
- package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/union-fan-in.js +7 -9
- package/out/zql/src/ivm/union-fan-in.js.map +1 -1
- package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
- package/out/zql/src/ivm/view-apply-change.js +4 -9
- package/out/zql/src/ivm/view-apply-change.js.map +1 -1
- package/out/zql/src/ivm/view.d.ts +0 -15
- package/out/zql/src/ivm/view.d.ts.map +1 -1
- package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
- package/out/zql/src/mutate/mutator-registry.js +2 -2
- package/out/zql/src/mutate/mutator-registry.js.map +1 -1
- package/out/zql/src/query/query-delegate-base.d.ts +1 -9
- package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
- package/out/zql/src/query/query-delegate-base.js +36 -132
- package/out/zql/src/query/query-delegate-base.js.map +1 -1
- package/out/zql/src/query/query-delegate.d.ts +1 -50
- package/out/zql/src/query/query-delegate.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +14 -25
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +94 -414
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query-internals.d.ts +11 -21
- package/out/zql/src/query/query-internals.d.ts.map +1 -1
- package/out/zql/src/query/query-internals.js.map +1 -1
- package/out/zql/src/query/query.d.ts +2 -11
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/runnable-query-impl.d.ts +2 -3
- package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
- package/out/zql/src/query/runnable-query-impl.js +2 -23
- package/out/zql/src/query/runnable-query-impl.js.map +1 -1
- package/out/zql/src/query/typed-view.d.ts +1 -1
- package/out/zql/src/query/typed-view.d.ts.map +1 -1
- package/out/zqlite/src/db.d.ts +1 -9
- package/out/zqlite/src/db.d.ts.map +1 -1
- package/out/zqlite/src/db.js +2 -8
- package/out/zqlite/src/db.js.map +1 -1
- package/out/zqlite/src/query-builder.d.ts.map +1 -1
- package/out/zqlite/src/query-builder.js +1 -2
- package/out/zqlite/src/query-builder.js.map +1 -1
- package/out/zqlite/src/sqlite-stat-fanout.d.ts.map +1 -1
- package/out/zqlite/src/sqlite-stat-fanout.js +0 -1
- package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts +1 -2
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +6 -12
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +3 -2
- package/out/replicache/src/dag/invalid-ref-count-error.d.ts +0 -12
- package/out/replicache/src/dag/invalid-ref-count-error.d.ts.map +0 -1
- package/out/replicache/src/dag/invalid-ref-count-error.js +0 -19
- package/out/replicache/src/dag/invalid-ref-count-error.js.map +0 -1
- package/out/shared/src/xxhash32.d.ts +0 -36
- package/out/shared/src/xxhash32.d.ts.map +0 -1
- package/out/shared/src/xxhash32.js +0 -51
- package/out/shared/src/xxhash32.js.map +0 -1
- package/out/zero-cache/src/db/index-predicate.d.ts +0 -4
- package/out/zero-cache/src/db/index-predicate.d.ts.map +0 -1
- package/out/zero-cache/src/db/index-predicate.js +0 -46
- package/out/zero-cache/src/db/index-predicate.js.map +0 -1
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts +0 -19
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts.map +0 -1
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js +0 -581
- package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js.map +0 -1
- package/out/zero-cache/src/services/litestream/litestream-checkpointer.js +0 -131
- package/out/zero-cache/src/services/litestream/litestream-checkpointer.js.map +0 -1
- package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +0 -70
- package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +0 -1
- package/out/zero-cache/src/services/litestream/litestream-controller.js +0 -101
- package/out/zero-cache/src/services/litestream/litestream-controller.js.map +0 -1
- package/out/zero-cache/src/services/profz.d.ts +0 -7
- package/out/zero-cache/src/services/profz.d.ts.map +0 -1
- package/out/zero-cache/src/services/profz.js +0 -103
- package/out/zero-cache/src/services/profz.js.map +0 -1
- package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts +0 -33
- package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts.map +0 -1
- package/out/zero-cache/src/services/view-syncer/hydration-budget.js +0 -62
- package/out/zero-cache/src/services/view-syncer/hydration-budget.js.map +0 -1
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts +0 -51
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts.map +0 -1
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js +0 -78
- package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js.map +0 -1
- package/out/zero-protocol/src/query-hash-visitor.d.ts +0 -81
- package/out/zero-protocol/src/query-hash-visitor.d.ts.map +0 -1
- package/out/zero-protocol/src/query-hash-visitor.js +0 -324
- package/out/zero-protocol/src/query-hash-visitor.js.map +0 -1
- package/out/zql/src/ivm/deferred-input.d.ts +0 -44
- package/out/zql/src/ivm/deferred-input.d.ts.map +0 -1
- package/out/zql/src/ivm/deferred-input.js +0 -89
- package/out/zql/src/ivm/deferred-input.js.map +0 -1
- package/out/zql/src/query/query-transitions.d.ts +0 -171
- package/out/zql/src/query/query-transitions.d.ts.map +0 -1
- package/out/zql/src/query/query-transitions.js +0 -207
- package/out/zql/src/query/query-transitions.js.map +0 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { valita_exports } from "../../shared/src/valita.js";
|
|
2
2
|
import { clientSchemaSchema } from "./client-schema.js";
|
|
3
|
+
import { fromBase64url, toBase64url } from "../../shared/src/base64.js";
|
|
4
|
+
import { packBooleanMap, unpackBooleanMap } from "../../shared/src/packed-boolean-map.js";
|
|
3
5
|
import { deleteClientsBodySchema } from "./delete-clients.js";
|
|
6
|
+
import { feature_flag_enum_exports } from "./feature-flag-enum.js";
|
|
4
7
|
import { upQueriesPatchSchema } from "./queries-patch.js";
|
|
5
8
|
//#region ../zero-protocol/src/connect.ts
|
|
6
9
|
/**
|
|
@@ -34,6 +37,29 @@ var initConnectionBodySchema = valita_exports.object({
|
|
|
34
37
|
traceparent: valita_exports.string().optional()
|
|
35
38
|
});
|
|
36
39
|
var initConnectionMessageSchema = valita_exports.tuple([valita_exports.literal("initConnection"), initConnectionBodySchema]);
|
|
40
|
+
var FEATURE_FLAGS_PARAM = "f";
|
|
41
|
+
/**
|
|
42
|
+
* Adds the client's feature flags to the connect URL: every flag this client
|
|
43
|
+
* knows, turned on.
|
|
44
|
+
*/
|
|
45
|
+
function setFeatureFlags(params) {
|
|
46
|
+
const flags = new Map(Object.values(feature_flag_enum_exports).map((flag) => [flag, true]));
|
|
47
|
+
params.set(FEATURE_FLAGS_PARAM, toBase64url(packBooleanMap(flags)));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reads the feature flags a client sent in the connect URL. Flags this server
|
|
51
|
+
* doesn't know are dropped, and a malformed value counts as no flags, so newer
|
|
52
|
+
* clients can always connect.
|
|
53
|
+
*/
|
|
54
|
+
function getFeatureFlags(params) {
|
|
55
|
+
let bytes;
|
|
56
|
+
try {
|
|
57
|
+
bytes = fromBase64url(params.get(FEATURE_FLAGS_PARAM) ?? "");
|
|
58
|
+
} catch {
|
|
59
|
+
return /* @__PURE__ */ new Map();
|
|
60
|
+
}
|
|
61
|
+
return unpackBooleanMap(bytes, Object.values(feature_flag_enum_exports));
|
|
62
|
+
}
|
|
37
63
|
function encodeSecProtocols(initConnectionMessage, authToken) {
|
|
38
64
|
const protocols = {
|
|
39
65
|
initConnectionMessage,
|
|
@@ -49,6 +75,6 @@ function decodeSecProtocols(secProtocol) {
|
|
|
49
75
|
return JSON.parse(new TextDecoder().decode(bytes));
|
|
50
76
|
}
|
|
51
77
|
//#endregion
|
|
52
|
-
export { connectedMessageSchema, decodeSecProtocols, encodeSecProtocols, initConnectionMessageSchema };
|
|
78
|
+
export { connectedMessageSchema, decodeSecProtocols, encodeSecProtocols, getFeatureFlags, initConnectionMessageSchema, setFeatureFlags };
|
|
53
79
|
|
|
54
80
|
//# sourceMappingURL=connect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","names":[],"sources":["../../../../zero-protocol/src/connect.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {clientSchemaSchema} from './client-schema.ts';\nimport {deleteClientsBodySchema} from './delete-clients.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\n/**\n * After opening a websocket the client waits for a `connected` message\n * from the server. It then sends an `initConnection` message to the\n * server. The server waits for the `initConnection` message before\n * beginning to send pokes to the newly connected client, so as to avoid\n * syncing lots of queries which are no longer desired by the client.\n */\n\nexport const connectedBodySchema = v.object({\n wsid: v.string(),\n timestamp: v.number().optional(),\n});\n\nexport const connectedMessageSchema = v.tuple([\n v.literal('connected'),\n connectedBodySchema,\n]);\n\nconst initConnectionBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n // As the schema can be large, client only sends when it does not have a\n // server snapshot (i.e. a snapshot with a cookie). Once it has a server\n // snapshot it will assume the zero-cache already has the schema for this\n // client's client group in the CVR store.\n clientSchema: clientSchemaSchema.optional(),\n deleted: deleteClientsBodySchema.optional(),\n // parameters to configure the mutate endpoint\n userPushURL: v.string().optional(),\n userPushHeaders: v.record(v.string()).optional(),\n // parameters to configure the query endpoint\n userQueryURL: v.string().optional(),\n userQueryHeaders: v.record(v.string()).optional(),\n\n /**\n * `activeClients` is an optional array of client IDs that are currently active\n * in the client group. This is used to inform the server about the clients\n * that are currently active (aka running, aka alive), so it can inactive\n * queries from inactive clients.\n */\n activeClients: v.array(v.string()).optional(),\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const initConnectionMessageSchema = v.tuple([\n v.literal('initConnection'),\n initConnectionBodySchema,\n]);\n\nexport type ConnectedBody = v.Infer<typeof connectedBodySchema>;\nexport type ConnectedMessage = v.Infer<typeof connectedMessageSchema>;\nexport type InitConnectionBody = v.Infer<typeof initConnectionBodySchema>;\nexport type InitConnectionMessage = v.Infer<typeof initConnectionMessageSchema>;\n\nexport function encodeSecProtocols(\n initConnectionMessage: InitConnectionMessage | undefined,\n authToken: string | undefined,\n): string {\n const protocols = {\n initConnectionMessage,\n authToken,\n };\n // WS sec protocols needs to be URI encoded. To save space, we base64 encode\n // the JSON before URI encoding it. But InitConnectionMessage can contain\n // arbitrary unicode strings, so we need to encode the JSON as UTF-8 first.\n // Phew!\n const bytes = new TextEncoder().encode(JSON.stringify(protocols));\n\n // Convert bytes to string without spreading all bytes as arguments\n // to avoid \"Maximum call stack size exceeded\" error with large data\n const s = Array.from(bytes, byte => String.fromCharCode(byte)).join('');\n\n return encodeURIComponent(btoa(s));\n}\n\nexport function decodeSecProtocols(secProtocol: string): {\n initConnectionMessage: InitConnectionMessage | undefined;\n authToken: string | undefined;\n} {\n const binString = atob(decodeURIComponent(secProtocol));\n const bytes = Uint8Array.from(binString, c => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.js","names":[],"sources":["../../../../zero-protocol/src/connect.ts"],"sourcesContent":["import {fromBase64url, toBase64url} from '../../shared/src/base64.ts';\nimport {\n packBooleanMap,\n unpackBooleanMap,\n} from '../../shared/src/packed-boolean-map.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport {clientSchemaSchema} from './client-schema.ts';\nimport {deleteClientsBodySchema} from './delete-clients.ts';\nimport {FeatureFlag} from './feature-flag.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\n/**\n * After opening a websocket the client waits for a `connected` message\n * from the server. It then sends an `initConnection` message to the\n * server. The server waits for the `initConnection` message before\n * beginning to send pokes to the newly connected client, so as to avoid\n * syncing lots of queries which are no longer desired by the client.\n */\n\nexport const connectedBodySchema = v.object({\n wsid: v.string(),\n timestamp: v.number().optional(),\n});\n\nexport const connectedMessageSchema = v.tuple([\n v.literal('connected'),\n connectedBodySchema,\n]);\n\nconst initConnectionBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n // As the schema can be large, client only sends when it does not have a\n // server snapshot (i.e. a snapshot with a cookie). Once it has a server\n // snapshot it will assume the zero-cache already has the schema for this\n // client's client group in the CVR store.\n clientSchema: clientSchemaSchema.optional(),\n deleted: deleteClientsBodySchema.optional(),\n // parameters to configure the mutate endpoint\n userPushURL: v.string().optional(),\n userPushHeaders: v.record(v.string()).optional(),\n // parameters to configure the query endpoint\n userQueryURL: v.string().optional(),\n userQueryHeaders: v.record(v.string()).optional(),\n\n /**\n * `activeClients` is an optional array of client IDs that are currently active\n * in the client group. This is used to inform the server about the clients\n * that are currently active (aka running, aka alive), so it can inactive\n * queries from inactive clients.\n */\n activeClients: v.array(v.string()).optional(),\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const initConnectionMessageSchema = v.tuple([\n v.literal('initConnection'),\n initConnectionBodySchema,\n]);\n\nexport type ConnectedBody = v.Infer<typeof connectedBodySchema>;\nexport type ConnectedMessage = v.Infer<typeof connectedMessageSchema>;\nexport type InitConnectionBody = v.Infer<typeof initConnectionBodySchema>;\nexport type InitConnectionMessage = v.Infer<typeof initConnectionMessageSchema>;\n\n/**\n * The feature flags a client sent. A missing flag means the server's default.\n */\nexport type FeatureFlags = ReadonlyMap<FeatureFlag, boolean>;\n\n// The connect URL parameter that carries the feature flags: a byte array with\n// two bits per flag, the low bit saying the client sent the flag and the high\n// bit its value (see packed-boolean-map.ts), in unpadded base64url.\nconst FEATURE_FLAGS_PARAM = 'f';\n\n/**\n * Adds the client's feature flags to the connect URL: every flag this client\n * knows, turned on.\n */\nexport function setFeatureFlags(params: URLSearchParams): void {\n const flags = new Map(Object.values(FeatureFlag).map(flag => [flag, true]));\n params.set(FEATURE_FLAGS_PARAM, toBase64url(packBooleanMap(flags)));\n}\n\n/**\n * Reads the feature flags a client sent in the connect URL. Flags this server\n * doesn't know are dropped, and a malformed value counts as no flags, so newer\n * clients can always connect.\n */\nexport function getFeatureFlags(params: URLSearchParams): FeatureFlags {\n let bytes: Uint8Array;\n try {\n bytes = fromBase64url(params.get(FEATURE_FLAGS_PARAM) ?? '');\n } catch {\n return new Map();\n }\n return unpackBooleanMap(bytes, Object.values(FeatureFlag));\n}\n\nexport function encodeSecProtocols(\n initConnectionMessage: InitConnectionMessage | undefined,\n authToken: string | undefined,\n): string {\n const protocols = {\n initConnectionMessage,\n authToken,\n };\n // WS sec protocols needs to be URI encoded. To save space, we base64 encode\n // the JSON before URI encoding it. But InitConnectionMessage can contain\n // arbitrary unicode strings, so we need to encode the JSON as UTF-8 first.\n // Phew!\n const bytes = new TextEncoder().encode(JSON.stringify(protocols));\n\n // Convert bytes to string without spreading all bytes as arguments\n // to avoid \"Maximum call stack size exceeded\" error with large data\n const s = Array.from(bytes, byte => String.fromCharCode(byte)).join('');\n\n return encodeURIComponent(btoa(s));\n}\n\nexport function decodeSecProtocols(secProtocol: string): {\n initConnectionMessage: InitConnectionMessage | undefined;\n authToken: string | undefined;\n} {\n const binString = atob(decodeURIComponent(secProtocol));\n const bytes = Uint8Array.from(binString, c => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,IAAa,sBAAsB,eAAE,OAAO;CAC1C,MAAM,eAAE,OAAO;CACf,WAAW,eAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAED,IAAa,yBAAyB,eAAE,MAAM,CAC5C,eAAE,QAAQ,WAAW,GACrB,mBACF,CAAC;AAED,IAAM,2BAA2B,eAAE,OAAO;CACxC,qBAAqB;CAKrB,cAAc,mBAAmB,SAAS;CAC1C,SAAS,wBAAwB,SAAS;CAE1C,aAAa,eAAE,OAAO,EAAE,SAAS;CACjC,iBAAiB,eAAE,OAAO,eAAE,OAAO,CAAC,EAAE,SAAS;CAE/C,cAAc,eAAE,OAAO,EAAE,SAAS;CAClC,kBAAkB,eAAE,OAAO,eAAE,OAAO,CAAC,EAAE,SAAS;;;;;;;CAQhD,eAAe,eAAE,MAAM,eAAE,OAAO,CAAC,EAAE,SAAS;;CAE5C,aAAa,eAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AAED,IAAa,8BAA8B,eAAE,MAAM,CACjD,eAAE,QAAQ,gBAAgB,GAC1B,wBACF,CAAC;AAeD,IAAM,sBAAsB;;;;;AAM5B,SAAgB,gBAAgB,QAA+B;CAC7D,MAAM,QAAQ,IAAI,IAAI,OAAO,OAAO,yBAAW,EAAE,KAAI,SAAQ,CAAC,MAAM,IAAI,CAAC,CAAC;CAC1E,OAAO,IAAI,qBAAqB,YAAY,eAAe,KAAK,CAAC,CAAC;AACpE;;;;;;AAOA,SAAgB,gBAAgB,QAAuC;CACrE,IAAI;CACJ,IAAI;EACF,QAAQ,cAAc,OAAO,IAAI,mBAAmB,KAAK,EAAE;CAC7D,QAAQ;EACN,uBAAO,IAAI,IAAI;CACjB;CACA,OAAO,iBAAiB,OAAO,OAAO,OAAO,yBAAW,CAAC;AAC3D;AAEA,SAAgB,mBACd,uBACA,WACQ;CACR,MAAM,YAAY;EAChB;EACA;CACF;CAKA,MAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,KAAK,UAAU,SAAS,CAAC;CAIhE,MAAM,IAAI,MAAM,KAAK,QAAO,SAAQ,OAAO,aAAa,IAAI,CAAC,EAAE,KAAK,EAAE;CAEtE,OAAO,mBAAmB,KAAK,CAAC,CAAC;AACnC;AAEA,SAAgB,mBAAmB,aAGjC;CACA,MAAM,YAAY,KAAK,mBAAmB,WAAW,CAAC;CACtD,MAAM,QAAQ,WAAW,KAAK,YAAW,MAAK,EAAE,WAAW,CAAC,CAAC;CAC7D,OAAO,KAAK,MAAM,IAAI,YAAY,EAAE,OAAO,KAAK,CAAC;AACnD"}
|
|
@@ -94,7 +94,7 @@ export declare const transformFailedBodySchema: v.UnionType<[v.ObjectType<Omit<{
|
|
|
94
94
|
reason: v.Type<"parse" | "timeout" | "internal">;
|
|
95
95
|
}, undefined>]>;
|
|
96
96
|
export declare const errorBodySchema: v.UnionType<[v.ObjectType<{
|
|
97
|
-
kind: v.Type<"
|
|
97
|
+
kind: v.Type<"AuthInvalidated" | "ClientNotFound" | "InvalidConnectionRequest" | "InvalidConnectionRequestBaseCookie" | "InvalidConnectionRequestLastMutationID" | "InvalidConnectionRequestClientDeleted" | "InvalidMessage" | "InvalidPush" | "MutationFailed" | "MutationRateLimited" | "Unauthorized" | "VersionNotSupported" | "SchemaVersionNotSupported" | "Internal">;
|
|
98
98
|
message: v.Type<string>;
|
|
99
99
|
origin: v.Optional<"server" | "zeroCache">;
|
|
100
100
|
}, undefined>, v.ObjectType<{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flag-enum.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/feature-flag-enum.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region ../zero-protocol/src/feature-flag-enum.ts
|
|
3
|
+
var feature_flag_enum_exports = /* @__PURE__ */ __exportAll({ PokeChunk: () => 0 });
|
|
4
|
+
//#endregion
|
|
5
|
+
export { feature_flag_enum_exports };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=feature-flag-enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flag-enum.js","names":[],"sources":["../../../../zero-protocol/src/feature-flag-enum.ts"],"sourcesContent":["// Feature flags let a client ask for behavior that an older server can\n// ignore, without raising CLIENT_PROTOCOL_VERSION (see protocol-version.ts).\n//\n// The client sends its flags in one connect URL parameter (setFeatureFlags in\n// connect.ts). A flag the client doesn't send means the server's default. A\n// server ignores flags it doesn't know, so the client must keep supporting the\n// old behavior.\n//\n// The numbers are part of the wire protocol: they are bit positions in that\n// parameter. Never change a flag's number, and never reuse the number of a\n// retired flag.\n\n/**\n * Binary poke chunks instead of JSON `pokePart` messages. Defaults to on for\n * clients at protocol version 52 or above.\n */\nexport const PokeChunk = 0;\n\nexport type PokeChunk = typeof PokeChunk;\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flag.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/feature-flag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAC,eAAe,IAAI,WAAW,EAAC,CAAC;AACxC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -12,8 +12,9 @@ import * as v from '../../shared/src/valita.ts';
|
|
|
12
12
|
* the poke is updating from and the `cookie` the poke is updating to.
|
|
13
13
|
*
|
|
14
14
|
* Through protocol version 51, the poke continues with zero to many
|
|
15
|
-
* `poke-part` JSON messages. Starting in version 52,
|
|
16
|
-
*
|
|
15
|
+
* `poke-part` JSON messages. Starting in version 52, or when the client sends
|
|
16
|
+
* the `PokeChunk` feature flag, it continues with zero to many binary
|
|
17
|
+
* `pokeChunk` messages instead. Each binary message starts with a message
|
|
17
18
|
* type byte. Concatenating and decoding the payload after that byte produces a
|
|
18
19
|
* PokePartBody array. pokeChunk boundaries have no semantic meaning.
|
|
19
20
|
*
|
|
@@ -270,9 +271,15 @@ export type PokeParts = v.Infer<typeof pokePartsSchema>;
|
|
|
270
271
|
export type PokeEndBody = v.Infer<typeof pokeEndBodySchema>;
|
|
271
272
|
/** The first byte identifying a binary WebSocket message as a poke chunk. */
|
|
272
273
|
export declare const POKE_CHUNK_MESSAGE_TYPE = 0;
|
|
273
|
-
/**
|
|
274
|
+
/**
|
|
275
|
+
* The first protocol version that receives binary poke chunks without the
|
|
276
|
+
* `PokeChunk` feature flag.
|
|
277
|
+
*/
|
|
274
278
|
export declare const POKE_CHUNK_PROTOCOL_VERSION = 52;
|
|
275
|
-
/**
|
|
279
|
+
/**
|
|
280
|
+
* The last protocol version that receives JSON pokePart messages unless the
|
|
281
|
+
* client sends the `PokeChunk` feature flag.
|
|
282
|
+
*/
|
|
276
283
|
export declare const LAST_POKE_PART_PROTOCOL_VERSION = 51;
|
|
277
284
|
/** A tagged binary poke chunk WebSocket message. */
|
|
278
285
|
export type PokeChunk = Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poke.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/poke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAMhD
|
|
1
|
+
{"version":3,"file":"poke.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/poke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAMhD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,mBAAmB;;;IAM9B;;;OAGG;;;;;;aAQH,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAa7B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA8B,CAAC;AAE3D,eAAO,MAAM,iBAAiB;;;;aAO5B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;IA5CjC;;;OAGG;;;;;;eA4CH,CAAC;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAGhC,CAAC;AACH,eAAO,MAAM,oBAAoB;;;;eAG/B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,IAAO,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD,oDAAoD;AACpD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AAEnC,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -17,8 +17,9 @@ import { nullableVersionSchema, versionSchema } from "./version.js";
|
|
|
17
17
|
* the poke is updating from and the `cookie` the poke is updating to.
|
|
18
18
|
*
|
|
19
19
|
* Through protocol version 51, the poke continues with zero to many
|
|
20
|
-
* `poke-part` JSON messages. Starting in version 52,
|
|
21
|
-
*
|
|
20
|
+
* `poke-part` JSON messages. Starting in version 52, or when the client sends
|
|
21
|
+
* the `PokeChunk` feature flag, it continues with zero to many binary
|
|
22
|
+
* `pokeChunk` messages instead. Each binary message starts with a message
|
|
22
23
|
* type byte. Concatenating and decoding the payload after that byte produces a
|
|
23
24
|
* PokePartBody array. pokeChunk boundaries have no semantic meaning.
|
|
24
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poke.js","names":[],"sources":["../../../../zero-protocol/src/poke.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {mutationsPatchSchema} from './mutations-patch.ts';\nimport {queriesPatchSchema} from './queries-patch.ts';\nimport {rowsPatchSchema} from './row-patch.ts';\nimport {nullableVersionSchema, versionSchema} from './version.ts';\n\n/**\n * Pokes use a multi-part format. Pokes send entity data to the client and can\n * be multiple mega-bytes in size. Using a multi-part format allows the server\n * to avoid having to have the full poke in memory at one time.\n *\n * Each poke is assigned a `pokeID`, a unique id (within the context of the\n * connection) for identifying the poke. All messages for a poke will have the\n * same `pokeID`.\n *\n * A poke begins with a `poke-start` message which contains the `baseCookie`\n * the poke is updating from and the `cookie` the poke is updating to.\n *\n * Through protocol version 51, the poke continues with zero to many\n * `poke-part` JSON messages. Starting in version 52, it continues with zero to\n *
|
|
1
|
+
{"version":3,"file":"poke.js","names":[],"sources":["../../../../zero-protocol/src/poke.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {mutationsPatchSchema} from './mutations-patch.ts';\nimport {queriesPatchSchema} from './queries-patch.ts';\nimport {rowsPatchSchema} from './row-patch.ts';\nimport {nullableVersionSchema, versionSchema} from './version.ts';\n\n/**\n * Pokes use a multi-part format. Pokes send entity data to the client and can\n * be multiple mega-bytes in size. Using a multi-part format allows the server\n * to avoid having to have the full poke in memory at one time.\n *\n * Each poke is assigned a `pokeID`, a unique id (within the context of the\n * connection) for identifying the poke. All messages for a poke will have the\n * same `pokeID`.\n *\n * A poke begins with a `poke-start` message which contains the `baseCookie`\n * the poke is updating from and the `cookie` the poke is updating to.\n *\n * Through protocol version 51, the poke continues with zero to many\n * `poke-part` JSON messages. Starting in version 52, or when the client sends\n * the `PokeChunk` feature flag, it continues with zero to many binary\n * `pokeChunk` messages instead. Each binary message starts with a message\n * type byte. Concatenating and decoding the payload after that byte produces a\n * PokePartBody array. pokeChunk boundaries have no semantic meaning.\n *\n * Finally, the poke ends with a `poke-end` message. The decoded patches can\n * now be applied as a whole to update from `baseCookie` to `cookie`.\n *\n * Poke messages can be intermingled with other `down` messages, but cannot be\n * intermingled with poke messages for a different `pokeID`. If this is\n * observed it is an unexpected error; the client should ignore both pokes,\n * disconnect, and reconnect.\n */\n\nexport const pokeStartBodySchema = v.object({\n pokeID: v.string(),\n // We always specify a Version as our cookie, but Replicache starts clients\n // with initial cookie `null`, before the first request. So we have to be\n // able to send a base cookie with value `null` to match that state.\n baseCookie: nullableVersionSchema,\n /**\n * This field is always set if the poke contains a `rowsPatch`.\n * It may be absent for patches that only update clients and queries.\n */\n schemaVersions: v\n .object({\n minSupportedVersion: v.number(),\n maxSupportedVersion: v.number(),\n })\n .optional(),\n timestamp: v.number().optional(),\n});\n\nexport const pokePartBodySchema = v.object({\n // Changes to last mutation id by client id.\n lastMutationIDChanges: v.record(v.number()).optional(),\n // Patches to the desired query sets by client id.\n desiredQueriesPatches: v.record(queriesPatchSchema).optional(),\n // Patches to the set of queries for which entities are sync'd in\n // rowsPatch.\n gotQueriesPatch: queriesPatchSchema.optional(),\n // Patches to the rows set.\n rowsPatch: rowsPatchSchema.optional(),\n // Mutation results patch\n mutationsPatch: mutationsPatchSchema.optional(),\n pokeID: v.string(),\n});\n\n/**\n * The logical payload carried by binary poke chunks. Chunk boundaries are\n * arbitrary; concatenating and decoding all chunks for a poke produces this\n * array.\n */\nexport const pokePartsSchema = v.array(pokePartBodySchema);\n\nexport const pokeEndBodySchema = v.object({\n pokeID: v.string(),\n // Note: This should be ignored (and may be empty) if cancel === `true`.\n cookie: versionSchema,\n // If `true`, the poke with id `pokeID` should be discarded without\n // applying it.\n cancel: v.boolean().optional(),\n});\n\nexport const pokeStartMessageSchema = v.tuple([\n v.literal('pokeStart'),\n pokeStartBodySchema,\n]);\nexport const pokePartMessageSchema = v.tuple([\n v.literal('pokePart'),\n pokePartBodySchema,\n]);\nexport const pokeEndMessageSchema = v.tuple([\n v.literal('pokeEnd'),\n pokeEndBodySchema,\n]);\n\nexport type PokeStartBody = v.Infer<typeof pokeStartBodySchema>;\nexport type PokePartBody = v.Infer<typeof pokePartBodySchema>;\nexport type PokeParts = v.Infer<typeof pokePartsSchema>;\nexport type PokeEndBody = v.Infer<typeof pokeEndBodySchema>;\n\n/** The first byte identifying a binary WebSocket message as a poke chunk. */\nexport const POKE_CHUNK_MESSAGE_TYPE = 0x00;\n\n/**\n * The first protocol version that receives binary poke chunks without the\n * `PokeChunk` feature flag.\n */\nexport const POKE_CHUNK_PROTOCOL_VERSION = 52;\n\n/**\n * The last protocol version that receives JSON pokePart messages unless the\n * client sends the `PokeChunk` feature flag.\n */\nexport const LAST_POKE_PART_PROTOCOL_VERSION = 51;\n\n/** A tagged binary poke chunk WebSocket message. */\nexport type PokeChunk = Uint8Array;\n\nexport type PokeStartMessage = v.Infer<typeof pokeStartMessageSchema>;\nexport type PokePartMessage = v.Infer<typeof pokePartMessageSchema>;\nexport type PokeEndMessage = v.Infer<typeof pokeEndMessageSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,sBAAsB,eAAE,OAAO;CAC1C,QAAQ,eAAE,OAAO;CAIjB,YAAY;;;;;CAKZ,gBAAgB,eACb,OAAO;EACN,qBAAqB,eAAE,OAAO;EAC9B,qBAAqB,eAAE,OAAO;CAChC,CAAC,EACA,SAAS;CACZ,WAAW,eAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAED,IAAa,qBAAqB,eAAE,OAAO;CAEzC,uBAAuB,eAAE,OAAO,eAAE,OAAO,CAAC,EAAE,SAAS;CAErD,uBAAuB,eAAE,OAAO,kBAAkB,EAAE,SAAS;CAG7D,iBAAiB,mBAAmB,SAAS;CAE7C,WAAW,gBAAgB,SAAS;CAEpC,gBAAgB,qBAAqB,SAAS;CAC9C,QAAQ,eAAE,OAAO;AACnB,CAAC;;;;;;AAOD,IAAa,kBAAkB,eAAE,MAAM,kBAAkB;AAEzD,IAAa,oBAAoB,eAAE,OAAO;CACxC,QAAQ,eAAE,OAAO;CAEjB,QAAQ;CAGR,QAAQ,eAAE,QAAQ,EAAE,SAAS;AAC/B,CAAC;AAED,IAAa,yBAAyB,eAAE,MAAM,CAC5C,eAAE,QAAQ,WAAW,GACrB,mBACF,CAAC;AACD,IAAa,wBAAwB,eAAE,MAAM,CAC3C,eAAE,QAAQ,UAAU,GACpB,kBACF,CAAC;AACD,IAAa,uBAAuB,eAAE,MAAM,CAC1C,eAAE,QAAQ,SAAS,GACnB,iBACF,CAAC"}
|
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The highest sync protocol version `zero-cache` accepts (i.e. the version
|
|
3
|
+
* declared in the "/sync/v{#}/connect" URL). Clients send
|
|
4
|
+
* {@link CLIENT_PROTOCOL_VERSION}.
|
|
3
5
|
*
|
|
4
|
-
* The
|
|
6
|
+
* The protocol encompasses both the wire-protocol of the `/sync/...`
|
|
5
7
|
* connection between the browser and `zero-cache`, as well as the format of
|
|
6
8
|
* the `AST` objects stored in both components (i.e. IDB and CVR).
|
|
7
9
|
*
|
|
8
|
-
* A
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* A client one release ahead of the server must still be able to connect, so
|
|
11
|
+
* that clients and `zero-cache` can be updated and rolled back in either
|
|
12
|
+
* order. Two rules keep that working:
|
|
13
|
+
*
|
|
14
|
+
* 1. A change an old server can ignore goes behind a feature flag (see
|
|
15
|
+
* `feature-flag-enum.ts`) and the client keeps sending the same
|
|
16
|
+
* {@link CLIENT_PROTOCOL_VERSION}. Old servers ignore flags they don't
|
|
17
|
+
* know, so the client must keep supporting the old behavior.
|
|
18
|
+
* 2. A change an old server can't ignore (e.g. new `AST` functionality)
|
|
19
|
+
* increments `PROTOCOL_VERSION` one release before clients start sending
|
|
20
|
+
* it in {@link CLIENT_PROTOCOL_VERSION}.
|
|
12
21
|
*/
|
|
13
22
|
export declare const PROTOCOL_VERSION = 52;
|
|
23
|
+
/**
|
|
24
|
+
* The sync protocol version clients send in the "/sync/v{#}/connect" URL.
|
|
25
|
+
*
|
|
26
|
+
* Kept below {@link PROTOCOL_VERSION} so that clients can connect to servers
|
|
27
|
+
* from earlier releases: 1.9 servers accept versions up to 51. Clients ask for
|
|
28
|
+
* newer behavior with feature flags instead (rule 1 above). Only increase it
|
|
29
|
+
* to a version that every supported server already accepts (rule 2 above).
|
|
30
|
+
*
|
|
31
|
+
* This number is also part of the client's local database name (Replicache
|
|
32
|
+
* `schemaVersion`). Changing it opens a fresh local database, which drops
|
|
33
|
+
* unsent mutations because Zero disables mutation recovery. Canary clients
|
|
34
|
+
* already used 52 and 53 in their database names, so if the name changes it
|
|
35
|
+
* must move above 53; reusing 52 or 53 would open a stale canary database.
|
|
36
|
+
*/
|
|
37
|
+
export declare const CLIENT_PROTOCOL_VERSION = 51;
|
|
14
38
|
/**
|
|
15
39
|
* The minimum server-supported sync protocol version (i.e. the version
|
|
16
40
|
* declared in the "/sync/v{#}/connect" URL).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-version.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/protocol-version.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"protocol-version.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/protocol-version.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAiDH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kCAAkC,KAAK,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../shared/src/asserts.js";
|
|
2
|
-
assert(true, "
|
|
2
|
+
assert(true, "CLIENT_PROTOCOL_VERSION must be between MIN_SERVER_SUPPORTED_SYNC_PROTOCOL and PROTOCOL_VERSION");
|
|
3
3
|
//#endregion
|
|
4
4
|
export {};
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-version.js","names":[],"sources":["../../../../zero-protocol/src/protocol-version.ts"],"sourcesContent":["import {assert} from '../../shared/src/asserts.ts';\n\n/**\n * The
|
|
1
|
+
{"version":3,"file":"protocol-version.js","names":[],"sources":["../../../../zero-protocol/src/protocol-version.ts"],"sourcesContent":["import {assert} from '../../shared/src/asserts.ts';\n\n/**\n * The highest sync protocol version `zero-cache` accepts (i.e. the version\n * declared in the \"/sync/v{#}/connect\" URL). Clients send\n * {@link CLIENT_PROTOCOL_VERSION}.\n *\n * The protocol encompasses both the wire-protocol of the `/sync/...`\n * connection between the browser and `zero-cache`, as well as the format of\n * the `AST` objects stored in both components (i.e. IDB and CVR).\n *\n * A client one release ahead of the server must still be able to connect, so\n * that clients and `zero-cache` can be updated and rolled back in either\n * order. Two rules keep that working:\n *\n * 1. A change an old server can ignore goes behind a feature flag (see\n * `feature-flag-enum.ts`) and the client keeps sending the same\n * {@link CLIENT_PROTOCOL_VERSION}. Old servers ignore flags they don't\n * know, so the client must keep supporting the old behavior.\n * 2. A change an old server can't ignore (e.g. new `AST` functionality)\n * increments `PROTOCOL_VERSION` one release before clients start sending\n * it in {@link CLIENT_PROTOCOL_VERSION}.\n */\n// History:\n// -- Version 5 adds support for `pokeEnd.cookie`. (0.14)\n// -- Version 6 makes `pokeStart.cookie` optional. (0.16)\n// -- Version 7 introduces the initConnection.clientSchema field. (0.17)\n// -- Version 8 drops support for Version 5 (0.18).\n// -- Version 11 adds inspect queries. (0.18)\n// -- Version 12 adds 'timestamp' and 'date' types to the ClientSchema ValueType. (not shipped, reversed by version 14)\n// -- Version 14 removes 'timestamp' and 'date' types from the ClientSchema ValueType. (0.18)\n// -- Version 15 adds a `userPushParams` field to `initConnection` (0.19)\n// -- Version 16 adds a new error type (alreadyProcessed) to mutation responses (0.19)\n// -- Version 17 deprecates `AST` in downstream query puts. It was never used anyway. (0.21)\n// -- Version 18 adds `name` and `args` to the `queries-patch` protocol (0.21)\n// -- Version 19 adds `activeClients` to the `initConnection` protocol (0.22)\n// -- Version 20 changes inspector down message (0.22)\n// -- Version 21 removes `AST` in downstream query puts which was deprecated in Version 17, removes support for versions < 18 (0.22)\n// -- Version 22 adds an optional 'userQueryParams' field to `initConnection` (0.22)\n// -- Version 23 add `mutationResults` to poke (0.22)\n// -- Version 24 adds `ackMutationResults` to upstream (0.22).\n// -- version 25 modifies `mutationsResults` to include `del` patches (0.22)\n// -- version 26 adds inspect/metrics and adds metrics to inspect/query (0.23)\n// -- version 27 adds inspect/version (0.23)\n// -- version 28 adds more inspect/metrics (0.23)\n// -- version 29 adds error responses for custom queries (0.23)\n// -- version 30 adds an optional primaryKey to the ClientSchema (0.24)\n// -- version 31 adds admin password authentication to inspector RPC calls (0.24)\n// -- version 32 adds analyze-query to the inspector RPC calls (0.24)\n// -- version 33 adds `flip` to CorrelatedSubquery (0.25)\n// -- version 34 moves `flip` from CorrelatedSubquery to CorrelatedSubqueryCondition (0.25)\n// -- version 35 adds `readRows`, `readRowCountsByQuery` and `readRowCount` to analyze-query result (0.25)\n// -- version 36 changes inspector analyze-query and adds error response to RPC (0.25)\n// -- version 37 adds `elapsed` to AnalyzeQueryResult (0.25)\n// -- version 38 adds structured push/transform error responses (0.25)\n// -- version 39 removes per-transform error types and adds `message` to app error (0.25)\n// -- version 40 adds `dbRowScansByQuery` to AnalyzeQueryResult (0.25)\n// -- version 41 makes ClientSchema.primaryKey required (0.25)\n// -- version 42 adds planner events to AnalyzeQueryResult (0.25)\n// -- version 43 renames `plans` to `sqlitePlans`, `plannerEvents` to `joinPlans`, and `plannerDebug` option to `joinPlans` (0.25)\n// -- version 44 adds profileID to connection URL (0.25)\n// -- version 45 adds userPushHeaders and userQueryHeaders to initConnection (0.25)\n// -- version 46 adds scalarSubquery condition type to AST\n// -- version 47 adds optional auth token to push body\n// -- version 48 adds updateAuth\n// -- version 49 adds `scalar` to CorrelatedSubqueryCondition, removes scalarSubquery\n// -- version 50 adds OTEL headers to push and query messages\n// -- version 51 changes inspector metrics fields\n// -- version 52 replaces JSON pokePart messages with binary poke chunks for\n// clients using protocol version 52 or newer. Older clients retain pokePart\n// unless they send the `PokeChunk` feature flag. (1.10 canaries)\nexport const PROTOCOL_VERSION = 52;\n\n/**\n * The sync protocol version clients send in the \"/sync/v{#}/connect\" URL.\n *\n * Kept below {@link PROTOCOL_VERSION} so that clients can connect to servers\n * from earlier releases: 1.9 servers accept versions up to 51. Clients ask for\n * newer behavior with feature flags instead (rule 1 above). Only increase it\n * to a version that every supported server already accepts (rule 2 above).\n *\n * This number is also part of the client's local database name (Replicache\n * `schemaVersion`). Changing it opens a fresh local database, which drops\n * unsent mutations because Zero disables mutation recovery. Canary clients\n * already used 52 and 53 in their database names, so if the name changes it\n * must move above 53; reusing 52 or 53 would open a stale canary database.\n */\nexport const CLIENT_PROTOCOL_VERSION = 51;\n\n/**\n * The minimum server-supported sync protocol version (i.e. the version\n * declared in the \"/sync/v{#}/connect\" URL).\n *\n * CloudZero can serve applications running old client releases indefinitely.\n * Consequently, this value must never be increased: `zero-cache` must continue\n * to support every sync protocol from this version through `PROTOCOL_VERSION`.\n * A wire change that an old client cannot ignore must branch on the client's\n * protocol version and retain the old behavior. Keep each compatibility fork\n * isolated at the boundary that owns the changed behavior and test both sides\n * of its version cutoff.\n *\n * Client connections from protocol versions before this historical floor are\n * closed with a `VersionNotSupported` error.\n */\nexport const MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 30;\n\nassert(\n MIN_SERVER_SUPPORTED_SYNC_PROTOCOL <= CLIENT_PROTOCOL_VERSION &&\n CLIENT_PROTOCOL_VERSION <= PROTOCOL_VERSION,\n 'CLIENT_PROTOCOL_VERSION must be between MIN_SERVER_SUPPORTED_SYNC_PROTOCOL and PROTOCOL_VERSION',\n);\n"],"mappings":";AA0GA,OAAA,MAGE,iGACF"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { type AST
|
|
1
|
+
import { type AST } from './ast.ts';
|
|
2
2
|
export declare function hashOfAST(ast: AST): string;
|
|
3
|
-
|
|
4
|
-
* The hash of an AST that is already normalized, e.g. the AST of a query
|
|
5
|
-
* whose builder kept it normalized as it built it.
|
|
6
|
-
*/
|
|
7
|
-
export declare function hashOfNormalizedAST(ast: NormalizedAST): string;
|
|
8
|
-
export { hashNameAndArgs as hashOfNameAndArgs } from './query-hash-visitor.ts';
|
|
3
|
+
export declare function hashOfNameAndArgs(name: string, args: readonly unknown[]): string;
|
|
9
4
|
//# sourceMappingURL=query-hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-hash.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/query-hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query-hash.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/query-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,GAAG,EAAC,MAAM,UAAU,CAAC;AAIhD,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAS1C;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,OAAO,EAAE,GACvB,MAAM,CAGR"}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { normalizeAST } from "./ast.js";
|
|
2
|
-
import {
|
|
2
|
+
import { h64 } from "../../shared/src/hash.js";
|
|
3
3
|
//#region ../zero-protocol/src/query-hash.ts
|
|
4
4
|
var hashCache = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
function hashOfAST(ast) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The hash of an AST that is already normalized, e.g. the AST of a query
|
|
10
|
-
* whose builder kept it normalized as it built it.
|
|
11
|
-
*/
|
|
12
|
-
function hashOfNormalizedAST(ast) {
|
|
13
|
-
const cached = hashCache.get(ast);
|
|
6
|
+
const normalized = normalizeAST(ast);
|
|
7
|
+
const cached = hashCache.get(normalized);
|
|
14
8
|
if (cached) return cached;
|
|
15
|
-
const hash =
|
|
16
|
-
hashCache.set(
|
|
9
|
+
const hash = h64(JSON.stringify(normalized)).toString(36);
|
|
10
|
+
hashCache.set(normalized, hash);
|
|
17
11
|
return hash;
|
|
18
12
|
}
|
|
13
|
+
function hashOfNameAndArgs(name, args) {
|
|
14
|
+
return h64(`${name}:${JSON.stringify(args)}`).toString(36);
|
|
15
|
+
}
|
|
19
16
|
//#endregion
|
|
20
|
-
export { hashOfAST };
|
|
17
|
+
export { hashOfAST, hashOfNameAndArgs };
|
|
21
18
|
|
|
22
19
|
//# sourceMappingURL=query-hash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-hash.js","names":[],"sources":["../../../../zero-protocol/src/query-hash.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"query-hash.js","names":[],"sources":["../../../../zero-protocol/src/query-hash.ts"],"sourcesContent":["import {h64} from '../../shared/src/hash.ts';\nimport {normalizeAST, type AST} from './ast.ts';\n\nconst hashCache = new WeakMap<AST, string>();\n\nexport function hashOfAST(ast: AST): string {\n const normalized = normalizeAST(ast);\n const cached = hashCache.get(normalized);\n if (cached) {\n return cached;\n }\n const hash = h64(JSON.stringify(normalized)).toString(36);\n hashCache.set(normalized, hash);\n return hash;\n}\n\nexport function hashOfNameAndArgs(\n name: string,\n args: readonly unknown[],\n): string {\n const argsString = JSON.stringify(args);\n return h64(`${name}:${argsString}`).toString(36);\n}\n"],"mappings":";;;AAGA,IAAM,4BAAY,IAAI,QAAqB;AAE3C,SAAgB,UAAU,KAAkB;CAC1C,MAAM,aAAa,aAAa,GAAG;CACnC,MAAM,SAAS,UAAU,IAAI,UAAU;CACvC,IAAI,QACF,OAAO;CAET,MAAM,OAAO,IAAI,KAAK,UAAU,UAAU,CAAC,EAAE,SAAS,EAAE;CACxD,UAAU,IAAI,YAAY,IAAI;CAC9B,OAAO;AACT;AAEA,SAAgB,kBACd,MACA,MACQ;CAER,OAAO,IAAI,GAAG,KAAK,GADA,KAAK,UAAU,IACZ,GAAY,EAAE,SAAS,EAAE;AACjD"}
|
|
@@ -25,11 +25,10 @@ export type UseSuspenseQueryOptions = UseQueryOptions & {
|
|
|
25
25
|
* Whether to suspend until:
|
|
26
26
|
* - 'partial': the query has partial results (partial array or defined
|
|
27
27
|
* value for singular results) which may be of result type 'unknown',
|
|
28
|
-
* or the query result type is 'complete'
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* the query has completed loading from the server.
|
|
28
|
+
* or the query result type is 'complete' (in which case results may be
|
|
29
|
+
* empty). This is useful for suspending until there are partial
|
|
30
|
+
* optimistic local results, or the query has completed loading from the
|
|
31
|
+
* server.
|
|
33
32
|
* - 'complete': the query result type is 'complete'.
|
|
34
33
|
*
|
|
35
34
|
* Default is 'partial'.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-query.d.ts","sourceRoot":"","sources":["../../../../zero-react/src/use-query.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-query.d.ts","sourceRoot":"","sources":["../../../../zero-react/src/use-query.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,aAAa,EAEb,KAAK,EACL,aAAa,EACb,OAAO,EACP,KAAK,EAEL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EAEjB,GAAG,EAEH,IAAI,EACL,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,WAAW,CAAC,OAAO,IAAI,SAAS;IAC1C,aAAa,CAAC,OAAO,CAAC;IACtB,kBAAkB,GAAG,EAAE;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,OAAO,IAAI,SAAS;IAC/C,aAAa,CAAC,OAAO,CAAC,GAAG,SAAS;IAClC,kBAAkB,GAAG,EAAE;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;;OAIG;IACH,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG;IACtD;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACvC,CAAC;AAUF,wBAAgB,QAAQ,CACtB,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC/C,MAAM,SAAS,iBAAiB,GAAG,SAAS,EAC5C,OAAO,SAAS,iBAAiB,GAAG,SAAS,EAC7C,OAAO,SAAS,iBAAiB,GAAG,aAAa,EACjD,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,QAAQ,SAAS,kBAAkB,GAAG,cAAc,EAEpD,KAAK,EAAE,mBAAmB,CACxB,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,CACT,EACD,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,GAClC,WAAW,CAAC,OAAO,CAAC,CAAC;AAGxB,wBAAgB,QAAQ,CACtB,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC/C,MAAM,SAAS,iBAAiB,GAAG,SAAS,EAC5C,OAAO,SAAS,iBAAiB,GAAG,SAAS,EAC7C,OAAO,SAAS,iBAAiB,GAAG,aAAa,EACjD,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,QAAQ,SAAS,kBAAkB,GAAG,cAAc,EAEpD,KAAK,EACD,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GACxE,KAAK,EACT,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,GAClC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AA0C7B,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC/C,MAAM,SAAS,iBAAiB,GAAG,SAAS,EAC5C,OAAO,SAAS,iBAAiB,GAAG,SAAS,EAC7C,OAAO,SAAS,iBAAiB,GAAG,aAAa,EACjD,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,QAAQ,SAAS,kBAAkB,GAAG,cAAc,EAEpD,KAAK,EAAE,mBAAmB,CACxB,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,CACT,EACD,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,GAC1C,WAAW,CAAC,OAAO,CAAC,CAAC;AAGxB,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC/C,MAAM,SAAS,iBAAiB,GAAG,SAAS,EAC5C,OAAO,SAAS,iBAAiB,GAAG,SAAS,EAC7C,OAAO,SAAS,iBAAiB,GAAG,aAAa,EACjD,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,QAAQ,SAAS,kBAAkB,GAAG,cAAc,EAEpD,KAAK,EACD,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GACxE,KAAK,EACT,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,GAC1C,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAsK7B,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAKlE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,SAAS;;;IASpB,OAAO,CACL,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC/C,OAAO,SAAS,iBAAiB,EACjC,OAAO,EACP,EAAE,SAAS,iBAAiB,GAAG,SAAS,EACxC,QAAQ,SAAS,kBAAkB,EAEnC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,EACjC,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAClC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,GACP;QACD,WAAW,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;QACxC,uBAAuB,EAAE,CAAC,SAAS,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;QAC/D,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;QAC9B,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QACrC,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QACrC,QAAQ,EAAE,OAAO,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC;KACnB;CAgCF"}
|
|
@@ -1,57 +1,11 @@
|
|
|
1
|
-
import { deepEqual } from "../../shared/src/json.js";
|
|
2
1
|
import { asQueryInternals } from "../../zql/src/query/query-internals.js";
|
|
3
2
|
import { addContextToQuery } from "../../zql/src/query/query-registry.js";
|
|
4
3
|
import { DEFAULT_TTL_MS } from "../../zql/src/query/ttl.js";
|
|
5
4
|
import { useZero } from "./zero-provider.js";
|
|
6
5
|
import "./bindings.js";
|
|
7
6
|
import { resolver } from "@rocicorp/resolver";
|
|
8
|
-
import React, {
|
|
7
|
+
import React, { useSyncExternalStore } from "react";
|
|
9
8
|
//#region ../zero-react/src/use-query.tsx
|
|
10
|
-
/**
|
|
11
|
-
* Resolves a query request against the Zero context, reusing the previous
|
|
12
|
-
* result while the request means the same thing.
|
|
13
|
-
*
|
|
14
|
-
* Interning already makes an unchanged *plain* query come back as the same
|
|
15
|
-
* object, so this is aimed at the query-request form -- `queries.issue({id})`
|
|
16
|
-
* -- where every render allocates a fresh request and `addContextToQuery`
|
|
17
|
-
* re-runs the definition. That costs argument validation (a zod parse of
|
|
18
|
-
* byte-identical args) plus a walk of the builder chain, neither of which
|
|
19
|
-
* interning removes: it makes rebuilding the chain cheap and gives the same
|
|
20
|
-
* object back, but only after the work has been done again.
|
|
21
|
-
*
|
|
22
|
-
* A request resolves to the previous query when it names the same
|
|
23
|
-
* `CustomQuery`, the same context, and deep-equal args. Those are exactly the
|
|
24
|
-
* inputs the definition is allowed to depend on: a named query is re-derived
|
|
25
|
-
* on the server from its name and args, so it has to be a pure function of
|
|
26
|
-
* them, or client and server would build different queries.
|
|
27
|
-
*
|
|
28
|
-
* The ref is written during render. That is safe here because it is a pure
|
|
29
|
-
* cache: an entry is derived only from the inputs, so a StrictMode double
|
|
30
|
-
* render or a discarded concurrent render leaves it valid either way.
|
|
31
|
-
*/
|
|
32
|
-
function useStableQuery(query, zero) {
|
|
33
|
-
const cacheRef = useRef(void 0);
|
|
34
|
-
if (!query) return;
|
|
35
|
-
const cache = cacheRef.current;
|
|
36
|
-
if (cache && cache.zero === zero) {
|
|
37
|
-
if (cache.rawQuery === query) return cache.q;
|
|
38
|
-
if ("query" in query && cache.customQuery === query.query && cache.context === zero.context && deepEqual(cache.args, query.args)) {
|
|
39
|
-
cache.rawQuery = query;
|
|
40
|
-
return cache.q;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const q = addContextToQuery(query, zero.context);
|
|
44
|
-
const isRequest = "query" in query;
|
|
45
|
-
cacheRef.current = {
|
|
46
|
-
zero,
|
|
47
|
-
context: zero.context,
|
|
48
|
-
rawQuery: query,
|
|
49
|
-
customQuery: isRequest ? query.query : void 0,
|
|
50
|
-
args: isRequest ? query.args : void 0,
|
|
51
|
-
q
|
|
52
|
-
};
|
|
53
|
-
return q;
|
|
54
|
-
}
|
|
55
9
|
var reactUse = React.use;
|
|
56
10
|
var suspend = reactUse ? reactUse : (p) => {
|
|
57
11
|
throw p;
|
|
@@ -62,7 +16,7 @@ function useQuery(query, options) {
|
|
|
62
16
|
if (typeof options === "boolean") enabled = options;
|
|
63
17
|
else if (options) ({enabled = true, ttl = DEFAULT_TTL_MS} = options);
|
|
64
18
|
const zero = useZero();
|
|
65
|
-
const q =
|
|
19
|
+
const q = query ? addContextToQuery(query, zero.context) : void 0;
|
|
66
20
|
const view = q ? viewStore.getView(zero, q, enabled, ttl) : void 0;
|
|
67
21
|
return useSyncExternalStore(view?.subscribeReactInternals ?? disabledSubscriber, view?.getSnapshot ?? getDisabledSnapshot, view?.getSnapshot ?? getDisabledSnapshot);
|
|
68
22
|
}
|
|
@@ -73,7 +27,7 @@ function useSuspenseQuery(query, options) {
|
|
|
73
27
|
if (typeof options === "boolean") enabled = options;
|
|
74
28
|
else if (options) ({enabled = true, ttl = DEFAULT_TTL_MS, suspendUntil = "complete"} = options);
|
|
75
29
|
const zero = useZero();
|
|
76
|
-
const q =
|
|
30
|
+
const q = query ? addContextToQuery(query, zero.context) : void 0;
|
|
77
31
|
const view = q ? viewStore.getView(zero, q, enabled, ttl) : void 0;
|
|
78
32
|
const snapshot = useSyncExternalStore(view?.subscribeReactInternals ?? disabledSubscriber, view?.getSnapshot ?? getDisabledSnapshot, view?.getSnapshot ?? getDisabledSnapshot);
|
|
79
33
|
if (view && enabled) {
|
|
@@ -85,17 +39,14 @@ function useSuspenseQuery(query, options) {
|
|
|
85
39
|
var emptyArray = [];
|
|
86
40
|
var disabledSubscriber = () => () => {};
|
|
87
41
|
var resultTypeUnknown = { type: "unknown" };
|
|
88
|
-
var resultTypeCached = { type: "cached" };
|
|
89
42
|
var resultTypeComplete = { type: "complete" };
|
|
90
43
|
var resultTypeError = { type: "error" };
|
|
91
44
|
var disabledQuerySnapshot = [void 0, resultTypeUnknown];
|
|
92
45
|
var getDisabledSnapshot = () => disabledQuerySnapshot;
|
|
93
46
|
var emptySnapshotSingularUnknown = [void 0, resultTypeUnknown];
|
|
94
|
-
var emptySnapshotSingularCached = [void 0, resultTypeCached];
|
|
95
47
|
var emptySnapshotSingularComplete = [void 0, resultTypeComplete];
|
|
96
48
|
var emptySnapshotSingularErrorUnknown = [void 0, resultTypeError];
|
|
97
49
|
var emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown];
|
|
98
|
-
var emptySnapshotPluralCached = [emptyArray, resultTypeCached];
|
|
99
50
|
var emptySnapshotPluralComplete = [emptyArray, resultTypeComplete];
|
|
100
51
|
var emptySnapshotErrorUnknown = [emptyArray, resultTypeError];
|
|
101
52
|
function getDefaultSnapshot(singular) {
|
|
@@ -112,7 +63,6 @@ function getSnapshot(singular, data, resultType, retryFn, error) {
|
|
|
112
63
|
return emptySnapshotSingularErrorUnknown;
|
|
113
64
|
case "complete": return emptySnapshotSingularComplete;
|
|
114
65
|
case "unknown": return emptySnapshotSingularUnknown;
|
|
115
|
-
case "cached": return emptySnapshotSingularCached;
|
|
116
66
|
}
|
|
117
67
|
if (!singular && data.length === 0) switch (resultType) {
|
|
118
68
|
case "error":
|
|
@@ -120,7 +70,6 @@ function getSnapshot(singular, data, resultType, retryFn, error) {
|
|
|
120
70
|
return emptySnapshotErrorUnknown;
|
|
121
71
|
case "complete": return emptySnapshotPluralComplete;
|
|
122
72
|
case "unknown": return emptySnapshotPluralUnknown;
|
|
123
|
-
case "cached": return emptySnapshotPluralCached;
|
|
124
73
|
}
|
|
125
74
|
switch (resultType) {
|
|
126
75
|
case "error":
|
|
@@ -133,7 +82,6 @@ function getSnapshot(singular, data, resultType, retryFn, error) {
|
|
|
133
82
|
})];
|
|
134
83
|
case "complete": return [data, resultTypeComplete];
|
|
135
84
|
case "unknown": return [data, resultTypeUnknown];
|
|
136
|
-
case "cached": return [data, resultTypeCached];
|
|
137
85
|
}
|
|
138
86
|
}
|
|
139
87
|
function makeError(retry, error) {
|
|
@@ -198,17 +146,6 @@ function makeError(retry, error) {
|
|
|
198
146
|
* Swapping `useState` to `useRef` has similar problems.
|
|
199
147
|
*/
|
|
200
148
|
var ViewStore = class {
|
|
201
|
-
/**
|
|
202
|
-
* Client id, then query hash.
|
|
203
|
-
*
|
|
204
|
-
* Nested rather than keyed by the two joined together, because this is
|
|
205
|
-
* looked up on every render of every `useQuery`. Joining them builds a
|
|
206
|
-
* string that V8 has to hash from scratch, where both halves on their own
|
|
207
|
-
* are strings it has already hashed and cached -- `hash()` is memoized on an
|
|
208
|
-
* interned query, so the same string comes back each render. Measured over a
|
|
209
|
-
* rebuild-and-look-up of one chain, that is the difference between 202ns and
|
|
210
|
-
* 123ns; the join cost more than rebuilding and hashing the whole query.
|
|
211
|
-
*/
|
|
212
149
|
#views = /* @__PURE__ */ new Map();
|
|
213
150
|
constructor() {}
|
|
214
151
|
getView(zero, q, enabled, ttl) {
|
|
@@ -222,23 +159,15 @@ var ViewStore = class {
|
|
|
222
159
|
complete: false,
|
|
223
160
|
nonEmpty: false
|
|
224
161
|
};
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
let byHash = this.#views.get(clientID);
|
|
228
|
-
let existing = byHash?.get(hash);
|
|
162
|
+
const hash = qi.hash() + JSON.stringify(qi.format) + zero.clientID;
|
|
163
|
+
let existing = this.#views.get(hash);
|
|
229
164
|
if (!existing) {
|
|
230
165
|
existing = new ViewWrapper(q, zero, ttl, (view) => {
|
|
231
|
-
const
|
|
232
|
-
const currentView = views?.get(hash);
|
|
166
|
+
const currentView = this.#views.get(hash);
|
|
233
167
|
if (currentView && currentView !== view) return;
|
|
234
|
-
views
|
|
235
|
-
if (views?.size === 0) this.#views.delete(clientID);
|
|
168
|
+
this.#views.delete(hash);
|
|
236
169
|
});
|
|
237
|
-
|
|
238
|
-
byHash = /* @__PURE__ */ new Map();
|
|
239
|
-
this.#views.set(clientID, byHash);
|
|
240
|
-
}
|
|
241
|
-
byHash.set(hash, existing);
|
|
170
|
+
this.#views.set(hash, existing);
|
|
242
171
|
} else existing.updateTTL(ttl);
|
|
243
172
|
return existing;
|
|
244
173
|
}
|
|
@@ -295,7 +224,6 @@ var ViewWrapper = class {
|
|
|
295
224
|
}
|
|
296
225
|
#onData = (snap, resultType, error) => {
|
|
297
226
|
const data = snap;
|
|
298
|
-
const wasCached = this.#snapshot[1].type === "cached";
|
|
299
227
|
this.#snapshot = getSnapshot(this.#singular, data, resultType, this.#retry, error);
|
|
300
228
|
if (resultType === "complete" || resultType === "error") {
|
|
301
229
|
this.#complete = true;
|
|
@@ -303,13 +231,9 @@ var ViewWrapper = class {
|
|
|
303
231
|
this.#nonEmpty = true;
|
|
304
232
|
this.#nonEmptyResolver.resolve();
|
|
305
233
|
}
|
|
306
|
-
|
|
307
|
-
if (resultType === "cached" || hasData) {
|
|
234
|
+
if (this.#singular ? this.#snapshot[0] !== void 0 : this.#snapshot[0].length !== 0) {
|
|
308
235
|
this.#nonEmpty = true;
|
|
309
236
|
this.#nonEmptyResolver.resolve();
|
|
310
|
-
} else if (wasCached && resultType === "unknown") {
|
|
311
|
-
this.#nonEmpty = false;
|
|
312
|
-
this.#nonEmptyResolver = resolver();
|
|
313
237
|
}
|
|
314
238
|
for (const internals of this.#reactInternals) internals();
|
|
315
239
|
};
|
|
@@ -352,7 +276,6 @@ var ViewWrapper = class {
|
|
|
352
276
|
};
|
|
353
277
|
};
|
|
354
278
|
updateTTL(ttl) {
|
|
355
|
-
if (this.#ttl === ttl) return;
|
|
356
279
|
this.#ttl = ttl;
|
|
357
280
|
this.#view?.updateTTL(ttl);
|
|
358
281
|
}
|