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/vite-esm/index.js
CHANGED
|
@@ -62972,7 +62972,7 @@ function mergeSchemas(config2) {
|
|
|
62972
62972
|
|
|
62973
62973
|
// src/lib/config.ts
|
|
62974
62974
|
var import_minimatch8 = __toESM(require_minimatch(), 1);
|
|
62975
|
-
import * as
|
|
62975
|
+
import * as graphql5 from "graphql";
|
|
62976
62976
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
62977
62977
|
|
|
62978
62978
|
// src/runtime/imports/config.ts
|
|
@@ -70192,43 +70192,43 @@ __export(conventions_exports, {
|
|
|
70192
70192
|
vite_render_path: () => vite_render_path
|
|
70193
70193
|
});
|
|
70194
70194
|
function router_path(config2) {
|
|
70195
|
-
return
|
|
70195
|
+
return join2(base_dir(config2), "Router.jsx");
|
|
70196
70196
|
}
|
|
70197
70197
|
function page_entry_path(config2, id, base) {
|
|
70198
|
-
return
|
|
70198
|
+
return join2(page_entries_dir(config2, base), `${id}.jsx`);
|
|
70199
70199
|
}
|
|
70200
70200
|
function server_adapter_path(config2, base) {
|
|
70201
|
-
return
|
|
70201
|
+
return join2(units_dir(config2, base), "render", "server.js");
|
|
70202
70202
|
}
|
|
70203
70203
|
function adapter_config_path(config2, base) {
|
|
70204
|
-
return
|
|
70204
|
+
return join2(units_dir(config2, base), "render", "config.js");
|
|
70205
70205
|
}
|
|
70206
70206
|
function vite_render_path(config2, base) {
|
|
70207
|
-
return
|
|
70207
|
+
return join2(units_dir(config2, base), "render", "vite.js");
|
|
70208
70208
|
}
|
|
70209
70209
|
function app_component_path(config2, base) {
|
|
70210
|
-
return
|
|
70210
|
+
return join2(units_dir(config2, base), "render", "App.jsx");
|
|
70211
70211
|
}
|
|
70212
70212
|
function page_unit_path(config2, id, base) {
|
|
70213
|
-
return
|
|
70213
|
+
return join2(page_units_dir(config2, base), `${id}.jsx`);
|
|
70214
70214
|
}
|
|
70215
70215
|
function layout_unit_path(config2, id, base) {
|
|
70216
|
-
return
|
|
70216
|
+
return join2(layout_units_dir(config2, base), `${id}.jsx`);
|
|
70217
70217
|
}
|
|
70218
70218
|
function componentField_unit_path(config2, id, base) {
|
|
70219
|
-
return
|
|
70219
|
+
return join2(units_dir(config2, base), "componentFields", `wrapper_${id}.jsx`);
|
|
70220
70220
|
}
|
|
70221
70221
|
function fallback_unit_path(config2, which, id, base) {
|
|
70222
|
-
return
|
|
70222
|
+
return join2(fallbacks_units_dir(config2, which, base), `${id}.jsx`);
|
|
70223
70223
|
}
|
|
70224
70224
|
async function read_pageQuery(base) {
|
|
70225
|
-
const target =
|
|
70226
|
-
return [target, await
|
|
70225
|
+
const target = join2(base, "+page.gql");
|
|
70226
|
+
return [target, await readFile(target)];
|
|
70227
70227
|
}
|
|
70228
70228
|
async function read_pageView(base) {
|
|
70229
70229
|
for (const name of ["+page.tsx", "+page.jsx"]) {
|
|
70230
|
-
let target =
|
|
70231
|
-
let result = await
|
|
70230
|
+
let target = join2(base, name);
|
|
70231
|
+
let result = await readFile(target);
|
|
70232
70232
|
if (result) {
|
|
70233
70233
|
return [target, result];
|
|
70234
70234
|
}
|
|
@@ -70236,13 +70236,13 @@ async function read_pageView(base) {
|
|
|
70236
70236
|
return [null, null];
|
|
70237
70237
|
}
|
|
70238
70238
|
async function read_layoutQuery(base) {
|
|
70239
|
-
const target =
|
|
70240
|
-
return [target, await
|
|
70239
|
+
const target = join2(base, "+layout.gql");
|
|
70240
|
+
return [target, await readFile(target)];
|
|
70241
70241
|
}
|
|
70242
70242
|
async function read_layoutView(base) {
|
|
70243
70243
|
for (const name of ["+layout.tsx", "+layout.jsx"]) {
|
|
70244
|
-
let target =
|
|
70245
|
-
let result = await
|
|
70244
|
+
let target = join2(base, name);
|
|
70245
|
+
let result = await readFile(target);
|
|
70246
70246
|
if (result) {
|
|
70247
70247
|
return [target, result];
|
|
70248
70248
|
}
|
|
@@ -70250,10 +70250,10 @@ async function read_layoutView(base) {
|
|
|
70250
70250
|
return [null, null];
|
|
70251
70251
|
}
|
|
70252
70252
|
function temp_dir(config2, key) {
|
|
70253
|
-
return
|
|
70253
|
+
return join2(config2.rootDir, "temp", key);
|
|
70254
70254
|
}
|
|
70255
70255
|
function router_index_path(config2) {
|
|
70256
|
-
return
|
|
70256
|
+
return join2(config2.routesDir, "..", "+index.jsx");
|
|
70257
70257
|
}
|
|
70258
70258
|
function is_layout(path4) {
|
|
70259
70259
|
return path4.endsWith("+layout.tsx") || path4.endsWith("+layout.jsx");
|
|
@@ -70276,202 +70276,510 @@ function page_id(path4) {
|
|
|
70276
70276
|
return copy;
|
|
70277
70277
|
}
|
|
70278
70278
|
function page_entries_dir(config2, base) {
|
|
70279
|
-
return
|
|
70279
|
+
return join2(units_dir(config2, base), "entries");
|
|
70280
70280
|
}
|
|
70281
70281
|
function page_units_dir(config2, base) {
|
|
70282
|
-
return
|
|
70282
|
+
return join2(units_dir(config2, base), "pages");
|
|
70283
70283
|
}
|
|
70284
70284
|
function layout_units_dir(config2, base) {
|
|
70285
|
-
return
|
|
70285
|
+
return join2(units_dir(config2, base), "layouts");
|
|
70286
70286
|
}
|
|
70287
70287
|
function fallbacks_units_dir(config2, which, base) {
|
|
70288
|
-
return
|
|
70288
|
+
return join2(units_dir(config2, base), "fallbacks", which);
|
|
70289
70289
|
}
|
|
70290
70290
|
function units_dir(config2, base = base_dir(config2)) {
|
|
70291
|
-
return
|
|
70291
|
+
return join2(base, "units");
|
|
70292
70292
|
}
|
|
70293
70293
|
function base_dir(config2) {
|
|
70294
70294
|
return config2.pluginDirectory("houdini-react");
|
|
70295
70295
|
}
|
|
70296
70296
|
function serialized_manifest_path(config2, base = base_dir(config2)) {
|
|
70297
|
-
return
|
|
70297
|
+
return join2(base, "manifest.json");
|
|
70298
70298
|
}
|
|
70299
70299
|
|
|
70300
70300
|
// src/lib/router/manifest.ts
|
|
70301
70301
|
var t2 = __toESM(require_lib5(), 1);
|
|
70302
|
-
import * as
|
|
70303
|
-
|
|
70304
|
-
|
|
70305
|
-
|
|
70306
|
-
|
|
70307
|
-
|
|
70308
|
-
|
|
70309
|
-
|
|
70310
|
-
|
|
70311
|
-
|
|
70312
|
-
|
|
70313
|
-
|
|
70314
|
-
|
|
70315
|
-
|
|
70316
|
-
|
|
70317
|
-
|
|
70318
|
-
|
|
70319
|
-
|
|
70320
|
-
variables: {}
|
|
70321
|
-
});
|
|
70322
|
-
if (args.includeArtifacts) {
|
|
70323
|
-
try {
|
|
70324
|
-
for (const artifactPath of await fs_exports.readdir(args.config.artifactDirectory)) {
|
|
70325
|
-
if (!artifactPath.endsWith(".js") || artifactPath === "index.js") {
|
|
70326
|
-
continue;
|
|
70327
|
-
}
|
|
70328
|
-
manifest.artifacts.push(artifactPath.substring(0, artifactPath.length - 3));
|
|
70302
|
+
import * as graphql3 from "graphql";
|
|
70303
|
+
|
|
70304
|
+
// src/runtime/router/match.ts
|
|
70305
|
+
var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
70306
|
+
function parse_page_pattern(id) {
|
|
70307
|
+
const params = [];
|
|
70308
|
+
const pattern = id === "/" ? /^\/$/ : new RegExp(
|
|
70309
|
+
`^${get_route_segments(id).map((segment) => {
|
|
70310
|
+
const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
|
70311
|
+
if (rest_match) {
|
|
70312
|
+
params.push({
|
|
70313
|
+
name: rest_match[1],
|
|
70314
|
+
matcher: rest_match[2],
|
|
70315
|
+
optional: false,
|
|
70316
|
+
rest: true,
|
|
70317
|
+
chained: true
|
|
70318
|
+
});
|
|
70319
|
+
return "(?:/(.*))?";
|
|
70329
70320
|
}
|
|
70330
|
-
|
|
70331
|
-
|
|
70332
|
-
|
|
70333
|
-
|
|
70334
|
-
|
|
70335
|
-
|
|
70336
|
-
|
|
70337
|
-
|
|
70338
|
-
|
|
70339
|
-
|
|
70340
|
-
manifest.local_yoga = true;
|
|
70321
|
+
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
70322
|
+
if (optional_match) {
|
|
70323
|
+
params.push({
|
|
70324
|
+
name: optional_match[1],
|
|
70325
|
+
matcher: optional_match[2],
|
|
70326
|
+
optional: true,
|
|
70327
|
+
rest: false,
|
|
70328
|
+
chained: true
|
|
70329
|
+
});
|
|
70330
|
+
return "(?:/([^/]+))?";
|
|
70341
70331
|
}
|
|
70342
|
-
|
|
70343
|
-
} catch {
|
|
70344
|
-
}
|
|
70345
|
-
return manifest;
|
|
70346
|
-
}
|
|
70347
|
-
async function walk_routes(args) {
|
|
70348
|
-
const directory_contents = await fs_exports.readdir(args.filepath, {
|
|
70349
|
-
withFileTypes: true
|
|
70350
|
-
});
|
|
70351
|
-
const variables = { ...args.variables };
|
|
70352
|
-
let newLayouts = args.layouts;
|
|
70353
|
-
let newLayoutQueries = args.queries;
|
|
70354
|
-
let layout = null;
|
|
70355
|
-
let layoutQuery = null;
|
|
70356
|
-
let pageQuery = null;
|
|
70357
|
-
const [
|
|
70358
|
-
[layoutQueryPath, layoutQueryContents],
|
|
70359
|
-
[layoutViewPath, layoutViewContents],
|
|
70360
|
-
[pageQueryPath, pageQueryContents],
|
|
70361
|
-
[pageViewPath, pageViewContents]
|
|
70362
|
-
] = await Promise.all([
|
|
70363
|
-
read_layoutQuery(args.filepath),
|
|
70364
|
-
read_layoutView(args.filepath),
|
|
70365
|
-
read_pageQuery(args.filepath),
|
|
70366
|
-
read_pageView(args.filepath)
|
|
70367
|
-
]);
|
|
70368
|
-
if (layoutQueryContents) {
|
|
70369
|
-
layoutQuery = await add_query({
|
|
70370
|
-
path: layoutQueryPath,
|
|
70371
|
-
config: args.config,
|
|
70372
|
-
url: args.url,
|
|
70373
|
-
project: args.project,
|
|
70374
|
-
type: "layout",
|
|
70375
|
-
contents: layoutQueryContents,
|
|
70376
|
-
variables
|
|
70377
|
-
});
|
|
70378
|
-
newLayoutQueries = [...args.queries, layoutQuery.name];
|
|
70379
|
-
}
|
|
70380
|
-
if (layoutViewContents) {
|
|
70381
|
-
layout = await add_view({
|
|
70382
|
-
url: args.url,
|
|
70383
|
-
path: layoutViewPath,
|
|
70384
|
-
project: args.project,
|
|
70385
|
-
type: "layout",
|
|
70386
|
-
contents: layoutViewContents,
|
|
70387
|
-
layouts: args.layouts,
|
|
70388
|
-
queries: newLayoutQueries,
|
|
70389
|
-
config: args.config,
|
|
70390
|
-
variables
|
|
70391
|
-
});
|
|
70392
|
-
newLayouts = [...args.layouts, page_id(layout.url)];
|
|
70393
|
-
}
|
|
70394
|
-
if (pageQueryContents) {
|
|
70395
|
-
pageQuery = await add_query({
|
|
70396
|
-
path: pageQueryPath,
|
|
70397
|
-
config: args.config,
|
|
70398
|
-
url: args.url,
|
|
70399
|
-
project: args.project,
|
|
70400
|
-
type: "page",
|
|
70401
|
-
contents: pageQueryContents,
|
|
70402
|
-
variables
|
|
70403
|
-
});
|
|
70404
|
-
}
|
|
70405
|
-
if (pageViewContents) {
|
|
70406
|
-
await add_view({
|
|
70407
|
-
path: pageViewPath,
|
|
70408
|
-
url: args.url.substring(0, args.url.length - 1) || "/",
|
|
70409
|
-
project: args.project,
|
|
70410
|
-
type: "page",
|
|
70411
|
-
contents: pageViewContents,
|
|
70412
|
-
layouts: newLayouts,
|
|
70413
|
-
queries: pageQuery ? [...newLayoutQueries, pageQuery.name] : newLayoutQueries,
|
|
70414
|
-
config: args.config,
|
|
70415
|
-
variables
|
|
70416
|
-
});
|
|
70417
|
-
}
|
|
70418
|
-
await Promise.all(
|
|
70419
|
-
directory_contents.map((dir) => {
|
|
70420
|
-
if (!dir.isDirectory()) {
|
|
70332
|
+
if (!segment) {
|
|
70421
70333
|
return;
|
|
70422
70334
|
}
|
|
70423
|
-
|
|
70424
|
-
|
|
70425
|
-
|
|
70426
|
-
|
|
70427
|
-
|
|
70428
|
-
|
|
70429
|
-
|
|
70430
|
-
|
|
70431
|
-
|
|
70335
|
+
const parts = segment.split(/\[(.+?)\](?!\])/);
|
|
70336
|
+
const result = parts.map((content, i2) => {
|
|
70337
|
+
if (i2 % 2) {
|
|
70338
|
+
if (content.startsWith("x+")) {
|
|
70339
|
+
return escape3(
|
|
70340
|
+
String.fromCharCode(parseInt(content.slice(2), 16))
|
|
70341
|
+
);
|
|
70342
|
+
}
|
|
70343
|
+
if (content.startsWith("u+")) {
|
|
70344
|
+
return escape3(
|
|
70345
|
+
String.fromCharCode(
|
|
70346
|
+
...content.slice(2).split("-").map((code) => parseInt(code, 16))
|
|
70347
|
+
)
|
|
70348
|
+
);
|
|
70349
|
+
}
|
|
70350
|
+
const match2 = param_pattern.exec(content);
|
|
70351
|
+
if (!match2) {
|
|
70352
|
+
throw new Error(
|
|
70353
|
+
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
70354
|
+
);
|
|
70355
|
+
}
|
|
70356
|
+
const [, is_optional, is_rest, name, matcher] = match2;
|
|
70357
|
+
params.push({
|
|
70358
|
+
name,
|
|
70359
|
+
matcher,
|
|
70360
|
+
optional: !!is_optional,
|
|
70361
|
+
rest: !!is_rest,
|
|
70362
|
+
chained: is_rest ? i2 === 1 && parts[0] === "" : false
|
|
70363
|
+
});
|
|
70364
|
+
return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
|
|
70365
|
+
}
|
|
70366
|
+
return escape3(content);
|
|
70367
|
+
}).join("");
|
|
70368
|
+
return "/" + result;
|
|
70369
|
+
}).join("")}/?$`
|
|
70432
70370
|
);
|
|
70433
|
-
return
|
|
70371
|
+
return { pattern, params, page_id: id };
|
|
70434
70372
|
}
|
|
70435
|
-
|
|
70436
|
-
|
|
70437
|
-
|
|
70438
|
-
|
|
70439
|
-
|
|
70440
|
-
|
|
70441
|
-
|
|
70442
|
-
|
|
70373
|
+
function affects_path(segment) {
|
|
70374
|
+
return !/^\([^)]+\)$/.test(segment);
|
|
70375
|
+
}
|
|
70376
|
+
function get_route_segments(route) {
|
|
70377
|
+
return route.slice(1).split("/").filter(affects_path);
|
|
70378
|
+
}
|
|
70379
|
+
function escape3(str) {
|
|
70380
|
+
return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
|
|
70381
|
+
}
|
|
70382
|
+
|
|
70383
|
+
// src/lib/graphql.ts
|
|
70384
|
+
import * as graphql2 from "graphql";
|
|
70385
|
+
import crypto2 from "node:crypto";
|
|
70386
|
+
function getRootType(type) {
|
|
70387
|
+
if (graphql2.isNonNullType(type)) {
|
|
70388
|
+
return getRootType(type.ofType);
|
|
70443
70389
|
}
|
|
70444
|
-
|
|
70445
|
-
|
|
70446
|
-
|
|
70447
|
-
|
|
70448
|
-
url: args.url,
|
|
70449
|
-
layouts: args.layouts,
|
|
70450
|
-
path: path_exports.relative(args.config.projectRoot, args.path),
|
|
70451
|
-
query_options: args.queries,
|
|
70452
|
-
params: Object.fromEntries(
|
|
70453
|
-
parse_page_pattern(args.url).params.map((param) => [
|
|
70454
|
-
param.name,
|
|
70455
|
-
args.variables[param.name] ?? null
|
|
70456
|
-
])
|
|
70457
|
-
)
|
|
70458
|
-
};
|
|
70459
|
-
return target[id];
|
|
70390
|
+
if (graphql2.isListType(type)) {
|
|
70391
|
+
return getRootType(type.ofType);
|
|
70392
|
+
}
|
|
70393
|
+
return type;
|
|
70460
70394
|
}
|
|
70461
|
-
|
|
70462
|
-
|
|
70463
|
-
|
|
70464
|
-
|
|
70465
|
-
);
|
|
70466
|
-
|
|
70467
|
-
|
|
70395
|
+
function hashOriginal({ document }) {
|
|
70396
|
+
return hashDocument(document.originalString);
|
|
70397
|
+
}
|
|
70398
|
+
function hashRaw({ document }) {
|
|
70399
|
+
return hashDocument(document.artifact?.raw);
|
|
70400
|
+
}
|
|
70401
|
+
function hashDocument(str) {
|
|
70402
|
+
return crypto2.createHash("sha256").update(str || "").digest("hex");
|
|
70403
|
+
}
|
|
70404
|
+
function parentField(ancestors) {
|
|
70405
|
+
return walkParentField([...ancestors].sort(() => -1));
|
|
70406
|
+
}
|
|
70407
|
+
function walkParentField(ancestors) {
|
|
70408
|
+
let head = ancestors.shift();
|
|
70409
|
+
if (Array.isArray(head) || head.kind === "SelectionSet") {
|
|
70410
|
+
return walkParentField(ancestors);
|
|
70468
70411
|
}
|
|
70469
|
-
|
|
70470
|
-
|
|
70471
|
-
|
|
70472
|
-
|
|
70473
|
-
|
|
70474
|
-
|
|
70412
|
+
return head;
|
|
70413
|
+
}
|
|
70414
|
+
function parentTypeFromAncestors(schema, filepath, ancestors) {
|
|
70415
|
+
const parents = [...ancestors];
|
|
70416
|
+
parents.reverse();
|
|
70417
|
+
return walkAncestors(schema, filepath, parents);
|
|
70418
|
+
}
|
|
70419
|
+
function walkAncestors(schema, filepath, ancestors) {
|
|
70420
|
+
let head = ancestors.shift();
|
|
70421
|
+
if (Array.isArray(head)) {
|
|
70422
|
+
return walkAncestors(schema, filepath, ancestors);
|
|
70423
|
+
}
|
|
70424
|
+
if (!head) {
|
|
70425
|
+
throw new HoudiniError({ filepath, message: "Could not figure out type of field" });
|
|
70426
|
+
}
|
|
70427
|
+
if (head.kind === "OperationDefinition") {
|
|
70428
|
+
const operationType = {
|
|
70429
|
+
query: schema.getQueryType(),
|
|
70430
|
+
mutation: schema.getMutationType(),
|
|
70431
|
+
subscription: schema.getSubscriptionType()
|
|
70432
|
+
}[head.operation];
|
|
70433
|
+
if (!operationType) {
|
|
70434
|
+
throw new HoudiniError({ filepath, message: "Could not find operation type" });
|
|
70435
|
+
}
|
|
70436
|
+
return operationType;
|
|
70437
|
+
}
|
|
70438
|
+
if (head.kind === "FragmentDefinition") {
|
|
70439
|
+
const result = schema.getType(head.typeCondition.name.value);
|
|
70440
|
+
if (!result) {
|
|
70441
|
+
throw new HoudiniError({
|
|
70442
|
+
filepath,
|
|
70443
|
+
message: `Could not find definition for ${head.typeCondition.name.value} in the schema`
|
|
70444
|
+
});
|
|
70445
|
+
}
|
|
70446
|
+
return result;
|
|
70447
|
+
}
|
|
70448
|
+
if (head.kind === "FragmentSpread") {
|
|
70449
|
+
throw new Error("How the hell did this happen?");
|
|
70450
|
+
}
|
|
70451
|
+
const parent2 = walkAncestors(schema, filepath, ancestors);
|
|
70452
|
+
if (head.kind === "InlineFragment") {
|
|
70453
|
+
if (!head.typeCondition) {
|
|
70454
|
+
return parent2;
|
|
70455
|
+
}
|
|
70456
|
+
const wrapper = schema.getType(head.typeCondition.name.value);
|
|
70457
|
+
if (!wrapper) {
|
|
70458
|
+
throw new HoudiniError({
|
|
70459
|
+
filepath,
|
|
70460
|
+
message: "Could not find type with name: " + head.typeCondition.name.value
|
|
70461
|
+
});
|
|
70462
|
+
}
|
|
70463
|
+
return wrapper;
|
|
70464
|
+
}
|
|
70465
|
+
if (head.kind === "SelectionSet") {
|
|
70466
|
+
return parent2;
|
|
70467
|
+
}
|
|
70468
|
+
const field = parent2.getFields()[head.name.value];
|
|
70469
|
+
if (!field) {
|
|
70470
|
+
throw new HoudiniError({
|
|
70471
|
+
filepath,
|
|
70472
|
+
message: `Could not find definition of ${head.name.value} in ${parent2.toString()}`
|
|
70473
|
+
});
|
|
70474
|
+
}
|
|
70475
|
+
return getRootType(field.type);
|
|
70476
|
+
}
|
|
70477
|
+
function definitionFromAncestors(ancestors) {
|
|
70478
|
+
let parents = [...ancestors];
|
|
70479
|
+
parents.shift();
|
|
70480
|
+
let definition = parents.shift();
|
|
70481
|
+
while (Array.isArray(definition) && definition) {
|
|
70482
|
+
definition = parents.shift();
|
|
70483
|
+
}
|
|
70484
|
+
return { parents, definition };
|
|
70485
|
+
}
|
|
70486
|
+
function formatErrors(e2, afterError) {
|
|
70487
|
+
const errors = Array.isArray(e2) ? e2 : [e2];
|
|
70488
|
+
for (const error of errors) {
|
|
70489
|
+
if ("filepath" in error && error.filepath) {
|
|
70490
|
+
const relative2 = relative(process.cwd(), error.filepath);
|
|
70491
|
+
console.error(`\u274C Encountered error in ${relative2}`);
|
|
70492
|
+
if (error.message) {
|
|
70493
|
+
console.error(error.message);
|
|
70494
|
+
}
|
|
70495
|
+
} else {
|
|
70496
|
+
console.error(`\u274C ${error.message}`);
|
|
70497
|
+
if ("description" in error && error.description) {
|
|
70498
|
+
console.error(`${error.description}`);
|
|
70499
|
+
}
|
|
70500
|
+
}
|
|
70501
|
+
afterError?.(e2);
|
|
70502
|
+
}
|
|
70503
|
+
}
|
|
70504
|
+
function unwrapType(config2, type, wrappers = [], convertRuntimeScalars) {
|
|
70505
|
+
if (type.kind === "NonNullType") {
|
|
70506
|
+
return unwrapType(config2, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
70507
|
+
}
|
|
70508
|
+
if (type instanceof graphql2.GraphQLNonNull) {
|
|
70509
|
+
return unwrapType(config2, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
|
|
70510
|
+
}
|
|
70511
|
+
if (wrappers[0] !== TypeWrapper.NonNull) {
|
|
70512
|
+
wrappers.unshift(TypeWrapper.Nullable);
|
|
70513
|
+
}
|
|
70514
|
+
if (type.kind === "ListType") {
|
|
70515
|
+
return unwrapType(config2, type.type, [TypeWrapper.List, ...wrappers]);
|
|
70516
|
+
}
|
|
70517
|
+
if (type instanceof graphql2.GraphQLList) {
|
|
70518
|
+
return unwrapType(config2, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
70519
|
+
}
|
|
70520
|
+
if (convertRuntimeScalars && config2.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
70521
|
+
type = config2.schema.getType(
|
|
70522
|
+
config2.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
70523
|
+
);
|
|
70524
|
+
}
|
|
70525
|
+
const namedType = config2.schema.getType(type.name.value || type.name);
|
|
70526
|
+
if (!namedType) {
|
|
70527
|
+
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
70528
|
+
}
|
|
70529
|
+
return { type: namedType, wrappers };
|
|
70530
|
+
}
|
|
70531
|
+
function wrapType({
|
|
70532
|
+
type,
|
|
70533
|
+
wrappers
|
|
70534
|
+
}) {
|
|
70535
|
+
const head = wrappers[0];
|
|
70536
|
+
const tail = wrappers.slice(1);
|
|
70537
|
+
let kind = graphql2.Kind.NAMED_TYPE;
|
|
70538
|
+
if (head === TypeWrapper.List) {
|
|
70539
|
+
kind = graphql2.Kind.LIST_TYPE;
|
|
70540
|
+
} else if (head === TypeWrapper.NonNull) {
|
|
70541
|
+
kind = graphql2.Kind.NON_NULL_TYPE;
|
|
70542
|
+
}
|
|
70543
|
+
if (kind === "NamedType") {
|
|
70544
|
+
return {
|
|
70545
|
+
kind,
|
|
70546
|
+
name: {
|
|
70547
|
+
kind: graphql2.Kind.NAME,
|
|
70548
|
+
value: type.name
|
|
70549
|
+
}
|
|
70550
|
+
};
|
|
70551
|
+
}
|
|
70552
|
+
return {
|
|
70553
|
+
kind,
|
|
70554
|
+
type: wrapType({ type, wrappers: tail })
|
|
70555
|
+
};
|
|
70556
|
+
}
|
|
70557
|
+
var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
|
|
70558
|
+
TypeWrapper2["Nullable"] = "Nullable";
|
|
70559
|
+
TypeWrapper2["List"] = "List";
|
|
70560
|
+
TypeWrapper2["NonNull"] = "NonNull";
|
|
70561
|
+
return TypeWrapper2;
|
|
70562
|
+
})(TypeWrapper || {});
|
|
70563
|
+
|
|
70564
|
+
// src/lib/parse.ts
|
|
70565
|
+
var import_parser = __toESM(require_lib6(), 1);
|
|
70566
|
+
var import_recast = __toESM(require_main2(), 1);
|
|
70567
|
+
|
|
70568
|
+
// src/lib/deepMerge.ts
|
|
70569
|
+
var import_deepmerge = __toESM(require_cjs(), 1);
|
|
70570
|
+
function deepMerge2(filepath, ...targets) {
|
|
70571
|
+
try {
|
|
70572
|
+
if (targets.length === 1) {
|
|
70573
|
+
return targets[0];
|
|
70574
|
+
} else if (targets.length === 2) {
|
|
70575
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
70576
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
70577
|
+
});
|
|
70578
|
+
}
|
|
70579
|
+
return deepMerge2(filepath, targets[0], deepMerge2(filepath, ...targets.slice(1)));
|
|
70580
|
+
} catch (e2) {
|
|
70581
|
+
throw new HoudiniError({
|
|
70582
|
+
filepath,
|
|
70583
|
+
message: "could not merge: " + JSON.stringify(targets, null, 4),
|
|
70584
|
+
description: e2.message
|
|
70585
|
+
});
|
|
70586
|
+
}
|
|
70587
|
+
}
|
|
70588
|
+
|
|
70589
|
+
// src/lib/parse.ts
|
|
70590
|
+
function parseJS(str, config2) {
|
|
70591
|
+
const defaultConfig = {
|
|
70592
|
+
plugins: [
|
|
70593
|
+
"typescript",
|
|
70594
|
+
"importAssertions",
|
|
70595
|
+
"decorators-legacy",
|
|
70596
|
+
"explicitResourceManagement"
|
|
70597
|
+
],
|
|
70598
|
+
sourceType: "module"
|
|
70599
|
+
};
|
|
70600
|
+
return (0, import_parser.parse)(str || "", config2 ? deepMerge2("", defaultConfig, config2) : defaultConfig).program;
|
|
70601
|
+
}
|
|
70602
|
+
async function printJS(script, options) {
|
|
70603
|
+
if (options?.pretty) {
|
|
70604
|
+
return (0, import_recast.prettyPrint)(script, options);
|
|
70605
|
+
} else {
|
|
70606
|
+
return (0, import_recast.print)(script, options);
|
|
70607
|
+
}
|
|
70608
|
+
}
|
|
70609
|
+
|
|
70610
|
+
// src/lib/router/manifest.ts
|
|
70611
|
+
async function load_manifest(args) {
|
|
70612
|
+
const manifest = await walk_routes({
|
|
70613
|
+
config: args.config,
|
|
70614
|
+
url: "/",
|
|
70615
|
+
filepath: args.config.routesDir,
|
|
70616
|
+
project: {
|
|
70617
|
+
component_fields: {},
|
|
70618
|
+
pages: {},
|
|
70619
|
+
layouts: {},
|
|
70620
|
+
page_queries: {},
|
|
70621
|
+
layout_queries: {},
|
|
70622
|
+
artifacts: [],
|
|
70623
|
+
local_schema: false,
|
|
70624
|
+
local_yoga: false
|
|
70625
|
+
},
|
|
70626
|
+
queries: [],
|
|
70627
|
+
layouts: [],
|
|
70628
|
+
variables: {}
|
|
70629
|
+
});
|
|
70630
|
+
if (args.includeArtifacts) {
|
|
70631
|
+
try {
|
|
70632
|
+
for (const artifactPath of await readdir2(args.config.artifactDirectory)) {
|
|
70633
|
+
if (!artifactPath.endsWith(".js") || artifactPath === "index.js") {
|
|
70634
|
+
continue;
|
|
70635
|
+
}
|
|
70636
|
+
manifest.artifacts.push(artifactPath.substring(0, artifactPath.length - 3));
|
|
70637
|
+
}
|
|
70638
|
+
} catch {
|
|
70639
|
+
}
|
|
70640
|
+
}
|
|
70641
|
+
try {
|
|
70642
|
+
await stat(args.config.localApiDir);
|
|
70643
|
+
for (const child of await readdir2(args.config.localApiDir, { withFileTypes: true })) {
|
|
70644
|
+
const name = child.isDirectory() ? child.name : parse3(child.name).name;
|
|
70645
|
+
if (name === "+schema") {
|
|
70646
|
+
manifest.local_schema = true;
|
|
70647
|
+
} else if (name === "+yoga") {
|
|
70648
|
+
manifest.local_yoga = true;
|
|
70649
|
+
}
|
|
70650
|
+
}
|
|
70651
|
+
} catch {
|
|
70652
|
+
}
|
|
70653
|
+
return manifest;
|
|
70654
|
+
}
|
|
70655
|
+
async function walk_routes(args) {
|
|
70656
|
+
const directory_contents = await readdir2(args.filepath, {
|
|
70657
|
+
withFileTypes: true
|
|
70658
|
+
});
|
|
70659
|
+
const variables = { ...args.variables };
|
|
70660
|
+
let newLayouts = args.layouts;
|
|
70661
|
+
let newLayoutQueries = args.queries;
|
|
70662
|
+
let layout = null;
|
|
70663
|
+
let layoutQuery = null;
|
|
70664
|
+
let pageQuery = null;
|
|
70665
|
+
const [
|
|
70666
|
+
[layoutQueryPath, layoutQueryContents],
|
|
70667
|
+
[layoutViewPath, layoutViewContents],
|
|
70668
|
+
[pageQueryPath, pageQueryContents],
|
|
70669
|
+
[pageViewPath, pageViewContents]
|
|
70670
|
+
] = await Promise.all([
|
|
70671
|
+
read_layoutQuery(args.filepath),
|
|
70672
|
+
read_layoutView(args.filepath),
|
|
70673
|
+
read_pageQuery(args.filepath),
|
|
70674
|
+
read_pageView(args.filepath)
|
|
70675
|
+
]);
|
|
70676
|
+
if (layoutQueryContents) {
|
|
70677
|
+
layoutQuery = await add_query({
|
|
70678
|
+
path: layoutQueryPath,
|
|
70679
|
+
config: args.config,
|
|
70680
|
+
url: args.url,
|
|
70681
|
+
project: args.project,
|
|
70682
|
+
type: "layout",
|
|
70683
|
+
contents: layoutQueryContents,
|
|
70684
|
+
variables
|
|
70685
|
+
});
|
|
70686
|
+
newLayoutQueries = [...args.queries, layoutQuery.name];
|
|
70687
|
+
}
|
|
70688
|
+
if (layoutViewContents) {
|
|
70689
|
+
layout = await add_view({
|
|
70690
|
+
url: args.url,
|
|
70691
|
+
path: layoutViewPath,
|
|
70692
|
+
project: args.project,
|
|
70693
|
+
type: "layout",
|
|
70694
|
+
contents: layoutViewContents,
|
|
70695
|
+
layouts: args.layouts,
|
|
70696
|
+
queries: newLayoutQueries,
|
|
70697
|
+
config: args.config,
|
|
70698
|
+
variables
|
|
70699
|
+
});
|
|
70700
|
+
newLayouts = [...args.layouts, page_id(layout.url)];
|
|
70701
|
+
}
|
|
70702
|
+
if (pageQueryContents) {
|
|
70703
|
+
pageQuery = await add_query({
|
|
70704
|
+
path: pageQueryPath,
|
|
70705
|
+
config: args.config,
|
|
70706
|
+
url: args.url,
|
|
70707
|
+
project: args.project,
|
|
70708
|
+
type: "page",
|
|
70709
|
+
contents: pageQueryContents,
|
|
70710
|
+
variables
|
|
70711
|
+
});
|
|
70712
|
+
}
|
|
70713
|
+
if (pageViewContents) {
|
|
70714
|
+
await add_view({
|
|
70715
|
+
path: pageViewPath,
|
|
70716
|
+
url: args.url.substring(0, args.url.length - 1) || "/",
|
|
70717
|
+
project: args.project,
|
|
70718
|
+
type: "page",
|
|
70719
|
+
contents: pageViewContents,
|
|
70720
|
+
layouts: newLayouts,
|
|
70721
|
+
queries: pageQuery ? [...newLayoutQueries, pageQuery.name] : newLayoutQueries,
|
|
70722
|
+
config: args.config,
|
|
70723
|
+
variables
|
|
70724
|
+
});
|
|
70725
|
+
}
|
|
70726
|
+
await Promise.all(
|
|
70727
|
+
directory_contents.map((dir) => {
|
|
70728
|
+
if (!dir.isDirectory()) {
|
|
70729
|
+
return;
|
|
70730
|
+
}
|
|
70731
|
+
return walk_routes({
|
|
70732
|
+
...args,
|
|
70733
|
+
filepath: join2(args.filepath, dir.name),
|
|
70734
|
+
url: `${args.url}${dir.name}/`,
|
|
70735
|
+
queries: newLayoutQueries,
|
|
70736
|
+
layouts: newLayouts,
|
|
70737
|
+
variables
|
|
70738
|
+
});
|
|
70739
|
+
})
|
|
70740
|
+
);
|
|
70741
|
+
return args.project;
|
|
70742
|
+
}
|
|
70743
|
+
async function add_view(args) {
|
|
70744
|
+
const target = args.type === "page" ? args.project.pages : args.project.layouts;
|
|
70745
|
+
const queries = await extractQueries(args.contents);
|
|
70746
|
+
const missing_queries = queries.filter((query2) => !args.queries.includes(query2));
|
|
70747
|
+
if (missing_queries.length > 0) {
|
|
70748
|
+
throw {
|
|
70749
|
+
message: `Unknown queries in ${args.path}: ${missing_queries.join(", ")}`
|
|
70750
|
+
};
|
|
70751
|
+
}
|
|
70752
|
+
const id = page_id(args.url);
|
|
70753
|
+
target[id] = {
|
|
70754
|
+
id,
|
|
70755
|
+
queries,
|
|
70756
|
+
url: args.url,
|
|
70757
|
+
layouts: args.layouts,
|
|
70758
|
+
path: relative(args.config.projectRoot, args.path),
|
|
70759
|
+
query_options: args.queries,
|
|
70760
|
+
params: Object.fromEntries(
|
|
70761
|
+
parse_page_pattern(args.url).params.map((param) => [
|
|
70762
|
+
param.name,
|
|
70763
|
+
args.variables[param.name] ?? null
|
|
70764
|
+
])
|
|
70765
|
+
)
|
|
70766
|
+
};
|
|
70767
|
+
return target[id];
|
|
70768
|
+
}
|
|
70769
|
+
async function add_query(args) {
|
|
70770
|
+
const parsed = graphql3.parse(args.contents);
|
|
70771
|
+
const query2 = parsed.definitions.find(
|
|
70772
|
+
(def) => def.kind === "OperationDefinition" && def.operation === "query"
|
|
70773
|
+
);
|
|
70774
|
+
if (!query2?.name) {
|
|
70775
|
+
throw new Error("No query found");
|
|
70776
|
+
}
|
|
70777
|
+
let loading = false;
|
|
70778
|
+
await graphql3.visit(parsed, {
|
|
70779
|
+
Directive(node) {
|
|
70780
|
+
if (node.name.value === args.config.loadingDirective) {
|
|
70781
|
+
loading = true;
|
|
70782
|
+
}
|
|
70475
70783
|
}
|
|
70476
70784
|
});
|
|
70477
70785
|
const queryVariables = Object.fromEntries(
|
|
@@ -70486,7 +70794,7 @@ async function add_query(args) {
|
|
|
70486
70794
|
Object.assign(args.variables, queryVariables);
|
|
70487
70795
|
const target = args.type === "page" ? args.project.page_queries : args.project.layout_queries;
|
|
70488
70796
|
target[page_id(args.url)] = {
|
|
70489
|
-
path:
|
|
70797
|
+
path: relative(args.config.routesDir, args.path),
|
|
70490
70798
|
name: query2.name.value,
|
|
70491
70799
|
url: args.url,
|
|
70492
70800
|
loading,
|
|
@@ -70561,7 +70869,7 @@ async function extractQueries(source) {
|
|
|
70561
70869
|
}
|
|
70562
70870
|
|
|
70563
70871
|
// src/lib/router/server.ts
|
|
70564
|
-
import * as
|
|
70872
|
+
import * as graphql4 from "graphql";
|
|
70565
70873
|
import path3 from "node:path";
|
|
70566
70874
|
|
|
70567
70875
|
// src/runtime/lib/flatten.ts
|
|
@@ -72910,14 +73218,14 @@ function isSecondaryBuild() {
|
|
|
72910
73218
|
async function buildLocalSchema(config2) {
|
|
72911
73219
|
const { build } = await import("vite");
|
|
72912
73220
|
const schema = path3.join(config2.localApiDir, "+schema");
|
|
72913
|
-
const outDir =
|
|
73221
|
+
const outDir = temp_dir(config2, "schema");
|
|
72914
73222
|
process.env.HOUDINI_SECONDARY_BUILD = "true";
|
|
72915
73223
|
try {
|
|
72916
|
-
await
|
|
73224
|
+
await remove(path3.join(outDir, "assets", "schema.js"));
|
|
72917
73225
|
} catch {
|
|
72918
73226
|
}
|
|
72919
73227
|
try {
|
|
72920
|
-
await
|
|
73228
|
+
await mkdir(outDir);
|
|
72921
73229
|
} catch {
|
|
72922
73230
|
}
|
|
72923
73231
|
await build({
|
|
@@ -72949,14 +73257,14 @@ async function loadLocalSchema(config2) {
|
|
|
72949
73257
|
}
|
|
72950
73258
|
try {
|
|
72951
73259
|
const { default: schema } = await import(path3.join(
|
|
72952
|
-
|
|
73260
|
+
temp_dir(config2, "schema"),
|
|
72953
73261
|
`schema.js?${Date.now().valueOf()}}`
|
|
72954
73262
|
));
|
|
72955
73263
|
return schema;
|
|
72956
73264
|
} catch (e2) {
|
|
72957
73265
|
const message = "message" in e2 ? e2.message : e2;
|
|
72958
73266
|
console.error("\u26A0\uFE0F Failed to load local schema: ", message);
|
|
72959
|
-
return new
|
|
73267
|
+
return new graphql4.GraphQLSchema({});
|
|
72960
73268
|
}
|
|
72961
73269
|
}
|
|
72962
73270
|
|
|
@@ -73031,7 +73339,7 @@ var Config = class {
|
|
|
73031
73339
|
persistedQueriesPath
|
|
73032
73340
|
} = this.configFile;
|
|
73033
73341
|
if (typeof schema === "string") {
|
|
73034
|
-
this.schema =
|
|
73342
|
+
this.schema = graphql5.buildSchema(schema);
|
|
73035
73343
|
} else {
|
|
73036
73344
|
this.schema = schema;
|
|
73037
73345
|
}
|
|
@@ -73179,7 +73487,7 @@ var Config = class {
|
|
|
73179
73487
|
set newSchema(value) {
|
|
73180
73488
|
this.schemaString = value;
|
|
73181
73489
|
if (value) {
|
|
73182
|
-
this.#newSchemaInstance =
|
|
73490
|
+
this.#newSchemaInstance = graphql5.buildSchema(value);
|
|
73183
73491
|
} else {
|
|
73184
73492
|
this.#newSchemaInstance = null;
|
|
73185
73493
|
}
|
|
@@ -73269,21 +73577,21 @@ var Config = class {
|
|
|
73269
73577
|
}
|
|
73270
73578
|
documentName(document) {
|
|
73271
73579
|
const operation = document.definitions.find(
|
|
73272
|
-
({ kind }) => kind ===
|
|
73580
|
+
({ kind }) => kind === graphql5.Kind.OPERATION_DEFINITION
|
|
73273
73581
|
);
|
|
73274
73582
|
if (operation) {
|
|
73275
73583
|
if (!operation.name) {
|
|
73276
|
-
throw new Error("encountered operation with no name: " +
|
|
73584
|
+
throw new Error("encountered operation with no name: " + graphql5.print(document));
|
|
73277
73585
|
}
|
|
73278
73586
|
return operation.name.value;
|
|
73279
73587
|
}
|
|
73280
73588
|
const fragmentDefinitions = document.definitions.filter(
|
|
73281
|
-
({ kind }) => kind ===
|
|
73589
|
+
({ kind }) => kind === graphql5.Kind.FRAGMENT_DEFINITION
|
|
73282
73590
|
);
|
|
73283
73591
|
if (fragmentDefinitions.length) {
|
|
73284
73592
|
return fragmentDefinitions[0].name.value;
|
|
73285
73593
|
}
|
|
73286
|
-
throw new Error("Could not generate artifact name for document: " +
|
|
73594
|
+
throw new Error("Could not generate artifact name for document: " + graphql5.print(document));
|
|
73287
73595
|
}
|
|
73288
73596
|
isSelectionScalar(type) {
|
|
73289
73597
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(this.scalars || {})).includes(type);
|
|
@@ -73493,10 +73801,10 @@ var Config = class {
|
|
|
73493
73801
|
localDocumentData(document) {
|
|
73494
73802
|
let paginated = false;
|
|
73495
73803
|
let componentFields3 = [];
|
|
73496
|
-
const typeInfo = new
|
|
73497
|
-
|
|
73804
|
+
const typeInfo = new graphql5.TypeInfo(this.schema);
|
|
73805
|
+
graphql5.visit(
|
|
73498
73806
|
document,
|
|
73499
|
-
|
|
73807
|
+
graphql5.visitWithTypeInfo(typeInfo, {
|
|
73500
73808
|
Directive: (node) => {
|
|
73501
73809
|
if ([this.paginateDirective].includes(node.name.value)) {
|
|
73502
73810
|
paginated = true;
|
|
@@ -73767,332 +74075,105 @@ async function flattenPluginList(root, list, name, pluginFile) {
|
|
|
73767
74075
|
}
|
|
73768
74076
|
}
|
|
73769
74077
|
}
|
|
73770
|
-
return result;
|
|
73771
|
-
}
|
|
73772
|
-
async function readConfigFile(configPath = DEFAULT_CONFIG_PATH) {
|
|
73773
|
-
let importPath2 = importPath(configPath);
|
|
73774
|
-
let imported;
|
|
73775
|
-
try {
|
|
73776
|
-
imported = await import(importPath2);
|
|
73777
|
-
} catch (e2) {
|
|
73778
|
-
throw new Error(`Could not load config file at file://${configPath}.
|
|
73779
|
-
${e2.message}`);
|
|
73780
|
-
}
|
|
73781
|
-
const config2 = imported.default || imported;
|
|
73782
|
-
return config2;
|
|
73783
|
-
}
|
|
73784
|
-
var orderedPlugins = (plugins) => {
|
|
73785
|
-
const ordered = plugins.filter(
|
|
73786
|
-
(plugin2) => plugin2.order === "before" || plugin2.order === void 0
|
|
73787
|
-
);
|
|
73788
|
-
ordered.push(
|
|
73789
|
-
...plugins.filter((plugin2) => plugin2.order === "core"),
|
|
73790
|
-
...plugins.filter((plugin2) => plugin2.order === "after")
|
|
73791
|
-
);
|
|
73792
|
-
return ordered;
|
|
73793
|
-
};
|
|
73794
|
-
async function pluginPath(plugin_name, config_path) {
|
|
73795
|
-
try {
|
|
73796
|
-
if (process.versions.pnp) {
|
|
73797
|
-
const { findPnpApi } = __require("node:module");
|
|
73798
|
-
const pnp = findPnpApi(config_path);
|
|
73799
|
-
return pnp.resolveRequest(plugin_name, config_path, { conditions: /* @__PURE__ */ new Set(["import"]) });
|
|
73800
|
-
}
|
|
73801
|
-
const pluginDirectory = findModule(plugin_name, config_path);
|
|
73802
|
-
const packageJsonSrc = await readFile(join2(pluginDirectory, "package.json"));
|
|
73803
|
-
if (!packageJsonSrc) {
|
|
73804
|
-
throw new Error("skip");
|
|
73805
|
-
}
|
|
73806
|
-
const packageJSON = JSON.parse(packageJsonSrc);
|
|
73807
|
-
if (!packageJSON.exports?.["."]?.import) {
|
|
73808
|
-
throw new Error("");
|
|
73809
|
-
}
|
|
73810
|
-
return join2(pluginDirectory, packageJSON.exports["."].import);
|
|
73811
|
-
} catch {
|
|
73812
|
-
const err = new Error(
|
|
73813
|
-
`Could not find plugin: ${plugin_name}. Are you sure its installed? If so, please open a ticket on GitHub.`
|
|
73814
|
-
);
|
|
73815
|
-
throw err;
|
|
73816
|
-
}
|
|
73817
|
-
}
|
|
73818
|
-
function findModule(pkg = "houdini", currentLocation) {
|
|
73819
|
-
const pathEndingBy = ["node_modules", pkg];
|
|
73820
|
-
let locationFound = join2(currentLocation, ...pathEndingBy);
|
|
73821
|
-
let previousLocation = "";
|
|
73822
|
-
const backFolder = [];
|
|
73823
|
-
while (previousLocation !== locationFound && !existsSync(locationFound)) {
|
|
73824
|
-
previousLocation = locationFound;
|
|
73825
|
-
backFolder.push("../");
|
|
73826
|
-
locationFound = join2(currentLocation, ...backFolder, ...pathEndingBy);
|
|
73827
|
-
}
|
|
73828
|
-
if (previousLocation === locationFound) {
|
|
73829
|
-
throw new Error("Could not find any node_modules/houdini folder");
|
|
73830
|
-
}
|
|
73831
|
-
return locationFound;
|
|
73832
|
-
}
|
|
73833
|
-
async function loadSchemaFile(schemaPath) {
|
|
73834
|
-
if (isAbsolute(schemaPath)) {
|
|
73835
|
-
const relPath = relative(process.cwd(), schemaPath);
|
|
73836
|
-
const error = new Error(
|
|
73837
|
-
`Invalid config value: 'schemaPath' must now be passed as a relative directory. Please change its value to "./${relPath}".`
|
|
73838
|
-
);
|
|
73839
|
-
error.stack = "";
|
|
73840
|
-
throw error;
|
|
73841
|
-
}
|
|
73842
|
-
if (glob2.hasMagic(schemaPath)) {
|
|
73843
|
-
const sourceFiles = await glob2(schemaPath);
|
|
73844
|
-
return mergeSchemas({
|
|
73845
|
-
typeDefs: await Promise.all(
|
|
73846
|
-
sourceFiles.map(async (filepath) => await readFile(filepath))
|
|
73847
|
-
)
|
|
73848
|
-
});
|
|
73849
|
-
}
|
|
73850
|
-
try {
|
|
73851
|
-
await stat(schemaPath);
|
|
73852
|
-
} catch {
|
|
73853
|
-
throw new HoudiniError({
|
|
73854
|
-
message: `Schema file does not exist! Create it using houdini pull-schema`
|
|
73855
|
-
});
|
|
73856
|
-
}
|
|
73857
|
-
const contents = await readFile(schemaPath);
|
|
73858
|
-
if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql") || schemaPath.endsWith("graphqls")) {
|
|
73859
|
-
return graphql4.buildSchema(contents);
|
|
73860
|
-
}
|
|
73861
|
-
const jsonContents = JSON.parse(contents);
|
|
73862
|
-
if (jsonContents.data) {
|
|
73863
|
-
return graphql4.buildClientSchema(jsonContents.data);
|
|
73864
|
-
}
|
|
73865
|
-
return graphql4.buildClientSchema(jsonContents);
|
|
73866
|
-
}
|
|
73867
|
-
var emptySchema = graphql4.buildSchema("type Query { hello: String }");
|
|
73868
|
-
var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
|
|
73869
|
-
|
|
73870
|
-
// src/lib/graphql.ts
|
|
73871
|
-
import * as graphql5 from "graphql";
|
|
73872
|
-
import crypto2 from "node:crypto";
|
|
73873
|
-
function getRootType(type) {
|
|
73874
|
-
if (graphql5.isNonNullType(type)) {
|
|
73875
|
-
return getRootType(type.ofType);
|
|
73876
|
-
}
|
|
73877
|
-
if (graphql5.isListType(type)) {
|
|
73878
|
-
return getRootType(type.ofType);
|
|
73879
|
-
}
|
|
73880
|
-
return type;
|
|
73881
|
-
}
|
|
73882
|
-
function hashOriginal({ document }) {
|
|
73883
|
-
return hashDocument(document.originalString);
|
|
73884
|
-
}
|
|
73885
|
-
function hashRaw({ document }) {
|
|
73886
|
-
return hashDocument(document.artifact?.raw);
|
|
73887
|
-
}
|
|
73888
|
-
function hashDocument(str) {
|
|
73889
|
-
return crypto2.createHash("sha256").update(str || "").digest("hex");
|
|
73890
|
-
}
|
|
73891
|
-
function parentField(ancestors) {
|
|
73892
|
-
return walkParentField([...ancestors].sort(() => -1));
|
|
73893
|
-
}
|
|
73894
|
-
function walkParentField(ancestors) {
|
|
73895
|
-
let head = ancestors.shift();
|
|
73896
|
-
if (Array.isArray(head) || head.kind === "SelectionSet") {
|
|
73897
|
-
return walkParentField(ancestors);
|
|
73898
|
-
}
|
|
73899
|
-
return head;
|
|
73900
|
-
}
|
|
73901
|
-
function parentTypeFromAncestors(schema, filepath, ancestors) {
|
|
73902
|
-
const parents = [...ancestors];
|
|
73903
|
-
parents.reverse();
|
|
73904
|
-
return walkAncestors(schema, filepath, parents);
|
|
73905
|
-
}
|
|
73906
|
-
function walkAncestors(schema, filepath, ancestors) {
|
|
73907
|
-
let head = ancestors.shift();
|
|
73908
|
-
if (Array.isArray(head)) {
|
|
73909
|
-
return walkAncestors(schema, filepath, ancestors);
|
|
73910
|
-
}
|
|
73911
|
-
if (!head) {
|
|
73912
|
-
throw new HoudiniError({ filepath, message: "Could not figure out type of field" });
|
|
73913
|
-
}
|
|
73914
|
-
if (head.kind === "OperationDefinition") {
|
|
73915
|
-
const operationType = {
|
|
73916
|
-
query: schema.getQueryType(),
|
|
73917
|
-
mutation: schema.getMutationType(),
|
|
73918
|
-
subscription: schema.getSubscriptionType()
|
|
73919
|
-
}[head.operation];
|
|
73920
|
-
if (!operationType) {
|
|
73921
|
-
throw new HoudiniError({ filepath, message: "Could not find operation type" });
|
|
73922
|
-
}
|
|
73923
|
-
return operationType;
|
|
73924
|
-
}
|
|
73925
|
-
if (head.kind === "FragmentDefinition") {
|
|
73926
|
-
const result = schema.getType(head.typeCondition.name.value);
|
|
73927
|
-
if (!result) {
|
|
73928
|
-
throw new HoudiniError({
|
|
73929
|
-
filepath,
|
|
73930
|
-
message: `Could not find definition for ${head.typeCondition.name.value} in the schema`
|
|
73931
|
-
});
|
|
73932
|
-
}
|
|
73933
|
-
return result;
|
|
73934
|
-
}
|
|
73935
|
-
if (head.kind === "FragmentSpread") {
|
|
73936
|
-
throw new Error("How the hell did this happen?");
|
|
73937
|
-
}
|
|
73938
|
-
const parent2 = walkAncestors(schema, filepath, ancestors);
|
|
73939
|
-
if (head.kind === "InlineFragment") {
|
|
73940
|
-
if (!head.typeCondition) {
|
|
73941
|
-
return parent2;
|
|
73942
|
-
}
|
|
73943
|
-
const wrapper = schema.getType(head.typeCondition.name.value);
|
|
73944
|
-
if (!wrapper) {
|
|
73945
|
-
throw new HoudiniError({
|
|
73946
|
-
filepath,
|
|
73947
|
-
message: "Could not find type with name: " + head.typeCondition.name.value
|
|
73948
|
-
});
|
|
73949
|
-
}
|
|
73950
|
-
return wrapper;
|
|
73951
|
-
}
|
|
73952
|
-
if (head.kind === "SelectionSet") {
|
|
73953
|
-
return parent2;
|
|
73954
|
-
}
|
|
73955
|
-
const field = parent2.getFields()[head.name.value];
|
|
73956
|
-
if (!field) {
|
|
73957
|
-
throw new HoudiniError({
|
|
73958
|
-
filepath,
|
|
73959
|
-
message: `Could not find definition of ${head.name.value} in ${parent2.toString()}`
|
|
73960
|
-
});
|
|
73961
|
-
}
|
|
73962
|
-
return getRootType(field.type);
|
|
73963
|
-
}
|
|
73964
|
-
function definitionFromAncestors(ancestors) {
|
|
73965
|
-
let parents = [...ancestors];
|
|
73966
|
-
parents.shift();
|
|
73967
|
-
let definition = parents.shift();
|
|
73968
|
-
while (Array.isArray(definition) && definition) {
|
|
73969
|
-
definition = parents.shift();
|
|
73970
|
-
}
|
|
73971
|
-
return { parents, definition };
|
|
73972
|
-
}
|
|
73973
|
-
function formatErrors(e2, afterError) {
|
|
73974
|
-
const errors = Array.isArray(e2) ? e2 : [e2];
|
|
73975
|
-
for (const error of errors) {
|
|
73976
|
-
if ("filepath" in error && error.filepath) {
|
|
73977
|
-
const relative2 = relative(process.cwd(), error.filepath);
|
|
73978
|
-
console.error(`\u274C Encountered error in ${relative2}`);
|
|
73979
|
-
if (error.message) {
|
|
73980
|
-
console.error(error.message);
|
|
73981
|
-
}
|
|
73982
|
-
} else {
|
|
73983
|
-
console.error(`\u274C ${error.message}`);
|
|
73984
|
-
if ("description" in error && error.description) {
|
|
73985
|
-
console.error(`${error.description}`);
|
|
73986
|
-
}
|
|
73987
|
-
}
|
|
73988
|
-
afterError?.(e2);
|
|
73989
|
-
}
|
|
73990
|
-
}
|
|
73991
|
-
function unwrapType(config2, type, wrappers = [], convertRuntimeScalars) {
|
|
73992
|
-
if (type.kind === "NonNullType") {
|
|
73993
|
-
return unwrapType(config2, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
73994
|
-
}
|
|
73995
|
-
if (type instanceof graphql5.GraphQLNonNull) {
|
|
73996
|
-
return unwrapType(config2, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
|
|
73997
|
-
}
|
|
73998
|
-
if (wrappers[0] !== TypeWrapper.NonNull) {
|
|
73999
|
-
wrappers.unshift(TypeWrapper.Nullable);
|
|
74000
|
-
}
|
|
74001
|
-
if (type.kind === "ListType") {
|
|
74002
|
-
return unwrapType(config2, type.type, [TypeWrapper.List, ...wrappers]);
|
|
74003
|
-
}
|
|
74004
|
-
if (type instanceof graphql5.GraphQLList) {
|
|
74005
|
-
return unwrapType(config2, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
74078
|
+
return result;
|
|
74079
|
+
}
|
|
74080
|
+
async function readConfigFile(configPath = DEFAULT_CONFIG_PATH) {
|
|
74081
|
+
let importPath2 = importPath(configPath);
|
|
74082
|
+
let imported;
|
|
74083
|
+
try {
|
|
74084
|
+
imported = await import(importPath2);
|
|
74085
|
+
} catch (e2) {
|
|
74086
|
+
throw new Error(`Could not load config file at file://${configPath}.
|
|
74087
|
+
${e2.message}`);
|
|
74006
74088
|
}
|
|
74007
|
-
|
|
74008
|
-
|
|
74009
|
-
|
|
74089
|
+
const config2 = imported.default || imported;
|
|
74090
|
+
return config2;
|
|
74091
|
+
}
|
|
74092
|
+
var orderedPlugins = (plugins) => {
|
|
74093
|
+
const ordered = plugins.filter(
|
|
74094
|
+
(plugin2) => plugin2.order === "before" || plugin2.order === void 0
|
|
74095
|
+
);
|
|
74096
|
+
ordered.push(
|
|
74097
|
+
...plugins.filter((plugin2) => plugin2.order === "core"),
|
|
74098
|
+
...plugins.filter((plugin2) => plugin2.order === "after")
|
|
74099
|
+
);
|
|
74100
|
+
return ordered;
|
|
74101
|
+
};
|
|
74102
|
+
async function pluginPath(plugin_name, config_path) {
|
|
74103
|
+
try {
|
|
74104
|
+
if (process.versions.pnp) {
|
|
74105
|
+
const { findPnpApi } = __require("node:module");
|
|
74106
|
+
const pnp = findPnpApi(config_path);
|
|
74107
|
+
return pnp.resolveRequest(plugin_name, config_path, { conditions: /* @__PURE__ */ new Set(["import"]) });
|
|
74108
|
+
}
|
|
74109
|
+
const pluginDirectory = findModule(plugin_name, config_path);
|
|
74110
|
+
const packageJsonSrc = await readFile(join2(pluginDirectory, "package.json"));
|
|
74111
|
+
if (!packageJsonSrc) {
|
|
74112
|
+
throw new Error("skip");
|
|
74113
|
+
}
|
|
74114
|
+
const packageJSON = JSON.parse(packageJsonSrc);
|
|
74115
|
+
if (!packageJSON.exports?.["."]?.import) {
|
|
74116
|
+
throw new Error("");
|
|
74117
|
+
}
|
|
74118
|
+
return join2(pluginDirectory, packageJSON.exports["."].import);
|
|
74119
|
+
} catch {
|
|
74120
|
+
const err = new Error(
|
|
74121
|
+
`Could not find plugin: ${plugin_name}. Are you sure its installed? If so, please open a ticket on GitHub.`
|
|
74010
74122
|
);
|
|
74123
|
+
throw err;
|
|
74011
74124
|
}
|
|
74012
|
-
const namedType = config2.schema.getType(type.name.value || type.name);
|
|
74013
|
-
if (!namedType) {
|
|
74014
|
-
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
74015
|
-
}
|
|
74016
|
-
return { type: namedType, wrappers };
|
|
74017
74125
|
}
|
|
74018
|
-
function
|
|
74019
|
-
|
|
74020
|
-
|
|
74021
|
-
|
|
74022
|
-
const
|
|
74023
|
-
|
|
74024
|
-
|
|
74025
|
-
|
|
74026
|
-
|
|
74027
|
-
} else if (head === TypeWrapper.NonNull) {
|
|
74028
|
-
kind = graphql5.Kind.NON_NULL_TYPE;
|
|
74126
|
+
function findModule(pkg = "houdini", currentLocation) {
|
|
74127
|
+
const pathEndingBy = ["node_modules", pkg];
|
|
74128
|
+
let locationFound = join2(currentLocation, ...pathEndingBy);
|
|
74129
|
+
let previousLocation = "";
|
|
74130
|
+
const backFolder = [];
|
|
74131
|
+
while (previousLocation !== locationFound && !existsSync(locationFound)) {
|
|
74132
|
+
previousLocation = locationFound;
|
|
74133
|
+
backFolder.push("../");
|
|
74134
|
+
locationFound = join2(currentLocation, ...backFolder, ...pathEndingBy);
|
|
74029
74135
|
}
|
|
74030
|
-
if (
|
|
74031
|
-
|
|
74032
|
-
kind,
|
|
74033
|
-
name: {
|
|
74034
|
-
kind: graphql5.Kind.NAME,
|
|
74035
|
-
value: type.name
|
|
74036
|
-
}
|
|
74037
|
-
};
|
|
74136
|
+
if (previousLocation === locationFound) {
|
|
74137
|
+
throw new Error("Could not find any node_modules/houdini folder");
|
|
74038
74138
|
}
|
|
74039
|
-
return
|
|
74040
|
-
kind,
|
|
74041
|
-
type: wrapType({ type, wrappers: tail })
|
|
74042
|
-
};
|
|
74139
|
+
return locationFound;
|
|
74043
74140
|
}
|
|
74044
|
-
|
|
74045
|
-
|
|
74046
|
-
|
|
74047
|
-
|
|
74048
|
-
|
|
74049
|
-
|
|
74050
|
-
|
|
74051
|
-
|
|
74052
|
-
|
|
74053
|
-
|
|
74054
|
-
|
|
74055
|
-
|
|
74056
|
-
|
|
74057
|
-
|
|
74141
|
+
async function loadSchemaFile(schemaPath) {
|
|
74142
|
+
if (isAbsolute(schemaPath)) {
|
|
74143
|
+
const relPath = relative(process.cwd(), schemaPath);
|
|
74144
|
+
const error = new Error(
|
|
74145
|
+
`Invalid config value: 'schemaPath' must now be passed as a relative directory. Please change its value to "./${relPath}".`
|
|
74146
|
+
);
|
|
74147
|
+
error.stack = "";
|
|
74148
|
+
throw error;
|
|
74149
|
+
}
|
|
74150
|
+
if (glob2.hasMagic(schemaPath)) {
|
|
74151
|
+
const sourceFiles = await glob2(schemaPath);
|
|
74152
|
+
return mergeSchemas({
|
|
74153
|
+
typeDefs: await Promise.all(
|
|
74154
|
+
sourceFiles.map(async (filepath) => await readFile(filepath))
|
|
74155
|
+
)
|
|
74156
|
+
});
|
|
74157
|
+
}
|
|
74058
74158
|
try {
|
|
74059
|
-
|
|
74060
|
-
|
|
74061
|
-
} else if (targets.length === 2) {
|
|
74062
|
-
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
74063
|
-
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
74064
|
-
});
|
|
74065
|
-
}
|
|
74066
|
-
return deepMerge2(filepath, targets[0], deepMerge2(filepath, ...targets.slice(1)));
|
|
74067
|
-
} catch (e2) {
|
|
74159
|
+
await stat(schemaPath);
|
|
74160
|
+
} catch {
|
|
74068
74161
|
throw new HoudiniError({
|
|
74069
|
-
|
|
74070
|
-
message: "could not merge: " + JSON.stringify(targets, null, 4),
|
|
74071
|
-
description: e2.message
|
|
74162
|
+
message: `Schema file does not exist! Create it using houdini pull-schema`
|
|
74072
74163
|
});
|
|
74073
74164
|
}
|
|
74074
|
-
|
|
74075
|
-
|
|
74076
|
-
|
|
74077
|
-
function parseJS(str, config2) {
|
|
74078
|
-
const defaultConfig = {
|
|
74079
|
-
plugins: [
|
|
74080
|
-
"typescript",
|
|
74081
|
-
"importAssertions",
|
|
74082
|
-
"decorators-legacy",
|
|
74083
|
-
"explicitResourceManagement"
|
|
74084
|
-
],
|
|
74085
|
-
sourceType: "module"
|
|
74086
|
-
};
|
|
74087
|
-
return (0, import_parser.parse)(str || "", config2 ? deepMerge2("", defaultConfig, config2) : defaultConfig).program;
|
|
74088
|
-
}
|
|
74089
|
-
async function printJS(script, options) {
|
|
74090
|
-
if (options?.pretty) {
|
|
74091
|
-
return (0, import_recast.prettyPrint)(script, options);
|
|
74092
|
-
} else {
|
|
74093
|
-
return (0, import_recast.print)(script, options);
|
|
74165
|
+
const contents = await readFile(schemaPath);
|
|
74166
|
+
if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql") || schemaPath.endsWith("graphqls")) {
|
|
74167
|
+
return graphql5.buildSchema(contents);
|
|
74094
74168
|
}
|
|
74169
|
+
const jsonContents = JSON.parse(contents);
|
|
74170
|
+
if (jsonContents.data) {
|
|
74171
|
+
return graphql5.buildClientSchema(jsonContents.data);
|
|
74172
|
+
}
|
|
74173
|
+
return graphql5.buildClientSchema(jsonContents);
|
|
74095
74174
|
}
|
|
74175
|
+
var emptySchema = graphql5.buildSchema("type Query { hello: String }");
|
|
74176
|
+
var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
|
|
74096
74177
|
|
|
74097
74178
|
// src/lib/imports.ts
|
|
74098
74179
|
var recast = __toESM(require_main2(), 1);
|
|
@@ -74153,85 +74234,6 @@ async function cleanupFiles(pathFolder, listOfObj) {
|
|
|
74153
74234
|
return allFilesNotInList;
|
|
74154
74235
|
}
|
|
74155
74236
|
|
|
74156
|
-
// src/runtime/router/match.ts
|
|
74157
|
-
var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
74158
|
-
function parse_page_pattern(id) {
|
|
74159
|
-
const params = [];
|
|
74160
|
-
const pattern = id === "/" ? /^\/$/ : new RegExp(
|
|
74161
|
-
`^${get_route_segments(id).map((segment) => {
|
|
74162
|
-
const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
|
74163
|
-
if (rest_match) {
|
|
74164
|
-
params.push({
|
|
74165
|
-
name: rest_match[1],
|
|
74166
|
-
matcher: rest_match[2],
|
|
74167
|
-
optional: false,
|
|
74168
|
-
rest: true,
|
|
74169
|
-
chained: true
|
|
74170
|
-
});
|
|
74171
|
-
return "(?:/(.*))?";
|
|
74172
|
-
}
|
|
74173
|
-
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
74174
|
-
if (optional_match) {
|
|
74175
|
-
params.push({
|
|
74176
|
-
name: optional_match[1],
|
|
74177
|
-
matcher: optional_match[2],
|
|
74178
|
-
optional: true,
|
|
74179
|
-
rest: false,
|
|
74180
|
-
chained: true
|
|
74181
|
-
});
|
|
74182
|
-
return "(?:/([^/]+))?";
|
|
74183
|
-
}
|
|
74184
|
-
if (!segment) {
|
|
74185
|
-
return;
|
|
74186
|
-
}
|
|
74187
|
-
const parts = segment.split(/\[(.+?)\](?!\])/);
|
|
74188
|
-
const result = parts.map((content, i2) => {
|
|
74189
|
-
if (i2 % 2) {
|
|
74190
|
-
if (content.startsWith("x+")) {
|
|
74191
|
-
return escape3(
|
|
74192
|
-
String.fromCharCode(parseInt(content.slice(2), 16))
|
|
74193
|
-
);
|
|
74194
|
-
}
|
|
74195
|
-
if (content.startsWith("u+")) {
|
|
74196
|
-
return escape3(
|
|
74197
|
-
String.fromCharCode(
|
|
74198
|
-
...content.slice(2).split("-").map((code) => parseInt(code, 16))
|
|
74199
|
-
)
|
|
74200
|
-
);
|
|
74201
|
-
}
|
|
74202
|
-
const match2 = param_pattern.exec(content);
|
|
74203
|
-
if (!match2) {
|
|
74204
|
-
throw new Error(
|
|
74205
|
-
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
74206
|
-
);
|
|
74207
|
-
}
|
|
74208
|
-
const [, is_optional, is_rest, name, matcher] = match2;
|
|
74209
|
-
params.push({
|
|
74210
|
-
name,
|
|
74211
|
-
matcher,
|
|
74212
|
-
optional: !!is_optional,
|
|
74213
|
-
rest: !!is_rest,
|
|
74214
|
-
chained: is_rest ? i2 === 1 && parts[0] === "" : false
|
|
74215
|
-
});
|
|
74216
|
-
return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
|
|
74217
|
-
}
|
|
74218
|
-
return escape3(content);
|
|
74219
|
-
}).join("");
|
|
74220
|
-
return "/" + result;
|
|
74221
|
-
}).join("")}/?$`
|
|
74222
|
-
);
|
|
74223
|
-
return { pattern, params, page_id: id };
|
|
74224
|
-
}
|
|
74225
|
-
function affects_path(segment) {
|
|
74226
|
-
return !/^\([^)]+\)$/.test(segment);
|
|
74227
|
-
}
|
|
74228
|
-
function get_route_segments(route) {
|
|
74229
|
-
return route.slice(1).split("/").filter(affects_path);
|
|
74230
|
-
}
|
|
74231
|
-
function escape3(str) {
|
|
74232
|
-
return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
|
|
74233
|
-
}
|
|
74234
|
-
|
|
74235
74237
|
// src/lib/typescript.ts
|
|
74236
74238
|
var recast2 = __toESM(require_main2(), 1);
|
|
74237
74239
|
import * as graphql6 from "graphql";
|
|
@@ -74301,18 +74303,18 @@ function scalarPropertyValue(config2, filepath, missingScalars, target, body, fi
|
|
|
74301
74303
|
return AST3.tsNeverKeyword();
|
|
74302
74304
|
}
|
|
74303
74305
|
const component = config2.componentFields[field.parent][field.field];
|
|
74304
|
-
const sourcePathRelative =
|
|
74305
|
-
|
|
74306
|
+
const sourcePathRelative = relative(
|
|
74307
|
+
join2(config2.projectRoot, "src"),
|
|
74306
74308
|
component.filepath
|
|
74307
74309
|
);
|
|
74308
|
-
let sourcePathParsed =
|
|
74309
|
-
let sourcePath =
|
|
74310
|
+
let sourcePathParsed = parse3(sourcePathRelative);
|
|
74311
|
+
let sourcePath = join2(sourcePathParsed.dir, sourcePathParsed.name);
|
|
74310
74312
|
const localImport = ensureImports({
|
|
74311
74313
|
config: config2,
|
|
74312
74314
|
body,
|
|
74313
74315
|
import: "__component__" + component.fragment,
|
|
74314
|
-
sourceModule:
|
|
74315
|
-
|
|
74316
|
+
sourceModule: join2(
|
|
74317
|
+
relative(dirname(filepath), config2.projectRoot),
|
|
74316
74318
|
"src",
|
|
74317
74319
|
sourcePath
|
|
74318
74320
|
)
|
|
@@ -74378,9 +74380,9 @@ function scalarPropertyValue(config2, filepath, missingScalars, target, body, fi
|
|
|
74378
74380
|
}
|
|
74379
74381
|
}
|
|
74380
74382
|
async function writeTsConfig(config2) {
|
|
74381
|
-
await
|
|
74382
|
-
await
|
|
74383
|
-
|
|
74383
|
+
await mkdirp(config2.rootDir);
|
|
74384
|
+
await writeFile(
|
|
74385
|
+
join2(config2.rootDir, "tsconfig.json"),
|
|
74384
74386
|
JSON.stringify(
|
|
74385
74387
|
{
|
|
74386
74388
|
compilerOptions: {
|
|
@@ -77275,6 +77277,16 @@ async function generatePluginIndex({
|
|
|
77275
77277
|
}
|
|
77276
77278
|
|
|
77277
77279
|
// src/codegen/generators/runtime/pluginRuntime.ts
|
|
77280
|
+
function moduleStatments(config2) {
|
|
77281
|
+
const importStatement = config2.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
|
|
77282
|
+
const exportDefaultStatement = config2.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
|
|
77283
|
+
const exportStarStatement = config2.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
|
|
77284
|
+
return {
|
|
77285
|
+
importStatement,
|
|
77286
|
+
exportDefaultStatement,
|
|
77287
|
+
exportStarStatement
|
|
77288
|
+
};
|
|
77289
|
+
}
|
|
77278
77290
|
async function generatePluginRuntimes({
|
|
77279
77291
|
config: config2,
|
|
77280
77292
|
docs
|
|
@@ -77290,7 +77302,7 @@ async function generatePluginRuntimes({
|
|
|
77290
77302
|
return;
|
|
77291
77303
|
}
|
|
77292
77304
|
try {
|
|
77293
|
-
await
|
|
77305
|
+
await stat(runtime_path);
|
|
77294
77306
|
} catch {
|
|
77295
77307
|
throw new HoudiniError({
|
|
77296
77308
|
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
@@ -77302,13 +77314,13 @@ async function generatePluginRuntimes({
|
|
|
77302
77314
|
if (transformMap && typeof transformMap === "function") {
|
|
77303
77315
|
transformMap = transformMap(docs, { config: config2 });
|
|
77304
77316
|
}
|
|
77305
|
-
await
|
|
77306
|
-
await
|
|
77317
|
+
await mkdirp(pluginDir);
|
|
77318
|
+
await recursiveCopy(
|
|
77307
77319
|
runtime_path,
|
|
77308
77320
|
pluginDir,
|
|
77309
77321
|
Object.fromEntries(
|
|
77310
77322
|
Object.entries(transformMap).map(([key, value]) => [
|
|
77311
|
-
|
|
77323
|
+
join2(runtime_path, key),
|
|
77312
77324
|
(content) => value({
|
|
77313
77325
|
config: config2,
|
|
77314
77326
|
content,
|
|
@@ -77355,21 +77367,21 @@ async function runtimeGenerator(config2, docs) {
|
|
|
77355
77367
|
exportStarStatement: exportStar
|
|
77356
77368
|
} = moduleStatments(config2);
|
|
77357
77369
|
await Promise.all([
|
|
77358
|
-
|
|
77359
|
-
[
|
|
77370
|
+
recursiveCopy(config2.runtimeSource, config2.runtimeDirectory, {
|
|
77371
|
+
[join2(config2.runtimeSource, "lib", "constants.js")]: (content) => {
|
|
77360
77372
|
return content.replace("SITE_URL", siteURL);
|
|
77361
77373
|
},
|
|
77362
|
-
[
|
|
77374
|
+
[join2(config2.runtimeSource, "imports", "pluginConfig.js")]: (content) => {
|
|
77363
77375
|
return injectConfig({ config: config2, importStatement, exportStatement, content });
|
|
77364
77376
|
},
|
|
77365
|
-
[
|
|
77366
|
-
const configFilePath =
|
|
77367
|
-
const relativePath =
|
|
77377
|
+
[join2(config2.runtimeSource, "imports", "config.js")]: (content) => {
|
|
77378
|
+
const configFilePath = join2(config2.runtimeDirectory, "imports", "config.js");
|
|
77379
|
+
const relativePath = relative(dirname(configFilePath), config2.filepath);
|
|
77368
77380
|
return `${importStatement(relativePath, "config")}
|
|
77369
77381
|
${exportStatement("config")}
|
|
77370
77382
|
`;
|
|
77371
77383
|
},
|
|
77372
|
-
[
|
|
77384
|
+
[join2(config2.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config: config2, content, importStatement, exportStatement })
|
|
77373
77385
|
}),
|
|
77374
77386
|
generatePluginRuntimes({
|
|
77375
77387
|
config: config2,
|
|
@@ -77379,16 +77391,6 @@ ${exportStatement("config")}
|
|
|
77379
77391
|
]);
|
|
77380
77392
|
await generateGraphqlReturnTypes(config2, docs);
|
|
77381
77393
|
}
|
|
77382
|
-
function moduleStatments(config2) {
|
|
77383
|
-
const importStatement = config2.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
|
|
77384
|
-
const exportDefaultStatement = config2.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
|
|
77385
|
-
const exportStarStatement = config2.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
|
|
77386
|
-
return {
|
|
77387
|
-
importStatement,
|
|
77388
|
-
exportDefaultStatement,
|
|
77389
|
-
exportStarStatement
|
|
77390
|
-
};
|
|
77391
|
-
}
|
|
77392
77394
|
|
|
77393
77395
|
// src/codegen/generators/typescript/documentTypes.ts
|
|
77394
77396
|
var recast11 = __toESM(require_main2(), 1);
|