houdini-svelte 0.17.0 → 0.17.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/.turbo/turbo-compile.log +2 -2
- package/.turbo/turbo-typedefs.log +2 -2
- package/CHANGELOG.md +20 -0
- package/build/plugin/kit.d.ts +2 -1
- package/build/plugin-cjs/index.js +52 -47
- package/build/plugin-esm/index.js +52 -47
- package/build/preprocess-cjs/index.js +17 -3
- package/build/preprocess-esm/index.js +17 -3
- package/build/test-cjs/index.js +52 -47
- package/build/test-esm/index.js +52 -47
- package/package.json +2 -2
- package/src/plugin/codegen/index.ts +0 -2
- package/src/plugin/codegen/routes/index.ts +1 -1
- package/src/plugin/codegen/routes/kit.test.ts +7 -7
- package/src/plugin/fsPatch.ts +13 -7
- package/src/plugin/index.ts +28 -0
- package/src/plugin/kit.ts +7 -6
- package/src/plugin/transforms/kit/load.test.ts +54 -9
- package/src/plugin/transforms/kit/load.ts +15 -5
- package/build/plugin/codegen/adapter.d.ts +0 -2
- package/build/plugin/imports.d.ts +0 -15
- package/src/plugin/codegen/adapter.ts +0 -45
- package/src/plugin/imports.ts +0 -28
package/.turbo/turbo-compile.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
houdini-svelte:compile: cache hit, replaying output
|
|
1
|
+
houdini-svelte:compile: cache hit, replaying output bb0207bdc5a5b1bb
|
|
2
2
|
houdini-svelte:compile:
|
|
3
|
-
houdini-svelte:compile: > houdini-svelte@0.17.
|
|
3
|
+
houdini-svelte:compile: > houdini-svelte@0.17.2 compile /home/runner/work/houdini/houdini/packages/houdini-svelte
|
|
4
4
|
houdini-svelte:compile: > scripts build --plugin
|
|
5
5
|
houdini-svelte:compile:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
houdini-svelte:typedefs: cache hit, replaying output
|
|
1
|
+
houdini-svelte:typedefs: cache hit, replaying output d8f39fd8ade18fe7
|
|
2
2
|
houdini-svelte:typedefs:
|
|
3
|
-
houdini-svelte:typedefs: > houdini-svelte@0.17.
|
|
3
|
+
houdini-svelte:typedefs: > houdini-svelte@0.17.2 typedefs /home/runner/work/houdini/houdini/packages/houdini-svelte
|
|
4
4
|
houdini-svelte:typedefs: > scripts typedefs --plugin
|
|
5
5
|
houdini-svelte:typedefs:
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# houdini-svelte
|
|
2
2
|
|
|
3
|
+
## 0.17.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#639](https://github.com/HoudiniGraphql/houdini/pull/639) [`cfdb009`](https://github.com/HoudiniGraphql/houdini/commit/cfdb00907829576b142366bad8835e2d32f3ea78) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Fix error with generated route types
|
|
8
|
+
|
|
9
|
+
- [#633](https://github.com/HoudiniGraphql/houdini/pull/633) [`8e52a90`](https://github.com/HoudiniGraphql/houdini/commit/8e52a907642003c3b9c9f9b2a4c9824e49136b5d) Thanks [@jycouet](https://github.com/jycouet)! - fix: queries will be sent once if they are defined in +(page|layout).gql
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- houdini@0.17.2
|
|
13
|
+
|
|
14
|
+
## 0.17.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#630](https://github.com/HoudiniGraphql/houdini/pull/630) [`02d8fc4`](https://github.com/HoudiniGraphql/houdini/commit/02d8fc47f71980bd2b6492162b8e57808447bdbc) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Fix relative imports from root layout
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`02d8fc4`](https://github.com/HoudiniGraphql/houdini/commit/02d8fc47f71980bd2b6492162b8e57808447bdbc)]:
|
|
21
|
+
- houdini@0.17.1
|
|
22
|
+
|
|
3
23
|
## 0.17.0
|
|
4
24
|
|
|
5
25
|
### ⚠️ Breaking Changes
|
package/build/plugin/kit.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ export declare function is_layout_script(framework: Framework, filename: string)
|
|
|
13
13
|
export declare function is_root_layout(config: Config, filename: string): boolean;
|
|
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
|
-
export declare function is_layout_component(
|
|
16
|
+
export declare function is_layout_component(framework: Framework, filename: string): boolean;
|
|
17
|
+
export declare function is_layout(framework: Framework, filename: string): boolean;
|
|
17
18
|
export declare function is_component(config: Config, framework: Framework, filename: string): boolean;
|
|
18
19
|
export declare function page_query_path(config: Config, filename: string): string;
|
|
19
20
|
export declare function layout_query_path(config: Config, filename: string): string;
|
|
@@ -182653,8 +182653,11 @@ function is_root_layout_server(config2, filename) {
|
|
|
182653
182653
|
function is_root_layout_script(config2, filename) {
|
|
182654
182654
|
return resolve_relative(config2, filename).replace(config2.projectRoot, "").replace(".ts", ".js") === path_exports.sep + path_exports.join("src", "routes", "+layout.js");
|
|
182655
182655
|
}
|
|
182656
|
-
function is_layout_component(
|
|
182657
|
-
return
|
|
182656
|
+
function is_layout_component(framework2, filename) {
|
|
182657
|
+
return framework2 === "kit" && filename.endsWith("+layout.svelte");
|
|
182658
|
+
}
|
|
182659
|
+
function is_layout(framework2, filename) {
|
|
182660
|
+
return is_layout_script(framework2, filename) || is_layout_component(framework2, filename);
|
|
182658
182661
|
}
|
|
182659
182662
|
function is_component(config2, framework2, filename) {
|
|
182660
182663
|
return framework2 === "svelte" || filename.endsWith(".svelte") && !is_route_script(framework2, filename) && !is_route(config2, framework2, filename);
|
|
@@ -182734,7 +182737,7 @@ async function walk_routes(config2, framework2, visitor, dirpath = config2.route
|
|
|
182734
182737
|
continue;
|
|
182735
182738
|
}
|
|
182736
182739
|
await visitor.routeLayoutQuery(routeLayoutQuery, childPath);
|
|
182737
|
-
} else if (is_layout_component(
|
|
182740
|
+
} else if (is_layout_component(framework2, child)) {
|
|
182738
182741
|
const contents = await fs_exports.readFile(childPath);
|
|
182739
182742
|
if (!contents) {
|
|
182740
182743
|
continue;
|
|
@@ -182852,41 +182855,6 @@ function store_import({
|
|
|
182852
182855
|
return { id: ids, added };
|
|
182853
182856
|
}
|
|
182854
182857
|
|
|
182855
|
-
// src/plugin/codegen/adapter.ts
|
|
182856
|
-
async function generateAdapter({ config: config2, framework: framework2 }) {
|
|
182857
|
-
if (framework2 !== "kit") {
|
|
182858
|
-
return;
|
|
182859
|
-
}
|
|
182860
|
-
const adapterLocation = path_exports.join(config2.pluginRuntimeDirectory("houdini-svelte"), "adapter.js");
|
|
182861
|
-
const adapter = {
|
|
182862
|
-
kit: sveltekitAdapter
|
|
182863
|
-
}[framework2];
|
|
182864
|
-
await fs_exports.mkdirp(path_exports.dirname(adapterLocation));
|
|
182865
|
-
await fs_exports.writeFile(adapterLocation, adapter);
|
|
182866
|
-
}
|
|
182867
|
-
var sveltekitAdapter = `import { goto as go } from '$app/navigation'
|
|
182868
|
-
import { get } from 'svelte/store';
|
|
182869
|
-
import { browser, prerendering } from '$app/environment'
|
|
182870
|
-
import { page } from '$app/stores'
|
|
182871
|
-
import { error as svelteKitError } from '@sveltejs/kit'
|
|
182872
|
-
|
|
182873
|
-
export function goTo(location, options) {
|
|
182874
|
-
go(location, options)
|
|
182875
|
-
}
|
|
182876
|
-
|
|
182877
|
-
export const isBrowser = browser
|
|
182878
|
-
|
|
182879
|
-
export let clientStarted = false;
|
|
182880
|
-
|
|
182881
|
-
export function setClientStarted() {
|
|
182882
|
-
clientStarted = true
|
|
182883
|
-
}
|
|
182884
|
-
|
|
182885
|
-
export const isPrerender = prerendering
|
|
182886
|
-
|
|
182887
|
-
export const error = svelteKitError
|
|
182888
|
-
`;
|
|
182889
|
-
|
|
182890
182858
|
// src/plugin/codegen/components/index.ts
|
|
182891
182859
|
async function componentTypesGenerator(framework2, { config: config2, documents }) {
|
|
182892
182860
|
const queries = {};
|
|
@@ -183212,7 +183180,7 @@ function append_Store(houdiniRelative, config2, queries) {
|
|
|
183212
183180
|
return queries.map((query) => {
|
|
183213
183181
|
const name2 = query.name.value;
|
|
183214
183182
|
return `import { ${name2}$result, ${name2}$input } from '${houdiniRelative}/${config2.artifactDirectoryName}/${name2}'
|
|
183215
|
-
import { ${name2}Store } from '${houdiniRelative}/${stores_directory_name()}/${name2}'`;
|
|
183183
|
+
import { ${name2}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name2}'`;
|
|
183216
183184
|
}).join("\n");
|
|
183217
183185
|
}
|
|
183218
183186
|
function append_VariablesFunction(type, config2, queries) {
|
|
@@ -183551,7 +183519,6 @@ async function codegen_default(input) {
|
|
|
183551
183519
|
fs_exports.mkdirp(stores_directory(input.plugin_root))
|
|
183552
183520
|
]);
|
|
183553
183521
|
await Promise.all([
|
|
183554
|
-
generateAdapter(input),
|
|
183555
183522
|
svelteKitGenerator(input.framework, input),
|
|
183556
183523
|
storesGenerator(input),
|
|
183557
183524
|
componentTypesGenerator(input.framework, input)
|
|
@@ -183561,14 +183528,20 @@ async function codegen_default(input) {
|
|
|
183561
183528
|
// src/plugin/fsPatch.ts
|
|
183562
183529
|
var import_fs = __toESM(require("fs"), 1);
|
|
183563
183530
|
var fsPatch_default = (getFramwork) => ({
|
|
183564
|
-
resolveId(filepath, _, { config: config2 }) {
|
|
183531
|
+
async resolveId(filepath, _, { config: config2, isEntry }) {
|
|
183532
|
+
if (!isEntry) {
|
|
183533
|
+
const match = filepath.match("^((../)+)src/routes");
|
|
183534
|
+
if (match) {
|
|
183535
|
+
return path_exports.join(config2.projectRoot, filepath.substring(match[1].length));
|
|
183536
|
+
}
|
|
183537
|
+
return;
|
|
183538
|
+
}
|
|
183565
183539
|
filepath = path_exports.posixify(filepath.toString());
|
|
183566
183540
|
if (is_route_script(getFramwork(), filepath) || is_root_layout(config2, filepath) || is_root_layout_server(config2, filepath)) {
|
|
183567
183541
|
return {
|
|
183568
|
-
id: filepath
|
|
183542
|
+
id: resolve_relative(config2, filepath)
|
|
183569
183543
|
};
|
|
183570
183544
|
}
|
|
183571
|
-
return null;
|
|
183572
183545
|
},
|
|
183573
183546
|
load: async (filepath, { config: config2 }) => {
|
|
183574
183547
|
filepath = path_exports.posixify(filepath.toString());
|
|
@@ -183584,7 +183557,6 @@ var fsPatch_default = (getFramwork) => ({
|
|
|
183584
183557
|
code: await fs_exports.readFile(filepath) || await fs_exports.readFile(path_exports.join(config2.projectRoot, filepath)) || empty_layout
|
|
183585
183558
|
};
|
|
183586
183559
|
}
|
|
183587
|
-
return null;
|
|
183588
183560
|
}
|
|
183589
183561
|
});
|
|
183590
183562
|
var _readDirSync = import_fs.default.readdirSync;
|
|
@@ -183968,18 +183940,26 @@ async function kit_load_generator(page2) {
|
|
|
183968
183940
|
),
|
|
183969
183941
|
find_page_info(page2)
|
|
183970
183942
|
]);
|
|
183971
|
-
const
|
|
183943
|
+
const houdini_load_queries = [];
|
|
183972
183944
|
for (const [i3, target] of (page_info.houdini_load ?? []).entries()) {
|
|
183973
|
-
|
|
183945
|
+
houdini_load_queries.push({
|
|
183974
183946
|
name: target.name.value,
|
|
183975
183947
|
variables: operation_requires_variables(target),
|
|
183976
183948
|
store_id: AST15.memberExpression(AST15.identifier("houdini_load"), AST15.literal(i3))
|
|
183977
183949
|
});
|
|
183978
183950
|
}
|
|
183979
183951
|
if (script) {
|
|
183952
|
+
const queries_that_needs_a_load = [...houdini_load_queries, ...inline_queries];
|
|
183953
|
+
const isLayout = is_layout(page2.framework, page2.filepath);
|
|
183954
|
+
if (isLayout && layout_query) {
|
|
183955
|
+
queries_that_needs_a_load.push(layout_query);
|
|
183956
|
+
}
|
|
183957
|
+
if (!isLayout && page_query) {
|
|
183958
|
+
queries_that_needs_a_load.push(page_query);
|
|
183959
|
+
}
|
|
183980
183960
|
add_load({
|
|
183981
183961
|
page: page2,
|
|
183982
|
-
queries,
|
|
183962
|
+
queries: queries_that_needs_a_load,
|
|
183983
183963
|
page_info
|
|
183984
183964
|
});
|
|
183985
183965
|
}
|
|
@@ -184694,6 +184674,31 @@ var HoudiniSveltePlugin = async () => ({
|
|
|
184694
184674
|
path_exports.join(config2.projectRoot, plugin_config(config2).client)
|
|
184695
184675
|
);
|
|
184696
184676
|
return content.replace("HOUDINI_CLIENT_PATH", relativePath);
|
|
184677
|
+
},
|
|
184678
|
+
"adapter.js": ({ content }) => {
|
|
184679
|
+
const sveltekit_adapter = `import { goto as go } from '$app/navigation'
|
|
184680
|
+
import { get } from 'svelte/store';
|
|
184681
|
+
import { browser, prerendering } from '$app/environment'
|
|
184682
|
+
import { page } from '$app/stores'
|
|
184683
|
+
import { error as svelteKitError } from '@sveltejs/kit'
|
|
184684
|
+
|
|
184685
|
+
export function goTo(location, options) {
|
|
184686
|
+
go(location, options)
|
|
184687
|
+
}
|
|
184688
|
+
|
|
184689
|
+
export const isBrowser = browser
|
|
184690
|
+
|
|
184691
|
+
export let clientStarted = false;
|
|
184692
|
+
|
|
184693
|
+
export function setClientStarted() {
|
|
184694
|
+
clientStarted = true
|
|
184695
|
+
}
|
|
184696
|
+
|
|
184697
|
+
export const isPrerender = prerendering
|
|
184698
|
+
|
|
184699
|
+
export const error = svelteKitError
|
|
184700
|
+
`;
|
|
184701
|
+
return framework === "kit" ? sveltekit_adapter : content;
|
|
184697
184702
|
}
|
|
184698
184703
|
},
|
|
184699
184704
|
extract_documents: extract_default,
|
|
@@ -182649,8 +182649,11 @@ function is_root_layout_server(config2, filename) {
|
|
|
182649
182649
|
function is_root_layout_script(config2, filename) {
|
|
182650
182650
|
return resolve_relative(config2, filename).replace(config2.projectRoot, "").replace(".ts", ".js") === path_exports.sep + path_exports.join("src", "routes", "+layout.js");
|
|
182651
182651
|
}
|
|
182652
|
-
function is_layout_component(
|
|
182653
|
-
return
|
|
182652
|
+
function is_layout_component(framework2, filename) {
|
|
182653
|
+
return framework2 === "kit" && filename.endsWith("+layout.svelte");
|
|
182654
|
+
}
|
|
182655
|
+
function is_layout(framework2, filename) {
|
|
182656
|
+
return is_layout_script(framework2, filename) || is_layout_component(framework2, filename);
|
|
182654
182657
|
}
|
|
182655
182658
|
function is_component(config2, framework2, filename) {
|
|
182656
182659
|
return framework2 === "svelte" || filename.endsWith(".svelte") && !is_route_script(framework2, filename) && !is_route(config2, framework2, filename);
|
|
@@ -182730,7 +182733,7 @@ async function walk_routes(config2, framework2, visitor, dirpath = config2.route
|
|
|
182730
182733
|
continue;
|
|
182731
182734
|
}
|
|
182732
182735
|
await visitor.routeLayoutQuery(routeLayoutQuery, childPath);
|
|
182733
|
-
} else if (is_layout_component(
|
|
182736
|
+
} else if (is_layout_component(framework2, child)) {
|
|
182734
182737
|
const contents = await fs_exports.readFile(childPath);
|
|
182735
182738
|
if (!contents) {
|
|
182736
182739
|
continue;
|
|
@@ -182848,41 +182851,6 @@ function store_import({
|
|
|
182848
182851
|
return { id: ids, added };
|
|
182849
182852
|
}
|
|
182850
182853
|
|
|
182851
|
-
// src/plugin/codegen/adapter.ts
|
|
182852
|
-
async function generateAdapter({ config: config2, framework: framework2 }) {
|
|
182853
|
-
if (framework2 !== "kit") {
|
|
182854
|
-
return;
|
|
182855
|
-
}
|
|
182856
|
-
const adapterLocation = path_exports.join(config2.pluginRuntimeDirectory("houdini-svelte"), "adapter.js");
|
|
182857
|
-
const adapter = {
|
|
182858
|
-
kit: sveltekitAdapter
|
|
182859
|
-
}[framework2];
|
|
182860
|
-
await fs_exports.mkdirp(path_exports.dirname(adapterLocation));
|
|
182861
|
-
await fs_exports.writeFile(adapterLocation, adapter);
|
|
182862
|
-
}
|
|
182863
|
-
var sveltekitAdapter = `import { goto as go } from '$app/navigation'
|
|
182864
|
-
import { get } from 'svelte/store';
|
|
182865
|
-
import { browser, prerendering } from '$app/environment'
|
|
182866
|
-
import { page } from '$app/stores'
|
|
182867
|
-
import { error as svelteKitError } from '@sveltejs/kit'
|
|
182868
|
-
|
|
182869
|
-
export function goTo(location, options) {
|
|
182870
|
-
go(location, options)
|
|
182871
|
-
}
|
|
182872
|
-
|
|
182873
|
-
export const isBrowser = browser
|
|
182874
|
-
|
|
182875
|
-
export let clientStarted = false;
|
|
182876
|
-
|
|
182877
|
-
export function setClientStarted() {
|
|
182878
|
-
clientStarted = true
|
|
182879
|
-
}
|
|
182880
|
-
|
|
182881
|
-
export const isPrerender = prerendering
|
|
182882
|
-
|
|
182883
|
-
export const error = svelteKitError
|
|
182884
|
-
`;
|
|
182885
|
-
|
|
182886
182854
|
// src/plugin/codegen/components/index.ts
|
|
182887
182855
|
async function componentTypesGenerator(framework2, { config: config2, documents }) {
|
|
182888
182856
|
const queries = {};
|
|
@@ -183208,7 +183176,7 @@ function append_Store(houdiniRelative, config2, queries) {
|
|
|
183208
183176
|
return queries.map((query) => {
|
|
183209
183177
|
const name2 = query.name.value;
|
|
183210
183178
|
return `import { ${name2}$result, ${name2}$input } from '${houdiniRelative}/${config2.artifactDirectoryName}/${name2}'
|
|
183211
|
-
import { ${name2}Store } from '${houdiniRelative}/${stores_directory_name()}/${name2}'`;
|
|
183179
|
+
import { ${name2}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name2}'`;
|
|
183212
183180
|
}).join("\n");
|
|
183213
183181
|
}
|
|
183214
183182
|
function append_VariablesFunction(type, config2, queries) {
|
|
@@ -183547,7 +183515,6 @@ async function codegen_default(input) {
|
|
|
183547
183515
|
fs_exports.mkdirp(stores_directory(input.plugin_root))
|
|
183548
183516
|
]);
|
|
183549
183517
|
await Promise.all([
|
|
183550
|
-
generateAdapter(input),
|
|
183551
183518
|
svelteKitGenerator(input.framework, input),
|
|
183552
183519
|
storesGenerator(input),
|
|
183553
183520
|
componentTypesGenerator(input.framework, input)
|
|
@@ -183557,14 +183524,20 @@ async function codegen_default(input) {
|
|
|
183557
183524
|
// src/plugin/fsPatch.ts
|
|
183558
183525
|
import filesystem, { Dirent } from "fs";
|
|
183559
183526
|
var fsPatch_default = (getFramwork) => ({
|
|
183560
|
-
resolveId(filepath, _, { config: config2 }) {
|
|
183527
|
+
async resolveId(filepath, _, { config: config2, isEntry }) {
|
|
183528
|
+
if (!isEntry) {
|
|
183529
|
+
const match = filepath.match("^((../)+)src/routes");
|
|
183530
|
+
if (match) {
|
|
183531
|
+
return path_exports.join(config2.projectRoot, filepath.substring(match[1].length));
|
|
183532
|
+
}
|
|
183533
|
+
return;
|
|
183534
|
+
}
|
|
183561
183535
|
filepath = path_exports.posixify(filepath.toString());
|
|
183562
183536
|
if (is_route_script(getFramwork(), filepath) || is_root_layout(config2, filepath) || is_root_layout_server(config2, filepath)) {
|
|
183563
183537
|
return {
|
|
183564
|
-
id: filepath
|
|
183538
|
+
id: resolve_relative(config2, filepath)
|
|
183565
183539
|
};
|
|
183566
183540
|
}
|
|
183567
|
-
return null;
|
|
183568
183541
|
},
|
|
183569
183542
|
load: async (filepath, { config: config2 }) => {
|
|
183570
183543
|
filepath = path_exports.posixify(filepath.toString());
|
|
@@ -183580,7 +183553,6 @@ var fsPatch_default = (getFramwork) => ({
|
|
|
183580
183553
|
code: await fs_exports.readFile(filepath) || await fs_exports.readFile(path_exports.join(config2.projectRoot, filepath)) || empty_layout
|
|
183581
183554
|
};
|
|
183582
183555
|
}
|
|
183583
|
-
return null;
|
|
183584
183556
|
}
|
|
183585
183557
|
});
|
|
183586
183558
|
var _readDirSync = filesystem.readdirSync;
|
|
@@ -183964,18 +183936,26 @@ async function kit_load_generator(page2) {
|
|
|
183964
183936
|
),
|
|
183965
183937
|
find_page_info(page2)
|
|
183966
183938
|
]);
|
|
183967
|
-
const
|
|
183939
|
+
const houdini_load_queries = [];
|
|
183968
183940
|
for (const [i3, target] of (page_info.houdini_load ?? []).entries()) {
|
|
183969
|
-
|
|
183941
|
+
houdini_load_queries.push({
|
|
183970
183942
|
name: target.name.value,
|
|
183971
183943
|
variables: operation_requires_variables(target),
|
|
183972
183944
|
store_id: AST15.memberExpression(AST15.identifier("houdini_load"), AST15.literal(i3))
|
|
183973
183945
|
});
|
|
183974
183946
|
}
|
|
183975
183947
|
if (script) {
|
|
183948
|
+
const queries_that_needs_a_load = [...houdini_load_queries, ...inline_queries];
|
|
183949
|
+
const isLayout = is_layout(page2.framework, page2.filepath);
|
|
183950
|
+
if (isLayout && layout_query) {
|
|
183951
|
+
queries_that_needs_a_load.push(layout_query);
|
|
183952
|
+
}
|
|
183953
|
+
if (!isLayout && page_query) {
|
|
183954
|
+
queries_that_needs_a_load.push(page_query);
|
|
183955
|
+
}
|
|
183976
183956
|
add_load({
|
|
183977
183957
|
page: page2,
|
|
183978
|
-
queries,
|
|
183958
|
+
queries: queries_that_needs_a_load,
|
|
183979
183959
|
page_info
|
|
183980
183960
|
});
|
|
183981
183961
|
}
|
|
@@ -184690,6 +184670,31 @@ var HoudiniSveltePlugin = async () => ({
|
|
|
184690
184670
|
path_exports.join(config2.projectRoot, plugin_config(config2).client)
|
|
184691
184671
|
);
|
|
184692
184672
|
return content.replace("HOUDINI_CLIENT_PATH", relativePath);
|
|
184673
|
+
},
|
|
184674
|
+
"adapter.js": ({ content }) => {
|
|
184675
|
+
const sveltekit_adapter = `import { goto as go } from '$app/navigation'
|
|
184676
|
+
import { get } from 'svelte/store';
|
|
184677
|
+
import { browser, prerendering } from '$app/environment'
|
|
184678
|
+
import { page } from '$app/stores'
|
|
184679
|
+
import { error as svelteKitError } from '@sveltejs/kit'
|
|
184680
|
+
|
|
184681
|
+
export function goTo(location, options) {
|
|
184682
|
+
go(location, options)
|
|
184683
|
+
}
|
|
184684
|
+
|
|
184685
|
+
export const isBrowser = browser
|
|
184686
|
+
|
|
184687
|
+
export let clientStarted = false;
|
|
184688
|
+
|
|
184689
|
+
export function setClientStarted() {
|
|
184690
|
+
clientStarted = true
|
|
184691
|
+
}
|
|
184692
|
+
|
|
184693
|
+
export const isPrerender = prerendering
|
|
184694
|
+
|
|
184695
|
+
export const error = svelteKitError
|
|
184696
|
+
`;
|
|
184697
|
+
return framework === "kit" ? sveltekit_adapter : content;
|
|
184693
184698
|
}
|
|
184694
184699
|
},
|
|
184695
184700
|
extract_documents: extract_default,
|
|
@@ -186422,6 +186422,12 @@ function is_root_layout_server(config2, filename) {
|
|
|
186422
186422
|
function is_root_layout_script(config2, filename) {
|
|
186423
186423
|
return resolve_relative(config2, filename).replace(config2.projectRoot, "").replace(".ts", ".js") === path_exports.sep + path_exports.join("src", "routes", "+layout.js");
|
|
186424
186424
|
}
|
|
186425
|
+
function is_layout_component(framework, filename) {
|
|
186426
|
+
return framework === "kit" && filename.endsWith("+layout.svelte");
|
|
186427
|
+
}
|
|
186428
|
+
function is_layout(framework, filename) {
|
|
186429
|
+
return is_layout_script(framework, filename) || is_layout_component(framework, filename);
|
|
186430
|
+
}
|
|
186425
186431
|
function is_component(config2, framework, filename) {
|
|
186426
186432
|
return framework === "svelte" || filename.endsWith(".svelte") && !is_route_script(framework, filename) && !is_route(config2, framework, filename);
|
|
186427
186433
|
}
|
|
@@ -186892,18 +186898,26 @@ async function kit_load_generator(page2) {
|
|
|
186892
186898
|
),
|
|
186893
186899
|
find_page_info(page2)
|
|
186894
186900
|
]);
|
|
186895
|
-
const
|
|
186901
|
+
const houdini_load_queries = [];
|
|
186896
186902
|
for (const [i3, target] of (page_info.houdini_load ?? []).entries()) {
|
|
186897
|
-
|
|
186903
|
+
houdini_load_queries.push({
|
|
186898
186904
|
name: target.name.value,
|
|
186899
186905
|
variables: operation_requires_variables(target),
|
|
186900
186906
|
store_id: AST15.memberExpression(AST15.identifier("houdini_load"), AST15.literal(i3))
|
|
186901
186907
|
});
|
|
186902
186908
|
}
|
|
186903
186909
|
if (script) {
|
|
186910
|
+
const queries_that_needs_a_load = [...houdini_load_queries, ...inline_queries];
|
|
186911
|
+
const isLayout = is_layout(page2.framework, page2.filepath);
|
|
186912
|
+
if (isLayout && layout_query) {
|
|
186913
|
+
queries_that_needs_a_load.push(layout_query);
|
|
186914
|
+
}
|
|
186915
|
+
if (!isLayout && page_query) {
|
|
186916
|
+
queries_that_needs_a_load.push(page_query);
|
|
186917
|
+
}
|
|
186904
186918
|
add_load({
|
|
186905
186919
|
page: page2,
|
|
186906
|
-
queries,
|
|
186920
|
+
queries: queries_that_needs_a_load,
|
|
186907
186921
|
page_info
|
|
186908
186922
|
});
|
|
186909
186923
|
}
|
|
@@ -186414,6 +186414,12 @@ function is_root_layout_server(config2, filename) {
|
|
|
186414
186414
|
function is_root_layout_script(config2, filename) {
|
|
186415
186415
|
return resolve_relative(config2, filename).replace(config2.projectRoot, "").replace(".ts", ".js") === path_exports.sep + path_exports.join("src", "routes", "+layout.js");
|
|
186416
186416
|
}
|
|
186417
|
+
function is_layout_component(framework, filename) {
|
|
186418
|
+
return framework === "kit" && filename.endsWith("+layout.svelte");
|
|
186419
|
+
}
|
|
186420
|
+
function is_layout(framework, filename) {
|
|
186421
|
+
return is_layout_script(framework, filename) || is_layout_component(framework, filename);
|
|
186422
|
+
}
|
|
186417
186423
|
function is_component(config2, framework, filename) {
|
|
186418
186424
|
return framework === "svelte" || filename.endsWith(".svelte") && !is_route_script(framework, filename) && !is_route(config2, framework, filename);
|
|
186419
186425
|
}
|
|
@@ -186884,18 +186890,26 @@ async function kit_load_generator(page2) {
|
|
|
186884
186890
|
),
|
|
186885
186891
|
find_page_info(page2)
|
|
186886
186892
|
]);
|
|
186887
|
-
const
|
|
186893
|
+
const houdini_load_queries = [];
|
|
186888
186894
|
for (const [i3, target] of (page_info.houdini_load ?? []).entries()) {
|
|
186889
|
-
|
|
186895
|
+
houdini_load_queries.push({
|
|
186890
186896
|
name: target.name.value,
|
|
186891
186897
|
variables: operation_requires_variables(target),
|
|
186892
186898
|
store_id: AST15.memberExpression(AST15.identifier("houdini_load"), AST15.literal(i3))
|
|
186893
186899
|
});
|
|
186894
186900
|
}
|
|
186895
186901
|
if (script) {
|
|
186902
|
+
const queries_that_needs_a_load = [...houdini_load_queries, ...inline_queries];
|
|
186903
|
+
const isLayout = is_layout(page2.framework, page2.filepath);
|
|
186904
|
+
if (isLayout && layout_query) {
|
|
186905
|
+
queries_that_needs_a_load.push(layout_query);
|
|
186906
|
+
}
|
|
186907
|
+
if (!isLayout && page_query) {
|
|
186908
|
+
queries_that_needs_a_load.push(page_query);
|
|
186909
|
+
}
|
|
186896
186910
|
add_load({
|
|
186897
186911
|
page: page2,
|
|
186898
|
-
queries,
|
|
186912
|
+
queries: queries_that_needs_a_load,
|
|
186899
186913
|
page_info
|
|
186900
186914
|
});
|
|
186901
186915
|
}
|
package/build/test-cjs/index.js
CHANGED
|
@@ -299397,8 +299397,11 @@ function is_root_layout_server(config3, filename) {
|
|
|
299397
299397
|
function is_root_layout_script(config3, filename) {
|
|
299398
299398
|
return resolve_relative(config3, filename).replace(config3.projectRoot, "").replace(".ts", ".js") === path_exports.sep + path_exports.join("src", "routes", "+layout.js");
|
|
299399
299399
|
}
|
|
299400
|
-
function is_layout_component(
|
|
299401
|
-
return
|
|
299400
|
+
function is_layout_component(framework2, filename) {
|
|
299401
|
+
return framework2 === "kit" && filename.endsWith("+layout.svelte");
|
|
299402
|
+
}
|
|
299403
|
+
function is_layout(framework2, filename) {
|
|
299404
|
+
return is_layout_script(framework2, filename) || is_layout_component(framework2, filename);
|
|
299402
299405
|
}
|
|
299403
299406
|
function is_component(config3, framework2, filename) {
|
|
299404
299407
|
return framework2 === "svelte" || filename.endsWith(".svelte") && !is_route_script(framework2, filename) && !is_route(config3, framework2, filename);
|
|
@@ -299478,7 +299481,7 @@ async function walk_routes(config3, framework2, visitor, dirpath = config3.route
|
|
|
299478
299481
|
continue;
|
|
299479
299482
|
}
|
|
299480
299483
|
await visitor.routeLayoutQuery(routeLayoutQuery, childPath);
|
|
299481
|
-
} else if (is_layout_component(
|
|
299484
|
+
} else if (is_layout_component(framework2, child)) {
|
|
299482
299485
|
const contents = await fs_exports.readFile(childPath);
|
|
299483
299486
|
if (!contents) {
|
|
299484
299487
|
continue;
|
|
@@ -299596,41 +299599,6 @@ function store_import({
|
|
|
299596
299599
|
return { id: ids, added };
|
|
299597
299600
|
}
|
|
299598
299601
|
|
|
299599
|
-
// src/plugin/codegen/adapter.ts
|
|
299600
|
-
async function generateAdapter({ config: config3, framework: framework2 }) {
|
|
299601
|
-
if (framework2 !== "kit") {
|
|
299602
|
-
return;
|
|
299603
|
-
}
|
|
299604
|
-
const adapterLocation = path_exports.join(config3.pluginRuntimeDirectory("houdini-svelte"), "adapter.js");
|
|
299605
|
-
const adapter = {
|
|
299606
|
-
kit: sveltekitAdapter
|
|
299607
|
-
}[framework2];
|
|
299608
|
-
await fs_exports.mkdirp(path_exports.dirname(adapterLocation));
|
|
299609
|
-
await fs_exports.writeFile(adapterLocation, adapter);
|
|
299610
|
-
}
|
|
299611
|
-
var sveltekitAdapter = `import { goto as go } from '$app/navigation'
|
|
299612
|
-
import { get } from 'svelte/store';
|
|
299613
|
-
import { browser, prerendering } from '$app/environment'
|
|
299614
|
-
import { page } from '$app/stores'
|
|
299615
|
-
import { error as svelteKitError } from '@sveltejs/kit'
|
|
299616
|
-
|
|
299617
|
-
export function goTo(location, options) {
|
|
299618
|
-
go(location, options)
|
|
299619
|
-
}
|
|
299620
|
-
|
|
299621
|
-
export const isBrowser = browser
|
|
299622
|
-
|
|
299623
|
-
export let clientStarted = false;
|
|
299624
|
-
|
|
299625
|
-
export function setClientStarted() {
|
|
299626
|
-
clientStarted = true
|
|
299627
|
-
}
|
|
299628
|
-
|
|
299629
|
-
export const isPrerender = prerendering
|
|
299630
|
-
|
|
299631
|
-
export const error = svelteKitError
|
|
299632
|
-
`;
|
|
299633
|
-
|
|
299634
299602
|
// src/plugin/codegen/components/index.ts
|
|
299635
299603
|
async function componentTypesGenerator(framework2, { config: config3, documents }) {
|
|
299636
299604
|
const queries = {};
|
|
@@ -299956,7 +299924,7 @@ function append_Store(houdiniRelative, config3, queries) {
|
|
|
299956
299924
|
return queries.map((query) => {
|
|
299957
299925
|
const name2 = query.name.value;
|
|
299958
299926
|
return `import { ${name2}$result, ${name2}$input } from '${houdiniRelative}/${config3.artifactDirectoryName}/${name2}'
|
|
299959
|
-
import { ${name2}Store } from '${houdiniRelative}/${stores_directory_name()}/${name2}'`;
|
|
299927
|
+
import { ${name2}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name2}'`;
|
|
299960
299928
|
}).join("\n");
|
|
299961
299929
|
}
|
|
299962
299930
|
function append_VariablesFunction(type, config3, queries) {
|
|
@@ -300295,7 +300263,6 @@ async function codegen_default(input) {
|
|
|
300295
300263
|
fs_exports.mkdirp(stores_directory(input.plugin_root))
|
|
300296
300264
|
]);
|
|
300297
300265
|
await Promise.all([
|
|
300298
|
-
generateAdapter(input),
|
|
300299
300266
|
svelteKitGenerator(input.framework, input),
|
|
300300
300267
|
storesGenerator(input),
|
|
300301
300268
|
componentTypesGenerator(input.framework, input)
|
|
@@ -300305,14 +300272,20 @@ async function codegen_default(input) {
|
|
|
300305
300272
|
// src/plugin/fsPatch.ts
|
|
300306
300273
|
var import_fs = __toESM(require("fs"), 1);
|
|
300307
300274
|
var fsPatch_default = (getFramwork) => ({
|
|
300308
|
-
resolveId(filepath, _, { config: config3 }) {
|
|
300275
|
+
async resolveId(filepath, _, { config: config3, isEntry }) {
|
|
300276
|
+
if (!isEntry) {
|
|
300277
|
+
const match = filepath.match("^((../)+)src/routes");
|
|
300278
|
+
if (match) {
|
|
300279
|
+
return path_exports.join(config3.projectRoot, filepath.substring(match[1].length));
|
|
300280
|
+
}
|
|
300281
|
+
return;
|
|
300282
|
+
}
|
|
300309
300283
|
filepath = path_exports.posixify(filepath.toString());
|
|
300310
300284
|
if (is_route_script(getFramwork(), filepath) || is_root_layout(config3, filepath) || is_root_layout_server(config3, filepath)) {
|
|
300311
300285
|
return {
|
|
300312
|
-
id: filepath
|
|
300286
|
+
id: resolve_relative(config3, filepath)
|
|
300313
300287
|
};
|
|
300314
300288
|
}
|
|
300315
|
-
return null;
|
|
300316
300289
|
},
|
|
300317
300290
|
load: async (filepath, { config: config3 }) => {
|
|
300318
300291
|
filepath = path_exports.posixify(filepath.toString());
|
|
@@ -300328,7 +300301,6 @@ var fsPatch_default = (getFramwork) => ({
|
|
|
300328
300301
|
code: await fs_exports.readFile(filepath) || await fs_exports.readFile(path_exports.join(config3.projectRoot, filepath)) || empty_layout
|
|
300329
300302
|
};
|
|
300330
300303
|
}
|
|
300331
|
-
return null;
|
|
300332
300304
|
}
|
|
300333
300305
|
});
|
|
300334
300306
|
var _readDirSync = import_fs.default.readdirSync;
|
|
@@ -300712,18 +300684,26 @@ async function kit_load_generator(page2) {
|
|
|
300712
300684
|
),
|
|
300713
300685
|
find_page_info(page2)
|
|
300714
300686
|
]);
|
|
300715
|
-
const
|
|
300687
|
+
const houdini_load_queries = [];
|
|
300716
300688
|
for (const [i3, target] of (page_info.houdini_load ?? []).entries()) {
|
|
300717
|
-
|
|
300689
|
+
houdini_load_queries.push({
|
|
300718
300690
|
name: target.name.value,
|
|
300719
300691
|
variables: operation_requires_variables(target),
|
|
300720
300692
|
store_id: AST16.memberExpression(AST16.identifier("houdini_load"), AST16.literal(i3))
|
|
300721
300693
|
});
|
|
300722
300694
|
}
|
|
300723
300695
|
if (script) {
|
|
300696
|
+
const queries_that_needs_a_load = [...houdini_load_queries, ...inline_queries];
|
|
300697
|
+
const isLayout = is_layout(page2.framework, page2.filepath);
|
|
300698
|
+
if (isLayout && layout_query) {
|
|
300699
|
+
queries_that_needs_a_load.push(layout_query);
|
|
300700
|
+
}
|
|
300701
|
+
if (!isLayout && page_query) {
|
|
300702
|
+
queries_that_needs_a_load.push(page_query);
|
|
300703
|
+
}
|
|
300724
300704
|
add_load({
|
|
300725
300705
|
page: page2,
|
|
300726
|
-
queries,
|
|
300706
|
+
queries: queries_that_needs_a_load,
|
|
300727
300707
|
page_info
|
|
300728
300708
|
});
|
|
300729
300709
|
}
|
|
@@ -301438,6 +301418,31 @@ var HoudiniSveltePlugin = async () => ({
|
|
|
301438
301418
|
path_exports.join(config3.projectRoot, plugin_config(config3).client)
|
|
301439
301419
|
);
|
|
301440
301420
|
return content.replace("HOUDINI_CLIENT_PATH", relativePath);
|
|
301421
|
+
},
|
|
301422
|
+
"adapter.js": ({ content }) => {
|
|
301423
|
+
const sveltekit_adapter = `import { goto as go } from '$app/navigation'
|
|
301424
|
+
import { get } from 'svelte/store';
|
|
301425
|
+
import { browser, prerendering } from '$app/environment'
|
|
301426
|
+
import { page } from '$app/stores'
|
|
301427
|
+
import { error as svelteKitError } from '@sveltejs/kit'
|
|
301428
|
+
|
|
301429
|
+
export function goTo(location, options) {
|
|
301430
|
+
go(location, options)
|
|
301431
|
+
}
|
|
301432
|
+
|
|
301433
|
+
export const isBrowser = browser
|
|
301434
|
+
|
|
301435
|
+
export let clientStarted = false;
|
|
301436
|
+
|
|
301437
|
+
export function setClientStarted() {
|
|
301438
|
+
clientStarted = true
|
|
301439
|
+
}
|
|
301440
|
+
|
|
301441
|
+
export const isPrerender = prerendering
|
|
301442
|
+
|
|
301443
|
+
export const error = svelteKitError
|
|
301444
|
+
`;
|
|
301445
|
+
return framework === "kit" ? sveltekit_adapter : content;
|
|
301441
301446
|
}
|
|
301442
301447
|
},
|
|
301443
301448
|
extract_documents: extract_default,
|
package/build/test-esm/index.js
CHANGED
|
@@ -299386,8 +299386,11 @@ function is_root_layout_server(config3, filename) {
|
|
|
299386
299386
|
function is_root_layout_script(config3, filename) {
|
|
299387
299387
|
return resolve_relative(config3, filename).replace(config3.projectRoot, "").replace(".ts", ".js") === path_exports.sep + path_exports.join("src", "routes", "+layout.js");
|
|
299388
299388
|
}
|
|
299389
|
-
function is_layout_component(
|
|
299390
|
-
return
|
|
299389
|
+
function is_layout_component(framework2, filename) {
|
|
299390
|
+
return framework2 === "kit" && filename.endsWith("+layout.svelte");
|
|
299391
|
+
}
|
|
299392
|
+
function is_layout(framework2, filename) {
|
|
299393
|
+
return is_layout_script(framework2, filename) || is_layout_component(framework2, filename);
|
|
299391
299394
|
}
|
|
299392
299395
|
function is_component(config3, framework2, filename) {
|
|
299393
299396
|
return framework2 === "svelte" || filename.endsWith(".svelte") && !is_route_script(framework2, filename) && !is_route(config3, framework2, filename);
|
|
@@ -299467,7 +299470,7 @@ async function walk_routes(config3, framework2, visitor, dirpath = config3.route
|
|
|
299467
299470
|
continue;
|
|
299468
299471
|
}
|
|
299469
299472
|
await visitor.routeLayoutQuery(routeLayoutQuery, childPath);
|
|
299470
|
-
} else if (is_layout_component(
|
|
299473
|
+
} else if (is_layout_component(framework2, child)) {
|
|
299471
299474
|
const contents = await fs_exports.readFile(childPath);
|
|
299472
299475
|
if (!contents) {
|
|
299473
299476
|
continue;
|
|
@@ -299585,41 +299588,6 @@ function store_import({
|
|
|
299585
299588
|
return { id: ids, added };
|
|
299586
299589
|
}
|
|
299587
299590
|
|
|
299588
|
-
// src/plugin/codegen/adapter.ts
|
|
299589
|
-
async function generateAdapter({ config: config3, framework: framework2 }) {
|
|
299590
|
-
if (framework2 !== "kit") {
|
|
299591
|
-
return;
|
|
299592
|
-
}
|
|
299593
|
-
const adapterLocation = path_exports.join(config3.pluginRuntimeDirectory("houdini-svelte"), "adapter.js");
|
|
299594
|
-
const adapter = {
|
|
299595
|
-
kit: sveltekitAdapter
|
|
299596
|
-
}[framework2];
|
|
299597
|
-
await fs_exports.mkdirp(path_exports.dirname(adapterLocation));
|
|
299598
|
-
await fs_exports.writeFile(adapterLocation, adapter);
|
|
299599
|
-
}
|
|
299600
|
-
var sveltekitAdapter = `import { goto as go } from '$app/navigation'
|
|
299601
|
-
import { get } from 'svelte/store';
|
|
299602
|
-
import { browser, prerendering } from '$app/environment'
|
|
299603
|
-
import { page } from '$app/stores'
|
|
299604
|
-
import { error as svelteKitError } from '@sveltejs/kit'
|
|
299605
|
-
|
|
299606
|
-
export function goTo(location, options) {
|
|
299607
|
-
go(location, options)
|
|
299608
|
-
}
|
|
299609
|
-
|
|
299610
|
-
export const isBrowser = browser
|
|
299611
|
-
|
|
299612
|
-
export let clientStarted = false;
|
|
299613
|
-
|
|
299614
|
-
export function setClientStarted() {
|
|
299615
|
-
clientStarted = true
|
|
299616
|
-
}
|
|
299617
|
-
|
|
299618
|
-
export const isPrerender = prerendering
|
|
299619
|
-
|
|
299620
|
-
export const error = svelteKitError
|
|
299621
|
-
`;
|
|
299622
|
-
|
|
299623
299591
|
// src/plugin/codegen/components/index.ts
|
|
299624
299592
|
async function componentTypesGenerator(framework2, { config: config3, documents }) {
|
|
299625
299593
|
const queries = {};
|
|
@@ -299945,7 +299913,7 @@ function append_Store(houdiniRelative, config3, queries) {
|
|
|
299945
299913
|
return queries.map((query) => {
|
|
299946
299914
|
const name2 = query.name.value;
|
|
299947
299915
|
return `import { ${name2}$result, ${name2}$input } from '${houdiniRelative}/${config3.artifactDirectoryName}/${name2}'
|
|
299948
|
-
import { ${name2}Store } from '${houdiniRelative}/${stores_directory_name()}/${name2}'`;
|
|
299916
|
+
import { ${name2}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name2}'`;
|
|
299949
299917
|
}).join("\n");
|
|
299950
299918
|
}
|
|
299951
299919
|
function append_VariablesFunction(type, config3, queries) {
|
|
@@ -300284,7 +300252,6 @@ async function codegen_default(input) {
|
|
|
300284
300252
|
fs_exports.mkdirp(stores_directory(input.plugin_root))
|
|
300285
300253
|
]);
|
|
300286
300254
|
await Promise.all([
|
|
300287
|
-
generateAdapter(input),
|
|
300288
300255
|
svelteKitGenerator(input.framework, input),
|
|
300289
300256
|
storesGenerator(input),
|
|
300290
300257
|
componentTypesGenerator(input.framework, input)
|
|
@@ -300294,14 +300261,20 @@ async function codegen_default(input) {
|
|
|
300294
300261
|
// src/plugin/fsPatch.ts
|
|
300295
300262
|
import filesystem, { Dirent } from "fs";
|
|
300296
300263
|
var fsPatch_default = (getFramwork) => ({
|
|
300297
|
-
resolveId(filepath, _, { config: config3 }) {
|
|
300264
|
+
async resolveId(filepath, _, { config: config3, isEntry }) {
|
|
300265
|
+
if (!isEntry) {
|
|
300266
|
+
const match = filepath.match("^((../)+)src/routes");
|
|
300267
|
+
if (match) {
|
|
300268
|
+
return path_exports.join(config3.projectRoot, filepath.substring(match[1].length));
|
|
300269
|
+
}
|
|
300270
|
+
return;
|
|
300271
|
+
}
|
|
300298
300272
|
filepath = path_exports.posixify(filepath.toString());
|
|
300299
300273
|
if (is_route_script(getFramwork(), filepath) || is_root_layout(config3, filepath) || is_root_layout_server(config3, filepath)) {
|
|
300300
300274
|
return {
|
|
300301
|
-
id: filepath
|
|
300275
|
+
id: resolve_relative(config3, filepath)
|
|
300302
300276
|
};
|
|
300303
300277
|
}
|
|
300304
|
-
return null;
|
|
300305
300278
|
},
|
|
300306
300279
|
load: async (filepath, { config: config3 }) => {
|
|
300307
300280
|
filepath = path_exports.posixify(filepath.toString());
|
|
@@ -300317,7 +300290,6 @@ var fsPatch_default = (getFramwork) => ({
|
|
|
300317
300290
|
code: await fs_exports.readFile(filepath) || await fs_exports.readFile(path_exports.join(config3.projectRoot, filepath)) || empty_layout
|
|
300318
300291
|
};
|
|
300319
300292
|
}
|
|
300320
|
-
return null;
|
|
300321
300293
|
}
|
|
300322
300294
|
});
|
|
300323
300295
|
var _readDirSync = filesystem.readdirSync;
|
|
@@ -300701,18 +300673,26 @@ async function kit_load_generator(page2) {
|
|
|
300701
300673
|
),
|
|
300702
300674
|
find_page_info(page2)
|
|
300703
300675
|
]);
|
|
300704
|
-
const
|
|
300676
|
+
const houdini_load_queries = [];
|
|
300705
300677
|
for (const [i3, target] of (page_info.houdini_load ?? []).entries()) {
|
|
300706
|
-
|
|
300678
|
+
houdini_load_queries.push({
|
|
300707
300679
|
name: target.name.value,
|
|
300708
300680
|
variables: operation_requires_variables(target),
|
|
300709
300681
|
store_id: AST16.memberExpression(AST16.identifier("houdini_load"), AST16.literal(i3))
|
|
300710
300682
|
});
|
|
300711
300683
|
}
|
|
300712
300684
|
if (script) {
|
|
300685
|
+
const queries_that_needs_a_load = [...houdini_load_queries, ...inline_queries];
|
|
300686
|
+
const isLayout = is_layout(page2.framework, page2.filepath);
|
|
300687
|
+
if (isLayout && layout_query) {
|
|
300688
|
+
queries_that_needs_a_load.push(layout_query);
|
|
300689
|
+
}
|
|
300690
|
+
if (!isLayout && page_query) {
|
|
300691
|
+
queries_that_needs_a_load.push(page_query);
|
|
300692
|
+
}
|
|
300713
300693
|
add_load({
|
|
300714
300694
|
page: page2,
|
|
300715
|
-
queries,
|
|
300695
|
+
queries: queries_that_needs_a_load,
|
|
300716
300696
|
page_info
|
|
300717
300697
|
});
|
|
300718
300698
|
}
|
|
@@ -301427,6 +301407,31 @@ var HoudiniSveltePlugin = async () => ({
|
|
|
301427
301407
|
path_exports.join(config3.projectRoot, plugin_config(config3).client)
|
|
301428
301408
|
);
|
|
301429
301409
|
return content.replace("HOUDINI_CLIENT_PATH", relativePath);
|
|
301410
|
+
},
|
|
301411
|
+
"adapter.js": ({ content }) => {
|
|
301412
|
+
const sveltekit_adapter = `import { goto as go } from '$app/navigation'
|
|
301413
|
+
import { get } from 'svelte/store';
|
|
301414
|
+
import { browser, prerendering } from '$app/environment'
|
|
301415
|
+
import { page } from '$app/stores'
|
|
301416
|
+
import { error as svelteKitError } from '@sveltejs/kit'
|
|
301417
|
+
|
|
301418
|
+
export function goTo(location, options) {
|
|
301419
|
+
go(location, options)
|
|
301420
|
+
}
|
|
301421
|
+
|
|
301422
|
+
export const isBrowser = browser
|
|
301423
|
+
|
|
301424
|
+
export let clientStarted = false;
|
|
301425
|
+
|
|
301426
|
+
export function setClientStarted() {
|
|
301427
|
+
clientStarted = true
|
|
301428
|
+
}
|
|
301429
|
+
|
|
301430
|
+
export const isPrerender = prerendering
|
|
301431
|
+
|
|
301432
|
+
export const error = svelteKitError
|
|
301433
|
+
`;
|
|
301434
|
+
return framework === "kit" ? sveltekit_adapter : content;
|
|
301430
301435
|
}
|
|
301431
301436
|
},
|
|
301432
301437
|
extract_documents: extract_default,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-svelte",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"description": "The svelte plugin for houdini",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"ast-types": "^0.15.1",
|
|
10
10
|
"estree-walker": "^3.0.1",
|
|
11
11
|
"graphql": "^16.6.0",
|
|
12
|
-
"houdini": "^0.17.
|
|
12
|
+
"houdini": "^0.17.2",
|
|
13
13
|
"minimatch": "^5.1.0",
|
|
14
14
|
"recast": "^0.21.5",
|
|
15
15
|
"svelte": "^3.52.0"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GenerateHookInput, fs, Config } from 'houdini'
|
|
2
2
|
|
|
3
3
|
import { stores_directory, type_route_dir } from '../kit'
|
|
4
|
-
import adapter from './adapter'
|
|
5
4
|
import components from './components'
|
|
6
5
|
import kit from './routes'
|
|
7
6
|
import stores from './stores'
|
|
@@ -15,7 +14,6 @@ export default async function (input: PluginGenerateInput) {
|
|
|
15
14
|
|
|
16
15
|
// generate the files
|
|
17
16
|
await Promise.all([
|
|
18
|
-
adapter(input),
|
|
19
17
|
kit(input.framework, input),
|
|
20
18
|
stores(input),
|
|
21
19
|
components(input.framework, input),
|
|
@@ -183,7 +183,7 @@ function append_Store(houdiniRelative: string, config: Config, queries: Operatio
|
|
|
183
183
|
return `import { ${name}$result, ${name}$input } from '${houdiniRelative}/${
|
|
184
184
|
config.artifactDirectoryName
|
|
185
185
|
}/${name}'
|
|
186
|
-
import { ${name}Store } from '${houdiniRelative}/${stores_directory_name()}/${name}'`
|
|
186
|
+
import { ${name}Store } from '${houdiniRelative}/plugins/houdini-svelte/${stores_directory_name()}/${name}'`
|
|
187
187
|
})
|
|
188
188
|
.join('\n')
|
|
189
189
|
}
|
|
@@ -40,7 +40,7 @@ test('generates types for inline queries', async function () {
|
|
|
40
40
|
import type { VariableFunction, AfterLoadFunction, BeforeLoadFunction } from "../../../../plugins/houdini-svelte/runtime/types";
|
|
41
41
|
import type { PageLoadEvent, PageData as KitPageData } from "./$types";
|
|
42
42
|
import { MyInlineQuery$result, MyInlineQuery$input } from "../../../../artifacts/MyInlineQuery";
|
|
43
|
-
import { MyInlineQueryStore } from "../../../../stores/MyInlineQuery";
|
|
43
|
+
import { MyInlineQueryStore } from "../../../../plugins/houdini-svelte/stores/MyInlineQuery";
|
|
44
44
|
type PageParams = PageLoadEvent["params"];
|
|
45
45
|
|
|
46
46
|
export type PageData = {
|
|
@@ -81,7 +81,7 @@ query MyPageQuery {
|
|
|
81
81
|
import type { VariableFunction, AfterLoadFunction, BeforeLoadFunction } from "../../../../plugins/houdini-svelte/runtime/types";
|
|
82
82
|
import type { PageLoadEvent, PageData as KitPageData } from "./$types";
|
|
83
83
|
import { MyPageQuery$result, MyPageQuery$input } from "../../../../artifacts/MyPageQuery";
|
|
84
|
-
import { MyPageQueryStore } from "../../../../stores/MyPageQuery";
|
|
84
|
+
import { MyPageQueryStore } from "../../../../plugins/houdini-svelte/stores/MyPageQuery";
|
|
85
85
|
type PageParams = PageLoadEvent["params"];
|
|
86
86
|
|
|
87
87
|
export type PageData = {
|
|
@@ -122,7 +122,7 @@ query MyLayoutQuery {
|
|
|
122
122
|
import type { VariableFunction, AfterLoadFunction, BeforeLoadFunction } from "../../../../plugins/houdini-svelte/runtime/types";
|
|
123
123
|
import type { LayoutLoadEvent, LayoutData as KitPageData } from "./$types";
|
|
124
124
|
import { MyLayoutQuery$result, MyLayoutQuery$input } from "../../../../artifacts/MyLayoutQuery";
|
|
125
|
-
import { MyLayoutQueryStore } from "../../../../stores/MyLayoutQuery";
|
|
125
|
+
import { MyLayoutQueryStore } from "../../../../plugins/houdini-svelte/stores/MyLayoutQuery";
|
|
126
126
|
type LayoutParams = LayoutLoadEvent["params"];
|
|
127
127
|
|
|
128
128
|
export type LayoutData = {
|
|
@@ -178,9 +178,9 @@ test('generates types for after load', async function () {
|
|
|
178
178
|
import type { VariableFunction, AfterLoadFunction, BeforeLoadFunction } from "../../../../plugins/houdini-svelte/runtime/types";
|
|
179
179
|
import type { PageLoadEvent, PageData as KitPageData } from "./$types";
|
|
180
180
|
import { MyPageLoad1Query$result, MyPageLoad1Query$input } from "../../../../artifacts/MyPageLoad1Query";
|
|
181
|
-
import { MyPageLoad1QueryStore } from "../../../../stores/MyPageLoad1Query";
|
|
181
|
+
import { MyPageLoad1QueryStore } from "../../../../plugins/houdini-svelte/stores/MyPageLoad1Query";
|
|
182
182
|
import { MyPageLoad2Query$result, MyPageLoad2Query$input } from "../../../../artifacts/MyPageLoad2Query";
|
|
183
|
-
import { MyPageLoad2QueryStore } from "../../../../stores/MyPageLoad2Query";
|
|
183
|
+
import { MyPageLoad2QueryStore } from "../../../../plugins/houdini-svelte/stores/MyPageLoad2Query";
|
|
184
184
|
type PageParams = PageLoadEvent["params"];
|
|
185
185
|
export type MyPageLoad1QueryVariables = VariableFunction<PageParams, MyPageLoad1Query$input>;
|
|
186
186
|
type AfterLoadReturn = ReturnType<typeof import("./+page").afterLoad>;
|
|
@@ -254,9 +254,9 @@ test('generates types for onError', async function () {
|
|
|
254
254
|
import type { VariableFunction, AfterLoadFunction, BeforeLoadFunction } from "../../../../plugins/houdini-svelte/runtime/types";
|
|
255
255
|
import type { PageLoadEvent, PageData as KitPageData } from "./$types";
|
|
256
256
|
import { MyPageLoad1Query$result, MyPageLoad1Query$input } from "../../../../artifacts/MyPageLoad1Query";
|
|
257
|
-
import { MyPageLoad1QueryStore } from "../../../../stores/MyPageLoad1Query";
|
|
257
|
+
import { MyPageLoad1QueryStore } from "../../../../plugins/houdini-svelte/stores/MyPageLoad1Query";
|
|
258
258
|
import { MyPageLoad2Query$result, MyPageLoad2Query$input } from "../../../../artifacts/MyPageLoad2Query";
|
|
259
|
-
import { MyPageLoad2QueryStore } from "../../../../stores/MyPageLoad2Query";
|
|
259
|
+
import { MyPageLoad2QueryStore } from "../../../../plugins/houdini-svelte/stores/MyPageLoad2Query";
|
|
260
260
|
type PageParams = PageLoadEvent["params"];
|
|
261
261
|
export type MyPageLoad1QueryVariables = VariableFunction<PageParams, MyPageLoad1Query$input>;
|
|
262
262
|
|
package/src/plugin/fsPatch.ts
CHANGED
|
@@ -12,7 +12,18 @@ import {
|
|
|
12
12
|
// this plugin is responsible for faking `+page.js` existence in the eyes of sveltekit
|
|
13
13
|
export default (getFramwork: () => Framework) =>
|
|
14
14
|
({
|
|
15
|
-
resolveId(filepath, _, { config }) {
|
|
15
|
+
async resolveId(filepath, _, { config, isEntry }) {
|
|
16
|
+
// without this check, the block underneath breaks relative imports from root layout
|
|
17
|
+
if (!isEntry) {
|
|
18
|
+
// make sure there is no
|
|
19
|
+
const match = filepath.match('^((../)+)src/routes')
|
|
20
|
+
if (match) {
|
|
21
|
+
return path.join(config.projectRoot, filepath.substring(match[1].length))
|
|
22
|
+
}
|
|
23
|
+
// if there is no deep relative import, do the default thing
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
// everything internal to houdini should assume posix paths
|
|
17
28
|
filepath = path.posixify(filepath.toString())
|
|
18
29
|
|
|
@@ -23,11 +34,9 @@ export default (getFramwork: () => Framework) =>
|
|
|
23
34
|
is_root_layout_server(config, filepath)
|
|
24
35
|
) {
|
|
25
36
|
return {
|
|
26
|
-
id: filepath,
|
|
37
|
+
id: resolve_relative(config, filepath),
|
|
27
38
|
}
|
|
28
39
|
}
|
|
29
|
-
|
|
30
|
-
return null
|
|
31
40
|
},
|
|
32
41
|
|
|
33
42
|
load: async (filepath, { config }) => {
|
|
@@ -57,9 +66,6 @@ export default (getFramwork: () => Framework) =>
|
|
|
57
66
|
empty_layout,
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
|
-
|
|
61
|
-
// do the normal thing
|
|
62
|
-
return null
|
|
63
69
|
},
|
|
64
70
|
} as Plugin['vite'])
|
|
65
71
|
|
package/src/plugin/index.ts
CHANGED
|
@@ -38,6 +38,34 @@ const HoudiniSveltePlugin: PluginFactory = async () => ({
|
|
|
38
38
|
|
|
39
39
|
return content.replace('HOUDINI_CLIENT_PATH', relativePath)
|
|
40
40
|
},
|
|
41
|
+
|
|
42
|
+
'adapter.js': ({ content }) => {
|
|
43
|
+
// dedicated sveltekit adapter.
|
|
44
|
+
const sveltekit_adapter = `import { goto as go } from '$app/navigation'
|
|
45
|
+
import { get } from 'svelte/store';
|
|
46
|
+
import { browser, prerendering } from '$app/environment'
|
|
47
|
+
import { page } from '$app/stores'
|
|
48
|
+
import { error as svelteKitError } from '@sveltejs/kit'
|
|
49
|
+
|
|
50
|
+
export function goTo(location, options) {
|
|
51
|
+
go(location, options)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const isBrowser = browser
|
|
55
|
+
|
|
56
|
+
export let clientStarted = false;
|
|
57
|
+
|
|
58
|
+
export function setClientStarted() {
|
|
59
|
+
clientStarted = true
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const isPrerender = prerendering
|
|
63
|
+
|
|
64
|
+
export const error = svelteKitError
|
|
65
|
+
`
|
|
66
|
+
|
|
67
|
+
return framework === 'kit' ? sveltekit_adapter : content
|
|
68
|
+
},
|
|
41
69
|
},
|
|
42
70
|
|
|
43
71
|
// custom logic to pull a graphql document out of a svelte file
|
package/src/plugin/kit.ts
CHANGED
|
@@ -69,11 +69,12 @@ export function is_root_layout_script(config: Config, filename: string) {
|
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export function is_layout_component(
|
|
73
|
-
return (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
export function is_layout_component(framework: Framework, filename: string) {
|
|
73
|
+
return framework === 'kit' && filename.endsWith('+layout.svelte')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function is_layout(framework: Framework, filename: string) {
|
|
77
|
+
return is_layout_script(framework, filename) || is_layout_component(framework, filename)
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
export function is_component(config: Config, framework: Framework, filename: string) {
|
|
@@ -203,7 +204,7 @@ export async function walk_routes(
|
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
// inline layout queries
|
|
206
|
-
else if (is_layout_component(
|
|
207
|
+
else if (is_layout_component(framework, child)) {
|
|
207
208
|
// load the contents and parse it
|
|
208
209
|
const contents = await fs.readFile(childPath)
|
|
209
210
|
if (!contents) {
|
|
@@ -369,10 +369,10 @@ describe('kit route processor', function () {
|
|
|
369
369
|
`)
|
|
370
370
|
expect(route.script).toMatchInlineSnapshot(`
|
|
371
371
|
import GQL_MyQuery1 from "$houdini/plugins/houdini-svelte/stores/MyQuery1";
|
|
372
|
+
import { load_TestQuery } from "$houdini/plugins/houdini-svelte/stores/TestQuery";
|
|
372
373
|
import GQL_MyQuery2 from "$houdini/plugins/houdini-svelte/stores/MyQuery2";
|
|
373
374
|
import { load_MyQuery2 } from "$houdini/plugins/houdini-svelte/stores/MyQuery2";
|
|
374
375
|
import { load_MyQuery1 } from "$houdini/plugins/houdini-svelte/stores/MyQuery1";
|
|
375
|
-
import { load_TestQuery } from "$houdini/plugins/houdini-svelte/stores/TestQuery";
|
|
376
376
|
import { getCurrentConfig } from "$houdini/runtime/lib/config";
|
|
377
377
|
import { RequestContext } from "$houdini/plugins/houdini-svelte/runtime/session";
|
|
378
378
|
import GQL_TestQuery from "$houdini/plugins/houdini-svelte/stores/TestQuery";
|
|
@@ -386,14 +386,6 @@ describe('kit route processor', function () {
|
|
|
386
386
|
const houdiniConfig = await getCurrentConfig();
|
|
387
387
|
const promises = [];
|
|
388
388
|
const inputs = {};
|
|
389
|
-
inputs["TestQuery"] = {};
|
|
390
|
-
|
|
391
|
-
promises.push(load_TestQuery({
|
|
392
|
-
"variables": inputs["TestQuery"],
|
|
393
|
-
"event": context,
|
|
394
|
-
"blocking": false
|
|
395
|
-
}));
|
|
396
|
-
|
|
397
389
|
inputs["MyQuery1"] = {};
|
|
398
390
|
|
|
399
391
|
promises.push(load_MyQuery1({
|
|
@@ -414,6 +406,14 @@ describe('kit route processor', function () {
|
|
|
414
406
|
"blocking": false
|
|
415
407
|
}));
|
|
416
408
|
|
|
409
|
+
inputs["TestQuery"] = {};
|
|
410
|
+
|
|
411
|
+
promises.push(load_TestQuery({
|
|
412
|
+
"variables": inputs["TestQuery"],
|
|
413
|
+
"event": context,
|
|
414
|
+
"blocking": false
|
|
415
|
+
}));
|
|
416
|
+
|
|
417
417
|
let result = {};
|
|
418
418
|
|
|
419
419
|
try {
|
|
@@ -444,6 +444,7 @@ describe('kit route processor', function () {
|
|
|
444
444
|
expect(route.component).toMatchInlineSnapshot(
|
|
445
445
|
'import GQL_TestPageQuery from "$houdini/plugins/houdini-svelte/stores/TestPageQuery";'
|
|
446
446
|
)
|
|
447
|
+
|
|
447
448
|
expect(route.script).toMatchInlineSnapshot(`
|
|
448
449
|
import { load_TestPageQuery } from "$houdini/plugins/houdini-svelte/stores/TestPageQuery";
|
|
449
450
|
import { getCurrentConfig } from "$houdini/runtime/lib/config";
|
|
@@ -477,6 +478,32 @@ describe('kit route processor', function () {
|
|
|
477
478
|
};
|
|
478
479
|
}
|
|
479
480
|
`)
|
|
481
|
+
|
|
482
|
+
expect(route.layout).toMatchInlineSnapshot(`
|
|
483
|
+
import { page } from "$app/stores";
|
|
484
|
+
import { extractSession, setClientSession } from "$houdini/plugins/houdini-svelte/runtime/session";
|
|
485
|
+
import { onMount } from "svelte";
|
|
486
|
+
import { setClientStarted } from "$houdini/plugins/houdini-svelte/runtime/adapter";
|
|
487
|
+
import GQL_TestPageQuery from "$houdini/plugins/houdini-svelte/stores/TestPageQuery";
|
|
488
|
+
onMount(() => setClientStarted());
|
|
489
|
+
|
|
490
|
+
page.subscribe(val => {
|
|
491
|
+
setClientSession(extractSession(val.data));
|
|
492
|
+
});
|
|
493
|
+
`)
|
|
494
|
+
|
|
495
|
+
expect(route.layout_script).toMatchInlineSnapshot(`
|
|
496
|
+
import GQL_TestPageQuery from "$houdini/plugins/houdini-svelte/stores/TestPageQuery";
|
|
497
|
+
|
|
498
|
+
export async function load(event) {
|
|
499
|
+
const __houdini__vite__plugin__return__value__ = {};
|
|
500
|
+
|
|
501
|
+
return {
|
|
502
|
+
...event.data,
|
|
503
|
+
...__houdini__vite__plugin__return__value__
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
`)
|
|
480
507
|
})
|
|
481
508
|
|
|
482
509
|
test('route with +layout.gql query', async function () {
|
|
@@ -493,6 +520,24 @@ describe('kit route processor', function () {
|
|
|
493
520
|
expect(route.component).toMatchInlineSnapshot(
|
|
494
521
|
'import GQL_TestLayoutQuery from "$houdini/plugins/houdini-svelte/stores/TestLayoutQuery";'
|
|
495
522
|
)
|
|
523
|
+
|
|
524
|
+
expect(route.script).toMatchInlineSnapshot(
|
|
525
|
+
'import GQL_TestLayoutQuery from "$houdini/plugins/houdini-svelte/stores/TestLayoutQuery";'
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
expect(route.layout).toMatchInlineSnapshot(`
|
|
529
|
+
import { page } from "$app/stores";
|
|
530
|
+
import { extractSession, setClientSession } from "$houdini/plugins/houdini-svelte/runtime/session";
|
|
531
|
+
import { onMount } from "svelte";
|
|
532
|
+
import { setClientStarted } from "$houdini/plugins/houdini-svelte/runtime/adapter";
|
|
533
|
+
import GQL_TestLayoutQuery from "$houdini/plugins/houdini-svelte/stores/TestLayoutQuery";
|
|
534
|
+
onMount(() => setClientStarted());
|
|
535
|
+
|
|
536
|
+
page.subscribe(val => {
|
|
537
|
+
setClientSession(extractSession(val.data));
|
|
538
|
+
});
|
|
539
|
+
`)
|
|
540
|
+
|
|
496
541
|
expect(route.layout_script).toMatchInlineSnapshot(`
|
|
497
542
|
import { load_TestLayoutQuery } from "$houdini/plugins/houdini-svelte/stores/TestLayoutQuery";
|
|
498
543
|
import { getCurrentConfig } from "$houdini/runtime/lib/config";
|
|
@@ -11,6 +11,7 @@ import { parseSvelte } from '../../extract'
|
|
|
11
11
|
import { extract_load_function } from '../../extractLoadFunction'
|
|
12
12
|
import {
|
|
13
13
|
HoudiniRouteScript,
|
|
14
|
+
is_layout,
|
|
14
15
|
is_route,
|
|
15
16
|
is_route_script,
|
|
16
17
|
layout_query_path,
|
|
@@ -63,21 +64,30 @@ export default async function kit_load_generator(page: SvelteTransformPage) {
|
|
|
63
64
|
find_page_info(page),
|
|
64
65
|
])
|
|
65
66
|
|
|
66
|
-
const
|
|
67
|
+
const houdini_load_queries = []
|
|
67
68
|
for (const [i, target] of (page_info.houdini_load ?? []).entries()) {
|
|
68
|
-
|
|
69
|
+
houdini_load_queries.push({
|
|
69
70
|
name: target.name!.value,
|
|
70
71
|
variables: operation_requires_variables(target),
|
|
71
72
|
store_id: AST.memberExpression(AST.identifier('houdini_load'), AST.literal(i)),
|
|
72
73
|
})
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
//
|
|
76
|
+
// add the load functions
|
|
76
77
|
if (script) {
|
|
77
|
-
|
|
78
|
+
const queries_that_needs_a_load = [...houdini_load_queries, ...inline_queries]
|
|
79
|
+
// Add special queries files to the list only if we are in the good context
|
|
80
|
+
const isLayout = is_layout(page.framework, page.filepath)
|
|
81
|
+
if (isLayout && layout_query) {
|
|
82
|
+
queries_that_needs_a_load.push(layout_query)
|
|
83
|
+
}
|
|
84
|
+
if (!isLayout && page_query) {
|
|
85
|
+
queries_that_needs_a_load.push(page_query)
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
add_load({
|
|
79
89
|
page,
|
|
80
|
-
queries,
|
|
90
|
+
queries: queries_that_needs_a_load,
|
|
81
91
|
page_info,
|
|
82
92
|
})
|
|
83
93
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Config, Script } from 'houdini';
|
|
2
|
-
import recast from 'recast';
|
|
3
|
-
declare type Identifier = recast.types.namedTypes.Identifier;
|
|
4
|
-
export declare function store_import({ config, script, artifact, local, }: {
|
|
5
|
-
config: Config;
|
|
6
|
-
script: Script;
|
|
7
|
-
artifact: {
|
|
8
|
-
name: string;
|
|
9
|
-
};
|
|
10
|
-
local?: string;
|
|
11
|
-
}): {
|
|
12
|
-
id: Identifier;
|
|
13
|
-
added: number;
|
|
14
|
-
};
|
|
15
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { fs, path } from 'houdini'
|
|
2
|
-
|
|
3
|
-
import { PluginGenerateInput } from '.'
|
|
4
|
-
|
|
5
|
-
export default async function generateAdapter({ config, framework }: PluginGenerateInput) {
|
|
6
|
-
// we only need to generate an adapter for kit (the default one is fine for vanilla svelte)
|
|
7
|
-
if (framework !== 'kit') {
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// the location of the adapter
|
|
12
|
-
const adapterLocation = path.join(config.pluginRuntimeDirectory('houdini-svelte'), 'adapter.js')
|
|
13
|
-
|
|
14
|
-
// figure out which adapter we need to lay down
|
|
15
|
-
const adapter = {
|
|
16
|
-
kit: sveltekitAdapter,
|
|
17
|
-
}[framework]
|
|
18
|
-
|
|
19
|
-
// write the index file that exports the runtime
|
|
20
|
-
await fs.mkdirp(path.dirname(adapterLocation))
|
|
21
|
-
await fs.writeFile(adapterLocation, adapter)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const sveltekitAdapter = `import { goto as go } from '$app/navigation'
|
|
25
|
-
import { get } from 'svelte/store';
|
|
26
|
-
import { browser, prerendering } from '$app/environment'
|
|
27
|
-
import { page } from '$app/stores'
|
|
28
|
-
import { error as svelteKitError } from '@sveltejs/kit'
|
|
29
|
-
|
|
30
|
-
export function goTo(location, options) {
|
|
31
|
-
go(location, options)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const isBrowser = browser
|
|
35
|
-
|
|
36
|
-
export let clientStarted = false;
|
|
37
|
-
|
|
38
|
-
export function setClientStarted() {
|
|
39
|
-
clientStarted = true
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const isPrerender = prerendering
|
|
43
|
-
|
|
44
|
-
export const error = svelteKitError
|
|
45
|
-
`
|
package/src/plugin/imports.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Config, Script } from 'houdini'
|
|
2
|
-
import { ensure_imports } from 'houdini/vite'
|
|
3
|
-
import recast from 'recast'
|
|
4
|
-
|
|
5
|
-
import { store_import_path } from './kit'
|
|
6
|
-
|
|
7
|
-
type Identifier = recast.types.namedTypes.Identifier
|
|
8
|
-
|
|
9
|
-
export function store_import({
|
|
10
|
-
config,
|
|
11
|
-
script,
|
|
12
|
-
artifact,
|
|
13
|
-
local,
|
|
14
|
-
}: {
|
|
15
|
-
config: Config
|
|
16
|
-
script: Script
|
|
17
|
-
artifact: { name: string }
|
|
18
|
-
local?: string
|
|
19
|
-
}): { id: Identifier; added: number } {
|
|
20
|
-
const { ids, added } = ensure_imports({
|
|
21
|
-
config,
|
|
22
|
-
script,
|
|
23
|
-
sourceModule: store_import_path({ config, name: artifact.name }),
|
|
24
|
-
import: `GQL_${artifact.name}`,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return { id: ids, added }
|
|
28
|
-
}
|