houdini 1.5.3 → 1.5.4
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/cmd-cjs/index.js +418 -544
- package/build/cmd-esm/index.js +268 -394
- package/build/codegen/generators/runtime/index.d.ts +2 -7
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +8 -1
- package/build/codegen-cjs/index.js +389 -389
- package/build/codegen-esm/index.js +239 -239
- package/build/lib/router/conventions.d.ts +1 -1
- package/build/lib/router/manifest.d.ts +1 -1
- package/build/lib/typescript.d.ts +1 -1
- package/build/lib-cjs/index.js +665 -663
- package/build/lib-esm/index.js +665 -663
- package/build/test-cjs/index.js +398 -398
- package/build/test-esm/index.js +248 -248
- package/build/vite-cjs/index.js +741 -739
- package/build/vite-esm/index.js +631 -629
- package/package.json +1 -1
package/build/lib-cjs/index.js
CHANGED
|
@@ -59882,7 +59882,7 @@ function mergeSchemas(config) {
|
|
|
59882
59882
|
}
|
|
59883
59883
|
|
|
59884
59884
|
// src/lib/config.ts
|
|
59885
|
-
var
|
|
59885
|
+
var graphql5 = __toESM(require("graphql"), 1);
|
|
59886
59886
|
var import_minimatch8 = __toESM(require_minimatch(), 1);
|
|
59887
59887
|
var import_node_url4 = require("node:url");
|
|
59888
59888
|
|
|
@@ -67296,43 +67296,43 @@ __export(conventions_exports, {
|
|
|
67296
67296
|
vite_render_path: () => vite_render_path
|
|
67297
67297
|
});
|
|
67298
67298
|
function router_path(config) {
|
|
67299
|
-
return
|
|
67299
|
+
return join2(base_dir(config), "Router.jsx");
|
|
67300
67300
|
}
|
|
67301
67301
|
function page_entry_path(config, id, base) {
|
|
67302
|
-
return
|
|
67302
|
+
return join2(page_entries_dir(config, base), `${id}.jsx`);
|
|
67303
67303
|
}
|
|
67304
67304
|
function server_adapter_path(config, base) {
|
|
67305
|
-
return
|
|
67305
|
+
return join2(units_dir(config, base), "render", "server.js");
|
|
67306
67306
|
}
|
|
67307
67307
|
function adapter_config_path(config, base) {
|
|
67308
|
-
return
|
|
67308
|
+
return join2(units_dir(config, base), "render", "config.js");
|
|
67309
67309
|
}
|
|
67310
67310
|
function vite_render_path(config, base) {
|
|
67311
|
-
return
|
|
67311
|
+
return join2(units_dir(config, base), "render", "vite.js");
|
|
67312
67312
|
}
|
|
67313
67313
|
function app_component_path(config, base) {
|
|
67314
|
-
return
|
|
67314
|
+
return join2(units_dir(config, base), "render", "App.jsx");
|
|
67315
67315
|
}
|
|
67316
67316
|
function page_unit_path(config, id, base) {
|
|
67317
|
-
return
|
|
67317
|
+
return join2(page_units_dir(config, base), `${id}.jsx`);
|
|
67318
67318
|
}
|
|
67319
67319
|
function layout_unit_path(config, id, base) {
|
|
67320
|
-
return
|
|
67320
|
+
return join2(layout_units_dir(config, base), `${id}.jsx`);
|
|
67321
67321
|
}
|
|
67322
67322
|
function componentField_unit_path(config, id, base) {
|
|
67323
|
-
return
|
|
67323
|
+
return join2(units_dir(config, base), "componentFields", `wrapper_${id}.jsx`);
|
|
67324
67324
|
}
|
|
67325
67325
|
function fallback_unit_path(config, which, id, base) {
|
|
67326
|
-
return
|
|
67326
|
+
return join2(fallbacks_units_dir(config, which, base), `${id}.jsx`);
|
|
67327
67327
|
}
|
|
67328
67328
|
async function read_pageQuery(base) {
|
|
67329
|
-
const target =
|
|
67330
|
-
return [target, await
|
|
67329
|
+
const target = join2(base, "+page.gql");
|
|
67330
|
+
return [target, await readFile(target)];
|
|
67331
67331
|
}
|
|
67332
67332
|
async function read_pageView(base) {
|
|
67333
67333
|
for (const name of ["+page.tsx", "+page.jsx"]) {
|
|
67334
|
-
let target =
|
|
67335
|
-
let result = await
|
|
67334
|
+
let target = join2(base, name);
|
|
67335
|
+
let result = await readFile(target);
|
|
67336
67336
|
if (result) {
|
|
67337
67337
|
return [target, result];
|
|
67338
67338
|
}
|
|
@@ -67340,13 +67340,13 @@ async function read_pageView(base) {
|
|
|
67340
67340
|
return [null, null];
|
|
67341
67341
|
}
|
|
67342
67342
|
async function read_layoutQuery(base) {
|
|
67343
|
-
const target =
|
|
67344
|
-
return [target, await
|
|
67343
|
+
const target = join2(base, "+layout.gql");
|
|
67344
|
+
return [target, await readFile(target)];
|
|
67345
67345
|
}
|
|
67346
67346
|
async function read_layoutView(base) {
|
|
67347
67347
|
for (const name of ["+layout.tsx", "+layout.jsx"]) {
|
|
67348
|
-
let target =
|
|
67349
|
-
let result = await
|
|
67348
|
+
let target = join2(base, name);
|
|
67349
|
+
let result = await readFile(target);
|
|
67350
67350
|
if (result) {
|
|
67351
67351
|
return [target, result];
|
|
67352
67352
|
}
|
|
@@ -67354,10 +67354,10 @@ async function read_layoutView(base) {
|
|
|
67354
67354
|
return [null, null];
|
|
67355
67355
|
}
|
|
67356
67356
|
function temp_dir(config, key) {
|
|
67357
|
-
return
|
|
67357
|
+
return join2(config.rootDir, "temp", key);
|
|
67358
67358
|
}
|
|
67359
67359
|
function router_index_path(config) {
|
|
67360
|
-
return
|
|
67360
|
+
return join2(config.routesDir, "..", "+index.jsx");
|
|
67361
67361
|
}
|
|
67362
67362
|
function is_layout(path4) {
|
|
67363
67363
|
return path4.endsWith("+layout.tsx") || path4.endsWith("+layout.jsx");
|
|
@@ -67380,190 +67380,591 @@ function page_id(path4) {
|
|
|
67380
67380
|
return copy;
|
|
67381
67381
|
}
|
|
67382
67382
|
function page_entries_dir(config, base) {
|
|
67383
|
-
return
|
|
67383
|
+
return join2(units_dir(config, base), "entries");
|
|
67384
67384
|
}
|
|
67385
67385
|
function page_units_dir(config, base) {
|
|
67386
|
-
return
|
|
67386
|
+
return join2(units_dir(config, base), "pages");
|
|
67387
67387
|
}
|
|
67388
67388
|
function layout_units_dir(config, base) {
|
|
67389
|
-
return
|
|
67389
|
+
return join2(units_dir(config, base), "layouts");
|
|
67390
67390
|
}
|
|
67391
67391
|
function fallbacks_units_dir(config, which, base) {
|
|
67392
|
-
return
|
|
67392
|
+
return join2(units_dir(config, base), "fallbacks", which);
|
|
67393
67393
|
}
|
|
67394
67394
|
function units_dir(config, base = base_dir(config)) {
|
|
67395
|
-
return
|
|
67395
|
+
return join2(base, "units");
|
|
67396
67396
|
}
|
|
67397
67397
|
function base_dir(config) {
|
|
67398
67398
|
return config.pluginDirectory("houdini-react");
|
|
67399
67399
|
}
|
|
67400
67400
|
function serialized_manifest_path(config, base = base_dir(config)) {
|
|
67401
|
-
return
|
|
67401
|
+
return join2(base, "manifest.json");
|
|
67402
67402
|
}
|
|
67403
67403
|
|
|
67404
67404
|
// src/lib/router/manifest.ts
|
|
67405
67405
|
var t2 = __toESM(require_lib5(), 1);
|
|
67406
|
-
var
|
|
67407
|
-
|
|
67408
|
-
|
|
67409
|
-
|
|
67410
|
-
|
|
67411
|
-
|
|
67412
|
-
|
|
67413
|
-
|
|
67414
|
-
|
|
67415
|
-
|
|
67416
|
-
|
|
67417
|
-
layout_queries: {},
|
|
67418
|
-
artifacts: [],
|
|
67419
|
-
local_schema: false,
|
|
67420
|
-
local_yoga: false
|
|
67421
|
-
},
|
|
67422
|
-
queries: [],
|
|
67423
|
-
layouts: [],
|
|
67424
|
-
variables: {}
|
|
67425
|
-
});
|
|
67426
|
-
if (args.includeArtifacts) {
|
|
67427
|
-
try {
|
|
67428
|
-
for (const artifactPath of await fs_exports.readdir(args.config.artifactDirectory)) {
|
|
67429
|
-
if (!artifactPath.endsWith(".js") || artifactPath === "index.js") {
|
|
67430
|
-
continue;
|
|
67431
|
-
}
|
|
67432
|
-
manifest.artifacts.push(artifactPath.substring(0, artifactPath.length - 3));
|
|
67433
|
-
}
|
|
67434
|
-
} catch {
|
|
67406
|
+
var graphql3 = __toESM(require("graphql"), 1);
|
|
67407
|
+
|
|
67408
|
+
// src/runtime/router/match.ts
|
|
67409
|
+
var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
67410
|
+
function find_match(config, manifest, current, allowNull = true) {
|
|
67411
|
+
let match2 = null;
|
|
67412
|
+
let matchVariables = null;
|
|
67413
|
+
for (const page of Object.values(manifest.pages)) {
|
|
67414
|
+
const urlMatch = current.match(page.pattern);
|
|
67415
|
+
if (!urlMatch) {
|
|
67416
|
+
continue;
|
|
67435
67417
|
}
|
|
67418
|
+
match2 = page;
|
|
67419
|
+
matchVariables = exec(urlMatch, page.params) || {};
|
|
67420
|
+
break;
|
|
67436
67421
|
}
|
|
67437
|
-
|
|
67438
|
-
|
|
67439
|
-
|
|
67440
|
-
|
|
67441
|
-
|
|
67442
|
-
|
|
67443
|
-
|
|
67444
|
-
|
|
67422
|
+
if (!match2 && !allowNull) {
|
|
67423
|
+
throw new Error("404");
|
|
67424
|
+
}
|
|
67425
|
+
let variables = {
|
|
67426
|
+
...matchVariables
|
|
67427
|
+
};
|
|
67428
|
+
for (const document of Object.values(match2?.documents ?? {})) {
|
|
67429
|
+
for (const [variable, { type }] of Object.entries(document.variables)) {
|
|
67430
|
+
if (matchVariables?.[variable]) {
|
|
67431
|
+
variables[variable] = parseScalar(config, type, matchVariables[variable]);
|
|
67445
67432
|
}
|
|
67446
67433
|
}
|
|
67447
|
-
} catch {
|
|
67448
67434
|
}
|
|
67449
|
-
return
|
|
67435
|
+
return [match2, variables];
|
|
67450
67436
|
}
|
|
67451
|
-
|
|
67452
|
-
const
|
|
67453
|
-
|
|
67454
|
-
|
|
67455
|
-
|
|
67456
|
-
|
|
67457
|
-
|
|
67458
|
-
|
|
67459
|
-
|
|
67460
|
-
|
|
67461
|
-
|
|
67462
|
-
|
|
67463
|
-
|
|
67464
|
-
|
|
67465
|
-
|
|
67466
|
-
|
|
67467
|
-
|
|
67468
|
-
|
|
67469
|
-
|
|
67470
|
-
|
|
67471
|
-
|
|
67472
|
-
|
|
67473
|
-
|
|
67474
|
-
|
|
67475
|
-
|
|
67476
|
-
|
|
67477
|
-
|
|
67478
|
-
type: "layout",
|
|
67479
|
-
contents: layoutQueryContents,
|
|
67480
|
-
variables
|
|
67481
|
-
});
|
|
67482
|
-
newLayoutQueries = [...args.queries, layoutQuery.name];
|
|
67483
|
-
}
|
|
67484
|
-
if (layoutViewContents) {
|
|
67485
|
-
layout = await add_view({
|
|
67486
|
-
url: args.url,
|
|
67487
|
-
path: layoutViewPath,
|
|
67488
|
-
project: args.project,
|
|
67489
|
-
type: "layout",
|
|
67490
|
-
contents: layoutViewContents,
|
|
67491
|
-
layouts: args.layouts,
|
|
67492
|
-
queries: newLayoutQueries,
|
|
67493
|
-
config: args.config,
|
|
67494
|
-
variables
|
|
67495
|
-
});
|
|
67496
|
-
newLayouts = [...args.layouts, page_id(layout.url)];
|
|
67497
|
-
}
|
|
67498
|
-
if (pageQueryContents) {
|
|
67499
|
-
pageQuery = await add_query({
|
|
67500
|
-
path: pageQueryPath,
|
|
67501
|
-
config: args.config,
|
|
67502
|
-
url: args.url,
|
|
67503
|
-
project: args.project,
|
|
67504
|
-
type: "page",
|
|
67505
|
-
contents: pageQueryContents,
|
|
67506
|
-
variables
|
|
67507
|
-
});
|
|
67508
|
-
}
|
|
67509
|
-
if (pageViewContents) {
|
|
67510
|
-
await add_view({
|
|
67511
|
-
path: pageViewPath,
|
|
67512
|
-
url: args.url.substring(0, args.url.length - 1) || "/",
|
|
67513
|
-
project: args.project,
|
|
67514
|
-
type: "page",
|
|
67515
|
-
contents: pageViewContents,
|
|
67516
|
-
layouts: newLayouts,
|
|
67517
|
-
queries: pageQuery ? [...newLayoutQueries, pageQuery.name] : newLayoutQueries,
|
|
67518
|
-
config: args.config,
|
|
67519
|
-
variables
|
|
67520
|
-
});
|
|
67521
|
-
}
|
|
67522
|
-
await Promise.all(
|
|
67523
|
-
directory_contents.map((dir) => {
|
|
67524
|
-
if (!dir.isDirectory()) {
|
|
67437
|
+
function parse_page_pattern(id) {
|
|
67438
|
+
const params = [];
|
|
67439
|
+
const pattern = id === "/" ? /^\/$/ : new RegExp(
|
|
67440
|
+
`^${get_route_segments(id).map((segment) => {
|
|
67441
|
+
const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
|
67442
|
+
if (rest_match) {
|
|
67443
|
+
params.push({
|
|
67444
|
+
name: rest_match[1],
|
|
67445
|
+
matcher: rest_match[2],
|
|
67446
|
+
optional: false,
|
|
67447
|
+
rest: true,
|
|
67448
|
+
chained: true
|
|
67449
|
+
});
|
|
67450
|
+
return "(?:/(.*))?";
|
|
67451
|
+
}
|
|
67452
|
+
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
67453
|
+
if (optional_match) {
|
|
67454
|
+
params.push({
|
|
67455
|
+
name: optional_match[1],
|
|
67456
|
+
matcher: optional_match[2],
|
|
67457
|
+
optional: true,
|
|
67458
|
+
rest: false,
|
|
67459
|
+
chained: true
|
|
67460
|
+
});
|
|
67461
|
+
return "(?:/([^/]+))?";
|
|
67462
|
+
}
|
|
67463
|
+
if (!segment) {
|
|
67525
67464
|
return;
|
|
67526
67465
|
}
|
|
67527
|
-
|
|
67528
|
-
|
|
67529
|
-
|
|
67530
|
-
|
|
67531
|
-
|
|
67532
|
-
|
|
67533
|
-
|
|
67534
|
-
|
|
67535
|
-
|
|
67466
|
+
const parts = segment.split(/\[(.+?)\](?!\])/);
|
|
67467
|
+
const result = parts.map((content, i2) => {
|
|
67468
|
+
if (i2 % 2) {
|
|
67469
|
+
if (content.startsWith("x+")) {
|
|
67470
|
+
return escape3(
|
|
67471
|
+
String.fromCharCode(parseInt(content.slice(2), 16))
|
|
67472
|
+
);
|
|
67473
|
+
}
|
|
67474
|
+
if (content.startsWith("u+")) {
|
|
67475
|
+
return escape3(
|
|
67476
|
+
String.fromCharCode(
|
|
67477
|
+
...content.slice(2).split("-").map((code) => parseInt(code, 16))
|
|
67478
|
+
)
|
|
67479
|
+
);
|
|
67480
|
+
}
|
|
67481
|
+
const match2 = param_pattern.exec(content);
|
|
67482
|
+
if (!match2) {
|
|
67483
|
+
throw new Error(
|
|
67484
|
+
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
67485
|
+
);
|
|
67486
|
+
}
|
|
67487
|
+
const [, is_optional, is_rest, name, matcher] = match2;
|
|
67488
|
+
params.push({
|
|
67489
|
+
name,
|
|
67490
|
+
matcher,
|
|
67491
|
+
optional: !!is_optional,
|
|
67492
|
+
rest: !!is_rest,
|
|
67493
|
+
chained: is_rest ? i2 === 1 && parts[0] === "" : false
|
|
67494
|
+
});
|
|
67495
|
+
return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
|
|
67496
|
+
}
|
|
67497
|
+
return escape3(content);
|
|
67498
|
+
}).join("");
|
|
67499
|
+
return "/" + result;
|
|
67500
|
+
}).join("")}/?$`
|
|
67536
67501
|
);
|
|
67537
|
-
return
|
|
67502
|
+
return { pattern, params, page_id: id };
|
|
67538
67503
|
}
|
|
67539
|
-
|
|
67540
|
-
|
|
67541
|
-
|
|
67542
|
-
|
|
67543
|
-
|
|
67544
|
-
|
|
67545
|
-
|
|
67546
|
-
|
|
67504
|
+
function affects_path(segment) {
|
|
67505
|
+
return !/^\([^)]+\)$/.test(segment);
|
|
67506
|
+
}
|
|
67507
|
+
function get_route_segments(route) {
|
|
67508
|
+
return route.slice(1).split("/").filter(affects_path);
|
|
67509
|
+
}
|
|
67510
|
+
function exec(match2, params) {
|
|
67511
|
+
const result = {};
|
|
67512
|
+
const values = match2.slice(1);
|
|
67513
|
+
let buffered = "";
|
|
67514
|
+
for (let i2 = 0; i2 < (params || []).length; i2 += 1) {
|
|
67515
|
+
const param = params[i2];
|
|
67516
|
+
let value = values[i2];
|
|
67517
|
+
if (param.chained && param.rest && buffered) {
|
|
67518
|
+
value = value ? buffered + "/" + value : buffered;
|
|
67519
|
+
}
|
|
67520
|
+
buffered = "";
|
|
67521
|
+
if (value === void 0) {
|
|
67522
|
+
if (param.rest)
|
|
67523
|
+
result[param.name] = "";
|
|
67524
|
+
} else {
|
|
67525
|
+
result[param.name] = decodeURIComponent(value);
|
|
67526
|
+
}
|
|
67547
67527
|
}
|
|
67548
|
-
|
|
67549
|
-
|
|
67550
|
-
|
|
67551
|
-
|
|
67552
|
-
|
|
67553
|
-
|
|
67554
|
-
|
|
67555
|
-
|
|
67556
|
-
|
|
67557
|
-
|
|
67558
|
-
|
|
67559
|
-
|
|
67560
|
-
|
|
67561
|
-
)
|
|
67562
|
-
}
|
|
67563
|
-
|
|
67528
|
+
if (buffered)
|
|
67529
|
+
return;
|
|
67530
|
+
return result;
|
|
67531
|
+
}
|
|
67532
|
+
function escape3(str) {
|
|
67533
|
+
return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
|
|
67534
|
+
}
|
|
67535
|
+
|
|
67536
|
+
// src/lib/graphql.ts
|
|
67537
|
+
var graphql2 = __toESM(require("graphql"), 1);
|
|
67538
|
+
var import_node_crypto = __toESM(require("node:crypto"), 1);
|
|
67539
|
+
function getRootType(type) {
|
|
67540
|
+
if (graphql2.isNonNullType(type)) {
|
|
67541
|
+
return getRootType(type.ofType);
|
|
67542
|
+
}
|
|
67543
|
+
if (graphql2.isListType(type)) {
|
|
67544
|
+
return getRootType(type.ofType);
|
|
67545
|
+
}
|
|
67546
|
+
return type;
|
|
67547
|
+
}
|
|
67548
|
+
function processComponentFieldDirective(directive) {
|
|
67549
|
+
let field;
|
|
67550
|
+
let exportValue;
|
|
67551
|
+
let prop;
|
|
67552
|
+
let raw;
|
|
67553
|
+
for (const arg of directive.arguments ?? []) {
|
|
67554
|
+
if (arg.name.value === "field" && arg.value.kind === "StringValue") {
|
|
67555
|
+
field = arg.value.value;
|
|
67556
|
+
} else if (arg.name.value === "export" && arg.value.kind === "StringValue") {
|
|
67557
|
+
exportValue = arg.value.value;
|
|
67558
|
+
} else if (arg.name.value === "prop" && arg.value.kind === "StringValue") {
|
|
67559
|
+
prop = arg.value.value;
|
|
67560
|
+
} else if (arg.name.value === "raw" && arg.value.kind === "StringValue") {
|
|
67561
|
+
raw = arg.value.value;
|
|
67562
|
+
}
|
|
67563
|
+
}
|
|
67564
|
+
const missing = [];
|
|
67565
|
+
if (!field) {
|
|
67566
|
+
missing.push("field");
|
|
67567
|
+
}
|
|
67568
|
+
if (!prop) {
|
|
67569
|
+
missing.push("prop");
|
|
67570
|
+
}
|
|
67571
|
+
if (missing.length > 0) {
|
|
67572
|
+
throw new Error(`missing arguments to @componentField: ${missing.join(", ")}`);
|
|
67573
|
+
}
|
|
67574
|
+
return {
|
|
67575
|
+
prop,
|
|
67576
|
+
field,
|
|
67577
|
+
raw,
|
|
67578
|
+
export: exportValue
|
|
67579
|
+
};
|
|
67580
|
+
}
|
|
67581
|
+
function hashOriginal({ document }) {
|
|
67582
|
+
return hashDocument(document.originalString);
|
|
67583
|
+
}
|
|
67584
|
+
function hashRaw({ document }) {
|
|
67585
|
+
return hashDocument(document.artifact?.raw);
|
|
67586
|
+
}
|
|
67587
|
+
function hashDocument(str) {
|
|
67588
|
+
return import_node_crypto.default.createHash("sha256").update(str || "").digest("hex");
|
|
67589
|
+
}
|
|
67590
|
+
function parentField(ancestors) {
|
|
67591
|
+
return walkParentField([...ancestors].sort(() => -1));
|
|
67592
|
+
}
|
|
67593
|
+
function walkParentField(ancestors) {
|
|
67594
|
+
let head = ancestors.shift();
|
|
67595
|
+
if (Array.isArray(head) || head.kind === "SelectionSet") {
|
|
67596
|
+
return walkParentField(ancestors);
|
|
67597
|
+
}
|
|
67598
|
+
return head;
|
|
67599
|
+
}
|
|
67600
|
+
function parentTypeFromAncestors(schema, filepath, ancestors) {
|
|
67601
|
+
const parents = [...ancestors];
|
|
67602
|
+
parents.reverse();
|
|
67603
|
+
return walkAncestors(schema, filepath, parents);
|
|
67604
|
+
}
|
|
67605
|
+
function walkAncestors(schema, filepath, ancestors) {
|
|
67606
|
+
let head = ancestors.shift();
|
|
67607
|
+
if (Array.isArray(head)) {
|
|
67608
|
+
return walkAncestors(schema, filepath, ancestors);
|
|
67609
|
+
}
|
|
67610
|
+
if (!head) {
|
|
67611
|
+
throw new HoudiniError({ filepath, message: "Could not figure out type of field" });
|
|
67612
|
+
}
|
|
67613
|
+
if (head.kind === "OperationDefinition") {
|
|
67614
|
+
const operationType = {
|
|
67615
|
+
query: schema.getQueryType(),
|
|
67616
|
+
mutation: schema.getMutationType(),
|
|
67617
|
+
subscription: schema.getSubscriptionType()
|
|
67618
|
+
}[head.operation];
|
|
67619
|
+
if (!operationType) {
|
|
67620
|
+
throw new HoudiniError({ filepath, message: "Could not find operation type" });
|
|
67621
|
+
}
|
|
67622
|
+
return operationType;
|
|
67623
|
+
}
|
|
67624
|
+
if (head.kind === "FragmentDefinition") {
|
|
67625
|
+
const result = schema.getType(head.typeCondition.name.value);
|
|
67626
|
+
if (!result) {
|
|
67627
|
+
throw new HoudiniError({
|
|
67628
|
+
filepath,
|
|
67629
|
+
message: `Could not find definition for ${head.typeCondition.name.value} in the schema`
|
|
67630
|
+
});
|
|
67631
|
+
}
|
|
67632
|
+
return result;
|
|
67633
|
+
}
|
|
67634
|
+
if (head.kind === "FragmentSpread") {
|
|
67635
|
+
throw new Error("How the hell did this happen?");
|
|
67636
|
+
}
|
|
67637
|
+
const parent = walkAncestors(schema, filepath, ancestors);
|
|
67638
|
+
if (head.kind === "InlineFragment") {
|
|
67639
|
+
if (!head.typeCondition) {
|
|
67640
|
+
return parent;
|
|
67641
|
+
}
|
|
67642
|
+
const wrapper = schema.getType(head.typeCondition.name.value);
|
|
67643
|
+
if (!wrapper) {
|
|
67644
|
+
throw new HoudiniError({
|
|
67645
|
+
filepath,
|
|
67646
|
+
message: "Could not find type with name: " + head.typeCondition.name.value
|
|
67647
|
+
});
|
|
67648
|
+
}
|
|
67649
|
+
return wrapper;
|
|
67650
|
+
}
|
|
67651
|
+
if (head.kind === "SelectionSet") {
|
|
67652
|
+
return parent;
|
|
67653
|
+
}
|
|
67654
|
+
const field = parent.getFields()[head.name.value];
|
|
67655
|
+
if (!field) {
|
|
67656
|
+
throw new HoudiniError({
|
|
67657
|
+
filepath,
|
|
67658
|
+
message: `Could not find definition of ${head.name.value} in ${parent.toString()}`
|
|
67659
|
+
});
|
|
67660
|
+
}
|
|
67661
|
+
return getRootType(field.type);
|
|
67662
|
+
}
|
|
67663
|
+
function definitionFromAncestors(ancestors) {
|
|
67664
|
+
let parents = [...ancestors];
|
|
67665
|
+
parents.shift();
|
|
67666
|
+
let definition = parents.shift();
|
|
67667
|
+
while (Array.isArray(definition) && definition) {
|
|
67668
|
+
definition = parents.shift();
|
|
67669
|
+
}
|
|
67670
|
+
return { parents, definition };
|
|
67671
|
+
}
|
|
67672
|
+
function formatErrors(e2, afterError) {
|
|
67673
|
+
const errors = Array.isArray(e2) ? e2 : [e2];
|
|
67674
|
+
for (const error of errors) {
|
|
67675
|
+
if ("filepath" in error && error.filepath) {
|
|
67676
|
+
const relative2 = relative(process.cwd(), error.filepath);
|
|
67677
|
+
console.error(`\u274C Encountered error in ${relative2}`);
|
|
67678
|
+
if (error.message) {
|
|
67679
|
+
console.error(error.message);
|
|
67680
|
+
}
|
|
67681
|
+
} else {
|
|
67682
|
+
console.error(`\u274C ${error.message}`);
|
|
67683
|
+
if ("description" in error && error.description) {
|
|
67684
|
+
console.error(`${error.description}`);
|
|
67685
|
+
}
|
|
67686
|
+
}
|
|
67687
|
+
afterError?.(e2);
|
|
67688
|
+
}
|
|
67689
|
+
}
|
|
67690
|
+
function operation_requires_variables(operation) {
|
|
67691
|
+
return Boolean(
|
|
67692
|
+
operation.variableDefinitions && operation.variableDefinitions?.find(
|
|
67693
|
+
(defn) => defn.type.kind === "NonNullType" && !defn.defaultValue
|
|
67694
|
+
)
|
|
67695
|
+
);
|
|
67696
|
+
}
|
|
67697
|
+
function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
|
|
67698
|
+
if (type.kind === "NonNullType") {
|
|
67699
|
+
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
67700
|
+
}
|
|
67701
|
+
if (type instanceof graphql2.GraphQLNonNull) {
|
|
67702
|
+
return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
|
|
67703
|
+
}
|
|
67704
|
+
if (wrappers[0] !== TypeWrapper.NonNull) {
|
|
67705
|
+
wrappers.unshift(TypeWrapper.Nullable);
|
|
67706
|
+
}
|
|
67707
|
+
if (type.kind === "ListType") {
|
|
67708
|
+
return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers]);
|
|
67709
|
+
}
|
|
67710
|
+
if (type instanceof graphql2.GraphQLList) {
|
|
67711
|
+
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
67712
|
+
}
|
|
67713
|
+
if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
67714
|
+
type = config.schema.getType(
|
|
67715
|
+
config.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
67716
|
+
);
|
|
67717
|
+
}
|
|
67718
|
+
const namedType = config.schema.getType(type.name.value || type.name);
|
|
67719
|
+
if (!namedType) {
|
|
67720
|
+
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
67721
|
+
}
|
|
67722
|
+
return { type: namedType, wrappers };
|
|
67723
|
+
}
|
|
67724
|
+
function wrapType({
|
|
67725
|
+
type,
|
|
67726
|
+
wrappers
|
|
67727
|
+
}) {
|
|
67728
|
+
const head = wrappers[0];
|
|
67729
|
+
const tail = wrappers.slice(1);
|
|
67730
|
+
let kind = graphql2.Kind.NAMED_TYPE;
|
|
67731
|
+
if (head === TypeWrapper.List) {
|
|
67732
|
+
kind = graphql2.Kind.LIST_TYPE;
|
|
67733
|
+
} else if (head === TypeWrapper.NonNull) {
|
|
67734
|
+
kind = graphql2.Kind.NON_NULL_TYPE;
|
|
67735
|
+
}
|
|
67736
|
+
if (kind === "NamedType") {
|
|
67737
|
+
return {
|
|
67738
|
+
kind,
|
|
67739
|
+
name: {
|
|
67740
|
+
kind: graphql2.Kind.NAME,
|
|
67741
|
+
value: type.name
|
|
67742
|
+
}
|
|
67743
|
+
};
|
|
67744
|
+
}
|
|
67745
|
+
return {
|
|
67746
|
+
kind,
|
|
67747
|
+
type: wrapType({ type, wrappers: tail })
|
|
67748
|
+
};
|
|
67749
|
+
}
|
|
67750
|
+
var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
|
|
67751
|
+
TypeWrapper2["Nullable"] = "Nullable";
|
|
67752
|
+
TypeWrapper2["List"] = "List";
|
|
67753
|
+
TypeWrapper2["NonNull"] = "NonNull";
|
|
67754
|
+
return TypeWrapper2;
|
|
67755
|
+
})(TypeWrapper || {});
|
|
67756
|
+
|
|
67757
|
+
// src/lib/parse.ts
|
|
67758
|
+
var import_parser = __toESM(require_lib6(), 1);
|
|
67759
|
+
var import_recast = __toESM(require_main2(), 1);
|
|
67760
|
+
|
|
67761
|
+
// src/lib/deepMerge.ts
|
|
67762
|
+
var import_deepmerge = __toESM(require_cjs(), 1);
|
|
67763
|
+
function deepMerge2(filepath, ...targets) {
|
|
67764
|
+
try {
|
|
67765
|
+
if (targets.length === 1) {
|
|
67766
|
+
return targets[0];
|
|
67767
|
+
} else if (targets.length === 2) {
|
|
67768
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
67769
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
67770
|
+
});
|
|
67771
|
+
}
|
|
67772
|
+
return deepMerge2(filepath, targets[0], deepMerge2(filepath, ...targets.slice(1)));
|
|
67773
|
+
} catch (e2) {
|
|
67774
|
+
throw new HoudiniError({
|
|
67775
|
+
filepath,
|
|
67776
|
+
message: "could not merge: " + JSON.stringify(targets, null, 4),
|
|
67777
|
+
description: e2.message
|
|
67778
|
+
});
|
|
67779
|
+
}
|
|
67780
|
+
}
|
|
67781
|
+
|
|
67782
|
+
// src/lib/parse.ts
|
|
67783
|
+
function parseJS(str, config) {
|
|
67784
|
+
const defaultConfig = {
|
|
67785
|
+
plugins: [
|
|
67786
|
+
"typescript",
|
|
67787
|
+
"importAssertions",
|
|
67788
|
+
"decorators-legacy",
|
|
67789
|
+
"explicitResourceManagement"
|
|
67790
|
+
],
|
|
67791
|
+
sourceType: "module"
|
|
67792
|
+
};
|
|
67793
|
+
return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
|
|
67794
|
+
}
|
|
67795
|
+
function parseJSON(str) {
|
|
67796
|
+
str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m2, g) => g ? "" : m2);
|
|
67797
|
+
return JSON.parse(str);
|
|
67798
|
+
}
|
|
67799
|
+
async function printJS(script, options) {
|
|
67800
|
+
if (options?.pretty) {
|
|
67801
|
+
return (0, import_recast.prettyPrint)(script, options);
|
|
67802
|
+
} else {
|
|
67803
|
+
return (0, import_recast.print)(script, options);
|
|
67804
|
+
}
|
|
67805
|
+
}
|
|
67806
|
+
|
|
67807
|
+
// src/lib/router/manifest.ts
|
|
67808
|
+
async function load_manifest(args) {
|
|
67809
|
+
const manifest = await walk_routes({
|
|
67810
|
+
config: args.config,
|
|
67811
|
+
url: "/",
|
|
67812
|
+
filepath: args.config.routesDir,
|
|
67813
|
+
project: {
|
|
67814
|
+
component_fields: {},
|
|
67815
|
+
pages: {},
|
|
67816
|
+
layouts: {},
|
|
67817
|
+
page_queries: {},
|
|
67818
|
+
layout_queries: {},
|
|
67819
|
+
artifacts: [],
|
|
67820
|
+
local_schema: false,
|
|
67821
|
+
local_yoga: false
|
|
67822
|
+
},
|
|
67823
|
+
queries: [],
|
|
67824
|
+
layouts: [],
|
|
67825
|
+
variables: {}
|
|
67826
|
+
});
|
|
67827
|
+
if (args.includeArtifacts) {
|
|
67828
|
+
try {
|
|
67829
|
+
for (const artifactPath of await readdir2(args.config.artifactDirectory)) {
|
|
67830
|
+
if (!artifactPath.endsWith(".js") || artifactPath === "index.js") {
|
|
67831
|
+
continue;
|
|
67832
|
+
}
|
|
67833
|
+
manifest.artifacts.push(artifactPath.substring(0, artifactPath.length - 3));
|
|
67834
|
+
}
|
|
67835
|
+
} catch {
|
|
67836
|
+
}
|
|
67837
|
+
}
|
|
67838
|
+
try {
|
|
67839
|
+
await stat(args.config.localApiDir);
|
|
67840
|
+
for (const child of await readdir2(args.config.localApiDir, { withFileTypes: true })) {
|
|
67841
|
+
const name = child.isDirectory() ? child.name : parse3(child.name).name;
|
|
67842
|
+
if (name === "+schema") {
|
|
67843
|
+
manifest.local_schema = true;
|
|
67844
|
+
} else if (name === "+yoga") {
|
|
67845
|
+
manifest.local_yoga = true;
|
|
67846
|
+
}
|
|
67847
|
+
}
|
|
67848
|
+
} catch {
|
|
67849
|
+
}
|
|
67850
|
+
return manifest;
|
|
67851
|
+
}
|
|
67852
|
+
async function walk_routes(args) {
|
|
67853
|
+
const directory_contents = await readdir2(args.filepath, {
|
|
67854
|
+
withFileTypes: true
|
|
67855
|
+
});
|
|
67856
|
+
const variables = { ...args.variables };
|
|
67857
|
+
let newLayouts = args.layouts;
|
|
67858
|
+
let newLayoutQueries = args.queries;
|
|
67859
|
+
let layout = null;
|
|
67860
|
+
let layoutQuery = null;
|
|
67861
|
+
let pageQuery = null;
|
|
67862
|
+
const [
|
|
67863
|
+
[layoutQueryPath, layoutQueryContents],
|
|
67864
|
+
[layoutViewPath, layoutViewContents],
|
|
67865
|
+
[pageQueryPath, pageQueryContents],
|
|
67866
|
+
[pageViewPath, pageViewContents]
|
|
67867
|
+
] = await Promise.all([
|
|
67868
|
+
read_layoutQuery(args.filepath),
|
|
67869
|
+
read_layoutView(args.filepath),
|
|
67870
|
+
read_pageQuery(args.filepath),
|
|
67871
|
+
read_pageView(args.filepath)
|
|
67872
|
+
]);
|
|
67873
|
+
if (layoutQueryContents) {
|
|
67874
|
+
layoutQuery = await add_query({
|
|
67875
|
+
path: layoutQueryPath,
|
|
67876
|
+
config: args.config,
|
|
67877
|
+
url: args.url,
|
|
67878
|
+
project: args.project,
|
|
67879
|
+
type: "layout",
|
|
67880
|
+
contents: layoutQueryContents,
|
|
67881
|
+
variables
|
|
67882
|
+
});
|
|
67883
|
+
newLayoutQueries = [...args.queries, layoutQuery.name];
|
|
67884
|
+
}
|
|
67885
|
+
if (layoutViewContents) {
|
|
67886
|
+
layout = await add_view({
|
|
67887
|
+
url: args.url,
|
|
67888
|
+
path: layoutViewPath,
|
|
67889
|
+
project: args.project,
|
|
67890
|
+
type: "layout",
|
|
67891
|
+
contents: layoutViewContents,
|
|
67892
|
+
layouts: args.layouts,
|
|
67893
|
+
queries: newLayoutQueries,
|
|
67894
|
+
config: args.config,
|
|
67895
|
+
variables
|
|
67896
|
+
});
|
|
67897
|
+
newLayouts = [...args.layouts, page_id(layout.url)];
|
|
67898
|
+
}
|
|
67899
|
+
if (pageQueryContents) {
|
|
67900
|
+
pageQuery = await add_query({
|
|
67901
|
+
path: pageQueryPath,
|
|
67902
|
+
config: args.config,
|
|
67903
|
+
url: args.url,
|
|
67904
|
+
project: args.project,
|
|
67905
|
+
type: "page",
|
|
67906
|
+
contents: pageQueryContents,
|
|
67907
|
+
variables
|
|
67908
|
+
});
|
|
67909
|
+
}
|
|
67910
|
+
if (pageViewContents) {
|
|
67911
|
+
await add_view({
|
|
67912
|
+
path: pageViewPath,
|
|
67913
|
+
url: args.url.substring(0, args.url.length - 1) || "/",
|
|
67914
|
+
project: args.project,
|
|
67915
|
+
type: "page",
|
|
67916
|
+
contents: pageViewContents,
|
|
67917
|
+
layouts: newLayouts,
|
|
67918
|
+
queries: pageQuery ? [...newLayoutQueries, pageQuery.name] : newLayoutQueries,
|
|
67919
|
+
config: args.config,
|
|
67920
|
+
variables
|
|
67921
|
+
});
|
|
67922
|
+
}
|
|
67923
|
+
await Promise.all(
|
|
67924
|
+
directory_contents.map((dir) => {
|
|
67925
|
+
if (!dir.isDirectory()) {
|
|
67926
|
+
return;
|
|
67927
|
+
}
|
|
67928
|
+
return walk_routes({
|
|
67929
|
+
...args,
|
|
67930
|
+
filepath: join2(args.filepath, dir.name),
|
|
67931
|
+
url: `${args.url}${dir.name}/`,
|
|
67932
|
+
queries: newLayoutQueries,
|
|
67933
|
+
layouts: newLayouts,
|
|
67934
|
+
variables
|
|
67935
|
+
});
|
|
67936
|
+
})
|
|
67937
|
+
);
|
|
67938
|
+
return args.project;
|
|
67939
|
+
}
|
|
67940
|
+
async function add_view(args) {
|
|
67941
|
+
const target = args.type === "page" ? args.project.pages : args.project.layouts;
|
|
67942
|
+
const queries = await extractQueries(args.contents);
|
|
67943
|
+
const missing_queries = queries.filter((query2) => !args.queries.includes(query2));
|
|
67944
|
+
if (missing_queries.length > 0) {
|
|
67945
|
+
throw {
|
|
67946
|
+
message: `Unknown queries in ${args.path}: ${missing_queries.join(", ")}`
|
|
67947
|
+
};
|
|
67948
|
+
}
|
|
67949
|
+
const id = page_id(args.url);
|
|
67950
|
+
target[id] = {
|
|
67951
|
+
id,
|
|
67952
|
+
queries,
|
|
67953
|
+
url: args.url,
|
|
67954
|
+
layouts: args.layouts,
|
|
67955
|
+
path: relative(args.config.projectRoot, args.path),
|
|
67956
|
+
query_options: args.queries,
|
|
67957
|
+
params: Object.fromEntries(
|
|
67958
|
+
parse_page_pattern(args.url).params.map((param) => [
|
|
67959
|
+
param.name,
|
|
67960
|
+
args.variables[param.name] ?? null
|
|
67961
|
+
])
|
|
67962
|
+
)
|
|
67963
|
+
};
|
|
67964
|
+
return target[id];
|
|
67564
67965
|
}
|
|
67565
67966
|
async function add_query(args) {
|
|
67566
|
-
const parsed =
|
|
67967
|
+
const parsed = graphql3.parse(args.contents);
|
|
67567
67968
|
const query2 = parsed.definitions.find(
|
|
67568
67969
|
(def) => def.kind === "OperationDefinition" && def.operation === "query"
|
|
67569
67970
|
);
|
|
@@ -67571,7 +67972,7 @@ async function add_query(args) {
|
|
|
67571
67972
|
throw new Error("No query found");
|
|
67572
67973
|
}
|
|
67573
67974
|
let loading = false;
|
|
67574
|
-
await
|
|
67975
|
+
await graphql3.visit(parsed, {
|
|
67575
67976
|
Directive(node) {
|
|
67576
67977
|
if (node.name.value === args.config.loadingDirective) {
|
|
67577
67978
|
loading = true;
|
|
@@ -67590,7 +67991,7 @@ async function add_query(args) {
|
|
|
67590
67991
|
Object.assign(args.variables, queryVariables);
|
|
67591
67992
|
const target = args.type === "page" ? args.project.page_queries : args.project.layout_queries;
|
|
67592
67993
|
target[page_id(args.url)] = {
|
|
67593
|
-
path:
|
|
67994
|
+
path: relative(args.config.routesDir, args.path),
|
|
67594
67995
|
name: query2.name.value,
|
|
67595
67996
|
url: args.url,
|
|
67596
67997
|
loading,
|
|
@@ -67665,7 +68066,7 @@ async function extractQueries(source) {
|
|
|
67665
68066
|
}
|
|
67666
68067
|
|
|
67667
68068
|
// src/lib/router/server.ts
|
|
67668
|
-
var
|
|
68069
|
+
var graphql4 = __toESM(require("graphql"), 1);
|
|
67669
68070
|
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
67670
68071
|
|
|
67671
68072
|
// src/runtime/lib/flatten.ts
|
|
@@ -71424,14 +71825,14 @@ function internalRoutes(config) {
|
|
|
71424
71825
|
async function buildLocalSchema(config) {
|
|
71425
71826
|
const { build } = await import("vite");
|
|
71426
71827
|
const schema = import_node_path3.default.join(config.localApiDir, "+schema");
|
|
71427
|
-
const outDir =
|
|
71828
|
+
const outDir = temp_dir(config, "schema");
|
|
71428
71829
|
process.env.HOUDINI_SECONDARY_BUILD = "true";
|
|
71429
71830
|
try {
|
|
71430
|
-
await
|
|
71831
|
+
await remove(import_node_path3.default.join(outDir, "assets", "schema.js"));
|
|
71431
71832
|
} catch {
|
|
71432
71833
|
}
|
|
71433
71834
|
try {
|
|
71434
|
-
await
|
|
71835
|
+
await mkdir(outDir);
|
|
71435
71836
|
} catch {
|
|
71436
71837
|
}
|
|
71437
71838
|
await build({
|
|
@@ -71463,14 +71864,14 @@ async function loadLocalSchema(config) {
|
|
|
71463
71864
|
}
|
|
71464
71865
|
try {
|
|
71465
71866
|
const { default: schema } = await import(import_node_path3.default.join(
|
|
71466
|
-
|
|
71867
|
+
temp_dir(config, "schema"),
|
|
71467
71868
|
`schema.js?${Date.now().valueOf()}}`
|
|
71468
71869
|
));
|
|
71469
71870
|
return schema;
|
|
71470
71871
|
} catch (e2) {
|
|
71471
71872
|
const message = "message" in e2 ? e2.message : e2;
|
|
71472
71873
|
console.error("\u26A0\uFE0F Failed to load local schema: ", message);
|
|
71473
|
-
return new
|
|
71874
|
+
return new graphql4.GraphQLSchema({});
|
|
71474
71875
|
}
|
|
71475
71876
|
}
|
|
71476
71877
|
|
|
@@ -71808,7 +72209,7 @@ var Config = class {
|
|
|
71808
72209
|
persistedQueriesPath
|
|
71809
72210
|
} = this.configFile;
|
|
71810
72211
|
if (typeof schema === "string") {
|
|
71811
|
-
this.schema =
|
|
72212
|
+
this.schema = graphql5.buildSchema(schema);
|
|
71812
72213
|
} else {
|
|
71813
72214
|
this.schema = schema;
|
|
71814
72215
|
}
|
|
@@ -71956,7 +72357,7 @@ var Config = class {
|
|
|
71956
72357
|
set newSchema(value) {
|
|
71957
72358
|
this.schemaString = value;
|
|
71958
72359
|
if (value) {
|
|
71959
|
-
this.#newSchemaInstance =
|
|
72360
|
+
this.#newSchemaInstance = graphql5.buildSchema(value);
|
|
71960
72361
|
} else {
|
|
71961
72362
|
this.#newSchemaInstance = null;
|
|
71962
72363
|
}
|
|
@@ -72046,21 +72447,21 @@ var Config = class {
|
|
|
72046
72447
|
}
|
|
72047
72448
|
documentName(document) {
|
|
72048
72449
|
const operation = document.definitions.find(
|
|
72049
|
-
({ kind }) => kind ===
|
|
72450
|
+
({ kind }) => kind === graphql5.Kind.OPERATION_DEFINITION
|
|
72050
72451
|
);
|
|
72051
72452
|
if (operation) {
|
|
72052
72453
|
if (!operation.name) {
|
|
72053
|
-
throw new Error("encountered operation with no name: " +
|
|
72454
|
+
throw new Error("encountered operation with no name: " + graphql5.print(document));
|
|
72054
72455
|
}
|
|
72055
72456
|
return operation.name.value;
|
|
72056
72457
|
}
|
|
72057
72458
|
const fragmentDefinitions = document.definitions.filter(
|
|
72058
|
-
({ kind }) => kind ===
|
|
72459
|
+
({ kind }) => kind === graphql5.Kind.FRAGMENT_DEFINITION
|
|
72059
72460
|
);
|
|
72060
72461
|
if (fragmentDefinitions.length) {
|
|
72061
72462
|
return fragmentDefinitions[0].name.value;
|
|
72062
72463
|
}
|
|
72063
|
-
throw new Error("Could not generate artifact name for document: " +
|
|
72464
|
+
throw new Error("Could not generate artifact name for document: " + graphql5.print(document));
|
|
72064
72465
|
}
|
|
72065
72466
|
isSelectionScalar(type) {
|
|
72066
72467
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(this.scalars || {})).includes(type);
|
|
@@ -72270,10 +72671,10 @@ var Config = class {
|
|
|
72270
72671
|
localDocumentData(document) {
|
|
72271
72672
|
let paginated = false;
|
|
72272
72673
|
let componentFields = [];
|
|
72273
|
-
const typeInfo = new
|
|
72274
|
-
|
|
72674
|
+
const typeInfo = new graphql5.TypeInfo(this.schema);
|
|
72675
|
+
graphql5.visit(
|
|
72275
72676
|
document,
|
|
72276
|
-
|
|
72677
|
+
graphql5.visitWithTypeInfo(typeInfo, {
|
|
72277
72678
|
Directive: (node) => {
|
|
72278
72679
|
if ([this.paginateDirective].includes(node.name.value)) {
|
|
72279
72680
|
paginated = true;
|
|
@@ -72573,347 +72974,76 @@ async function pluginPath(plugin_name, config_path) {
|
|
|
72573
72974
|
if (process.versions.pnp) {
|
|
72574
72975
|
const { findPnpApi } = require("node:module");
|
|
72575
72976
|
const pnp = findPnpApi(config_path);
|
|
72576
|
-
return pnp.resolveRequest(plugin_name, config_path, { conditions: /* @__PURE__ */ new Set(["import"]) });
|
|
72577
|
-
}
|
|
72578
|
-
const pluginDirectory = findModule(plugin_name, config_path);
|
|
72579
|
-
const packageJsonSrc = await readFile(join2(pluginDirectory, "package.json"));
|
|
72580
|
-
if (!packageJsonSrc) {
|
|
72581
|
-
throw new Error("skip");
|
|
72582
|
-
}
|
|
72583
|
-
const packageJSON = JSON.parse(packageJsonSrc);
|
|
72584
|
-
if (!packageJSON.exports?.["."]?.import) {
|
|
72585
|
-
throw new Error("");
|
|
72586
|
-
}
|
|
72587
|
-
return join2(pluginDirectory, packageJSON.exports["."].import);
|
|
72588
|
-
} catch {
|
|
72589
|
-
const err = new Error(
|
|
72590
|
-
`Could not find plugin: ${plugin_name}. Are you sure its installed? If so, please open a ticket on GitHub.`
|
|
72591
|
-
);
|
|
72592
|
-
throw err;
|
|
72593
|
-
}
|
|
72594
|
-
}
|
|
72595
|
-
function findModule(pkg = "houdini", currentLocation) {
|
|
72596
|
-
const pathEndingBy = ["node_modules", pkg];
|
|
72597
|
-
let locationFound = join2(currentLocation, ...pathEndingBy);
|
|
72598
|
-
let previousLocation = "";
|
|
72599
|
-
const backFolder = [];
|
|
72600
|
-
while (previousLocation !== locationFound && !existsSync(locationFound)) {
|
|
72601
|
-
previousLocation = locationFound;
|
|
72602
|
-
backFolder.push("../");
|
|
72603
|
-
locationFound = join2(currentLocation, ...backFolder, ...pathEndingBy);
|
|
72604
|
-
}
|
|
72605
|
-
if (previousLocation === locationFound) {
|
|
72606
|
-
throw new Error("Could not find any node_modules/houdini folder");
|
|
72607
|
-
}
|
|
72608
|
-
return locationFound;
|
|
72609
|
-
}
|
|
72610
|
-
async function loadSchemaFile(schemaPath) {
|
|
72611
|
-
if (isAbsolute(schemaPath)) {
|
|
72612
|
-
const relPath = relative(process.cwd(), schemaPath);
|
|
72613
|
-
const error = new Error(
|
|
72614
|
-
`Invalid config value: 'schemaPath' must now be passed as a relative directory. Please change its value to "./${relPath}".`
|
|
72615
|
-
);
|
|
72616
|
-
error.stack = "";
|
|
72617
|
-
throw error;
|
|
72618
|
-
}
|
|
72619
|
-
if (glob2.hasMagic(schemaPath)) {
|
|
72620
|
-
const sourceFiles = await glob2(schemaPath);
|
|
72621
|
-
return mergeSchemas({
|
|
72622
|
-
typeDefs: await Promise.all(
|
|
72623
|
-
sourceFiles.map(async (filepath) => await readFile(filepath))
|
|
72624
|
-
)
|
|
72625
|
-
});
|
|
72626
|
-
}
|
|
72627
|
-
try {
|
|
72628
|
-
await stat(schemaPath);
|
|
72629
|
-
} catch {
|
|
72630
|
-
throw new HoudiniError({
|
|
72631
|
-
message: `Schema file does not exist! Create it using houdini pull-schema`
|
|
72632
|
-
});
|
|
72633
|
-
}
|
|
72634
|
-
const contents = await readFile(schemaPath);
|
|
72635
|
-
if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql") || schemaPath.endsWith("graphqls")) {
|
|
72636
|
-
return graphql4.buildSchema(contents);
|
|
72637
|
-
}
|
|
72638
|
-
const jsonContents = JSON.parse(contents);
|
|
72639
|
-
if (jsonContents.data) {
|
|
72640
|
-
return graphql4.buildClientSchema(jsonContents.data);
|
|
72641
|
-
}
|
|
72642
|
-
return graphql4.buildClientSchema(jsonContents);
|
|
72643
|
-
}
|
|
72644
|
-
var emptySchema = graphql4.buildSchema("type Query { hello: String }");
|
|
72645
|
-
var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
|
|
72646
|
-
|
|
72647
|
-
// src/lib/graphql.ts
|
|
72648
|
-
var graphql5 = __toESM(require("graphql"), 1);
|
|
72649
|
-
var import_node_crypto = __toESM(require("node:crypto"), 1);
|
|
72650
|
-
function getRootType(type) {
|
|
72651
|
-
if (graphql5.isNonNullType(type)) {
|
|
72652
|
-
return getRootType(type.ofType);
|
|
72653
|
-
}
|
|
72654
|
-
if (graphql5.isListType(type)) {
|
|
72655
|
-
return getRootType(type.ofType);
|
|
72656
|
-
}
|
|
72657
|
-
return type;
|
|
72658
|
-
}
|
|
72659
|
-
function processComponentFieldDirective(directive) {
|
|
72660
|
-
let field;
|
|
72661
|
-
let exportValue;
|
|
72662
|
-
let prop;
|
|
72663
|
-
let raw;
|
|
72664
|
-
for (const arg of directive.arguments ?? []) {
|
|
72665
|
-
if (arg.name.value === "field" && arg.value.kind === "StringValue") {
|
|
72666
|
-
field = arg.value.value;
|
|
72667
|
-
} else if (arg.name.value === "export" && arg.value.kind === "StringValue") {
|
|
72668
|
-
exportValue = arg.value.value;
|
|
72669
|
-
} else if (arg.name.value === "prop" && arg.value.kind === "StringValue") {
|
|
72670
|
-
prop = arg.value.value;
|
|
72671
|
-
} else if (arg.name.value === "raw" && arg.value.kind === "StringValue") {
|
|
72672
|
-
raw = arg.value.value;
|
|
72673
|
-
}
|
|
72674
|
-
}
|
|
72675
|
-
const missing = [];
|
|
72676
|
-
if (!field) {
|
|
72677
|
-
missing.push("field");
|
|
72678
|
-
}
|
|
72679
|
-
if (!prop) {
|
|
72680
|
-
missing.push("prop");
|
|
72681
|
-
}
|
|
72682
|
-
if (missing.length > 0) {
|
|
72683
|
-
throw new Error(`missing arguments to @componentField: ${missing.join(", ")}`);
|
|
72684
|
-
}
|
|
72685
|
-
return {
|
|
72686
|
-
prop,
|
|
72687
|
-
field,
|
|
72688
|
-
raw,
|
|
72689
|
-
export: exportValue
|
|
72690
|
-
};
|
|
72691
|
-
}
|
|
72692
|
-
function hashOriginal({ document }) {
|
|
72693
|
-
return hashDocument(document.originalString);
|
|
72694
|
-
}
|
|
72695
|
-
function hashRaw({ document }) {
|
|
72696
|
-
return hashDocument(document.artifact?.raw);
|
|
72697
|
-
}
|
|
72698
|
-
function hashDocument(str) {
|
|
72699
|
-
return import_node_crypto.default.createHash("sha256").update(str || "").digest("hex");
|
|
72700
|
-
}
|
|
72701
|
-
function parentField(ancestors) {
|
|
72702
|
-
return walkParentField([...ancestors].sort(() => -1));
|
|
72703
|
-
}
|
|
72704
|
-
function walkParentField(ancestors) {
|
|
72705
|
-
let head = ancestors.shift();
|
|
72706
|
-
if (Array.isArray(head) || head.kind === "SelectionSet") {
|
|
72707
|
-
return walkParentField(ancestors);
|
|
72708
|
-
}
|
|
72709
|
-
return head;
|
|
72710
|
-
}
|
|
72711
|
-
function parentTypeFromAncestors(schema, filepath, ancestors) {
|
|
72712
|
-
const parents = [...ancestors];
|
|
72713
|
-
parents.reverse();
|
|
72714
|
-
return walkAncestors(schema, filepath, parents);
|
|
72715
|
-
}
|
|
72716
|
-
function walkAncestors(schema, filepath, ancestors) {
|
|
72717
|
-
let head = ancestors.shift();
|
|
72718
|
-
if (Array.isArray(head)) {
|
|
72719
|
-
return walkAncestors(schema, filepath, ancestors);
|
|
72720
|
-
}
|
|
72721
|
-
if (!head) {
|
|
72722
|
-
throw new HoudiniError({ filepath, message: "Could not figure out type of field" });
|
|
72723
|
-
}
|
|
72724
|
-
if (head.kind === "OperationDefinition") {
|
|
72725
|
-
const operationType = {
|
|
72726
|
-
query: schema.getQueryType(),
|
|
72727
|
-
mutation: schema.getMutationType(),
|
|
72728
|
-
subscription: schema.getSubscriptionType()
|
|
72729
|
-
}[head.operation];
|
|
72730
|
-
if (!operationType) {
|
|
72731
|
-
throw new HoudiniError({ filepath, message: "Could not find operation type" });
|
|
72732
|
-
}
|
|
72733
|
-
return operationType;
|
|
72734
|
-
}
|
|
72735
|
-
if (head.kind === "FragmentDefinition") {
|
|
72736
|
-
const result = schema.getType(head.typeCondition.name.value);
|
|
72737
|
-
if (!result) {
|
|
72738
|
-
throw new HoudiniError({
|
|
72739
|
-
filepath,
|
|
72740
|
-
message: `Could not find definition for ${head.typeCondition.name.value} in the schema`
|
|
72741
|
-
});
|
|
72742
|
-
}
|
|
72743
|
-
return result;
|
|
72744
|
-
}
|
|
72745
|
-
if (head.kind === "FragmentSpread") {
|
|
72746
|
-
throw new Error("How the hell did this happen?");
|
|
72747
|
-
}
|
|
72748
|
-
const parent = walkAncestors(schema, filepath, ancestors);
|
|
72749
|
-
if (head.kind === "InlineFragment") {
|
|
72750
|
-
if (!head.typeCondition) {
|
|
72751
|
-
return parent;
|
|
72752
|
-
}
|
|
72753
|
-
const wrapper = schema.getType(head.typeCondition.name.value);
|
|
72754
|
-
if (!wrapper) {
|
|
72755
|
-
throw new HoudiniError({
|
|
72756
|
-
filepath,
|
|
72757
|
-
message: "Could not find type with name: " + head.typeCondition.name.value
|
|
72758
|
-
});
|
|
72759
|
-
}
|
|
72760
|
-
return wrapper;
|
|
72761
|
-
}
|
|
72762
|
-
if (head.kind === "SelectionSet") {
|
|
72763
|
-
return parent;
|
|
72764
|
-
}
|
|
72765
|
-
const field = parent.getFields()[head.name.value];
|
|
72766
|
-
if (!field) {
|
|
72767
|
-
throw new HoudiniError({
|
|
72768
|
-
filepath,
|
|
72769
|
-
message: `Could not find definition of ${head.name.value} in ${parent.toString()}`
|
|
72770
|
-
});
|
|
72771
|
-
}
|
|
72772
|
-
return getRootType(field.type);
|
|
72773
|
-
}
|
|
72774
|
-
function definitionFromAncestors(ancestors) {
|
|
72775
|
-
let parents = [...ancestors];
|
|
72776
|
-
parents.shift();
|
|
72777
|
-
let definition = parents.shift();
|
|
72778
|
-
while (Array.isArray(definition) && definition) {
|
|
72779
|
-
definition = parents.shift();
|
|
72780
|
-
}
|
|
72781
|
-
return { parents, definition };
|
|
72782
|
-
}
|
|
72783
|
-
function formatErrors(e2, afterError) {
|
|
72784
|
-
const errors = Array.isArray(e2) ? e2 : [e2];
|
|
72785
|
-
for (const error of errors) {
|
|
72786
|
-
if ("filepath" in error && error.filepath) {
|
|
72787
|
-
const relative2 = relative(process.cwd(), error.filepath);
|
|
72788
|
-
console.error(`\u274C Encountered error in ${relative2}`);
|
|
72789
|
-
if (error.message) {
|
|
72790
|
-
console.error(error.message);
|
|
72791
|
-
}
|
|
72792
|
-
} else {
|
|
72793
|
-
console.error(`\u274C ${error.message}`);
|
|
72794
|
-
if ("description" in error && error.description) {
|
|
72795
|
-
console.error(`${error.description}`);
|
|
72796
|
-
}
|
|
72797
|
-
}
|
|
72798
|
-
afterError?.(e2);
|
|
72799
|
-
}
|
|
72800
|
-
}
|
|
72801
|
-
function operation_requires_variables(operation) {
|
|
72802
|
-
return Boolean(
|
|
72803
|
-
operation.variableDefinitions && operation.variableDefinitions?.find(
|
|
72804
|
-
(defn) => defn.type.kind === "NonNullType" && !defn.defaultValue
|
|
72805
|
-
)
|
|
72806
|
-
);
|
|
72807
|
-
}
|
|
72808
|
-
function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
|
|
72809
|
-
if (type.kind === "NonNullType") {
|
|
72810
|
-
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
72811
|
-
}
|
|
72812
|
-
if (type instanceof graphql5.GraphQLNonNull) {
|
|
72813
|
-
return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
|
|
72814
|
-
}
|
|
72815
|
-
if (wrappers[0] !== TypeWrapper.NonNull) {
|
|
72816
|
-
wrappers.unshift(TypeWrapper.Nullable);
|
|
72817
|
-
}
|
|
72818
|
-
if (type.kind === "ListType") {
|
|
72819
|
-
return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers]);
|
|
72820
|
-
}
|
|
72821
|
-
if (type instanceof graphql5.GraphQLList) {
|
|
72822
|
-
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
72823
|
-
}
|
|
72824
|
-
if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
72825
|
-
type = config.schema.getType(
|
|
72826
|
-
config.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
72977
|
+
return pnp.resolveRequest(plugin_name, config_path, { conditions: /* @__PURE__ */ new Set(["import"]) });
|
|
72978
|
+
}
|
|
72979
|
+
const pluginDirectory = findModule(plugin_name, config_path);
|
|
72980
|
+
const packageJsonSrc = await readFile(join2(pluginDirectory, "package.json"));
|
|
72981
|
+
if (!packageJsonSrc) {
|
|
72982
|
+
throw new Error("skip");
|
|
72983
|
+
}
|
|
72984
|
+
const packageJSON = JSON.parse(packageJsonSrc);
|
|
72985
|
+
if (!packageJSON.exports?.["."]?.import) {
|
|
72986
|
+
throw new Error("");
|
|
72987
|
+
}
|
|
72988
|
+
return join2(pluginDirectory, packageJSON.exports["."].import);
|
|
72989
|
+
} catch {
|
|
72990
|
+
const err = new Error(
|
|
72991
|
+
`Could not find plugin: ${plugin_name}. Are you sure its installed? If so, please open a ticket on GitHub.`
|
|
72827
72992
|
);
|
|
72993
|
+
throw err;
|
|
72828
72994
|
}
|
|
72829
|
-
const namedType = config.schema.getType(type.name.value || type.name);
|
|
72830
|
-
if (!namedType) {
|
|
72831
|
-
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
72832
|
-
}
|
|
72833
|
-
return { type: namedType, wrappers };
|
|
72834
72995
|
}
|
|
72835
|
-
function
|
|
72836
|
-
|
|
72837
|
-
|
|
72838
|
-
|
|
72839
|
-
const
|
|
72840
|
-
|
|
72841
|
-
|
|
72842
|
-
|
|
72843
|
-
|
|
72844
|
-
} else if (head === TypeWrapper.NonNull) {
|
|
72845
|
-
kind = graphql5.Kind.NON_NULL_TYPE;
|
|
72996
|
+
function findModule(pkg = "houdini", currentLocation) {
|
|
72997
|
+
const pathEndingBy = ["node_modules", pkg];
|
|
72998
|
+
let locationFound = join2(currentLocation, ...pathEndingBy);
|
|
72999
|
+
let previousLocation = "";
|
|
73000
|
+
const backFolder = [];
|
|
73001
|
+
while (previousLocation !== locationFound && !existsSync(locationFound)) {
|
|
73002
|
+
previousLocation = locationFound;
|
|
73003
|
+
backFolder.push("../");
|
|
73004
|
+
locationFound = join2(currentLocation, ...backFolder, ...pathEndingBy);
|
|
72846
73005
|
}
|
|
72847
|
-
if (
|
|
72848
|
-
|
|
72849
|
-
kind,
|
|
72850
|
-
name: {
|
|
72851
|
-
kind: graphql5.Kind.NAME,
|
|
72852
|
-
value: type.name
|
|
72853
|
-
}
|
|
72854
|
-
};
|
|
73006
|
+
if (previousLocation === locationFound) {
|
|
73007
|
+
throw new Error("Could not find any node_modules/houdini folder");
|
|
72855
73008
|
}
|
|
72856
|
-
return
|
|
72857
|
-
kind,
|
|
72858
|
-
type: wrapType({ type, wrappers: tail })
|
|
72859
|
-
};
|
|
73009
|
+
return locationFound;
|
|
72860
73010
|
}
|
|
72861
|
-
|
|
72862
|
-
|
|
72863
|
-
|
|
72864
|
-
|
|
72865
|
-
|
|
72866
|
-
|
|
72867
|
-
|
|
72868
|
-
|
|
72869
|
-
|
|
72870
|
-
|
|
72871
|
-
|
|
72872
|
-
|
|
72873
|
-
|
|
72874
|
-
|
|
73011
|
+
async function loadSchemaFile(schemaPath) {
|
|
73012
|
+
if (isAbsolute(schemaPath)) {
|
|
73013
|
+
const relPath = relative(process.cwd(), schemaPath);
|
|
73014
|
+
const error = new Error(
|
|
73015
|
+
`Invalid config value: 'schemaPath' must now be passed as a relative directory. Please change its value to "./${relPath}".`
|
|
73016
|
+
);
|
|
73017
|
+
error.stack = "";
|
|
73018
|
+
throw error;
|
|
73019
|
+
}
|
|
73020
|
+
if (glob2.hasMagic(schemaPath)) {
|
|
73021
|
+
const sourceFiles = await glob2(schemaPath);
|
|
73022
|
+
return mergeSchemas({
|
|
73023
|
+
typeDefs: await Promise.all(
|
|
73024
|
+
sourceFiles.map(async (filepath) => await readFile(filepath))
|
|
73025
|
+
)
|
|
73026
|
+
});
|
|
73027
|
+
}
|
|
72875
73028
|
try {
|
|
72876
|
-
|
|
72877
|
-
|
|
72878
|
-
} else if (targets.length === 2) {
|
|
72879
|
-
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
72880
|
-
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
72881
|
-
});
|
|
72882
|
-
}
|
|
72883
|
-
return deepMerge2(filepath, targets[0], deepMerge2(filepath, ...targets.slice(1)));
|
|
72884
|
-
} catch (e2) {
|
|
73029
|
+
await stat(schemaPath);
|
|
73030
|
+
} catch {
|
|
72885
73031
|
throw new HoudiniError({
|
|
72886
|
-
|
|
72887
|
-
message: "could not merge: " + JSON.stringify(targets, null, 4),
|
|
72888
|
-
description: e2.message
|
|
73032
|
+
message: `Schema file does not exist! Create it using houdini pull-schema`
|
|
72889
73033
|
});
|
|
72890
73034
|
}
|
|
72891
|
-
|
|
72892
|
-
|
|
72893
|
-
|
|
72894
|
-
function parseJS(str, config) {
|
|
72895
|
-
const defaultConfig = {
|
|
72896
|
-
plugins: [
|
|
72897
|
-
"typescript",
|
|
72898
|
-
"importAssertions",
|
|
72899
|
-
"decorators-legacy",
|
|
72900
|
-
"explicitResourceManagement"
|
|
72901
|
-
],
|
|
72902
|
-
sourceType: "module"
|
|
72903
|
-
};
|
|
72904
|
-
return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
|
|
72905
|
-
}
|
|
72906
|
-
function parseJSON(str) {
|
|
72907
|
-
str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m2, g) => g ? "" : m2);
|
|
72908
|
-
return JSON.parse(str);
|
|
72909
|
-
}
|
|
72910
|
-
async function printJS(script, options) {
|
|
72911
|
-
if (options?.pretty) {
|
|
72912
|
-
return (0, import_recast.prettyPrint)(script, options);
|
|
72913
|
-
} else {
|
|
72914
|
-
return (0, import_recast.print)(script, options);
|
|
73035
|
+
const contents = await readFile(schemaPath);
|
|
73036
|
+
if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql") || schemaPath.endsWith("graphqls")) {
|
|
73037
|
+
return graphql5.buildSchema(contents);
|
|
72915
73038
|
}
|
|
73039
|
+
const jsonContents = JSON.parse(contents);
|
|
73040
|
+
if (jsonContents.data) {
|
|
73041
|
+
return graphql5.buildClientSchema(jsonContents.data);
|
|
73042
|
+
}
|
|
73043
|
+
return graphql5.buildClientSchema(jsonContents);
|
|
72916
73044
|
}
|
|
73045
|
+
var emptySchema = graphql5.buildSchema("type Query { hello: String }");
|
|
73046
|
+
var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
|
|
72917
73047
|
|
|
72918
73048
|
// src/lib/imports.ts
|
|
72919
73049
|
var recast = __toESM(require_main2(), 1);
|
|
@@ -72991,7 +73121,7 @@ async function cleanupFiles(pathFolder, listOfObj) {
|
|
|
72991
73121
|
// src/lib/detectTools.ts
|
|
72992
73122
|
async function detectFromPackageJSON(cwd) {
|
|
72993
73123
|
try {
|
|
72994
|
-
const packageJSONFile = await
|
|
73124
|
+
const packageJSONFile = await readFile(join2(cwd, "package.json"));
|
|
72995
73125
|
if (packageJSONFile) {
|
|
72996
73126
|
var packageJSON = JSON.parse(packageJSONFile);
|
|
72997
73127
|
} else {
|
|
@@ -73016,22 +73146,22 @@ async function detectFromPackageJSON(cwd) {
|
|
|
73016
73146
|
async function detectTools(cwd = process.cwd()) {
|
|
73017
73147
|
let typescript = false;
|
|
73018
73148
|
try {
|
|
73019
|
-
await
|
|
73149
|
+
await stat(join2(cwd, "tsconfig.json"));
|
|
73020
73150
|
typescript = true;
|
|
73021
73151
|
} catch {
|
|
73022
73152
|
}
|
|
73023
73153
|
let package_manager = "npm";
|
|
73024
73154
|
let dir = cwd;
|
|
73025
73155
|
do {
|
|
73026
|
-
if (
|
|
73156
|
+
if (existsSync(join2(dir, "pnpm-lock.yaml"))) {
|
|
73027
73157
|
package_manager = "pnpm";
|
|
73028
73158
|
break;
|
|
73029
73159
|
}
|
|
73030
|
-
if (
|
|
73160
|
+
if (existsSync(join2(dir, "yarn.lock"))) {
|
|
73031
73161
|
package_manager = "yarn";
|
|
73032
73162
|
break;
|
|
73033
73163
|
}
|
|
73034
|
-
} while (dir !== (dir =
|
|
73164
|
+
} while (dir !== (dir = dirname(dir)));
|
|
73035
73165
|
return {
|
|
73036
73166
|
typescript,
|
|
73037
73167
|
package_manager,
|
|
@@ -73039,134 +73169,6 @@ async function detectTools(cwd = process.cwd()) {
|
|
|
73039
73169
|
};
|
|
73040
73170
|
}
|
|
73041
73171
|
|
|
73042
|
-
// src/runtime/router/match.ts
|
|
73043
|
-
var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
73044
|
-
function find_match(config, manifest, current, allowNull = true) {
|
|
73045
|
-
let match2 = null;
|
|
73046
|
-
let matchVariables = null;
|
|
73047
|
-
for (const page of Object.values(manifest.pages)) {
|
|
73048
|
-
const urlMatch = current.match(page.pattern);
|
|
73049
|
-
if (!urlMatch) {
|
|
73050
|
-
continue;
|
|
73051
|
-
}
|
|
73052
|
-
match2 = page;
|
|
73053
|
-
matchVariables = exec(urlMatch, page.params) || {};
|
|
73054
|
-
break;
|
|
73055
|
-
}
|
|
73056
|
-
if (!match2 && !allowNull) {
|
|
73057
|
-
throw new Error("404");
|
|
73058
|
-
}
|
|
73059
|
-
let variables = {
|
|
73060
|
-
...matchVariables
|
|
73061
|
-
};
|
|
73062
|
-
for (const document of Object.values(match2?.documents ?? {})) {
|
|
73063
|
-
for (const [variable, { type }] of Object.entries(document.variables)) {
|
|
73064
|
-
if (matchVariables?.[variable]) {
|
|
73065
|
-
variables[variable] = parseScalar(config, type, matchVariables[variable]);
|
|
73066
|
-
}
|
|
73067
|
-
}
|
|
73068
|
-
}
|
|
73069
|
-
return [match2, variables];
|
|
73070
|
-
}
|
|
73071
|
-
function parse_page_pattern(id) {
|
|
73072
|
-
const params = [];
|
|
73073
|
-
const pattern = id === "/" ? /^\/$/ : new RegExp(
|
|
73074
|
-
`^${get_route_segments(id).map((segment) => {
|
|
73075
|
-
const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
|
73076
|
-
if (rest_match) {
|
|
73077
|
-
params.push({
|
|
73078
|
-
name: rest_match[1],
|
|
73079
|
-
matcher: rest_match[2],
|
|
73080
|
-
optional: false,
|
|
73081
|
-
rest: true,
|
|
73082
|
-
chained: true
|
|
73083
|
-
});
|
|
73084
|
-
return "(?:/(.*))?";
|
|
73085
|
-
}
|
|
73086
|
-
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
73087
|
-
if (optional_match) {
|
|
73088
|
-
params.push({
|
|
73089
|
-
name: optional_match[1],
|
|
73090
|
-
matcher: optional_match[2],
|
|
73091
|
-
optional: true,
|
|
73092
|
-
rest: false,
|
|
73093
|
-
chained: true
|
|
73094
|
-
});
|
|
73095
|
-
return "(?:/([^/]+))?";
|
|
73096
|
-
}
|
|
73097
|
-
if (!segment) {
|
|
73098
|
-
return;
|
|
73099
|
-
}
|
|
73100
|
-
const parts = segment.split(/\[(.+?)\](?!\])/);
|
|
73101
|
-
const result = parts.map((content, i2) => {
|
|
73102
|
-
if (i2 % 2) {
|
|
73103
|
-
if (content.startsWith("x+")) {
|
|
73104
|
-
return escape3(
|
|
73105
|
-
String.fromCharCode(parseInt(content.slice(2), 16))
|
|
73106
|
-
);
|
|
73107
|
-
}
|
|
73108
|
-
if (content.startsWith("u+")) {
|
|
73109
|
-
return escape3(
|
|
73110
|
-
String.fromCharCode(
|
|
73111
|
-
...content.slice(2).split("-").map((code) => parseInt(code, 16))
|
|
73112
|
-
)
|
|
73113
|
-
);
|
|
73114
|
-
}
|
|
73115
|
-
const match2 = param_pattern.exec(content);
|
|
73116
|
-
if (!match2) {
|
|
73117
|
-
throw new Error(
|
|
73118
|
-
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
73119
|
-
);
|
|
73120
|
-
}
|
|
73121
|
-
const [, is_optional, is_rest, name, matcher] = match2;
|
|
73122
|
-
params.push({
|
|
73123
|
-
name,
|
|
73124
|
-
matcher,
|
|
73125
|
-
optional: !!is_optional,
|
|
73126
|
-
rest: !!is_rest,
|
|
73127
|
-
chained: is_rest ? i2 === 1 && parts[0] === "" : false
|
|
73128
|
-
});
|
|
73129
|
-
return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
|
|
73130
|
-
}
|
|
73131
|
-
return escape3(content);
|
|
73132
|
-
}).join("");
|
|
73133
|
-
return "/" + result;
|
|
73134
|
-
}).join("")}/?$`
|
|
73135
|
-
);
|
|
73136
|
-
return { pattern, params, page_id: id };
|
|
73137
|
-
}
|
|
73138
|
-
function affects_path(segment) {
|
|
73139
|
-
return !/^\([^)]+\)$/.test(segment);
|
|
73140
|
-
}
|
|
73141
|
-
function get_route_segments(route) {
|
|
73142
|
-
return route.slice(1).split("/").filter(affects_path);
|
|
73143
|
-
}
|
|
73144
|
-
function exec(match2, params) {
|
|
73145
|
-
const result = {};
|
|
73146
|
-
const values = match2.slice(1);
|
|
73147
|
-
let buffered = "";
|
|
73148
|
-
for (let i2 = 0; i2 < (params || []).length; i2 += 1) {
|
|
73149
|
-
const param = params[i2];
|
|
73150
|
-
let value = values[i2];
|
|
73151
|
-
if (param.chained && param.rest && buffered) {
|
|
73152
|
-
value = value ? buffered + "/" + value : buffered;
|
|
73153
|
-
}
|
|
73154
|
-
buffered = "";
|
|
73155
|
-
if (value === void 0) {
|
|
73156
|
-
if (param.rest)
|
|
73157
|
-
result[param.name] = "";
|
|
73158
|
-
} else {
|
|
73159
|
-
result[param.name] = decodeURIComponent(value);
|
|
73160
|
-
}
|
|
73161
|
-
}
|
|
73162
|
-
if (buffered)
|
|
73163
|
-
return;
|
|
73164
|
-
return result;
|
|
73165
|
-
}
|
|
73166
|
-
function escape3(str) {
|
|
73167
|
-
return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
|
|
73168
|
-
}
|
|
73169
|
-
|
|
73170
73172
|
// src/lib/typescript.ts
|
|
73171
73173
|
var graphql6 = __toESM(require("graphql"), 1);
|
|
73172
73174
|
var recast2 = __toESM(require_main2(), 1);
|
|
@@ -73236,18 +73238,18 @@ function scalarPropertyValue(config, filepath, missingScalars, target, body, fie
|
|
|
73236
73238
|
return AST3.tsNeverKeyword();
|
|
73237
73239
|
}
|
|
73238
73240
|
const component = config.componentFields[field.parent][field.field];
|
|
73239
|
-
const sourcePathRelative =
|
|
73240
|
-
|
|
73241
|
+
const sourcePathRelative = relative(
|
|
73242
|
+
join2(config.projectRoot, "src"),
|
|
73241
73243
|
component.filepath
|
|
73242
73244
|
);
|
|
73243
|
-
let sourcePathParsed =
|
|
73244
|
-
let sourcePath =
|
|
73245
|
+
let sourcePathParsed = parse3(sourcePathRelative);
|
|
73246
|
+
let sourcePath = join2(sourcePathParsed.dir, sourcePathParsed.name);
|
|
73245
73247
|
const localImport = ensureImports({
|
|
73246
73248
|
config,
|
|
73247
73249
|
body,
|
|
73248
73250
|
import: "__component__" + component.fragment,
|
|
73249
|
-
sourceModule:
|
|
73250
|
-
|
|
73251
|
+
sourceModule: join2(
|
|
73252
|
+
relative(dirname(filepath), config.projectRoot),
|
|
73251
73253
|
"src",
|
|
73252
73254
|
sourcePath
|
|
73253
73255
|
)
|
|
@@ -73313,9 +73315,9 @@ function scalarPropertyValue(config, filepath, missingScalars, target, body, fie
|
|
|
73313
73315
|
}
|
|
73314
73316
|
}
|
|
73315
73317
|
async function writeTsConfig(config) {
|
|
73316
|
-
await
|
|
73317
|
-
await
|
|
73318
|
-
|
|
73318
|
+
await mkdirp(config.rootDir);
|
|
73319
|
+
await writeFile(
|
|
73320
|
+
join2(config.rootDir, "tsconfig.json"),
|
|
73319
73321
|
JSON.stringify(
|
|
73320
73322
|
{
|
|
73321
73323
|
compilerOptions: {
|