@rocicorp/zero 0.17.2025031400 → 0.18.2025031401

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 (48) hide show
  1. package/out/advanced.js +1 -1
  2. package/out/{chunk-RUSVENO2.js → chunk-4HTOMAT6.js} +66 -53
  3. package/out/chunk-4HTOMAT6.js.map +7 -0
  4. package/out/{chunk-7ARRNDLF.js → chunk-SVJISXWE.js} +49 -56
  5. package/out/{chunk-7ARRNDLF.js.map → chunk-SVJISXWE.js.map} +3 -3
  6. package/out/replicache/src/persist/refresh.d.ts.map +1 -1
  7. package/out/replicache/src/replicache-options.d.ts +1 -2
  8. package/out/replicache/src/replicache-options.d.ts.map +1 -1
  9. package/out/shared/src/custom-key-map.d.ts +2 -2
  10. package/out/shared/src/custom-key-map.d.ts.map +1 -1
  11. package/out/shared/src/custom-key-map.js.map +1 -1
  12. package/out/shared/src/custom-key-set.d.ts +2 -2
  13. package/out/shared/src/custom-key-set.d.ts.map +1 -1
  14. package/out/shared/src/custom-key-set.js.map +1 -1
  15. package/out/solid.js +2 -2
  16. package/out/zero-cache/src/scripts/deploy-permissions.js +1 -1
  17. package/out/zero-cache/src/scripts/deploy-permissions.js.map +1 -1
  18. package/out/zero-cache/src/scripts/permissions.d.ts +23 -0
  19. package/out/zero-cache/src/scripts/permissions.d.ts.map +1 -1
  20. package/out/zero-cache/src/scripts/permissions.js +2 -0
  21. package/out/zero-cache/src/scripts/permissions.js.map +1 -1
  22. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +1 -0
  23. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  24. package/out/zero-cache/src/services/view-syncer/cvr.js +4 -4
  25. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  26. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  27. package/out/zero-cache/src/services/view-syncer/view-syncer.js +3 -2
  28. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  29. package/out/zero-client/src/client/custom.d.ts +9 -13
  30. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  31. package/out/zero-client/src/client/ivm-branch.d.ts +1 -2
  32. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  33. package/out/zero-client/src/client/zero-rep.d.ts +1 -2
  34. package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
  35. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  36. package/out/zero.js +2 -2
  37. package/out/zql/src/ivm/schema.d.ts +2 -2
  38. package/out/zql/src/ivm/schema.d.ts.map +1 -1
  39. package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
  40. package/out/zql/src/ivm/view-apply-change.js +34 -54
  41. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  42. package/out/zql/src/query/query-impl.d.ts +1 -1
  43. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  44. package/out/zql/src/query/query-impl.js.map +1 -1
  45. package/out/zql/src/query/query.d.ts +1 -1
  46. package/out/zql/src/query/query.d.ts.map +1 -1
  47. package/package.json +4 -3
  48. package/out/chunk-RUSVENO2.js.map +0 -7
package/out/advanced.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./chunk-ULOTOBTC.js";
2
2
  import {
3
3
  applyChange
4
- } from "./chunk-7ARRNDLF.js";
4
+ } from "./chunk-SVJISXWE.js";
5
5
  import "./chunk-424PT5DM.js";
6
6
  export {
7
7
  applyChange
@@ -21,7 +21,7 @@ import {
21
21
  throwInvalidType,
22
22
  unreachable,
23
23
  valuesEqual
24
- } from "./chunk-7ARRNDLF.js";
24
+ } from "./chunk-SVJISXWE.js";
25
25
  import {
26
26
  __export,
27
27
  __reExport
@@ -6315,7 +6315,7 @@ async function persistDD31(lc, clientID, memdag, perdag, mutators, closed, forma
6315
6315
  return;
6316
6316
  }
6317
6317
  let memdagBaseSnapshotPersisted = false;
6318
- const zeroDataForMemdagBaseSnapshot = getZeroData && await getZeroData("rebase", memdagBaseSnapshot.chunk.hash);
6318
+ const zeroDataForMemdagBaseSnapshot = getZeroData && await getZeroData(memdagBaseSnapshot.chunk.hash);
6319
6319
  await withWrite(perdag, async (perdagWrite) => {
6320
6320
  const [mainClientGroup, latestPerdagMainClientGroupHeadCommit] = await getClientGroupInfo(perdagWrite, mainClientGroupID);
6321
6321
  let newMainClientGroupHeadHash = latestPerdagMainClientGroupHeadCommit.chunk.hash;
@@ -6368,7 +6368,7 @@ async function persistDD31(lc, clientID, memdag, perdag, mutators, closed, forma
6368
6368
  }
6369
6369
  let zeroDataForPerdagHeadCommit;
6370
6370
  if (!memdagBaseSnapshotPersisted) {
6371
- zeroDataForPerdagHeadCommit = getZeroData && await getZeroData("rebase", newMainClientGroupHeadHash, {
6371
+ zeroDataForPerdagHeadCommit = getZeroData && await getZeroData(newMainClientGroupHeadHash, {
6372
6372
  openLazySourceRead: perdagWrite
6373
6373
  });
6374
6374
  }
@@ -6575,13 +6575,9 @@ async function refresh(lc, memdag, perdag, clientID, mutators, diffConfig, close
6575
6575
  await Promise.all(ps);
6576
6576
  let newMemdagHeadHash = perdagClientGroupHeadHash;
6577
6577
  if (newMemdagMutations.length > 0) {
6578
- const zeroData2 = await zero?.getTxData?.(
6579
- "rebase",
6580
- newMemdagHeadHash,
6581
- {
6582
- openLazyRead: memdagWrite
6583
- }
6584
- );
6578
+ const zeroData2 = await zero?.getTxData?.(newMemdagHeadHash, {
6579
+ openLazyRead: memdagWrite
6580
+ });
6585
6581
  for (let i = newMemdagMutations.length - 1; i >= 0; i--) {
6586
6582
  newMemdagHeadHash = (await rebaseMutationAndPutCommit(
6587
6583
  newMemdagMutations[i],
@@ -7624,7 +7620,7 @@ var ReplicacheImpl = class {
7624
7620
  void this.#schedulePersist();
7625
7621
  return;
7626
7622
  }
7627
- const zeroData2 = await this.#zero?.getTxData?.("rebase", syncHead);
7623
+ const zeroData2 = await this.#zero?.getTxData?.(syncHead);
7628
7624
  for (const mutation of replayMutations) {
7629
7625
  if (this.#subscriptions.hasPendingSubscriptionRuns) {
7630
7626
  await Promise.resolve();
@@ -8190,7 +8186,7 @@ var ReplicacheImpl = class {
8190
8186
  clientID,
8191
8187
  await dbWrite.getMutationID(),
8192
8188
  "initial",
8193
- await this.#zero?.getTxData("initial", headHash, {
8189
+ await this.#zero?.getTxData(headHash, {
8194
8190
  openLazyRead: dagWrite
8195
8191
  }),
8196
8192
  dbWrite,
@@ -13686,14 +13682,7 @@ var IVMSourceBranch = class _IVMSourceBranch {
13686
13682
  /**
13687
13683
  * Fork the branch and patch it up to match the desired head.
13688
13684
  */
13689
- async forkToHead(reason, store, desiredHead, readOptions) {
13690
- if (reason === "initial") {
13691
- assert(
13692
- this.hash === desiredHead,
13693
- "main branch must be at desired head for `initial`"
13694
- );
13695
- return this;
13696
- }
13685
+ async forkToHead(store, desiredHead, readOptions) {
13697
13686
  const fork = this.fork();
13698
13687
  if (fork.hash === desiredHead) {
13699
13688
  return fork;
@@ -14114,12 +14103,7 @@ var TransactionImpl = class {
14114
14103
  this.mutate = makeSchemaCRUD(
14115
14104
  schema,
14116
14105
  repTx,
14117
- // CRUD operators should not mutate the IVM store directly
14118
- // for `initial`. The IVM store will be updated via calls to `advance`
14119
- // after the transaction has been committed to the Replicache b-tree.
14120
- // Mutating the IVM store in the mutator would cause us to synchronously
14121
- // notify listeners of IVM while we're inside of the Replicache DB transaction.
14122
- repTx.reason === "initial" ? void 0 : must(
14106
+ must(
14123
14107
  castedRepTx[zeroData],
14124
14108
  "zero was not set on replicache internal options!"
14125
14109
  )
@@ -14515,7 +14499,7 @@ function makeMessage(message, context, logLevel) {
14515
14499
  }
14516
14500
 
14517
14501
  // ../zero-client/src/client/version.ts
14518
- var version2 = "0.17.2025031400";
14502
+ var version2 = "0.18.2025031401";
14519
14503
 
14520
14504
  // ../zero-client/src/client/log-options.ts
14521
14505
  var LevelFilterLogSink = class {
@@ -15467,12 +15451,11 @@ var ZeroRep = class {
15467
15451
  this.#store = store;
15468
15452
  this.#context.processChanges(void 0, hash2, diffs);
15469
15453
  }
15470
- getTxData = (reason, desiredHead, readOptions) => {
15454
+ getTxData = (desiredHead, readOptions) => {
15471
15455
  if (!this.#customMutatorsEnabled) {
15472
15456
  return;
15473
15457
  }
15474
15458
  return this.#ivmMain.forkToHead(
15475
- reason,
15476
15459
  must(this.#store),
15477
15460
  desiredHead,
15478
15461
  readOptions
@@ -15673,19 +15656,45 @@ var Zero = class {
15673
15656
  [CRUD_MUTATION_NAME]: makeCRUDMutator(schema)
15674
15657
  };
15675
15658
  this.#ivmMain = new IVMSourceBranch(schema.tables);
15659
+ function assertUnique(key) {
15660
+ assert(
15661
+ replicacheMutators[key] === void 0,
15662
+ `A mutator, or mutator namespace, has already been defined for ${key}`
15663
+ );
15664
+ }
15676
15665
  const lc = new LogContext4(logOptions.logLevel, {}, logOptions.logSink);
15677
- for (const [namespace, mutatorsForNamespace] of Object.entries(
15678
- options.mutators ?? {}
15679
- )) {
15680
- for (const [name, mutator] of Object.entries(
15681
- mutatorsForNamespace
15666
+ if (options.mutators) {
15667
+ for (const [namespaceOrKey, mutatorOrMutators] of Object.entries(
15668
+ options.mutators
15682
15669
  )) {
15683
- replicacheMutators[customMutatorKey(namespace, name)] = makeReplicacheMutator(
15684
- lc,
15685
- mutator,
15686
- schema,
15687
- slowMaterializeThreshold
15688
- );
15670
+ if (typeof mutatorOrMutators === "function") {
15671
+ const key = namespaceOrKey;
15672
+ assertUnique(key);
15673
+ replicacheMutators[key] = makeReplicacheMutator(
15674
+ lc,
15675
+ mutatorOrMutators,
15676
+ schema,
15677
+ slowMaterializeThreshold
15678
+ );
15679
+ continue;
15680
+ }
15681
+ if (typeof mutatorOrMutators === "object") {
15682
+ for (const [name, mutator] of Object.entries(mutatorOrMutators)) {
15683
+ const key = customMutatorKey(
15684
+ namespaceOrKey,
15685
+ name
15686
+ );
15687
+ assertUnique(key);
15688
+ replicacheMutators[key] = makeReplicacheMutator(
15689
+ lc,
15690
+ mutator,
15691
+ schema,
15692
+ slowMaterializeThreshold
15693
+ );
15694
+ }
15695
+ continue;
15696
+ }
15697
+ unreachable(mutatorOrMutators);
15689
15698
  }
15690
15699
  }
15691
15700
  this.storageKey = storageKey ?? "";
@@ -15759,19 +15768,23 @@ var Zero = class {
15759
15768
  if (options.mutators) {
15760
15769
  mutate = {};
15761
15770
  mutateBatch = void 0;
15762
- }
15763
- for (const [namespace, mutatorsForNamespace] of Object.entries(
15764
- options.mutators ?? {}
15765
- )) {
15766
- let existing = mutate[namespace];
15767
- if (existing === void 0) {
15768
- existing = {};
15769
- mutate[namespace] = existing;
15770
- }
15771
- for (const name of Object.keys(
15772
- mutatorsForNamespace
15771
+ for (const [namespaceOrKey, mutatorsOrMutator] of Object.entries(
15772
+ options.mutators
15773
15773
  )) {
15774
- existing[name] = must(rep.mutate[customMutatorKey(namespace, name)]);
15774
+ if (typeof mutatorsOrMutator === "function") {
15775
+ mutate[namespaceOrKey] = must(rep.mutate[namespaceOrKey]);
15776
+ continue;
15777
+ }
15778
+ let existing = mutate[namespaceOrKey];
15779
+ if (existing === void 0) {
15780
+ existing = {};
15781
+ mutate[namespaceOrKey] = existing;
15782
+ }
15783
+ for (const name of Object.keys(mutatorsOrMutator)) {
15784
+ existing[name] = must(
15785
+ rep.mutate[customMutatorKey(namespaceOrKey, name)]
15786
+ );
15787
+ }
15775
15788
  }
15776
15789
  }
15777
15790
  this.mutate = mutate;
@@ -16791,4 +16804,4 @@ export {
16791
16804
  escapeLike,
16792
16805
  Zero
16793
16806
  };
16794
- //# sourceMappingURL=chunk-RUSVENO2.js.map
16807
+ //# sourceMappingURL=chunk-4HTOMAT6.js.map