houdini-svelte 1.2.6 → 1.2.8
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/plugin/kit.d.ts +6 -0
- package/build/plugin-cjs/index.js +83 -8
- package/build/plugin-esm/index.js +83 -8
- package/build/preprocess-cjs/index.js +10 -6
- package/build/preprocess-esm/index.js +10 -6
- package/build/test-cjs/index.js +184 -71
- package/build/test-esm/index.js +184 -71
- package/package.json +2 -2
package/build/plugin/kit.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare function is_root_layout(config: Config, filename: string): boolea
|
|
|
14
14
|
export declare function is_root_layout_server(config: Config, filename: string): boolean;
|
|
15
15
|
export declare function is_root_layout_script(config: Config, filename: string): boolean;
|
|
16
16
|
export declare function is_layout_component(framework: Framework, filename: string): boolean;
|
|
17
|
+
export declare function is_page_component(framework: Framework, filename: string): boolean;
|
|
17
18
|
export declare function is_layout(framework: Framework, filename: string): boolean;
|
|
18
19
|
export declare function is_component(config: Config, framework: Framework, filename: string): boolean;
|
|
19
20
|
export declare function page_query_path(config: Config, filename: string): string;
|
|
@@ -25,6 +26,7 @@ export type RouteVisitor = {
|
|
|
25
26
|
inlineLayoutQueries?: RouteVisitorHandler<graphql.OperationDefinitionNode>;
|
|
26
27
|
routePageQuery?: RouteVisitorHandler<graphql.OperationDefinitionNode>;
|
|
27
28
|
routeLayoutQuery?: RouteVisitorHandler<graphql.OperationDefinitionNode>;
|
|
29
|
+
routeComponentQuery?: RouteVisitorHandler<graphql.OperationDefinitionNode>;
|
|
28
30
|
layoutQueries?: RouteVisitorHandler<graphql.OperationDefinitionNode[]>;
|
|
29
31
|
pageQueries?: RouteVisitorHandler<graphql.OperationDefinitionNode[]>;
|
|
30
32
|
layoutExports?: RouteVisitorHandler<string[]>;
|
|
@@ -34,6 +36,10 @@ export type RouteVisitor = {
|
|
|
34
36
|
svelteTypeFilePath: string;
|
|
35
37
|
layoutQueries: graphql.OperationDefinitionNode[];
|
|
36
38
|
pageQueries: graphql.OperationDefinitionNode[];
|
|
39
|
+
componentQueries: {
|
|
40
|
+
query: graphql.OperationDefinitionNode;
|
|
41
|
+
componentPath: string;
|
|
42
|
+
}[];
|
|
37
43
|
layoutExports: string[];
|
|
38
44
|
pageExports: string[];
|
|
39
45
|
}>;
|
|
@@ -84573,11 +84573,11 @@ var require_esprima2 = __commonJS2({
|
|
|
84573
84573
|
case "}":
|
|
84574
84574
|
regex2 = false;
|
|
84575
84575
|
if (this.values[this.curly - 3] === "function") {
|
|
84576
|
-
var
|
|
84577
|
-
regex2 =
|
|
84576
|
+
var check = this.values[this.curly - 4];
|
|
84577
|
+
regex2 = check ? !this.beforeFunctionExpression(check) : false;
|
|
84578
84578
|
} else if (this.values[this.curly - 4] === "function") {
|
|
84579
|
-
var
|
|
84580
|
-
regex2 =
|
|
84579
|
+
var check = this.values[this.curly - 5];
|
|
84580
|
+
regex2 = check ? !this.beforeFunctionExpression(check) : true;
|
|
84581
84581
|
}
|
|
84582
84582
|
break;
|
|
84583
84583
|
default:
|
|
@@ -186350,6 +186350,9 @@ function is_root_layout_script(config4, filename) {
|
|
|
186350
186350
|
function is_layout_component(framework2, filename) {
|
|
186351
186351
|
return framework2 === "kit" && filename.endsWith("+layout.svelte");
|
|
186352
186352
|
}
|
|
186353
|
+
function is_page_component(framework2, filename) {
|
|
186354
|
+
return framework2 === "kit" && filename.endsWith("+page.svelte");
|
|
186355
|
+
}
|
|
186353
186356
|
function is_layout(framework2, filename) {
|
|
186354
186357
|
return is_layout_script(framework2, filename) || is_layout_component(framework2, filename);
|
|
186355
186358
|
}
|
|
@@ -186380,6 +186383,7 @@ async function walk_routes(config4, framework2, visitor, dirpath = config4.route
|
|
|
186380
186383
|
let layoutExports = [];
|
|
186381
186384
|
let pageQueries = [];
|
|
186382
186385
|
let layoutQueries = [];
|
|
186386
|
+
let componentQueries = [];
|
|
186383
186387
|
let validRoute = false;
|
|
186384
186388
|
for (const child of await fs_exports.readdir(dirpath)) {
|
|
186385
186389
|
const childPath = path_exports.join(dirpath, child);
|
|
@@ -186426,7 +186430,7 @@ async function walk_routes(config4, framework2, visitor, dirpath = config4.route
|
|
|
186426
186430
|
layoutQueries.push(definition);
|
|
186427
186431
|
}
|
|
186428
186432
|
});
|
|
186429
|
-
} else if (
|
|
186433
|
+
} else if (is_page_component(framework2, childPath)) {
|
|
186430
186434
|
validRoute = true;
|
|
186431
186435
|
const contents = await fs_exports.readFile(childPath);
|
|
186432
186436
|
if (!contents) {
|
|
@@ -186451,6 +186455,31 @@ async function walk_routes(config4, framework2, visitor, dirpath = config4.route
|
|
|
186451
186455
|
pageQueries.push(definition);
|
|
186452
186456
|
}
|
|
186453
186457
|
});
|
|
186458
|
+
} else if (is_component(config4, framework2, childPath)) {
|
|
186459
|
+
validRoute = true;
|
|
186460
|
+
const contents = await fs_exports.readFile(childPath);
|
|
186461
|
+
if (!contents) {
|
|
186462
|
+
continue;
|
|
186463
|
+
}
|
|
186464
|
+
const parsed = await parseSvelte(contents);
|
|
186465
|
+
if (!parsed) {
|
|
186466
|
+
continue;
|
|
186467
|
+
}
|
|
186468
|
+
const { script } = parsed;
|
|
186469
|
+
await find_graphql(config4, script, {
|
|
186470
|
+
where: (tag2) => {
|
|
186471
|
+
try {
|
|
186472
|
+
return !!config4.extractQueryDefinition(tag2);
|
|
186473
|
+
} catch {
|
|
186474
|
+
return false;
|
|
186475
|
+
}
|
|
186476
|
+
},
|
|
186477
|
+
tag: async ({ parsedDocument }) => {
|
|
186478
|
+
let definition = config4.extractQueryDefinition(parsedDocument);
|
|
186479
|
+
await visitor.routeComponentQuery?.(definition, childPath);
|
|
186480
|
+
componentQueries.push({ query: definition, componentPath: childPath });
|
|
186481
|
+
}
|
|
186482
|
+
});
|
|
186454
186483
|
} else if (child === plugin_config(config4).layoutQueryFilename) {
|
|
186455
186484
|
validRoute = true;
|
|
186456
186485
|
const contents = await fs_exports.readFile(childPath);
|
|
@@ -186500,6 +186529,7 @@ async function walk_routes(config4, framework2, visitor, dirpath = config4.route
|
|
|
186500
186529
|
svelteTypeFilePath,
|
|
186501
186530
|
layoutQueries,
|
|
186502
186531
|
pageQueries,
|
|
186532
|
+
componentQueries,
|
|
186503
186533
|
layoutExports,
|
|
186504
186534
|
pageExports
|
|
186505
186535
|
},
|
|
@@ -186897,6 +186927,7 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186897
186927
|
svelteTypeFilePath,
|
|
186898
186928
|
layoutQueries,
|
|
186899
186929
|
pageQueries,
|
|
186930
|
+
componentQueries,
|
|
186900
186931
|
layoutExports,
|
|
186901
186932
|
pageExports
|
|
186902
186933
|
}) {
|
|
@@ -186919,6 +186950,14 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186919
186950
|
uniqueLayoutQueries.push(layout);
|
|
186920
186951
|
}
|
|
186921
186952
|
}
|
|
186953
|
+
const componentNames = [];
|
|
186954
|
+
const uniqueComponentQueries = [];
|
|
186955
|
+
for (const component of componentQueries) {
|
|
186956
|
+
if (!componentNames.includes(component.query.name.value)) {
|
|
186957
|
+
componentNames.push(component.query.name.value);
|
|
186958
|
+
uniqueComponentQueries.push(component);
|
|
186959
|
+
}
|
|
186960
|
+
}
|
|
186922
186961
|
if (!config4.include.some((path3) => path3.includes("js")) && (!plugin_config(config4).static || uniquePageQueries.length > 0 || uniqueLayoutQueries.length > 0)) {
|
|
186923
186962
|
console.error(
|
|
186924
186963
|
`\u26A0\uFE0F You are using at least one page/layout query but aren't "include"ing .js files in your config.
|
|
@@ -186934,6 +186973,11 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186934
186973
|
config4,
|
|
186935
186974
|
uniqueLayoutQueries
|
|
186936
186975
|
);
|
|
186976
|
+
const componentQueryTypeImports = getComponentTypeImports(
|
|
186977
|
+
dirpath,
|
|
186978
|
+
config4,
|
|
186979
|
+
uniqueComponentQueries
|
|
186980
|
+
);
|
|
186937
186981
|
const beforePageLoad = pageExports.includes(houdini_before_load_fn);
|
|
186938
186982
|
const afterPageLoad = pageExports.includes(houdini_afterLoad_fn);
|
|
186939
186983
|
const onPageError = pageExports.includes(houdini_on_error_fn);
|
|
@@ -186952,6 +186996,11 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186952
186996
|
config4,
|
|
186953
186997
|
uniquePageQueries
|
|
186954
186998
|
);
|
|
186999
|
+
const component_append_VariablesFunction = append_ComponentVariablesFunction(
|
|
187000
|
+
dirpath,
|
|
187001
|
+
config4,
|
|
187002
|
+
uniqueComponentQueries
|
|
187003
|
+
);
|
|
186955
187004
|
const layout_append_beforeLoad = append_beforeLoad(beforeLayoutLoad, "Layout");
|
|
186956
187005
|
const page_append_beforeLoad = append_beforeLoad(beforePageLoad, "Page");
|
|
186957
187006
|
const layout_append_afterLoad = append_afterLoad(
|
|
@@ -186992,11 +187041,11 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186992
187041
|
import type { ${functionImportsToBring.join(
|
|
186993
187042
|
", "
|
|
186994
187043
|
)} } from '${houdiniRelative}/plugins/houdini-svelte/runtime/types';` : "";
|
|
186995
|
-
typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports);
|
|
187044
|
+
typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports).concat(componentQueryTypeImports);
|
|
186996
187045
|
const layoutParams = `${layoutQueries.length > 0 && !utilityTypes.includes("LayoutParams") ? "\ntype LayoutParams = LayoutLoadEvent['params'];" : ""}`;
|
|
186997
187046
|
const pageParams = `${pageQueries.length > 0 && !utilityTypes.includes("PageParams") ? "\ntype PageParams = PageLoadEvent['params'];" : ""}`;
|
|
186998
187047
|
utilityTypes = utilityTypes.concat(layoutParams).concat(pageParams).replaceAll(/\$types\.js/gm, "$houdini");
|
|
186999
|
-
typeExports = typeExports.concat(append_loadInput([...layoutQueries, ...pageQueries])).concat(layout_append_beforeLoad).concat(page_append_beforeLoad).concat(layout_append_afterLoad).concat(page_append_afterLoad).concat(layout_append_onError).concat(page_append_onError).concat(layout_append_VariablesFunction).concat(page_append_VariablesFunction).replace(
|
|
187048
|
+
typeExports = typeExports.concat(append_loadInput([...layoutQueries, ...pageQueries])).concat(layout_append_beforeLoad).concat(page_append_beforeLoad).concat(layout_append_afterLoad).concat(page_append_afterLoad).concat(layout_append_onError).concat(page_append_onError).concat(layout_append_VariablesFunction).concat(page_append_VariablesFunction).concat(component_append_VariablesFunction).replace(
|
|
187000
187049
|
/(?<=LayoutData = )([\s\S]*?)(?=;)/,
|
|
187001
187050
|
`Expand<$1 & { ${layoutQueries.map((query3) => {
|
|
187002
187051
|
const name = query3.name.value;
|
|
@@ -187041,6 +187090,20 @@ import { ${name}$result, ${name}$input } from '${houdiniRelative}/${config4.arti
|
|
|
187041
187090
|
import { ${name}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name}';`;
|
|
187042
187091
|
}).join("\n");
|
|
187043
187092
|
}
|
|
187093
|
+
function getComponentTypeImports(dirpath, config4, queries) {
|
|
187094
|
+
if (queries.length === 0) {
|
|
187095
|
+
return "";
|
|
187096
|
+
}
|
|
187097
|
+
let typeFile = "\nimport type { ComponentProps } from 'svelte'\n";
|
|
187098
|
+
return typeFile + queries.map((query3) => {
|
|
187099
|
+
const no_ext = path_exports.parse(query3.componentPath).name;
|
|
187100
|
+
const file = path_exports.parse(query3.componentPath);
|
|
187101
|
+
return `
|
|
187102
|
+
import ${no_ext} from './${file.base}'
|
|
187103
|
+
import type { ${query3.query.name.value}$input } from '${path_exports.relative(dirpath, path_exports.join(config4.artifactDirectory, query3.query.name.value)).replace("/$houdini", "")}'
|
|
187104
|
+
`;
|
|
187105
|
+
}).join("\n");
|
|
187106
|
+
}
|
|
187044
187107
|
function append_VariablesFunction(type, filepath, config4, queries) {
|
|
187045
187108
|
const { params } = route_params(filepath);
|
|
187046
187109
|
const garunteed_args = params.filter((param) => !param.optional).map((param) => param.name);
|
|
@@ -187065,6 +187128,18 @@ export type ${config4.variableFunctionName(
|
|
|
187065
187128
|
)} = VariableFunction<${type}Params, ${input_type}>;`;
|
|
187066
187129
|
}).join("\n");
|
|
187067
187130
|
}
|
|
187131
|
+
function append_ComponentVariablesFunction(filepath, config4, queries) {
|
|
187132
|
+
return queries.map((query3) => {
|
|
187133
|
+
const no_ext = path_exports.parse(query3.componentPath).name;
|
|
187134
|
+
const prop_type = no_ext + "Props";
|
|
187135
|
+
return `
|
|
187136
|
+
type ${prop_type} = ComponentProps<${no_ext}>
|
|
187137
|
+
export type ${config4.variableFunctionName(
|
|
187138
|
+
query3.query.name.value
|
|
187139
|
+
)} = <_Props extends ${prop_type}>(args: { props: _Props }) => ${query3.query.name.value}$input
|
|
187140
|
+
`;
|
|
187141
|
+
}).join("\n");
|
|
187142
|
+
}
|
|
187068
187143
|
function append_loadInput(queries) {
|
|
187069
187144
|
return `${queries.filter((q) => q.variableDefinitions?.length).length ? `
|
|
187070
187145
|
type LoadInput = { ${queries.filter((query3) => query3.variableDefinitions?.length).map((query3) => {
|
|
@@ -188549,7 +188624,7 @@ export const redirect = svelteKitRedirect
|
|
|
188549
188624
|
schema({ config: config4 }) {
|
|
188550
188625
|
return `
|
|
188551
188626
|
"""
|
|
188552
|
-
@${config4.loadDirective} is used to
|
|
188627
|
+
@${config4.loadDirective} is used to enable automatic fetch on inline queries.
|
|
188553
188628
|
"""
|
|
188554
188629
|
directive @${config4.loadDirective} on QUERY
|
|
188555
188630
|
|
|
@@ -84564,11 +84564,11 @@ var require_esprima2 = __commonJS2({
|
|
|
84564
84564
|
case "}":
|
|
84565
84565
|
regex2 = false;
|
|
84566
84566
|
if (this.values[this.curly - 3] === "function") {
|
|
84567
|
-
var
|
|
84568
|
-
regex2 =
|
|
84567
|
+
var check = this.values[this.curly - 4];
|
|
84568
|
+
regex2 = check ? !this.beforeFunctionExpression(check) : false;
|
|
84569
84569
|
} else if (this.values[this.curly - 4] === "function") {
|
|
84570
|
-
var
|
|
84571
|
-
regex2 =
|
|
84570
|
+
var check = this.values[this.curly - 5];
|
|
84571
|
+
regex2 = check ? !this.beforeFunctionExpression(check) : true;
|
|
84572
84572
|
}
|
|
84573
84573
|
break;
|
|
84574
84574
|
default:
|
|
@@ -186340,6 +186340,9 @@ function is_root_layout_script(config4, filename) {
|
|
|
186340
186340
|
function is_layout_component(framework2, filename) {
|
|
186341
186341
|
return framework2 === "kit" && filename.endsWith("+layout.svelte");
|
|
186342
186342
|
}
|
|
186343
|
+
function is_page_component(framework2, filename) {
|
|
186344
|
+
return framework2 === "kit" && filename.endsWith("+page.svelte");
|
|
186345
|
+
}
|
|
186343
186346
|
function is_layout(framework2, filename) {
|
|
186344
186347
|
return is_layout_script(framework2, filename) || is_layout_component(framework2, filename);
|
|
186345
186348
|
}
|
|
@@ -186370,6 +186373,7 @@ async function walk_routes(config4, framework2, visitor, dirpath = config4.route
|
|
|
186370
186373
|
let layoutExports = [];
|
|
186371
186374
|
let pageQueries = [];
|
|
186372
186375
|
let layoutQueries = [];
|
|
186376
|
+
let componentQueries = [];
|
|
186373
186377
|
let validRoute = false;
|
|
186374
186378
|
for (const child of await fs_exports.readdir(dirpath)) {
|
|
186375
186379
|
const childPath = path_exports.join(dirpath, child);
|
|
@@ -186416,7 +186420,7 @@ async function walk_routes(config4, framework2, visitor, dirpath = config4.route
|
|
|
186416
186420
|
layoutQueries.push(definition);
|
|
186417
186421
|
}
|
|
186418
186422
|
});
|
|
186419
|
-
} else if (
|
|
186423
|
+
} else if (is_page_component(framework2, childPath)) {
|
|
186420
186424
|
validRoute = true;
|
|
186421
186425
|
const contents = await fs_exports.readFile(childPath);
|
|
186422
186426
|
if (!contents) {
|
|
@@ -186441,6 +186445,31 @@ async function walk_routes(config4, framework2, visitor, dirpath = config4.route
|
|
|
186441
186445
|
pageQueries.push(definition);
|
|
186442
186446
|
}
|
|
186443
186447
|
});
|
|
186448
|
+
} else if (is_component(config4, framework2, childPath)) {
|
|
186449
|
+
validRoute = true;
|
|
186450
|
+
const contents = await fs_exports.readFile(childPath);
|
|
186451
|
+
if (!contents) {
|
|
186452
|
+
continue;
|
|
186453
|
+
}
|
|
186454
|
+
const parsed = await parseSvelte(contents);
|
|
186455
|
+
if (!parsed) {
|
|
186456
|
+
continue;
|
|
186457
|
+
}
|
|
186458
|
+
const { script } = parsed;
|
|
186459
|
+
await find_graphql(config4, script, {
|
|
186460
|
+
where: (tag2) => {
|
|
186461
|
+
try {
|
|
186462
|
+
return !!config4.extractQueryDefinition(tag2);
|
|
186463
|
+
} catch {
|
|
186464
|
+
return false;
|
|
186465
|
+
}
|
|
186466
|
+
},
|
|
186467
|
+
tag: async ({ parsedDocument }) => {
|
|
186468
|
+
let definition = config4.extractQueryDefinition(parsedDocument);
|
|
186469
|
+
await visitor.routeComponentQuery?.(definition, childPath);
|
|
186470
|
+
componentQueries.push({ query: definition, componentPath: childPath });
|
|
186471
|
+
}
|
|
186472
|
+
});
|
|
186444
186473
|
} else if (child === plugin_config(config4).layoutQueryFilename) {
|
|
186445
186474
|
validRoute = true;
|
|
186446
186475
|
const contents = await fs_exports.readFile(childPath);
|
|
@@ -186490,6 +186519,7 @@ async function walk_routes(config4, framework2, visitor, dirpath = config4.route
|
|
|
186490
186519
|
svelteTypeFilePath,
|
|
186491
186520
|
layoutQueries,
|
|
186492
186521
|
pageQueries,
|
|
186522
|
+
componentQueries,
|
|
186493
186523
|
layoutExports,
|
|
186494
186524
|
pageExports
|
|
186495
186525
|
},
|
|
@@ -186887,6 +186917,7 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186887
186917
|
svelteTypeFilePath,
|
|
186888
186918
|
layoutQueries,
|
|
186889
186919
|
pageQueries,
|
|
186920
|
+
componentQueries,
|
|
186890
186921
|
layoutExports,
|
|
186891
186922
|
pageExports
|
|
186892
186923
|
}) {
|
|
@@ -186909,6 +186940,14 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186909
186940
|
uniqueLayoutQueries.push(layout);
|
|
186910
186941
|
}
|
|
186911
186942
|
}
|
|
186943
|
+
const componentNames = [];
|
|
186944
|
+
const uniqueComponentQueries = [];
|
|
186945
|
+
for (const component of componentQueries) {
|
|
186946
|
+
if (!componentNames.includes(component.query.name.value)) {
|
|
186947
|
+
componentNames.push(component.query.name.value);
|
|
186948
|
+
uniqueComponentQueries.push(component);
|
|
186949
|
+
}
|
|
186950
|
+
}
|
|
186912
186951
|
if (!config4.include.some((path3) => path3.includes("js")) && (!plugin_config(config4).static || uniquePageQueries.length > 0 || uniqueLayoutQueries.length > 0)) {
|
|
186913
186952
|
console.error(
|
|
186914
186953
|
`\u26A0\uFE0F You are using at least one page/layout query but aren't "include"ing .js files in your config.
|
|
@@ -186924,6 +186963,11 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186924
186963
|
config4,
|
|
186925
186964
|
uniqueLayoutQueries
|
|
186926
186965
|
);
|
|
186966
|
+
const componentQueryTypeImports = getComponentTypeImports(
|
|
186967
|
+
dirpath,
|
|
186968
|
+
config4,
|
|
186969
|
+
uniqueComponentQueries
|
|
186970
|
+
);
|
|
186927
186971
|
const beforePageLoad = pageExports.includes(houdini_before_load_fn);
|
|
186928
186972
|
const afterPageLoad = pageExports.includes(houdini_afterLoad_fn);
|
|
186929
186973
|
const onPageError = pageExports.includes(houdini_on_error_fn);
|
|
@@ -186942,6 +186986,11 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186942
186986
|
config4,
|
|
186943
186987
|
uniquePageQueries
|
|
186944
186988
|
);
|
|
186989
|
+
const component_append_VariablesFunction = append_ComponentVariablesFunction(
|
|
186990
|
+
dirpath,
|
|
186991
|
+
config4,
|
|
186992
|
+
uniqueComponentQueries
|
|
186993
|
+
);
|
|
186945
186994
|
const layout_append_beforeLoad = append_beforeLoad(beforeLayoutLoad, "Layout");
|
|
186946
186995
|
const page_append_beforeLoad = append_beforeLoad(beforePageLoad, "Page");
|
|
186947
186996
|
const layout_append_afterLoad = append_afterLoad(
|
|
@@ -186982,11 +187031,11 @@ async function svelteKitGenerator(framework2, { config: config4 }) {
|
|
|
186982
187031
|
import type { ${functionImportsToBring.join(
|
|
186983
187032
|
", "
|
|
186984
187033
|
)} } from '${houdiniRelative}/plugins/houdini-svelte/runtime/types';` : "";
|
|
186985
|
-
typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports);
|
|
187034
|
+
typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports).concat(componentQueryTypeImports);
|
|
186986
187035
|
const layoutParams = `${layoutQueries.length > 0 && !utilityTypes.includes("LayoutParams") ? "\ntype LayoutParams = LayoutLoadEvent['params'];" : ""}`;
|
|
186987
187036
|
const pageParams = `${pageQueries.length > 0 && !utilityTypes.includes("PageParams") ? "\ntype PageParams = PageLoadEvent['params'];" : ""}`;
|
|
186988
187037
|
utilityTypes = utilityTypes.concat(layoutParams).concat(pageParams).replaceAll(/\$types\.js/gm, "$houdini");
|
|
186989
|
-
typeExports = typeExports.concat(append_loadInput([...layoutQueries, ...pageQueries])).concat(layout_append_beforeLoad).concat(page_append_beforeLoad).concat(layout_append_afterLoad).concat(page_append_afterLoad).concat(layout_append_onError).concat(page_append_onError).concat(layout_append_VariablesFunction).concat(page_append_VariablesFunction).replace(
|
|
187038
|
+
typeExports = typeExports.concat(append_loadInput([...layoutQueries, ...pageQueries])).concat(layout_append_beforeLoad).concat(page_append_beforeLoad).concat(layout_append_afterLoad).concat(page_append_afterLoad).concat(layout_append_onError).concat(page_append_onError).concat(layout_append_VariablesFunction).concat(page_append_VariablesFunction).concat(component_append_VariablesFunction).replace(
|
|
186990
187039
|
/(?<=LayoutData = )([\s\S]*?)(?=;)/,
|
|
186991
187040
|
`Expand<$1 & { ${layoutQueries.map((query3) => {
|
|
186992
187041
|
const name = query3.name.value;
|
|
@@ -187031,6 +187080,20 @@ import { ${name}$result, ${name}$input } from '${houdiniRelative}/${config4.arti
|
|
|
187031
187080
|
import { ${name}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name}';`;
|
|
187032
187081
|
}).join("\n");
|
|
187033
187082
|
}
|
|
187083
|
+
function getComponentTypeImports(dirpath, config4, queries) {
|
|
187084
|
+
if (queries.length === 0) {
|
|
187085
|
+
return "";
|
|
187086
|
+
}
|
|
187087
|
+
let typeFile = "\nimport type { ComponentProps } from 'svelte'\n";
|
|
187088
|
+
return typeFile + queries.map((query3) => {
|
|
187089
|
+
const no_ext = path_exports.parse(query3.componentPath).name;
|
|
187090
|
+
const file = path_exports.parse(query3.componentPath);
|
|
187091
|
+
return `
|
|
187092
|
+
import ${no_ext} from './${file.base}'
|
|
187093
|
+
import type { ${query3.query.name.value}$input } from '${path_exports.relative(dirpath, path_exports.join(config4.artifactDirectory, query3.query.name.value)).replace("/$houdini", "")}'
|
|
187094
|
+
`;
|
|
187095
|
+
}).join("\n");
|
|
187096
|
+
}
|
|
187034
187097
|
function append_VariablesFunction(type, filepath, config4, queries) {
|
|
187035
187098
|
const { params } = route_params(filepath);
|
|
187036
187099
|
const garunteed_args = params.filter((param) => !param.optional).map((param) => param.name);
|
|
@@ -187055,6 +187118,18 @@ export type ${config4.variableFunctionName(
|
|
|
187055
187118
|
)} = VariableFunction<${type}Params, ${input_type}>;`;
|
|
187056
187119
|
}).join("\n");
|
|
187057
187120
|
}
|
|
187121
|
+
function append_ComponentVariablesFunction(filepath, config4, queries) {
|
|
187122
|
+
return queries.map((query3) => {
|
|
187123
|
+
const no_ext = path_exports.parse(query3.componentPath).name;
|
|
187124
|
+
const prop_type = no_ext + "Props";
|
|
187125
|
+
return `
|
|
187126
|
+
type ${prop_type} = ComponentProps<${no_ext}>
|
|
187127
|
+
export type ${config4.variableFunctionName(
|
|
187128
|
+
query3.query.name.value
|
|
187129
|
+
)} = <_Props extends ${prop_type}>(args: { props: _Props }) => ${query3.query.name.value}$input
|
|
187130
|
+
`;
|
|
187131
|
+
}).join("\n");
|
|
187132
|
+
}
|
|
187058
187133
|
function append_loadInput(queries) {
|
|
187059
187134
|
return `${queries.filter((q) => q.variableDefinitions?.length).length ? `
|
|
187060
187135
|
type LoadInput = { ${queries.filter((query3) => query3.variableDefinitions?.length).map((query3) => {
|
|
@@ -188539,7 +188614,7 @@ export const redirect = svelteKitRedirect
|
|
|
188539
188614
|
schema({ config: config4 }) {
|
|
188540
188615
|
return `
|
|
188541
188616
|
"""
|
|
188542
|
-
@${config4.loadDirective} is used to
|
|
188617
|
+
@${config4.loadDirective} is used to enable automatic fetch on inline queries.
|
|
188543
188618
|
"""
|
|
188544
188619
|
directive @${config4.loadDirective} on QUERY
|
|
188545
188620
|
|
|
@@ -84577,11 +84577,11 @@ var require_esprima2 = __commonJS2({
|
|
|
84577
84577
|
case "}":
|
|
84578
84578
|
regex2 = false;
|
|
84579
84579
|
if (this.values[this.curly - 3] === "function") {
|
|
84580
|
-
var
|
|
84581
|
-
regex2 =
|
|
84580
|
+
var check = this.values[this.curly - 4];
|
|
84581
|
+
regex2 = check ? !this.beforeFunctionExpression(check) : false;
|
|
84582
84582
|
} else if (this.values[this.curly - 4] === "function") {
|
|
84583
|
-
var
|
|
84584
|
-
regex2 =
|
|
84583
|
+
var check = this.values[this.curly - 5];
|
|
84584
|
+
regex2 = check ? !this.beforeFunctionExpression(check) : true;
|
|
84585
84585
|
}
|
|
84586
84586
|
break;
|
|
84587
84587
|
default:
|
|
@@ -96024,7 +96024,7 @@ var Config = class {
|
|
|
96024
96024
|
projectRoot;
|
|
96025
96025
|
schema;
|
|
96026
96026
|
schemaPath;
|
|
96027
|
-
|
|
96027
|
+
persistedQueriesPath = "./$houdini/persisted_queries.json";
|
|
96028
96028
|
exclude;
|
|
96029
96029
|
scalars;
|
|
96030
96030
|
module = "esm";
|
|
@@ -96076,7 +96076,8 @@ var Config = class {
|
|
|
96076
96076
|
logLevel,
|
|
96077
96077
|
defaultFragmentMasking = "enable",
|
|
96078
96078
|
watchSchema,
|
|
96079
|
-
projectDir
|
|
96079
|
+
projectDir,
|
|
96080
|
+
persistedQueriesPath
|
|
96080
96081
|
} = this.configFile;
|
|
96081
96082
|
if (typeof schema === "string") {
|
|
96082
96083
|
this.schema = graphql2.buildSchema(schema);
|
|
@@ -96113,6 +96114,9 @@ var Config = class {
|
|
|
96113
96114
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
96114
96115
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
96115
96116
|
this.#fragmentVariableMaps = {};
|
|
96117
|
+
if (persistedQueriesPath) {
|
|
96118
|
+
this.persistedQueriesPath = persistedQueriesPath;
|
|
96119
|
+
}
|
|
96116
96120
|
if (defaultKeys) {
|
|
96117
96121
|
this.defaultKeys = defaultKeys;
|
|
96118
96122
|
}
|
|
@@ -84570,11 +84570,11 @@ var require_esprima2 = __commonJS2({
|
|
|
84570
84570
|
case "}":
|
|
84571
84571
|
regex2 = false;
|
|
84572
84572
|
if (this.values[this.curly - 3] === "function") {
|
|
84573
|
-
var
|
|
84574
|
-
regex2 =
|
|
84573
|
+
var check = this.values[this.curly - 4];
|
|
84574
|
+
regex2 = check ? !this.beforeFunctionExpression(check) : false;
|
|
84575
84575
|
} else if (this.values[this.curly - 4] === "function") {
|
|
84576
|
-
var
|
|
84577
|
-
regex2 =
|
|
84576
|
+
var check = this.values[this.curly - 5];
|
|
84577
|
+
regex2 = check ? !this.beforeFunctionExpression(check) : true;
|
|
84578
84578
|
}
|
|
84579
84579
|
break;
|
|
84580
84580
|
default:
|
|
@@ -96017,7 +96017,7 @@ var Config = class {
|
|
|
96017
96017
|
projectRoot;
|
|
96018
96018
|
schema;
|
|
96019
96019
|
schemaPath;
|
|
96020
|
-
|
|
96020
|
+
persistedQueriesPath = "./$houdini/persisted_queries.json";
|
|
96021
96021
|
exclude;
|
|
96022
96022
|
scalars;
|
|
96023
96023
|
module = "esm";
|
|
@@ -96069,7 +96069,8 @@ var Config = class {
|
|
|
96069
96069
|
logLevel,
|
|
96070
96070
|
defaultFragmentMasking = "enable",
|
|
96071
96071
|
watchSchema,
|
|
96072
|
-
projectDir
|
|
96072
|
+
projectDir,
|
|
96073
|
+
persistedQueriesPath
|
|
96073
96074
|
} = this.configFile;
|
|
96074
96075
|
if (typeof schema === "string") {
|
|
96075
96076
|
this.schema = graphql2.buildSchema(schema);
|
|
@@ -96106,6 +96107,9 @@ var Config = class {
|
|
|
96106
96107
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
96107
96108
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
96108
96109
|
this.#fragmentVariableMaps = {};
|
|
96110
|
+
if (persistedQueriesPath) {
|
|
96111
|
+
this.persistedQueriesPath = persistedQueriesPath;
|
|
96112
|
+
}
|
|
96109
96113
|
if (defaultKeys) {
|
|
96110
96114
|
this.defaultKeys = defaultKeys;
|
|
96111
96115
|
}
|