houdini-svelte 2.1.17 → 2.1.19

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.
@@ -81310,20 +81310,21 @@ var CacheInternal = class {
81310
81310
  }
81311
81311
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
81312
81312
  let oldIDs = [...previousValue || []];
81313
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
81314
- if (!id) {
81315
- return "";
81316
- }
81317
- const { value: cursorField } = this.storage.get(id, "cursor");
81318
- if (cursorField) {
81319
- return "";
81320
- }
81321
- const { value: node } = this.storage.get(id, "node");
81322
- if (!node) {
81323
- return "";
81324
- }
81325
- return node;
81326
- });
81313
+ if (updates?.includes("append") || updates?.includes("prepend")) {
81314
+ oldIDs = oldIDs.filter((id) => {
81315
+ for (const layer2 of this.storage.data) {
81316
+ for (const operation of Object.values(layer2.operations)) {
81317
+ if (operation.fields?.[key])
81318
+ for (const listOperation of operation.fields[key]) {
81319
+ if ("id" in listOperation && listOperation.id === id) {
81320
+ return false;
81321
+ }
81322
+ }
81323
+ }
81324
+ }
81325
+ return true;
81326
+ });
81327
+ }
81327
81328
  let linkedIDs = [];
81328
81329
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
81329
81330
  value,
@@ -81342,39 +81343,45 @@ var CacheInternal = class {
81342
81343
  layer.writeLink(parent2, key, linkedIDs);
81343
81344
  };
81344
81345
  if (applyUpdates && updates) {
81345
- if (key === "edges") {
81346
- const newNodeIDs = [];
81347
- for (const id of newIDs) {
81346
+ const filterIDs = (keep, insert) => {
81347
+ const existingIDs = /* @__PURE__ */ new Set();
81348
+ for (const id of keep) {
81348
81349
  if (!id) {
81349
81350
  continue;
81350
81351
  }
81351
81352
  const { value: node } = this.storage.get(id, "node");
81352
- if (typeof node !== "string") {
81353
+ if (!node) {
81353
81354
  continue;
81354
81355
  }
81355
- if (!node || !this.storage.get(node, "__typename")) {
81356
+ const nodeID = this.storage.get(node, "id");
81357
+ if (!nodeID) {
81356
81358
  continue;
81357
81359
  }
81358
- newNodeIDs.push(node);
81360
+ existingIDs.add(nodeID.value);
81359
81361
  }
81360
- oldIDs = oldIDs.filter((id) => {
81362
+ return insert.filter((id) => {
81361
81363
  if (!id) {
81362
81364
  return true;
81363
81365
  }
81364
- const { value: value2 } = this.storage.get(id, "node");
81365
- const node = value2;
81366
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
81367
- return false;
81366
+ const { value: node } = this.storage.get(id, "node");
81367
+ if (!node) {
81368
+ return true;
81368
81369
  }
81369
- return true;
81370
+ const nodeID = this.storage.get(node, "id");
81371
+ if (!nodeID) {
81372
+ return true;
81373
+ }
81374
+ return !existingIDs.has(nodeID.value);
81370
81375
  });
81371
- }
81376
+ };
81372
81377
  for (const update of applyUpdates) {
81373
81378
  if (update !== "replace" && !updates.includes(update)) {
81374
81379
  continue;
81375
81380
  }
81376
81381
  if (update === "prepend") {
81377
- linkedIDs = newIDs.concat(oldIDs);
81382
+ linkedIDs = newIDs.concat(
81383
+ filterIDs(newIDs, oldIDs)
81384
+ );
81378
81385
  if (layer?.optimistic) {
81379
81386
  action = () => {
81380
81387
  for (const id of newIDs) {
@@ -81385,7 +81392,7 @@ var CacheInternal = class {
81385
81392
  };
81386
81393
  }
81387
81394
  } else if (update === "append") {
81388
- linkedIDs = oldIDs.concat(newIDs);
81395
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
81389
81396
  if (layer?.optimistic) {
81390
81397
  action = () => {
81391
81398
  for (const id of newIDs) {
@@ -142040,20 +142047,21 @@ var CacheInternal2 = class {
142040
142047
  }
142041
142048
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
142042
142049
  let oldIDs = [...previousValue || []];
142043
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
142044
- if (!id) {
142045
- return "";
142046
- }
142047
- const { value: cursorField } = this.storage.get(id, "cursor");
142048
- if (cursorField) {
142049
- return "";
142050
- }
142051
- const { value: node } = this.storage.get(id, "node");
142052
- if (!node) {
142053
- return "";
142054
- }
142055
- return node;
142056
- });
142050
+ if (updates?.includes("append") || updates?.includes("prepend")) {
142051
+ oldIDs = oldIDs.filter((id) => {
142052
+ for (const layer2 of this.storage.data) {
142053
+ for (const operation of Object.values(layer2.operations)) {
142054
+ if (operation.fields?.[key])
142055
+ for (const listOperation of operation.fields[key]) {
142056
+ if ("id" in listOperation && listOperation.id === id) {
142057
+ return false;
142058
+ }
142059
+ }
142060
+ }
142061
+ }
142062
+ return true;
142063
+ });
142064
+ }
142057
142065
  let linkedIDs = [];
142058
142066
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
142059
142067
  value,
@@ -142072,39 +142080,45 @@ var CacheInternal2 = class {
142072
142080
  layer.writeLink(parent2, key, linkedIDs);
142073
142081
  };
142074
142082
  if (applyUpdates && updates) {
142075
- if (key === "edges") {
142076
- const newNodeIDs = [];
142077
- for (const id of newIDs) {
142083
+ const filterIDs = (keep, insert) => {
142084
+ const existingIDs = /* @__PURE__ */ new Set();
142085
+ for (const id of keep) {
142078
142086
  if (!id) {
142079
142087
  continue;
142080
142088
  }
142081
142089
  const { value: node } = this.storage.get(id, "node");
142082
- if (typeof node !== "string") {
142090
+ if (!node) {
142083
142091
  continue;
142084
142092
  }
142085
- if (!node || !this.storage.get(node, "__typename")) {
142093
+ const nodeID = this.storage.get(node, "id");
142094
+ if (!nodeID) {
142086
142095
  continue;
142087
142096
  }
142088
- newNodeIDs.push(node);
142097
+ existingIDs.add(nodeID.value);
142089
142098
  }
142090
- oldIDs = oldIDs.filter((id) => {
142099
+ return insert.filter((id) => {
142091
142100
  if (!id) {
142092
142101
  return true;
142093
142102
  }
142094
- const { value: value2 } = this.storage.get(id, "node");
142095
- const node = value2;
142096
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
142097
- return false;
142103
+ const { value: node } = this.storage.get(id, "node");
142104
+ if (!node) {
142105
+ return true;
142098
142106
  }
142099
- return true;
142107
+ const nodeID = this.storage.get(node, "id");
142108
+ if (!nodeID) {
142109
+ return true;
142110
+ }
142111
+ return !existingIDs.has(nodeID.value);
142100
142112
  });
142101
- }
142113
+ };
142102
142114
  for (const update of applyUpdates) {
142103
142115
  if (update !== "replace" && !updates.includes(update)) {
142104
142116
  continue;
142105
142117
  }
142106
142118
  if (update === "prepend") {
142107
- linkedIDs = newIDs.concat(oldIDs);
142119
+ linkedIDs = newIDs.concat(
142120
+ filterIDs(newIDs, oldIDs)
142121
+ );
142108
142122
  if (layer?.optimistic) {
142109
142123
  action = () => {
142110
142124
  for (const id of newIDs) {
@@ -142115,7 +142129,7 @@ var CacheInternal2 = class {
142115
142129
  };
142116
142130
  }
142117
142131
  } else if (update === "append") {
142118
- linkedIDs = oldIDs.concat(newIDs);
142132
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
142119
142133
  if (layer?.optimistic) {
142120
142134
  action = () => {
142121
142135
  for (const id of newIDs) {
@@ -210170,20 +210184,21 @@ var CacheInternal3 = class {
210170
210184
  }
210171
210185
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
210172
210186
  let oldIDs = [...previousValue || []];
210173
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
210174
- if (!id) {
210175
- return "";
210176
- }
210177
- const { value: cursorField } = this.storage.get(id, "cursor");
210178
- if (cursorField) {
210179
- return "";
210180
- }
210181
- const { value: node } = this.storage.get(id, "node");
210182
- if (!node) {
210183
- return "";
210184
- }
210185
- return node;
210186
- });
210187
+ if (updates?.includes("append") || updates?.includes("prepend")) {
210188
+ oldIDs = oldIDs.filter((id) => {
210189
+ for (const layer2 of this.storage.data) {
210190
+ for (const operation of Object.values(layer2.operations)) {
210191
+ if (operation.fields?.[key])
210192
+ for (const listOperation of operation.fields[key]) {
210193
+ if ("id" in listOperation && listOperation.id === id) {
210194
+ return false;
210195
+ }
210196
+ }
210197
+ }
210198
+ }
210199
+ return true;
210200
+ });
210201
+ }
210187
210202
  let linkedIDs = [];
210188
210203
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
210189
210204
  value,
@@ -210202,39 +210217,45 @@ var CacheInternal3 = class {
210202
210217
  layer.writeLink(parent2, key, linkedIDs);
210203
210218
  };
210204
210219
  if (applyUpdates && updates) {
210205
- if (key === "edges") {
210206
- const newNodeIDs = [];
210207
- for (const id of newIDs) {
210220
+ const filterIDs = (keep, insert) => {
210221
+ const existingIDs = /* @__PURE__ */ new Set();
210222
+ for (const id of keep) {
210208
210223
  if (!id) {
210209
210224
  continue;
210210
210225
  }
210211
210226
  const { value: node } = this.storage.get(id, "node");
210212
- if (typeof node !== "string") {
210227
+ if (!node) {
210213
210228
  continue;
210214
210229
  }
210215
- if (!node || !this.storage.get(node, "__typename")) {
210230
+ const nodeID = this.storage.get(node, "id");
210231
+ if (!nodeID) {
210216
210232
  continue;
210217
210233
  }
210218
- newNodeIDs.push(node);
210234
+ existingIDs.add(nodeID.value);
210219
210235
  }
210220
- oldIDs = oldIDs.filter((id) => {
210236
+ return insert.filter((id) => {
210221
210237
  if (!id) {
210222
210238
  return true;
210223
210239
  }
210224
- const { value: value2 } = this.storage.get(id, "node");
210225
- const node = value2;
210226
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
210227
- return false;
210240
+ const { value: node } = this.storage.get(id, "node");
210241
+ if (!node) {
210242
+ return true;
210228
210243
  }
210229
- return true;
210244
+ const nodeID = this.storage.get(node, "id");
210245
+ if (!nodeID) {
210246
+ return true;
210247
+ }
210248
+ return !existingIDs.has(nodeID.value);
210230
210249
  });
210231
- }
210250
+ };
210232
210251
  for (const update of applyUpdates) {
210233
210252
  if (update !== "replace" && !updates.includes(update)) {
210234
210253
  continue;
210235
210254
  }
210236
210255
  if (update === "prepend") {
210237
- linkedIDs = newIDs.concat(oldIDs);
210256
+ linkedIDs = newIDs.concat(
210257
+ filterIDs(newIDs, oldIDs)
210258
+ );
210238
210259
  if (layer?.optimistic) {
210239
210260
  action = () => {
210240
210261
  for (const id of newIDs) {
@@ -210245,7 +210266,7 @@ var CacheInternal3 = class {
210245
210266
  };
210246
210267
  }
210247
210268
  } else if (update === "append") {
210248
- linkedIDs = oldIDs.concat(newIDs);
210269
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
210249
210270
  if (layer?.optimistic) {
210250
210271
  action = () => {
210251
210272
  for (const id of newIDs) {
@@ -280356,20 +280377,21 @@ var CacheInternal4 = class {
280356
280377
  }
280357
280378
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
280358
280379
  let oldIDs = [...previousValue || []];
280359
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
280360
- if (!id) {
280361
- return "";
280362
- }
280363
- const { value: cursorField } = this.storage.get(id, "cursor");
280364
- if (cursorField) {
280365
- return "";
280366
- }
280367
- const { value: node } = this.storage.get(id, "node");
280368
- if (!node) {
280369
- return "";
280370
- }
280371
- return node;
280372
- });
280380
+ if (updates?.includes("append") || updates?.includes("prepend")) {
280381
+ oldIDs = oldIDs.filter((id) => {
280382
+ for (const layer2 of this.storage.data) {
280383
+ for (const operation of Object.values(layer2.operations)) {
280384
+ if (operation.fields?.[key])
280385
+ for (const listOperation of operation.fields[key]) {
280386
+ if ("id" in listOperation && listOperation.id === id) {
280387
+ return false;
280388
+ }
280389
+ }
280390
+ }
280391
+ }
280392
+ return true;
280393
+ });
280394
+ }
280373
280395
  let linkedIDs = [];
280374
280396
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
280375
280397
  value,
@@ -280388,39 +280410,45 @@ var CacheInternal4 = class {
280388
280410
  layer.writeLink(parent2, key, linkedIDs);
280389
280411
  };
280390
280412
  if (applyUpdates && updates) {
280391
- if (key === "edges") {
280392
- const newNodeIDs = [];
280393
- for (const id of newIDs) {
280413
+ const filterIDs = (keep, insert) => {
280414
+ const existingIDs = /* @__PURE__ */ new Set();
280415
+ for (const id of keep) {
280394
280416
  if (!id) {
280395
280417
  continue;
280396
280418
  }
280397
280419
  const { value: node } = this.storage.get(id, "node");
280398
- if (typeof node !== "string") {
280420
+ if (!node) {
280399
280421
  continue;
280400
280422
  }
280401
- if (!node || !this.storage.get(node, "__typename")) {
280423
+ const nodeID = this.storage.get(node, "id");
280424
+ if (!nodeID) {
280402
280425
  continue;
280403
280426
  }
280404
- newNodeIDs.push(node);
280427
+ existingIDs.add(nodeID.value);
280405
280428
  }
280406
- oldIDs = oldIDs.filter((id) => {
280429
+ return insert.filter((id) => {
280407
280430
  if (!id) {
280408
280431
  return true;
280409
280432
  }
280410
- const { value: value2 } = this.storage.get(id, "node");
280411
- const node = value2;
280412
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
280413
- return false;
280433
+ const { value: node } = this.storage.get(id, "node");
280434
+ if (!node) {
280435
+ return true;
280414
280436
  }
280415
- return true;
280437
+ const nodeID = this.storage.get(node, "id");
280438
+ if (!nodeID) {
280439
+ return true;
280440
+ }
280441
+ return !existingIDs.has(nodeID.value);
280416
280442
  });
280417
- }
280443
+ };
280418
280444
  for (const update of applyUpdates) {
280419
280445
  if (update !== "replace" && !updates.includes(update)) {
280420
280446
  continue;
280421
280447
  }
280422
280448
  if (update === "prepend") {
280423
- linkedIDs = newIDs.concat(oldIDs);
280449
+ linkedIDs = newIDs.concat(
280450
+ filterIDs(newIDs, oldIDs)
280451
+ );
280424
280452
  if (layer?.optimistic) {
280425
280453
  action = () => {
280426
280454
  for (const id of newIDs) {
@@ -280431,7 +280459,7 @@ var CacheInternal4 = class {
280431
280459
  };
280432
280460
  }
280433
280461
  } else if (update === "append") {
280434
- linkedIDs = oldIDs.concat(newIDs);
280462
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
280435
280463
  if (layer?.optimistic) {
280436
280464
  action = () => {
280437
280465
  for (const id of newIDs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "2.1.17",
3
+ "version": "2.1.19",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -30,7 +30,7 @@
30
30
  "graphql": "^15.8.0",
31
31
  "recast": "^0.23.1",
32
32
  "rollup": "^4.28.1",
33
- "houdini": "^1.5.7"
33
+ "houdini": "^1.5.9"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@sveltejs/kit": "<=2.21.0",