houdini 2.0.0-next.0 → 2.0.0-next.2
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 +127 -43
- package/build/cmd-esm/index.js +127 -43
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +3 -0
- package/build/codegen-cjs/index.js +86 -29
- package/build/codegen-esm/index.js +86 -29
- package/build/lib/config.d.ts +3 -0
- package/build/lib/introspection.d.ts +1 -1
- package/build/lib-cjs/index.js +75 -38
- package/build/lib-esm/index.js +75 -38
- package/build/runtime/lib/config.d.ts +7 -0
- package/build/runtime-cjs/cache/cache.js +36 -29
- package/build/runtime-cjs/lib/config.d.ts +7 -0
- package/build/runtime-esm/cache/cache.js +36 -29
- package/build/runtime-esm/lib/config.d.ts +7 -0
- package/build/test-cjs/index.js +64 -32
- package/build/test-esm/index.js +64 -32
- package/build/vite-cjs/index.js +127 -39
- package/build/vite-esm/index.js +127 -39
- package/package.json +1 -1
|
@@ -64940,20 +64940,21 @@ var CacheInternal = class {
|
|
|
64940
64940
|
} else if (Array.isArray(value) && // make typescript happy
|
|
64941
64941
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
64942
64942
|
let oldIDs = [...previousValue || []];
|
|
64943
|
-
|
|
64944
|
-
|
|
64945
|
-
|
|
64946
|
-
|
|
64947
|
-
|
|
64948
|
-
|
|
64949
|
-
|
|
64950
|
-
|
|
64951
|
-
|
|
64952
|
-
|
|
64953
|
-
|
|
64954
|
-
|
|
64955
|
-
|
|
64956
|
-
|
|
64943
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
64944
|
+
oldIDs = oldIDs.filter((id) => {
|
|
64945
|
+
for (const layer2 of this.storage.data) {
|
|
64946
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
64947
|
+
if (operation.fields?.[key])
|
|
64948
|
+
for (const listOperation of operation.fields[key]) {
|
|
64949
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
64950
|
+
return false;
|
|
64951
|
+
}
|
|
64952
|
+
}
|
|
64953
|
+
}
|
|
64954
|
+
}
|
|
64955
|
+
return true;
|
|
64956
|
+
});
|
|
64957
|
+
}
|
|
64957
64958
|
let linkedIDs = [];
|
|
64958
64959
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
64959
64960
|
value,
|
|
@@ -64972,39 +64973,45 @@ var CacheInternal = class {
|
|
|
64972
64973
|
layer.writeLink(parent2, key, linkedIDs);
|
|
64973
64974
|
};
|
|
64974
64975
|
if (applyUpdates && updates) {
|
|
64975
|
-
|
|
64976
|
-
const
|
|
64977
|
-
for (const id of
|
|
64976
|
+
const filterIDs = (keep, insert) => {
|
|
64977
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
64978
|
+
for (const id of keep) {
|
|
64978
64979
|
if (!id) {
|
|
64979
64980
|
continue;
|
|
64980
64981
|
}
|
|
64981
64982
|
const { value: node } = this.storage.get(id, "node");
|
|
64982
|
-
if (
|
|
64983
|
+
if (!node) {
|
|
64983
64984
|
continue;
|
|
64984
64985
|
}
|
|
64985
|
-
|
|
64986
|
+
const nodeID = this.storage.get(node, "id");
|
|
64987
|
+
if (!nodeID) {
|
|
64986
64988
|
continue;
|
|
64987
64989
|
}
|
|
64988
|
-
|
|
64990
|
+
existingIDs.add(nodeID.value);
|
|
64989
64991
|
}
|
|
64990
|
-
|
|
64992
|
+
return insert.filter((id) => {
|
|
64991
64993
|
if (!id) {
|
|
64992
64994
|
return true;
|
|
64993
64995
|
}
|
|
64994
|
-
const { value:
|
|
64995
|
-
|
|
64996
|
-
|
|
64997
|
-
return false;
|
|
64996
|
+
const { value: node } = this.storage.get(id, "node");
|
|
64997
|
+
if (!node) {
|
|
64998
|
+
return true;
|
|
64998
64999
|
}
|
|
64999
|
-
|
|
65000
|
+
const nodeID = this.storage.get(node, "id");
|
|
65001
|
+
if (!nodeID) {
|
|
65002
|
+
return true;
|
|
65003
|
+
}
|
|
65004
|
+
return !existingIDs.has(nodeID.value);
|
|
65000
65005
|
});
|
|
65001
|
-
}
|
|
65006
|
+
};
|
|
65002
65007
|
for (const update of applyUpdates) {
|
|
65003
65008
|
if (update !== "replace" && !updates.includes(update)) {
|
|
65004
65009
|
continue;
|
|
65005
65010
|
}
|
|
65006
65011
|
if (update === "prepend") {
|
|
65007
|
-
linkedIDs = newIDs.concat(
|
|
65012
|
+
linkedIDs = newIDs.concat(
|
|
65013
|
+
filterIDs(newIDs, oldIDs)
|
|
65014
|
+
);
|
|
65008
65015
|
if (layer?.optimistic) {
|
|
65009
65016
|
action = () => {
|
|
65010
65017
|
for (const id of newIDs) {
|
|
@@ -65015,7 +65022,7 @@ var CacheInternal = class {
|
|
|
65015
65022
|
};
|
|
65016
65023
|
}
|
|
65017
65024
|
} else if (update === "append") {
|
|
65018
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
65025
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
65019
65026
|
if (layer?.optimistic) {
|
|
65020
65027
|
action = () => {
|
|
65021
65028
|
for (const id of newIDs) {
|
|
@@ -68733,6 +68740,50 @@ function moduleStatments(config) {
|
|
|
68733
68740
|
exportStarStatement
|
|
68734
68741
|
};
|
|
68735
68742
|
}
|
|
68743
|
+
async function generateStaticRuntimes({ config }) {
|
|
68744
|
+
if (houdini_mode.is_testing) {
|
|
68745
|
+
return;
|
|
68746
|
+
}
|
|
68747
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
|
|
68748
|
+
await Promise.all(
|
|
68749
|
+
config.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
68750
|
+
const runtime_path = config.pluginStaticRuntimeSource(plugin2);
|
|
68751
|
+
if (!runtime_path) {
|
|
68752
|
+
return;
|
|
68753
|
+
}
|
|
68754
|
+
try {
|
|
68755
|
+
await stat(runtime_path);
|
|
68756
|
+
} catch {
|
|
68757
|
+
throw new HoudiniError({
|
|
68758
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
68759
|
+
description: "Maybe it was bundled?"
|
|
68760
|
+
});
|
|
68761
|
+
}
|
|
68762
|
+
const pluginDir = config.pluginStaticRuntimeDirectory(plugin2.name);
|
|
68763
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
68764
|
+
if (transformMap && typeof transformMap === "function") {
|
|
68765
|
+
transformMap = transformMap([], { config });
|
|
68766
|
+
}
|
|
68767
|
+
await mkdirp(pluginDir);
|
|
68768
|
+
await recursiveCopy(
|
|
68769
|
+
runtime_path,
|
|
68770
|
+
pluginDir,
|
|
68771
|
+
Object.fromEntries(
|
|
68772
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
68773
|
+
join(runtime_path, key),
|
|
68774
|
+
(content) => value({
|
|
68775
|
+
config,
|
|
68776
|
+
content,
|
|
68777
|
+
importStatement,
|
|
68778
|
+
exportDefaultStatement,
|
|
68779
|
+
exportStarStatement
|
|
68780
|
+
})
|
|
68781
|
+
])
|
|
68782
|
+
)
|
|
68783
|
+
);
|
|
68784
|
+
})
|
|
68785
|
+
);
|
|
68786
|
+
}
|
|
68736
68787
|
async function generatePluginRuntimes({
|
|
68737
68788
|
config,
|
|
68738
68789
|
docs
|
|
@@ -70334,6 +70385,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
70334
70385
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
70335
70386
|
});
|
|
70336
70387
|
}
|
|
70388
|
+
if (plugin2.staticRuntime) {
|
|
70389
|
+
body += exportStar({
|
|
70390
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
70391
|
+
});
|
|
70392
|
+
}
|
|
70337
70393
|
}
|
|
70338
70394
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
70339
70395
|
}
|
|
@@ -74251,6 +74307,7 @@ async function componentFields2(config, docs) {
|
|
|
74251
74307
|
|
|
74252
74308
|
// src/codegen/index.ts
|
|
74253
74309
|
async function compile(config) {
|
|
74310
|
+
await generateStaticRuntimes({ config });
|
|
74254
74311
|
const documents = await collectDocuments(config);
|
|
74255
74312
|
return await runPipeline2(config, documents);
|
|
74256
74313
|
}
|
|
@@ -64940,20 +64940,21 @@ var CacheInternal = class {
|
|
|
64940
64940
|
} else if (Array.isArray(value) && // make typescript happy
|
|
64941
64941
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
64942
64942
|
let oldIDs = [...previousValue || []];
|
|
64943
|
-
|
|
64944
|
-
|
|
64945
|
-
|
|
64946
|
-
|
|
64947
|
-
|
|
64948
|
-
|
|
64949
|
-
|
|
64950
|
-
|
|
64951
|
-
|
|
64952
|
-
|
|
64953
|
-
|
|
64954
|
-
|
|
64955
|
-
|
|
64956
|
-
|
|
64943
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
64944
|
+
oldIDs = oldIDs.filter((id) => {
|
|
64945
|
+
for (const layer2 of this.storage.data) {
|
|
64946
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
64947
|
+
if (operation.fields?.[key])
|
|
64948
|
+
for (const listOperation of operation.fields[key]) {
|
|
64949
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
64950
|
+
return false;
|
|
64951
|
+
}
|
|
64952
|
+
}
|
|
64953
|
+
}
|
|
64954
|
+
}
|
|
64955
|
+
return true;
|
|
64956
|
+
});
|
|
64957
|
+
}
|
|
64957
64958
|
let linkedIDs = [];
|
|
64958
64959
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
64959
64960
|
value,
|
|
@@ -64972,39 +64973,45 @@ var CacheInternal = class {
|
|
|
64972
64973
|
layer.writeLink(parent2, key, linkedIDs);
|
|
64973
64974
|
};
|
|
64974
64975
|
if (applyUpdates && updates) {
|
|
64975
|
-
|
|
64976
|
-
const
|
|
64977
|
-
for (const id of
|
|
64976
|
+
const filterIDs = (keep, insert) => {
|
|
64977
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
64978
|
+
for (const id of keep) {
|
|
64978
64979
|
if (!id) {
|
|
64979
64980
|
continue;
|
|
64980
64981
|
}
|
|
64981
64982
|
const { value: node } = this.storage.get(id, "node");
|
|
64982
|
-
if (
|
|
64983
|
+
if (!node) {
|
|
64983
64984
|
continue;
|
|
64984
64985
|
}
|
|
64985
|
-
|
|
64986
|
+
const nodeID = this.storage.get(node, "id");
|
|
64987
|
+
if (!nodeID) {
|
|
64986
64988
|
continue;
|
|
64987
64989
|
}
|
|
64988
|
-
|
|
64990
|
+
existingIDs.add(nodeID.value);
|
|
64989
64991
|
}
|
|
64990
|
-
|
|
64992
|
+
return insert.filter((id) => {
|
|
64991
64993
|
if (!id) {
|
|
64992
64994
|
return true;
|
|
64993
64995
|
}
|
|
64994
|
-
const { value:
|
|
64995
|
-
|
|
64996
|
-
|
|
64997
|
-
return false;
|
|
64996
|
+
const { value: node } = this.storage.get(id, "node");
|
|
64997
|
+
if (!node) {
|
|
64998
|
+
return true;
|
|
64998
64999
|
}
|
|
64999
|
-
|
|
65000
|
+
const nodeID = this.storage.get(node, "id");
|
|
65001
|
+
if (!nodeID) {
|
|
65002
|
+
return true;
|
|
65003
|
+
}
|
|
65004
|
+
return !existingIDs.has(nodeID.value);
|
|
65000
65005
|
});
|
|
65001
|
-
}
|
|
65006
|
+
};
|
|
65002
65007
|
for (const update of applyUpdates) {
|
|
65003
65008
|
if (update !== "replace" && !updates.includes(update)) {
|
|
65004
65009
|
continue;
|
|
65005
65010
|
}
|
|
65006
65011
|
if (update === "prepend") {
|
|
65007
|
-
linkedIDs = newIDs.concat(
|
|
65012
|
+
linkedIDs = newIDs.concat(
|
|
65013
|
+
filterIDs(newIDs, oldIDs)
|
|
65014
|
+
);
|
|
65008
65015
|
if (layer?.optimistic) {
|
|
65009
65016
|
action = () => {
|
|
65010
65017
|
for (const id of newIDs) {
|
|
@@ -65015,7 +65022,7 @@ var CacheInternal = class {
|
|
|
65015
65022
|
};
|
|
65016
65023
|
}
|
|
65017
65024
|
} else if (update === "append") {
|
|
65018
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
65025
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
65019
65026
|
if (layer?.optimistic) {
|
|
65020
65027
|
action = () => {
|
|
65021
65028
|
for (const id of newIDs) {
|
|
@@ -68732,6 +68739,50 @@ function moduleStatments(config) {
|
|
|
68732
68739
|
exportStarStatement
|
|
68733
68740
|
};
|
|
68734
68741
|
}
|
|
68742
|
+
async function generateStaticRuntimes({ config }) {
|
|
68743
|
+
if (houdini_mode.is_testing) {
|
|
68744
|
+
return;
|
|
68745
|
+
}
|
|
68746
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
|
|
68747
|
+
await Promise.all(
|
|
68748
|
+
config.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
68749
|
+
const runtime_path = config.pluginStaticRuntimeSource(plugin2);
|
|
68750
|
+
if (!runtime_path) {
|
|
68751
|
+
return;
|
|
68752
|
+
}
|
|
68753
|
+
try {
|
|
68754
|
+
await stat(runtime_path);
|
|
68755
|
+
} catch {
|
|
68756
|
+
throw new HoudiniError({
|
|
68757
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
68758
|
+
description: "Maybe it was bundled?"
|
|
68759
|
+
});
|
|
68760
|
+
}
|
|
68761
|
+
const pluginDir = config.pluginStaticRuntimeDirectory(plugin2.name);
|
|
68762
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
68763
|
+
if (transformMap && typeof transformMap === "function") {
|
|
68764
|
+
transformMap = transformMap([], { config });
|
|
68765
|
+
}
|
|
68766
|
+
await mkdirp(pluginDir);
|
|
68767
|
+
await recursiveCopy(
|
|
68768
|
+
runtime_path,
|
|
68769
|
+
pluginDir,
|
|
68770
|
+
Object.fromEntries(
|
|
68771
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
68772
|
+
join(runtime_path, key),
|
|
68773
|
+
(content) => value({
|
|
68774
|
+
config,
|
|
68775
|
+
content,
|
|
68776
|
+
importStatement,
|
|
68777
|
+
exportDefaultStatement,
|
|
68778
|
+
exportStarStatement
|
|
68779
|
+
})
|
|
68780
|
+
])
|
|
68781
|
+
)
|
|
68782
|
+
);
|
|
68783
|
+
})
|
|
68784
|
+
);
|
|
68785
|
+
}
|
|
68735
68786
|
async function generatePluginRuntimes({
|
|
68736
68787
|
config,
|
|
68737
68788
|
docs
|
|
@@ -70333,6 +70384,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
70333
70384
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
70334
70385
|
});
|
|
70335
70386
|
}
|
|
70387
|
+
if (plugin2.staticRuntime) {
|
|
70388
|
+
body += exportStar({
|
|
70389
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
70390
|
+
});
|
|
70391
|
+
}
|
|
70336
70392
|
}
|
|
70337
70393
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
70338
70394
|
}
|
|
@@ -74250,6 +74306,7 @@ async function componentFields2(config, docs) {
|
|
|
74250
74306
|
|
|
74251
74307
|
// src/codegen/index.ts
|
|
74252
74308
|
async function compile(config) {
|
|
74309
|
+
await generateStaticRuntimes({ config });
|
|
74253
74310
|
const documents = await collectDocuments(config);
|
|
74254
74311
|
return await runPipeline2(config, documents);
|
|
74255
74312
|
}
|
package/build/lib/config.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare class Config {
|
|
|
36
36
|
routesDir: string;
|
|
37
37
|
schemaPollInterval: number | null;
|
|
38
38
|
schemaPollTimeout: number;
|
|
39
|
+
schemaPollWriteToDisk: boolean;
|
|
39
40
|
schemaPollHeaders: ((env: any) => Record<string, string>) | Record<string, string | ((env: any) => string)>;
|
|
40
41
|
pluginMode: boolean;
|
|
41
42
|
plugins: PluginMeta[];
|
|
@@ -58,6 +59,7 @@ export declare class Config {
|
|
|
58
59
|
processEnvValues(env: Record<string, string | undefined>, value: string | ((env: any) => string)): string | undefined;
|
|
59
60
|
pullHeaders(): Promise<any>;
|
|
60
61
|
pluginRuntimeSource(plugin: PluginMeta): string | null;
|
|
62
|
+
pluginStaticRuntimeSource(plugin: PluginMeta): string | null;
|
|
61
63
|
sourceFiles(): Promise<string[]>;
|
|
62
64
|
get componentScalar(): string;
|
|
63
65
|
schemaString: string;
|
|
@@ -99,6 +101,7 @@ export declare class Config {
|
|
|
99
101
|
ignore_plugins?: boolean;
|
|
100
102
|
}): boolean;
|
|
101
103
|
pluginRuntimeDirectory(name: string): string;
|
|
104
|
+
pluginStaticRuntimeDirectory(name: string): string;
|
|
102
105
|
get pluginRootDirectory(): string;
|
|
103
106
|
pluginDirectory(name: string): string;
|
|
104
107
|
get loadDirective(): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function pullSchema(url: string, fetchTimeout: number, schemaPath: string, headers?: Record<string, string>,
|
|
1
|
+
export declare function pullSchema(url: string, fetchTimeout: number, schemaPath: string, headers?: Record<string, string>, writeToDisk?: boolean): Promise<string | null>;
|
|
2
2
|
export declare function extractHeadersStr(str: string | undefined): Record<string, string>;
|
|
3
3
|
export declare function extractHeaders(headers?: string[] | undefined): {};
|
package/build/lib-cjs/index.js
CHANGED
|
@@ -72731,7 +72731,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
72731
72731
|
}
|
|
72732
72732
|
|
|
72733
72733
|
// src/lib/introspection.ts
|
|
72734
|
-
async function pullSchema(url, fetchTimeout, schemaPath, headers,
|
|
72734
|
+
async function pullSchema(url, fetchTimeout, schemaPath, headers, writeToDisk = true) {
|
|
72735
72735
|
let content = "";
|
|
72736
72736
|
try {
|
|
72737
72737
|
const fetchWithTimeout = (url2, timeoutMs, options) => {
|
|
@@ -72769,8 +72769,15 @@ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
|
|
|
72769
72769
|
} else {
|
|
72770
72770
|
fileData = JSON.stringify(jsonSchema);
|
|
72771
72771
|
}
|
|
72772
|
-
if (
|
|
72773
|
-
|
|
72772
|
+
if (writeToDisk) {
|
|
72773
|
+
try {
|
|
72774
|
+
await writeFile(schemaPath, fileData);
|
|
72775
|
+
} catch (e2) {
|
|
72776
|
+
console.warn(
|
|
72777
|
+
`\u26A0\uFE0F Couldn't write your pulled schema to disk: ${e2.message}
|
|
72778
|
+
If this is expected, please set watchSchema.writePolledSchema to false in your config file.`
|
|
72779
|
+
);
|
|
72780
|
+
}
|
|
72774
72781
|
}
|
|
72775
72782
|
return fileData;
|
|
72776
72783
|
} catch (e2) {
|
|
@@ -75371,20 +75378,21 @@ var CacheInternal = class {
|
|
|
75371
75378
|
} else if (Array.isArray(value) && // make typescript happy
|
|
75372
75379
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
75373
75380
|
let oldIDs = [...previousValue || []];
|
|
75374
|
-
|
|
75375
|
-
|
|
75376
|
-
|
|
75377
|
-
|
|
75378
|
-
|
|
75379
|
-
|
|
75380
|
-
|
|
75381
|
-
|
|
75382
|
-
|
|
75383
|
-
|
|
75384
|
-
|
|
75385
|
-
|
|
75386
|
-
|
|
75387
|
-
|
|
75381
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
75382
|
+
oldIDs = oldIDs.filter((id) => {
|
|
75383
|
+
for (const layer2 of this.storage.data) {
|
|
75384
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
75385
|
+
if (operation.fields?.[key])
|
|
75386
|
+
for (const listOperation of operation.fields[key]) {
|
|
75387
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
75388
|
+
return false;
|
|
75389
|
+
}
|
|
75390
|
+
}
|
|
75391
|
+
}
|
|
75392
|
+
}
|
|
75393
|
+
return true;
|
|
75394
|
+
});
|
|
75395
|
+
}
|
|
75388
75396
|
let linkedIDs = [];
|
|
75389
75397
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
75390
75398
|
value,
|
|
@@ -75403,39 +75411,45 @@ var CacheInternal = class {
|
|
|
75403
75411
|
layer.writeLink(parent, key, linkedIDs);
|
|
75404
75412
|
};
|
|
75405
75413
|
if (applyUpdates && updates) {
|
|
75406
|
-
|
|
75407
|
-
const
|
|
75408
|
-
for (const id of
|
|
75414
|
+
const filterIDs = (keep, insert) => {
|
|
75415
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
75416
|
+
for (const id of keep) {
|
|
75409
75417
|
if (!id) {
|
|
75410
75418
|
continue;
|
|
75411
75419
|
}
|
|
75412
75420
|
const { value: node } = this.storage.get(id, "node");
|
|
75413
|
-
if (
|
|
75421
|
+
if (!node) {
|
|
75414
75422
|
continue;
|
|
75415
75423
|
}
|
|
75416
|
-
|
|
75424
|
+
const nodeID = this.storage.get(node, "id");
|
|
75425
|
+
if (!nodeID) {
|
|
75417
75426
|
continue;
|
|
75418
75427
|
}
|
|
75419
|
-
|
|
75428
|
+
existingIDs.add(nodeID.value);
|
|
75420
75429
|
}
|
|
75421
|
-
|
|
75430
|
+
return insert.filter((id) => {
|
|
75422
75431
|
if (!id) {
|
|
75423
75432
|
return true;
|
|
75424
75433
|
}
|
|
75425
|
-
const { value:
|
|
75426
|
-
|
|
75427
|
-
|
|
75428
|
-
return false;
|
|
75434
|
+
const { value: node } = this.storage.get(id, "node");
|
|
75435
|
+
if (!node) {
|
|
75436
|
+
return true;
|
|
75429
75437
|
}
|
|
75430
|
-
|
|
75438
|
+
const nodeID = this.storage.get(node, "id");
|
|
75439
|
+
if (!nodeID) {
|
|
75440
|
+
return true;
|
|
75441
|
+
}
|
|
75442
|
+
return !existingIDs.has(nodeID.value);
|
|
75431
75443
|
});
|
|
75432
|
-
}
|
|
75444
|
+
};
|
|
75433
75445
|
for (const update of applyUpdates) {
|
|
75434
75446
|
if (update !== "replace" && !updates.includes(update)) {
|
|
75435
75447
|
continue;
|
|
75436
75448
|
}
|
|
75437
75449
|
if (update === "prepend") {
|
|
75438
|
-
linkedIDs = newIDs.concat(
|
|
75450
|
+
linkedIDs = newIDs.concat(
|
|
75451
|
+
filterIDs(newIDs, oldIDs)
|
|
75452
|
+
);
|
|
75439
75453
|
if (layer?.optimistic) {
|
|
75440
75454
|
action = () => {
|
|
75441
75455
|
for (const id of newIDs) {
|
|
@@ -75446,7 +75460,7 @@ var CacheInternal = class {
|
|
|
75446
75460
|
};
|
|
75447
75461
|
}
|
|
75448
75462
|
} else if (update === "append") {
|
|
75449
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
75463
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
75450
75464
|
if (layer?.optimistic) {
|
|
75451
75465
|
action = () => {
|
|
75452
75466
|
for (const id of newIDs) {
|
|
@@ -77838,6 +77852,7 @@ var Config = class {
|
|
|
77838
77852
|
routesDir;
|
|
77839
77853
|
schemaPollInterval;
|
|
77840
77854
|
schemaPollTimeout;
|
|
77855
|
+
schemaPollWriteToDisk = false;
|
|
77841
77856
|
schemaPollHeaders;
|
|
77842
77857
|
pluginMode = false;
|
|
77843
77858
|
plugins = [];
|
|
@@ -77914,6 +77929,7 @@ var Config = class {
|
|
|
77914
77929
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
77915
77930
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
77916
77931
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
77932
|
+
this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
|
|
77917
77933
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
77918
77934
|
this.rootDir = join2(this.projectRoot, this.runtimeDir);
|
|
77919
77935
|
this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
|
|
@@ -77946,11 +77962,17 @@ var Config = class {
|
|
|
77946
77962
|
const include = [`src/**/*{${extensions.join(",")}}`];
|
|
77947
77963
|
for (const plugin2 of this.plugins) {
|
|
77948
77964
|
const runtimeDir = this.pluginRuntimeSource(plugin2);
|
|
77949
|
-
|
|
77965
|
+
const staticDir = this.pluginStaticRuntimeSource(plugin2);
|
|
77966
|
+
if (!runtimeDir && !staticDir) {
|
|
77950
77967
|
continue;
|
|
77951
77968
|
}
|
|
77952
|
-
const
|
|
77953
|
-
|
|
77969
|
+
for (const dir of [runtimeDir, staticDir]) {
|
|
77970
|
+
if (!dir) {
|
|
77971
|
+
continue;
|
|
77972
|
+
}
|
|
77973
|
+
const includePath = relative(this.projectRoot, dir);
|
|
77974
|
+
include.push(`${includePath}/**/*{${extensions.join(",")}}`);
|
|
77975
|
+
}
|
|
77954
77976
|
}
|
|
77955
77977
|
return include;
|
|
77956
77978
|
}
|
|
@@ -78004,6 +78026,15 @@ var Config = class {
|
|
|
78004
78026
|
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
|
|
78005
78027
|
);
|
|
78006
78028
|
}
|
|
78029
|
+
pluginStaticRuntimeSource(plugin2) {
|
|
78030
|
+
if (!plugin2.staticRuntime) {
|
|
78031
|
+
return null;
|
|
78032
|
+
}
|
|
78033
|
+
return join2(
|
|
78034
|
+
dirname(plugin2.filepath),
|
|
78035
|
+
typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
|
|
78036
|
+
);
|
|
78037
|
+
}
|
|
78007
78038
|
async sourceFiles() {
|
|
78008
78039
|
return [
|
|
78009
78040
|
...new Set(
|
|
@@ -78200,6 +78231,9 @@ var Config = class {
|
|
|
78200
78231
|
pluginRuntimeDirectory(name) {
|
|
78201
78232
|
return join2(this.pluginDirectory(name), "runtime");
|
|
78202
78233
|
}
|
|
78234
|
+
pluginStaticRuntimeDirectory(name) {
|
|
78235
|
+
return join2(this.pluginDirectory(name), "static");
|
|
78236
|
+
}
|
|
78203
78237
|
get pluginRootDirectory() {
|
|
78204
78238
|
return houdini_mode.is_testing ? "../../../" : join2(this.rootDir, "plugins");
|
|
78205
78239
|
}
|
|
@@ -78577,17 +78611,20 @@ async function getConfig({
|
|
|
78577
78611
|
if (!_config.localSchema && _config.schemaPath && !_config.schema) {
|
|
78578
78612
|
let schemaOk = true;
|
|
78579
78613
|
if (apiURL) {
|
|
78580
|
-
if (glob2.hasMagic(_config.schemaPath)) {
|
|
78614
|
+
if (glob2.hasMagic(_config.schemaPath) && _config.schemaPollWriteToDisk) {
|
|
78581
78615
|
console.log(
|
|
78582
78616
|
`\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
|
|
78583
|
-
This will prevent your schema from being
|
|
78617
|
+
This will prevent your schema from being written to disk. If this is expected, please set the writePolledSchema value to false.`
|
|
78584
78618
|
);
|
|
78619
|
+
_config.schemaPollWriteToDisk = false;
|
|
78585
78620
|
} else if (!await readFile(_config.schemaPath)) {
|
|
78586
78621
|
console.log("\u231B Pulling schema from api");
|
|
78587
78622
|
schemaOk = await pullSchema(
|
|
78588
78623
|
apiURL,
|
|
78589
78624
|
_config.schemaPollTimeout,
|
|
78590
|
-
_config.schemaPath
|
|
78625
|
+
_config.schemaPath,
|
|
78626
|
+
{},
|
|
78627
|
+
_config.schemaPollWriteToDisk
|
|
78591
78628
|
) !== null;
|
|
78592
78629
|
}
|
|
78593
78630
|
}
|