houdini 1.5.7 → 1.5.9
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 +54 -34
- package/build/cmd-esm/index.js +54 -34
- package/build/codegen-cjs/index.js +36 -29
- package/build/codegen-esm/index.js +36 -29
- package/build/lib-cjs/index.js +36 -29
- package/build/lib-esm/index.js +36 -29
- package/build/runtime-cjs/cache/cache.js +36 -29
- package/build/runtime-esm/cache/cache.js +36 -29
- package/build/test-cjs/index.js +36 -29
- package/build/test-esm/index.js +36 -29
- package/build/vite-cjs/index.js +36 -29
- package/build/vite-esm/index.js +36 -29
- package/package.json +1 -1
package/build/cmd-cjs/index.js
CHANGED
|
@@ -70812,20 +70812,21 @@ var CacheInternal = class {
|
|
|
70812
70812
|
}
|
|
70813
70813
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
70814
70814
|
let oldIDs = [...previousValue || []];
|
|
70815
|
-
|
|
70816
|
-
|
|
70817
|
-
|
|
70818
|
-
|
|
70819
|
-
|
|
70820
|
-
|
|
70821
|
-
|
|
70822
|
-
|
|
70823
|
-
|
|
70824
|
-
|
|
70825
|
-
|
|
70826
|
-
|
|
70827
|
-
|
|
70828
|
-
|
|
70815
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
70816
|
+
oldIDs = oldIDs.filter((id) => {
|
|
70817
|
+
for (const layer2 of this.storage.data) {
|
|
70818
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
70819
|
+
if (operation.fields?.[key])
|
|
70820
|
+
for (const listOperation of operation.fields[key]) {
|
|
70821
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
70822
|
+
return false;
|
|
70823
|
+
}
|
|
70824
|
+
}
|
|
70825
|
+
}
|
|
70826
|
+
}
|
|
70827
|
+
return true;
|
|
70828
|
+
});
|
|
70829
|
+
}
|
|
70829
70830
|
let linkedIDs = [];
|
|
70830
70831
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
70831
70832
|
value,
|
|
@@ -70844,39 +70845,45 @@ var CacheInternal = class {
|
|
|
70844
70845
|
layer.writeLink(parent2, key, linkedIDs);
|
|
70845
70846
|
};
|
|
70846
70847
|
if (applyUpdates && updates) {
|
|
70847
|
-
|
|
70848
|
-
const
|
|
70849
|
-
for (const id of
|
|
70848
|
+
const filterIDs = (keep, insert) => {
|
|
70849
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
70850
|
+
for (const id of keep) {
|
|
70850
70851
|
if (!id) {
|
|
70851
70852
|
continue;
|
|
70852
70853
|
}
|
|
70853
70854
|
const { value: node } = this.storage.get(id, "node");
|
|
70854
|
-
if (
|
|
70855
|
+
if (!node) {
|
|
70855
70856
|
continue;
|
|
70856
70857
|
}
|
|
70857
|
-
|
|
70858
|
+
const nodeID = this.storage.get(node, "id");
|
|
70859
|
+
if (!nodeID) {
|
|
70858
70860
|
continue;
|
|
70859
70861
|
}
|
|
70860
|
-
|
|
70862
|
+
existingIDs.add(nodeID.value);
|
|
70861
70863
|
}
|
|
70862
|
-
|
|
70864
|
+
return insert.filter((id) => {
|
|
70863
70865
|
if (!id) {
|
|
70864
70866
|
return true;
|
|
70865
70867
|
}
|
|
70866
|
-
const { value:
|
|
70867
|
-
|
|
70868
|
-
|
|
70869
|
-
return false;
|
|
70868
|
+
const { value: node } = this.storage.get(id, "node");
|
|
70869
|
+
if (!node) {
|
|
70870
|
+
return true;
|
|
70870
70871
|
}
|
|
70871
|
-
|
|
70872
|
+
const nodeID = this.storage.get(node, "id");
|
|
70873
|
+
if (!nodeID) {
|
|
70874
|
+
return true;
|
|
70875
|
+
}
|
|
70876
|
+
return !existingIDs.has(nodeID.value);
|
|
70872
70877
|
});
|
|
70873
|
-
}
|
|
70878
|
+
};
|
|
70874
70879
|
for (const update of applyUpdates) {
|
|
70875
70880
|
if (update !== "replace" && !updates.includes(update)) {
|
|
70876
70881
|
continue;
|
|
70877
70882
|
}
|
|
70878
70883
|
if (update === "prepend") {
|
|
70879
|
-
linkedIDs = newIDs.concat(
|
|
70884
|
+
linkedIDs = newIDs.concat(
|
|
70885
|
+
filterIDs(newIDs, oldIDs)
|
|
70886
|
+
);
|
|
70880
70887
|
if (layer?.optimistic) {
|
|
70881
70888
|
action = () => {
|
|
70882
70889
|
for (const id of newIDs) {
|
|
@@ -70887,7 +70894,7 @@ var CacheInternal = class {
|
|
|
70887
70894
|
};
|
|
70888
70895
|
}
|
|
70889
70896
|
} else if (update === "append") {
|
|
70890
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
70897
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
70891
70898
|
if (layer?.optimistic) {
|
|
70892
70899
|
action = () => {
|
|
70893
70900
|
for (const id of newIDs) {
|
|
@@ -82026,7 +82033,10 @@ async function init2(_path, args) {
|
|
|
82026
82033
|
} else if (frameworkInfo.framework === "kit") {
|
|
82027
82034
|
await svelteConfig(targetPath, typescript);
|
|
82028
82035
|
}
|
|
82029
|
-
await gitIgnore(
|
|
82036
|
+
await gitIgnore({
|
|
82037
|
+
targetPath,
|
|
82038
|
+
schemaPath: is_remote_endpoint ? path_exports.relative(targetPath, schemaPath) : void 0
|
|
82039
|
+
});
|
|
82030
82040
|
await graphqlRC(targetPath);
|
|
82031
82041
|
await viteConfig(targetPath, frameworkInfo, typescript);
|
|
82032
82042
|
await tjsConfig(targetPath, frameworkInfo);
|
|
@@ -82177,11 +82187,21 @@ async function svelteConfig(targetPath, typescript) {
|
|
|
82177
82187
|
});
|
|
82178
82188
|
await fs_exports.writeFile(svelteConfigPath, recast14.print(ast).code);
|
|
82179
82189
|
}
|
|
82180
|
-
async function gitIgnore(targetPath) {
|
|
82190
|
+
async function gitIgnore({ targetPath, schemaPath }) {
|
|
82181
82191
|
const filepath = path_exports.join(targetPath, ".gitignore");
|
|
82182
82192
|
const existing = await fs_exports.readFile(filepath) || "";
|
|
82193
|
+
let newIgnores = "";
|
|
82183
82194
|
if (!existing.includes("\n.houdini\n")) {
|
|
82184
|
-
|
|
82195
|
+
newIgnores += ".houdini\n";
|
|
82196
|
+
}
|
|
82197
|
+
if (schemaPath && !existing.includes(`
|
|
82198
|
+
${schemaPath}
|
|
82199
|
+
`)) {
|
|
82200
|
+
newIgnores += `${schemaPath}
|
|
82201
|
+
`;
|
|
82202
|
+
}
|
|
82203
|
+
if (newIgnores) {
|
|
82204
|
+
await fs_exports.writeFile(filepath, existing + "\n" + newIgnores);
|
|
82185
82205
|
}
|
|
82186
82206
|
}
|
|
82187
82207
|
async function graphqlRC(targetPath) {
|
|
@@ -82355,13 +82375,13 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
82355
82375
|
}
|
|
82356
82376
|
packageJSON2.devDependencies = {
|
|
82357
82377
|
...packageJSON2.devDependencies,
|
|
82358
|
-
houdini: "^1.5.
|
|
82378
|
+
houdini: "^1.5.9",
|
|
82359
82379
|
"@sveltejs/kit": "<=2.21.0"
|
|
82360
82380
|
};
|
|
82361
82381
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
82362
82382
|
packageJSON2.devDependencies = {
|
|
82363
82383
|
...packageJSON2.devDependencies,
|
|
82364
|
-
"houdini-svelte": "^2.1.
|
|
82384
|
+
"houdini-svelte": "^2.1.19"
|
|
82365
82385
|
};
|
|
82366
82386
|
} else {
|
|
82367
82387
|
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
|
package/build/cmd-esm/index.js
CHANGED
|
@@ -70818,20 +70818,21 @@ var CacheInternal = class {
|
|
|
70818
70818
|
}
|
|
70819
70819
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
70820
70820
|
let oldIDs = [...previousValue || []];
|
|
70821
|
-
|
|
70822
|
-
|
|
70823
|
-
|
|
70824
|
-
|
|
70825
|
-
|
|
70826
|
-
|
|
70827
|
-
|
|
70828
|
-
|
|
70829
|
-
|
|
70830
|
-
|
|
70831
|
-
|
|
70832
|
-
|
|
70833
|
-
|
|
70834
|
-
|
|
70821
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
70822
|
+
oldIDs = oldIDs.filter((id) => {
|
|
70823
|
+
for (const layer2 of this.storage.data) {
|
|
70824
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
70825
|
+
if (operation.fields?.[key])
|
|
70826
|
+
for (const listOperation of operation.fields[key]) {
|
|
70827
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
70828
|
+
return false;
|
|
70829
|
+
}
|
|
70830
|
+
}
|
|
70831
|
+
}
|
|
70832
|
+
}
|
|
70833
|
+
return true;
|
|
70834
|
+
});
|
|
70835
|
+
}
|
|
70835
70836
|
let linkedIDs = [];
|
|
70836
70837
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
70837
70838
|
value,
|
|
@@ -70850,39 +70851,45 @@ var CacheInternal = class {
|
|
|
70850
70851
|
layer.writeLink(parent2, key, linkedIDs);
|
|
70851
70852
|
};
|
|
70852
70853
|
if (applyUpdates && updates) {
|
|
70853
|
-
|
|
70854
|
-
const
|
|
70855
|
-
for (const id of
|
|
70854
|
+
const filterIDs = (keep, insert) => {
|
|
70855
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
70856
|
+
for (const id of keep) {
|
|
70856
70857
|
if (!id) {
|
|
70857
70858
|
continue;
|
|
70858
70859
|
}
|
|
70859
70860
|
const { value: node } = this.storage.get(id, "node");
|
|
70860
|
-
if (
|
|
70861
|
+
if (!node) {
|
|
70861
70862
|
continue;
|
|
70862
70863
|
}
|
|
70863
|
-
|
|
70864
|
+
const nodeID = this.storage.get(node, "id");
|
|
70865
|
+
if (!nodeID) {
|
|
70864
70866
|
continue;
|
|
70865
70867
|
}
|
|
70866
|
-
|
|
70868
|
+
existingIDs.add(nodeID.value);
|
|
70867
70869
|
}
|
|
70868
|
-
|
|
70870
|
+
return insert.filter((id) => {
|
|
70869
70871
|
if (!id) {
|
|
70870
70872
|
return true;
|
|
70871
70873
|
}
|
|
70872
|
-
const { value:
|
|
70873
|
-
|
|
70874
|
-
|
|
70875
|
-
return false;
|
|
70874
|
+
const { value: node } = this.storage.get(id, "node");
|
|
70875
|
+
if (!node) {
|
|
70876
|
+
return true;
|
|
70876
70877
|
}
|
|
70877
|
-
|
|
70878
|
+
const nodeID = this.storage.get(node, "id");
|
|
70879
|
+
if (!nodeID) {
|
|
70880
|
+
return true;
|
|
70881
|
+
}
|
|
70882
|
+
return !existingIDs.has(nodeID.value);
|
|
70878
70883
|
});
|
|
70879
|
-
}
|
|
70884
|
+
};
|
|
70880
70885
|
for (const update of applyUpdates) {
|
|
70881
70886
|
if (update !== "replace" && !updates.includes(update)) {
|
|
70882
70887
|
continue;
|
|
70883
70888
|
}
|
|
70884
70889
|
if (update === "prepend") {
|
|
70885
|
-
linkedIDs = newIDs.concat(
|
|
70890
|
+
linkedIDs = newIDs.concat(
|
|
70891
|
+
filterIDs(newIDs, oldIDs)
|
|
70892
|
+
);
|
|
70886
70893
|
if (layer?.optimistic) {
|
|
70887
70894
|
action = () => {
|
|
70888
70895
|
for (const id of newIDs) {
|
|
@@ -70893,7 +70900,7 @@ var CacheInternal = class {
|
|
|
70893
70900
|
};
|
|
70894
70901
|
}
|
|
70895
70902
|
} else if (update === "append") {
|
|
70896
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
70903
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
70897
70904
|
if (layer?.optimistic) {
|
|
70898
70905
|
action = () => {
|
|
70899
70906
|
for (const id of newIDs) {
|
|
@@ -82031,7 +82038,10 @@ async function init2(_path, args) {
|
|
|
82031
82038
|
} else if (frameworkInfo.framework === "kit") {
|
|
82032
82039
|
await svelteConfig(targetPath, typescript);
|
|
82033
82040
|
}
|
|
82034
|
-
await gitIgnore(
|
|
82041
|
+
await gitIgnore({
|
|
82042
|
+
targetPath,
|
|
82043
|
+
schemaPath: is_remote_endpoint ? path_exports.relative(targetPath, schemaPath) : void 0
|
|
82044
|
+
});
|
|
82035
82045
|
await graphqlRC(targetPath);
|
|
82036
82046
|
await viteConfig(targetPath, frameworkInfo, typescript);
|
|
82037
82047
|
await tjsConfig(targetPath, frameworkInfo);
|
|
@@ -82182,11 +82192,21 @@ async function svelteConfig(targetPath, typescript) {
|
|
|
82182
82192
|
});
|
|
82183
82193
|
await fs_exports.writeFile(svelteConfigPath, recast14.print(ast).code);
|
|
82184
82194
|
}
|
|
82185
|
-
async function gitIgnore(targetPath) {
|
|
82195
|
+
async function gitIgnore({ targetPath, schemaPath }) {
|
|
82186
82196
|
const filepath = path_exports.join(targetPath, ".gitignore");
|
|
82187
82197
|
const existing = await fs_exports.readFile(filepath) || "";
|
|
82198
|
+
let newIgnores = "";
|
|
82188
82199
|
if (!existing.includes("\n.houdini\n")) {
|
|
82189
|
-
|
|
82200
|
+
newIgnores += ".houdini\n";
|
|
82201
|
+
}
|
|
82202
|
+
if (schemaPath && !existing.includes(`
|
|
82203
|
+
${schemaPath}
|
|
82204
|
+
`)) {
|
|
82205
|
+
newIgnores += `${schemaPath}
|
|
82206
|
+
`;
|
|
82207
|
+
}
|
|
82208
|
+
if (newIgnores) {
|
|
82209
|
+
await fs_exports.writeFile(filepath, existing + "\n" + newIgnores);
|
|
82190
82210
|
}
|
|
82191
82211
|
}
|
|
82192
82212
|
async function graphqlRC(targetPath) {
|
|
@@ -82360,13 +82380,13 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
82360
82380
|
}
|
|
82361
82381
|
packageJSON2.devDependencies = {
|
|
82362
82382
|
...packageJSON2.devDependencies,
|
|
82363
|
-
houdini: "^1.5.
|
|
82383
|
+
houdini: "^1.5.9",
|
|
82364
82384
|
"@sveltejs/kit": "<=2.21.0"
|
|
82365
82385
|
};
|
|
82366
82386
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
82367
82387
|
packageJSON2.devDependencies = {
|
|
82368
82388
|
...packageJSON2.devDependencies,
|
|
82369
|
-
"houdini-svelte": "^2.1.
|
|
82389
|
+
"houdini-svelte": "^2.1.19"
|
|
82370
82390
|
};
|
|
82371
82391
|
} else {
|
|
82372
82392
|
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
|
|
@@ -60139,20 +60139,21 @@ var CacheInternal = class {
|
|
|
60139
60139
|
}
|
|
60140
60140
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
60141
60141
|
let oldIDs = [...previousValue || []];
|
|
60142
|
-
|
|
60143
|
-
|
|
60144
|
-
|
|
60145
|
-
|
|
60146
|
-
|
|
60147
|
-
|
|
60148
|
-
|
|
60149
|
-
|
|
60150
|
-
|
|
60151
|
-
|
|
60152
|
-
|
|
60153
|
-
|
|
60154
|
-
|
|
60155
|
-
|
|
60142
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
60143
|
+
oldIDs = oldIDs.filter((id) => {
|
|
60144
|
+
for (const layer2 of this.storage.data) {
|
|
60145
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
60146
|
+
if (operation.fields?.[key])
|
|
60147
|
+
for (const listOperation of operation.fields[key]) {
|
|
60148
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
60149
|
+
return false;
|
|
60150
|
+
}
|
|
60151
|
+
}
|
|
60152
|
+
}
|
|
60153
|
+
}
|
|
60154
|
+
return true;
|
|
60155
|
+
});
|
|
60156
|
+
}
|
|
60156
60157
|
let linkedIDs = [];
|
|
60157
60158
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
60158
60159
|
value,
|
|
@@ -60171,39 +60172,45 @@ var CacheInternal = class {
|
|
|
60171
60172
|
layer.writeLink(parent2, key, linkedIDs);
|
|
60172
60173
|
};
|
|
60173
60174
|
if (applyUpdates && updates) {
|
|
60174
|
-
|
|
60175
|
-
const
|
|
60176
|
-
for (const id of
|
|
60175
|
+
const filterIDs = (keep, insert) => {
|
|
60176
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
60177
|
+
for (const id of keep) {
|
|
60177
60178
|
if (!id) {
|
|
60178
60179
|
continue;
|
|
60179
60180
|
}
|
|
60180
60181
|
const { value: node } = this.storage.get(id, "node");
|
|
60181
|
-
if (
|
|
60182
|
+
if (!node) {
|
|
60182
60183
|
continue;
|
|
60183
60184
|
}
|
|
60184
|
-
|
|
60185
|
+
const nodeID = this.storage.get(node, "id");
|
|
60186
|
+
if (!nodeID) {
|
|
60185
60187
|
continue;
|
|
60186
60188
|
}
|
|
60187
|
-
|
|
60189
|
+
existingIDs.add(nodeID.value);
|
|
60188
60190
|
}
|
|
60189
|
-
|
|
60191
|
+
return insert.filter((id) => {
|
|
60190
60192
|
if (!id) {
|
|
60191
60193
|
return true;
|
|
60192
60194
|
}
|
|
60193
|
-
const { value:
|
|
60194
|
-
|
|
60195
|
-
|
|
60196
|
-
return false;
|
|
60195
|
+
const { value: node } = this.storage.get(id, "node");
|
|
60196
|
+
if (!node) {
|
|
60197
|
+
return true;
|
|
60197
60198
|
}
|
|
60198
|
-
|
|
60199
|
+
const nodeID = this.storage.get(node, "id");
|
|
60200
|
+
if (!nodeID) {
|
|
60201
|
+
return true;
|
|
60202
|
+
}
|
|
60203
|
+
return !existingIDs.has(nodeID.value);
|
|
60199
60204
|
});
|
|
60200
|
-
}
|
|
60205
|
+
};
|
|
60201
60206
|
for (const update of applyUpdates) {
|
|
60202
60207
|
if (update !== "replace" && !updates.includes(update)) {
|
|
60203
60208
|
continue;
|
|
60204
60209
|
}
|
|
60205
60210
|
if (update === "prepend") {
|
|
60206
|
-
linkedIDs = newIDs.concat(
|
|
60211
|
+
linkedIDs = newIDs.concat(
|
|
60212
|
+
filterIDs(newIDs, oldIDs)
|
|
60213
|
+
);
|
|
60207
60214
|
if (layer?.optimistic) {
|
|
60208
60215
|
action = () => {
|
|
60209
60216
|
for (const id of newIDs) {
|
|
@@ -60214,7 +60221,7 @@ var CacheInternal = class {
|
|
|
60214
60221
|
};
|
|
60215
60222
|
}
|
|
60216
60223
|
} else if (update === "append") {
|
|
60217
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
60224
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
60218
60225
|
if (layer?.optimistic) {
|
|
60219
60226
|
action = () => {
|
|
60220
60227
|
for (const id of newIDs) {
|
|
@@ -60139,20 +60139,21 @@ var CacheInternal = class {
|
|
|
60139
60139
|
}
|
|
60140
60140
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
60141
60141
|
let oldIDs = [...previousValue || []];
|
|
60142
|
-
|
|
60143
|
-
|
|
60144
|
-
|
|
60145
|
-
|
|
60146
|
-
|
|
60147
|
-
|
|
60148
|
-
|
|
60149
|
-
|
|
60150
|
-
|
|
60151
|
-
|
|
60152
|
-
|
|
60153
|
-
|
|
60154
|
-
|
|
60155
|
-
|
|
60142
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
60143
|
+
oldIDs = oldIDs.filter((id) => {
|
|
60144
|
+
for (const layer2 of this.storage.data) {
|
|
60145
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
60146
|
+
if (operation.fields?.[key])
|
|
60147
|
+
for (const listOperation of operation.fields[key]) {
|
|
60148
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
60149
|
+
return false;
|
|
60150
|
+
}
|
|
60151
|
+
}
|
|
60152
|
+
}
|
|
60153
|
+
}
|
|
60154
|
+
return true;
|
|
60155
|
+
});
|
|
60156
|
+
}
|
|
60156
60157
|
let linkedIDs = [];
|
|
60157
60158
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
60158
60159
|
value,
|
|
@@ -60171,39 +60172,45 @@ var CacheInternal = class {
|
|
|
60171
60172
|
layer.writeLink(parent2, key, linkedIDs);
|
|
60172
60173
|
};
|
|
60173
60174
|
if (applyUpdates && updates) {
|
|
60174
|
-
|
|
60175
|
-
const
|
|
60176
|
-
for (const id of
|
|
60175
|
+
const filterIDs = (keep, insert) => {
|
|
60176
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
60177
|
+
for (const id of keep) {
|
|
60177
60178
|
if (!id) {
|
|
60178
60179
|
continue;
|
|
60179
60180
|
}
|
|
60180
60181
|
const { value: node } = this.storage.get(id, "node");
|
|
60181
|
-
if (
|
|
60182
|
+
if (!node) {
|
|
60182
60183
|
continue;
|
|
60183
60184
|
}
|
|
60184
|
-
|
|
60185
|
+
const nodeID = this.storage.get(node, "id");
|
|
60186
|
+
if (!nodeID) {
|
|
60185
60187
|
continue;
|
|
60186
60188
|
}
|
|
60187
|
-
|
|
60189
|
+
existingIDs.add(nodeID.value);
|
|
60188
60190
|
}
|
|
60189
|
-
|
|
60191
|
+
return insert.filter((id) => {
|
|
60190
60192
|
if (!id) {
|
|
60191
60193
|
return true;
|
|
60192
60194
|
}
|
|
60193
|
-
const { value:
|
|
60194
|
-
|
|
60195
|
-
|
|
60196
|
-
return false;
|
|
60195
|
+
const { value: node } = this.storage.get(id, "node");
|
|
60196
|
+
if (!node) {
|
|
60197
|
+
return true;
|
|
60197
60198
|
}
|
|
60198
|
-
|
|
60199
|
+
const nodeID = this.storage.get(node, "id");
|
|
60200
|
+
if (!nodeID) {
|
|
60201
|
+
return true;
|
|
60202
|
+
}
|
|
60203
|
+
return !existingIDs.has(nodeID.value);
|
|
60199
60204
|
});
|
|
60200
|
-
}
|
|
60205
|
+
};
|
|
60201
60206
|
for (const update of applyUpdates) {
|
|
60202
60207
|
if (update !== "replace" && !updates.includes(update)) {
|
|
60203
60208
|
continue;
|
|
60204
60209
|
}
|
|
60205
60210
|
if (update === "prepend") {
|
|
60206
|
-
linkedIDs = newIDs.concat(
|
|
60211
|
+
linkedIDs = newIDs.concat(
|
|
60212
|
+
filterIDs(newIDs, oldIDs)
|
|
60213
|
+
);
|
|
60207
60214
|
if (layer?.optimistic) {
|
|
60208
60215
|
action = () => {
|
|
60209
60216
|
for (const id of newIDs) {
|
|
@@ -60214,7 +60221,7 @@ var CacheInternal = class {
|
|
|
60214
60221
|
};
|
|
60215
60222
|
}
|
|
60216
60223
|
} else if (update === "append") {
|
|
60217
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
60224
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
60218
60225
|
if (layer?.optimistic) {
|
|
60219
60226
|
action = () => {
|
|
60220
60227
|
for (const id of newIDs) {
|
package/build/lib-cjs/index.js
CHANGED
|
@@ -69759,20 +69759,21 @@ var CacheInternal = class {
|
|
|
69759
69759
|
}
|
|
69760
69760
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
69761
69761
|
let oldIDs = [...previousValue || []];
|
|
69762
|
-
|
|
69763
|
-
|
|
69764
|
-
|
|
69765
|
-
|
|
69766
|
-
|
|
69767
|
-
|
|
69768
|
-
|
|
69769
|
-
|
|
69770
|
-
|
|
69771
|
-
|
|
69772
|
-
|
|
69773
|
-
|
|
69774
|
-
|
|
69775
|
-
|
|
69762
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
69763
|
+
oldIDs = oldIDs.filter((id) => {
|
|
69764
|
+
for (const layer2 of this.storage.data) {
|
|
69765
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
69766
|
+
if (operation.fields?.[key])
|
|
69767
|
+
for (const listOperation of operation.fields[key]) {
|
|
69768
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
69769
|
+
return false;
|
|
69770
|
+
}
|
|
69771
|
+
}
|
|
69772
|
+
}
|
|
69773
|
+
}
|
|
69774
|
+
return true;
|
|
69775
|
+
});
|
|
69776
|
+
}
|
|
69776
69777
|
let linkedIDs = [];
|
|
69777
69778
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
69778
69779
|
value,
|
|
@@ -69791,39 +69792,45 @@ var CacheInternal = class {
|
|
|
69791
69792
|
layer.writeLink(parent, key, linkedIDs);
|
|
69792
69793
|
};
|
|
69793
69794
|
if (applyUpdates && updates) {
|
|
69794
|
-
|
|
69795
|
-
const
|
|
69796
|
-
for (const id of
|
|
69795
|
+
const filterIDs = (keep, insert) => {
|
|
69796
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
69797
|
+
for (const id of keep) {
|
|
69797
69798
|
if (!id) {
|
|
69798
69799
|
continue;
|
|
69799
69800
|
}
|
|
69800
69801
|
const { value: node } = this.storage.get(id, "node");
|
|
69801
|
-
if (
|
|
69802
|
+
if (!node) {
|
|
69802
69803
|
continue;
|
|
69803
69804
|
}
|
|
69804
|
-
|
|
69805
|
+
const nodeID = this.storage.get(node, "id");
|
|
69806
|
+
if (!nodeID) {
|
|
69805
69807
|
continue;
|
|
69806
69808
|
}
|
|
69807
|
-
|
|
69809
|
+
existingIDs.add(nodeID.value);
|
|
69808
69810
|
}
|
|
69809
|
-
|
|
69811
|
+
return insert.filter((id) => {
|
|
69810
69812
|
if (!id) {
|
|
69811
69813
|
return true;
|
|
69812
69814
|
}
|
|
69813
|
-
const { value:
|
|
69814
|
-
|
|
69815
|
-
|
|
69816
|
-
return false;
|
|
69815
|
+
const { value: node } = this.storage.get(id, "node");
|
|
69816
|
+
if (!node) {
|
|
69817
|
+
return true;
|
|
69817
69818
|
}
|
|
69818
|
-
|
|
69819
|
+
const nodeID = this.storage.get(node, "id");
|
|
69820
|
+
if (!nodeID) {
|
|
69821
|
+
return true;
|
|
69822
|
+
}
|
|
69823
|
+
return !existingIDs.has(nodeID.value);
|
|
69819
69824
|
});
|
|
69820
|
-
}
|
|
69825
|
+
};
|
|
69821
69826
|
for (const update of applyUpdates) {
|
|
69822
69827
|
if (update !== "replace" && !updates.includes(update)) {
|
|
69823
69828
|
continue;
|
|
69824
69829
|
}
|
|
69825
69830
|
if (update === "prepend") {
|
|
69826
|
-
linkedIDs = newIDs.concat(
|
|
69831
|
+
linkedIDs = newIDs.concat(
|
|
69832
|
+
filterIDs(newIDs, oldIDs)
|
|
69833
|
+
);
|
|
69827
69834
|
if (layer?.optimistic) {
|
|
69828
69835
|
action = () => {
|
|
69829
69836
|
for (const id of newIDs) {
|
|
@@ -69834,7 +69841,7 @@ var CacheInternal = class {
|
|
|
69834
69841
|
};
|
|
69835
69842
|
}
|
|
69836
69843
|
} else if (update === "append") {
|
|
69837
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
69844
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
69838
69845
|
if (layer?.optimistic) {
|
|
69839
69846
|
action = () => {
|
|
69840
69847
|
for (const id of newIDs) {
|