@rocicorp/zero 0.22.2025070200 → 0.22.2025070600

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 (47) hide show
  1. package/out/analyze-query/src/bin-analyze.js +1 -0
  2. package/out/analyze-query/src/bin-analyze.js.map +1 -1
  3. package/out/{chunk-ODTJYJ37.js → chunk-5ZACJSVD.js} +3 -3
  4. package/out/{chunk-43L7S6AU.js → chunk-U52OBQ2U.js} +60 -36
  5. package/out/chunk-U52OBQ2U.js.map +7 -0
  6. package/out/{chunk-HTNKB2W7.js → chunk-ZGVTOORV.js} +59 -38
  7. package/out/{chunk-HTNKB2W7.js.map → chunk-ZGVTOORV.js.map} +2 -2
  8. package/out/{inspector-WSEHHWA3.js → inspector-XJ4IL4MG.js} +2 -2
  9. package/out/react.js +3 -3
  10. package/out/react.js.map +2 -2
  11. package/out/replicache/src/btree/node.d.ts.map +1 -1
  12. package/out/replicache/src/subscriptions.d.ts.map +1 -1
  13. package/out/shared/src/binary-search.d.ts.map +1 -0
  14. package/out/solid.js +27 -7
  15. package/out/solid.js.map +2 -2
  16. package/out/zero-client/src/client/context.d.ts +3 -1
  17. package/out/zero-client/src/client/context.d.ts.map +1 -1
  18. package/out/zero-client/src/client/custom.d.ts +6 -6
  19. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  20. package/out/zero-client/src/client/options.d.ts +9 -2
  21. package/out/zero-client/src/client/options.d.ts.map +1 -1
  22. package/out/zero-client/src/client/query-manager.d.ts +2 -1
  23. package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
  24. package/out/zero-client/src/client/zero.d.ts +3 -3
  25. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  26. package/out/zero-react/src/zero-provider.d.ts +1 -1
  27. package/out/zero-react/src/zero-provider.d.ts.map +1 -1
  28. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  29. package/out/zero-solid/src/use-zero.d.ts +1 -1
  30. package/out/zero-solid/src/use-zero.d.ts.map +1 -1
  31. package/out/zero.js +3 -3
  32. package/out/zql/src/ivm/view-apply-change.d.ts +2 -3
  33. package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
  34. package/out/zql/src/ivm/view-apply-change.js +28 -19
  35. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  36. package/out/zql/src/query/query-delegate.d.ts +1 -0
  37. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  38. package/out/zqlite/src/query-delegate.d.ts +1 -0
  39. package/out/zqlite/src/query-delegate.d.ts.map +1 -1
  40. package/out/zqlite/src/query-delegate.js +1 -0
  41. package/out/zqlite/src/query-delegate.js.map +1 -1
  42. package/package.json +1 -1
  43. package/out/chunk-43L7S6AU.js.map +0 -7
  44. package/out/replicache/src/binary-search.d.ts.map +0 -1
  45. /package/out/{chunk-ODTJYJ37.js.map → chunk-5ZACJSVD.js.map} +0 -0
  46. /package/out/{inspector-WSEHHWA3.js.map → inspector-XJ4IL4MG.js.map} +0 -0
  47. /package/out/{replicache → shared}/src/binary-search.d.ts +0 -0
@@ -126,7 +126,7 @@ import {
126
126
  withWrite,
127
127
  withWriteNoImplicitCommit,
128
128
  wrapIterable
129
- } from "./chunk-43L7S6AU.js";
129
+ } from "./chunk-U52OBQ2U.js";
130
130
  import {
131
131
  __export
132
132
  } from "./chunk-424PT5DM.js";
@@ -7782,6 +7782,7 @@ var ZeroContext = class {
7782
7782
  #addCustomQuery;
7783
7783
  #updateQuery;
7784
7784
  #updateCustomQuery;
7785
+ #flushQueryChanges;
7785
7786
  #batchViewUpdates;
7786
7787
  #commitListeners = /* @__PURE__ */ new Set();
7787
7788
  #slowMaterializeThreshold;
@@ -7792,7 +7793,7 @@ var ZeroContext = class {
7792
7793
  * "complete" once the server has sent back the query result.
7793
7794
  */
7794
7795
  defaultQueryComplete = false;
7795
- constructor(lc, mainSources, addQuery, addCustomQuery, updateQuery, updateCustomQuery, batchViewUpdates, slowMaterializeThreshold, assertValidRunOptions3) {
7796
+ constructor(lc, mainSources, addQuery, addCustomQuery, updateQuery, updateCustomQuery, flushQueryChanges, batchViewUpdates, slowMaterializeThreshold, assertValidRunOptions3) {
7796
7797
  this.#mainSources = mainSources;
7797
7798
  this.#addQuery = addQuery;
7798
7799
  this.#updateQuery = updateQuery;
@@ -7802,6 +7803,7 @@ var ZeroContext = class {
7802
7803
  this.#slowMaterializeThreshold = slowMaterializeThreshold;
7803
7804
  this.assertValidRunOptions = assertValidRunOptions3;
7804
7805
  this.#addCustomQuery = addCustomQuery;
7806
+ this.#flushQueryChanges = flushQueryChanges;
7805
7807
  }
7806
7808
  getSource(name) {
7807
7809
  return this.#mainSources.getSource(name);
@@ -7823,6 +7825,9 @@ var ZeroContext = class {
7823
7825
  updateCustomQuery(customQueryID, ttl) {
7824
7826
  this.#updateCustomQuery(customQueryID.name, customQueryID.args, ttl);
7825
7827
  }
7828
+ flushQueryChanges() {
7829
+ this.#flushQueryChanges();
7830
+ }
7826
7831
  onQueryMaterialized(hash, ast, duration) {
7827
7832
  if (this.#slowMaterializeThreshold !== void 0 && duration > this.#slowMaterializeThreshold) {
7828
7833
  this.#lc.warn?.(
@@ -8186,6 +8191,7 @@ function makeSchemaQuery(lc, schema, ivmBranch, slowMaterializeThreshold) {
8186
8191
  () => emptyFunction,
8187
8192
  emptyFunction,
8188
8193
  emptyFunction,
8194
+ emptyFunction,
8189
8195
  (applyViewUpdates) => applyViewUpdates(),
8190
8196
  slowMaterializeThreshold,
8191
8197
  assertValidRunOptions
@@ -8533,7 +8539,7 @@ function makeMessage(message, context, logLevel) {
8533
8539
  }
8534
8540
 
8535
8541
  // ../zero-client/src/client/version.ts
8536
- var version2 = "0.22.2025070200";
8542
+ var version2 = "0.22.2025070600";
8537
8543
 
8538
8544
  // ../zero-client/src/client/log-options.ts
8539
8545
  var LevelFilterLogSink = class {
@@ -9022,13 +9028,17 @@ var QueryManager = class {
9022
9028
  #recentQueries = /* @__PURE__ */ new Set();
9023
9029
  #gotQueries = /* @__PURE__ */ new Set();
9024
9030
  #mutationTracker;
9031
+ #pendingQueryChanges = [];
9032
+ #queryChangeThrottleMs;
9025
9033
  #pendingRemovals = [];
9026
- constructor(mutationTracker, clientID, tables, send2, experimentalWatch, recentQueriesMaxSize) {
9034
+ #batchTimer;
9035
+ constructor(mutationTracker, clientID, tables, send2, experimentalWatch, recentQueriesMaxSize, queryChangeThrottleMs) {
9027
9036
  this.#clientID = clientID;
9028
9037
  this.#clientToServer = clientToServer(tables);
9029
9038
  this.#recentQueriesMaxSize = recentQueriesMaxSize;
9030
9039
  this.#send = send2;
9031
9040
  this.#mutationTracker = mutationTracker;
9041
+ this.#queryChangeThrottleMs = queryChangeThrottleMs;
9032
9042
  this.#mutationTracker.onAllMutationsConfirmed(() => {
9033
9043
  if (this.#pendingRemovals.length === 0) {
9034
9044
  return;
@@ -9167,21 +9177,14 @@ var QueryManager = class {
9167
9177
  ttl
9168
9178
  };
9169
9179
  this.#queries.set(queryId, entry);
9170
- this.#send([
9171
- "changeDesiredQueries",
9172
- {
9173
- desiredQueriesPatch: [
9174
- {
9175
- op: "put",
9176
- hash: queryId,
9177
- ast: normalized,
9178
- name,
9179
- args,
9180
- ttl: parseTTL(ttl)
9181
- }
9182
- ]
9183
- }
9184
- ]);
9180
+ this.#queueQueryChange({
9181
+ op: "put",
9182
+ hash: queryId,
9183
+ ast: normalized,
9184
+ name,
9185
+ args,
9186
+ ttl: parseTTL(ttl)
9187
+ });
9185
9188
  } else {
9186
9189
  ++entry.count;
9187
9190
  this.#updateEntry(entry, queryId, ttl);
@@ -9221,21 +9224,41 @@ var QueryManager = class {
9221
9224
  #updateEntry(entry, hash, ttl) {
9222
9225
  if (compareTTL(ttl, entry.ttl) > 0) {
9223
9226
  entry.ttl = ttl;
9227
+ this.#queueQueryChange({
9228
+ op: "put",
9229
+ hash,
9230
+ ast: entry.normalized,
9231
+ name: entry.name,
9232
+ args: entry.args,
9233
+ ttl: parseTTL(ttl)
9234
+ });
9235
+ }
9236
+ }
9237
+ #queueQueryChange(op) {
9238
+ this.#pendingQueryChanges.push(op);
9239
+ this.#scheduleBatch();
9240
+ }
9241
+ #scheduleBatch() {
9242
+ if (this.#batchTimer === void 0) {
9243
+ this.#batchTimer = setTimeout(
9244
+ () => this.flushBatch(),
9245
+ this.#queryChangeThrottleMs
9246
+ );
9247
+ }
9248
+ }
9249
+ flushBatch() {
9250
+ if (this.#batchTimer !== void 0) {
9251
+ clearTimeout(this.#batchTimer);
9252
+ this.#batchTimer = void 0;
9253
+ }
9254
+ if (this.#pendingQueryChanges.length > 0) {
9224
9255
  this.#send([
9225
9256
  "changeDesiredQueries",
9226
9257
  {
9227
- desiredQueriesPatch: [
9228
- {
9229
- op: "put",
9230
- hash,
9231
- ast: entry.normalized,
9232
- name: entry.name,
9233
- args: entry.args,
9234
- ttl: parseTTL(ttl)
9235
- }
9236
- ]
9258
+ desiredQueriesPatch: [...this.#pendingQueryChanges]
9237
9259
  }
9238
9260
  ]);
9261
+ this.#pendingQueryChanges.length = 0;
9239
9262
  }
9240
9263
  }
9241
9264
  #remove(entry, astHash, gotCallback) {
@@ -9251,12 +9274,7 @@ var QueryManager = class {
9251
9274
  assert(lruAstHash);
9252
9275
  this.#queries.delete(lruAstHash);
9253
9276
  this.#recentQueries.delete(lruAstHash);
9254
- this.#send([
9255
- "changeDesiredQueries",
9256
- {
9257
- desiredQueriesPatch: [{ op: "del", hash: lruAstHash }]
9258
- }
9259
- ]);
9277
+ this.#queueQueryChange({ op: "del", hash: lruAstHash });
9260
9278
  }
9261
9279
  }
9262
9280
  }
@@ -9802,6 +9820,7 @@ var DEFAULT_DISCONNECT_HIDDEN_DELAY_MS = 5e3;
9802
9820
  var CONNECT_TIMEOUT_MS = 1e4;
9803
9821
  var CHECK_CONNECTIVITY_ON_ERROR_FREQUENCY = 6;
9804
9822
  var NULL_LAST_MUTATION_ID_SENT = { clientID: "", id: -1 };
9823
+ var DEFAULT_QUERY_CHANGE_THROTTLE_MS = 10;
9805
9824
  function convertOnUpdateNeededReason(reason) {
9806
9825
  return { type: reason.type };
9807
9826
  }
@@ -10069,6 +10088,7 @@ var Zero = class _Zero {
10069
10088
  (queryName, queryArgs, ttl, gotCallback) => this.#queryManager.addCustom(queryName, queryArgs, ttl, gotCallback),
10070
10089
  (ast, ttl) => this.#queryManager.updateLegacy(ast, ttl),
10071
10090
  (name, args, ttl) => this.#queryManager.updateCustom(name, args, ttl),
10091
+ () => this.#queryManager.flushBatch(),
10072
10092
  batchViewUpdates,
10073
10093
  slowMaterializeThreshold,
10074
10094
  assertValidRunOptions2
@@ -10157,7 +10177,8 @@ var Zero = class _Zero {
10157
10177
  schema.tables,
10158
10178
  (msg) => this.#send(msg),
10159
10179
  rep.experimentalWatch.bind(rep),
10160
- maxRecentQueries
10180
+ maxRecentQueries,
10181
+ options.queryChangeThrottleMs ?? DEFAULT_QUERY_CHANGE_THROTTLE_MS
10161
10182
  );
10162
10183
  this.#clientToServer = clientToServer(schema.tables);
10163
10184
  this.#deleteClientsManager = new DeleteClientsManager(
@@ -11078,7 +11099,7 @@ var Zero = class _Zero {
11078
11099
  */
11079
11100
  async inspect() {
11080
11101
  BUNDLE_SIZE: {
11081
- const m = await import("./inspector-WSEHHWA3.js");
11102
+ const m = await import("./inspector-XJ4IL4MG.js");
11082
11103
  return m.newInspector(this.#rep, this.#schema, async () => {
11083
11104
  await this.#connectResolver.promise;
11084
11105
  return this.#socket;
@@ -11216,4 +11237,4 @@ export {
11216
11237
  update_needed_reason_type_enum_exports,
11217
11238
  Zero
11218
11239
  };
11219
- //# sourceMappingURL=chunk-HTNKB2W7.js.map
11240
+ //# sourceMappingURL=chunk-ZGVTOORV.js.map