houdini-svelte 0.0.0-20240930203739 → 0.0.0-20241011124909
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 +34 -28
- package/build/plugin-esm/index.js +34 -28
- package/build/preprocess-cjs/index.js +435 -431
- package/build/preprocess-esm/index.js +435 -431
- package/build/test-cjs/index.js +38 -32
- package/build/test-esm/index.js +38 -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,7 @@ async function extract_default({
|
|
|
170345
170345
|
content
|
|
170346
170346
|
}) {
|
|
170347
170347
|
const documents = [];
|
|
170348
|
-
let parsedFile = await parseSvelte(content);
|
|
170348
|
+
let parsedFile = await parseSvelte(content, plugin_config(config).forceRunesMode);
|
|
170349
170349
|
if (!parsedFile) {
|
|
170350
170350
|
return documents;
|
|
170351
170351
|
}
|
|
@@ -170373,7 +170373,7 @@ var svelteRunes = [
|
|
|
170373
170373
|
"$inspect().with",
|
|
170374
170374
|
"$host"
|
|
170375
170375
|
];
|
|
170376
|
-
async function parseSvelte(str) {
|
|
170376
|
+
async function parseSvelte(str, forceRunes) {
|
|
170377
170377
|
str = str.replace(/(<script[^>]*)(\s+)(generics="[^"]+?")/, (_, $1, $2, $3) => {
|
|
170378
170378
|
return $1 + $2 + " ".repeat($3.length);
|
|
170379
170379
|
});
|
|
@@ -170404,30 +170404,34 @@ async function parseSvelte(str) {
|
|
|
170404
170404
|
const string2 = str.slice(greaterThanIndex, lessThanIndex);
|
|
170405
170405
|
const scriptParsed = parseJS(string2);
|
|
170406
170406
|
let usesRunes = false;
|
|
170407
|
-
|
|
170408
|
-
|
|
170409
|
-
|
|
170410
|
-
|
|
170411
|
-
|
|
170412
|
-
|
|
170413
|
-
|
|
170414
|
-
|
|
170415
|
-
|
|
170416
|
-
|
|
170417
|
-
|
|
170418
|
-
|
|
170419
|
-
|
|
170420
|
-
|
|
170421
|
-
|
|
170422
|
-
|
|
170423
|
-
|
|
170424
|
-
|
|
170425
|
-
|
|
170407
|
+
if (forceRunes) {
|
|
170408
|
+
usesRunes = true;
|
|
170409
|
+
} else {
|
|
170410
|
+
walk(scriptParsed, {
|
|
170411
|
+
enter(node) {
|
|
170412
|
+
if (node.type === "CallExpression") {
|
|
170413
|
+
let callNode = node;
|
|
170414
|
+
if (callNode.callee.type === "Identifier") {
|
|
170415
|
+
const calleeName = callNode.callee.name;
|
|
170416
|
+
if (svelteRunes.some((rune) => rune === calleeName)) {
|
|
170417
|
+
usesRunes = true;
|
|
170418
|
+
this.skip();
|
|
170419
|
+
}
|
|
170420
|
+
} else if (callNode.callee.type === "MemberExpression") {
|
|
170421
|
+
const callee = callNode.callee;
|
|
170422
|
+
if (callee.object.type !== "Identifier" || callee.property.type !== "Identifier") {
|
|
170423
|
+
return;
|
|
170424
|
+
}
|
|
170425
|
+
const calleeName = `${callee.object.name}.${callee.property.name}`;
|
|
170426
|
+
if (svelteRunes.some((rune) => rune === calleeName)) {
|
|
170427
|
+
usesRunes = true;
|
|
170428
|
+
this.skip();
|
|
170429
|
+
}
|
|
170426
170430
|
}
|
|
170427
170431
|
}
|
|
170428
170432
|
}
|
|
170429
|
-
}
|
|
170430
|
-
}
|
|
170433
|
+
});
|
|
170434
|
+
}
|
|
170431
170435
|
return {
|
|
170432
170436
|
script: scriptParsed,
|
|
170433
170437
|
position: {
|
|
@@ -170850,7 +170854,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170850
170854
|
if (!contents) {
|
|
170851
170855
|
continue;
|
|
170852
170856
|
}
|
|
170853
|
-
const parsed = await parseSvelte(contents);
|
|
170857
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170854
170858
|
if (!parsed) {
|
|
170855
170859
|
continue;
|
|
170856
170860
|
}
|
|
@@ -170875,7 +170879,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170875
170879
|
if (!contents) {
|
|
170876
170880
|
continue;
|
|
170877
170881
|
}
|
|
170878
|
-
const parsed = await parseSvelte(contents);
|
|
170882
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170879
170883
|
if (!parsed) {
|
|
170880
170884
|
continue;
|
|
170881
170885
|
}
|
|
@@ -170900,7 +170904,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170900
170904
|
if (!contents) {
|
|
170901
170905
|
continue;
|
|
170902
170906
|
}
|
|
170903
|
-
const parsed = await parseSvelte(contents);
|
|
170907
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170904
170908
|
if (!parsed) {
|
|
170905
170909
|
continue;
|
|
170906
170910
|
}
|
|
@@ -171009,6 +171013,7 @@ function plugin_config(config) {
|
|
|
171009
171013
|
pageQueryFilename: "+page.gql",
|
|
171010
171014
|
layoutQueryFilename: "+layout.gql",
|
|
171011
171015
|
static: false,
|
|
171016
|
+
forceRunesMode: false,
|
|
171012
171017
|
...cfg,
|
|
171013
171018
|
customStores: {
|
|
171014
171019
|
query: "../runtime/stores/query.QueryStore",
|
|
@@ -172398,7 +172403,8 @@ async function kit_load_generator(page) {
|
|
|
172398
172403
|
find_inline_queries(
|
|
172399
172404
|
page,
|
|
172400
172405
|
route ? page.script : (await parseSvelte(
|
|
172401
|
-
await fs_exports.readFile(route_page_path(page.config, page.filepath)) || ""
|
|
172406
|
+
await fs_exports.readFile(route_page_path(page.config, page.filepath)) || "",
|
|
172407
|
+
plugin_config(page.config).forceRunesMode
|
|
172402
172408
|
))?.script ?? null,
|
|
172403
172409
|
inline_query_store
|
|
172404
172410
|
),
|
|
@@ -172954,7 +172960,7 @@ async function apply_transforms(framework2, page) {
|
|
|
172954
172960
|
let useRunes = false;
|
|
172955
172961
|
try {
|
|
172956
172962
|
if (page.filepath.endsWith(".svelte")) {
|
|
172957
|
-
const res = await parseSvelte(page.content);
|
|
172963
|
+
const res = await parseSvelte(page.content, plugin_config(page.config).forceRunesMode);
|
|
172958
172964
|
if (res) {
|
|
172959
172965
|
script = res.script;
|
|
172960
172966
|
position = res.position;
|
|
@@ -170339,7 +170339,7 @@ async function extract_default({
|
|
|
170339
170339
|
content
|
|
170340
170340
|
}) {
|
|
170341
170341
|
const documents = [];
|
|
170342
|
-
let parsedFile = await parseSvelte(content);
|
|
170342
|
+
let parsedFile = await parseSvelte(content, plugin_config(config).forceRunesMode);
|
|
170343
170343
|
if (!parsedFile) {
|
|
170344
170344
|
return documents;
|
|
170345
170345
|
}
|
|
@@ -170367,7 +170367,7 @@ var svelteRunes = [
|
|
|
170367
170367
|
"$inspect().with",
|
|
170368
170368
|
"$host"
|
|
170369
170369
|
];
|
|
170370
|
-
async function parseSvelte(str) {
|
|
170370
|
+
async function parseSvelte(str, forceRunes) {
|
|
170371
170371
|
str = str.replace(/(<script[^>]*)(\s+)(generics="[^"]+?")/, (_, $1, $2, $3) => {
|
|
170372
170372
|
return $1 + $2 + " ".repeat($3.length);
|
|
170373
170373
|
});
|
|
@@ -170398,30 +170398,34 @@ async function parseSvelte(str) {
|
|
|
170398
170398
|
const string2 = str.slice(greaterThanIndex, lessThanIndex);
|
|
170399
170399
|
const scriptParsed = parseJS(string2);
|
|
170400
170400
|
let usesRunes = false;
|
|
170401
|
-
|
|
170402
|
-
|
|
170403
|
-
|
|
170404
|
-
|
|
170405
|
-
|
|
170406
|
-
|
|
170407
|
-
|
|
170408
|
-
|
|
170409
|
-
|
|
170410
|
-
|
|
170411
|
-
|
|
170412
|
-
|
|
170413
|
-
|
|
170414
|
-
|
|
170415
|
-
|
|
170416
|
-
|
|
170417
|
-
|
|
170418
|
-
|
|
170419
|
-
|
|
170401
|
+
if (forceRunes) {
|
|
170402
|
+
usesRunes = true;
|
|
170403
|
+
} else {
|
|
170404
|
+
walk(scriptParsed, {
|
|
170405
|
+
enter(node) {
|
|
170406
|
+
if (node.type === "CallExpression") {
|
|
170407
|
+
let callNode = node;
|
|
170408
|
+
if (callNode.callee.type === "Identifier") {
|
|
170409
|
+
const calleeName = callNode.callee.name;
|
|
170410
|
+
if (svelteRunes.some((rune) => rune === calleeName)) {
|
|
170411
|
+
usesRunes = true;
|
|
170412
|
+
this.skip();
|
|
170413
|
+
}
|
|
170414
|
+
} else if (callNode.callee.type === "MemberExpression") {
|
|
170415
|
+
const callee = callNode.callee;
|
|
170416
|
+
if (callee.object.type !== "Identifier" || callee.property.type !== "Identifier") {
|
|
170417
|
+
return;
|
|
170418
|
+
}
|
|
170419
|
+
const calleeName = `${callee.object.name}.${callee.property.name}`;
|
|
170420
|
+
if (svelteRunes.some((rune) => rune === calleeName)) {
|
|
170421
|
+
usesRunes = true;
|
|
170422
|
+
this.skip();
|
|
170423
|
+
}
|
|
170420
170424
|
}
|
|
170421
170425
|
}
|
|
170422
170426
|
}
|
|
170423
|
-
}
|
|
170424
|
-
}
|
|
170427
|
+
});
|
|
170428
|
+
}
|
|
170425
170429
|
return {
|
|
170426
170430
|
script: scriptParsed,
|
|
170427
170431
|
position: {
|
|
@@ -170844,7 +170848,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170844
170848
|
if (!contents) {
|
|
170845
170849
|
continue;
|
|
170846
170850
|
}
|
|
170847
|
-
const parsed = await parseSvelte(contents);
|
|
170851
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170848
170852
|
if (!parsed) {
|
|
170849
170853
|
continue;
|
|
170850
170854
|
}
|
|
@@ -170869,7 +170873,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170869
170873
|
if (!contents) {
|
|
170870
170874
|
continue;
|
|
170871
170875
|
}
|
|
170872
|
-
const parsed = await parseSvelte(contents);
|
|
170876
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170873
170877
|
if (!parsed) {
|
|
170874
170878
|
continue;
|
|
170875
170879
|
}
|
|
@@ -170894,7 +170898,7 @@ async function walk_routes(config, framework2, visitor, dirpath = config.routesD
|
|
|
170894
170898
|
if (!contents) {
|
|
170895
170899
|
continue;
|
|
170896
170900
|
}
|
|
170897
|
-
const parsed = await parseSvelte(contents);
|
|
170901
|
+
const parsed = await parseSvelte(contents, plugin_config(config).forceRunesMode);
|
|
170898
170902
|
if (!parsed) {
|
|
170899
170903
|
continue;
|
|
170900
170904
|
}
|
|
@@ -171003,6 +171007,7 @@ function plugin_config(config) {
|
|
|
171003
171007
|
pageQueryFilename: "+page.gql",
|
|
171004
171008
|
layoutQueryFilename: "+layout.gql",
|
|
171005
171009
|
static: false,
|
|
171010
|
+
forceRunesMode: false,
|
|
171006
171011
|
...cfg,
|
|
171007
171012
|
customStores: {
|
|
171008
171013
|
query: "../runtime/stores/query.QueryStore",
|
|
@@ -172392,7 +172397,8 @@ async function kit_load_generator(page) {
|
|
|
172392
172397
|
find_inline_queries(
|
|
172393
172398
|
page,
|
|
172394
172399
|
route ? page.script : (await parseSvelte(
|
|
172395
|
-
await fs_exports.readFile(route_page_path(page.config, page.filepath)) || ""
|
|
172400
|
+
await fs_exports.readFile(route_page_path(page.config, page.filepath)) || "",
|
|
172401
|
+
plugin_config(page.config).forceRunesMode
|
|
172396
172402
|
))?.script ?? null,
|
|
172397
172403
|
inline_query_store
|
|
172398
172404
|
),
|
|
@@ -172948,7 +172954,7 @@ async function apply_transforms(framework2, page) {
|
|
|
172948
172954
|
let useRunes = false;
|
|
172949
172955
|
try {
|
|
172950
172956
|
if (page.filepath.endsWith(".svelte")) {
|
|
172951
|
-
const res = await parseSvelte(page.content);
|
|
172957
|
+
const res = await parseSvelte(page.content, plugin_config(page.config).forceRunesMode);
|
|
172952
172958
|
if (res) {
|
|
172953
172959
|
script = res.script;
|
|
172954
172960
|
position = res.position;
|