houdini 1.2.2 → 1.2.3
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.
- package/build/cmd-cjs/index.js +106 -48
- package/build/cmd-esm/index.js +106 -48
- package/build/codegen-cjs/index.js +104 -46
- package/build/codegen-esm/index.js +104 -46
- package/build/lib-cjs/index.js +103 -45
- package/build/lib-esm/index.js +103 -45
- package/build/runtime/cache/cache.d.ts +3 -1
- package/build/runtime/cache/lists.d.ts +3 -3
- package/build/runtime/cache/storage.d.ts +2 -2
- package/build/runtime/cache/subscription.d.ts +1 -0
- package/build/runtime-cjs/cache/cache.d.ts +3 -1
- package/build/runtime-cjs/cache/cache.js +78 -27
- package/build/runtime-cjs/cache/lists.d.ts +3 -3
- package/build/runtime-cjs/cache/lists.js +7 -7
- package/build/runtime-cjs/cache/storage.d.ts +2 -2
- package/build/runtime-cjs/cache/storage.js +5 -5
- package/build/runtime-cjs/cache/subscription.d.ts +1 -0
- package/build/runtime-cjs/cache/subscription.js +3 -0
- package/build/runtime-cjs/client/plugins/mutation.js +10 -6
- package/build/runtime-esm/cache/cache.d.ts +3 -1
- package/build/runtime-esm/cache/cache.js +78 -27
- package/build/runtime-esm/cache/lists.d.ts +3 -3
- package/build/runtime-esm/cache/lists.js +7 -7
- package/build/runtime-esm/cache/storage.d.ts +2 -2
- package/build/runtime-esm/cache/storage.js +5 -5
- package/build/runtime-esm/cache/subscription.d.ts +1 -0
- package/build/runtime-esm/cache/subscription.js +3 -0
- package/build/runtime-esm/client/plugins/mutation.js +10 -6
- package/build/test-cjs/index.js +104 -46
- package/build/test-esm/index.js +104 -46
- package/build/vite-cjs/index.js +104 -46
- package/build/vite-esm/index.js +104 -46
- package/package.json +1 -1
package/build/cmd-cjs/index.js
CHANGED
|
@@ -70293,10 +70293,10 @@ var ListManager = class {
|
|
|
70293
70293
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
70294
70294
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
70295
70295
|
}
|
|
70296
|
-
removeIDFromAllLists(id) {
|
|
70296
|
+
removeIDFromAllLists(id, layer) {
|
|
70297
70297
|
for (const fieldMap of this.lists.values()) {
|
|
70298
70298
|
for (const list of fieldMap.values()) {
|
|
70299
|
-
list.removeID(id);
|
|
70299
|
+
list.removeID(id, void 0, layer);
|
|
70300
70300
|
}
|
|
70301
70301
|
}
|
|
70302
70302
|
}
|
|
@@ -70453,7 +70453,7 @@ var List = class {
|
|
|
70453
70453
|
layer: layer?.id
|
|
70454
70454
|
});
|
|
70455
70455
|
}
|
|
70456
|
-
removeID(id, variables = {}) {
|
|
70456
|
+
removeID(id, variables = {}, layer) {
|
|
70457
70457
|
if (!this.validateWhen()) {
|
|
70458
70458
|
return;
|
|
70459
70459
|
}
|
|
@@ -70500,7 +70500,7 @@ var List = class {
|
|
|
70500
70500
|
subscribers.map((sub) => sub[0]),
|
|
70501
70501
|
variables
|
|
70502
70502
|
);
|
|
70503
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
70503
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
70504
70504
|
for (const [spec] of subscribers) {
|
|
70505
70505
|
spec.set(
|
|
70506
70506
|
this.cache._internal_unstable.getSelection({
|
|
@@ -70513,12 +70513,12 @@ var List = class {
|
|
|
70513
70513
|
}
|
|
70514
70514
|
return true;
|
|
70515
70515
|
}
|
|
70516
|
-
remove(data, variables = {}) {
|
|
70516
|
+
remove(data, variables = {}, layer) {
|
|
70517
70517
|
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
70518
70518
|
if (!targetID) {
|
|
70519
70519
|
return;
|
|
70520
70520
|
}
|
|
70521
|
-
return this.removeID(targetID, variables);
|
|
70521
|
+
return this.removeID(targetID, variables, layer);
|
|
70522
70522
|
}
|
|
70523
70523
|
listType(data) {
|
|
70524
70524
|
return data.__typename || this.type;
|
|
@@ -70550,7 +70550,7 @@ var List = class {
|
|
|
70550
70550
|
layer,
|
|
70551
70551
|
where
|
|
70552
70552
|
}) {
|
|
70553
|
-
if (!this.remove(data, variables)) {
|
|
70553
|
+
if (!this.remove(data, variables, layer)) {
|
|
70554
70554
|
this.addToList(selection, data, variables, where, layer);
|
|
70555
70555
|
}
|
|
70556
70556
|
}
|
|
@@ -70687,7 +70687,7 @@ var StaleManager = class {
|
|
|
70687
70687
|
// src/runtime/cache/storage.ts
|
|
70688
70688
|
var InMemoryStorage = class {
|
|
70689
70689
|
data;
|
|
70690
|
-
idCount =
|
|
70690
|
+
idCount = 1;
|
|
70691
70691
|
rank = 0;
|
|
70692
70692
|
constructor() {
|
|
70693
70693
|
this.data = [];
|
|
@@ -70707,11 +70707,11 @@ var InMemoryStorage = class {
|
|
|
70707
70707
|
insert(id, field, location, target) {
|
|
70708
70708
|
return this.topLayer.insert(id, field, location, target);
|
|
70709
70709
|
}
|
|
70710
|
-
remove(id, field, target) {
|
|
70711
|
-
return
|
|
70710
|
+
remove(id, field, target, layerToUser = this.topLayer) {
|
|
70711
|
+
return layerToUser.remove(id, field, target);
|
|
70712
70712
|
}
|
|
70713
|
-
delete(id) {
|
|
70714
|
-
return
|
|
70713
|
+
delete(id, layerToUser = this.topLayer) {
|
|
70714
|
+
return layerToUser.delete(id);
|
|
70715
70715
|
}
|
|
70716
70716
|
deleteField(id, field) {
|
|
70717
70717
|
return this.topLayer.deleteField(id, field);
|
|
@@ -71083,6 +71083,9 @@ var InMemorySubscriptions = class {
|
|
|
71083
71083
|
subscribers = {};
|
|
71084
71084
|
referenceCounts = {};
|
|
71085
71085
|
keyVersions = {};
|
|
71086
|
+
activeFields(parent2) {
|
|
71087
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
71088
|
+
}
|
|
71086
71089
|
add({
|
|
71087
71090
|
parent: parent2,
|
|
71088
71091
|
spec,
|
|
@@ -71351,20 +71354,7 @@ var Cache = class {
|
|
|
71351
71354
|
}) {
|
|
71352
71355
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
71353
71356
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
71354
|
-
|
|
71355
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
71356
|
-
if (!notified.includes(spec.set)) {
|
|
71357
|
-
notified.push(spec.set);
|
|
71358
|
-
spec.set(
|
|
71359
|
-
this._internal_unstable.getSelection({
|
|
71360
|
-
parent: spec.parentID || rootID,
|
|
71361
|
-
selection: spec.selection,
|
|
71362
|
-
variables: spec.variables?.() || {},
|
|
71363
|
-
ignoreMasking: false
|
|
71364
|
-
}).data
|
|
71365
|
-
);
|
|
71366
|
-
}
|
|
71367
|
-
}
|
|
71357
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
71368
71358
|
return subscribers;
|
|
71369
71359
|
}
|
|
71370
71360
|
read(...args) {
|
|
@@ -71403,10 +71393,10 @@ var Cache = class {
|
|
|
71403
71393
|
}
|
|
71404
71394
|
return handler;
|
|
71405
71395
|
}
|
|
71406
|
-
delete(id) {
|
|
71396
|
+
delete(id, layer) {
|
|
71407
71397
|
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
71408
|
-
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
71409
|
-
this._internal_unstable.storage.delete(id);
|
|
71398
|
+
this._internal_unstable.lists.removeIDFromAllLists(id, layer);
|
|
71399
|
+
this._internal_unstable.storage.delete(id, layer);
|
|
71410
71400
|
}
|
|
71411
71401
|
setConfig(config2) {
|
|
71412
71402
|
this._internal_unstable.setConfig(config2);
|
|
@@ -71438,6 +71428,70 @@ var Cache = class {
|
|
|
71438
71428
|
config() {
|
|
71439
71429
|
return this._internal_unstable.config;
|
|
71440
71430
|
}
|
|
71431
|
+
clearLayer(layerID) {
|
|
71432
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
71433
|
+
if (!layer) {
|
|
71434
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
71435
|
+
}
|
|
71436
|
+
const toNotify = [];
|
|
71437
|
+
const allFields = [];
|
|
71438
|
+
for (const target of [layer.fields, layer.links]) {
|
|
71439
|
+
for (const [id, fields] of Object.entries(target)) {
|
|
71440
|
+
allFields.push(
|
|
71441
|
+
...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
|
|
71442
|
+
);
|
|
71443
|
+
}
|
|
71444
|
+
}
|
|
71445
|
+
const displayFields = [];
|
|
71446
|
+
for (const pair of allFields) {
|
|
71447
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
71448
|
+
if (!displayLayers.includes(layerID)) {
|
|
71449
|
+
continue;
|
|
71450
|
+
}
|
|
71451
|
+
displayFields.push(pair);
|
|
71452
|
+
}
|
|
71453
|
+
for (const [id, operation] of Object.entries(layer.operations)) {
|
|
71454
|
+
if (operation.deleted) {
|
|
71455
|
+
displayFields.push(
|
|
71456
|
+
...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
|
|
71457
|
+
);
|
|
71458
|
+
}
|
|
71459
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
71460
|
+
if (fields.length > 0) {
|
|
71461
|
+
displayFields.push(...fields.map((field) => ({ id, field })));
|
|
71462
|
+
}
|
|
71463
|
+
}
|
|
71464
|
+
layer.clear();
|
|
71465
|
+
for (const display of displayFields) {
|
|
71466
|
+
const { field, id } = display;
|
|
71467
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
|
|
71468
|
+
if (notify) {
|
|
71469
|
+
toNotify.push(
|
|
71470
|
+
...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
|
|
71471
|
+
);
|
|
71472
|
+
}
|
|
71473
|
+
}
|
|
71474
|
+
this.#notifySubscribers(toNotify);
|
|
71475
|
+
}
|
|
71476
|
+
#notifySubscribers(subs) {
|
|
71477
|
+
if (subs.length === 0) {
|
|
71478
|
+
return;
|
|
71479
|
+
}
|
|
71480
|
+
const notified = [];
|
|
71481
|
+
for (const spec of subs) {
|
|
71482
|
+
if (!notified.includes(spec.set)) {
|
|
71483
|
+
notified.push(spec.set);
|
|
71484
|
+
spec.set(
|
|
71485
|
+
this._internal_unstable.getSelection({
|
|
71486
|
+
parent: spec.parentID || rootID,
|
|
71487
|
+
selection: spec.selection,
|
|
71488
|
+
variables: spec.variables?.() || {},
|
|
71489
|
+
ignoreMasking: false
|
|
71490
|
+
}).data
|
|
71491
|
+
);
|
|
71492
|
+
}
|
|
71493
|
+
}
|
|
71494
|
+
}
|
|
71441
71495
|
};
|
|
71442
71496
|
var CacheInternal = class {
|
|
71443
71497
|
_disabled = false;
|
|
@@ -71725,8 +71779,16 @@ var CacheInternal = class {
|
|
|
71725
71779
|
operation.position || "last",
|
|
71726
71780
|
layer
|
|
71727
71781
|
);
|
|
71782
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
71783
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
71784
|
+
selection: fieldSelection,
|
|
71785
|
+
data: target,
|
|
71786
|
+
variables,
|
|
71787
|
+
where: operation.position || "last",
|
|
71788
|
+
layer
|
|
71789
|
+
});
|
|
71728
71790
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
71729
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
71791
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
71730
71792
|
} else if (operation.action === "delete" && operation.type) {
|
|
71731
71793
|
if (typeof target !== "string") {
|
|
71732
71794
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -71735,15 +71797,7 @@ var CacheInternal = class {
|
|
|
71735
71797
|
if (!targetID) {
|
|
71736
71798
|
continue;
|
|
71737
71799
|
}
|
|
71738
|
-
this.cache.delete(targetID);
|
|
71739
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
71740
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
71741
|
-
selection: fieldSelection,
|
|
71742
|
-
data: target,
|
|
71743
|
-
variables,
|
|
71744
|
-
where: operation.position || "last",
|
|
71745
|
-
layer
|
|
71746
|
-
});
|
|
71800
|
+
this.cache.delete(targetID, layer);
|
|
71747
71801
|
}
|
|
71748
71802
|
}
|
|
71749
71803
|
}
|
|
@@ -72278,7 +72332,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
72278
72332
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
72279
72333
|
return {
|
|
72280
72334
|
async start(ctx, { next, marshalVariables }) {
|
|
72281
|
-
const
|
|
72335
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
72282
72336
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
72283
72337
|
let toNotify = [];
|
|
72284
72338
|
if (optimisticResponse) {
|
|
@@ -72289,25 +72343,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
72289
72343
|
data: optimisticResponse
|
|
72290
72344
|
}),
|
|
72291
72345
|
variables: marshalVariables(ctx),
|
|
72292
|
-
layer:
|
|
72346
|
+
layer: layerOptimistic.id
|
|
72293
72347
|
});
|
|
72294
72348
|
}
|
|
72295
72349
|
ctx.cacheParams = {
|
|
72296
72350
|
...ctx.cacheParams,
|
|
72297
|
-
layer,
|
|
72351
|
+
layer: layerOptimistic,
|
|
72298
72352
|
notifySubscribers: toNotify,
|
|
72299
72353
|
forceNotify: true
|
|
72300
72354
|
};
|
|
72301
72355
|
next(ctx);
|
|
72302
72356
|
},
|
|
72303
72357
|
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
72304
|
-
ctx.cacheParams?.layer
|
|
72358
|
+
if (ctx.cacheParams?.layer) {
|
|
72359
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
72360
|
+
}
|
|
72305
72361
|
resolve2(ctx);
|
|
72306
72362
|
},
|
|
72307
72363
|
end(ctx, { resolve: resolve2, value }) {
|
|
72308
72364
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
72309
72365
|
if (hasErrors) {
|
|
72310
|
-
ctx.cacheParams?.layer
|
|
72366
|
+
if (ctx.cacheParams?.layer) {
|
|
72367
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
72368
|
+
}
|
|
72311
72369
|
}
|
|
72312
72370
|
if (ctx.cacheParams?.layer) {
|
|
72313
72371
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -72317,7 +72375,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
72317
72375
|
catch(ctx, { error }) {
|
|
72318
72376
|
if (ctx.cacheParams?.layer) {
|
|
72319
72377
|
const { layer } = ctx.cacheParams;
|
|
72320
|
-
layer.
|
|
72378
|
+
cache_default.clearLayer(layer.id);
|
|
72321
72379
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
72322
72380
|
}
|
|
72323
72381
|
throw error;
|
|
@@ -74799,7 +74857,7 @@ function operationObject({
|
|
|
74799
74857
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
74800
74858
|
operation.position = position;
|
|
74801
74859
|
}
|
|
74802
|
-
if (operationKind
|
|
74860
|
+
if (allLists && operationKind !== "delete") {
|
|
74803
74861
|
operation.target = "all";
|
|
74804
74862
|
}
|
|
74805
74863
|
if (parentID) {
|
|
@@ -80054,8 +80112,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
80054
80112
|
}
|
|
80055
80113
|
packageJSON.devDependencies = {
|
|
80056
80114
|
...packageJSON.devDependencies,
|
|
80057
|
-
houdini: "^1.2.
|
|
80058
|
-
"houdini-svelte": "^1.2.
|
|
80115
|
+
houdini: "^1.2.3",
|
|
80116
|
+
"houdini-svelte": "^1.2.3"
|
|
80059
80117
|
};
|
|
80060
80118
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
80061
80119
|
}
|
package/build/cmd-esm/index.js
CHANGED
|
@@ -70299,10 +70299,10 @@ var ListManager = class {
|
|
|
70299
70299
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
70300
70300
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
70301
70301
|
}
|
|
70302
|
-
removeIDFromAllLists(id) {
|
|
70302
|
+
removeIDFromAllLists(id, layer) {
|
|
70303
70303
|
for (const fieldMap of this.lists.values()) {
|
|
70304
70304
|
for (const list of fieldMap.values()) {
|
|
70305
|
-
list.removeID(id);
|
|
70305
|
+
list.removeID(id, void 0, layer);
|
|
70306
70306
|
}
|
|
70307
70307
|
}
|
|
70308
70308
|
}
|
|
@@ -70459,7 +70459,7 @@ var List = class {
|
|
|
70459
70459
|
layer: layer?.id
|
|
70460
70460
|
});
|
|
70461
70461
|
}
|
|
70462
|
-
removeID(id, variables = {}) {
|
|
70462
|
+
removeID(id, variables = {}, layer) {
|
|
70463
70463
|
if (!this.validateWhen()) {
|
|
70464
70464
|
return;
|
|
70465
70465
|
}
|
|
@@ -70506,7 +70506,7 @@ var List = class {
|
|
|
70506
70506
|
subscribers.map((sub) => sub[0]),
|
|
70507
70507
|
variables
|
|
70508
70508
|
);
|
|
70509
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
70509
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
70510
70510
|
for (const [spec] of subscribers) {
|
|
70511
70511
|
spec.set(
|
|
70512
70512
|
this.cache._internal_unstable.getSelection({
|
|
@@ -70519,12 +70519,12 @@ var List = class {
|
|
|
70519
70519
|
}
|
|
70520
70520
|
return true;
|
|
70521
70521
|
}
|
|
70522
|
-
remove(data, variables = {}) {
|
|
70522
|
+
remove(data, variables = {}, layer) {
|
|
70523
70523
|
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
70524
70524
|
if (!targetID) {
|
|
70525
70525
|
return;
|
|
70526
70526
|
}
|
|
70527
|
-
return this.removeID(targetID, variables);
|
|
70527
|
+
return this.removeID(targetID, variables, layer);
|
|
70528
70528
|
}
|
|
70529
70529
|
listType(data) {
|
|
70530
70530
|
return data.__typename || this.type;
|
|
@@ -70556,7 +70556,7 @@ var List = class {
|
|
|
70556
70556
|
layer,
|
|
70557
70557
|
where
|
|
70558
70558
|
}) {
|
|
70559
|
-
if (!this.remove(data, variables)) {
|
|
70559
|
+
if (!this.remove(data, variables, layer)) {
|
|
70560
70560
|
this.addToList(selection, data, variables, where, layer);
|
|
70561
70561
|
}
|
|
70562
70562
|
}
|
|
@@ -70693,7 +70693,7 @@ var StaleManager = class {
|
|
|
70693
70693
|
// src/runtime/cache/storage.ts
|
|
70694
70694
|
var InMemoryStorage = class {
|
|
70695
70695
|
data;
|
|
70696
|
-
idCount =
|
|
70696
|
+
idCount = 1;
|
|
70697
70697
|
rank = 0;
|
|
70698
70698
|
constructor() {
|
|
70699
70699
|
this.data = [];
|
|
@@ -70713,11 +70713,11 @@ var InMemoryStorage = class {
|
|
|
70713
70713
|
insert(id, field, location, target) {
|
|
70714
70714
|
return this.topLayer.insert(id, field, location, target);
|
|
70715
70715
|
}
|
|
70716
|
-
remove(id, field, target) {
|
|
70717
|
-
return
|
|
70716
|
+
remove(id, field, target, layerToUser = this.topLayer) {
|
|
70717
|
+
return layerToUser.remove(id, field, target);
|
|
70718
70718
|
}
|
|
70719
|
-
delete(id) {
|
|
70720
|
-
return
|
|
70719
|
+
delete(id, layerToUser = this.topLayer) {
|
|
70720
|
+
return layerToUser.delete(id);
|
|
70721
70721
|
}
|
|
70722
70722
|
deleteField(id, field) {
|
|
70723
70723
|
return this.topLayer.deleteField(id, field);
|
|
@@ -71089,6 +71089,9 @@ var InMemorySubscriptions = class {
|
|
|
71089
71089
|
subscribers = {};
|
|
71090
71090
|
referenceCounts = {};
|
|
71091
71091
|
keyVersions = {};
|
|
71092
|
+
activeFields(parent2) {
|
|
71093
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
71094
|
+
}
|
|
71092
71095
|
add({
|
|
71093
71096
|
parent: parent2,
|
|
71094
71097
|
spec,
|
|
@@ -71357,20 +71360,7 @@ var Cache = class {
|
|
|
71357
71360
|
}) {
|
|
71358
71361
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
71359
71362
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
71360
|
-
|
|
71361
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
71362
|
-
if (!notified.includes(spec.set)) {
|
|
71363
|
-
notified.push(spec.set);
|
|
71364
|
-
spec.set(
|
|
71365
|
-
this._internal_unstable.getSelection({
|
|
71366
|
-
parent: spec.parentID || rootID,
|
|
71367
|
-
selection: spec.selection,
|
|
71368
|
-
variables: spec.variables?.() || {},
|
|
71369
|
-
ignoreMasking: false
|
|
71370
|
-
}).data
|
|
71371
|
-
);
|
|
71372
|
-
}
|
|
71373
|
-
}
|
|
71363
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
71374
71364
|
return subscribers;
|
|
71375
71365
|
}
|
|
71376
71366
|
read(...args) {
|
|
@@ -71409,10 +71399,10 @@ var Cache = class {
|
|
|
71409
71399
|
}
|
|
71410
71400
|
return handler;
|
|
71411
71401
|
}
|
|
71412
|
-
delete(id) {
|
|
71402
|
+
delete(id, layer) {
|
|
71413
71403
|
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
71414
|
-
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
71415
|
-
this._internal_unstable.storage.delete(id);
|
|
71404
|
+
this._internal_unstable.lists.removeIDFromAllLists(id, layer);
|
|
71405
|
+
this._internal_unstable.storage.delete(id, layer);
|
|
71416
71406
|
}
|
|
71417
71407
|
setConfig(config2) {
|
|
71418
71408
|
this._internal_unstable.setConfig(config2);
|
|
@@ -71444,6 +71434,70 @@ var Cache = class {
|
|
|
71444
71434
|
config() {
|
|
71445
71435
|
return this._internal_unstable.config;
|
|
71446
71436
|
}
|
|
71437
|
+
clearLayer(layerID) {
|
|
71438
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
71439
|
+
if (!layer) {
|
|
71440
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
71441
|
+
}
|
|
71442
|
+
const toNotify = [];
|
|
71443
|
+
const allFields = [];
|
|
71444
|
+
for (const target of [layer.fields, layer.links]) {
|
|
71445
|
+
for (const [id, fields] of Object.entries(target)) {
|
|
71446
|
+
allFields.push(
|
|
71447
|
+
...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
|
|
71448
|
+
);
|
|
71449
|
+
}
|
|
71450
|
+
}
|
|
71451
|
+
const displayFields = [];
|
|
71452
|
+
for (const pair of allFields) {
|
|
71453
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
71454
|
+
if (!displayLayers.includes(layerID)) {
|
|
71455
|
+
continue;
|
|
71456
|
+
}
|
|
71457
|
+
displayFields.push(pair);
|
|
71458
|
+
}
|
|
71459
|
+
for (const [id, operation] of Object.entries(layer.operations)) {
|
|
71460
|
+
if (operation.deleted) {
|
|
71461
|
+
displayFields.push(
|
|
71462
|
+
...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
|
|
71463
|
+
);
|
|
71464
|
+
}
|
|
71465
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
71466
|
+
if (fields.length > 0) {
|
|
71467
|
+
displayFields.push(...fields.map((field) => ({ id, field })));
|
|
71468
|
+
}
|
|
71469
|
+
}
|
|
71470
|
+
layer.clear();
|
|
71471
|
+
for (const display of displayFields) {
|
|
71472
|
+
const { field, id } = display;
|
|
71473
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
|
|
71474
|
+
if (notify) {
|
|
71475
|
+
toNotify.push(
|
|
71476
|
+
...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
|
|
71477
|
+
);
|
|
71478
|
+
}
|
|
71479
|
+
}
|
|
71480
|
+
this.#notifySubscribers(toNotify);
|
|
71481
|
+
}
|
|
71482
|
+
#notifySubscribers(subs) {
|
|
71483
|
+
if (subs.length === 0) {
|
|
71484
|
+
return;
|
|
71485
|
+
}
|
|
71486
|
+
const notified = [];
|
|
71487
|
+
for (const spec of subs) {
|
|
71488
|
+
if (!notified.includes(spec.set)) {
|
|
71489
|
+
notified.push(spec.set);
|
|
71490
|
+
spec.set(
|
|
71491
|
+
this._internal_unstable.getSelection({
|
|
71492
|
+
parent: spec.parentID || rootID,
|
|
71493
|
+
selection: spec.selection,
|
|
71494
|
+
variables: spec.variables?.() || {},
|
|
71495
|
+
ignoreMasking: false
|
|
71496
|
+
}).data
|
|
71497
|
+
);
|
|
71498
|
+
}
|
|
71499
|
+
}
|
|
71500
|
+
}
|
|
71447
71501
|
};
|
|
71448
71502
|
var CacheInternal = class {
|
|
71449
71503
|
_disabled = false;
|
|
@@ -71731,8 +71785,16 @@ var CacheInternal = class {
|
|
|
71731
71785
|
operation.position || "last",
|
|
71732
71786
|
layer
|
|
71733
71787
|
);
|
|
71788
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
71789
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
71790
|
+
selection: fieldSelection,
|
|
71791
|
+
data: target,
|
|
71792
|
+
variables,
|
|
71793
|
+
where: operation.position || "last",
|
|
71794
|
+
layer
|
|
71795
|
+
});
|
|
71734
71796
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
71735
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
71797
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
71736
71798
|
} else if (operation.action === "delete" && operation.type) {
|
|
71737
71799
|
if (typeof target !== "string") {
|
|
71738
71800
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -71741,15 +71803,7 @@ var CacheInternal = class {
|
|
|
71741
71803
|
if (!targetID) {
|
|
71742
71804
|
continue;
|
|
71743
71805
|
}
|
|
71744
|
-
this.cache.delete(targetID);
|
|
71745
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
71746
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
71747
|
-
selection: fieldSelection,
|
|
71748
|
-
data: target,
|
|
71749
|
-
variables,
|
|
71750
|
-
where: operation.position || "last",
|
|
71751
|
-
layer
|
|
71752
|
-
});
|
|
71806
|
+
this.cache.delete(targetID, layer);
|
|
71753
71807
|
}
|
|
71754
71808
|
}
|
|
71755
71809
|
}
|
|
@@ -72284,7 +72338,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
72284
72338
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
72285
72339
|
return {
|
|
72286
72340
|
async start(ctx, { next, marshalVariables }) {
|
|
72287
|
-
const
|
|
72341
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
72288
72342
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
72289
72343
|
let toNotify = [];
|
|
72290
72344
|
if (optimisticResponse) {
|
|
@@ -72295,25 +72349,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
72295
72349
|
data: optimisticResponse
|
|
72296
72350
|
}),
|
|
72297
72351
|
variables: marshalVariables(ctx),
|
|
72298
|
-
layer:
|
|
72352
|
+
layer: layerOptimistic.id
|
|
72299
72353
|
});
|
|
72300
72354
|
}
|
|
72301
72355
|
ctx.cacheParams = {
|
|
72302
72356
|
...ctx.cacheParams,
|
|
72303
|
-
layer,
|
|
72357
|
+
layer: layerOptimistic,
|
|
72304
72358
|
notifySubscribers: toNotify,
|
|
72305
72359
|
forceNotify: true
|
|
72306
72360
|
};
|
|
72307
72361
|
next(ctx);
|
|
72308
72362
|
},
|
|
72309
72363
|
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
72310
|
-
ctx.cacheParams?.layer
|
|
72364
|
+
if (ctx.cacheParams?.layer) {
|
|
72365
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
72366
|
+
}
|
|
72311
72367
|
resolve2(ctx);
|
|
72312
72368
|
},
|
|
72313
72369
|
end(ctx, { resolve: resolve2, value }) {
|
|
72314
72370
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
72315
72371
|
if (hasErrors) {
|
|
72316
|
-
ctx.cacheParams?.layer
|
|
72372
|
+
if (ctx.cacheParams?.layer) {
|
|
72373
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
72374
|
+
}
|
|
72317
72375
|
}
|
|
72318
72376
|
if (ctx.cacheParams?.layer) {
|
|
72319
72377
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -72323,7 +72381,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
72323
72381
|
catch(ctx, { error }) {
|
|
72324
72382
|
if (ctx.cacheParams?.layer) {
|
|
72325
72383
|
const { layer } = ctx.cacheParams;
|
|
72326
|
-
layer.
|
|
72384
|
+
cache_default.clearLayer(layer.id);
|
|
72327
72385
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
72328
72386
|
}
|
|
72329
72387
|
throw error;
|
|
@@ -74804,7 +74862,7 @@ function operationObject({
|
|
|
74804
74862
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
74805
74863
|
operation.position = position;
|
|
74806
74864
|
}
|
|
74807
|
-
if (operationKind
|
|
74865
|
+
if (allLists && operationKind !== "delete") {
|
|
74808
74866
|
operation.target = "all";
|
|
74809
74867
|
}
|
|
74810
74868
|
if (parentID) {
|
|
@@ -80059,8 +80117,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
80059
80117
|
}
|
|
80060
80118
|
packageJSON.devDependencies = {
|
|
80061
80119
|
...packageJSON.devDependencies,
|
|
80062
|
-
houdini: "^1.2.
|
|
80063
|
-
"houdini-svelte": "^1.2.
|
|
80120
|
+
houdini: "^1.2.3",
|
|
80121
|
+
"houdini-svelte": "^1.2.3"
|
|
80064
80122
|
};
|
|
80065
80123
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
80066
80124
|
}
|