@rocicorp/zero 1.10.0-canary.21 → 1.10.0-canary.22

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 (224) hide show
  1. package/out/analyze-query/src/analyze-cli.js +2 -2
  2. package/out/analyze-query/src/analyze-cli.js.map +1 -1
  3. package/out/replicache/src/dag/gc.d.ts.map +1 -1
  4. package/out/replicache/src/dag/gc.js +2 -1
  5. package/out/replicache/src/dag/gc.js.map +1 -1
  6. package/out/replicache/src/dag/invalid-ref-count-error.d.ts +12 -0
  7. package/out/replicache/src/dag/invalid-ref-count-error.d.ts.map +1 -0
  8. package/out/replicache/src/dag/invalid-ref-count-error.js +19 -0
  9. package/out/replicache/src/dag/invalid-ref-count-error.js.map +1 -0
  10. package/out/replicache/src/dag/store-impl.d.ts +12 -2
  11. package/out/replicache/src/dag/store-impl.d.ts.map +1 -1
  12. package/out/replicache/src/dag/store-impl.js +22 -8
  13. package/out/replicache/src/dag/store-impl.js.map +1 -1
  14. package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -1
  15. package/out/replicache/src/kv/expo-sqlite/store.js +1 -1
  16. package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
  17. package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts +15 -5
  18. package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts.map +1 -1
  19. package/out/replicache/src/kv/idb-store-with-mem-fallback.js +25 -25
  20. package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +1 -1
  21. package/out/replicache/src/kv/idb-store.d.ts +9 -0
  22. package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
  23. package/out/replicache/src/kv/idb-store.js +14 -2
  24. package/out/replicache/src/kv/idb-store.js.map +1 -1
  25. package/out/replicache/src/kv/mem-store.d.ts +1 -0
  26. package/out/replicache/src/kv/mem-store.d.ts.map +1 -1
  27. package/out/replicache/src/kv/mem-store.js +3 -0
  28. package/out/replicache/src/kv/mem-store.js.map +1 -1
  29. package/out/replicache/src/kv/op-sqlite/store.d.ts.map +1 -1
  30. package/out/replicache/src/kv/op-sqlite/store.js +1 -1
  31. package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
  32. package/out/replicache/src/kv/sqlite-store.d.ts +2 -1
  33. package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
  34. package/out/replicache/src/kv/sqlite-store.js +6 -1
  35. package/out/replicache/src/kv/sqlite-store.js.map +1 -1
  36. package/out/replicache/src/kv/store.d.ts +6 -0
  37. package/out/replicache/src/kv/store.d.ts.map +1 -1
  38. package/out/replicache/src/persist/collect-idb-databases.d.ts +10 -5
  39. package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
  40. package/out/replicache/src/persist/collect-idb-databases.js +16 -9
  41. package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
  42. package/out/replicache/src/replicache-impl.d.ts +14 -3
  43. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  44. package/out/replicache/src/replicache-impl.js +104 -9
  45. package/out/replicache/src/replicache-impl.js.map +1 -1
  46. package/out/shared/src/arrays.js +1 -15
  47. package/out/shared/src/arrays.js.map +1 -1
  48. package/out/shared/src/hash.d.ts +1 -0
  49. package/out/shared/src/hash.d.ts.map +1 -1
  50. package/out/shared/src/hash.js +10 -28
  51. package/out/shared/src/hash.js.map +1 -1
  52. package/out/shared/src/iterables.d.ts +2 -0
  53. package/out/shared/src/iterables.d.ts.map +1 -1
  54. package/out/shared/src/iterables.js +18 -1
  55. package/out/shared/src/iterables.js.map +1 -1
  56. package/out/shared/src/json.d.ts.map +1 -1
  57. package/out/shared/src/json.js +2 -2
  58. package/out/shared/src/json.js.map +1 -1
  59. package/out/shared/src/ring-buffer.d.ts +8 -0
  60. package/out/shared/src/ring-buffer.d.ts.map +1 -1
  61. package/out/shared/src/ring-buffer.js +22 -1
  62. package/out/shared/src/ring-buffer.js.map +1 -1
  63. package/out/shared/src/xxhash32.d.ts +36 -0
  64. package/out/shared/src/xxhash32.d.ts.map +1 -0
  65. package/out/shared/src/xxhash32.js +51 -0
  66. package/out/shared/src/xxhash32.js.map +1 -0
  67. package/out/z2s/src/compiler.js +1 -1
  68. package/out/zero/package.js +1 -1
  69. package/out/zero/package.js.map +1 -1
  70. package/out/zero-cache/src/auth/read-authorizer.js +1 -1
  71. package/out/zero-cache/src/custom-queries/transform-query.js +1 -1
  72. package/out/zero-cache/src/server/inspector-delegate.js +3 -2
  73. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
  74. package/out/zero-cache/src/services/change-source/custom/change-source.js +2 -2
  75. package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
  76. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +3 -3
  77. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  78. package/out/zero-cache/src/services/mutagen/pusher.js +1 -1
  79. package/out/zero-cache/src/services/run-ast.js +1 -1
  80. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  81. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +6 -10
  82. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  83. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +1 -1
  84. package/out/zero-cache/src/services/view-syncer/query-covering.js.map +1 -1
  85. package/out/zero-cache/src/workers/connection.js +3 -3
  86. package/out/zero-cache/src/workers/connection.js.map +1 -1
  87. package/out/zero-client/src/client/connection-manager.d.ts +20 -0
  88. package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
  89. package/out/zero-client/src/client/connection-manager.js +32 -14
  90. package/out/zero-client/src/client/connection-manager.js.map +1 -1
  91. package/out/zero-client/src/client/connection-status-enum.d.ts +2 -0
  92. package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
  93. package/out/zero-client/src/client/connection-status-enum.js +3 -1
  94. package/out/zero-client/src/client/connection-status-enum.js.map +1 -1
  95. package/out/zero-client/src/client/connection.d.ts +6 -0
  96. package/out/zero-client/src/client/connection.d.ts.map +1 -1
  97. package/out/zero-client/src/client/connection.js +2 -1
  98. package/out/zero-client/src/client/connection.js.map +1 -1
  99. package/out/zero-client/src/client/context.d.ts +8 -11
  100. package/out/zero-client/src/client/context.d.ts.map +1 -1
  101. package/out/zero-client/src/client/context.js +11 -15
  102. package/out/zero-client/src/client/context.js.map +1 -1
  103. package/out/zero-client/src/client/custom.js +2 -2
  104. package/out/zero-client/src/client/custom.js.map +1 -1
  105. package/out/zero-client/src/client/error.js +1 -1
  106. package/out/zero-client/src/client/mutator-proxy.d.ts.map +1 -1
  107. package/out/zero-client/src/client/mutator-proxy.js +2 -1
  108. package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
  109. package/out/zero-client/src/client/options.d.ts +3 -0
  110. package/out/zero-client/src/client/options.d.ts.map +1 -1
  111. package/out/zero-client/src/client/options.js.map +1 -1
  112. package/out/zero-client/src/client/query-manager.d.ts +2 -0
  113. package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
  114. package/out/zero-client/src/client/query-manager.js +48 -9
  115. package/out/zero-client/src/client/query-manager.js.map +1 -1
  116. package/out/zero-client/src/client/version.js +1 -1
  117. package/out/zero-client/src/client/zero.d.ts +18 -3
  118. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  119. package/out/zero-client/src/client/zero.js +59 -12
  120. package/out/zero-client/src/client/zero.js.map +1 -1
  121. package/out/zero-client/src/types/query-result.d.ts +2 -0
  122. package/out/zero-client/src/types/query-result.d.ts.map +1 -1
  123. package/out/zero-protocol/src/ast.d.ts +64 -1
  124. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  125. package/out/zero-protocol/src/ast.js +223 -51
  126. package/out/zero-protocol/src/ast.js.map +1 -1
  127. package/out/zero-protocol/src/query-hash-visitor.d.ts +81 -0
  128. package/out/zero-protocol/src/query-hash-visitor.d.ts.map +1 -0
  129. package/out/zero-protocol/src/query-hash-visitor.js +324 -0
  130. package/out/zero-protocol/src/query-hash-visitor.js.map +1 -0
  131. package/out/zero-protocol/src/query-hash.d.ts +7 -2
  132. package/out/zero-protocol/src/query-hash.d.ts.map +1 -1
  133. package/out/zero-protocol/src/query-hash.js +12 -9
  134. package/out/zero-protocol/src/query-hash.js.map +1 -1
  135. package/out/zero-react/src/use-query.d.ts +5 -4
  136. package/out/zero-react/src/use-query.d.ts.map +1 -1
  137. package/out/zero-react/src/use-query.js +86 -9
  138. package/out/zero-react/src/use-query.js.map +1 -1
  139. package/out/zero-solid/src/solid-view.d.ts +10 -0
  140. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  141. package/out/zero-solid/src/solid-view.js +27 -0
  142. package/out/zero-solid/src/solid-view.js.map +1 -1
  143. package/out/zero-solid/src/use-query.js +5 -3
  144. package/out/zero-solid/src/use-query.js.map +1 -1
  145. package/out/zql/src/ivm/array-view.d.ts +10 -0
  146. package/out/zql/src/ivm/array-view.d.ts.map +1 -1
  147. package/out/zql/src/ivm/array-view.js +20 -8
  148. package/out/zql/src/ivm/array-view.js.map +1 -1
  149. package/out/zql/src/ivm/cap.d.ts.map +1 -1
  150. package/out/zql/src/ivm/cap.js +5 -3
  151. package/out/zql/src/ivm/cap.js.map +1 -1
  152. package/out/zql/src/ivm/deferred-input.d.ts.map +1 -1
  153. package/out/zql/src/ivm/deferred-input.js +3 -2
  154. package/out/zql/src/ivm/deferred-input.js.map +1 -1
  155. package/out/zql/src/ivm/exists.d.ts +1 -1
  156. package/out/zql/src/ivm/exists.d.ts.map +1 -1
  157. package/out/zql/src/ivm/exists.js +1 -1
  158. package/out/zql/src/ivm/exists.js.map +1 -1
  159. package/out/zql/src/ivm/fan-in.d.ts +2 -2
  160. package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
  161. package/out/zql/src/ivm/fan-in.js +6 -5
  162. package/out/zql/src/ivm/fan-in.js.map +1 -1
  163. package/out/zql/src/ivm/fan-out.d.ts +2 -2
  164. package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
  165. package/out/zql/src/ivm/fan-out.js.map +1 -1
  166. package/out/zql/src/ivm/filter-operators.d.ts +4 -4
  167. package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
  168. package/out/zql/src/ivm/filter-operators.js +10 -8
  169. package/out/zql/src/ivm/filter-operators.js.map +1 -1
  170. package/out/zql/src/ivm/filter.d.ts +2 -2
  171. package/out/zql/src/ivm/filter.d.ts.map +1 -1
  172. package/out/zql/src/ivm/filter.js +7 -4
  173. package/out/zql/src/ivm/filter.js.map +1 -1
  174. package/out/zql/src/ivm/flipped-join.js +2 -2
  175. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  176. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +1 -1
  177. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
  178. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +6 -4
  179. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
  180. package/out/zql/src/ivm/memory-source.d.ts +2 -2
  181. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  182. package/out/zql/src/ivm/memory-source.js +9 -9
  183. package/out/zql/src/ivm/memory-source.js.map +1 -1
  184. package/out/zql/src/ivm/take.d.ts.map +1 -1
  185. package/out/zql/src/ivm/take.js +3 -4
  186. package/out/zql/src/ivm/take.js.map +1 -1
  187. package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
  188. package/out/zql/src/ivm/union-fan-in.js +9 -7
  189. package/out/zql/src/ivm/union-fan-in.js.map +1 -1
  190. package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
  191. package/out/zql/src/ivm/view-apply-change.js +3 -3
  192. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  193. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  194. package/out/zql/src/mutate/mutator-registry.js +2 -2
  195. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  196. package/out/zql/src/query/query-delegate-base.d.ts +2 -0
  197. package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
  198. package/out/zql/src/query/query-delegate-base.js +58 -31
  199. package/out/zql/src/query/query-delegate-base.js.map +1 -1
  200. package/out/zql/src/query/query-delegate.d.ts +11 -1
  201. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  202. package/out/zql/src/query/query-impl.d.ts +25 -14
  203. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  204. package/out/zql/src/query/query-impl.js +414 -94
  205. package/out/zql/src/query/query-impl.js.map +1 -1
  206. package/out/zql/src/query/query-internals.d.ts +21 -11
  207. package/out/zql/src/query/query-internals.d.ts.map +1 -1
  208. package/out/zql/src/query/query-internals.js.map +1 -1
  209. package/out/zql/src/query/query-transitions.d.ts +171 -0
  210. package/out/zql/src/query/query-transitions.d.ts.map +1 -0
  211. package/out/zql/src/query/query-transitions.js +207 -0
  212. package/out/zql/src/query/query-transitions.js.map +1 -0
  213. package/out/zql/src/query/query.d.ts +7 -1
  214. package/out/zql/src/query/query.d.ts.map +1 -1
  215. package/out/zql/src/query/runnable-query-impl.d.ts +3 -2
  216. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  217. package/out/zql/src/query/runnable-query-impl.js +23 -2
  218. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  219. package/out/zql/src/query/typed-view.d.ts +1 -1
  220. package/out/zql/src/query/typed-view.d.ts.map +1 -1
  221. package/out/zqlite/src/table-source.d.ts.map +1 -1
  222. package/out/zqlite/src/table-source.js +7 -5
  223. package/out/zqlite/src/table-source.js.map +1 -1
  224. package/package.json +1 -1
@@ -0,0 +1,207 @@
1
+ import { deepEqual } from "../../../shared/src/json.js";
2
+ /** How large the weak map must get before its first sweep. */
3
+ var SWEEP_INITIAL = 64;
4
+ /** The transitions out of one node. */
5
+ var Transitions = class {
6
+ #firstKey;
7
+ #firstValue;
8
+ #firstDelta;
9
+ #first;
10
+ #bounded;
11
+ #rest;
12
+ #sweepAt = SWEEP_INITIAL;
13
+ #restSize = 0;
14
+ lookupBounded(key) {
15
+ return this.#bounded?.get(key);
16
+ }
17
+ /**
18
+ * Records a transition whose key space is finite and schema-derived — the base
19
+ * sub-query handed to a `related`/`exists` callback, keyed by relationship
20
+ * name.
21
+ *
22
+ * These are held strongly. Retention is bounded by the number of relationships
23
+ * on the table, so it cannot grow with what an app queries for, and in exchange
24
+ * a relationship traversal allocates no `WeakRef`. Anything keyed by a *value*
25
+ * — a row id, a search string, a limit — must not come through here.
26
+ */
27
+ storeBounded(key, value) {
28
+ (this.#bounded ??= /* @__PURE__ */ new Map()).set(key, value);
29
+ }
30
+ lookup(key, value, delta) {
31
+ if (this.#firstKey === key && this.#firstValue === value && deepEqual(this.#firstDelta, delta)) return this.#first;
32
+ const byValue = this.#rest?.get(key);
33
+ if (byValue === void 0) return;
34
+ const bucket = byValue.get(value);
35
+ if (bucket === void 0) return;
36
+ if (!(bucket instanceof Set)) {
37
+ const found = bucket.ref.deref();
38
+ if (found === void 0) {
39
+ byValue.delete(value);
40
+ this.#restSize--;
41
+ return;
42
+ }
43
+ return deepEqual(bucket.delta, delta) ? found : void 0;
44
+ }
45
+ for (const entry of bucket) {
46
+ const found = entry.ref.deref();
47
+ if (found === void 0) {
48
+ bucket.delete(entry);
49
+ this.#restSize--;
50
+ continue;
51
+ }
52
+ if (deepEqual(entry.delta, delta)) return found;
53
+ }
54
+ if (bucket.size === 0) byValue.delete(value);
55
+ }
56
+ store(key, value, delta, node) {
57
+ if (this.#firstKey === void 0) {
58
+ this.#firstKey = key;
59
+ this.#firstValue = value;
60
+ this.#firstDelta = delta;
61
+ this.#first = node;
62
+ return;
63
+ }
64
+ const rest = this.#rest ??= /* @__PURE__ */ new Map();
65
+ let byValue = rest.get(key);
66
+ if (byValue === void 0) {
67
+ byValue = /* @__PURE__ */ new Map();
68
+ rest.set(key, byValue);
69
+ }
70
+ const entry = {
71
+ delta,
72
+ ref: new WeakRef(node)
73
+ };
74
+ const bucket = byValue.get(value);
75
+ if (bucket === void 0) byValue.set(value, entry);
76
+ else if (!(bucket instanceof Set)) byValue.set(value, new Set([bucket, entry]));
77
+ else {
78
+ if (bucket.size >= 64) return;
79
+ bucket.add(entry);
80
+ }
81
+ this.#restSize++;
82
+ this.#maybeSweep(rest);
83
+ }
84
+ /**
85
+ * Re-points the transition that produced `from` at `to`, so the next lookup
86
+ * along that path yields `to` instead. This is how {@linkcode HashIndex}
87
+ * converges two paths on one node: `from` keeps its identity, since it has
88
+ * already been handed out, and its path is redirected for the rebuilds that
89
+ * follow.
90
+ *
91
+ * Scans rather than taking a key. This runs once per redirected path, so a
92
+ * walk here is cheaper than the fields every node would need to carry to
93
+ * name its own transition.
94
+ */
95
+ replace(from, to) {
96
+ if (this.#first === from) {
97
+ this.#first = to;
98
+ return true;
99
+ }
100
+ const rest = this.#rest;
101
+ if (rest === void 0) return false;
102
+ for (const byValue of rest.values()) for (const [value, bucket] of byValue) {
103
+ if (!(bucket instanceof Set)) {
104
+ if (bucket.ref.deref() === from) {
105
+ byValue.set(value, {
106
+ delta: bucket.delta,
107
+ ref: new WeakRef(to)
108
+ });
109
+ return true;
110
+ }
111
+ continue;
112
+ }
113
+ for (const entry of bucket) if (entry.ref.deref() === from) {
114
+ bucket.delete(entry);
115
+ bucket.add({
116
+ delta: entry.delta,
117
+ ref: new WeakRef(to)
118
+ });
119
+ return true;
120
+ }
121
+ }
122
+ return false;
123
+ }
124
+ /**
125
+ * Drops entries for collected values, if the map has grown enough to be worth
126
+ * walking.
127
+ *
128
+ * A lookup already prunes whatever it walks past, which covers every key that
129
+ * is asked for again. This is for the key that is not: a miss on a fresh key
130
+ * returns without touching any existing entry, so nothing would ever notice
131
+ * that those had died. Doubling the threshold off whatever survives keeps this
132
+ * amortized O(1) per insert whether or not there was anything to reclaim, and
133
+ * it is self-limiting — only a node that keeps taking inserts can keep
134
+ * accumulating, and taking inserts is what triggers the sweep.
135
+ */
136
+ #maybeSweep(rest) {
137
+ if (this.#restSize < this.#sweepAt) return;
138
+ let live = 0;
139
+ for (const [key, byValue] of rest) {
140
+ for (const [value, bucket] of byValue) {
141
+ if (!(bucket instanceof Set)) {
142
+ if (bucket.ref.deref() === void 0) byValue.delete(value);
143
+ else live++;
144
+ continue;
145
+ }
146
+ for (const entry of bucket) if (entry.ref.deref() === void 0) bucket.delete(entry);
147
+ else live++;
148
+ if (bucket.size === 0) byValue.delete(value);
149
+ }
150
+ if (byValue.size === 0) rest.delete(key);
151
+ }
152
+ this.#restSize = live;
153
+ this.#sweepAt = Math.max(SWEEP_INITIAL, live * 2);
154
+ }
155
+ };
156
+ /**
157
+ * The second level of interning: nodes keyed by *content* rather than by the
158
+ * path that built them.
159
+ *
160
+ * The transition tree cannot see that `q.where(a).where(b)` and
161
+ * `q.where(b).where(a)` are the same query. `normalizeAST` sorts conditions
162
+ * and `related` entries, so the two build byte-identical ASTs, but they are
163
+ * different paths and so different nodes. This index closes that gap, keyed by
164
+ * the query's hash.
165
+ *
166
+ * It is consulted when a query is *hashed*, not when it is built. Hashing on
167
+ * every tree miss would make a cold chain pay for a hash per node, where the
168
+ * uninterned code paid for one at the end, if at all -- and server-side queries
169
+ * are built cold, once, per request. The consumers that key by hash already
170
+ * hash the queries they care about, so doing the work there costs one map
171
+ * lookup on top of a hash that was being computed anyway, and nothing at all
172
+ * for a query nobody hashes.
173
+ *
174
+ * On a hit the query being hashed keeps its identity, since it has already
175
+ * been handed out. Its *transition* is re-pointed at the existing node instead
176
+ * (see {@linkcode Transitions.replace}), so the next rebuild along that path
177
+ * yields the shared instance. As with the tree this is a cache: the rebuild
178
+ * after a redirect is what converges, not the call that found the duplicate.
179
+ *
180
+ * One index per root, which is what scopes it. Two roots never share an index,
181
+ * so queries against different schemas or different delegates -- neither of
182
+ * which the hash covers -- can never be conflated. Entries are weak: a cleared
183
+ * one is dropped by the lookup that finds it, or by a sweep once the map has
184
+ * doubled since the last one.
185
+ */
186
+ var HashIndex = class {
187
+ #byHash = /* @__PURE__ */ new Map();
188
+ #sweepAt = SWEEP_INITIAL;
189
+ get(hash) {
190
+ const ref = this.#byHash.get(hash);
191
+ if (ref === void 0) return;
192
+ const node = ref.deref();
193
+ if (node === void 0) this.#byHash.delete(hash);
194
+ return node;
195
+ }
196
+ set(hash, node) {
197
+ const byHash = this.#byHash;
198
+ byHash.set(hash, new WeakRef(node));
199
+ if (byHash.size < this.#sweepAt) return;
200
+ for (const [h, ref] of byHash) if (ref.deref() === void 0) byHash.delete(h);
201
+ this.#sweepAt = Math.max(SWEEP_INITIAL, byHash.size * 2);
202
+ }
203
+ };
204
+ //#endregion
205
+ export { HashIndex, Transitions };
206
+
207
+ //# sourceMappingURL=query-transitions.js.map
@@ -0,0 +1 @@
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';\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 let byValue = rest.get(key);\n if (byValue === undefined) {\n byValue = new Map();\n rest.set(key, byValue);\n }\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":";;AA8HA,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,KA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Query<TTable extends keyof TSchema['tables'] & string, TSchema
204
204
  preload(options?: PreloadOptions): {
205
205
  cleanup: () => void;
206
206
  complete: Promise<void>;
207
+ cached: Promise<void>;
207
208
  };
208
209
  /**
209
210
  * @deprecated Use {@linkcode MaterializeOptions} with {@linkcode zero.materialize} instead.
@@ -236,6 +237,11 @@ export type HumanReadableRecursive<T> = undefined extends T ? ExpandRecursive<T>
236
237
  * `unknown` means we don't want to wait for the server to return results. The result is a
237
238
  * snapshot of the data at the time the query was run.
238
239
  *
240
+ * `cached` means we want a result the server has confirmed, but one confirmed by a previous
241
+ * connection is fine: it resolves as soon as the result is `cached` or `complete`. Use it
242
+ * on the launch path when the client may be offline and the store holds last session's
243
+ * complete result for this query. If nothing is cached it waits like `complete`.
244
+ *
239
245
  * `complete` means we want to ensure that we have the latest result from the server. The
240
246
  * result is a complete and up-to-date view of the data. In some cases this means that we
241
247
  * have to wait for the server to return results. To ensure that we have the result for
@@ -247,7 +253,7 @@ export type HumanReadableRecursive<T> = undefined extends T ? ExpandRecursive<T>
247
253
  * time to keep the rows associated with this query after the promise has resolved.
248
254
  */
249
255
  export type RunOptions = {
250
- type: 'unknown' | 'complete';
256
+ type: 'unknown' | 'cached' | 'complete';
251
257
  ttl?: TTL | undefined;
252
258
  };
253
259
  export declare const DEFAULT_RUN_OPTIONS_UNKNOWN: {
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../../zql/src/query/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAC,KAAK,cAAc,EAAC,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,MAAM,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AS,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AAE7E;;GAEG;AAEH,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI,SAAS,SAAS,CAAC,GACvD,eAAe,CAAC,CAAC,CAAC,GAClB,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;IACxC,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,2BAA2B;;CAE9B,CAAC;AAEX,eAAO,MAAM,4BAA4B;;CAE/B,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { AST, System } from '../../../zero-protocol/src/ast.ts';
1
+ import { type NormalizedAST, type System } from '../../../zero-protocol/src/ast.ts';
2
2
  import type { Schema } from '../../../zero-types/src/schema.ts';
3
3
  import type { Format, ViewFactory } from '../ivm/view.ts';
4
4
  import type { CustomQueryID } from './named.ts';
@@ -10,11 +10,12 @@ import type { TypedView } from './typed-view.ts';
10
10
  export declare function newRunnableQuery<TTable extends keyof TSchema['tables'] & string, TSchema extends Schema>(delegate: QueryDelegate, schema: TSchema, table: TTable): Query<TTable, TSchema>;
11
11
  export declare class RunnableQueryImpl<TTable extends keyof TSchema['tables'] & string, TSchema extends Schema, TReturn = PullRow<TTable, TSchema>> extends QueryImpl<TTable, TSchema, TReturn> implements Query<TTable, TSchema, TReturn> {
12
12
  #private;
13
- constructor(delegate: QueryDelegate, schema: TSchema, tableName: TTable, ast?: AST, format?: Format, system?: System, customQueryID?: CustomQueryID, currentJunction?: string);
13
+ constructor(delegate: QueryDelegate, schema: TSchema, tableName: TTable, ast?: NormalizedAST, format?: Format, system?: System, customQueryID?: CustomQueryID, currentJunction?: string);
14
14
  run(options?: RunOptions): Promise<HumanReadable<TReturn>>;
15
15
  preload(options?: PreloadOptions): {
16
16
  cleanup: () => void;
17
17
  complete: Promise<void>;
18
+ cached: Promise<void>;
18
19
  };
19
20
  materialize(ttl?: TTL): TypedView<HumanReadable<TReturn>>;
20
21
  materialize<T>(factory: ViewFactory<TTable, TSchema, TReturn, T>, ttl?: TTL): T;
@@ -1 +1 @@
1
- {"version":3,"file":"runnable-query-impl.d.ts","sourceRoot":"","sources":["../../../../../zql/src/query/runnable-query-impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAE,MAAM,EAAC,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAE9D,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EACV,aAAa,EAEb,cAAc,EACd,OAAO,EACP,KAAK,EACL,UAAU,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE/C,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC/C,OAAO,SAAS,MAAM,EAEtB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CASxB;AAED,qBAAa,iBAAiB,CAC5B,MAAM,SAAS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,GAAG;QAC1C,OAAO,EAAE,MAAM,IAAI,CAAC;QACpB,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;KACvB;IAIQ,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzD,WAAW,CAAC,CAAC,EACpB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,EACjD,GAAG,CAAC,EAAE,GAAG,GACR,CAAC;CAsBL"}
@@ -1,12 +1,33 @@
1
+ import { tableAST } from "../../../zero-protocol/src/ast.js";
1
2
  import { defaultFormat } from "../../../zero-types/src/format.js";
2
3
  import { QueryImpl } from "./query-impl.js";
3
4
  //#region ../zql/src/query/runnable-query-impl.ts
5
+ /**
6
+ * Runnable roots are interned per delegate *and* schema -- a query is only
7
+ * interchangeable with another if it would run against the same delegate. See
8
+ * `query-transitions.ts` for why roots need to be shared at all.
9
+ */
10
+ var rootsByDelegate = /* @__PURE__ */ new WeakMap();
4
11
  function newRunnableQuery(delegate, schema, table) {
5
- return new RunnableQueryImpl(delegate, schema, table, { table }, defaultFormat, void 0);
12
+ let bySchema = rootsByDelegate.get(delegate);
13
+ if (!bySchema) {
14
+ bySchema = /* @__PURE__ */ new WeakMap();
15
+ rootsByDelegate.set(delegate, bySchema);
16
+ }
17
+ let roots = bySchema.get(schema);
18
+ if (!roots) {
19
+ roots = /* @__PURE__ */ new Map();
20
+ bySchema.set(schema, roots);
21
+ }
22
+ const existing = roots.get(table)?.deref();
23
+ if (existing) return existing;
24
+ const created = new RunnableQueryImpl(delegate, schema, table, tableAST(table), defaultFormat, void 0);
25
+ roots.set(table, new WeakRef(created));
26
+ return created;
6
27
  }
7
28
  var RunnableQueryImpl = class RunnableQueryImpl extends QueryImpl {
8
29
  #delegate;
9
- constructor(delegate, schema, tableName, ast = { table: tableName }, format = defaultFormat, system = "client", customQueryID, currentJunction) {
30
+ constructor(delegate, schema, tableName, ast = tableAST(tableName), format = defaultFormat, system = "client", customQueryID, currentJunction) {
10
31
  super(schema, tableName, ast, format, system, customQueryID, currentJunction, (tableName, ast, format, customQueryID, currentJunction) => new RunnableQueryImpl(delegate, schema, tableName, ast, format, system, customQueryID, currentJunction));
11
32
  this.#delegate = delegate;
12
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runnable-query-impl.js","names":["#delegate"],"sources":["../../../../../zql/src/query/runnable-query-impl.ts"],"sourcesContent":["import type {AST, System} from '../../../zero-protocol/src/ast.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {defaultFormat} from '../ivm/default-format.ts';\nimport type {Format, ViewFactory} from '../ivm/view.ts';\nimport type {CustomQueryID} from './named.ts';\nimport type {QueryDelegate} from './query-delegate.ts';\nimport {QueryImpl} from './query-impl.ts';\nimport type {\n HumanReadable,\n MaterializeOptions,\n PreloadOptions,\n PullRow,\n Query,\n RunOptions,\n} from './query.ts';\nimport type {TTL} from './ttl.ts';\nimport type {TypedView} from './typed-view.ts';\n\nexport function newRunnableQuery<\n TTable extends keyof TSchema['tables'] & string,\n TSchema extends Schema,\n>(\n delegate: QueryDelegate,\n schema: TSchema,\n table: TTable,\n): Query<TTable, TSchema> {\n return new RunnableQueryImpl(\n delegate,\n schema,\n table,\n {table},\n defaultFormat,\n undefined,\n );\n}\n\nexport class RunnableQueryImpl<\n TTable extends keyof TSchema['tables'] & string,\n TSchema extends Schema,\n TReturn = PullRow<TTable, TSchema>,\n>\n extends QueryImpl<TTable, TSchema, TReturn>\n implements Query<TTable, TSchema, TReturn>\n{\n readonly #delegate: QueryDelegate;\n\n constructor(\n delegate: QueryDelegate,\n schema: TSchema,\n tableName: TTable,\n ast: AST = {table: tableName},\n format: Format = defaultFormat,\n system: System = 'client',\n customQueryID?: CustomQueryID,\n currentJunction?: string,\n ) {\n super(\n schema,\n tableName,\n ast,\n format,\n system,\n customQueryID,\n currentJunction,\n (tableName, ast, format, customQueryID, currentJunction) =>\n new RunnableQueryImpl(\n delegate,\n schema,\n tableName,\n ast,\n format,\n system,\n customQueryID,\n currentJunction,\n ),\n );\n this.#delegate = delegate;\n }\n\n override run(options?: RunOptions): Promise<HumanReadable<TReturn>> {\n return this.#delegate.run(this, options);\n }\n\n override preload(options?: PreloadOptions): {\n cleanup: () => void;\n complete: Promise<void>;\n } {\n return this.#delegate.preload(this, options);\n }\n\n override materialize(ttl?: TTL): TypedView<HumanReadable<TReturn>>;\n override materialize<T>(\n factory: ViewFactory<TTable, TSchema, TReturn, T>,\n ttl?: TTL,\n ): T;\n override materialize<T>(\n factory?: unknown,\n ttl?: unknown,\n ): T | TypedView<HumanReadable<TReturn>> {\n let actualFactory: ViewFactory<TTable, TSchema, TReturn, T> | undefined;\n let options: MaterializeOptions | undefined;\n\n if (typeof factory === 'function') {\n actualFactory = factory as ViewFactory<TTable, TSchema, TReturn, T>;\n options = {ttl: ttl as TTL | undefined};\n } else {\n actualFactory = undefined;\n options = {ttl: factory as TTL | undefined};\n }\n\n return this.#delegate.materialize(this, actualFactory, options);\n }\n}\n"],"mappings":";;;AAkBA,SAAgB,iBAId,UACA,QACA,OACwB;CACxB,OAAO,IAAI,kBACT,UACA,QACA,OACA,EAAC,MAAK,GACN,eACA,KAAA,CACF;AACF;AAEA,IAAa,oBAAb,MAAa,0BAKH,UAEV;CACE;CAEA,YACE,UACA,QACA,WACA,MAAW,EAAC,OAAO,UAAS,GAC5B,SAAiB,eACjB,SAAiB,UACjB,eACA,iBACA;EACA,MACE,QACA,WACA,KACA,QACA,QACA,eACA,kBACC,WAAW,KAAK,QAAQ,eAAe,oBACtC,IAAI,kBACF,UACA,QACA,WACA,KACA,QACA,QACA,eACA,eACF,CACJ;EACA,KAAKA,YAAY;CACnB;CAEA,IAAa,SAAuD;EAClE,OAAO,KAAKA,UAAU,IAAI,MAAM,OAAO;CACzC;CAEA,QAAiB,SAGf;EACA,OAAO,KAAKA,UAAU,QAAQ,MAAM,OAAO;CAC7C;CAOA,YACE,SACA,KACuC;EACvC,IAAI;EACJ,IAAI;EAEJ,IAAI,OAAO,YAAY,YAAY;GACjC,gBAAgB;GAChB,UAAU,EAAM,IAAsB;EACxC,OAAO;GACL,gBAAgB,KAAA;GAChB,UAAU,EAAC,KAAK,QAA0B;EAC5C;EAEA,OAAO,KAAKA,UAAU,YAAY,MAAM,eAAe,OAAO;CAChE;AACF"}
1
+ {"version":3,"file":"runnable-query-impl.js","names":["#delegate"],"sources":["../../../../../zql/src/query/runnable-query-impl.ts"],"sourcesContent":["import {\n tableAST,\n type NormalizedAST,\n type System,\n} from '../../../zero-protocol/src/ast.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {defaultFormat} from '../ivm/default-format.ts';\nimport type {Format, ViewFactory} from '../ivm/view.ts';\nimport type {CustomQueryID} from './named.ts';\nimport type {QueryDelegate} from './query-delegate.ts';\nimport {QueryImpl} from './query-impl.ts';\nimport type {\n HumanReadable,\n MaterializeOptions,\n PreloadOptions,\n PullRow,\n Query,\n RunOptions,\n} from './query.ts';\nimport type {TTL} from './ttl.ts';\nimport type {TypedView} from './typed-view.ts';\n\n/**\n * Runnable roots are interned per delegate *and* schema -- a query is only\n * interchangeable with another if it would run against the same delegate. See\n * `query-transitions.ts` for why roots need to be shared at all.\n */\nconst rootsByDelegate = new WeakMap<\n QueryDelegate,\n // oxlint-disable-next-line no-explicit-any\n WeakMap<Schema, Map<string, WeakRef<RunnableQueryImpl<any, any, any>>>>\n>();\n\nexport function newRunnableQuery<\n TTable extends keyof TSchema['tables'] & string,\n TSchema extends Schema,\n>(\n delegate: QueryDelegate,\n schema: TSchema,\n table: TTable,\n): Query<TTable, TSchema> {\n let bySchema = rootsByDelegate.get(delegate);\n if (!bySchema) {\n bySchema = new WeakMap();\n rootsByDelegate.set(delegate, bySchema);\n }\n let roots = bySchema.get(schema);\n if (!roots) {\n roots = new Map();\n bySchema.set(schema, roots);\n }\n\n const existing = roots.get(table)?.deref();\n if (existing) {\n return existing as RunnableQueryImpl<TTable, TSchema>;\n }\n\n const created = new RunnableQueryImpl<TTable, TSchema>(\n delegate,\n schema,\n table,\n tableAST(table),\n defaultFormat,\n undefined,\n );\n roots.set(table, new WeakRef(created));\n return created;\n}\n\nexport class RunnableQueryImpl<\n TTable extends keyof TSchema['tables'] & string,\n TSchema extends Schema,\n TReturn = PullRow<TTable, TSchema>,\n>\n extends QueryImpl<TTable, TSchema, TReturn>\n implements Query<TTable, TSchema, TReturn>\n{\n readonly #delegate: QueryDelegate;\n\n constructor(\n delegate: QueryDelegate,\n schema: TSchema,\n tableName: TTable,\n ast: NormalizedAST = tableAST(tableName),\n format: Format = defaultFormat,\n system: System = 'client',\n customQueryID?: CustomQueryID,\n currentJunction?: string,\n ) {\n super(\n schema,\n tableName,\n ast,\n format,\n system,\n customQueryID,\n currentJunction,\n (tableName, ast, format, customQueryID, currentJunction) =>\n new RunnableQueryImpl(\n delegate,\n schema,\n tableName,\n ast,\n format,\n system,\n customQueryID,\n currentJunction,\n ),\n );\n this.#delegate = delegate;\n }\n\n override run(options?: RunOptions): Promise<HumanReadable<TReturn>> {\n // The type arguments on the delegate calls in this class are written out\n // because tsc 7.0.2 fails to infer them in some program layouts (the\n // packages/zero declaration build, apps/zero-throughput): inference\n // collapses TSchema to its constraint and the call misreports as a\n // TS2345 assignability error. Explicit arguments are inert where\n // inference works and correct where it does not.\n return this.#delegate.run<TTable, TSchema, TReturn>(this, options);\n }\n\n override preload(options?: PreloadOptions): {\n cleanup: () => void;\n complete: Promise<void>;\n cached: Promise<void>;\n } {\n return this.#delegate.preload<TTable, TSchema, TReturn>(this, options);\n }\n\n override materialize(ttl?: TTL): TypedView<HumanReadable<TReturn>>;\n override materialize<T>(\n factory: ViewFactory<TTable, TSchema, TReturn, T>,\n ttl?: TTL,\n ): T;\n override materialize<T>(\n factory?: unknown,\n ttl?: unknown,\n ): T | TypedView<HumanReadable<TReturn>> {\n let actualFactory: ViewFactory<TTable, TSchema, TReturn, T> | undefined;\n let options: MaterializeOptions | undefined;\n\n if (typeof factory === 'function') {\n actualFactory = factory as ViewFactory<TTable, TSchema, TReturn, T>;\n options = {ttl: ttl as TTL | undefined};\n } else {\n actualFactory = undefined;\n options = {ttl: factory as TTL | undefined};\n }\n\n return this.#delegate.materialize<TTable, TSchema, TReturn, T>(\n this,\n actualFactory,\n options,\n );\n }\n}\n"],"mappings":";;;;;;;;;AA2BA,IAAM,kCAAkB,IAAI,QAI1B;AAEF,SAAgB,iBAId,UACA,QACA,OACwB;CACxB,IAAI,WAAW,gBAAgB,IAAI,QAAQ;CAC3C,IAAI,CAAC,UAAU;EACb,2BAAW,IAAI,QAAQ;EACvB,gBAAgB,IAAI,UAAU,QAAQ;CACxC;CACA,IAAI,QAAQ,SAAS,IAAI,MAAM;CAC/B,IAAI,CAAC,OAAO;EACV,wBAAQ,IAAI,IAAI;EAChB,SAAS,IAAI,QAAQ,KAAK;CAC5B;CAEA,MAAM,WAAW,MAAM,IAAI,KAAK,GAAG,MAAM;CACzC,IAAI,UACF,OAAO;CAGT,MAAM,UAAU,IAAI,kBAClB,UACA,QACA,OACA,SAAS,KAAK,GACd,eACA,KAAA,CACF;CACA,MAAM,IAAI,OAAO,IAAI,QAAQ,OAAO,CAAC;CACrC,OAAO;AACT;AAEA,IAAa,oBAAb,MAAa,0BAKH,UAEV;CACE;CAEA,YACE,UACA,QACA,WACA,MAAqB,SAAS,SAAS,GACvC,SAAiB,eACjB,SAAiB,UACjB,eACA,iBACA;EACA,MACE,QACA,WACA,KACA,QACA,QACA,eACA,kBACC,WAAW,KAAK,QAAQ,eAAe,oBACtC,IAAI,kBACF,UACA,QACA,WACA,KACA,QACA,QACA,eACA,eACF,CACJ;EACA,KAAKA,YAAY;CACnB;CAEA,IAAa,SAAuD;EAOlE,OAAO,KAAKA,UAAU,IAA8B,MAAM,OAAO;CACnE;CAEA,QAAiB,SAIf;EACA,OAAO,KAAKA,UAAU,QAAkC,MAAM,OAAO;CACvE;CAOA,YACE,SACA,KACuC;EACvC,IAAI;EACJ,IAAI;EAEJ,IAAI,OAAO,YAAY,YAAY;GACjC,gBAAgB;GAChB,UAAU,EAAM,IAAsB;EACxC,OAAO;GACL,gBAAgB,KAAA;GAChB,UAAU,EAAC,KAAK,QAA0B;EAC5C;EAEA,OAAO,KAAKA,UAAU,YACpB,MACA,eACA,OACF;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  import type { Immutable } from '../../../shared/src/immutable.ts';
2
2
  import type { ErroredQuery } from '../../../zero-protocol/src/custom-queries.ts';
3
3
  import type { TTL } from './ttl.ts';
4
- export type ResultType = 'unknown' | 'complete' | 'error';
4
+ export type ResultType = 'unknown' | 'cached' | 'complete' | 'error';
5
5
  /**
6
6
  * Called when the view changes. The received data should be considered
7
7
  * immutable. Caller must not modify it. Passed data is valid until next
@@ -1 +1 @@
1
- {"version":3,"file":"typed-view.d.ts","sourceRoot":"","sources":["../../../../../zql/src/query/typed-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAChE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAElC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAE1D;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CACxB,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAClB,UAAU,EAAE,UAAU,EACtB,KAAK,CAAC,EAAE,YAAY,KACjB,IAAI,CAAC;AAEV,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC;IAC/C,OAAO,IAAI,IAAI,CAAC;IAChB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CAClB,CAAC"}
1
+ {"version":3,"file":"typed-view.d.ts","sourceRoot":"","sources":["../../../../../zql/src/query/typed-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAChE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAElC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CACxB,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAClB,UAAU,EAAE,UAAU,EACtB,KAAK,CAAC,EAAE,YAAY,KACjB,IAAI,CAAC;AAEV,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC;IAC/C,OAAO,IAAI,IAAI,CAAC;IAChB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CAClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"table-source.d.ts","sourceRoot":"","sources":["../../../../zqlite/src/table-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AAK7D,OAAO,KAAK,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAC,GAAG,EAAQ,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAC,UAAU,EAAC,MA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AU,EACtB,WAAW,gBAAc;IAkB3B,IAAI,WAAW;;;;MAMd;IAED;;;OAGG;IACH,KAAK,CAAC,EAAE,EAAE,QAAQ;IA4FlB,OAAO,CACL,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,OAAO,CAAC,EAAE,SAAS,EACnB,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAC3B,KAAK,CAAC,EAAE,aAAa;IA8CvB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG;IAqIzB,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;IAQ5C,OAAO,CAAC,MAAM,EAAE,YAAY;IAqG5B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS;CA+BrC;AA8BD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACvC,SAAS,OAAO,EAAE,CAEpB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,wCAa/C;AAED,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACvC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,MAAM,GAChB,GAAG,CAaL;AAyCD,qBAAa,qBAAsB,SAAQ,KAAK;CAAG"}
@@ -53,7 +53,8 @@ var TableSource = class {
53
53
  this.#primaryKey = primaryKey;
54
54
  this.#stmts = this.#getStatementsFor(db);
55
55
  this.#shouldYield = shouldYield;
56
- assert(this.#uniqueIndexes.has(JSON.stringify(primaryKey.toSorted())), `primary key ${primaryKey} does not have a UNIQUE index`);
56
+ const primaryKeyStr = JSON.stringify(primaryKey.toSorted());
57
+ assert(this.#uniqueIndexes.has(primaryKeyStr), `primary key ${primaryKeyStr} does not have a UNIQUE index`);
57
58
  }
58
59
  get tableSchema() {
59
60
  return {
@@ -180,11 +181,11 @@ var TableSource = class {
180
181
  *push(change) {
181
182
  for (const result of this.genPush(change)) if (result === "yield") yield result;
182
183
  }
183
- *genPush(change) {
184
+ genPush(change) {
184
185
  const exists = (row) => this.#stmts.checkExists.get(...toSQLiteTypes(this.#primaryKey, row, this.#columns))?.exists === 1;
185
186
  const setOverlay = (o) => this.#overlay = o;
186
187
  const writeChange = (c) => this.#writeChange(c);
187
- yield* genPushAndWriteWithSplitEdit(this.#connections, change, exists, setOverlay, writeChange, () => ++this.#pushEpoch);
188
+ return genPushAndWriteWithSplitEdit(this.#connections, change, exists, setOverlay, writeChange, () => ++this.#pushEpoch);
188
189
  }
189
190
  #writeChange(change) {
190
191
  switch (change[0]) {
@@ -280,8 +281,9 @@ function fromSQLiteType(valueType, v, column, tableName) {
280
281
  case "string":
281
282
  case "null":
282
283
  if (typeof v === "bigint") {
283
- if (v > Number.MAX_SAFE_INTEGER || v < Number.MIN_SAFE_INTEGER) throw new UnsupportedValueError(`value ${v} (in ${tableName}.${column}) is outside of supported bounds`);
284
- return Number(v);
284
+ const bi = v;
285
+ if (bi > Number.MAX_SAFE_INTEGER || bi < Number.MIN_SAFE_INTEGER) throw new UnsupportedValueError(`value ${bi} (in ${tableName}.${column}) is outside of supported bounds`);
286
+ return Number(bi);
285
287
  }
286
288
  return v;
287
289
  case "json": try {