@rocicorp/zero 0.24.2025092500 → 0.24.2025092700

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 (92) hide show
  1. package/out/analyze-query/src/run-ast.d.ts.map +1 -1
  2. package/out/analyze-query/src/run-ast.js +8 -0
  3. package/out/analyze-query/src/run-ast.js.map +1 -1
  4. package/out/ast-to-zql/src/ast-to-zql.js +5 -4
  5. package/out/ast-to-zql/src/ast-to-zql.js.map +1 -1
  6. package/out/{chunk-576ADFNS.js → chunk-C524XUFX.js} +3 -3
  7. package/out/{chunk-QZPMFA73.js → chunk-MGNNTSXN.js} +893 -263
  8. package/out/chunk-MGNNTSXN.js.map +7 -0
  9. package/out/{chunk-N4QOJO4J.js → chunk-YHZFOFXO.js} +94 -151
  10. package/out/{chunk-N4QOJO4J.js.map → chunk-YHZFOFXO.js.map} +4 -4
  11. package/out/{lazy-inspector-TOTYUTBC.js → lazy-inspector-VMXLTE36.js} +7 -6
  12. package/out/lazy-inspector-VMXLTE36.js.map +7 -0
  13. package/out/react.js +2 -2
  14. package/out/solid.js +3 -3
  15. package/out/zero/package.json +1 -1
  16. package/out/zero-protocol/src/ast.d.ts +1 -2
  17. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  18. package/out/zero-protocol/src/ast.js +1 -2
  19. package/out/zero-protocol/src/ast.js.map +1 -1
  20. package/out/zero-protocol/src/protocol-version.d.ts +1 -1
  21. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  22. package/out/zero-protocol/src/protocol-version.js +2 -1
  23. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  24. package/out/zero.js +3 -3
  25. package/out/zql/src/builder/builder.d.ts +2 -0
  26. package/out/zql/src/builder/builder.d.ts.map +1 -1
  27. package/out/zql/src/builder/builder.js +123 -42
  28. package/out/zql/src/builder/builder.js.map +1 -1
  29. package/out/zql/src/ivm/constraint.d.ts +6 -0
  30. package/out/zql/src/ivm/constraint.d.ts.map +1 -1
  31. package/out/zql/src/ivm/constraint.js +13 -0
  32. package/out/zql/src/ivm/constraint.js.map +1 -1
  33. package/out/zql/src/ivm/exists.d.ts.map +1 -1
  34. package/out/zql/src/ivm/exists.js +5 -5
  35. package/out/zql/src/ivm/exists.js.map +1 -1
  36. package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
  37. package/out/zql/src/ivm/fan-in.js +1 -1
  38. package/out/zql/src/ivm/fan-in.js.map +1 -1
  39. package/out/zql/src/ivm/fan-out.js +1 -1
  40. package/out/zql/src/ivm/fan-out.js.map +1 -1
  41. package/out/zql/src/ivm/filter-operators.js +2 -2
  42. package/out/zql/src/ivm/filter-operators.js.map +1 -1
  43. package/out/zql/src/ivm/filter-push.d.ts +2 -2
  44. package/out/zql/src/ivm/filter-push.d.ts.map +1 -1
  45. package/out/zql/src/ivm/filter-push.js +5 -5
  46. package/out/zql/src/ivm/filter-push.js.map +1 -1
  47. package/out/zql/src/ivm/filter.js +1 -1
  48. package/out/zql/src/ivm/filter.js.map +1 -1
  49. package/out/zql/src/ivm/flipped-join.d.ts.map +1 -1
  50. package/out/zql/src/ivm/flipped-join.js +42 -49
  51. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  52. package/out/zql/src/ivm/join.d.ts.map +1 -1
  53. package/out/zql/src/ivm/join.js +5 -5
  54. package/out/zql/src/ivm/join.js.map +1 -1
  55. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +2 -2
  56. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
  57. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +4 -4
  58. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
  59. package/out/zql/src/ivm/memory-source.d.ts +2 -2
  60. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  61. package/out/zql/src/ivm/memory-source.js +55 -66
  62. package/out/zql/src/ivm/memory-source.js.map +1 -1
  63. package/out/zql/src/ivm/operator.d.ts +1 -1
  64. package/out/zql/src/ivm/operator.d.ts.map +1 -1
  65. package/out/zql/src/ivm/push-accumulated.d.ts +2 -2
  66. package/out/zql/src/ivm/push-accumulated.d.ts.map +1 -1
  67. package/out/zql/src/ivm/push-accumulated.js +8 -8
  68. package/out/zql/src/ivm/push-accumulated.js.map +1 -1
  69. package/out/zql/src/ivm/skip.js +2 -2
  70. package/out/zql/src/ivm/skip.js.map +1 -1
  71. package/out/zql/src/ivm/take.d.ts.map +1 -1
  72. package/out/zql/src/ivm/take.js +17 -17
  73. package/out/zql/src/ivm/take.js.map +1 -1
  74. package/out/zql/src/ivm/union-fan-in.d.ts +19 -0
  75. package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -0
  76. package/out/zql/src/ivm/union-fan-in.js +146 -0
  77. package/out/zql/src/ivm/union-fan-in.js.map +1 -0
  78. package/out/zql/src/ivm/union-fan-out.d.ts +18 -0
  79. package/out/zql/src/ivm/union-fan-out.d.ts.map +1 -0
  80. package/out/zql/src/ivm/union-fan-out.js +48 -0
  81. package/out/zql/src/ivm/union-fan-out.js.map +1 -0
  82. package/out/zql/src/query/measure-push-operator.js +1 -1
  83. package/out/zql/src/query/measure-push-operator.js.map +1 -1
  84. package/out/zql/src/query/query-impl.js +3 -3
  85. package/out/zql/src/query/query-impl.js.map +1 -1
  86. package/out/zqlite/src/table-source.d.ts.map +1 -1
  87. package/out/zqlite/src/table-source.js +6 -7
  88. package/out/zqlite/src/table-source.js.map +1 -1
  89. package/package.json +1 -1
  90. package/out/chunk-QZPMFA73.js.map +0 -7
  91. package/out/lazy-inspector-TOTYUTBC.js.map +0 -7
  92. /package/out/{chunk-576ADFNS.js.map → chunk-C524XUFX.js.map} +0 -0
@@ -49,6 +49,8 @@ import {
49
49
  compareCookiesForSnapshots,
50
50
  compareTTL,
51
51
  compareValues,
52
+ constraintMatchesPrimaryKey,
53
+ constraintMatchesRow,
52
54
  createChunk,
53
55
  createPredicate,
54
56
  decodeIndexKey,
@@ -103,6 +105,7 @@ import {
103
105
  normalizeAST,
104
106
  once,
105
107
  parse,
108
+ primaryKeyConstraintFromFilters,
106
109
  primaryKeySchema,
107
110
  primaryKeyValueRecordSchema,
108
111
  readFromDefaultHead,
@@ -132,7 +135,7 @@ import {
132
135
  withWrite,
133
136
  withWriteNoImplicitCommit,
134
137
  wrapIterable
135
- } from "./chunk-QZPMFA73.js";
138
+ } from "./chunk-MGNNTSXN.js";
136
139
  import {
137
140
  assert,
138
141
  assertArray,
@@ -6425,7 +6428,7 @@ var downstreamSchema = valita_exports.union(
6425
6428
  );
6426
6429
 
6427
6430
  // ../zero-protocol/src/protocol-version.ts
6428
- var PROTOCOL_VERSION = 33;
6431
+ var PROTOCOL_VERSION = 34;
6429
6432
  var MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 18;
6430
6433
  assert(MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION);
6431
6434
 
@@ -7283,7 +7286,7 @@ var MeasurePushOperator = class {
7283
7286
  }
7284
7287
  push(change) {
7285
7288
  const startTime = performance.now();
7286
- this.#output.push(change);
7289
+ this.#output.push(change, this);
7287
7290
  this.#metricsDelegate.addMetric(
7288
7291
  this.#metricName,
7289
7292
  performance.now() - startTime,
@@ -7292,73 +7295,6 @@ var MeasurePushOperator = class {
7292
7295
  }
7293
7296
  };
7294
7297
 
7295
- // ../zql/src/ivm/constraint.ts
7296
- function constraintMatchesRow(constraint, row) {
7297
- for (const key in constraint) {
7298
- if (!valuesEqual(row[key], constraint[key])) {
7299
- return false;
7300
- }
7301
- }
7302
- return true;
7303
- }
7304
- function constraintMatchesPrimaryKey(constraint, primary) {
7305
- const constraintKeys = Object.keys(constraint);
7306
- if (constraintKeys.length !== primary.length) {
7307
- return false;
7308
- }
7309
- constraintKeys.sort(stringCompare);
7310
- for (let i = 0; i < constraintKeys.length; i++) {
7311
- if (constraintKeys[i] !== primary[i]) {
7312
- return false;
7313
- }
7314
- }
7315
- return true;
7316
- }
7317
- function pullSimpleAndComponents(condition) {
7318
- if (condition.type === "and") {
7319
- return condition.conditions.flatMap(pullSimpleAndComponents);
7320
- }
7321
- if (condition.type === "simple") {
7322
- return [condition];
7323
- }
7324
- if (condition.type === "or" && condition.conditions.length === 1) {
7325
- return pullSimpleAndComponents(condition.conditions[0]);
7326
- }
7327
- return [];
7328
- }
7329
- function primaryKeyConstraintFromFilters(condition, primary) {
7330
- if (condition === void 0) {
7331
- return void 0;
7332
- }
7333
- const conditions = pullSimpleAndComponents(condition);
7334
- if (conditions.length === 0) {
7335
- return void 0;
7336
- }
7337
- const ret = {};
7338
- for (const subCondition of conditions) {
7339
- if (subCondition.op === "=") {
7340
- const column = extractColumn(subCondition);
7341
- if (column !== void 0) {
7342
- if (!primary.includes(column.name)) {
7343
- continue;
7344
- }
7345
- ret[column.name] = column.value;
7346
- }
7347
- }
7348
- }
7349
- if (Object.keys(ret).length !== primary.length) {
7350
- return void 0;
7351
- }
7352
- return ret;
7353
- }
7354
- function extractColumn(condition) {
7355
- if (condition.left.type === "column") {
7356
- assert(condition.right.type === "literal");
7357
- return { name: condition.left.name, value: condition.right.value };
7358
- }
7359
- return void 0;
7360
- }
7361
-
7362
7298
  // ../zql/src/ivm/memory-source.ts
7363
7299
  var MemorySource = class _MemorySource {
7364
7300
  #tableName;
@@ -7368,7 +7304,6 @@ var MemorySource = class _MemorySource {
7368
7304
  #indexes = /* @__PURE__ */ new Map();
7369
7305
  #connections = [];
7370
7306
  #overlay;
7371
- #splitEditOverlay;
7372
7307
  constructor(tableName, columns, primaryKey, primaryIndexData) {
7373
7308
  this.#tableName = tableName;
7374
7309
  this.#columns = columns;
@@ -7524,7 +7459,6 @@ var MemorySource = class _MemorySource {
7524
7459
  // rather than as the fetch constraint.
7525
7460
  req.constraint,
7526
7461
  this.#overlay,
7527
- this.#splitEditOverlay,
7528
7462
  callingConnectionIndex,
7529
7463
  // Use indexComparator, generateWithOverlayInner has a subtle dependency
7530
7464
  // on this. Since generateWithConstraint is done after
@@ -7558,7 +7492,7 @@ var MemorySource = class _MemorySource {
7558
7492
  const { data } = primaryIndex;
7559
7493
  const exists = (row) => data.has(row);
7560
7494
  const setOverlay = (o) => this.#overlay = o;
7561
- const setSplitEditOverlay = (o) => this.#splitEditOverlay = o;
7495
+ const writeChange = (c) => this.#writeChange(c);
7562
7496
  if (change.type === "set") {
7563
7497
  const existing = data.get(change.row);
7564
7498
  if (existing !== void 0) {
@@ -7574,31 +7508,31 @@ var MemorySource = class _MemorySource {
7574
7508
  };
7575
7509
  }
7576
7510
  }
7577
- for (const x of genPush(
7511
+ yield* genPushAndWriteWithSplitEdit(
7512
+ this.#connections,
7578
7513
  change,
7579
7514
  exists,
7580
- this.#connections.entries(),
7581
7515
  setOverlay,
7582
- setSplitEditOverlay
7583
- )) {
7584
- yield x;
7585
- }
7586
- for (const { data: data2 } of this.#indexes.values()) {
7516
+ writeChange
7517
+ );
7518
+ }
7519
+ #writeChange(change) {
7520
+ for (const { data } of this.#indexes.values()) {
7587
7521
  switch (change.type) {
7588
7522
  case "add": {
7589
- const added = data2.add(change.row);
7523
+ const added = data.add(change.row);
7590
7524
  assert(added);
7591
7525
  break;
7592
7526
  }
7593
7527
  case "remove": {
7594
- const removed = data2.delete(change.row);
7528
+ const removed = data.delete(change.row);
7595
7529
  assert(removed);
7596
7530
  break;
7597
7531
  }
7598
7532
  case "edit": {
7599
- const removed = data2.delete(change.oldRow);
7533
+ const removed = data.delete(change.oldRow);
7600
7534
  assert(removed);
7601
- data2.add(change.row);
7535
+ data.add(change.row);
7602
7536
  break;
7603
7537
  }
7604
7538
  default:
@@ -7622,7 +7556,58 @@ function* generateWithFilter(it, filter) {
7622
7556
  }
7623
7557
  }
7624
7558
  }
7625
- function* genPush(change, exists, connections, setOverlay, setSplitEditOverlay) {
7559
+ function* genPushAndWriteWithSplitEdit(connections, change, exists, setOverlay, writeChange) {
7560
+ let shouldSplitEdit = false;
7561
+ if (change.type === "edit") {
7562
+ for (const { splitEditKeys } of connections) {
7563
+ if (splitEditKeys) {
7564
+ for (const key of splitEditKeys) {
7565
+ if (!valuesEqual(change.row[key], change.oldRow[key])) {
7566
+ shouldSplitEdit = true;
7567
+ break;
7568
+ }
7569
+ }
7570
+ }
7571
+ }
7572
+ }
7573
+ if (change.type === "edit" && shouldSplitEdit) {
7574
+ yield* genPushAndWrite(
7575
+ connections,
7576
+ {
7577
+ type: "remove",
7578
+ row: change.oldRow
7579
+ },
7580
+ exists,
7581
+ setOverlay,
7582
+ writeChange
7583
+ );
7584
+ yield* genPushAndWrite(
7585
+ connections,
7586
+ {
7587
+ type: "add",
7588
+ row: change.row
7589
+ },
7590
+ exists,
7591
+ setOverlay,
7592
+ writeChange
7593
+ );
7594
+ } else {
7595
+ yield* genPushAndWrite(
7596
+ connections,
7597
+ change,
7598
+ exists,
7599
+ setOverlay,
7600
+ writeChange
7601
+ );
7602
+ }
7603
+ }
7604
+ function* genPushAndWrite(connections, change, exists, setOverlay, writeChange) {
7605
+ for (const x of genPush(connections, change, exists, setOverlay)) {
7606
+ yield x;
7607
+ }
7608
+ writeChange(change);
7609
+ }
7610
+ function* genPush(connections, change, exists, setOverlay) {
7626
7611
  switch (change.type) {
7627
7612
  case "add":
7628
7613
  assert(
@@ -7639,68 +7624,28 @@ function* genPush(change, exists, connections, setOverlay, setSplitEditOverlay)
7639
7624
  default:
7640
7625
  unreachable(change);
7641
7626
  }
7642
- for (const [outputIndex, { output, splitEditKeys, filters }] of connections) {
7627
+ for (const [outputIndex, { output, filters, input }] of connections.entries()) {
7643
7628
  if (output) {
7644
- let splitEdit = false;
7645
- if (change.type === "edit" && splitEditKeys) {
7646
- for (const key of splitEditKeys) {
7647
- if (!valuesEqual(change.row[key], change.oldRow[key])) {
7648
- splitEdit = true;
7649
- break;
7650
- }
7629
+ setOverlay({ outputIndex, change });
7630
+ const outputChange = change.type === "edit" ? {
7631
+ type: change.type,
7632
+ oldNode: {
7633
+ row: change.oldRow,
7634
+ relationships: {}
7635
+ },
7636
+ node: {
7637
+ row: change.row,
7638
+ relationships: {}
7651
7639
  }
7652
- }
7653
- if (splitEdit) {
7654
- assert(change.type === "edit");
7655
- setSplitEditOverlay({
7656
- outputIndex,
7657
- change: {
7658
- type: "remove",
7659
- row: change.oldRow
7660
- }
7661
- });
7662
- const outputRemove = {
7663
- type: "remove",
7664
- node: {
7665
- row: change.oldRow,
7666
- relationships: {}
7667
- }
7668
- };
7669
- filterPush(outputRemove, output, filters?.predicate);
7670
- yield;
7671
- setSplitEditOverlay(void 0);
7672
- setOverlay({ outputIndex, change });
7673
- const outputAdd = {
7674
- type: "add",
7675
- node: {
7676
- row: change.row,
7677
- relationships: {}
7678
- }
7679
- };
7680
- filterPush(outputAdd, output, filters?.predicate);
7681
- yield;
7682
- } else {
7683
- setOverlay({ outputIndex, change });
7684
- const outputChange = change.type === "edit" ? {
7685
- type: change.type,
7686
- oldNode: {
7687
- row: change.oldRow,
7688
- relationships: {}
7689
- },
7690
- node: {
7691
- row: change.row,
7692
- relationships: {}
7693
- }
7694
- } : {
7695
- type: change.type,
7696
- node: {
7697
- row: change.row,
7698
- relationships: {}
7699
- }
7700
- };
7701
- filterPush(outputChange, output, filters?.predicate);
7702
- yield;
7703
- }
7640
+ } : {
7641
+ type: change.type,
7642
+ node: {
7643
+ row: change.row,
7644
+ relationships: {}
7645
+ }
7646
+ };
7647
+ filterPush(outputChange, output, input, filters?.predicate);
7648
+ yield;
7704
7649
  }
7705
7650
  }
7706
7651
  setOverlay(void 0);
@@ -7728,11 +7673,9 @@ function* generateWithStart(nodes, start, compare2) {
7728
7673
  }
7729
7674
  }
7730
7675
  }
7731
- function* generateWithOverlay(startAt, rows, constraint, overlay, splitEditOverlay, connectionIndex, compare2, filterPredicate) {
7676
+ function* generateWithOverlay(startAt, rows, constraint, overlay, connectionIndex, compare2, filterPredicate) {
7732
7677
  let overlayToApply = void 0;
7733
- if (splitEditOverlay && splitEditOverlay.outputIndex === connectionIndex) {
7734
- overlayToApply = splitEditOverlay;
7735
- } else if (overlay && connectionIndex <= overlay.outputIndex) {
7678
+ if (overlay && connectionIndex <= overlay.outputIndex) {
7736
7679
  overlayToApply = overlay;
7737
7680
  }
7738
7681
  const overlays = computeOverlays(
@@ -8749,7 +8692,7 @@ function makeMessage(message, context, logLevel) {
8749
8692
  }
8750
8693
 
8751
8694
  // ../zero-client/src/client/version.ts
8752
- var version2 = "0.24.2025092500";
8695
+ var version2 = "0.24.2025092700";
8753
8696
 
8754
8697
  // ../zero-client/src/client/log-options.ts
8755
8698
  var LevelFilterLogSink = class {
@@ -11724,4 +11667,4 @@ export {
11724
11667
  update_needed_reason_type_enum_exports,
11725
11668
  Zero
11726
11669
  };
11727
- //# sourceMappingURL=chunk-N4QOJO4J.js.map
11670
+ //# sourceMappingURL=chunk-YHZFOFXO.js.map