@rocicorp/zero 0.14.2025021100 → 0.14.2025021101

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 (36) hide show
  1. package/out/{chunk-OPWNICE2.js → chunk-5GWP7BBD.js} +148 -76
  2. package/out/chunk-5GWP7BBD.js.map +7 -0
  3. package/out/replicache/src/deleted-clients.d.ts +12 -6
  4. package/out/replicache/src/deleted-clients.d.ts.map +1 -1
  5. package/out/replicache/src/persist/client-group-gc.d.ts +3 -2
  6. package/out/replicache/src/persist/client-group-gc.d.ts.map +1 -1
  7. package/out/replicache/src/persist/clients.d.ts +1 -1
  8. package/out/replicache/src/persist/clients.d.ts.map +1 -1
  9. package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
  10. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  11. package/out/shared/src/immutable.d.ts +1 -1
  12. package/out/shared/src/immutable.d.ts.map +1 -1
  13. package/out/solid.js +1 -1
  14. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
  15. package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
  16. package/out/zero-cache/src/services/view-syncer/view-syncer.js +5 -5
  17. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  18. package/out/zero-client/src/client/delete-clients-manager.d.ts +6 -5
  19. package/out/zero-client/src/client/delete-clients-manager.d.ts.map +1 -1
  20. package/out/zero-client/src/client/zero.d.ts +2 -1
  21. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  22. package/out/zero-protocol/src/connect.d.ts +8 -2
  23. package/out/zero-protocol/src/connect.d.ts.map +1 -1
  24. package/out/zero-protocol/src/connect.js +2 -1
  25. package/out/zero-protocol/src/connect.js.map +1 -1
  26. package/out/zero-protocol/src/delete-clients.d.ts +8 -7
  27. package/out/zero-protocol/src/delete-clients.d.ts.map +1 -1
  28. package/out/zero-protocol/src/delete-clients.js +4 -3
  29. package/out/zero-protocol/src/delete-clients.js.map +1 -1
  30. package/out/zero-protocol/src/down.d.ts +4 -3
  31. package/out/zero-protocol/src/down.d.ts.map +1 -1
  32. package/out/zero-protocol/src/up.d.ts +8 -4
  33. package/out/zero-protocol/src/up.d.ts.map +1 -1
  34. package/out/zero.js +1 -1
  35. package/package.json +1 -1
  36. package/out/chunk-OPWNICE2.js.map +0 -7
@@ -1420,33 +1420,46 @@ var WriteImpl2 = class extends ReadImpl2 {
1420
1420
 
1421
1421
  // ../replicache/src/deleted-clients.ts
1422
1422
  var DELETED_CLIENTS_HEAD_NAME = "deleted-clients";
1423
- async function setDeletedClients(dagWrite, deletedClients) {
1424
- const normalized = normalize(deletedClients);
1425
- const chunkData = deepFreeze(normalized);
1423
+ var deletedClientsSchema = readonlyObject({
1424
+ clientIDs: readonlyArray(valita_exports.string()),
1425
+ clientGroupIDs: readonlyArray(valita_exports.string())
1426
+ });
1427
+ async function setDeletedClients(dagWrite, clientIDs, clientGroupIDs) {
1428
+ const data = {
1429
+ clientIDs: normalize(clientIDs),
1430
+ clientGroupIDs: normalize(clientGroupIDs)
1431
+ };
1432
+ const chunkData = deepFreeze(data);
1426
1433
  const chunk = dagWrite.createChunk(chunkData, []);
1427
1434
  await dagWrite.putChunk(chunk);
1428
1435
  await dagWrite.setHead(DELETED_CLIENTS_HEAD_NAME, chunk.hash);
1429
- return normalized;
1436
+ return data;
1430
1437
  }
1431
- var deletedClientsSchema = valita_exports.array(valita_exports.string());
1432
1438
  async function getDeletedClients(dagRead) {
1433
1439
  const hash2 = await dagRead.getHead(DELETED_CLIENTS_HEAD_NAME);
1434
1440
  if (hash2 === void 0) {
1435
- return [];
1441
+ return { clientIDs: [], clientGroupIDs: [] };
1436
1442
  }
1437
1443
  const chunk = await dagRead.mustGetChunk(hash2);
1438
1444
  return parse(chunk.data, deletedClientsSchema);
1439
1445
  }
1440
- async function addDeletedClients(dagWrite, clientIDs) {
1441
- const deletedClients = await getDeletedClients(dagWrite);
1442
- return setDeletedClients(dagWrite, [...deletedClients, ...clientIDs]);
1446
+ async function addDeletedClients(dagWrite, clientIDs, clientGroupIDs) {
1447
+ const { clientIDs: oldClientIDs, clientGroupIDs: oldClientGroupIDs } = await getDeletedClients(dagWrite);
1448
+ return setDeletedClients(
1449
+ dagWrite,
1450
+ [...oldClientIDs, ...clientIDs],
1451
+ [...oldClientGroupIDs, ...clientGroupIDs]
1452
+ );
1443
1453
  }
1444
- async function removeDeletedClients(dagWrite, clientIDs) {
1445
- const deletedClients = await getDeletedClients(dagWrite);
1446
- const newDeletedClients = deletedClients.filter(
1454
+ async function removeDeletedClients(dagWrite, clientIDs, clientGroupIDs) {
1455
+ const { clientIDs: oldClientIDs, clientGroupIDs: oldClientGroupIDs } = await getDeletedClients(dagWrite);
1456
+ const newDeletedClients = oldClientIDs.filter(
1447
1457
  (clientID) => !clientIDs.includes(clientID)
1448
1458
  );
1449
- return setDeletedClients(dagWrite, newDeletedClients);
1459
+ const newDeletedClientGroups = oldClientGroupIDs.filter(
1460
+ (clientGroupID) => !clientGroupIDs.includes(clientGroupID)
1461
+ );
1462
+ return setDeletedClients(dagWrite, newDeletedClients, newDeletedClientGroups);
1450
1463
  }
1451
1464
  function normalize(arr) {
1452
1465
  return [...new Set(arr)].sort();
@@ -3095,13 +3108,13 @@ var DataNodeImpl = class extends NodeImpl {
3095
3108
  }
3096
3109
  }
3097
3110
  };
3098
- function readonlySplice(array12, start, deleteCount, ...items) {
3099
- const arr = array12.slice(0, start);
3111
+ function readonlySplice(array9, start, deleteCount, ...items) {
3112
+ const arr = array9.slice(0, start);
3100
3113
  for (let i = 0; i < items.length; i++) {
3101
3114
  arr.push(items[i]);
3102
3115
  }
3103
- for (let i = start + deleteCount; i < array12.length; i++) {
3104
- arr.push(array12[i]);
3116
+ for (let i = start + deleteCount; i < array9.length; i++) {
3117
+ arr.push(array9[i]);
3105
3118
  }
3106
3119
  return arr;
3107
3120
  }
@@ -5772,7 +5785,7 @@ async function mustGetClient(id, dagRead) {
5772
5785
  return client;
5773
5786
  }
5774
5787
  function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVersion, enableClientGroupForking) {
5775
- return withWriteNoImplicitCommit(perdag, async (dagWrite) => {
5788
+ return withWrite(perdag, async (dagWrite) => {
5776
5789
  async function setClientsAndClientGroupAndCommit(basisHash, cookieJSON, valueHash2, indexRecords2) {
5777
5790
  const newSnapshotData = newSnapshotCommitDataDD31(
5778
5791
  basisHash,
@@ -5806,7 +5819,6 @@ function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVers
5806
5819
  setClients(newClients, dagWrite),
5807
5820
  setClientGroup(newClientGroupID, clientGroup, dagWrite)
5808
5821
  ]);
5809
- await dagWrite.commit();
5810
5822
  return [newClient, chunk.hash, newClients, true];
5811
5823
  }
5812
5824
  const clients = await getClients(dagWrite);
@@ -5821,7 +5833,6 @@ function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVers
5821
5833
  };
5822
5834
  const newClients = new Map(clients).set(newClientID, newClient);
5823
5835
  await setClients(newClients, dagWrite);
5824
- await dagWrite.commit();
5825
5836
  return [newClient, headHash, newClients, false];
5826
5837
  }
5827
5838
  if (!enableClientGroupForking || res.type === FIND_MATCHING_CLIENT_TYPE_NEW) {
@@ -6009,8 +6020,13 @@ function gcClients(clientID, dagStore, clientMaxInactiveTime, onClientsDeleted)
6009
6020
  return clients;
6010
6021
  }
6011
6022
  await setClients(newClients, dagWrite);
6012
- const normalized = await addDeletedClients(dagWrite, deletedClients);
6013
- onClientsDeleted(normalized);
6023
+ const { clientIDs, clientGroupIDs } = await addDeletedClients(
6024
+ dagWrite,
6025
+ deletedClients,
6026
+ // gcClients does not delete client groups
6027
+ []
6028
+ );
6029
+ onClientsDeleted(clientIDs, clientGroupIDs);
6014
6030
  return newClients;
6015
6031
  });
6016
6032
  }
@@ -6018,11 +6034,15 @@ function gcClients(clientID, dagStore, clientMaxInactiveTime, onClientsDeleted)
6018
6034
  // ../replicache/src/persist/client-group-gc.ts
6019
6035
  var GC_INTERVAL_MS = 5 * 60 * 1e3;
6020
6036
  var latestGCUpdate2;
6021
- function initClientGroupGC(dagStore, enableMutationRecovery, lc, signal) {
6037
+ function initClientGroupGC(dagStore, enableMutationRecovery, onClientsDeleted, lc, signal) {
6022
6038
  initBgIntervalProcess(
6023
6039
  "ClientGroupGC",
6024
6040
  () => {
6025
- latestGCUpdate2 = gcClientGroups(dagStore, enableMutationRecovery);
6041
+ latestGCUpdate2 = gcClientGroups(
6042
+ dagStore,
6043
+ enableMutationRecovery,
6044
+ onClientsDeleted
6045
+ );
6026
6046
  return latestGCUpdate2;
6027
6047
  },
6028
6048
  () => GC_INTERVAL_MS,
@@ -6030,7 +6050,7 @@ function initClientGroupGC(dagStore, enableMutationRecovery, lc, signal) {
6030
6050
  signal
6031
6051
  );
6032
6052
  }
6033
- function gcClientGroups(dagStore, enableMutationRecovery) {
6053
+ function gcClientGroups(dagStore, enableMutationRecovery, onClientsDeleted) {
6034
6054
  return withWrite(dagStore, async (tx) => {
6035
6055
  const clients = await getClients(tx);
6036
6056
  const clientGroupIDs = /* @__PURE__ */ new Set();
@@ -6038,12 +6058,16 @@ function gcClientGroups(dagStore, enableMutationRecovery) {
6038
6058
  clientGroupIDs.add(client.clientGroupID);
6039
6059
  }
6040
6060
  const clientGroups = /* @__PURE__ */ new Map();
6061
+ const removeClientGroups = /* @__PURE__ */ new Set();
6041
6062
  for (const [clientGroupID, clientGroup] of await getClientGroups(tx)) {
6042
6063
  if (clientGroupIDs.has(clientGroupID) || enableMutationRecovery && clientGroupHasPendingMutations(clientGroup)) {
6043
6064
  clientGroups.set(clientGroupID, clientGroup);
6065
+ } else {
6066
+ removeClientGroups.add(clientGroupID);
6044
6067
  }
6045
6068
  }
6046
6069
  await setClientGroups(clientGroups, tx);
6070
+ onClientsDeleted([], [...removeClientGroups].sort());
6047
6071
  return clientGroups;
6048
6072
  });
6049
6073
  }
@@ -7056,14 +7080,14 @@ function diffBinarySearch(diff2, prefix, compareKey) {
7056
7080
  }
7057
7081
 
7058
7082
  // ../shared/src/random-values.ts
7059
- function getNonCryptoRandomValues(array12) {
7060
- if (array12 === null) {
7083
+ function getNonCryptoRandomValues(array9) {
7084
+ if (array9 === null) {
7061
7085
  throw new TypeError("array cannot be null");
7062
7086
  }
7063
- for (let i = 0; i < array12.length; i++) {
7064
- array12[i] = Math.floor(Math.random() * 256);
7087
+ for (let i = 0; i < array9.length; i++) {
7088
+ array9[i] = Math.floor(Math.random() * 256);
7065
7089
  }
7066
- return array12;
7090
+ return array9;
7067
7091
  }
7068
7092
 
7069
7093
  // ../replicache/src/sync/request-id.ts
@@ -7424,7 +7448,13 @@ var ReplicacheImpl = class {
7424
7448
  this.#lc,
7425
7449
  signal
7426
7450
  );
7427
- initClientGroupGC(this.perdag, enableMutationRecovery, this.#lc, signal);
7451
+ initClientGroupGC(
7452
+ this.perdag,
7453
+ enableMutationRecovery,
7454
+ onClientsDeleted,
7455
+ this.#lc,
7456
+ signal
7457
+ );
7428
7458
  initNewClientChannel(
7429
7459
  this.name,
7430
7460
  this.idbName,
@@ -8288,10 +8318,15 @@ async function collectIDBDatabases(idbDatabasesStore, now, maxAge, kvDropStore,
8288
8318
  const dbNamesToRemove = [];
8289
8319
  const dbNamesToKeep = [];
8290
8320
  const clientIDsToRemove = [];
8291
- for (const [dbName, [canCollect, clientIDs]] of collectResults) {
8321
+ const clientGroupIDsToRemove = [];
8322
+ for (const [
8323
+ dbName,
8324
+ [canCollect, clientIDs, clientGroupIDs]
8325
+ ] of collectResults) {
8292
8326
  if (canCollect) {
8293
8327
  dbNamesToRemove.push(dbName);
8294
8328
  clientIDsToRemove.push(...clientIDs);
8329
+ clientGroupIDsToRemove.push(...clientGroupIDs);
8295
8330
  } else {
8296
8331
  dbNamesToKeep.push(dbName);
8297
8332
  }
@@ -8304,16 +8339,24 @@ async function collectIDBDatabases(idbDatabasesStore, now, maxAge, kvDropStore,
8304
8339
  if (errors.length) {
8305
8340
  throw errors[0];
8306
8341
  }
8307
- if (clientIDsToRemove.length) {
8308
- const toRemoveIncludingOld = clientIDsToRemove;
8342
+ if (clientIDsToRemove.length || clientGroupIDsToRemove.length) {
8343
+ const newClientIDsToRemove = clientIDsToRemove;
8344
+ const newClientGroupIDsToRemove = clientGroupIDsToRemove;
8309
8345
  for (const name of dbNamesToKeep) {
8310
8346
  await withWrite(newDagStore(name), async (dagWrite) => {
8311
- toRemoveIncludingOld.push(
8312
- ...await addDeletedClients(dagWrite, clientIDsToRemove)
8347
+ const { clientIDs, clientGroupIDs } = await addDeletedClients(
8348
+ dagWrite,
8349
+ clientIDsToRemove,
8350
+ clientGroupIDsToRemove
8313
8351
  );
8352
+ newClientIDsToRemove.push(...clientIDs);
8353
+ newClientGroupIDsToRemove.push(...clientGroupIDs);
8314
8354
  });
8315
8355
  }
8316
- onClientsDeleted(normalize(toRemoveIncludingOld));
8356
+ onClientsDeleted(
8357
+ normalize(newClientIDsToRemove),
8358
+ normalize(newClientGroupIDsToRemove)
8359
+ );
8317
8360
  }
8318
8361
  }
8319
8362
  async function dropDatabaseInternal(name, idbDatabasesStore, kvDropStore) {
@@ -8391,8 +8434,14 @@ function canDatabaseBeCollectedAndGetDeletedClientIDs(enableMutationRecovery, pe
8391
8434
  }
8392
8435
  }
8393
8436
  const clients = await getClients(read);
8394
- const oldDeletedClients = await getDeletedClients(read);
8395
- return [true, [...clients.keys(), ...oldDeletedClients]];
8437
+ const { clientIDs, clientGroupIDs } = await getDeletedClients(read);
8438
+ const newClientIDs = [...clientIDs];
8439
+ const newClientGroupIDs = [...clientGroupIDs];
8440
+ for (const [clientID, client] of clients) {
8441
+ newClientIDs.push(clientID);
8442
+ newClientGroupIDs.push(client.clientGroupID);
8443
+ }
8444
+ return [true, newClientIDs, newClientGroupIDs];
8396
8445
  });
8397
8446
  }
8398
8447
 
@@ -10926,8 +10975,8 @@ var negateOperatorMap = {
10926
10975
  function negateOperator(op) {
10927
10976
  return must(negateOperatorMap[op]);
10928
10977
  }
10929
- function filterUndefined(array12) {
10930
- return array12.filter((e) => e !== void 0);
10978
+ function filterUndefined(array9) {
10979
+ return array9.filter((e) => e !== void 0);
10931
10980
  }
10932
10981
  function filterTrue(conditions) {
10933
10982
  return conditions.filter((c) => !isAlwaysTrue(c));
@@ -11760,6 +11809,18 @@ function escapeLike(val) {
11760
11809
  import { LogContext as LogContext4 } from "@rocicorp/logger";
11761
11810
  import { resolver as resolver8 } from "@rocicorp/resolver";
11762
11811
 
11812
+ // ../zero-protocol/src/delete-clients.ts
11813
+ var deleteClientsBodySchema = valita_exports.union(
11814
+ readonlyObject({
11815
+ clientIDs: readonlyArray(valita_exports.string()).optional(),
11816
+ clientGroupIDs: readonlyArray(valita_exports.string()).optional()
11817
+ })
11818
+ );
11819
+ var deleteClientsMessageSchema = valita_exports.tuple([
11820
+ valita_exports.literal("deleteClients"),
11821
+ deleteClientsBodySchema
11822
+ ]);
11823
+
11763
11824
  // ../zero-protocol/src/queries-patch.ts
11764
11825
  var putOpSchema = valita_exports.object({
11765
11826
  op: valita_exports.literal("put"),
@@ -11787,7 +11848,7 @@ var connectedMessageSchema = valita_exports.tuple([
11787
11848
  ]);
11788
11849
  var initConnectionBodySchema = valita_exports.object({
11789
11850
  desiredQueriesPatch: queriesPatchSchema,
11790
- deletedClients: valita_exports.array(valita_exports.string()).optional()
11851
+ deleted: deleteClientsBodySchema.optional()
11791
11852
  });
11792
11853
  var initConnectionMessageSchema = valita_exports.tuple([
11793
11854
  valita_exports.literal("initConnection"),
@@ -11801,15 +11862,6 @@ function encodeSecProtocols(initConnectionMessage, authToken) {
11801
11862
  return encodeURIComponent(btoa(JSON.stringify(protocols)));
11802
11863
  }
11803
11864
 
11804
- // ../zero-protocol/src/delete-clients.ts
11805
- var deleteClientsBodySchema = valita_exports.object({
11806
- clientIDs: valita_exports.array(valita_exports.string())
11807
- });
11808
- var deleteClientsMessageSchema = valita_exports.tuple([
11809
- valita_exports.literal("deleteClients"),
11810
- deleteClientsBodySchema
11811
- ]);
11812
-
11813
11865
  // ../zero-protocol/src/error-kind-enum.ts
11814
11866
  var AuthInvalidated = "AuthInvalidated";
11815
11867
  var ClientNotFound = "ClientNotFound";
@@ -13697,33 +13749,37 @@ var DeleteClientsManager = class {
13697
13749
  * This gets called by Replicache when it deletes clients from the persistent
13698
13750
  * storage.
13699
13751
  */
13700
- onClientsDeleted(clientIDs) {
13752
+ onClientsDeleted(clientIDs, clientGroupIDs) {
13701
13753
  this.#lc.debug?.("DeletedClientsManager, send:", clientIDs);
13702
- this.#send(["deleteClients", { clientIDs }]);
13754
+ this.#send(["deleteClients", { clientIDs, clientGroupIDs }]);
13703
13755
  }
13704
13756
  /**
13705
13757
  * Zero calls this after it connects to ensure that the server knows about all
13706
13758
  * the clients that might have been deleted locally since the last connection.
13707
13759
  */
13708
13760
  async sendDeletedClientsToServer() {
13709
- const deletedClients = await withRead(
13761
+ const deleted = await withRead(
13710
13762
  this.#dagStore,
13711
13763
  (dagRead) => getDeletedClients(dagRead)
13712
13764
  );
13713
- if (deletedClients.length > 0) {
13714
- this.#send(["deleteClients", { clientIDs: deletedClients }]);
13715
- this.#lc.debug?.("DeletedClientsManager, send:", deletedClients);
13765
+ if (deleted.clientIDs.length > 0 || deleted.clientGroupIDs.length > 0) {
13766
+ this.#send(["deleteClients", deleted]);
13767
+ this.#lc.debug?.("DeletedClientsManager, send:", deleted);
13716
13768
  }
13717
13769
  }
13718
13770
  /**
13719
13771
  * This is called as a response to the server telling us which clients it
13720
13772
  * actually deleted.
13721
13773
  */
13722
- clientsDeletedOnServer(clientIDs) {
13723
- return withWrite(this.#dagStore, async (dagWrite) => {
13724
- this.#lc.debug?.("clientsDeletedOnServer:", clientIDs);
13725
- await removeDeletedClients(dagWrite, clientIDs);
13726
- });
13774
+ clientsDeletedOnServer(deletedClients) {
13775
+ const { clientIDs = [], clientGroupIDs = [] } = deletedClients;
13776
+ if (clientIDs.length > 0 || clientGroupIDs.length > 0) {
13777
+ return withWrite(this.#dagStore, async (dagWrite) => {
13778
+ this.#lc.debug?.("clientsDeletedOnServer:", clientIDs, clientGroupIDs);
13779
+ await removeDeletedClients(dagWrite, clientIDs, clientGroupIDs);
13780
+ });
13781
+ }
13782
+ return promiseVoid;
13727
13783
  }
13728
13784
  getDeletedClients() {
13729
13785
  return withRead(this.#dagStore, getDeletedClients);
@@ -13978,7 +14034,7 @@ function makeMessage(message, context, logLevel) {
13978
14034
  }
13979
14035
 
13980
14036
  // ../zero-client/src/client/version.ts
13981
- var version2 = "0.14.2025021100";
14037
+ var version2 = "0.14.2025021101";
13982
14038
 
13983
14039
  // ../zero-client/src/client/log-options.ts
13984
14040
  var LevelFilterLogSink = class {
@@ -14963,9 +15019,10 @@ var Zero = class {
14963
15019
  */
14964
15020
  #initConnectionQueries;
14965
15021
  /**
14966
- * We try to send the deleted clients as part of the sec-protocol header. If we can't
14967
- * because the header would get to long we keep track of the deleted clients and send
14968
- * them after the connection is established.
15022
+ * We try to send the deleted clients and (client groups) as part of the
15023
+ * sec-protocol header. If we can't because the header would get too large we
15024
+ * keep track of the deleted clients and send them after the connection is
15025
+ * established.
14969
15026
  */
14970
15027
  #deletedClients;
14971
15028
  #lastMutationIDSent = NULL_LAST_MUTATION_ID_SENT;
@@ -15104,7 +15161,7 @@ var Zero = class {
15104
15161
  const replicacheImplOptions = {
15105
15162
  enableClientGroupForking: false,
15106
15163
  enableMutationRecovery: false,
15107
- onClientsDeleted: (clientIDs) => this.#deleteClientsManager.onClientsDeleted(clientIDs)
15164
+ onClientsDeleted: (clientIDs, clientGroupIDs) => this.#deleteClientsManager.onClientsDeleted(clientIDs, clientGroupIDs)
15108
15165
  };
15109
15166
  const rep = new ReplicacheImpl(replicacheOptions, replicacheImplOptions);
15110
15167
  this.#rep = rep;
@@ -15369,7 +15426,7 @@ var Zero = class {
15369
15426
  break;
15370
15427
  case "deleteClients":
15371
15428
  return this.#deleteClientsManager.clientsDeletedOnServer(
15372
- downMessage[1].clientIDs
15429
+ downMessage[1]
15373
15430
  );
15374
15431
  default:
15375
15432
  msgType;
@@ -15477,11 +15534,10 @@ var Zero = class {
15477
15534
  const queriesPatch = await this.#rep.query(
15478
15535
  (tx) => this.#queryManager.getQueriesPatch(tx, this.#initConnectionQueries)
15479
15536
  );
15537
+ const hasDeletedClients = () => skipEmptyArray(this.#deletedClients?.clientIDs) || skipEmptyArray(this.#deletedClients?.clientGroupIDs);
15480
15538
  const maybeSendDeletedClients = () => {
15481
- if (this.#deletedClients) {
15482
- if (this.#deletedClients.length > 0) {
15483
- send(socket, ["deleteClients", { clientIDs: this.#deletedClients }]);
15484
- }
15539
+ if (hasDeletedClients()) {
15540
+ send(socket, ["deleteClients", this.#deletedClients]);
15485
15541
  this.#deletedClients = void 0;
15486
15542
  }
15487
15543
  };
@@ -15498,7 +15554,7 @@ var Zero = class {
15498
15554
  "initConnection",
15499
15555
  {
15500
15556
  desiredQueriesPatch: [...queriesPatch.values()],
15501
- deletedClients: this.#deletedClients && this.#deletedClients.length > 0 ? this.#deletedClients : void 0
15557
+ deleted: skipEmptyDeletedClients(this.#deletedClients)
15502
15558
  }
15503
15559
  ]);
15504
15560
  this.#deletedClients = void 0;
@@ -16071,7 +16127,7 @@ async function createSocket(rep, queryManager, deleteClientsManager, socketOrigi
16071
16127
  "initConnection",
16072
16128
  {
16073
16129
  desiredQueriesPatch: [...queriesPatch.values()],
16074
- deletedClients: deletedClients.length > 0 ? deletedClients : void 0
16130
+ deleted: skipEmptyDeletedClients(deletedClients)
16075
16131
  }
16076
16132
  ],
16077
16133
  auth
@@ -16089,9 +16145,25 @@ async function createSocket(rep, queryManager, deleteClientsManager, socketOrigi
16089
16145
  secProtocol
16090
16146
  ),
16091
16147
  queriesPatch,
16092
- deletedClients
16148
+ skipEmptyDeletedClients(deletedClients)
16093
16149
  ];
16094
16150
  }
16151
+ function skipEmptyArray(arr) {
16152
+ return arr && arr.length > 0 ? arr : void 0;
16153
+ }
16154
+ function skipEmptyDeletedClients(deletedClients) {
16155
+ if (!deletedClients) {
16156
+ return void 0;
16157
+ }
16158
+ const { clientIDs, clientGroupIDs } = deletedClients;
16159
+ if ((!clientIDs || clientIDs.length === 0) && (!clientGroupIDs || clientGroupIDs.length === 0)) {
16160
+ return void 0;
16161
+ }
16162
+ const data = {};
16163
+ data.clientIDs = skipEmptyArray(clientIDs);
16164
+ data.clientGroupIDs = skipEmptyArray(clientGroupIDs);
16165
+ return data;
16166
+ }
16095
16167
  function addWebSocketIDFromSocketToLogContext({ url }, lc) {
16096
16168
  const wsid = new URL(url).searchParams.get("wsid") ?? nanoid();
16097
16169
  return addWebSocketIDToLogContext(wsid, lc);
@@ -16134,4 +16206,4 @@ export {
16134
16206
  escapeLike,
16135
16207
  Zero
16136
16208
  };
16137
- //# sourceMappingURL=chunk-OPWNICE2.js.map
16209
+ //# sourceMappingURL=chunk-5GWP7BBD.js.map