houdini-svelte 1.2.7 → 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 +78 -3
- package/build/plugin-esm/index.js +78 -3
- package/build/test-cjs/index.js +78 -3
- package/build/test-esm/index.js +78 -3
- 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
|
}>;
|
|
@@ -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) => {
|
|
@@ -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) => {
|
package/build/test-cjs/index.js
CHANGED
|
@@ -306242,6 +306242,9 @@ function is_root_layout_script(config5, filename) {
|
|
|
306242
306242
|
function is_layout_component(framework2, filename) {
|
|
306243
306243
|
return framework2 === "kit" && filename.endsWith("+layout.svelte");
|
|
306244
306244
|
}
|
|
306245
|
+
function is_page_component(framework2, filename) {
|
|
306246
|
+
return framework2 === "kit" && filename.endsWith("+page.svelte");
|
|
306247
|
+
}
|
|
306245
306248
|
function is_layout(framework2, filename) {
|
|
306246
306249
|
return is_layout_script(framework2, filename) || is_layout_component(framework2, filename);
|
|
306247
306250
|
}
|
|
@@ -306272,6 +306275,7 @@ async function walk_routes(config5, framework2, visitor, dirpath = config5.route
|
|
|
306272
306275
|
let layoutExports = [];
|
|
306273
306276
|
let pageQueries = [];
|
|
306274
306277
|
let layoutQueries = [];
|
|
306278
|
+
let componentQueries = [];
|
|
306275
306279
|
let validRoute = false;
|
|
306276
306280
|
for (const child of await fs_exports.readdir(dirpath)) {
|
|
306277
306281
|
const childPath = path_exports.join(dirpath, child);
|
|
@@ -306318,7 +306322,7 @@ async function walk_routes(config5, framework2, visitor, dirpath = config5.route
|
|
|
306318
306322
|
layoutQueries.push(definition);
|
|
306319
306323
|
}
|
|
306320
306324
|
});
|
|
306321
|
-
} else if (
|
|
306325
|
+
} else if (is_page_component(framework2, childPath)) {
|
|
306322
306326
|
validRoute = true;
|
|
306323
306327
|
const contents = await fs_exports.readFile(childPath);
|
|
306324
306328
|
if (!contents) {
|
|
@@ -306343,6 +306347,31 @@ async function walk_routes(config5, framework2, visitor, dirpath = config5.route
|
|
|
306343
306347
|
pageQueries.push(definition);
|
|
306344
306348
|
}
|
|
306345
306349
|
});
|
|
306350
|
+
} else if (is_component(config5, framework2, childPath)) {
|
|
306351
|
+
validRoute = true;
|
|
306352
|
+
const contents = await fs_exports.readFile(childPath);
|
|
306353
|
+
if (!contents) {
|
|
306354
|
+
continue;
|
|
306355
|
+
}
|
|
306356
|
+
const parsed = await parseSvelte(contents);
|
|
306357
|
+
if (!parsed) {
|
|
306358
|
+
continue;
|
|
306359
|
+
}
|
|
306360
|
+
const { script } = parsed;
|
|
306361
|
+
await find_graphql(config5, script, {
|
|
306362
|
+
where: (tag2) => {
|
|
306363
|
+
try {
|
|
306364
|
+
return !!config5.extractQueryDefinition(tag2);
|
|
306365
|
+
} catch {
|
|
306366
|
+
return false;
|
|
306367
|
+
}
|
|
306368
|
+
},
|
|
306369
|
+
tag: async ({ parsedDocument }) => {
|
|
306370
|
+
let definition = config5.extractQueryDefinition(parsedDocument);
|
|
306371
|
+
await visitor.routeComponentQuery?.(definition, childPath);
|
|
306372
|
+
componentQueries.push({ query: definition, componentPath: childPath });
|
|
306373
|
+
}
|
|
306374
|
+
});
|
|
306346
306375
|
} else if (child === plugin_config(config5).layoutQueryFilename) {
|
|
306347
306376
|
validRoute = true;
|
|
306348
306377
|
const contents = await fs_exports.readFile(childPath);
|
|
@@ -306392,6 +306421,7 @@ async function walk_routes(config5, framework2, visitor, dirpath = config5.route
|
|
|
306392
306421
|
svelteTypeFilePath,
|
|
306393
306422
|
layoutQueries,
|
|
306394
306423
|
pageQueries,
|
|
306424
|
+
componentQueries,
|
|
306395
306425
|
layoutExports,
|
|
306396
306426
|
pageExports
|
|
306397
306427
|
},
|
|
@@ -306789,6 +306819,7 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306789
306819
|
svelteTypeFilePath,
|
|
306790
306820
|
layoutQueries,
|
|
306791
306821
|
pageQueries,
|
|
306822
|
+
componentQueries,
|
|
306792
306823
|
layoutExports,
|
|
306793
306824
|
pageExports
|
|
306794
306825
|
}) {
|
|
@@ -306811,6 +306842,14 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306811
306842
|
uniqueLayoutQueries.push(layout);
|
|
306812
306843
|
}
|
|
306813
306844
|
}
|
|
306845
|
+
const componentNames = [];
|
|
306846
|
+
const uniqueComponentQueries = [];
|
|
306847
|
+
for (const component of componentQueries) {
|
|
306848
|
+
if (!componentNames.includes(component.query.name.value)) {
|
|
306849
|
+
componentNames.push(component.query.name.value);
|
|
306850
|
+
uniqueComponentQueries.push(component);
|
|
306851
|
+
}
|
|
306852
|
+
}
|
|
306814
306853
|
if (!config5.include.some((path5) => path5.includes("js")) && (!plugin_config(config5).static || uniquePageQueries.length > 0 || uniqueLayoutQueries.length > 0)) {
|
|
306815
306854
|
console.error(
|
|
306816
306855
|
`\u26A0\uFE0F You are using at least one page/layout query but aren't "include"ing .js files in your config.
|
|
@@ -306826,6 +306865,11 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306826
306865
|
config5,
|
|
306827
306866
|
uniqueLayoutQueries
|
|
306828
306867
|
);
|
|
306868
|
+
const componentQueryTypeImports = getComponentTypeImports(
|
|
306869
|
+
dirpath,
|
|
306870
|
+
config5,
|
|
306871
|
+
uniqueComponentQueries
|
|
306872
|
+
);
|
|
306829
306873
|
const beforePageLoad = pageExports.includes(houdini_before_load_fn);
|
|
306830
306874
|
const afterPageLoad = pageExports.includes(houdini_afterLoad_fn);
|
|
306831
306875
|
const onPageError = pageExports.includes(houdini_on_error_fn);
|
|
@@ -306844,6 +306888,11 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306844
306888
|
config5,
|
|
306845
306889
|
uniquePageQueries
|
|
306846
306890
|
);
|
|
306891
|
+
const component_append_VariablesFunction = append_ComponentVariablesFunction(
|
|
306892
|
+
dirpath,
|
|
306893
|
+
config5,
|
|
306894
|
+
uniqueComponentQueries
|
|
306895
|
+
);
|
|
306847
306896
|
const layout_append_beforeLoad = append_beforeLoad(beforeLayoutLoad, "Layout");
|
|
306848
306897
|
const page_append_beforeLoad = append_beforeLoad(beforePageLoad, "Page");
|
|
306849
306898
|
const layout_append_afterLoad = append_afterLoad(
|
|
@@ -306884,11 +306933,11 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306884
306933
|
import type { ${functionImportsToBring.join(
|
|
306885
306934
|
", "
|
|
306886
306935
|
)} } from '${houdiniRelative}/plugins/houdini-svelte/runtime/types';` : "";
|
|
306887
|
-
typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports);
|
|
306936
|
+
typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports).concat(componentQueryTypeImports);
|
|
306888
306937
|
const layoutParams = `${layoutQueries.length > 0 && !utilityTypes.includes("LayoutParams") ? "\ntype LayoutParams = LayoutLoadEvent['params'];" : ""}`;
|
|
306889
306938
|
const pageParams = `${pageQueries.length > 0 && !utilityTypes.includes("PageParams") ? "\ntype PageParams = PageLoadEvent['params'];" : ""}`;
|
|
306890
306939
|
utilityTypes = utilityTypes.concat(layoutParams).concat(pageParams).replaceAll(/\$types\.js/gm, "$houdini");
|
|
306891
|
-
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(
|
|
306940
|
+
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(
|
|
306892
306941
|
/(?<=LayoutData = )([\s\S]*?)(?=;)/,
|
|
306893
306942
|
`Expand<$1 & { ${layoutQueries.map((query5) => {
|
|
306894
306943
|
const name = query5.name.value;
|
|
@@ -306933,6 +306982,20 @@ import { ${name}$result, ${name}$input } from '${houdiniRelative}/${config5.arti
|
|
|
306933
306982
|
import { ${name}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name}';`;
|
|
306934
306983
|
}).join("\n");
|
|
306935
306984
|
}
|
|
306985
|
+
function getComponentTypeImports(dirpath, config5, queries) {
|
|
306986
|
+
if (queries.length === 0) {
|
|
306987
|
+
return "";
|
|
306988
|
+
}
|
|
306989
|
+
let typeFile = "\nimport type { ComponentProps } from 'svelte'\n";
|
|
306990
|
+
return typeFile + queries.map((query5) => {
|
|
306991
|
+
const no_ext = path_exports.parse(query5.componentPath).name;
|
|
306992
|
+
const file = path_exports.parse(query5.componentPath);
|
|
306993
|
+
return `
|
|
306994
|
+
import ${no_ext} from './${file.base}'
|
|
306995
|
+
import type { ${query5.query.name.value}$input } from '${path_exports.relative(dirpath, path_exports.join(config5.artifactDirectory, query5.query.name.value)).replace("/$houdini", "")}'
|
|
306996
|
+
`;
|
|
306997
|
+
}).join("\n");
|
|
306998
|
+
}
|
|
306936
306999
|
function append_VariablesFunction(type, filepath, config5, queries) {
|
|
306937
307000
|
const { params } = route_params(filepath);
|
|
306938
307001
|
const garunteed_args = params.filter((param) => !param.optional).map((param) => param.name);
|
|
@@ -306957,6 +307020,18 @@ export type ${config5.variableFunctionName(
|
|
|
306957
307020
|
)} = VariableFunction<${type}Params, ${input_type}>;`;
|
|
306958
307021
|
}).join("\n");
|
|
306959
307022
|
}
|
|
307023
|
+
function append_ComponentVariablesFunction(filepath, config5, queries) {
|
|
307024
|
+
return queries.map((query5) => {
|
|
307025
|
+
const no_ext = path_exports.parse(query5.componentPath).name;
|
|
307026
|
+
const prop_type = no_ext + "Props";
|
|
307027
|
+
return `
|
|
307028
|
+
type ${prop_type} = ComponentProps<${no_ext}>
|
|
307029
|
+
export type ${config5.variableFunctionName(
|
|
307030
|
+
query5.query.name.value
|
|
307031
|
+
)} = <_Props extends ${prop_type}>(args: { props: _Props }) => ${query5.query.name.value}$input
|
|
307032
|
+
`;
|
|
307033
|
+
}).join("\n");
|
|
307034
|
+
}
|
|
306960
307035
|
function append_loadInput(queries) {
|
|
306961
307036
|
return `${queries.filter((q) => q.variableDefinitions?.length).length ? `
|
|
306962
307037
|
type LoadInput = { ${queries.filter((query5) => query5.variableDefinitions?.length).map((query5) => {
|
package/build/test-esm/index.js
CHANGED
|
@@ -306227,6 +306227,9 @@ function is_root_layout_script(config5, filename) {
|
|
|
306227
306227
|
function is_layout_component(framework2, filename) {
|
|
306228
306228
|
return framework2 === "kit" && filename.endsWith("+layout.svelte");
|
|
306229
306229
|
}
|
|
306230
|
+
function is_page_component(framework2, filename) {
|
|
306231
|
+
return framework2 === "kit" && filename.endsWith("+page.svelte");
|
|
306232
|
+
}
|
|
306230
306233
|
function is_layout(framework2, filename) {
|
|
306231
306234
|
return is_layout_script(framework2, filename) || is_layout_component(framework2, filename);
|
|
306232
306235
|
}
|
|
@@ -306257,6 +306260,7 @@ async function walk_routes(config5, framework2, visitor, dirpath = config5.route
|
|
|
306257
306260
|
let layoutExports = [];
|
|
306258
306261
|
let pageQueries = [];
|
|
306259
306262
|
let layoutQueries = [];
|
|
306263
|
+
let componentQueries = [];
|
|
306260
306264
|
let validRoute = false;
|
|
306261
306265
|
for (const child of await fs_exports.readdir(dirpath)) {
|
|
306262
306266
|
const childPath = path_exports.join(dirpath, child);
|
|
@@ -306303,7 +306307,7 @@ async function walk_routes(config5, framework2, visitor, dirpath = config5.route
|
|
|
306303
306307
|
layoutQueries.push(definition);
|
|
306304
306308
|
}
|
|
306305
306309
|
});
|
|
306306
|
-
} else if (
|
|
306310
|
+
} else if (is_page_component(framework2, childPath)) {
|
|
306307
306311
|
validRoute = true;
|
|
306308
306312
|
const contents = await fs_exports.readFile(childPath);
|
|
306309
306313
|
if (!contents) {
|
|
@@ -306328,6 +306332,31 @@ async function walk_routes(config5, framework2, visitor, dirpath = config5.route
|
|
|
306328
306332
|
pageQueries.push(definition);
|
|
306329
306333
|
}
|
|
306330
306334
|
});
|
|
306335
|
+
} else if (is_component(config5, framework2, childPath)) {
|
|
306336
|
+
validRoute = true;
|
|
306337
|
+
const contents = await fs_exports.readFile(childPath);
|
|
306338
|
+
if (!contents) {
|
|
306339
|
+
continue;
|
|
306340
|
+
}
|
|
306341
|
+
const parsed = await parseSvelte(contents);
|
|
306342
|
+
if (!parsed) {
|
|
306343
|
+
continue;
|
|
306344
|
+
}
|
|
306345
|
+
const { script } = parsed;
|
|
306346
|
+
await find_graphql(config5, script, {
|
|
306347
|
+
where: (tag2) => {
|
|
306348
|
+
try {
|
|
306349
|
+
return !!config5.extractQueryDefinition(tag2);
|
|
306350
|
+
} catch {
|
|
306351
|
+
return false;
|
|
306352
|
+
}
|
|
306353
|
+
},
|
|
306354
|
+
tag: async ({ parsedDocument }) => {
|
|
306355
|
+
let definition = config5.extractQueryDefinition(parsedDocument);
|
|
306356
|
+
await visitor.routeComponentQuery?.(definition, childPath);
|
|
306357
|
+
componentQueries.push({ query: definition, componentPath: childPath });
|
|
306358
|
+
}
|
|
306359
|
+
});
|
|
306331
306360
|
} else if (child === plugin_config(config5).layoutQueryFilename) {
|
|
306332
306361
|
validRoute = true;
|
|
306333
306362
|
const contents = await fs_exports.readFile(childPath);
|
|
@@ -306377,6 +306406,7 @@ async function walk_routes(config5, framework2, visitor, dirpath = config5.route
|
|
|
306377
306406
|
svelteTypeFilePath,
|
|
306378
306407
|
layoutQueries,
|
|
306379
306408
|
pageQueries,
|
|
306409
|
+
componentQueries,
|
|
306380
306410
|
layoutExports,
|
|
306381
306411
|
pageExports
|
|
306382
306412
|
},
|
|
@@ -306774,6 +306804,7 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306774
306804
|
svelteTypeFilePath,
|
|
306775
306805
|
layoutQueries,
|
|
306776
306806
|
pageQueries,
|
|
306807
|
+
componentQueries,
|
|
306777
306808
|
layoutExports,
|
|
306778
306809
|
pageExports
|
|
306779
306810
|
}) {
|
|
@@ -306796,6 +306827,14 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306796
306827
|
uniqueLayoutQueries.push(layout);
|
|
306797
306828
|
}
|
|
306798
306829
|
}
|
|
306830
|
+
const componentNames = [];
|
|
306831
|
+
const uniqueComponentQueries = [];
|
|
306832
|
+
for (const component of componentQueries) {
|
|
306833
|
+
if (!componentNames.includes(component.query.name.value)) {
|
|
306834
|
+
componentNames.push(component.query.name.value);
|
|
306835
|
+
uniqueComponentQueries.push(component);
|
|
306836
|
+
}
|
|
306837
|
+
}
|
|
306799
306838
|
if (!config5.include.some((path5) => path5.includes("js")) && (!plugin_config(config5).static || uniquePageQueries.length > 0 || uniqueLayoutQueries.length > 0)) {
|
|
306800
306839
|
console.error(
|
|
306801
306840
|
`\u26A0\uFE0F You are using at least one page/layout query but aren't "include"ing .js files in your config.
|
|
@@ -306811,6 +306850,11 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306811
306850
|
config5,
|
|
306812
306851
|
uniqueLayoutQueries
|
|
306813
306852
|
);
|
|
306853
|
+
const componentQueryTypeImports = getComponentTypeImports(
|
|
306854
|
+
dirpath,
|
|
306855
|
+
config5,
|
|
306856
|
+
uniqueComponentQueries
|
|
306857
|
+
);
|
|
306814
306858
|
const beforePageLoad = pageExports.includes(houdini_before_load_fn);
|
|
306815
306859
|
const afterPageLoad = pageExports.includes(houdini_afterLoad_fn);
|
|
306816
306860
|
const onPageError = pageExports.includes(houdini_on_error_fn);
|
|
@@ -306829,6 +306873,11 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306829
306873
|
config5,
|
|
306830
306874
|
uniquePageQueries
|
|
306831
306875
|
);
|
|
306876
|
+
const component_append_VariablesFunction = append_ComponentVariablesFunction(
|
|
306877
|
+
dirpath,
|
|
306878
|
+
config5,
|
|
306879
|
+
uniqueComponentQueries
|
|
306880
|
+
);
|
|
306832
306881
|
const layout_append_beforeLoad = append_beforeLoad(beforeLayoutLoad, "Layout");
|
|
306833
306882
|
const page_append_beforeLoad = append_beforeLoad(beforePageLoad, "Page");
|
|
306834
306883
|
const layout_append_afterLoad = append_afterLoad(
|
|
@@ -306869,11 +306918,11 @@ async function svelteKitGenerator(framework2, { config: config5 }) {
|
|
|
306869
306918
|
import type { ${functionImportsToBring.join(
|
|
306870
306919
|
", "
|
|
306871
306920
|
)} } from '${houdiniRelative}/plugins/houdini-svelte/runtime/types';` : "";
|
|
306872
|
-
typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports);
|
|
306921
|
+
typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports).concat(componentQueryTypeImports);
|
|
306873
306922
|
const layoutParams = `${layoutQueries.length > 0 && !utilityTypes.includes("LayoutParams") ? "\ntype LayoutParams = LayoutLoadEvent['params'];" : ""}`;
|
|
306874
306923
|
const pageParams = `${pageQueries.length > 0 && !utilityTypes.includes("PageParams") ? "\ntype PageParams = PageLoadEvent['params'];" : ""}`;
|
|
306875
306924
|
utilityTypes = utilityTypes.concat(layoutParams).concat(pageParams).replaceAll(/\$types\.js/gm, "$houdini");
|
|
306876
|
-
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(
|
|
306925
|
+
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(
|
|
306877
306926
|
/(?<=LayoutData = )([\s\S]*?)(?=;)/,
|
|
306878
306927
|
`Expand<$1 & { ${layoutQueries.map((query5) => {
|
|
306879
306928
|
const name = query5.name.value;
|
|
@@ -306918,6 +306967,20 @@ import { ${name}$result, ${name}$input } from '${houdiniRelative}/${config5.arti
|
|
|
306918
306967
|
import { ${name}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name}';`;
|
|
306919
306968
|
}).join("\n");
|
|
306920
306969
|
}
|
|
306970
|
+
function getComponentTypeImports(dirpath, config5, queries) {
|
|
306971
|
+
if (queries.length === 0) {
|
|
306972
|
+
return "";
|
|
306973
|
+
}
|
|
306974
|
+
let typeFile = "\nimport type { ComponentProps } from 'svelte'\n";
|
|
306975
|
+
return typeFile + queries.map((query5) => {
|
|
306976
|
+
const no_ext = path_exports.parse(query5.componentPath).name;
|
|
306977
|
+
const file = path_exports.parse(query5.componentPath);
|
|
306978
|
+
return `
|
|
306979
|
+
import ${no_ext} from './${file.base}'
|
|
306980
|
+
import type { ${query5.query.name.value}$input } from '${path_exports.relative(dirpath, path_exports.join(config5.artifactDirectory, query5.query.name.value)).replace("/$houdini", "")}'
|
|
306981
|
+
`;
|
|
306982
|
+
}).join("\n");
|
|
306983
|
+
}
|
|
306921
306984
|
function append_VariablesFunction(type, filepath, config5, queries) {
|
|
306922
306985
|
const { params } = route_params(filepath);
|
|
306923
306986
|
const garunteed_args = params.filter((param) => !param.optional).map((param) => param.name);
|
|
@@ -306942,6 +307005,18 @@ export type ${config5.variableFunctionName(
|
|
|
306942
307005
|
)} = VariableFunction<${type}Params, ${input_type}>;`;
|
|
306943
307006
|
}).join("\n");
|
|
306944
307007
|
}
|
|
307008
|
+
function append_ComponentVariablesFunction(filepath, config5, queries) {
|
|
307009
|
+
return queries.map((query5) => {
|
|
307010
|
+
const no_ext = path_exports.parse(query5.componentPath).name;
|
|
307011
|
+
const prop_type = no_ext + "Props";
|
|
307012
|
+
return `
|
|
307013
|
+
type ${prop_type} = ComponentProps<${no_ext}>
|
|
307014
|
+
export type ${config5.variableFunctionName(
|
|
307015
|
+
query5.query.name.value
|
|
307016
|
+
)} = <_Props extends ${prop_type}>(args: { props: _Props }) => ${query5.query.name.value}$input
|
|
307017
|
+
`;
|
|
307018
|
+
}).join("\n");
|
|
307019
|
+
}
|
|
306945
307020
|
function append_loadInput(queries) {
|
|
306946
307021
|
return `${queries.filter((q) => q.variableDefinitions?.length).length ? `
|
|
306947
307022
|
type LoadInput = { ${queries.filter((query5) => query5.variableDefinitions?.length).map((query5) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-svelte",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "The svelte plugin for houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"rollup": "^3.7.4",
|
|
33
33
|
"svelte": "^3.57.0",
|
|
34
34
|
"vite": "^4.1.1",
|
|
35
|
-
"houdini": "^1.2.
|
|
35
|
+
"houdini": "^1.2.8"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"build"
|