houdini-svelte 0.0.0-20240930203739 → 0.0.0-20240930215630
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/extract.d.ts +1 -1
- package/build/plugin/index.d.ts +6 -0
- package/build/plugin/transforms/index.d.ts +1 -1
- package/build/plugin-cjs/index.js +35 -28
- package/build/plugin-esm/index.js +35 -28
- package/build/preprocess-cjs/index.js +435 -431
- package/build/preprocess-esm/index.js +435 -431
- package/build/test-cjs/index.js +39 -32
- package/build/test-esm/index.js +39 -32
- package/package.json +2 -2
package/build/plugin/index.d.ts
CHANGED
|
@@ -38,6 +38,12 @@ export type HoudiniSvelteConfig = {
|
|
|
38
38
|
* @default undefined
|
|
39
39
|
*/
|
|
40
40
|
framework: 'kit' | 'svelte' | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Force Houdini to always use Runes under the hood. Set this to true if you are enabling Runes mode globally for your app.
|
|
43
|
+
* When disabled, Houdini will try to detect Runes and go into Runes mode if required.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
forceRunesMode?: boolean;
|
|
41
47
|
/**
|
|
42
48
|
* Override the classes used when building stores for documents. Values should take the form package.export
|
|
43
49
|
* For example, if you have a store exported from $lib/stores you should set the value to "$lib/stores.CustomStore".
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TransformPage } from 'houdini/vite';
|
|
2
2
|
import type { SourceMapInput } from 'rollup';
|
|
3
|
-
import type
|
|
3
|
+
import { type Framework } from '../kit';
|
|
4
4
|
export default function apply_transforms(framework: Framework, page: TransformPage): Promise<{
|
|
5
5
|
code: string;
|
|
6
6
|
map?: SourceMapInput;
|
|
@@ -170345,7 +170345,8 @@ async function extract_default({
|
|
|
170345
170345
|
content
|
|
170346
170346
|
}) {
|
|
170347
170347
|
const documents = [];
|
|
170348
|
-
|
|
170348
|
+
console.log(config.plugins);
|
|
170349
|
+
let parsedFile = await parseSvelte(content, plugin_config(config).forceRunesMode);
|
|
170349
170350
|
if (!parsedFile) {
|
|
170350
170351
|
return documents;
|
|
170351
170352
|
}
|
|
@@ -170373,7 +170374,7 @@ var svelteRunes = [
|
|
|
170373
170374
|
"$inspect().with",
|
|
170374
170375
|
"$host"
|
|
170375
170376
|
];
|
|
170376
|
-
async function parseSvelte(str) {
|
|
170377
|
+
async function parseSvelte(str, forceRunes) {
|
|
170377
170378
|
str = str.replace(/(<script[^>]*)(\s+)(generics="[^"]+?")/, (_, $1, $2, $3) => {
|
|
170378
170379
|
return $1 + $2 + " ".repeat($3.length);
|
|
170379
170380
|
});
|
|
@@ -170404,30 +170405,34 @@ async function parseSvelte(str) {
|
|
|
170404
170405
|
const string2 = str.slice(greaterThanIndex, lessThanIndex);
|
|
170405
170406
|
const scriptParsed = parseJS(string2);
|
|
170406
170407
|
let usesRunes = false;
|
|
170407
|
-
|
|
170408
|
-
|
|
170409
|
-
|
|
170410
|
-
|
|
170411
|
-
|
|
170412
|
-
|
|
170413
|
-
|
|
170414
|
-
|
|
170415
|
-
|
|
170416
|
-
|
|
170417
|
-
|
|
170418
|
-
|
|
170419
|
-
|
|
170420
|
-
|
|
170421
|
-
|
|
170422
|
-
|
|
170423
|
-
|
|
170424
|
-
|
|
170425
|
-
|
|
170408
|
+
if (forceRunes) {
|
|
170409
|
+
usesRunes = true;
|
|
170410
|
+
} else {
|
|
170411
|
+
walk(scriptParsed, {
|
|
170412
|
+
enter(node) {
|
|
170413
|
+
if (node.type === "CallExpression") {
|
|
170414
|
+
let callNode = node;
|
|
170415
|
+
if (callNode.callee.type === "Identifier") {
|
|
170416
|
+
const calleeName = callNode.callee.name;
|
|
170417
|
+
if (svelteRunes.some((rune) => rune === calleeName)) {
|
|
170418
|
+
usesRunes = true;
|
|
170419
|
+
this.skip();
|
|
170420
|
+
}
|
|
170421
|
+
} else if (callNode.callee.type === "MemberExpression") {
|
|
170422
|
+
const callee = callNode.callee;
|
|
170423
|
+
if (callee.object.type !== "Identifier" || callee.property.type !== "Identifier") {
|
|
170424
|
+
return;
|
|
170425
|
+
}
|
|
170426
|
+
const calleeName = `${callee.object.name}.${callee.property.name}`;
|
|
170427
|
+
if (svelteRunes.some((rune) => rune === calleeName)) {
|
|
170428
|
+
usesRunes = true;
|
|
170429
|
+
this.skip();
|
|
170430
|
+
}
|
|
170426
170431
|
}
|
|
170427
170432
|
}
|
|
170428
170433
|
}
|
|
170429
|
-
}
|
|
170430
|
-
}
|
|
170434
|
+
});
|
|
170435
|
+
}
|
|
170431
170436
|
return {
|
|
170432
170437
|
script: scriptParsed,
|
|
170433
170438
|
position: {
|
|
@@ -170850,7 +170855,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170850
170855
|
if (!contents) {
|
|
170851
170856
|
continue;
|
|
170852
170857
|
}
|
|
170853
|
-
const parsed = await parseSvelte(contents);
|
|
170858
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170854
170859
|
if (!parsed) {
|
|
170855
170860
|
continue;
|
|
170856
170861
|
}
|
|
@@ -170875,7 +170880,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170875
170880
|
if (!contents) {
|
|
170876
170881
|
continue;
|
|
170877
170882
|
}
|
|
170878
|
-
const parsed = await parseSvelte(contents);
|
|
170883
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170879
170884
|
if (!parsed) {
|
|
170880
170885
|
continue;
|
|
170881
170886
|
}
|
|
@@ -170900,7 +170905,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170900
170905
|
if (!contents) {
|
|
170901
170906
|
continue;
|
|
170902
170907
|
}
|
|
170903
|
-
const parsed = await parseSvelte(contents);
|
|
170908
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170904
170909
|
if (!parsed) {
|
|
170905
170910
|
continue;
|
|
170906
170911
|
}
|
|
@@ -171009,6 +171014,7 @@ function plugin_config(config) {
|
|
|
171009
171014
|
pageQueryFilename: "+page.gql",
|
|
171010
171015
|
layoutQueryFilename: "+layout.gql",
|
|
171011
171016
|
static: false,
|
|
171017
|
+
forceRunesMode: false,
|
|
171012
171018
|
...cfg,
|
|
171013
171019
|
customStores: {
|
|
171014
171020
|
query: "../runtime/stores/query.QueryStore",
|
|
@@ -172398,7 +172404,8 @@ async function kit_load_generator(page) {
|
|
|
172398
172404
|
find_inline_queries(
|
|
172399
172405
|
page,
|
|
172400
172406
|
route ? page.script : (await parseSvelte(
|
|
172401
|
-
await fs_exports.readFile(route_page_path(page.config, page.filepath)) || ""
|
|
172407
|
+
await fs_exports.readFile(route_page_path(page.config, page.filepath)) || "",
|
|
172408
|
+
plugin_config(page.config).forceRunesMode
|
|
172402
172409
|
))?.script ?? null,
|
|
172403
172410
|
inline_query_store
|
|
172404
172411
|
),
|
|
@@ -172954,7 +172961,7 @@ async function apply_transforms(framework2, page) {
|
|
|
172954
172961
|
let useRunes = false;
|
|
172955
172962
|
try {
|
|
172956
172963
|
if (page.filepath.endsWith(".svelte")) {
|
|
172957
|
-
const res = await parseSvelte(page.content);
|
|
172964
|
+
const res = await parseSvelte(page.content, plugin_config(page.config).forceRunesMode);
|
|
172958
172965
|
if (res) {
|
|
172959
172966
|
script = res.script;
|
|
172960
172967
|
position = res.position;
|
|
@@ -170339,7 +170339,8 @@ async function extract_default({
|
|
|
170339
170339
|
content
|
|
170340
170340
|
}) {
|
|
170341
170341
|
const documents = [];
|
|
170342
|
-
|
|
170342
|
+
console.log(config.plugins);
|
|
170343
|
+
let parsedFile = await parseSvelte(content, plugin_config(config).forceRunesMode);
|
|
170343
170344
|
if (!parsedFile) {
|
|
170344
170345
|
return documents;
|
|
170345
170346
|
}
|
|
@@ -170367,7 +170368,7 @@ var svelteRunes = [
|
|
|
170367
170368
|
"$inspect().with",
|
|
170368
170369
|
"$host"
|
|
170369
170370
|
];
|
|
170370
|
-
async function parseSvelte(str) {
|
|
170371
|
+
async function parseSvelte(str, forceRunes) {
|
|
170371
170372
|
str = str.replace(/(<script[^>]*)(\s+)(generics="[^"]+?")/, (_, $1, $2, $3) => {
|
|
170372
170373
|
return $1 + $2 + " ".repeat($3.length);
|
|
170373
170374
|
});
|
|
@@ -170398,30 +170399,34 @@ async function parseSvelte(str) {
|
|
|
170398
170399
|
const string2 = str.slice(greaterThanIndex, lessThanIndex);
|
|
170399
170400
|
const scriptParsed = parseJS(string2);
|
|
170400
170401
|
let usesRunes = false;
|
|
170401
|
-
|
|
170402
|
-
|
|
170403
|
-
|
|
170404
|
-
|
|
170405
|
-
|
|
170406
|
-
|
|
170407
|
-
|
|
170408
|
-
|
|
170409
|
-
|
|
170410
|
-
|
|
170411
|
-
|
|
170412
|
-
|
|
170413
|
-
|
|
170414
|
-
|
|
170415
|
-
|
|
170416
|
-
|
|
170417
|
-
|
|
170418
|
-
|
|
170419
|
-
|
|
170402
|
+
if (forceRunes) {
|
|
170403
|
+
usesRunes = true;
|
|
170404
|
+
} else {
|
|
170405
|
+
walk(scriptParsed, {
|
|
170406
|
+
enter(node) {
|
|
170407
|
+
if (node.type === "CallExpression") {
|
|
170408
|
+
let callNode = node;
|
|
170409
|
+
if (callNode.callee.type === "Identifier") {
|
|
170410
|
+
const calleeName = callNode.callee.name;
|
|
170411
|
+
if (svelteRunes.some((rune) => rune === calleeName)) {
|
|
170412
|
+
usesRunes = true;
|
|
170413
|
+
this.skip();
|
|
170414
|
+
}
|
|
170415
|
+
} else if (callNode.callee.type === "MemberExpression") {
|
|
170416
|
+
const callee = callNode.callee;
|
|
170417
|
+
if (callee.object.type !== "Identifier" || callee.property.type !== "Identifier") {
|
|
170418
|
+
return;
|
|
170419
|
+
}
|
|
170420
|
+
const calleeName = `${callee.object.name}.${callee.property.name}`;
|
|
170421
|
+
if (svelteRunes.some((rune) => rune === calleeName)) {
|
|
170422
|
+
usesRunes = true;
|
|
170423
|
+
this.skip();
|
|
170424
|
+
}
|
|
170420
170425
|
}
|
|
170421
170426
|
}
|
|
170422
170427
|
}
|
|
170423
|
-
}
|
|
170424
|
-
}
|
|
170428
|
+
});
|
|
170429
|
+
}
|
|
170425
170430
|
return {
|
|
170426
170431
|
script: scriptParsed,
|
|
170427
170432
|
position: {
|
|
@@ -170844,7 +170849,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170844
170849
|
if (!contents) {
|
|
170845
170850
|
continue;
|
|
170846
170851
|
}
|
|
170847
|
-
const parsed = await parseSvelte(contents);
|
|
170852
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170848
170853
|
if (!parsed) {
|
|
170849
170854
|
continue;
|
|
170850
170855
|
}
|
|
@@ -170869,7 +170874,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170869
170874
|
if (!contents) {
|
|
170870
170875
|
continue;
|
|
170871
170876
|
}
|
|
170872
|
-
const parsed = await parseSvelte(contents);
|
|
170877
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170873
170878
|
if (!parsed) {
|
|
170874
170879
|
continue;
|
|
170875
170880
|
}
|
|
@@ -170894,7 +170899,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170894
170899
|
if (!contents) {
|
|
170895
170900
|
continue;
|
|
170896
170901
|
}
|
|
170897
|
-
const parsed = await parseSvelte(contents);
|
|
170902
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170898
170903
|
if (!parsed) {
|
|
170899
170904
|
continue;
|
|
170900
170905
|
}
|
|
@@ -171003,6 +171008,7 @@ function plugin_config(config) {
|
|
|
171003
171008
|
pageQueryFilename: "+page.gql",
|
|
171004
171009
|
layoutQueryFilename: "+layout.gql",
|
|
171005
171010
|
static: false,
|
|
171011
|
+
forceRunesMode: false,
|
|
171006
171012
|
...cfg,
|
|
171007
171013
|
customStores: {
|
|
171008
171014
|
query: "../runtime/stores/query.QueryStore",
|
|
@@ -172392,7 +172398,8 @@ async function kit_load_generator(page) {
|
|
|
172392
172398
|
find_inline_queries(
|
|
172393
172399
|
page,
|
|
172394
172400
|
route ? page.script : (await parseSvelte(
|
|
172395
|
-
await fs_exports.readFile(route_page_path(page.config, page.filepath)) || ""
|
|
172401
|
+
await fs_exports.readFile(route_page_path(page.config, page.filepath)) || "",
|
|
172402
|
+
plugin_config(page.config).forceRunesMode
|
|
172396
172403
|
))?.script ?? null,
|
|
172397
172404
|
inline_query_store
|
|
172398
172405
|
),
|
|
@@ -172948,7 +172955,7 @@ async function apply_transforms(framework2, page) {
|
|
|
172948
172955
|
let useRunes = false;
|
|
172949
172956
|
try {
|
|
172950
172957
|
if (page.filepath.endsWith(".svelte")) {
|
|
172951
|
-
const res = await parseSvelte(page.content);
|
|
172958
|
+
const res = await parseSvelte(page.content, plugin_config(page.config).forceRunesMode);
|
|
172952
172959
|
if (res) {
|
|
172953
172960
|
script = res.script;
|
|
172954
172961
|
position = res.position;
|