@rocicorp/zero 1.10.0-canary.24 → 1.10.0-canary.26

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.
Files changed (568) hide show
  1. package/out/analyze-query/src/bin-analyze.js +8 -9
  2. package/out/analyze-query/src/bin-analyze.js.map +1 -1
  3. package/out/replicache/src/btree/node.d.ts.map +1 -1
  4. package/out/replicache/src/btree/node.js +6 -3
  5. package/out/replicache/src/btree/node.js.map +1 -1
  6. package/out/replicache/src/btree/read.d.ts +1 -12
  7. package/out/replicache/src/btree/read.d.ts.map +1 -1
  8. package/out/replicache/src/btree/read.js +12 -24
  9. package/out/replicache/src/btree/read.js.map +1 -1
  10. package/out/replicache/src/dag/gc.d.ts.map +1 -1
  11. package/out/replicache/src/dag/gc.js +11 -8
  12. package/out/replicache/src/dag/gc.js.map +1 -1
  13. package/out/replicache/src/dag/store-impl.d.ts +2 -12
  14. package/out/replicache/src/dag/store-impl.d.ts.map +1 -1
  15. package/out/replicache/src/dag/store-impl.js +8 -22
  16. package/out/replicache/src/dag/store-impl.js.map +1 -1
  17. package/out/replicache/src/db/rebase.d.ts +2 -14
  18. package/out/replicache/src/db/rebase.d.ts.map +1 -1
  19. package/out/replicache/src/db/rebase.js +5 -27
  20. package/out/replicache/src/db/rebase.js.map +1 -1
  21. package/out/replicache/src/db/write.js.map +1 -1
  22. package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -1
  23. package/out/replicache/src/kv/expo-sqlite/store.js +5 -28
  24. package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
  25. package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts +5 -15
  26. package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts.map +1 -1
  27. package/out/replicache/src/kv/idb-store-with-mem-fallback.js +25 -25
  28. package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +1 -1
  29. package/out/replicache/src/kv/idb-store.d.ts +0 -9
  30. package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
  31. package/out/replicache/src/kv/idb-store.js +2 -14
  32. package/out/replicache/src/kv/idb-store.js.map +1 -1
  33. package/out/replicache/src/kv/mem-store.d.ts +0 -1
  34. package/out/replicache/src/kv/mem-store.d.ts.map +1 -1
  35. package/out/replicache/src/kv/mem-store.js +0 -3
  36. package/out/replicache/src/kv/mem-store.js.map +1 -1
  37. package/out/replicache/src/kv/op-sqlite/store.d.ts.map +1 -1
  38. package/out/replicache/src/kv/op-sqlite/store.js +1 -1
  39. package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
  40. package/out/replicache/src/kv/sqlite-store.d.ts +1 -13
  41. package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
  42. package/out/replicache/src/kv/sqlite-store.js +6 -73
  43. package/out/replicache/src/kv/sqlite-store.js.map +1 -1
  44. package/out/replicache/src/kv/store.d.ts +0 -6
  45. package/out/replicache/src/kv/store.d.ts.map +1 -1
  46. package/out/replicache/src/persist/collect-idb-databases.d.ts +5 -10
  47. package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
  48. package/out/replicache/src/persist/collect-idb-databases.js +9 -16
  49. package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
  50. package/out/replicache/src/persist/persist.d.ts.map +1 -1
  51. package/out/replicache/src/persist/persist.js +6 -13
  52. package/out/replicache/src/persist/persist.js.map +1 -1
  53. package/out/replicache/src/persist/refresh.js +2 -6
  54. package/out/replicache/src/persist/refresh.js.map +1 -1
  55. package/out/replicache/src/replicache-impl.d.ts +3 -14
  56. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  57. package/out/replicache/src/replicache-impl.js +11 -118
  58. package/out/replicache/src/replicache-impl.js.map +1 -1
  59. package/out/replicache/src/replicache-options.d.ts +0 -9
  60. package/out/replicache/src/replicache-options.d.ts.map +1 -1
  61. package/out/replicache/src/transactions.d.ts.map +1 -1
  62. package/out/replicache/src/transactions.js +1 -1
  63. package/out/replicache/src/transactions.js.map +1 -1
  64. package/out/shared/src/arrays.d.ts +0 -5
  65. package/out/shared/src/arrays.d.ts.map +1 -1
  66. package/out/shared/src/arrays.js +24 -8
  67. package/out/shared/src/arrays.js.map +1 -1
  68. package/out/shared/src/base64.d.ts +19 -0
  69. package/out/shared/src/base64.d.ts.map +1 -0
  70. package/out/shared/src/base64.js +40 -0
  71. package/out/shared/src/base64.js.map +1 -0
  72. package/out/shared/src/error.d.ts +0 -11
  73. package/out/shared/src/error.d.ts.map +1 -1
  74. package/out/shared/src/error.js +1 -35
  75. package/out/shared/src/error.js.map +1 -1
  76. package/out/shared/src/hash.d.ts +0 -1
  77. package/out/shared/src/hash.d.ts.map +1 -1
  78. package/out/shared/src/hash.js +10 -87
  79. package/out/shared/src/hash.js.map +1 -1
  80. package/out/shared/src/iterables.d.ts +0 -2
  81. package/out/shared/src/iterables.d.ts.map +1 -1
  82. package/out/shared/src/iterables.js +1 -18
  83. package/out/shared/src/iterables.js.map +1 -1
  84. package/out/shared/src/json.d.ts.map +1 -1
  85. package/out/shared/src/json.js +2 -2
  86. package/out/shared/src/json.js.map +1 -1
  87. package/out/shared/src/map.d.ts +2 -24
  88. package/out/shared/src/map.d.ts.map +1 -1
  89. package/out/shared/src/map.js +4 -18
  90. package/out/shared/src/map.js.map +1 -1
  91. package/out/shared/src/ring-buffer.d.ts +0 -8
  92. package/out/shared/src/ring-buffer.d.ts.map +1 -1
  93. package/out/shared/src/ring-buffer.js +1 -22
  94. package/out/shared/src/ring-buffer.js.map +1 -1
  95. package/out/z2s/src/sql.d.ts.map +1 -1
  96. package/out/z2s/src/sql.js +2 -2
  97. package/out/z2s/src/sql.js.map +1 -1
  98. package/out/zero/package.js +3 -2
  99. package/out/zero/package.js.map +1 -1
  100. package/out/zero-cache/src/auth/read-authorizer.js +1 -1
  101. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
  102. package/out/zero-cache/src/auth/write-authorizer.js +0 -1
  103. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  104. package/out/zero-cache/src/config/zero-config.d.ts +2 -42
  105. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  106. package/out/zero-cache/src/config/zero-config.js +28 -149
  107. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  108. package/out/zero-cache/src/custom-queries/transform-query.js +1 -1
  109. package/out/zero-cache/src/db/create.d.ts.map +1 -1
  110. package/out/zero-cache/src/db/create.js +1 -4
  111. package/out/zero-cache/src/db/create.js.map +1 -1
  112. package/out/zero-cache/src/db/lite-tables.d.ts +2 -10
  113. package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
  114. package/out/zero-cache/src/db/lite-tables.js +6 -10
  115. package/out/zero-cache/src/db/lite-tables.js.map +1 -1
  116. package/out/zero-cache/src/db/specs.d.ts +0 -41
  117. package/out/zero-cache/src/db/specs.d.ts.map +1 -1
  118. package/out/zero-cache/src/db/specs.js +3 -30
  119. package/out/zero-cache/src/db/specs.js.map +1 -1
  120. package/out/zero-cache/src/observability/metrics.d.ts.map +1 -1
  121. package/out/zero-cache/src/observability/metrics.js +7 -2
  122. package/out/zero-cache/src/observability/metrics.js.map +1 -1
  123. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  124. package/out/zero-cache/src/server/change-streamer.js +4 -13
  125. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  126. package/out/zero-cache/src/server/inspector-delegate.d.ts +2 -18
  127. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
  128. package/out/zero-cache/src/server/inspector-delegate.js +17 -25
  129. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
  130. package/out/zero-cache/src/server/main.d.ts.map +1 -1
  131. package/out/zero-cache/src/server/main.js +1 -8
  132. package/out/zero-cache/src/server/main.js.map +1 -1
  133. package/out/zero-cache/src/server/mutator.js +0 -2
  134. package/out/zero-cache/src/server/mutator.js.map +1 -1
  135. package/out/zero-cache/src/server/reaper.d.ts.map +1 -1
  136. package/out/zero-cache/src/server/reaper.js +0 -2
  137. package/out/zero-cache/src/server/reaper.js.map +1 -1
  138. package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
  139. package/out/zero-cache/src/server/replicator.js +2 -8
  140. package/out/zero-cache/src/server/replicator.js.map +1 -1
  141. package/out/zero-cache/src/server/runner/zero-dispatcher.d.ts.map +1 -1
  142. package/out/zero-cache/src/server/runner/zero-dispatcher.js +0 -3
  143. package/out/zero-cache/src/server/runner/zero-dispatcher.js.map +1 -1
  144. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  145. package/out/zero-cache/src/server/syncer.js +1 -5
  146. package/out/zero-cache/src/server/syncer.js.map +1 -1
  147. package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
  148. package/out/zero-cache/src/services/analyze.js +9 -11
  149. package/out/zero-cache/src/services/analyze.js.map +1 -1
  150. package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts.map +1 -1
  151. package/out/zero-cache/src/services/change-source/common/backfill-manager.js +1 -14
  152. package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
  153. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts.map +1 -1
  154. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js +3 -15
  155. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
  156. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +1 -11
  157. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
  158. package/out/zero-cache/src/services/change-source/pg/change-source.js +2 -21
  159. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  160. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +0 -1
  161. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
  162. package/out/zero-cache/src/services/change-source/pg/initial-sync.js +7 -8
  163. package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
  164. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +229 -1513
  165. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
  166. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +2 -2
  167. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
  168. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +1 -1
  169. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
  170. package/out/zero-cache/src/services/change-source/pg/schema/init.js +6 -15
  171. package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
  172. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +20 -137
  173. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
  174. package/out/zero-cache/src/services/change-source/pg/schema/published.js +13 -82
  175. package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
  176. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +21 -128
  177. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
  178. package/out/zero-cache/src/services/change-source/pg/schema/shard.js +5 -5
  179. package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
  180. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +0 -2
  181. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
  182. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +0 -3
  183. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
  184. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +0 -3
  185. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
  186. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +1 -3
  187. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  188. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +0 -1
  189. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
  190. package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
  191. package/out/zero-cache/src/services/litestream/commands.js +3 -8
  192. package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
  193. package/out/zero-cache/src/services/litestream/config-v5.yml +1 -15
  194. package/out/zero-cache/src/services/mutagen/mutagen.d.ts +0 -5
  195. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
  196. package/out/zero-cache/src/services/mutagen/mutagen.js +1 -7
  197. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  198. package/out/zero-cache/src/services/mutagen/pusher.d.ts +119 -119
  199. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
  200. package/out/zero-cache/src/services/mutagen/pusher.js +6 -5
  201. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  202. package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
  203. package/out/zero-cache/src/services/replicator/change-processor.js +16 -16
  204. package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
  205. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
  206. package/out/zero-cache/src/services/replicator/incremental-sync.js +0 -1
  207. package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
  208. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +2 -27
  209. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts.map +1 -1
  210. package/out/zero-cache/src/services/replicator/write-worker-client.js +2 -3
  211. package/out/zero-cache/src/services/replicator/write-worker-client.js.map +1 -1
  212. package/out/zero-cache/src/services/replicator/write-worker.js +5 -24
  213. package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
  214. package/out/zero-cache/src/services/run-ast.d.ts +0 -12
  215. package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
  216. package/out/zero-cache/src/services/run-ast.js +15 -27
  217. package/out/zero-cache/src/services/run-ast.js.map +1 -1
  218. package/out/zero-cache/src/services/runner.d.ts.map +1 -1
  219. package/out/zero-cache/src/services/runner.js +1 -1
  220. package/out/zero-cache/src/services/runner.js.map +1 -1
  221. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +0 -45
  222. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  223. package/out/zero-cache/src/services/view-syncer/cvr.js +1 -133
  224. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  225. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +1 -14
  226. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts.map +1 -1
  227. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +4 -30
  228. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
  229. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +1 -1
  230. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -1
  231. package/out/zero-cache/src/services/view-syncer/inspect-handler.js +2 -2
  232. package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
  233. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +1 -2
  234. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  235. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +27 -48
  236. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  237. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +1 -1
  238. package/out/zero-cache/src/services/view-syncer/query-covering.js +6 -2
  239. package/out/zero-cache/src/services/view-syncer/query-covering.js.map +1 -1
  240. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +4 -42
  241. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
  242. package/out/zero-cache/src/services/view-syncer/snapshotter.js +28 -117
  243. package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
  244. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +1 -11
  245. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  246. package/out/zero-cache/src/services/view-syncer/view-syncer.js +95 -466
  247. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  248. package/out/zero-cache/src/types/processes.d.ts +0 -32
  249. package/out/zero-cache/src/types/processes.d.ts.map +1 -1
  250. package/out/zero-cache/src/types/processes.js +4 -43
  251. package/out/zero-cache/src/types/processes.js.map +1 -1
  252. package/out/zero-cache/src/types/profiler.d.ts +0 -12
  253. package/out/zero-cache/src/types/profiler.d.ts.map +1 -1
  254. package/out/zero-cache/src/types/profiler.js +1 -46
  255. package/out/zero-cache/src/types/profiler.js.map +1 -1
  256. package/out/zero-cache/src/types/row-key.d.ts.map +1 -1
  257. package/out/zero-cache/src/types/row-key.js +5 -5
  258. package/out/zero-cache/src/types/row-key.js.map +1 -1
  259. package/out/zero-cache/src/workers/connect-params.d.ts +7 -0
  260. package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
  261. package/out/zero-cache/src/workers/connect-params.js +20 -1
  262. package/out/zero-cache/src/workers/connect-params.js.map +1 -1
  263. package/out/zero-cache/src/workers/connection.d.ts +4 -4
  264. package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
  265. package/out/zero-cache/src/workers/connection.js +8 -8
  266. package/out/zero-cache/src/workers/connection.js.map +1 -1
  267. package/out/zero-cache/src/workers/replicator.d.ts +0 -1
  268. package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
  269. package/out/zero-cache/src/workers/replicator.js +2 -4
  270. package/out/zero-cache/src/workers/replicator.js.map +1 -1
  271. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
  272. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +16 -21
  273. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  274. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  275. package/out/zero-cache/src/workers/syncer.js +1 -10
  276. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  277. package/out/zero-client/src/client/connection-manager.d.ts +0 -20
  278. package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
  279. package/out/zero-client/src/client/connection-manager.js +13 -77
  280. package/out/zero-client/src/client/connection-manager.js.map +1 -1
  281. package/out/zero-client/src/client/connection-status-enum.d.ts +0 -2
  282. package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
  283. package/out/zero-client/src/client/connection-status-enum.js +1 -3
  284. package/out/zero-client/src/client/connection-status-enum.js.map +1 -1
  285. package/out/zero-client/src/client/connection.d.ts +0 -6
  286. package/out/zero-client/src/client/connection.d.ts.map +1 -1
  287. package/out/zero-client/src/client/connection.js +1 -2
  288. package/out/zero-client/src/client/connection.js.map +1 -1
  289. package/out/zero-client/src/client/context.d.ts +2 -27
  290. package/out/zero-client/src/client/context.d.ts.map +1 -1
  291. package/out/zero-client/src/client/context.js +1 -112
  292. package/out/zero-client/src/client/context.js.map +1 -1
  293. package/out/zero-client/src/client/custom.js +2 -2
  294. package/out/zero-client/src/client/custom.js.map +1 -1
  295. package/out/zero-client/src/client/error.js +1 -1
  296. package/out/zero-client/src/client/inspector/lazy-inspector.js +2 -2
  297. package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
  298. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  299. package/out/zero-client/src/client/ivm-branch.js +3 -20
  300. package/out/zero-client/src/client/ivm-branch.js.map +1 -1
  301. package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
  302. package/out/zero-client/src/client/mutation-tracker.js +1 -1
  303. package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
  304. package/out/zero-client/src/client/mutator-proxy.d.ts.map +1 -1
  305. package/out/zero-client/src/client/mutator-proxy.js +1 -2
  306. package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
  307. package/out/zero-client/src/client/options.d.ts +0 -3
  308. package/out/zero-client/src/client/options.d.ts.map +1 -1
  309. package/out/zero-client/src/client/options.js.map +1 -1
  310. package/out/zero-client/src/client/query-manager.d.ts +0 -2
  311. package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
  312. package/out/zero-client/src/client/query-manager.js +14 -50
  313. package/out/zero-client/src/client/query-manager.js.map +1 -1
  314. package/out/zero-client/src/client/version.js +1 -1
  315. package/out/zero-client/src/client/zero-rep.d.ts +0 -1
  316. package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
  317. package/out/zero-client/src/client/zero-rep.js +6 -9
  318. package/out/zero-client/src/client/zero-rep.js.map +1 -1
  319. package/out/zero-client/src/client/zero.d.ts +3 -18
  320. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  321. package/out/zero-client/src/client/zero.js +36 -123
  322. package/out/zero-client/src/client/zero.js.map +1 -1
  323. package/out/zero-client/src/types/query-result.d.ts +0 -2
  324. package/out/zero-client/src/types/query-result.d.ts.map +1 -1
  325. package/out/zero-protocol/src/analyze-query-result.d.ts +5 -5
  326. package/out/zero-protocol/src/analyze-query-result.d.ts.map +1 -1
  327. package/out/zero-protocol/src/analyze-query-result.js +1 -1
  328. package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
  329. package/out/zero-protocol/src/ast.d.ts +1 -64
  330. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  331. package/out/zero-protocol/src/ast.js +54 -225
  332. package/out/zero-protocol/src/ast.js.map +1 -1
  333. package/out/zero-protocol/src/connect.d.ts +13 -0
  334. package/out/zero-protocol/src/connect.d.ts.map +1 -1
  335. package/out/zero-protocol/src/connect.js +30 -1
  336. package/out/zero-protocol/src/connect.js.map +1 -1
  337. package/out/zero-protocol/src/down.d.ts +2 -2
  338. package/out/zero-protocol/src/error.d.ts +1 -1
  339. package/out/zero-protocol/src/inspect-down.d.ts +6 -6
  340. package/out/zero-protocol/src/poke.d.ts +11 -4
  341. package/out/zero-protocol/src/poke.d.ts.map +1 -1
  342. package/out/zero-protocol/src/poke.js +3 -2
  343. package/out/zero-protocol/src/poke.js.map +1 -1
  344. package/out/zero-protocol/src/protocol-flag-enum.d.ts +7 -0
  345. package/out/zero-protocol/src/protocol-flag-enum.d.ts.map +1 -0
  346. package/out/zero-protocol/src/protocol-flag-enum.js +7 -0
  347. package/out/zero-protocol/src/protocol-flag-enum.js.map +1 -0
  348. package/out/zero-protocol/src/protocol-flag.d.ts +14 -0
  349. package/out/zero-protocol/src/protocol-flag.d.ts.map +1 -0
  350. package/out/zero-protocol/src/protocol-flag.js +8 -0
  351. package/out/zero-protocol/src/protocol-flag.js.map +1 -0
  352. package/out/zero-protocol/src/protocol-version.d.ts +30 -6
  353. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  354. package/out/zero-protocol/src/protocol-version.js +1 -1
  355. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  356. package/out/zero-protocol/src/query-hash.d.ts +2 -7
  357. package/out/zero-protocol/src/query-hash.d.ts.map +1 -1
  358. package/out/zero-protocol/src/query-hash.js +10 -10
  359. package/out/zero-protocol/src/query-hash.js.map +1 -1
  360. package/out/zero-react/src/use-query.d.ts +4 -5
  361. package/out/zero-react/src/use-query.d.ts.map +1 -1
  362. package/out/zero-react/src/use-query.js +9 -86
  363. package/out/zero-react/src/use-query.js.map +1 -1
  364. package/out/zero-solid/src/solid-view.d.ts +0 -17
  365. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  366. package/out/zero-solid/src/solid-view.js +1 -39
  367. package/out/zero-solid/src/solid-view.js.map +1 -1
  368. package/out/zero-solid/src/use-query.js +3 -5
  369. package/out/zero-solid/src/use-query.js.map +1 -1
  370. package/out/zql/src/builder/builder.d.ts +0 -19
  371. package/out/zql/src/builder/builder.d.ts.map +1 -1
  372. package/out/zql/src/builder/builder.js +11 -28
  373. package/out/zql/src/builder/builder.js.map +1 -1
  374. package/out/zql/src/builder/debug-delegate.d.ts +1 -6
  375. package/out/zql/src/builder/debug-delegate.d.ts.map +1 -1
  376. package/out/zql/src/builder/debug-delegate.js +2 -14
  377. package/out/zql/src/builder/debug-delegate.js.map +1 -1
  378. package/out/zql/src/ivm/array-view.d.ts +0 -29
  379. package/out/zql/src/ivm/array-view.d.ts.map +1 -1
  380. package/out/zql/src/ivm/array-view.js +12 -63
  381. package/out/zql/src/ivm/array-view.js.map +1 -1
  382. package/out/zql/src/ivm/cap.d.ts.map +1 -1
  383. package/out/zql/src/ivm/cap.js +3 -5
  384. package/out/zql/src/ivm/cap.js.map +1 -1
  385. package/out/zql/src/ivm/data.d.ts.map +1 -1
  386. package/out/zql/src/ivm/data.js +3 -8
  387. package/out/zql/src/ivm/data.js.map +1 -1
  388. package/out/zql/src/ivm/exists.d.ts +1 -1
  389. package/out/zql/src/ivm/exists.d.ts.map +1 -1
  390. package/out/zql/src/ivm/exists.js.map +1 -1
  391. package/out/zql/src/ivm/fan-in.d.ts +2 -2
  392. package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
  393. package/out/zql/src/ivm/fan-in.js +5 -6
  394. package/out/zql/src/ivm/fan-in.js.map +1 -1
  395. package/out/zql/src/ivm/fan-out.d.ts +2 -2
  396. package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
  397. package/out/zql/src/ivm/fan-out.js.map +1 -1
  398. package/out/zql/src/ivm/filter-operators.d.ts +6 -7
  399. package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
  400. package/out/zql/src/ivm/filter-operators.js +12 -29
  401. package/out/zql/src/ivm/filter-operators.js.map +1 -1
  402. package/out/zql/src/ivm/filter.d.ts +2 -2
  403. package/out/zql/src/ivm/filter.d.ts.map +1 -1
  404. package/out/zql/src/ivm/filter.js +4 -7
  405. package/out/zql/src/ivm/filter.js.map +1 -1
  406. package/out/zql/src/ivm/flipped-join.js +2 -2
  407. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  408. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +1 -1
  409. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
  410. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +4 -6
  411. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
  412. package/out/zql/src/ivm/memory-source.d.ts +3 -15
  413. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  414. package/out/zql/src/ivm/memory-source.js +23 -57
  415. package/out/zql/src/ivm/memory-source.js.map +1 -1
  416. package/out/zql/src/ivm/operator.d.ts +0 -40
  417. package/out/zql/src/ivm/operator.d.ts.map +1 -1
  418. package/out/zql/src/ivm/operator.js.map +1 -1
  419. package/out/zql/src/ivm/take.d.ts.map +1 -1
  420. package/out/zql/src/ivm/take.js +4 -3
  421. package/out/zql/src/ivm/take.js.map +1 -1
  422. package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
  423. package/out/zql/src/ivm/union-fan-in.js +7 -9
  424. package/out/zql/src/ivm/union-fan-in.js.map +1 -1
  425. package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
  426. package/out/zql/src/ivm/view-apply-change.js +4 -9
  427. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  428. package/out/zql/src/ivm/view.d.ts +0 -15
  429. package/out/zql/src/ivm/view.d.ts.map +1 -1
  430. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  431. package/out/zql/src/mutate/mutator-registry.js +2 -2
  432. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  433. package/out/zql/src/planner/planner-builder.d.ts +3 -12
  434. package/out/zql/src/planner/planner-builder.d.ts.map +1 -1
  435. package/out/zql/src/planner/planner-builder.js +20 -40
  436. package/out/zql/src/planner/planner-builder.js.map +1 -1
  437. package/out/zql/src/planner/planner-connection.d.ts +2 -28
  438. package/out/zql/src/planner/planner-connection.d.ts.map +1 -1
  439. package/out/zql/src/planner/planner-connection.js +8 -108
  440. package/out/zql/src/planner/planner-connection.js.map +1 -1
  441. package/out/zql/src/planner/planner-debug.d.ts +1 -1
  442. package/out/zql/src/planner/planner-debug.d.ts.map +1 -1
  443. package/out/zql/src/planner/planner-debug.js +8 -3
  444. package/out/zql/src/planner/planner-debug.js.map +1 -1
  445. package/out/zql/src/planner/planner-fan-out.d.ts +0 -1
  446. package/out/zql/src/planner/planner-fan-out.d.ts.map +1 -1
  447. package/out/zql/src/planner/planner-fan-out.js +0 -3
  448. package/out/zql/src/planner/planner-fan-out.js.map +1 -1
  449. package/out/zql/src/planner/planner-graph.d.ts +0 -2
  450. package/out/zql/src/planner/planner-graph.d.ts.map +1 -1
  451. package/out/zql/src/planner/planner-graph.js +0 -2
  452. package/out/zql/src/planner/planner-graph.js.map +1 -1
  453. package/out/zql/src/planner/planner-join.d.ts +0 -2
  454. package/out/zql/src/planner/planner-join.d.ts.map +1 -1
  455. package/out/zql/src/planner/planner-join.js +0 -7
  456. package/out/zql/src/planner/planner-join.js.map +1 -1
  457. package/out/zql/src/planner/planner-node.d.ts +1 -2
  458. package/out/zql/src/planner/planner-node.d.ts.map +1 -1
  459. package/out/zql/src/planner/planner-node.js.map +1 -1
  460. package/out/zql/src/planner/planner-source.d.ts +2 -2
  461. package/out/zql/src/planner/planner-source.d.ts.map +1 -1
  462. package/out/zql/src/planner/planner-source.js +2 -2
  463. package/out/zql/src/planner/planner-source.js.map +1 -1
  464. package/out/zql/src/query/query-delegate-base.d.ts +1 -9
  465. package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
  466. package/out/zql/src/query/query-delegate-base.js +36 -132
  467. package/out/zql/src/query/query-delegate-base.js.map +1 -1
  468. package/out/zql/src/query/query-delegate.d.ts +1 -50
  469. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  470. package/out/zql/src/query/query-impl.d.ts +14 -25
  471. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  472. package/out/zql/src/query/query-impl.js +94 -397
  473. package/out/zql/src/query/query-impl.js.map +1 -1
  474. package/out/zql/src/query/query-internals.d.ts +11 -21
  475. package/out/zql/src/query/query-internals.d.ts.map +1 -1
  476. package/out/zql/src/query/query-internals.js.map +1 -1
  477. package/out/zql/src/query/query.d.ts +2 -11
  478. package/out/zql/src/query/query.d.ts.map +1 -1
  479. package/out/zql/src/query/runnable-query-impl.d.ts +2 -3
  480. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  481. package/out/zql/src/query/runnable-query-impl.js +2 -15
  482. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  483. package/out/zql/src/query/typed-view.d.ts +1 -1
  484. package/out/zql/src/query/typed-view.d.ts.map +1 -1
  485. package/out/zqlite/src/db.d.ts +1 -9
  486. package/out/zqlite/src/db.d.ts.map +1 -1
  487. package/out/zqlite/src/db.js +2 -8
  488. package/out/zqlite/src/db.js.map +1 -1
  489. package/out/zqlite/src/query-builder.d.ts +1 -1
  490. package/out/zqlite/src/query-builder.d.ts.map +1 -1
  491. package/out/zqlite/src/query-builder.js +2 -4
  492. package/out/zqlite/src/query-builder.js.map +1 -1
  493. package/out/zqlite/src/query-delegate.d.ts.map +1 -1
  494. package/out/zqlite/src/query-delegate.js +6 -5
  495. package/out/zqlite/src/query-delegate.js.map +1 -1
  496. package/out/zqlite/src/sqlite-cost-model.d.ts.map +1 -1
  497. package/out/zqlite/src/sqlite-cost-model.js +30 -2
  498. package/out/zqlite/src/sqlite-cost-model.js.map +1 -1
  499. package/out/zqlite/src/sqlite-stat-fanout.d.ts.map +1 -1
  500. package/out/zqlite/src/sqlite-stat-fanout.js +5 -4
  501. package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
  502. package/out/zqlite/src/table-source.d.ts +3 -16
  503. package/out/zqlite/src/table-source.d.ts.map +1 -1
  504. package/out/zqlite/src/table-source.js +14 -33
  505. package/out/zqlite/src/table-source.js.map +1 -1
  506. package/package.json +3 -2
  507. package/out/replicache/src/dag/invalid-ref-count-error.d.ts +0 -12
  508. package/out/replicache/src/dag/invalid-ref-count-error.d.ts.map +0 -1
  509. package/out/replicache/src/dag/invalid-ref-count-error.js +0 -19
  510. package/out/replicache/src/dag/invalid-ref-count-error.js.map +0 -1
  511. package/out/shared/src/xxhash32.d.ts +0 -36
  512. package/out/shared/src/xxhash32.d.ts.map +0 -1
  513. package/out/shared/src/xxhash32.js +0 -51
  514. package/out/shared/src/xxhash32.js.map +0 -1
  515. package/out/zero-cache/src/db/index-predicate.d.ts +0 -4
  516. package/out/zero-cache/src/db/index-predicate.d.ts.map +0 -1
  517. package/out/zero-cache/src/db/index-predicate.js +0 -46
  518. package/out/zero-cache/src/db/index-predicate.js.map +0 -1
  519. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts +0 -19
  520. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts.map +0 -1
  521. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js +0 -581
  522. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js.map +0 -1
  523. package/out/zero-cache/src/services/litestream/litestream-checkpointer.js +0 -131
  524. package/out/zero-cache/src/services/litestream/litestream-checkpointer.js.map +0 -1
  525. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +0 -70
  526. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +0 -1
  527. package/out/zero-cache/src/services/litestream/litestream-controller.js +0 -101
  528. package/out/zero-cache/src/services/litestream/litestream-controller.js.map +0 -1
  529. package/out/zero-cache/src/services/profz.d.ts +0 -7
  530. package/out/zero-cache/src/services/profz.d.ts.map +0 -1
  531. package/out/zero-cache/src/services/profz.js +0 -103
  532. package/out/zero-cache/src/services/profz.js.map +0 -1
  533. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts +0 -33
  534. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts.map +0 -1
  535. package/out/zero-cache/src/services/view-syncer/hydration-budget.js +0 -62
  536. package/out/zero-cache/src/services/view-syncer/hydration-budget.js.map +0 -1
  537. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts +0 -51
  538. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts.map +0 -1
  539. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js +0 -78
  540. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js.map +0 -1
  541. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts +0 -95
  542. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts.map +0 -1
  543. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js +0 -155
  544. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js.map +0 -1
  545. package/out/zero-protocol/src/query-hash-visitor.d.ts +0 -81
  546. package/out/zero-protocol/src/query-hash-visitor.d.ts.map +0 -1
  547. package/out/zero-protocol/src/query-hash-visitor.js +0 -324
  548. package/out/zero-protocol/src/query-hash-visitor.js.map +0 -1
  549. package/out/zql/src/builder/correlated-predicate-pushdown.d.ts +0 -43
  550. package/out/zql/src/builder/correlated-predicate-pushdown.d.ts.map +0 -1
  551. package/out/zql/src/builder/correlated-predicate-pushdown.js +0 -161
  552. package/out/zql/src/builder/correlated-predicate-pushdown.js.map +0 -1
  553. package/out/zql/src/ivm/connection-index.d.ts +0 -68
  554. package/out/zql/src/ivm/connection-index.d.ts.map +0 -1
  555. package/out/zql/src/ivm/connection-index.js +0 -149
  556. package/out/zql/src/ivm/connection-index.js.map +0 -1
  557. package/out/zql/src/ivm/deferred-input.d.ts +0 -44
  558. package/out/zql/src/ivm/deferred-input.d.ts.map +0 -1
  559. package/out/zql/src/ivm/deferred-input.js +0 -89
  560. package/out/zql/src/ivm/deferred-input.js.map +0 -1
  561. package/out/zql/src/planner/planner-filter.d.ts +0 -59
  562. package/out/zql/src/planner/planner-filter.d.ts.map +0 -1
  563. package/out/zql/src/planner/planner-filter.js +0 -116
  564. package/out/zql/src/planner/planner-filter.js.map +0 -1
  565. package/out/zql/src/query/query-transitions.d.ts +0 -171
  566. package/out/zql/src/query/query-transitions.d.ts.map +0 -1
  567. package/out/zql/src/query/query-transitions.js +0 -204
  568. package/out/zql/src/query/query-transitions.js.map +0 -1
@@ -1,171 +0,0 @@
1
- import { type ReadonlyJSONValue } from '../../../shared/src/json.ts';
2
- /**
3
- * A transition tree for interning immutable builder objects, modelled on V8's
4
- * hidden-class transitions.
5
- *
6
- * Each node keeps a map from a *transition* (an operation plus its arguments) to
7
- * the node that operation produces. Applying the same operation to the same node
8
- * twice therefore yields the same object both times.
9
- *
10
- * ## Why not hash?
11
- *
12
- * Hashing the resulting AST would work but is far too expensive to do on every
13
- * builder call. Instead a transition is identified by three things, in
14
- * decreasing order of how cheap they are to compare:
15
- *
16
- * 1. `key` — a short string naming the operation. Callers are expected to hand
17
- * in a *stable* string rather than build one per call; see below.
18
- * 2. `value` — the operation's varying argument, when it is a primitive, used
19
- * directly as a `Map` key.
20
- * 3. `delta` — anything left over, compared with {@linkcode deepEqual}.
21
- *
22
- * Splitting 1 from 2 is what makes this fast. Folding the value into the key
23
- * instead means building a fresh string on every call, and a fresh string has to
24
- * be hashed from scratch before a `Map` can look it up: measured at ~148ns,
25
- * against ~10ns to look up the caller's own string, whose hash V8 has already
26
- * cached on the string object. That difference is larger than everything else a
27
- * transition does.
28
- *
29
- * Comparing only the delta is sound because the parent node is already canonical:
30
- * two children of the same parent are equal exactly when the operations that
31
- * produced them are equal. We never deep-compare a whole AST.
32
- *
33
- * ## Liveness
34
- *
35
- * Children point back at their parents strongly (see `QueryImpl`), so holding a
36
- * query holds its whole ancestor spine and re-deriving it from the root gives
37
- * the same object back. The other direction has to be weak, or an interned root
38
- * — which lives as long as its schema — would retain every query ever derived
39
- * from it.
40
- *
41
- * Weak is expensive, though: `new WeakRef` costs on the order of a hundred
42
- * nanoseconds, more than everything else a transition does put together, and it
43
- * adds GC work later. So the *first* transition out of a node is held strongly
44
- * instead, in fields on this object, with no `WeakRef` at all.
45
- *
46
- * That is safe because strong first-children form a path, not a tree: each node
47
- * pins at most one child, which pins at most one of its own. The retained set
48
- * per root is bounded by the depth of a builder chain — a handful of queries —
49
- * rather than by how many distinct queries an app builds. Everything past the
50
- * first child is weak, so the unbounded cases (a search box typing into
51
- * `where:title:=:s<text>`, a row id per list item) stay collectible.
52
- *
53
- * It is also where the wins are: a chain like `q.where(…).orderBy(…).limit(…)`
54
- * gives every node exactly one child, so building it allocates no `WeakRef`s and
55
- * looks up through a field compare rather than a hash lookup.
56
- *
57
- * What a collected child leaves behind is a cleared `WeakRef` and its map key. A
58
- * lookup drops those as it walks, which covers every key that is asked for
59
- * again. A key that is *never* asked for again is handled by the sweep.
60
- *
61
- * ## Best effort
62
- *
63
- * Interning is a cache, not a guarantee: a missed lookup only costs an extra
64
- * object. See {@linkcode MAX_SCAN} for the one case where we deliberately give
65
- * up.
66
- *
67
- * ## Identity vs. hash
68
- *
69
- * Identity implies an equal query hash, but the tree alone does not give the
70
- * converse. `normalizeAST` sorts `related` and `and`/`or` conditions, so
71
- * `q.where(a).where(b)` and `q.where(b).where(a)` hash the same while being
72
- * distinct paths, and so distinct nodes. {@linkcode HashIndex} is the second
73
- * level that folds those together once they have been hashed. Callers that
74
- * need the normalizing behavior for a query that may not have been must keep
75
- * using the hash.
76
- */
77
- /**
78
- * The delta identifying a transition, or `undefined` when the key already
79
- * determines the result on its own.
80
- */
81
- export type Delta = ReadonlyJSONValue | undefined;
82
- /** The varying argument of a transition, when it is one. */
83
- export type TransitionValue = string | number | boolean | null | undefined;
84
- /**
85
- * The longest `deepEqual` scan we are willing to do on a lookup.
86
- *
87
- * This is a *latency* bound, not a memory bound — memory is already handled,
88
- * since entries are weak and are pruned both by the sweep and by any lookup that
89
- * walks past them, so a bucket only ever holds children that are still alive.
90
- *
91
- * Note what happens at the limit: we stop *storing*, we do not evict. Evicting
92
- * would de-intern objects that are still in use, and on a sequential sweep of a
93
- * live set larger than the limit it drives the hit rate to zero — each lookup
94
- * throws out the entry the next one needs. Refusing to store instead leaves
95
- * every already-shared sibling shared and degrades the surplus to the old
96
- * behavior of a fresh instance per call.
97
- *
98
- * Buckets should rarely get near this. Keys carry the discriminating value
99
- * wherever it is cheap to, and a key that carries it is *exact*, so it costs no
100
- * comparison at all: every simple comparison goes that way, and so does a
101
- * one-hop `exists`, via its sub-query's identity. What is left sharing a bucket
102
- * is two-hop `exists`, the `and`/`or` trees an expression factory builds, and
103
- * relationships whose callback varies.
104
- */
105
- export declare const MAX_SCAN = 64;
106
- /** The transitions out of one node. */
107
- export declare class Transitions<T extends object> {
108
- #private;
109
- lookupBounded(key: string): T | undefined;
110
- /**
111
- * Records a transition whose key space is finite and schema-derived — the base
112
- * sub-query handed to a `related`/`exists` callback, keyed by relationship
113
- * name.
114
- *
115
- * These are held strongly. Retention is bounded by the number of relationships
116
- * on the table, so it cannot grow with what an app queries for, and in exchange
117
- * a relationship traversal allocates no `WeakRef`. Anything keyed by a *value*
118
- * — a row id, a search string, a limit — must not come through here.
119
- */
120
- storeBounded(key: string, value: T): void;
121
- lookup(key: string, value: TransitionValue, delta: Delta): T | undefined;
122
- store(key: string, value: TransitionValue, delta: Delta, node: T): void;
123
- /**
124
- * Re-points the transition that produced `from` at `to`, so the next lookup
125
- * along that path yields `to` instead. This is how {@linkcode HashIndex}
126
- * converges two paths on one node: `from` keeps its identity, since it has
127
- * already been handed out, and its path is redirected for the rebuilds that
128
- * follow.
129
- *
130
- * Scans rather than taking a key. This runs once per redirected path, so a
131
- * walk here is cheaper than the fields every node would need to carry to
132
- * name its own transition.
133
- */
134
- replace(from: T, to: T): boolean;
135
- }
136
- /**
137
- * The second level of interning: nodes keyed by *content* rather than by the
138
- * path that built them.
139
- *
140
- * The transition tree cannot see that `q.where(a).where(b)` and
141
- * `q.where(b).where(a)` are the same query. `normalizeAST` sorts conditions
142
- * and `related` entries, so the two build byte-identical ASTs, but they are
143
- * different paths and so different nodes. This index closes that gap, keyed by
144
- * the query's hash.
145
- *
146
- * It is consulted when a query is *hashed*, not when it is built. Hashing on
147
- * every tree miss would make a cold chain pay for a hash per node, where the
148
- * uninterned code paid for one at the end, if at all -- and server-side queries
149
- * are built cold, once, per request. The consumers that key by hash already
150
- * hash the queries they care about, so doing the work there costs one map
151
- * lookup on top of a hash that was being computed anyway, and nothing at all
152
- * for a query nobody hashes.
153
- *
154
- * On a hit the query being hashed keeps its identity, since it has already
155
- * been handed out. Its *transition* is re-pointed at the existing node instead
156
- * (see {@linkcode Transitions.replace}), so the next rebuild along that path
157
- * yields the shared instance. As with the tree this is a cache: the rebuild
158
- * after a redirect is what converges, not the call that found the duplicate.
159
- *
160
- * One index per root, which is what scopes it. Two roots never share an index,
161
- * so queries against different schemas or different delegates -- neither of
162
- * which the hash covers -- can never be conflated. Entries are weak: a cleared
163
- * one is dropped by the lookup that finds it, or by a sweep once the map has
164
- * doubled since the last one.
165
- */
166
- export declare class HashIndex<T extends object> {
167
- #private;
168
- get(hash: string): T | undefined;
169
- set(hash: string, node: T): void;
170
- }
171
- //# sourceMappingURL=query-transitions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-transitions.d.ts","sourceRoot":"","sources":["../../../../../zql/src/query/query-transitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAiBlD,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,QAAQ,KAAK,CAAC;AAK3B,uCAAuC;AACvC,qBAAa,WAAW,CAAC,CAAC,SAAS,MAAM;;IAiBvC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIzC;;;;;;;;;OASG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIzC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,SAAS;IAkDxE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI;IAgCvE;;;;;;;;;;OAUG;IACH,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,OAAO;CA2EjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM;;IAIrC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAYhC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI;CAajC"}
@@ -1,204 +0,0 @@
1
- import { deepEqual } from "../../../shared/src/json.js";
2
- import { getOrInsertComputed, newMap } from "../../../shared/src/map.js";
3
- /** How large the weak map must get before its first sweep. */
4
- var SWEEP_INITIAL = 64;
5
- /** The transitions out of one node. */
6
- var Transitions = class {
7
- #firstKey;
8
- #firstValue;
9
- #firstDelta;
10
- #first;
11
- #bounded;
12
- #rest;
13
- #sweepAt = SWEEP_INITIAL;
14
- #restSize = 0;
15
- lookupBounded(key) {
16
- return this.#bounded?.get(key);
17
- }
18
- /**
19
- * Records a transition whose key space is finite and schema-derived — the base
20
- * sub-query handed to a `related`/`exists` callback, keyed by relationship
21
- * name.
22
- *
23
- * These are held strongly. Retention is bounded by the number of relationships
24
- * on the table, so it cannot grow with what an app queries for, and in exchange
25
- * a relationship traversal allocates no `WeakRef`. Anything keyed by a *value*
26
- * — a row id, a search string, a limit — must not come through here.
27
- */
28
- storeBounded(key, value) {
29
- (this.#bounded ??= /* @__PURE__ */ new Map()).set(key, value);
30
- }
31
- lookup(key, value, delta) {
32
- if (this.#firstKey === key && this.#firstValue === value && deepEqual(this.#firstDelta, delta)) return this.#first;
33
- const byValue = this.#rest?.get(key);
34
- if (byValue === void 0) return;
35
- const bucket = byValue.get(value);
36
- if (bucket === void 0) return;
37
- if (!(bucket instanceof Set)) {
38
- const found = bucket.ref.deref();
39
- if (found === void 0) {
40
- byValue.delete(value);
41
- this.#restSize--;
42
- return;
43
- }
44
- return deepEqual(bucket.delta, delta) ? found : void 0;
45
- }
46
- for (const entry of bucket) {
47
- const found = entry.ref.deref();
48
- if (found === void 0) {
49
- bucket.delete(entry);
50
- this.#restSize--;
51
- continue;
52
- }
53
- if (deepEqual(entry.delta, delta)) return found;
54
- }
55
- if (bucket.size === 0) byValue.delete(value);
56
- }
57
- store(key, value, delta, node) {
58
- if (this.#firstKey === void 0) {
59
- this.#firstKey = key;
60
- this.#firstValue = value;
61
- this.#firstDelta = delta;
62
- this.#first = node;
63
- return;
64
- }
65
- const rest = this.#rest ??= /* @__PURE__ */ new Map();
66
- const byValue = getOrInsertComputed(rest, key, newMap);
67
- const entry = {
68
- delta,
69
- ref: new WeakRef(node)
70
- };
71
- const bucket = byValue.get(value);
72
- if (bucket === void 0) byValue.set(value, entry);
73
- else if (!(bucket instanceof Set)) byValue.set(value, new Set([bucket, entry]));
74
- else {
75
- if (bucket.size >= 64) return;
76
- bucket.add(entry);
77
- }
78
- this.#restSize++;
79
- this.#maybeSweep(rest);
80
- }
81
- /**
82
- * Re-points the transition that produced `from` at `to`, so the next lookup
83
- * along that path yields `to` instead. This is how {@linkcode HashIndex}
84
- * converges two paths on one node: `from` keeps its identity, since it has
85
- * already been handed out, and its path is redirected for the rebuilds that
86
- * follow.
87
- *
88
- * Scans rather than taking a key. This runs once per redirected path, so a
89
- * walk here is cheaper than the fields every node would need to carry to
90
- * name its own transition.
91
- */
92
- replace(from, to) {
93
- if (this.#first === from) {
94
- this.#first = to;
95
- return true;
96
- }
97
- const rest = this.#rest;
98
- if (rest === void 0) return false;
99
- for (const byValue of rest.values()) for (const [value, bucket] of byValue) {
100
- if (!(bucket instanceof Set)) {
101
- if (bucket.ref.deref() === from) {
102
- byValue.set(value, {
103
- delta: bucket.delta,
104
- ref: new WeakRef(to)
105
- });
106
- return true;
107
- }
108
- continue;
109
- }
110
- for (const entry of bucket) if (entry.ref.deref() === from) {
111
- bucket.delete(entry);
112
- bucket.add({
113
- delta: entry.delta,
114
- ref: new WeakRef(to)
115
- });
116
- return true;
117
- }
118
- }
119
- return false;
120
- }
121
- /**
122
- * Drops entries for collected values, if the map has grown enough to be worth
123
- * walking.
124
- *
125
- * A lookup already prunes whatever it walks past, which covers every key that
126
- * is asked for again. This is for the key that is not: a miss on a fresh key
127
- * returns without touching any existing entry, so nothing would ever notice
128
- * that those had died. Doubling the threshold off whatever survives keeps this
129
- * amortized O(1) per insert whether or not there was anything to reclaim, and
130
- * it is self-limiting — only a node that keeps taking inserts can keep
131
- * accumulating, and taking inserts is what triggers the sweep.
132
- */
133
- #maybeSweep(rest) {
134
- if (this.#restSize < this.#sweepAt) return;
135
- let live = 0;
136
- for (const [key, byValue] of rest) {
137
- for (const [value, bucket] of byValue) {
138
- if (!(bucket instanceof Set)) {
139
- if (bucket.ref.deref() === void 0) byValue.delete(value);
140
- else live++;
141
- continue;
142
- }
143
- for (const entry of bucket) if (entry.ref.deref() === void 0) bucket.delete(entry);
144
- else live++;
145
- if (bucket.size === 0) byValue.delete(value);
146
- }
147
- if (byValue.size === 0) rest.delete(key);
148
- }
149
- this.#restSize = live;
150
- this.#sweepAt = Math.max(SWEEP_INITIAL, live * 2);
151
- }
152
- };
153
- /**
154
- * The second level of interning: nodes keyed by *content* rather than by the
155
- * path that built them.
156
- *
157
- * The transition tree cannot see that `q.where(a).where(b)` and
158
- * `q.where(b).where(a)` are the same query. `normalizeAST` sorts conditions
159
- * and `related` entries, so the two build byte-identical ASTs, but they are
160
- * different paths and so different nodes. This index closes that gap, keyed by
161
- * the query's hash.
162
- *
163
- * It is consulted when a query is *hashed*, not when it is built. Hashing on
164
- * every tree miss would make a cold chain pay for a hash per node, where the
165
- * uninterned code paid for one at the end, if at all -- and server-side queries
166
- * are built cold, once, per request. The consumers that key by hash already
167
- * hash the queries they care about, so doing the work there costs one map
168
- * lookup on top of a hash that was being computed anyway, and nothing at all
169
- * for a query nobody hashes.
170
- *
171
- * On a hit the query being hashed keeps its identity, since it has already
172
- * been handed out. Its *transition* is re-pointed at the existing node instead
173
- * (see {@linkcode Transitions.replace}), so the next rebuild along that path
174
- * yields the shared instance. As with the tree this is a cache: the rebuild
175
- * after a redirect is what converges, not the call that found the duplicate.
176
- *
177
- * One index per root, which is what scopes it. Two roots never share an index,
178
- * so queries against different schemas or different delegates -- neither of
179
- * which the hash covers -- can never be conflated. Entries are weak: a cleared
180
- * one is dropped by the lookup that finds it, or by a sweep once the map has
181
- * doubled since the last one.
182
- */
183
- var HashIndex = class {
184
- #byHash = /* @__PURE__ */ new Map();
185
- #sweepAt = SWEEP_INITIAL;
186
- get(hash) {
187
- const ref = this.#byHash.get(hash);
188
- if (ref === void 0) return;
189
- const node = ref.deref();
190
- if (node === void 0) this.#byHash.delete(hash);
191
- return node;
192
- }
193
- set(hash, node) {
194
- const byHash = this.#byHash;
195
- byHash.set(hash, new WeakRef(node));
196
- if (byHash.size < this.#sweepAt) return;
197
- for (const [h, ref] of byHash) if (ref.deref() === void 0) byHash.delete(h);
198
- this.#sweepAt = Math.max(SWEEP_INITIAL, byHash.size * 2);
199
- }
200
- };
201
- //#endregion
202
- export { HashIndex, Transitions };
203
-
204
- //# sourceMappingURL=query-transitions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-transitions.js","names":["#bounded","#firstKey","#firstValue","#firstDelta","#first","#rest","#restSize","#maybeSweep","#sweepAt","#byHash"],"sources":["../../../../../zql/src/query/query-transitions.ts"],"sourcesContent":["import {deepEqual, type ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {getOrInsertComputed, newMap} from '../../../shared/src/map.ts';\n\n/**\n * A transition tree for interning immutable builder objects, modelled on V8's\n * hidden-class transitions.\n *\n * Each node keeps a map from a *transition* (an operation plus its arguments) to\n * the node that operation produces. Applying the same operation to the same node\n * twice therefore yields the same object both times.\n *\n * ## Why not hash?\n *\n * Hashing the resulting AST would work but is far too expensive to do on every\n * builder call. Instead a transition is identified by three things, in\n * decreasing order of how cheap they are to compare:\n *\n * 1. `key` — a short string naming the operation. Callers are expected to hand\n * in a *stable* string rather than build one per call; see below.\n * 2. `value` — the operation's varying argument, when it is a primitive, used\n * directly as a `Map` key.\n * 3. `delta` — anything left over, compared with {@linkcode deepEqual}.\n *\n * Splitting 1 from 2 is what makes this fast. Folding the value into the key\n * instead means building a fresh string on every call, and a fresh string has to\n * be hashed from scratch before a `Map` can look it up: measured at ~148ns,\n * against ~10ns to look up the caller's own string, whose hash V8 has already\n * cached on the string object. That difference is larger than everything else a\n * transition does.\n *\n * Comparing only the delta is sound because the parent node is already canonical:\n * two children of the same parent are equal exactly when the operations that\n * produced them are equal. We never deep-compare a whole AST.\n *\n * ## Liveness\n *\n * Children point back at their parents strongly (see `QueryImpl`), so holding a\n * query holds its whole ancestor spine and re-deriving it from the root gives\n * the same object back. The other direction has to be weak, or an interned root\n * — which lives as long as its schema — would retain every query ever derived\n * from it.\n *\n * Weak is expensive, though: `new WeakRef` costs on the order of a hundred\n * nanoseconds, more than everything else a transition does put together, and it\n * adds GC work later. So the *first* transition out of a node is held strongly\n * instead, in fields on this object, with no `WeakRef` at all.\n *\n * That is safe because strong first-children form a path, not a tree: each node\n * pins at most one child, which pins at most one of its own. The retained set\n * per root is bounded by the depth of a builder chain — a handful of queries —\n * rather than by how many distinct queries an app builds. Everything past the\n * first child is weak, so the unbounded cases (a search box typing into\n * `where:title:=:s<text>`, a row id per list item) stay collectible.\n *\n * It is also where the wins are: a chain like `q.where(…).orderBy(…).limit(…)`\n * gives every node exactly one child, so building it allocates no `WeakRef`s and\n * looks up through a field compare rather than a hash lookup.\n *\n * What a collected child leaves behind is a cleared `WeakRef` and its map key. A\n * lookup drops those as it walks, which covers every key that is asked for\n * again. A key that is *never* asked for again is handled by the sweep.\n *\n * ## Best effort\n *\n * Interning is a cache, not a guarantee: a missed lookup only costs an extra\n * object. See {@linkcode MAX_SCAN} for the one case where we deliberately give\n * up.\n *\n * ## Identity vs. hash\n *\n * Identity implies an equal query hash, but the tree alone does not give the\n * converse. `normalizeAST` sorts `related` and `and`/`or` conditions, so\n * `q.where(a).where(b)` and `q.where(b).where(a)` hash the same while being\n * distinct paths, and so distinct nodes. {@linkcode HashIndex} is the second\n * level that folds those together once they have been hashed. Callers that\n * need the normalizing behavior for a query that may not have been must keep\n * using the hash.\n */\n\n/**\n * The delta identifying a transition, or `undefined` when the key already\n * determines the result on its own.\n */\nexport type Delta = ReadonlyJSONValue | undefined;\n\ntype Entry<T extends object> = {\n readonly delta: Delta;\n readonly ref: WeakRef<T>;\n};\n\n/**\n * A bucket holds a bare entry in the common single-entry case and is promoted to\n * a `Set` only on collision, so the usual transition allocates no container.\n *\n * A `Set` rather than an array: deleting during iteration is well defined, so a\n * lookup prunes collected entries and stops at its match in a single pass, and\n * removing an entry is O(1) rather than a scan.\n */\ntype Bucket<T extends object> = Entry<T> | Set<Entry<T>>;\n\n/** The varying argument of a transition, when it is one. */\nexport type TransitionValue = string | number | boolean | null | undefined;\n\n/**\n * The longest `deepEqual` scan we are willing to do on a lookup.\n *\n * This is a *latency* bound, not a memory bound — memory is already handled,\n * since entries are weak and are pruned both by the sweep and by any lookup that\n * walks past them, so a bucket only ever holds children that are still alive.\n *\n * Note what happens at the limit: we stop *storing*, we do not evict. Evicting\n * would de-intern objects that are still in use, and on a sequential sweep of a\n * live set larger than the limit it drives the hit rate to zero — each lookup\n * throws out the entry the next one needs. Refusing to store instead leaves\n * every already-shared sibling shared and degrades the surplus to the old\n * behavior of a fresh instance per call.\n *\n * Buckets should rarely get near this. Keys carry the discriminating value\n * wherever it is cheap to, and a key that carries it is *exact*, so it costs no\n * comparison at all: every simple comparison goes that way, and so does a\n * one-hop `exists`, via its sub-query's identity. What is left sharing a bucket\n * is two-hop `exists`, the `and`/`or` trees an expression factory builds, and\n * relationships whose callback varies.\n */\nexport const MAX_SCAN = 64;\n\n/** How large the weak map must get before its first sweep. */\nconst SWEEP_INITIAL = 64;\n\n/** The transitions out of one node. */\nexport class Transitions<T extends object> {\n // The first transition, held strongly and in place. See \"Liveness\" above.\n #firstKey: string | undefined;\n #firstValue: TransitionValue;\n #firstDelta: Delta;\n #first: T | undefined;\n\n // Transitions whose key space is finite and comes from the schema rather than\n // from user data, held strongly. See `storeBounded`.\n #bounded: Map<string, T> | undefined;\n\n // Everything else, weakly. Allocated only if there is a second. Nested so the\n // value stays a `Map` key of its own rather than part of the string.\n #rest: Map<string, Map<TransitionValue, Bucket<T>>> | undefined;\n #sweepAt = SWEEP_INITIAL;\n #restSize = 0;\n\n lookupBounded(key: string): T | undefined {\n return this.#bounded?.get(key);\n }\n\n /**\n * Records a transition whose key space is finite and schema-derived — the base\n * sub-query handed to a `related`/`exists` callback, keyed by relationship\n * name.\n *\n * These are held strongly. Retention is bounded by the number of relationships\n * on the table, so it cannot grow with what an app queries for, and in exchange\n * a relationship traversal allocates no `WeakRef`. Anything keyed by a *value*\n * — a row id, a search string, a limit — must not come through here.\n */\n storeBounded(key: string, value: T): void {\n (this.#bounded ??= new Map()).set(key, value);\n }\n\n lookup(key: string, value: TransitionValue, delta: Delta): T | undefined {\n if (\n this.#firstKey === key &&\n this.#firstValue === value &&\n deepEqual(this.#firstDelta, delta)\n ) {\n return this.#first;\n }\n const byValue = this.#rest?.get(key);\n if (byValue === undefined) {\n return undefined;\n }\n const bucket = byValue.get(value);\n if (bucket === undefined) {\n return undefined;\n }\n\n if (!(bucket instanceof Set)) {\n const found = bucket.ref.deref();\n if (found === undefined) {\n byValue.delete(value);\n this.#restSize--;\n return undefined;\n }\n // deepEqual short-circuits on reference equality, which is the fast path\n // we rely on for deltas built out of already-interned sub-queries.\n return deepEqual(bucket.delta, delta) ? found : undefined;\n }\n\n // One pass: drop what has been collected, stop at the match. Deleting from a\n // Set while iterating it is well defined — the iterator simply skips what is\n // gone — so this stays O(n) with no compaction step, and returns early on a\n // hit rather than walking the whole bucket first.\n for (const entry of bucket) {\n const found = entry.ref.deref();\n if (found === undefined) {\n bucket.delete(entry);\n this.#restSize--;\n continue;\n }\n if (deepEqual(entry.delta, delta)) {\n return found;\n }\n }\n if (bucket.size === 0) {\n byValue.delete(value);\n }\n return undefined;\n }\n\n store(key: string, value: TransitionValue, delta: Delta, node: T): void {\n if (this.#firstKey === undefined) {\n this.#firstKey = key;\n this.#firstValue = value;\n this.#firstDelta = delta;\n this.#first = node;\n return;\n }\n\n const rest = (this.#rest ??= new Map());\n const byValue = getOrInsertComputed(rest, key, newMap);\n\n const entry: Entry<T> = {delta, ref: new WeakRef(node)};\n const bucket = byValue.get(value);\n\n if (bucket === undefined) {\n byValue.set(value, entry);\n } else if (!(bucket instanceof Set)) {\n byValue.set(value, new Set([bucket, entry]));\n } else {\n if (bucket.size >= MAX_SCAN) {\n // Leave the bucket alone; see MAX_SCAN. `node` is simply not shared.\n // A store only follows a failed lookup, which has just pruned, so this\n // is measured against entries that are actually still alive.\n return;\n }\n bucket.add(entry);\n }\n this.#restSize++;\n this.#maybeSweep(rest);\n }\n\n /**\n * Re-points the transition that produced `from` at `to`, so the next lookup\n * along that path yields `to` instead. This is how {@linkcode HashIndex}\n * converges two paths on one node: `from` keeps its identity, since it has\n * already been handed out, and its path is redirected for the rebuilds that\n * follow.\n *\n * Scans rather than taking a key. This runs once per redirected path, so a\n * walk here is cheaper than the fields every node would need to carry to\n * name its own transition.\n */\n replace(from: T, to: T): boolean {\n if (this.#first === from) {\n this.#first = to;\n return true;\n }\n const rest = this.#rest;\n if (rest === undefined) {\n return false;\n }\n for (const byValue of rest.values()) {\n for (const [value, bucket] of byValue) {\n if (!(bucket instanceof Set)) {\n if (bucket.ref.deref() === from) {\n byValue.set(value, {delta: bucket.delta, ref: new WeakRef(to)});\n return true;\n }\n continue;\n }\n for (const entry of bucket) {\n if (entry.ref.deref() === from) {\n bucket.delete(entry);\n bucket.add({delta: entry.delta, ref: new WeakRef(to)});\n return true;\n }\n }\n }\n }\n return false;\n }\n\n /**\n * Drops entries for collected values, if the map has grown enough to be worth\n * walking.\n *\n * A lookup already prunes whatever it walks past, which covers every key that\n * is asked for again. This is for the key that is not: a miss on a fresh key\n * returns without touching any existing entry, so nothing would ever notice\n * that those had died. Doubling the threshold off whatever survives keeps this\n * amortized O(1) per insert whether or not there was anything to reclaim, and\n * it is self-limiting — only a node that keeps taking inserts can keep\n * accumulating, and taking inserts is what triggers the sweep.\n */\n #maybeSweep(rest: Map<string, Map<TransitionValue, Bucket<T>>>): void {\n if (this.#restSize < this.#sweepAt) {\n return;\n }\n let live = 0;\n for (const [key, byValue] of rest) {\n for (const [value, bucket] of byValue) {\n if (!(bucket instanceof Set)) {\n if (bucket.ref.deref() === undefined) {\n byValue.delete(value);\n } else {\n live++;\n }\n continue;\n }\n for (const entry of bucket) {\n if (entry.ref.deref() === undefined) {\n bucket.delete(entry);\n } else {\n live++;\n }\n }\n if (bucket.size === 0) {\n byValue.delete(value);\n }\n }\n if (byValue.size === 0) {\n rest.delete(key);\n }\n }\n this.#restSize = live;\n this.#sweepAt = Math.max(SWEEP_INITIAL, live * 2);\n }\n}\n\n/**\n * The second level of interning: nodes keyed by *content* rather than by the\n * path that built them.\n *\n * The transition tree cannot see that `q.where(a).where(b)` and\n * `q.where(b).where(a)` are the same query. `normalizeAST` sorts conditions\n * and `related` entries, so the two build byte-identical ASTs, but they are\n * different paths and so different nodes. This index closes that gap, keyed by\n * the query's hash.\n *\n * It is consulted when a query is *hashed*, not when it is built. Hashing on\n * every tree miss would make a cold chain pay for a hash per node, where the\n * uninterned code paid for one at the end, if at all -- and server-side queries\n * are built cold, once, per request. The consumers that key by hash already\n * hash the queries they care about, so doing the work there costs one map\n * lookup on top of a hash that was being computed anyway, and nothing at all\n * for a query nobody hashes.\n *\n * On a hit the query being hashed keeps its identity, since it has already\n * been handed out. Its *transition* is re-pointed at the existing node instead\n * (see {@linkcode Transitions.replace}), so the next rebuild along that path\n * yields the shared instance. As with the tree this is a cache: the rebuild\n * after a redirect is what converges, not the call that found the duplicate.\n *\n * One index per root, which is what scopes it. Two roots never share an index,\n * so queries against different schemas or different delegates -- neither of\n * which the hash covers -- can never be conflated. Entries are weak: a cleared\n * one is dropped by the lookup that finds it, or by a sweep once the map has\n * doubled since the last one.\n */\nexport class HashIndex<T extends object> {\n readonly #byHash = new Map<string, WeakRef<T>>();\n #sweepAt = SWEEP_INITIAL;\n\n get(hash: string): T | undefined {\n const ref = this.#byHash.get(hash);\n if (ref === undefined) {\n return undefined;\n }\n const node = ref.deref();\n if (node === undefined) {\n this.#byHash.delete(hash);\n }\n return node;\n }\n\n set(hash: string, node: T): void {\n const byHash = this.#byHash;\n byHash.set(hash, new WeakRef(node));\n if (byHash.size < this.#sweepAt) {\n return;\n }\n for (const [h, ref] of byHash) {\n if (ref.deref() === undefined) {\n byHash.delete(h);\n }\n }\n this.#sweepAt = Math.max(SWEEP_INITIAL, byHash.size * 2);\n }\n}\n"],"mappings":";;;AA+HA,IAAM,gBAAgB;;AAGtB,IAAa,cAAb,MAA2C;CAEzC;CACA;CACA;CACA;CAIA;CAIA;CACA,WAAW;CACX,YAAY;CAEZ,cAAc,KAA4B;EACxC,OAAO,KAAKA,UAAU,IAAI,GAAG;CAC/B;;;;;;;;;;;CAYA,aAAa,KAAa,OAAgB;EACxC,CAAC,KAAKA,6BAAa,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK;CAC9C;CAEA,OAAO,KAAa,OAAwB,OAA6B;EACvE,IACE,KAAKC,cAAc,OACnB,KAAKC,gBAAgB,SACrB,UAAU,KAAKC,aAAa,KAAK,GAEjC,OAAO,KAAKC;EAEd,MAAM,UAAU,KAAKC,OAAO,IAAI,GAAG;EACnC,IAAI,YAAY,KAAA,GACd;EAEF,MAAM,SAAS,QAAQ,IAAI,KAAK;EAChC,IAAI,WAAW,KAAA,GACb;EAGF,IAAI,EAAE,kBAAkB,MAAM;GAC5B,MAAM,QAAQ,OAAO,IAAI,MAAM;GAC/B,IAAI,UAAU,KAAA,GAAW;IACvB,QAAQ,OAAO,KAAK;IACpB,KAAKC;IACL;GACF;GAGA,OAAO,UAAU,OAAO,OAAO,KAAK,IAAI,QAAQ,KAAA;EAClD;EAMA,KAAK,MAAM,SAAS,QAAQ;GAC1B,MAAM,QAAQ,MAAM,IAAI,MAAM;GAC9B,IAAI,UAAU,KAAA,GAAW;IACvB,OAAO,OAAO,KAAK;IACnB,KAAKA;IACL;GACF;GACA,IAAI,UAAU,MAAM,OAAO,KAAK,GAC9B,OAAO;EAEX;EACA,IAAI,OAAO,SAAS,GAClB,QAAQ,OAAO,KAAK;CAGxB;CAEA,MAAM,KAAa,OAAwB,OAAc,MAAe;EACtE,IAAI,KAAKL,cAAc,KAAA,GAAW;GAChC,KAAKA,YAAY;GACjB,KAAKC,cAAc;GACnB,KAAKC,cAAc;GACnB,KAAKC,SAAS;GACd;EACF;EAEA,MAAM,OAAQ,KAAKC,0BAAU,IAAI,IAAI;EACrC,MAAM,UAAU,oBAAoB,MAAM,KAAK,MAAM;EAErD,MAAM,QAAkB;GAAC;GAAO,KAAK,IAAI,QAAQ,IAAI;EAAC;EACtD,MAAM,SAAS,QAAQ,IAAI,KAAK;EAEhC,IAAI,WAAW,KAAA,GACb,QAAQ,IAAI,OAAO,KAAK;OACnB,IAAI,EAAE,kBAAkB,MAC7B,QAAQ,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC;OACtC;GACL,IAAI,OAAO,QAAA,IAIT;GAEF,OAAO,IAAI,KAAK;EAClB;EACA,KAAKC;EACL,KAAKC,YAAY,IAAI;CACvB;;;;;;;;;;;;CAaA,QAAQ,MAAS,IAAgB;EAC/B,IAAI,KAAKH,WAAW,MAAM;GACxB,KAAKA,SAAS;GACd,OAAO;EACT;EACA,MAAM,OAAO,KAAKC;EAClB,IAAI,SAAS,KAAA,GACX,OAAO;EAET,KAAK,MAAM,WAAW,KAAK,OAAO,GAChC,KAAK,MAAM,CAAC,OAAO,WAAW,SAAS;GACrC,IAAI,EAAE,kBAAkB,MAAM;IAC5B,IAAI,OAAO,IAAI,MAAM,MAAM,MAAM;KAC/B,QAAQ,IAAI,OAAO;MAAC,OAAO,OAAO;MAAO,KAAK,IAAI,QAAQ,EAAE;KAAC,CAAC;KAC9D,OAAO;IACT;IACA;GACF;GACA,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,IAAI,MAAM,MAAM,MAAM;IAC9B,OAAO,OAAO,KAAK;IACnB,OAAO,IAAI;KAAC,OAAO,MAAM;KAAO,KAAK,IAAI,QAAQ,EAAE;IAAC,CAAC;IACrD,OAAO;GACT;EAEJ;EAEF,OAAO;CACT;;;;;;;;;;;;;CAcA,YAAY,MAA0D;EACpE,IAAI,KAAKC,YAAY,KAAKE,UACxB;EAEF,IAAI,OAAO;EACX,KAAK,MAAM,CAAC,KAAK,YAAY,MAAM;GACjC,KAAK,MAAM,CAAC,OAAO,WAAW,SAAS;IACrC,IAAI,EAAE,kBAAkB,MAAM;KAC5B,IAAI,OAAO,IAAI,MAAM,MAAM,KAAA,GACzB,QAAQ,OAAO,KAAK;UAEpB;KAEF;IACF;IACA,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,IAAI,MAAM,MAAM,KAAA,GACxB,OAAO,OAAO,KAAK;SAEnB;IAGJ,IAAI,OAAO,SAAS,GAClB,QAAQ,OAAO,KAAK;GAExB;GACA,IAAI,QAAQ,SAAS,GACnB,KAAK,OAAO,GAAG;EAEnB;EACA,KAAKF,YAAY;EACjB,KAAKE,WAAW,KAAK,IAAI,eAAe,OAAO,CAAC;CAClD;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAa,YAAb,MAAyC;CACvC,0BAAmB,IAAI,IAAwB;CAC/C,WAAW;CAEX,IAAI,MAA6B;EAC/B,MAAM,MAAM,KAAKC,QAAQ,IAAI,IAAI;EACjC,IAAI,QAAQ,KAAA,GACV;EAEF,MAAM,OAAO,IAAI,MAAM;EACvB,IAAI,SAAS,KAAA,GACX,KAAKA,QAAQ,OAAO,IAAI;EAE1B,OAAO;CACT;CAEA,IAAI,MAAc,MAAe;EAC/B,MAAM,SAAS,KAAKA;EACpB,OAAO,IAAI,MAAM,IAAI,QAAQ,IAAI,CAAC;EAClC,IAAI,OAAO,OAAO,KAAKD,UACrB;EAEF,KAAK,MAAM,CAAC,GAAG,QAAQ,QACrB,IAAI,IAAI,MAAM,MAAM,KAAA,GAClB,OAAO,OAAO,CAAC;EAGnB,KAAKA,WAAW,KAAK,IAAI,eAAe,OAAO,OAAO,CAAC;CACzD;AACF"}