@diagonal-hq/cli 0.37.7 → 0.37.8
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/dist/cli.mjs +372 -1809
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -20178,10 +20178,10 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
20178
20178
|
"interopRequireDefault"
|
|
20179
20179
|
)}(${primaryImportName});`;
|
|
20180
20180
|
}
|
|
20181
|
-
for (const { importedName
|
|
20181
|
+
for (const { importedName, localName } of namedExports) {
|
|
20182
20182
|
requireCode += ` ${this.helperManager.getHelperName(
|
|
20183
20183
|
"createNamedExportFrom"
|
|
20184
|
-
)}(${primaryImportName}, '${localName}', '${
|
|
20184
|
+
)}(${primaryImportName}, '${localName}', '${importedName}');`;
|
|
20185
20185
|
}
|
|
20186
20186
|
for (const exportStarName of exportStarNames) {
|
|
20187
20187
|
requireCode += ` exports.${exportStarName} = ${secondaryImportName};`;
|
|
@@ -20195,8 +20195,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
20195
20195
|
for (const defaultName of defaultNames) {
|
|
20196
20196
|
this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
|
|
20197
20197
|
}
|
|
20198
|
-
for (const { importedName
|
|
20199
|
-
this.identifierReplacements.set(localName, `${primaryImportName}.${
|
|
20198
|
+
for (const { importedName, localName } of namedImports) {
|
|
20199
|
+
this.identifierReplacements.set(localName, `${primaryImportName}.${importedName}`);
|
|
20200
20200
|
}
|
|
20201
20201
|
}
|
|
20202
20202
|
}
|
|
@@ -76710,28 +76710,12 @@ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
|
76710
76710
|
function studlyName(text2) {
|
|
76711
76711
|
return text2.split(/[^A-Za-z0-9]+/).filter((word) => word !== "").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
76712
76712
|
}
|
|
76713
|
-
function pageName(path) {
|
|
76714
|
-
const name = path.replace(/^pages\//, "").replace(/\.tsx$/, "").split("/").map((segment) => {
|
|
76715
|
-
const parameter = /^\[(.+)\]$/.exec(segment);
|
|
76716
|
-
return parameter === null ? studlyName(segment) : `$${studlyName(parameter[1])}`;
|
|
76717
|
-
}).join("_");
|
|
76718
|
-
return /^[0-9]/.test(name) ? `Page${name}` : name;
|
|
76719
|
-
}
|
|
76720
76713
|
|
|
76721
76714
|
// scripts/lib/workflow-code/ast-values.mjs
|
|
76722
76715
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
76723
76716
|
|
|
76724
76717
|
// scripts/lib/workflow-code/workflow-evaluator.mjs
|
|
76725
76718
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
76726
|
-
function textTemplateFields(template, variables) {
|
|
76727
|
-
return {
|
|
76728
|
-
template,
|
|
76729
|
-
values: Object.entries(variables).map(([key, replacement]) => ({
|
|
76730
|
-
search: `{{${key}}}`,
|
|
76731
|
-
replacement
|
|
76732
|
-
}))
|
|
76733
|
-
};
|
|
76734
|
-
}
|
|
76735
76719
|
|
|
76736
76720
|
// scripts/lib/workflow-code/ast-values.mjs
|
|
76737
76721
|
function memberPathSegments(node) {
|
|
@@ -77906,12 +77890,6 @@ function expectDefineCall(declaration, name, argumentCount) {
|
|
|
77906
77890
|
}
|
|
77907
77891
|
return declaration.arguments;
|
|
77908
77892
|
}
|
|
77909
|
-
function isFunctionNode(node) {
|
|
77910
|
-
return node?.type === "FunctionDeclaration" || node?.type === "FunctionExpression" || node?.type === "ArrowFunctionExpression";
|
|
77911
|
-
}
|
|
77912
|
-
function sliceOf(source, node) {
|
|
77913
|
-
return source.slice(node.start, node.end);
|
|
77914
|
-
}
|
|
77915
77893
|
function childNodes(node) {
|
|
77916
77894
|
const children = [];
|
|
77917
77895
|
for (const [key, child] of Object.entries(node)) {
|
|
@@ -78989,7 +78967,6 @@ function buildAssets(ast, catalog) {
|
|
|
78989
78967
|
});
|
|
78990
78968
|
}
|
|
78991
78969
|
var GENERATED_ASSETS_PATH = "generated/assets.ts";
|
|
78992
|
-
var GENERATED_ASSETS_MODULE = "@app/generated/assets";
|
|
78993
78970
|
var ASSETS_EXPORT = "Assets";
|
|
78994
78971
|
var VARIANTS_TYPE = "readonly { readonly width: number; readonly url: string }[]";
|
|
78995
78972
|
function assetEntries(assets, catalog) {
|
|
@@ -79013,16 +78990,6 @@ function assetEntries(assets, catalog) {
|
|
|
79013
78990
|
}
|
|
79014
78991
|
return entries;
|
|
79015
78992
|
}
|
|
79016
|
-
function assetsBinding(ast, entries) {
|
|
79017
|
-
const local = generatedBindingLocal(ast, GENERATED_ASSETS_MODULE, ASSETS_EXPORT);
|
|
79018
|
-
if (local === null) {
|
|
79019
|
-
return null;
|
|
79020
|
-
}
|
|
79021
|
-
return {
|
|
79022
|
-
local,
|
|
79023
|
-
keysByName: entries === null ? null : new Map(Object.entries(entries).map(([name, entry]) => [name, entry.key]))
|
|
79024
|
-
};
|
|
79025
|
-
}
|
|
79026
78993
|
function generatedAssetsSource(entries) {
|
|
79027
78994
|
return generatedModuleSource(ASSETS_EXPORT, entries);
|
|
79028
78995
|
}
|
|
@@ -79490,8 +79457,8 @@ function recordBindingUsages(root, paths, entries) {
|
|
|
79490
79457
|
}
|
|
79491
79458
|
|
|
79492
79459
|
// scripts/lib/runtime-build/build-workspace.mjs
|
|
79493
|
-
import { existsSync as
|
|
79494
|
-
import {
|
|
79460
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync5 } from "node:fs";
|
|
79461
|
+
import { dirname as dirname7, extname, join as join15 } from "node:path";
|
|
79495
79462
|
|
|
79496
79463
|
// packages/cli/brand-kit-catalog.json
|
|
79497
79464
|
var brand_kit_catalog_default = {
|
|
@@ -83461,72 +83428,6 @@ function checkDefinitionUids(root, definitions, options) {
|
|
|
83461
83428
|
return result;
|
|
83462
83429
|
}
|
|
83463
83430
|
|
|
83464
|
-
// scripts/lib/runtime-build/email-asset-references.mjs
|
|
83465
|
-
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
83466
|
-
var TOKEN = /asset:(?=[A-Za-z0-9_-])/gi;
|
|
83467
|
-
var WHOLE_VALUE = /^asset:([A-Za-z0-9_-]+)$/i;
|
|
83468
|
-
var NAMED_TOKEN = /asset:([A-Za-z0-9_-]+)/gi;
|
|
83469
|
-
var COMMENT = /<!--[\s\S]*?(?:-->|$)/g;
|
|
83470
|
-
var TAG = /<[A-Za-z][^>]*>/g;
|
|
83471
|
-
var ATTRIBUTE = /([^\s"'<>/=]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
|
|
83472
|
-
var STYLE_BLOCK = /<style\b[^>]*>([\s\S]*?)(?:<\/style\s*>|$)/gi;
|
|
83473
|
-
var STYLE_URL = /url\(\s*['"]?\s*(?=asset:[A-Za-z0-9_-])/gi;
|
|
83474
|
-
var EMAIL_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
83475
|
-
var MISPLACED_MESSAGE = 'asset: references in email HTML must be the whole quoted value of src or href, or of background in a layout, such as <img src="asset:logo">';
|
|
83476
|
-
var BACKGROUND_MESSAGE = 'background="asset:..." works only in an email layout body. Use an <img> in a template field';
|
|
83477
|
-
var TEXT_MESSAGE = "asset: references work only in email layout bodies and email fields";
|
|
83478
|
-
var ANIMATED_WEBP_MESSAGE = "Gmail shows animated WebP on a black background. Use a GIF asset";
|
|
83479
|
-
function notAssetKeyMessage(name) {
|
|
83480
|
-
return `"${name}" is not an asset key. Use the camelCase key from assets.ts, such as asset:heroImage`;
|
|
83481
|
-
}
|
|
83482
|
-
function unknownAssetMessage(key) {
|
|
83483
|
-
return `Unknown asset "${key}". Add it to assets.ts`;
|
|
83484
|
-
}
|
|
83485
|
-
function emailImageTypeMessage(mimeType) {
|
|
83486
|
-
return `Email clients do not show ${mimeType} images. Use a PNG, JPEG, or GIF asset`;
|
|
83487
|
-
}
|
|
83488
|
-
function emailAssetReferences(html, { allowBackground, keys: keys2 }) {
|
|
83489
|
-
const masked = html.replace(COMMENT, (comment) => " ".repeat(comment.length));
|
|
83490
|
-
const references = [];
|
|
83491
|
-
for (const tag of masked.matchAll(TAG)) {
|
|
83492
|
-
for (const attribute of tag[0].matchAll(ATTRIBUTE)) {
|
|
83493
|
-
const value = attribute[2] ?? attribute[3];
|
|
83494
|
-
const valueIndex = tag.index + attribute.index + attribute[0].length - value.length - 1;
|
|
83495
|
-
const name = attribute[1].toLowerCase();
|
|
83496
|
-
const whole = WHOLE_VALUE.exec(value);
|
|
83497
|
-
if (whole !== null && (name === "src" || name === "href" || name === "background")) {
|
|
83498
|
-
if (name === "background" && !allowBackground) {
|
|
83499
|
-
references.push({ index: valueIndex, kind: "background" });
|
|
83500
|
-
} else if (!isAssetKey(whole[1])) {
|
|
83501
|
-
references.push({ index: valueIndex, kind: "name", name: whole[1] });
|
|
83502
|
-
} else {
|
|
83503
|
-
references.push({ index: valueIndex, kind: "reference", name: whole[1], attribute: name });
|
|
83504
|
-
}
|
|
83505
|
-
continue;
|
|
83506
|
-
}
|
|
83507
|
-
for (const token of value.matchAll(TOKEN)) {
|
|
83508
|
-
references.push({ index: valueIndex + token.index, kind: "misplaced" });
|
|
83509
|
-
}
|
|
83510
|
-
}
|
|
83511
|
-
}
|
|
83512
|
-
for (const block of masked.matchAll(STYLE_BLOCK)) {
|
|
83513
|
-
const contentIndex = block.index + block[0].indexOf(">") + 1;
|
|
83514
|
-
for (const url of block[1].matchAll(STYLE_URL)) {
|
|
83515
|
-
references.push({ index: contentIndex + url.index + url[0].length, kind: "misplaced" });
|
|
83516
|
-
}
|
|
83517
|
-
}
|
|
83518
|
-
const scanned = new Set(references.map((reference) => reference.index));
|
|
83519
|
-
for (const token of masked.matchAll(NAMED_TOKEN)) {
|
|
83520
|
-
if (keys2.has(token[1]) && !scanned.has(token.index)) {
|
|
83521
|
-
references.push({ index: token.index, kind: "misplaced" });
|
|
83522
|
-
}
|
|
83523
|
-
}
|
|
83524
|
-
return references.toSorted((left, right) => left.index - right.index);
|
|
83525
|
-
}
|
|
83526
|
-
function textAssetReferences(text2, keys2) {
|
|
83527
|
-
return [...text2.matchAll(NAMED_TOKEN)].filter((token) => keys2.has(token[1])).map((token) => token.index);
|
|
83528
|
-
}
|
|
83529
|
-
|
|
83530
83431
|
// scripts/lib/runtime-build/fields.mjs
|
|
83531
83432
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
83532
83433
|
|
|
@@ -87461,41 +87362,6 @@ function appImportsOf(root, path, ast, { ui = false } = {}) {
|
|
|
87461
87362
|
}
|
|
87462
87363
|
return imports;
|
|
87463
87364
|
}
|
|
87464
|
-
function appBindings(source, imports) {
|
|
87465
|
-
return imports.map(({ statement: statement2, path }) => ({
|
|
87466
|
-
start: statement2.start,
|
|
87467
|
-
end: statement2.end,
|
|
87468
|
-
text: bindingFor(statement2, path),
|
|
87469
|
-
original: sliceOf(source, statement2)
|
|
87470
|
-
}));
|
|
87471
|
-
}
|
|
87472
|
-
function bindingFor(statement2, path) {
|
|
87473
|
-
if (statement2.importKind === "type") {
|
|
87474
|
-
return "";
|
|
87475
|
-
}
|
|
87476
|
-
const load = `${APP_IMPORT}(${JSON.stringify(path)})`;
|
|
87477
|
-
const named = [];
|
|
87478
|
-
const statements2 = [];
|
|
87479
|
-
for (const specifier of statement2.specifiers) {
|
|
87480
|
-
if (specifier.type === "ImportDefaultSpecifier") {
|
|
87481
|
-
statements2.push(`const ${specifier.local.name} = ${load}.default;`);
|
|
87482
|
-
} else if (specifier.type === "ImportNamespaceSpecifier") {
|
|
87483
|
-
statements2.push(`const ${specifier.local.name} = ${load};`);
|
|
87484
|
-
} else if (specifier.importKind !== "type") {
|
|
87485
|
-
const imported = specifier.imported.type === "StringLiteral" ? JSON.stringify(specifier.imported.value) : specifier.imported.name;
|
|
87486
|
-
named.push(
|
|
87487
|
-
imported === specifier.local.name ? imported : `${imported}: ${specifier.local.name}`
|
|
87488
|
-
);
|
|
87489
|
-
}
|
|
87490
|
-
}
|
|
87491
|
-
if (named.length > 0) {
|
|
87492
|
-
statements2.push(`const { ${named.join(", ")} } = ${load};`);
|
|
87493
|
-
}
|
|
87494
|
-
if (statements2.length === 0) {
|
|
87495
|
-
statements2.push(`${load};`);
|
|
87496
|
-
}
|
|
87497
|
-
return statements2.join(" ");
|
|
87498
|
-
}
|
|
87499
87365
|
function appModuleClosure(root, imports, external = /* @__PURE__ */ new Set(), { ui = false, transform: transform3 = null } = {}) {
|
|
87500
87366
|
const modules = /* @__PURE__ */ new Map();
|
|
87501
87367
|
const pending = imports.map((item) => item.path);
|
|
@@ -88333,12 +88199,12 @@ function notificationSendWarnings(path, ast, names2, options = {}) {
|
|
|
88333
88199
|
if (!type.byUid) {
|
|
88334
88200
|
warnings2.push(generatedReferenceDiagnostic(path, typeValue, typeUidReference, GENERATED_NOTIFICATION_TYPES_MODULE, options));
|
|
88335
88201
|
}
|
|
88336
|
-
const
|
|
88337
|
-
const templateSlug =
|
|
88202
|
+
const templateValue = propertyValue(object, "notificationTemplate");
|
|
88203
|
+
const templateSlug = templateValue === null ? null : templateSlugOfSend(templateValue, names2, type.slug, local);
|
|
88338
88204
|
const templateUidReference = templateSlug === null ? null : templateReference(names2, type.slug, templateSlug);
|
|
88339
88205
|
if (templateUidReference !== null) {
|
|
88340
88206
|
warnings2.push(
|
|
88341
|
-
generatedReferenceDiagnostic(path,
|
|
88207
|
+
generatedReferenceDiagnostic(path, templateValue, templateUidReference, GENERATED_NOTIFICATION_TYPES_MODULE, options)
|
|
88342
88208
|
);
|
|
88343
88209
|
}
|
|
88344
88210
|
}
|
|
@@ -88367,7 +88233,6 @@ var LEGACY_PERMISSIONS_PATH = "permissions.ts";
|
|
|
88367
88233
|
var GENERATED_PERMISSIONS_PATH = "generated/permissions.ts";
|
|
88368
88234
|
var GENERATED_PERMISSIONS_MODULE = "@app/generated/permissions";
|
|
88369
88235
|
var PERMISSIONS_EXPORT = "Permissions";
|
|
88370
|
-
var SYSTEM_PERMISSIONS_EXPORT = "SystemPermissions";
|
|
88371
88236
|
var MAX_LENGTH = 255;
|
|
88372
88237
|
var systemPermissions = Object.entries(SystemPermissions).map(([constName, permission]) => ({
|
|
88373
88238
|
constName,
|
|
@@ -88399,86 +88264,6 @@ function generatedPermissionsSource(entries) {
|
|
|
88399
88264
|
function permissionValues(entries) {
|
|
88400
88265
|
return { entries, exportName: PERMISSIONS_EXPORT, noun: "permission", directory: "permissions/", exampleMember: "uid" };
|
|
88401
88266
|
}
|
|
88402
|
-
function knownPermissionUids(permissions) {
|
|
88403
|
-
return /* @__PURE__ */ new Set([
|
|
88404
|
-
...systemByUid.keys(),
|
|
88405
|
-
...permissions.map((permission) => permission.uid).filter((uid2) => uid2 !== null)
|
|
88406
|
-
]);
|
|
88407
|
-
}
|
|
88408
|
-
function permissionReferenceProblem(reference, permissions) {
|
|
88409
|
-
const system = systemBySlug.get(reference);
|
|
88410
|
-
if (system !== void 0) {
|
|
88411
|
-
return `"${reference}" is the slug of a system permission. Use ${SYSTEM_PERMISSIONS_EXPORT}.${system.constName}.uid from ${AUTHORING_MODULE}`;
|
|
88412
|
-
}
|
|
88413
|
-
const declared = permissions.find((permission) => permission.slug === reference);
|
|
88414
|
-
if (declared !== void 0) {
|
|
88415
|
-
return `"${reference}" is the slug of a permission. Use ${PERMISSIONS_EXPORT}.${declared.name}.uid from ${GENERATED_PERMISSIONS_MODULE}`;
|
|
88416
|
-
}
|
|
88417
|
-
return `Unknown permission "${reference}". Use ${PERMISSIONS_EXPORT}.<Name>.uid from ${GENERATED_PERMISSIONS_MODULE}, or ${SYSTEM_PERMISSIONS_EXPORT}.<Name>.uid from ${AUTHORING_MODULE}`;
|
|
88418
|
-
}
|
|
88419
|
-
function permissionsBinding(ast, entries) {
|
|
88420
|
-
const bindings = [];
|
|
88421
|
-
const declared = generatedBindingLocal(ast, GENERATED_PERMISSIONS_MODULE, PERMISSIONS_EXPORT);
|
|
88422
|
-
const system = generatedBindingLocal(ast, AUTHORING_MODULE, SYSTEM_PERMISSIONS_EXPORT);
|
|
88423
|
-
if (declared !== null) {
|
|
88424
|
-
bindings.push({
|
|
88425
|
-
local: declared,
|
|
88426
|
-
entries: entries ?? /* @__PURE__ */ Object.create(null),
|
|
88427
|
-
source: `${PERMISSIONS_DIRECTORY}/`
|
|
88428
|
-
});
|
|
88429
|
-
}
|
|
88430
|
-
if (system !== null) {
|
|
88431
|
-
bindings.push({ local: system, entries: SystemPermissions, source: AUTHORING_MODULE });
|
|
88432
|
-
}
|
|
88433
|
-
return bindings.length === 0 ? null : bindings;
|
|
88434
|
-
}
|
|
88435
|
-
function menuPermissionSlugWarnings(path, ast, entries) {
|
|
88436
|
-
const declaration = ast.program.body.find((statement2) => statement2.type === "ExportDefaultDeclaration")?.declaration;
|
|
88437
|
-
const menu = declaration?.type === "CallExpression" ? declaration.arguments[0] : null;
|
|
88438
|
-
const context = menu?.params?.[0];
|
|
88439
|
-
if (context?.type !== "Identifier") {
|
|
88440
|
-
return [];
|
|
88441
|
-
}
|
|
88442
|
-
const references = new Map([
|
|
88443
|
-
...systemPermissions.map((permission) => [
|
|
88444
|
-
permission.slug,
|
|
88445
|
-
{ reference: `${SYSTEM_PERMISSIONS_EXPORT}.${permission.constName}.uid`, module: AUTHORING_MODULE }
|
|
88446
|
-
]),
|
|
88447
|
-
...Object.entries(entries).map(([name, entry]) => [
|
|
88448
|
-
entry.slug,
|
|
88449
|
-
{ reference: `${PERMISSIONS_EXPORT}.${name}.uid`, module: GENERATED_PERMISSIONS_MODULE }
|
|
88450
|
-
])
|
|
88451
|
-
]);
|
|
88452
|
-
const slugMembers = new Map(
|
|
88453
|
-
(permissionsBinding(ast, entries) ?? []).map((binding) => [binding.local, binding.entries])
|
|
88454
|
-
);
|
|
88455
|
-
const slugOf = (argument) => {
|
|
88456
|
-
if (argument?.type === "StringLiteral") {
|
|
88457
|
-
return argument.value;
|
|
88458
|
-
}
|
|
88459
|
-
const segments = memberPathSegments(argument);
|
|
88460
|
-
const bindingEntries = segments?.length === 3 && segments[2] === "slug" ? slugMembers.get(segments[0]) : void 0;
|
|
88461
|
-
return bindingEntries !== void 0 && Object.hasOwn(bindingEntries, segments[1]) ? bindingEntries[segments[1]].slug : null;
|
|
88462
|
-
};
|
|
88463
|
-
const warnings2 = [];
|
|
88464
|
-
const pending = [menu.body];
|
|
88465
|
-
while (pending.length > 0) {
|
|
88466
|
-
const current = pending.pop();
|
|
88467
|
-
pending.push(...childNodes(current));
|
|
88468
|
-
const callee = current.type === "CallExpression" ? current.callee : null;
|
|
88469
|
-
const argument = current.arguments?.[0];
|
|
88470
|
-
if (callee?.type !== "MemberExpression" || callee.computed || callee.object.type !== "Identifier" || callee.object.name !== context.name || callee.property.name !== "can") {
|
|
88471
|
-
continue;
|
|
88472
|
-
}
|
|
88473
|
-
const slug = slugOf(argument);
|
|
88474
|
-
if (slug === null || !references.has(slug)) {
|
|
88475
|
-
continue;
|
|
88476
|
-
}
|
|
88477
|
-
const { reference, module } = references.get(slug);
|
|
88478
|
-
warnings2.push(generatedReferenceDiagnostic(path, argument, reference, module));
|
|
88479
|
-
}
|
|
88480
|
-
return warnings2;
|
|
88481
|
-
}
|
|
88482
88267
|
|
|
88483
88268
|
// scripts/lib/runtime-build/role-references.mjs
|
|
88484
88269
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
@@ -88514,98 +88299,9 @@ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
|
88514
88299
|
var GENERATED_PAGES_PATH = "generated/pages.ts";
|
|
88515
88300
|
var GENERATED_PAGES_MODULE = "@app/generated/pages";
|
|
88516
88301
|
var PAGES_EXPORT = "Pages";
|
|
88517
|
-
var PAGE_NAME_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
88518
|
-
function pageName2(path) {
|
|
88519
|
-
return pageName(withoutDevInfix(path));
|
|
88520
|
-
}
|
|
88521
|
-
function pageNames(paths, diagnostics) {
|
|
88522
|
-
const pathsByName = /* @__PURE__ */ new Map();
|
|
88523
|
-
for (const path of paths) {
|
|
88524
|
-
const name = pageName2(path);
|
|
88525
|
-
if (!PAGE_NAME_PATTERN.test(name)) {
|
|
88526
|
-
diagnostics.push(
|
|
88527
|
-
diagnosticAt(path, null, `The page file ${path} gives no name in Pages. Give each folder and the file a name with a letter or a digit`)
|
|
88528
|
-
);
|
|
88529
|
-
continue;
|
|
88530
|
-
}
|
|
88531
|
-
const other = pathsByName.get(name);
|
|
88532
|
-
if (other !== void 0) {
|
|
88533
|
-
diagnostics.push(
|
|
88534
|
-
diagnosticAt(
|
|
88535
|
-
path,
|
|
88536
|
-
null,
|
|
88537
|
-
`The page files ${other} and ${path} both have the name Pages.${name}. Rename one of the files`,
|
|
88538
|
-
{ relatedPath: other }
|
|
88539
|
-
)
|
|
88540
|
-
);
|
|
88541
|
-
continue;
|
|
88542
|
-
}
|
|
88543
|
-
pathsByName.set(name, path);
|
|
88544
|
-
}
|
|
88545
|
-
return pathsByName;
|
|
88546
|
-
}
|
|
88547
|
-
function checkPageUids(root, pages, { write }) {
|
|
88548
|
-
const definitions = [];
|
|
88549
|
-
for (const { path, source, ast } of pages) {
|
|
88550
|
-
const node = definePageOptions(ast);
|
|
88551
|
-
if (node !== null) {
|
|
88552
|
-
definitions.push({ type: "page", path, source, node });
|
|
88553
|
-
}
|
|
88554
|
-
}
|
|
88555
|
-
const { uids, diagnostics } = checkDefinitionUids(root, definitions, { write });
|
|
88556
|
-
return {
|
|
88557
|
-
pages: new Map(
|
|
88558
|
-
definitions.map((definition, index3) => [definition.path, { uid: uids[index3], route: routeOf(definition.node) }])
|
|
88559
|
-
),
|
|
88560
|
-
diagnostics
|
|
88561
|
-
};
|
|
88562
|
-
}
|
|
88563
|
-
function definePageOptions(ast) {
|
|
88564
|
-
const withoutImports = {
|
|
88565
|
-
...ast,
|
|
88566
|
-
program: { ...ast.program, body: ast.program.body.filter((statement2) => statement2.type !== "ImportDeclaration") }
|
|
88567
|
-
};
|
|
88568
|
-
try {
|
|
88569
|
-
const { declaration } = defaultExportOf(withoutImports, { helpers: "anywhere", allowAppImports: true });
|
|
88570
|
-
return expectDefineCall(declaration, "definePage", 2)[0];
|
|
88571
|
-
} catch (error) {
|
|
88572
|
-
if (error instanceof SourceError) {
|
|
88573
|
-
return null;
|
|
88574
|
-
}
|
|
88575
|
-
throw error;
|
|
88576
|
-
}
|
|
88577
|
-
}
|
|
88578
|
-
function routeOf(options) {
|
|
88579
|
-
if (options.type !== "ObjectExpression") {
|
|
88580
|
-
return null;
|
|
88581
|
-
}
|
|
88582
|
-
try {
|
|
88583
|
-
const property = options.properties.find(
|
|
88584
|
-
(candidate) => candidate.type === "ObjectProperty" && propertyKey(candidate) === "route"
|
|
88585
|
-
);
|
|
88586
|
-
const route = property === void 0 ? null : staticValue(property.value);
|
|
88587
|
-
return typeof route === "string" ? route : null;
|
|
88588
|
-
} catch (error) {
|
|
88589
|
-
if (error instanceof SourceError) {
|
|
88590
|
-
return null;
|
|
88591
|
-
}
|
|
88592
|
-
throw error;
|
|
88593
|
-
}
|
|
88594
|
-
}
|
|
88595
|
-
function pageEntries(pathsByName, pages) {
|
|
88596
|
-
const entries = /* @__PURE__ */ Object.create(null);
|
|
88597
|
-
for (const name of [...pathsByName.keys()].toSorted()) {
|
|
88598
|
-
const page = pages.get(pathsByName.get(name));
|
|
88599
|
-
entries[name] = { uid: page?.uid ?? null, route: page?.route ?? null };
|
|
88600
|
-
}
|
|
88601
|
-
return entries;
|
|
88602
|
-
}
|
|
88603
88302
|
function routeParamNames(route) {
|
|
88604
88303
|
return [...route.matchAll(/\{([^}/]+)\}/g)].map((match) => match[1]);
|
|
88605
88304
|
}
|
|
88606
|
-
function generatedPagesSource(entries) {
|
|
88607
|
-
return generatedModuleSource(PAGES_EXPORT, entries);
|
|
88608
|
-
}
|
|
88609
88305
|
function pageValues(entries) {
|
|
88610
88306
|
return { entries, exportName: PAGES_EXPORT, noun: "page", directory: "pages/", exampleMember: "uid" };
|
|
88611
88307
|
}
|
|
@@ -101812,11 +101508,14 @@ function moduleCheckRequest({ entries, packages, assetKeys }) {
|
|
|
101812
101508
|
packages: [...packages],
|
|
101813
101509
|
assetKeys: assetKeys === null ? null : [...assetKeys],
|
|
101814
101510
|
generatedModules: Object.fromEntries(GENERATED_IMPORT_KINDS),
|
|
101815
|
-
rules:
|
|
101816
|
-
|
|
101817
|
-
|
|
101818
|
-
|
|
101819
|
-
|
|
101511
|
+
rules: importRules()
|
|
101512
|
+
};
|
|
101513
|
+
}
|
|
101514
|
+
function importRules() {
|
|
101515
|
+
return {
|
|
101516
|
+
...IMPORT_RULES,
|
|
101517
|
+
rowMenuMembers: [...ROW_MENU_MEMBERS],
|
|
101518
|
+
navigationMenuRemoved: NAVIGATION_MENU_REMOVED
|
|
101820
101519
|
};
|
|
101821
101520
|
}
|
|
101822
101521
|
function moduleCheckOf(root, request2, answers) {
|
|
@@ -101827,11 +101526,14 @@ function moduleCheckOf(root, request2, answers) {
|
|
|
101827
101526
|
throw new Error("The workspace check has no answer of the modules stage.");
|
|
101828
101527
|
}
|
|
101829
101528
|
const check2 = { root, request: request2, answers };
|
|
101830
|
-
if ((
|
|
101529
|
+
if (moduleCheckStale(root, answers)) {
|
|
101831
101530
|
check2.answers = runModuleCheck(root, request2);
|
|
101832
101531
|
}
|
|
101833
101532
|
return check2;
|
|
101834
101533
|
}
|
|
101534
|
+
function moduleCheckStale(root, answers) {
|
|
101535
|
+
return (answers.absentGenerated ?? []).some((path) => existsSync5(join11(root, path)));
|
|
101536
|
+
}
|
|
101835
101537
|
function runModuleCheck(root, request2) {
|
|
101836
101538
|
return request2.entries.length === 0 ? { modules: {}, stylesheets: {} } : checkWorkspace({ root, modules: request2 }).modules;
|
|
101837
101539
|
}
|
|
@@ -101988,9 +101690,6 @@ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
|
101988
101690
|
|
|
101989
101691
|
// scripts/lib/runtime-build/source-literal.mjs
|
|
101990
101692
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
101991
|
-
function quotedLiteral(value) {
|
|
101992
|
-
return `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\r", "\\r").replaceAll("\n", "\\n").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029")}'`;
|
|
101993
|
-
}
|
|
101994
101693
|
|
|
101995
101694
|
// scripts/lib/runtime-build/navigation-menu-file.mjs
|
|
101996
101695
|
function isMenuFile(path) {
|
|
@@ -102001,6 +101700,72 @@ function isMenuFile(path) {
|
|
|
102001
101700
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
102002
101701
|
import { posix as posix3 } from "node:path";
|
|
102003
101702
|
|
|
101703
|
+
// scripts/lib/runtime-build/email-asset-references.mjs
|
|
101704
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
101705
|
+
var TOKEN = /asset:(?=[A-Za-z0-9_-])/gi;
|
|
101706
|
+
var WHOLE_VALUE = /^asset:([A-Za-z0-9_-]+)$/i;
|
|
101707
|
+
var NAMED_TOKEN = /asset:([A-Za-z0-9_-]+)/gi;
|
|
101708
|
+
var COMMENT = /<!--[\s\S]*?(?:-->|$)/g;
|
|
101709
|
+
var TAG = /<[A-Za-z][^>]*>/g;
|
|
101710
|
+
var ATTRIBUTE = /([^\s"'<>/=]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
|
|
101711
|
+
var STYLE_BLOCK = /<style\b[^>]*>([\s\S]*?)(?:<\/style\s*>|$)/gi;
|
|
101712
|
+
var STYLE_URL = /url\(\s*['"]?\s*(?=asset:[A-Za-z0-9_-])/gi;
|
|
101713
|
+
var EMAIL_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
101714
|
+
var MISPLACED_MESSAGE = 'asset: references in email HTML must be the whole quoted value of src or href, or of background in a layout, such as <img src="asset:logo">';
|
|
101715
|
+
var BACKGROUND_MESSAGE = 'background="asset:..." works only in an email layout body. Use an <img> in a template field';
|
|
101716
|
+
var TEXT_MESSAGE = "asset: references work only in email layout bodies and email fields";
|
|
101717
|
+
var ANIMATED_WEBP_MESSAGE = "Gmail shows animated WebP on a black background. Use a GIF asset";
|
|
101718
|
+
function notAssetKeyMessage(name) {
|
|
101719
|
+
return `"${name}" is not an asset key. Use the camelCase key from assets.ts, such as asset:heroImage`;
|
|
101720
|
+
}
|
|
101721
|
+
function unknownAssetMessage(key) {
|
|
101722
|
+
return `Unknown asset "${key}". Add it to assets.ts`;
|
|
101723
|
+
}
|
|
101724
|
+
function emailImageTypeMessage(mimeType) {
|
|
101725
|
+
return `Email clients do not show ${mimeType} images. Use a PNG, JPEG, or GIF asset`;
|
|
101726
|
+
}
|
|
101727
|
+
function emailAssetReferences(html, { allowBackground, keys: keys2 }) {
|
|
101728
|
+
const masked = html.replace(COMMENT, (comment) => " ".repeat(comment.length));
|
|
101729
|
+
const references = [];
|
|
101730
|
+
for (const tag of masked.matchAll(TAG)) {
|
|
101731
|
+
for (const attribute of tag[0].matchAll(ATTRIBUTE)) {
|
|
101732
|
+
const value = attribute[2] ?? attribute[3];
|
|
101733
|
+
const valueIndex = tag.index + attribute.index + attribute[0].length - value.length - 1;
|
|
101734
|
+
const name = attribute[1].toLowerCase();
|
|
101735
|
+
const whole = WHOLE_VALUE.exec(value);
|
|
101736
|
+
if (whole !== null && (name === "src" || name === "href" || name === "background")) {
|
|
101737
|
+
if (name === "background" && !allowBackground) {
|
|
101738
|
+
references.push({ index: valueIndex, kind: "background" });
|
|
101739
|
+
} else if (!isAssetKey(whole[1])) {
|
|
101740
|
+
references.push({ index: valueIndex, kind: "name", name: whole[1] });
|
|
101741
|
+
} else {
|
|
101742
|
+
references.push({ index: valueIndex, kind: "reference", name: whole[1], attribute: name });
|
|
101743
|
+
}
|
|
101744
|
+
continue;
|
|
101745
|
+
}
|
|
101746
|
+
for (const token of value.matchAll(TOKEN)) {
|
|
101747
|
+
references.push({ index: valueIndex + token.index, kind: "misplaced" });
|
|
101748
|
+
}
|
|
101749
|
+
}
|
|
101750
|
+
}
|
|
101751
|
+
for (const block of masked.matchAll(STYLE_BLOCK)) {
|
|
101752
|
+
const contentIndex = block.index + block[0].indexOf(">") + 1;
|
|
101753
|
+
for (const url of block[1].matchAll(STYLE_URL)) {
|
|
101754
|
+
references.push({ index: contentIndex + url.index + url[0].length, kind: "misplaced" });
|
|
101755
|
+
}
|
|
101756
|
+
}
|
|
101757
|
+
const scanned = new Set(references.map((reference) => reference.index));
|
|
101758
|
+
for (const token of masked.matchAll(NAMED_TOKEN)) {
|
|
101759
|
+
if (keys2.has(token[1]) && !scanned.has(token.index)) {
|
|
101760
|
+
references.push({ index: token.index, kind: "misplaced" });
|
|
101761
|
+
}
|
|
101762
|
+
}
|
|
101763
|
+
return references.toSorted((left, right) => left.index - right.index);
|
|
101764
|
+
}
|
|
101765
|
+
function textAssetReferences(text2, keys2) {
|
|
101766
|
+
return [...text2.matchAll(NAMED_TOKEN)].filter((token) => keys2.has(token[1])).map((token) => token.index);
|
|
101767
|
+
}
|
|
101768
|
+
|
|
102004
101769
|
// scripts/lib/runtime-build/calendar-link-types.json
|
|
102005
101770
|
var calendar_link_types_default = [
|
|
102006
101771
|
"apple",
|
|
@@ -102521,11 +102286,11 @@ function positionIn(origin, text2, index3) {
|
|
|
102521
102286
|
return { line: origin.line, column: origin.column };
|
|
102522
102287
|
}
|
|
102523
102288
|
const prefix2 = text2.slice(0, index3);
|
|
102524
|
-
const
|
|
102289
|
+
const newlines = prefix2.split("\n").length - 1;
|
|
102525
102290
|
if (origin.file) {
|
|
102526
|
-
return { line:
|
|
102291
|
+
return { line: newlines + 1, column: index3 - prefix2.lastIndexOf("\n") };
|
|
102527
102292
|
}
|
|
102528
|
-
return
|
|
102293
|
+
return newlines === 0 ? { line: origin.line, column: origin.column + 1 + index3 } : { line: origin.line + newlines, column: index3 - prefix2.lastIndexOf("\n") };
|
|
102529
102294
|
}
|
|
102530
102295
|
function checkAssetReferences(text2, origin, { html, layout = false }, context, report) {
|
|
102531
102296
|
const assets = context.assets;
|
|
@@ -105321,9 +105086,9 @@ function findClockRead(path, seen, followHelpers = true) {
|
|
|
105321
105086
|
}
|
|
105322
105087
|
}
|
|
105323
105088
|
};
|
|
105324
|
-
const skipTruncated = (
|
|
105325
|
-
if (isTruncating(
|
|
105326
|
-
|
|
105089
|
+
const skipTruncated = (memberPath3) => {
|
|
105090
|
+
if (isTruncating(memberPath3)) {
|
|
105091
|
+
memberPath3.skip();
|
|
105327
105092
|
}
|
|
105328
105093
|
};
|
|
105329
105094
|
path.traverse({
|
|
@@ -105596,8 +105361,8 @@ function stageComponentReturnShape(ast) {
|
|
|
105596
105361
|
);
|
|
105597
105362
|
}
|
|
105598
105363
|
for (const returnStatement3 of factoryReturns) {
|
|
105599
|
-
const
|
|
105600
|
-
const component = isFunctionNode2(
|
|
105364
|
+
const returnedExpression = unwrapTypeScriptExpression(returnStatement3.argument);
|
|
105365
|
+
const component = isFunctionNode2(returnedExpression) ? returnedExpression : topLevelBindings.get(returnedExpression?.name);
|
|
105601
105366
|
if (!component) {
|
|
105602
105367
|
const line = returnStatement3.loc?.start.line ?? 1;
|
|
105603
105368
|
const column = returnStatement3.loc?.start.column ?? 0;
|
|
@@ -106059,11 +105824,14 @@ function lintUnits(units, catalogs) {
|
|
|
106059
105824
|
);
|
|
106060
105825
|
}
|
|
106061
105826
|
|
|
106062
|
-
// scripts/lib/runtime-build/page-
|
|
105827
|
+
// scripts/lib/runtime-build/page-units.mjs
|
|
106063
105828
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
105829
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
105830
|
+
import { join as join12 } from "node:path";
|
|
106064
105831
|
|
|
106065
|
-
//
|
|
105832
|
+
// app/pages/resources/js/pageRuntime/compiler/draftPagesName.ts
|
|
106066
105833
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
105834
|
+
var DRAFT_PAGES_NAME = "__draftPages";
|
|
106067
105835
|
|
|
106068
105836
|
// scripts/lib/runtime-build/page-meta-resolvers.json
|
|
106069
105837
|
var page_meta_resolvers_default = [
|
|
@@ -106071,564 +105839,107 @@ var page_meta_resolvers_default = [
|
|
|
106071
105839
|
"text.template"
|
|
106072
105840
|
];
|
|
106073
105841
|
|
|
106074
|
-
// scripts/lib/runtime-build/page-
|
|
106075
|
-
|
|
106076
|
-
|
|
106077
|
-
|
|
106078
|
-
|
|
106079
|
-
|
|
106080
|
-
|
|
106081
|
-
|
|
106082
|
-
|
|
106083
|
-
|
|
106084
|
-
|
|
106085
|
-
|
|
106086
|
-
|
|
106087
|
-
|
|
106088
|
-
|
|
106089
|
-
|
|
106090
|
-
|
|
106091
|
-
|
|
106092
|
-
|
|
106093
|
-
|
|
106094
|
-
|
|
106095
|
-
|
|
106096
|
-
|
|
106097
|
-
|
|
106098
|
-
|
|
106099
|
-
|
|
106100
|
-
|
|
106101
|
-
}
|
|
106102
|
-
if (node.type === "TemplateLiteral" && node.expressions.length === 0) {
|
|
106103
|
-
return node.quasis[0].value.cooked;
|
|
106104
|
-
}
|
|
106105
|
-
return void 0;
|
|
106106
|
-
}
|
|
106107
|
-
function unwrap3(node) {
|
|
106108
|
-
return node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSNonNullExpression" || node.type === "ParenthesizedExpression" ? unwrap3(node.expression) : node;
|
|
106109
|
-
}
|
|
106110
|
-
function isResolver(value) {
|
|
106111
|
-
return isPlainObject2(value) && Object.hasOwn(value, "$type");
|
|
106112
|
-
}
|
|
106113
|
-
function hasResolver(value) {
|
|
106114
|
-
if (value === null || typeof value !== "object") {
|
|
106115
|
-
return false;
|
|
106116
|
-
}
|
|
106117
|
-
return isResolver(value) || Object.values(value).some(hasResolver);
|
|
106118
|
-
}
|
|
106119
|
-
function tipTapText(content, oneLine, inlineSeparator = null) {
|
|
106120
|
-
if (typeof content === "string") {
|
|
106121
|
-
return content;
|
|
106122
|
-
}
|
|
106123
|
-
const separator = oneLine ? "" : "\n\n";
|
|
106124
|
-
const inline = inlineSeparator ?? separator;
|
|
106125
|
-
const render = (node) => {
|
|
106126
|
-
if (!isPlainObject2(node)) {
|
|
106127
|
-
return "";
|
|
106128
|
-
}
|
|
106129
|
-
if (node.content !== void 0 && node.content !== null) {
|
|
106130
|
-
return Array.isArray(node.content) ? node.content.map(render).join(inline) : "";
|
|
106131
|
-
}
|
|
106132
|
-
return typeof node.text === "string" ? node.text : "";
|
|
105842
|
+
// scripts/lib/runtime-build/page-units.mjs
|
|
105843
|
+
function pagesRequest(build) {
|
|
105844
|
+
return {
|
|
105845
|
+
pages: build.pages,
|
|
105846
|
+
entries: build.entries,
|
|
105847
|
+
menus: build.menus,
|
|
105848
|
+
migrate: build.migrate,
|
|
105849
|
+
names: { slugsByName: [...build.names.slugsByName], namesBySlug: [...build.names.namesBySlug] },
|
|
105850
|
+
permissionEntries: build.permissionEntries,
|
|
105851
|
+
permissions: build.permissions,
|
|
105852
|
+
permissionsComplete: build.permissionsComplete,
|
|
105853
|
+
systemPermissions: SystemPermissions,
|
|
105854
|
+
assets: build.assets,
|
|
105855
|
+
domainKeys: build.domainKeys,
|
|
105856
|
+
resources: build.resources,
|
|
105857
|
+
builtInResourceSlugs: build.builtInResourceSlugs,
|
|
105858
|
+
emailImageMimeTypes: EMAIL_IMAGE_MIME_TYPES,
|
|
105859
|
+
pageMetaResolvers: page_meta_resolvers_default,
|
|
105860
|
+
generatedModules: build.generatedModules,
|
|
105861
|
+
rules: importRules(),
|
|
105862
|
+
sdk: {
|
|
105863
|
+
exports: Object.entries(PAGE_SDK_EXPORTS),
|
|
105864
|
+
fileTypedExports: [...PAGE_SDK_FILE_TYPED_EXPORTS],
|
|
105865
|
+
internalModule: SDK_INTERNAL_MODULE,
|
|
105866
|
+
types: Object.entries(PAGE_SDK_TYPES)
|
|
105867
|
+
},
|
|
105868
|
+
appImport: APP_IMPORT
|
|
106133
105869
|
};
|
|
106134
|
-
return isPlainObject2(content) && Array.isArray(content.content) ? content.content.map(render).join(separator) : "";
|
|
106135
|
-
}
|
|
106136
|
-
function normalizeMetaValue(value) {
|
|
106137
|
-
if (typeof value === "string") {
|
|
106138
|
-
return value.trim() === "" ? null : value;
|
|
106139
|
-
}
|
|
106140
|
-
if (!isResolver(value) || value.$type !== TIPTAP_PARSE || hasResolver(value.$value)) {
|
|
106141
|
-
return value;
|
|
106142
|
-
}
|
|
106143
|
-
const text2 = tipTapText(value.$value?.content ?? "", value.$value?.oneLine === true);
|
|
106144
|
-
return text2.trim() === "" ? null : text2;
|
|
106145
105870
|
}
|
|
106146
|
-
function
|
|
106147
|
-
return
|
|
106148
|
-
}
|
|
106149
|
-
function disallowedMetaResolver(value) {
|
|
106150
|
-
if (value === null || typeof value === "string") {
|
|
106151
|
-
return null;
|
|
106152
|
-
}
|
|
106153
|
-
if (!isResolver(value)) {
|
|
106154
|
-
return Array.isArray(value) ? "a list" : isPlainObject2(value) ? "an object that is not a resolver" : typeof value;
|
|
106155
|
-
}
|
|
106156
|
-
const pending = [value];
|
|
106157
|
-
while (pending.length > 0) {
|
|
106158
|
-
const current = pending.pop();
|
|
106159
|
-
if (isResolver(current) && !PAGE_META_RESOLVERS.has(current.$type)) {
|
|
106160
|
-
return `the resolver "${current.$type}"`;
|
|
106161
|
-
}
|
|
106162
|
-
for (const child of Object.values(current)) {
|
|
106163
|
-
if (child !== null && typeof child === "object") {
|
|
106164
|
-
pending.push(child);
|
|
106165
|
-
}
|
|
106166
|
-
}
|
|
106167
|
-
}
|
|
106168
|
-
return null;
|
|
106169
|
-
}
|
|
106170
|
-
function bindingRoots(key, functionNode) {
|
|
106171
|
-
const params = functionNode.params;
|
|
106172
|
-
if (params.length !== 1) {
|
|
106173
|
-
throw seoError(key, "A seo function takes one parameter: ({ bindings }) => ...", functionNode);
|
|
106174
|
-
}
|
|
106175
|
-
const param = params[0].type === "AssignmentPattern" ? params[0].left : params[0];
|
|
106176
|
-
if (param.type === "Identifier") {
|
|
106177
|
-
return { context: param.name, bindings: null };
|
|
106178
|
-
}
|
|
106179
|
-
if (param.type === "ObjectPattern") {
|
|
106180
|
-
const property = param.properties.find(
|
|
106181
|
-
(item) => item.type === "ObjectProperty" && propertyKey(item) === "bindings"
|
|
106182
|
-
);
|
|
106183
|
-
if (property === void 0 || param.properties.length !== 1 || property.value.type !== "Identifier") {
|
|
106184
|
-
throw seoError(key, "A seo function reads only `bindings`: ({ bindings }) => ...", param);
|
|
106185
|
-
}
|
|
106186
|
-
return { context: null, bindings: property.value.name };
|
|
106187
|
-
}
|
|
106188
|
-
throw seoError(key, "A seo function takes one parameter: ({ bindings }) => ...", param);
|
|
106189
|
-
}
|
|
106190
|
-
function returnedExpression(key, functionNode) {
|
|
106191
|
-
if (functionNode.body.type !== "BlockStatement") {
|
|
106192
|
-
return functionNode.body;
|
|
106193
|
-
}
|
|
106194
|
-
const statements2 = functionNode.body.body;
|
|
106195
|
-
if (statements2.length !== 1 || statements2[0].type !== "ReturnStatement" || statements2[0].argument === null) {
|
|
106196
|
-
throw seoError(
|
|
106197
|
-
key,
|
|
106198
|
-
"A seo function has one expression and no statements. Write ({ bindings }) => bindings.<name>.<field>",
|
|
106199
|
-
functionNode.body
|
|
106200
|
-
);
|
|
106201
|
-
}
|
|
106202
|
-
return statements2[0].argument;
|
|
106203
|
-
}
|
|
106204
|
-
function memberPath3(key, node, roots) {
|
|
106205
|
-
const names2 = [];
|
|
106206
|
-
let current = unwrap3(node);
|
|
106207
|
-
while (current.type === "MemberExpression" || current.type === "OptionalMemberExpression") {
|
|
106208
|
-
if (current.computed) {
|
|
106209
|
-
if (current.property.type !== "StringLiteral") {
|
|
106210
|
-
throw seoError(key, "A computed field name must be a string literal", current.property);
|
|
106211
|
-
}
|
|
106212
|
-
names2.unshift(current.property.value);
|
|
106213
|
-
} else {
|
|
106214
|
-
names2.unshift(current.property.name);
|
|
106215
|
-
}
|
|
106216
|
-
current = unwrap3(current.object);
|
|
106217
|
-
}
|
|
106218
|
-
if (current.type !== "Identifier") {
|
|
106219
|
-
return null;
|
|
106220
|
-
}
|
|
106221
|
-
if (current.name === roots.context && names2[0] === "bindings") {
|
|
106222
|
-
names2.shift();
|
|
106223
|
-
} else if (current.name !== roots.bindings) {
|
|
106224
|
-
return null;
|
|
106225
|
-
}
|
|
106226
|
-
if (names2.length < 2) {
|
|
106227
|
-
throw seoError(key, "Read a field of a bound record, for example bindings.<name>.<field>", node);
|
|
106228
|
-
}
|
|
106229
|
-
return new FieldRead(names2[0], names2.slice(1), node);
|
|
106230
|
-
}
|
|
106231
|
-
function isTextTemplateCall(node) {
|
|
106232
|
-
return node.type === "CallExpression" && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.object.type === "Identifier" && node.callee.object.name === "text" && node.callee.property.name === "template";
|
|
106233
|
-
}
|
|
106234
|
-
function templatePlaceholders(template) {
|
|
106235
|
-
return [...template.matchAll(PLACEHOLDER)].map((match) => match[1]);
|
|
106236
|
-
}
|
|
106237
|
-
function templateLiteralSuggestion(source, node) {
|
|
106238
|
-
const used = /* @__PURE__ */ new Map();
|
|
106239
|
-
let template = "";
|
|
106240
|
-
node.quasis.forEach((quasi, index3) => {
|
|
106241
|
-
template += quasi.value.cooked;
|
|
106242
|
-
const expression2 = node.expressions[index3];
|
|
106243
|
-
if (expression2 === void 0) {
|
|
106244
|
-
return;
|
|
106245
|
-
}
|
|
106246
|
-
const text2 = sliceOf(source, expression2);
|
|
106247
|
-
const last2 = text2.split(".").at(-1).replaceAll(/[^A-Za-z0-9_]/g, "") || `value${index3 + 1}`;
|
|
106248
|
-
let name = last2;
|
|
106249
|
-
for (let suffix = 2; used.has(name) && used.get(name) !== text2; suffix += 1) {
|
|
106250
|
-
name = `${last2}${suffix}`;
|
|
106251
|
-
}
|
|
106252
|
-
used.set(name, text2);
|
|
106253
|
-
template += `{{${name}}}`;
|
|
106254
|
-
});
|
|
106255
|
-
const values = [...used].map(([name, text2]) => `${name}: ${text2}`).join(", ");
|
|
106256
|
-
return `text.template(${JSON.stringify(template)}, { ${values} })`;
|
|
106257
|
-
}
|
|
106258
|
-
function checkPlaceholders(key, template, values, templateNode, valuesNode) {
|
|
106259
|
-
const placeholders2 = templatePlaceholders(template);
|
|
106260
|
-
for (const placeholder2 of placeholders2) {
|
|
106261
|
-
if (!values.has(placeholder2)) {
|
|
106262
|
-
throw seoError(key, `The template uses {{${placeholder2}}}, but the values have no "${placeholder2}"`, valuesNode);
|
|
106263
|
-
}
|
|
106264
|
-
}
|
|
106265
|
-
for (const name of values.keys()) {
|
|
106266
|
-
if (!placeholders2.includes(name)) {
|
|
106267
|
-
throw seoError(key, `The value "${name}" is not used. Add {{${name}}} to the template`, templateNode);
|
|
106268
|
-
}
|
|
106269
|
-
}
|
|
106270
|
-
}
|
|
106271
|
-
function templateValue(key, node, roots) {
|
|
106272
|
-
const [templateNode, valuesNode, ...rest] = node.arguments;
|
|
106273
|
-
const template = templateNode === void 0 ? void 0 : staticText(templateNode);
|
|
106274
|
-
if (template === void 0 || rest.length > 0) {
|
|
106275
|
-
throw seoError(key, "text.template takes a string literal template and an object of values", node);
|
|
106276
|
-
}
|
|
106277
|
-
const values = /* @__PURE__ */ new Map();
|
|
106278
|
-
if (valuesNode !== void 0) {
|
|
106279
|
-
if (valuesNode.type !== "ObjectExpression") {
|
|
106280
|
-
throw seoError(key, "The values of text.template must be an object literal", valuesNode);
|
|
106281
|
-
}
|
|
106282
|
-
for (const property of valuesNode.properties) {
|
|
106283
|
-
if (property.type !== "ObjectProperty" || property.shorthand) {
|
|
106284
|
-
throw seoError(key, "Each text.template value must be written as name: value", property);
|
|
106285
|
-
}
|
|
106286
|
-
const name = propertyKey(property);
|
|
106287
|
-
const literal = staticText(property.value);
|
|
106288
|
-
if (literal !== void 0) {
|
|
106289
|
-
values.set(name, literal);
|
|
106290
|
-
continue;
|
|
106291
|
-
}
|
|
106292
|
-
const read2 = memberPath3(key, property.value, roots);
|
|
106293
|
-
if (read2 === null) {
|
|
106294
|
-
throw seoError(
|
|
106295
|
-
key,
|
|
106296
|
-
`The value "${name}" must be a string literal or a field of a bound record, for example bindings.<name>.<field>`,
|
|
106297
|
-
property.value
|
|
106298
|
-
);
|
|
106299
|
-
}
|
|
106300
|
-
values.set(name, read2);
|
|
106301
|
-
}
|
|
106302
|
-
}
|
|
106303
|
-
checkPlaceholders(key, template, values, templateNode, valuesNode ?? node);
|
|
106304
|
-
return { kind: "text", template, values, node };
|
|
106305
|
-
}
|
|
106306
|
-
function isAssetRead(node, assets) {
|
|
106307
|
-
if (assets === null) {
|
|
106308
|
-
return false;
|
|
106309
|
-
}
|
|
106310
|
-
const value = unwrap3(node);
|
|
106311
|
-
let current = value;
|
|
106312
|
-
while (current.type === "MemberExpression" || current.type === "OptionalMemberExpression") {
|
|
106313
|
-
current = unwrap3(current.object);
|
|
106314
|
-
}
|
|
106315
|
-
return current !== value && current.type === "Identifier" && current.name === assets.local;
|
|
106316
|
-
}
|
|
106317
|
-
function functionValue(key, functionNode, source, assets) {
|
|
106318
|
-
const roots = bindingRoots(key, functionNode);
|
|
106319
|
-
const expression2 = unwrap3(returnedExpression(key, functionNode));
|
|
106320
|
-
const literal = staticText(expression2);
|
|
106321
|
-
if (isAssetRead(expression2, assets)) {
|
|
106322
|
-
throw seoError(key, "Write the asset as seo: { image: Assets.<Name>.key }, not as a function", expression2);
|
|
106323
|
-
}
|
|
106324
|
-
if (literal !== void 0) {
|
|
106325
|
-
return staticValue2(key, literal, expression2);
|
|
106326
|
-
}
|
|
106327
|
-
if (isTextTemplateCall(expression2)) {
|
|
106328
|
-
if (key === "image") {
|
|
106329
|
-
throw seoError(key, "An image is a file field of a bound record, not a text", expression2);
|
|
106330
|
-
}
|
|
106331
|
-
return templateValue(key, expression2, roots);
|
|
106332
|
-
}
|
|
106333
|
-
const read2 = memberPath3(key, expression2, roots);
|
|
106334
|
-
if (read2 !== null) {
|
|
106335
|
-
return { kind: "field", read: read2 };
|
|
106336
|
-
}
|
|
106337
|
-
if (expression2.type === "TemplateLiteral") {
|
|
106338
|
-
throw seoError(
|
|
106339
|
-
key,
|
|
106340
|
-
`A template literal cannot become a server value. Write ${templateLiteralSuggestion(source, expression2)}`,
|
|
106341
|
-
expression2
|
|
106342
|
-
);
|
|
106343
|
-
}
|
|
106344
|
-
throw seoError(
|
|
106345
|
-
key,
|
|
106346
|
-
`${expression2.type} cannot become a server value. A seo function returns a field of a bound record, a string, or text.template(...)`,
|
|
106347
|
-
expression2
|
|
105871
|
+
function parserDisagreement(path) {
|
|
105872
|
+
return new Error(
|
|
105873
|
+
`The workspace check cannot parse ${path}, although the build parses it, so the build stops without checking it. Rewrite the syntax of ${path} that the oxc parser refuses, and report the file to the Diagonal platform team.`
|
|
106348
105874
|
);
|
|
106349
105875
|
}
|
|
106350
|
-
function
|
|
106351
|
-
|
|
106352
|
-
|
|
106353
|
-
}
|
|
106354
|
-
|
|
106355
|
-
|
|
106356
|
-
key,
|
|
106357
|
-
"An image is an asset (Assets.<Name>.key), the id of a public Media Library file, or a file field of a bound record: ({ bindings }) => bindings.<name>.<field>",
|
|
106358
|
-
node
|
|
106359
|
-
);
|
|
106360
|
-
}
|
|
106361
|
-
return { kind: "static", value: text2 };
|
|
106362
|
-
}
|
|
106363
|
-
function seoValue(key, node, source, assets) {
|
|
106364
|
-
const value = unwrap3(node);
|
|
106365
|
-
if (value.type === "NullLiteral" || value.type === "Identifier" && value.name === "undefined") {
|
|
106366
|
-
return null;
|
|
106367
|
-
}
|
|
106368
|
-
if (isAssetRead(value, assets)) {
|
|
106369
|
-
if (key !== "image") {
|
|
106370
|
-
throw seoError(key, "An asset is an image. Use it in seo.image", value);
|
|
106371
|
-
}
|
|
106372
|
-
return { kind: "asset", key: staticValue(value, { assets }), node: value };
|
|
106373
|
-
}
|
|
106374
|
-
const literal = staticText(value);
|
|
106375
|
-
if (literal !== void 0) {
|
|
106376
|
-
return staticValue2(key, literal, value);
|
|
106377
|
-
}
|
|
106378
|
-
if (isSeoFunction(value)) {
|
|
106379
|
-
const result = functionValue(key, value, source, assets);
|
|
106380
|
-
return result === null ? null : { ...result, function: value };
|
|
106381
|
-
}
|
|
106382
|
-
throw seoError(
|
|
106383
|
-
key,
|
|
106384
|
-
`${value.type} is not allowed. Write a string, or a function of the bound records: ({ bindings }) => ...`,
|
|
106385
|
-
value
|
|
106386
|
-
);
|
|
106387
|
-
}
|
|
106388
|
-
function isSeoFunction(node) {
|
|
106389
|
-
const value = unwrap3(node);
|
|
106390
|
-
return value.type === "ArrowFunctionExpression" || value.type === "FunctionExpression";
|
|
106391
|
-
}
|
|
106392
|
-
function seoProperty(optionsNode) {
|
|
106393
|
-
const node = unwrap3(optionsNode);
|
|
106394
|
-
return node.type === "ObjectExpression" ? node.properties.find((property) => property.type === "ObjectProperty" && propertyKey(property) === "seo") : void 0;
|
|
106395
|
-
}
|
|
106396
|
-
function seoValueNodes(node) {
|
|
106397
|
-
const value = unwrap3(node);
|
|
106398
|
-
if (value.type !== "ObjectExpression") {
|
|
106399
|
-
throw new SourceError('"seo" must be an object: { title, description, image }', node);
|
|
106400
|
-
}
|
|
106401
|
-
const nodes = /* @__PURE__ */ new Map();
|
|
106402
|
-
for (const property of value.properties) {
|
|
106403
|
-
if (property.type !== "ObjectProperty") {
|
|
106404
|
-
throw new SourceError('"seo" holds only title, description, and image', property);
|
|
106405
|
-
}
|
|
106406
|
-
const key = propertyKey(property);
|
|
106407
|
-
if (!SEO_KEYS.includes(key)) {
|
|
106408
|
-
throw new SourceError(`Unknown seo option "${key}". Use title, description, or image`, property.key);
|
|
105876
|
+
function moduleParseDiagnostic(root, path, modulePath) {
|
|
105877
|
+
try {
|
|
105878
|
+
parseSource(readFileSync9(join12(root, modulePath), "utf8"), { jsx: modulePath.endsWith("x") });
|
|
105879
|
+
} catch (error) {
|
|
105880
|
+
if (error instanceof SyntaxError) {
|
|
105881
|
+
return diagnosticAt(path, null, `${modulePath} does not parse: ${error.message}`);
|
|
106409
105882
|
}
|
|
106410
|
-
|
|
105883
|
+
throw error;
|
|
106411
105884
|
}
|
|
106412
|
-
|
|
105885
|
+
throw parserDisagreement(modulePath);
|
|
106413
105886
|
}
|
|
106414
|
-
function
|
|
106415
|
-
|
|
106416
|
-
|
|
106417
|
-
seo[key] = seoValue(key, valueNode, source, assets);
|
|
105887
|
+
function unitOf(root, path, outcome, modules) {
|
|
105888
|
+
if (outcome.failure !== void 0) {
|
|
105889
|
+
throw outcome.failure.name === "TypeError" ? new TypeError(outcome.failure.message) : new Error(outcome.failure.message);
|
|
106418
105890
|
}
|
|
106419
|
-
|
|
106420
|
-
}
|
|
106421
|
-
function seoFieldReads(seo) {
|
|
106422
|
-
const reads = [];
|
|
106423
|
-
for (const [key, value] of Object.entries(seo)) {
|
|
106424
|
-
if (value?.kind === "field") {
|
|
106425
|
-
reads.push({ key, read: value.read, inTemplate: false });
|
|
106426
|
-
}
|
|
106427
|
-
if (value?.kind === "text") {
|
|
106428
|
-
for (const replacement of value.values.values()) {
|
|
106429
|
-
if (replacement instanceof FieldRead) {
|
|
106430
|
-
reads.push({ key, read: replacement, inTemplate: true });
|
|
106431
|
-
}
|
|
106432
|
-
}
|
|
106433
|
-
}
|
|
105891
|
+
if (outcome.error !== void 0) {
|
|
105892
|
+
return { diagnostic: outcome.error };
|
|
106434
105893
|
}
|
|
106435
|
-
|
|
106436
|
-
}
|
|
106437
|
-
function bindingResolver(read2) {
|
|
106438
|
-
return { $type: "page.binding", $value: { key: read2.key } };
|
|
106439
|
-
}
|
|
106440
|
-
function seoResolver(value) {
|
|
106441
|
-
if (value === null) {
|
|
106442
|
-
return null;
|
|
105894
|
+
if (outcome.moduleDoesNotParse !== void 0) {
|
|
105895
|
+
return { diagnostic: moduleParseDiagnostic(root, path, outcome.moduleDoesNotParse) };
|
|
106443
105896
|
}
|
|
106444
|
-
|
|
106445
|
-
|
|
106446
|
-
|
|
106447
|
-
|
|
106448
|
-
return { asset: value.key };
|
|
106449
|
-
case "field":
|
|
106450
|
-
return bindingResolver(value.read);
|
|
106451
|
-
case "text": {
|
|
106452
|
-
const variables = Object.fromEntries(
|
|
106453
|
-
[...value.values].map(([name, replacement]) => [
|
|
106454
|
-
name,
|
|
106455
|
-
replacement instanceof FieldRead ? bindingResolver(replacement) : replacement
|
|
106456
|
-
])
|
|
106457
|
-
);
|
|
106458
|
-
return { $type: "text.template", $value: textTemplateFields(value.template, variables) };
|
|
106459
|
-
}
|
|
106460
|
-
default:
|
|
106461
|
-
throw new Error(`Unknown seo value kind ${value.kind}`);
|
|
106462
|
-
}
|
|
106463
|
-
}
|
|
106464
|
-
var TEXT_FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
106465
|
-
"text",
|
|
106466
|
-
"email",
|
|
106467
|
-
"url",
|
|
106468
|
-
"phone",
|
|
106469
|
-
"uuid",
|
|
106470
|
-
"select",
|
|
106471
|
-
"date",
|
|
106472
|
-
"datetime",
|
|
106473
|
-
"time",
|
|
106474
|
-
"timezone",
|
|
106475
|
-
"markdown",
|
|
106476
|
-
"color"
|
|
106477
|
-
]);
|
|
106478
|
-
var TEMPLATE_FIELD_TYPES = /* @__PURE__ */ new Set([...TEXT_FIELD_TYPES, "number", "boolean"]);
|
|
106479
|
-
var LIST_RELATION_TYPES = /* @__PURE__ */ new Set(["belongs_to_many", "has_many"]);
|
|
106480
|
-
function seoReadProblem({ key, read: read2, inTemplate }, bindings, resourcesBySlug) {
|
|
106481
|
-
const binding = bindings.get(read2.binding);
|
|
106482
|
-
if (binding === void 0) {
|
|
106483
|
-
const names2 = [...bindings.keys()];
|
|
106484
|
-
return `"${read2.binding}" is not a binding of this page. ${names2.length === 0 ? "The page has no bindings" : `Its bindings are ${names2.join(", ")}`}`;
|
|
106485
|
-
}
|
|
106486
|
-
let resource = resourcesBySlug.get(binding.resource);
|
|
106487
|
-
let field2 = null;
|
|
106488
|
-
for (const [index3, name] of read2.fields.entries()) {
|
|
106489
|
-
if (resource === void 0) {
|
|
106490
|
-
return null;
|
|
106491
|
-
}
|
|
106492
|
-
const last2 = index3 === read2.fields.length - 1;
|
|
106493
|
-
field2 = name === "id" ? { key: "id", type: "uuid", settings: {} } : resource.fields.find((item) => item.key === name);
|
|
106494
|
-
if (field2 === void 0) {
|
|
106495
|
-
return `${resource.name} has no field "${name}". Its fields are id, ${resource.fields.map((item) => item.key).join(", ")}`;
|
|
106496
|
-
}
|
|
106497
|
-
if (last2) {
|
|
106498
|
-
break;
|
|
106499
|
-
}
|
|
106500
|
-
if (field2.type !== "relation") {
|
|
106501
|
-
return `"${name}" is a ${field2.type} field and has no fields`;
|
|
106502
|
-
}
|
|
106503
|
-
if (index3 > 0) {
|
|
106504
|
-
return `${read2.key} reads through two relations. A seo value reads at most one relation`;
|
|
106505
|
-
}
|
|
106506
|
-
if (LIST_RELATION_TYPES.has(field2.settings?.type)) {
|
|
106507
|
-
return `"${name}" is a list of records. A seo value reads one record`;
|
|
106508
|
-
}
|
|
106509
|
-
if (!binding.relations.includes(name)) {
|
|
106510
|
-
return `"${name}" is a relation that the binding does not load. Add it: ${read2.binding}: { relations: ['${name}'] }`;
|
|
106511
|
-
}
|
|
106512
|
-
resource = resourcesBySlug.get(field2.settings.resource);
|
|
106513
|
-
}
|
|
106514
|
-
if (key === "image") {
|
|
106515
|
-
if (field2.type !== "file_reference") {
|
|
106516
|
-
return `${read2.key} is a ${field2.type} field. An image is a file_reference field`;
|
|
106517
|
-
}
|
|
106518
|
-
if (field2.settings?.visibility !== "public") {
|
|
106519
|
-
return `${read2.key} is a private file field. A social image must be public: settings: { visibility: 'public' }`;
|
|
106520
|
-
}
|
|
106521
|
-
return null;
|
|
106522
|
-
}
|
|
106523
|
-
if (field2.type === "relation") {
|
|
106524
|
-
return `${read2.key} is a relation. Read one of its fields, for example ${read2.key}.name`;
|
|
106525
|
-
}
|
|
106526
|
-
const allowed = inTemplate ? TEMPLATE_FIELD_TYPES : TEXT_FIELD_TYPES;
|
|
106527
|
-
if (!allowed.has(field2.type)) {
|
|
106528
|
-
return inTemplate || !TEMPLATE_FIELD_TYPES.has(field2.type) ? `${read2.key} is a ${field2.type} field, which has no text form` : `${read2.key} is a ${field2.type} field. Use text.template to make it text`;
|
|
106529
|
-
}
|
|
106530
|
-
return null;
|
|
106531
|
-
}
|
|
106532
|
-
|
|
106533
|
-
// scripts/lib/runtime-build/page-options-migration.mjs
|
|
106534
|
-
function movableMetaValue(value) {
|
|
106535
|
-
if (value !== null && typeof value !== "string" && !isPlainObject2(value)) {
|
|
106536
|
-
return void 0;
|
|
106537
|
-
}
|
|
106538
|
-
const normalized = normalizeMetaValue(value);
|
|
106539
|
-
return disallowedMetaResolver(normalized) === null ? normalized : void 0;
|
|
106540
|
-
}
|
|
106541
|
-
function definePageOptions2(ast) {
|
|
105897
|
+
const { unit } = outcome;
|
|
105898
|
+
const closure = (paths) => new Map(paths.map((modulePath) => [modulePath, modules[modulePath]]));
|
|
105899
|
+
let prelude;
|
|
105900
|
+
let draftPrelude;
|
|
106542
105901
|
try {
|
|
106543
|
-
|
|
106544
|
-
|
|
106545
|
-
|
|
105902
|
+
prelude = appPrelude(closure(unit.modules));
|
|
105903
|
+
draftPrelude = unit.draftModules === null ? prelude : `${appPrelude(closure(unit.draftModules))}
|
|
105904
|
+
const ${DRAFT_PAGES_NAME} = ${APP_IMPORT}(${JSON.stringify(GENERATED_PAGES_PATH)}).Pages;
|
|
105905
|
+
`;
|
|
106546
105906
|
} catch (error) {
|
|
106547
105907
|
if (error instanceof SourceError) {
|
|
106548
|
-
return
|
|
105908
|
+
return { diagnostic: diagnosticFromError(path, error) };
|
|
106549
105909
|
}
|
|
106550
105910
|
throw error;
|
|
106551
105911
|
}
|
|
106552
|
-
}
|
|
106553
|
-
|
|
105912
|
+
const code2 = `${prelude}${unit.bindings}${unit.body}`;
|
|
105913
|
+
let compiled;
|
|
106554
105914
|
try {
|
|
106555
|
-
|
|
105915
|
+
compiled = transformJsx(code2);
|
|
106556
105916
|
} catch (error) {
|
|
106557
|
-
if (error instanceof
|
|
106558
|
-
return
|
|
105917
|
+
if (error instanceof SyntaxError) {
|
|
105918
|
+
return { diagnostic: diagnostic(path, unit.functionLine, unit.functionColumn, `JSX compile failed: ${error.message}`) };
|
|
106559
105919
|
}
|
|
106560
105920
|
throw error;
|
|
106561
105921
|
}
|
|
106562
|
-
}
|
|
106563
|
-
|
|
106564
|
-
|
|
106565
|
-
|
|
106566
|
-
|
|
106567
|
-
|
|
106568
|
-
|
|
106569
|
-
|
|
106570
|
-
|
|
106571
|
-
|
|
106572
|
-
|
|
106573
|
-
|
|
106574
|
-
|
|
106575
|
-
|
|
106576
|
-
|
|
106577
|
-
|
|
106578
|
-
|
|
106579
|
-
|
|
106580
|
-
const edits = [];
|
|
106581
|
-
if (byKey.has("params") && !byKey.has("bindings")) {
|
|
106582
|
-
const key = byKey.get("params").key;
|
|
106583
|
-
edits.push({ start: key.start, end: key.end, text: "bindings" });
|
|
106584
|
-
}
|
|
106585
|
-
const moved = [];
|
|
106586
|
-
let keepsAllowedResolver = false;
|
|
106587
|
-
if (!byKey.has("seo")) {
|
|
106588
|
-
for (const [flat, grouped] of FLAT_SEO_KEYS) {
|
|
106589
|
-
const property = byKey.get(flat);
|
|
106590
|
-
if (property === void 0) {
|
|
106591
|
-
continue;
|
|
106592
|
-
}
|
|
106593
|
-
const value = movableMetaValue(propertyValue2(options, property));
|
|
106594
|
-
if (value === void 0) {
|
|
106595
|
-
continue;
|
|
106596
|
-
}
|
|
106597
|
-
if (value !== null && typeof value !== "string") {
|
|
106598
|
-
keepsAllowedResolver = true;
|
|
106599
|
-
continue;
|
|
106600
|
-
}
|
|
106601
|
-
const text2 = value === null ? "null" : property.value.type === "StringLiteral" && property.value.value === value ? sliceOf(source, property.value) : quotedLiteral(value);
|
|
106602
|
-
moved.push({ property, grouped, text: text2 });
|
|
106603
|
-
}
|
|
106604
|
-
}
|
|
106605
|
-
if (moved.length > 0 && !keepsAllowedResolver) {
|
|
106606
|
-
const entries = moved.toSorted((left, right) => SEO_KEYS.indexOf(left.grouped) - SEO_KEYS.indexOf(right.grouped)).map((entry) => `${entry.grouped}: ${entry.text}`);
|
|
106607
|
-
const last2 = moved.reduce(
|
|
106608
|
-
(latest, entry) => entry.property.start > latest.property.start ? entry : latest
|
|
106609
|
-
);
|
|
106610
|
-
const singleLine = options.loc.start.line === options.loc.end.line;
|
|
106611
|
-
const indent = lineIndent(source, last2.property.start);
|
|
106612
|
-
const seoText = singleLine ? `seo: { ${entries.join(", ")} }` : `seo: {
|
|
106613
|
-
${entries.map((entry) => `${indent} ${entry}`).join(",\n")}
|
|
106614
|
-
${indent}}`;
|
|
106615
|
-
for (const entry of moved) {
|
|
106616
|
-
if (entry === last2) {
|
|
106617
|
-
continue;
|
|
105922
|
+
const { code: lintCode, prefixLine, prefixColumn, prefixLength, suffixLine, suffixColumn, suffixLength, pagesNamespaces } = unit.lint;
|
|
105923
|
+
return {
|
|
105924
|
+
unit: {
|
|
105925
|
+
source: code2,
|
|
105926
|
+
compiled_code: compiled,
|
|
105927
|
+
// What a draft of this unit runs before its own code: the page builder
|
|
105928
|
+
// previews a page's factory body without its imports.
|
|
105929
|
+
app_prelude: draftPrelude === "" && unit.bindings === "" ? null : `${draftPrelude}${unit.bindings}`,
|
|
105930
|
+
lint: {
|
|
105931
|
+
code: lintCode,
|
|
105932
|
+
prefixLine,
|
|
105933
|
+
prefixColumn,
|
|
105934
|
+
prefixLength,
|
|
105935
|
+
suffixLine,
|
|
105936
|
+
suffixColumn,
|
|
105937
|
+
suffixLength,
|
|
105938
|
+
appModules: Object.fromEntries(unit.modules.map((modulePath) => [modulePath, modules[modulePath].source])),
|
|
105939
|
+
pagesNamespaces
|
|
106618
105940
|
}
|
|
106619
|
-
const next = properties[properties.indexOf(entry.property) + 1];
|
|
106620
|
-
edits.push({ start: entry.property.start, end: removalEnd(entry.property, next), text: "" });
|
|
106621
105941
|
}
|
|
106622
|
-
|
|
106623
|
-
}
|
|
106624
|
-
if (edits.length === 0) {
|
|
106625
|
-
return source;
|
|
106626
|
-
}
|
|
106627
|
-
let result = source;
|
|
106628
|
-
for (const edit of edits.toSorted((left, right) => right.start - left.start)) {
|
|
106629
|
-
result = `${result.slice(0, edit.start)}${edit.text}${result.slice(edit.end)}`;
|
|
106630
|
-
}
|
|
106631
|
-
return result;
|
|
105942
|
+
};
|
|
106632
105943
|
}
|
|
106633
105944
|
|
|
106634
105945
|
// scripts/lib/runtime-build/resources.mjs
|
|
@@ -106654,18 +105965,18 @@ function resourceChildArgument(kind, ast) {
|
|
|
106654
105965
|
|
|
106655
105966
|
// scripts/lib/runtime-build/sdk-packages.mjs
|
|
106656
105967
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
106657
|
-
import { existsSync as existsSync6, readFileSync as
|
|
106658
|
-
import { join as
|
|
105968
|
+
import { existsSync as existsSync6, readFileSync as readFileSync10 } from "node:fs";
|
|
105969
|
+
import { join as join13 } from "node:path";
|
|
106659
105970
|
var DIAGONAL_PACKAGE = /^@diagonal(-hq)?\//;
|
|
106660
105971
|
var TARBALL_VERSION = /-(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)\.tgz$/;
|
|
106661
105972
|
var EXACT_VERSION = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
106662
105973
|
function readPackageFiles(root, diagnostics) {
|
|
106663
105974
|
const read2 = (path) => {
|
|
106664
|
-
if (!existsSync6(
|
|
105975
|
+
if (!existsSync6(join13(root, path))) {
|
|
106665
105976
|
return null;
|
|
106666
105977
|
}
|
|
106667
105978
|
try {
|
|
106668
|
-
return JSON.parse(
|
|
105979
|
+
return JSON.parse(readFileSync10(join13(root, path), "utf8"));
|
|
106669
105980
|
} catch (error) {
|
|
106670
105981
|
if (!(error instanceof SyntaxError)) {
|
|
106671
105982
|
throw error;
|
|
@@ -106867,8 +106178,8 @@ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
|
106867
106178
|
|
|
106868
106179
|
// scripts/lib/test-code/files.mjs
|
|
106869
106180
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
106870
|
-
import { readFileSync as
|
|
106871
|
-
import { dirname as dirname5, join as
|
|
106181
|
+
import { readFileSync as readFileSync11 } from "node:fs";
|
|
106182
|
+
import { dirname as dirname5, join as join14, resolve as resolve5 } from "node:path";
|
|
106872
106183
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
106873
106184
|
|
|
106874
106185
|
// app/testing/resources/js/components/testCodeScope.ts
|
|
@@ -106966,7 +106277,7 @@ function readTestCodeScope() {
|
|
|
106966
106277
|
// can differ from the version in this checkout's node_modules.
|
|
106967
106278
|
PLAYWRIGHT_DECLARATIONS.map((path) => [
|
|
106968
106279
|
path,
|
|
106969
|
-
|
|
106280
|
+
readFileSync11(join14(root, "test-runner/playwright-types", path), "utf8")
|
|
106970
106281
|
])
|
|
106971
106282
|
)
|
|
106972
106283
|
}
|
|
@@ -107024,9 +106335,9 @@ function defaultCall(ast) {
|
|
|
107024
106335
|
if (statement2 === void 0) {
|
|
107025
106336
|
throw new SourceError("The file has no default export", ast.program);
|
|
107026
106337
|
}
|
|
107027
|
-
return
|
|
106338
|
+
return unwrap3(statement2.declaration);
|
|
107028
106339
|
}
|
|
107029
|
-
function
|
|
106340
|
+
function unwrap3(node) {
|
|
107030
106341
|
let current = node;
|
|
107031
106342
|
while (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "ParenthesizedExpression") {
|
|
107032
106343
|
current = current.expression;
|
|
@@ -107413,15 +106724,15 @@ function buildTest(file2, context, diagnostics) {
|
|
|
107413
106724
|
return null;
|
|
107414
106725
|
}
|
|
107415
106726
|
const hasSetup = handlers.setup !== void 0;
|
|
107416
|
-
const
|
|
106727
|
+
const compile = (phase, setupSource = null) => compileTestScript(
|
|
107417
106728
|
file2.path,
|
|
107418
106729
|
phaseScriptSource(file2.source, file2.ast, handlers[phase], phase, hasSetup),
|
|
107419
106730
|
context,
|
|
107420
106731
|
diagnostics,
|
|
107421
106732
|
setupSource
|
|
107422
106733
|
);
|
|
107423
|
-
const setup2 = hasSetup ?
|
|
107424
|
-
const assert4 = handlers.assert === void 0 ? null :
|
|
106734
|
+
const setup2 = hasSetup ? compile("setup") : null;
|
|
106735
|
+
const assert4 = handlers.assert === void 0 ? null : compile("assert", setup2?.source ?? null);
|
|
107425
106736
|
if (context.resourcesComplete) {
|
|
107426
106737
|
context.typeChecks.push({
|
|
107427
106738
|
path: file2.path,
|
|
@@ -107551,693 +106862,6 @@ ${resources}};
|
|
|
107551
106862
|
);
|
|
107552
106863
|
}
|
|
107553
106864
|
|
|
107554
|
-
// scripts/lib/runtime-build/ui-sources.mjs
|
|
107555
|
-
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
107556
|
-
import { existsSync as existsSync7 } from "node:fs";
|
|
107557
|
-
import { join as join14 } from "node:path";
|
|
107558
|
-
|
|
107559
|
-
// app/pages/resources/js/pageRuntime/compiler/draftPagesName.ts
|
|
107560
|
-
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
107561
|
-
var DRAFT_PAGES_NAME = "__draftPages";
|
|
107562
|
-
|
|
107563
|
-
// scripts/lib/runtime-build/ui-sources.mjs
|
|
107564
|
-
var PAGE_AUTHORIZERS = /* @__PURE__ */ new Set(["authenticated"]);
|
|
107565
|
-
var PAGE_KEYS = /* @__PURE__ */ new Set([
|
|
107566
|
-
"uid",
|
|
107567
|
-
"route",
|
|
107568
|
-
"name",
|
|
107569
|
-
"title",
|
|
107570
|
-
"description",
|
|
107571
|
-
"ogImage",
|
|
107572
|
-
"headHtml",
|
|
107573
|
-
"layout",
|
|
107574
|
-
"renderProfile",
|
|
107575
|
-
"sitemap",
|
|
107576
|
-
"domain",
|
|
107577
|
-
"paused",
|
|
107578
|
-
"authorizer",
|
|
107579
|
-
"bindings",
|
|
107580
|
-
"params",
|
|
107581
|
-
"seo"
|
|
107582
|
-
]);
|
|
107583
|
-
var PAGE_RENDER_PROFILES = /* @__PURE__ */ new Set(["standard", "print"]);
|
|
107584
|
-
var PARAM_KEYS = /* @__PURE__ */ new Set(["resource", "lookupField", "relations", "scope"]);
|
|
107585
|
-
var RECORD_SCOPES = /* @__PURE__ */ new Set(["active", "activeOrArchived", "archived"]);
|
|
107586
|
-
function isNamed(node, name) {
|
|
107587
|
-
return (node.type === "Identifier" || node.type === "JSXIdentifier") && node.name === name;
|
|
107588
|
-
}
|
|
107589
|
-
function customComponentName(node) {
|
|
107590
|
-
const isMember2 = node.type === "MemberExpression" || node.type === "JSXMemberExpression";
|
|
107591
|
-
if (!isMember2) {
|
|
107592
|
-
return null;
|
|
107593
|
-
}
|
|
107594
|
-
const object = node.object;
|
|
107595
|
-
const objectIsSdkCustom = (object.type === "MemberExpression" || object.type === "JSXMemberExpression") && isNamed(object.object, "Sdk") && !object.computed && isNamed(object.property, "Custom");
|
|
107596
|
-
if (!objectIsSdkCustom) {
|
|
107597
|
-
return null;
|
|
107598
|
-
}
|
|
107599
|
-
if (node.computed) {
|
|
107600
|
-
return node.property.type === "StringLiteral" ? node.property.value : null;
|
|
107601
|
-
}
|
|
107602
|
-
return node.property.name;
|
|
107603
|
-
}
|
|
107604
|
-
function customComponentReferences(root) {
|
|
107605
|
-
const references = [];
|
|
107606
|
-
const pending = [root];
|
|
107607
|
-
while (pending.length > 0) {
|
|
107608
|
-
const node = pending.pop();
|
|
107609
|
-
const name = customComponentName(node);
|
|
107610
|
-
if (name !== null) {
|
|
107611
|
-
references.push({ name, node });
|
|
107612
|
-
}
|
|
107613
|
-
pending.push(...childNodes(node));
|
|
107614
|
-
}
|
|
107615
|
-
return references.toSorted((left, right) => left.node.start - right.node.start);
|
|
107616
|
-
}
|
|
107617
|
-
function compile(code2, functionNode) {
|
|
107618
|
-
try {
|
|
107619
|
-
return transformJsx(code2);
|
|
107620
|
-
} catch (error) {
|
|
107621
|
-
if (error instanceof SyntaxError) {
|
|
107622
|
-
throw new SourceError(`JSX compile failed: ${error.message}`, functionNode);
|
|
107623
|
-
}
|
|
107624
|
-
throw error;
|
|
107625
|
-
}
|
|
107626
|
-
}
|
|
107627
|
-
var FACTORY_PREFIX = "return (";
|
|
107628
|
-
var FACTORY_SUFFIX = ");";
|
|
107629
|
-
var SDK_TYPE_DECLARATIONS = {
|
|
107630
|
-
LayoutProps: "{ children?: React.ReactNode }"
|
|
107631
|
-
};
|
|
107632
|
-
var AUTHORING_TYPE_PARAMETERS = {
|
|
107633
|
-
PageComponent: "<TRoute extends string = string, TBindings = {}>",
|
|
107634
|
-
PageProps: "<TRoute extends string = string, TBindings = {}>",
|
|
107635
|
-
PageRecord: "<R, TLoaded = never>"
|
|
107636
|
-
};
|
|
107637
|
-
function blankOut(text2) {
|
|
107638
|
-
return text2.replaceAll(/[^\n]/g, " ");
|
|
107639
|
-
}
|
|
107640
|
-
function keptTypeRange(statement2, helpers) {
|
|
107641
|
-
if (helpers.includes(statement2)) {
|
|
107642
|
-
return [statement2.start, statement2.end];
|
|
107643
|
-
}
|
|
107644
|
-
if (statement2.type === "ExportNamedDeclaration" && helpers.includes(statement2.declaration)) {
|
|
107645
|
-
return [statement2.declaration.start, statement2.declaration.end];
|
|
107646
|
-
}
|
|
107647
|
-
if (statement2.type === "TSTypeAliasDeclaration" || statement2.type === "TSInterfaceDeclaration") {
|
|
107648
|
-
return [statement2.start, statement2.end];
|
|
107649
|
-
}
|
|
107650
|
-
const declaration = statement2.type === "ExportNamedDeclaration" ? statement2.declaration : null;
|
|
107651
|
-
if (declaration?.type === "TSTypeAliasDeclaration" || declaration?.type === "TSInterfaceDeclaration") {
|
|
107652
|
-
return [declaration.start, statement2.end];
|
|
107653
|
-
}
|
|
107654
|
-
return null;
|
|
107655
|
-
}
|
|
107656
|
-
var LAZY_IMPORT = "__lazy(";
|
|
107657
|
-
function lintUnit(original, ast, functionNode, helpers, app, functionBinding) {
|
|
107658
|
-
let source = original;
|
|
107659
|
-
for (const lazy of app.lazy) {
|
|
107660
|
-
source = source.slice(0, lazy.start) + LAZY_IMPORT + source.slice(lazy.start + LAZY_IMPORT.length);
|
|
107661
|
-
}
|
|
107662
|
-
let kept = blankOut(source);
|
|
107663
|
-
const ranges = ast.program.body.map((statement2) => keptTypeRange(statement2, helpers)).filter((range) => range !== null);
|
|
107664
|
-
for (const [start, end] of ranges) {
|
|
107665
|
-
kept = kept.slice(0, start) + source.slice(start, end) + kept.slice(end);
|
|
107666
|
-
}
|
|
107667
|
-
const trailing = kept.slice(functionNode.end);
|
|
107668
|
-
kept = kept.slice(0, functionNode.start);
|
|
107669
|
-
for (const binding of app.bindings.toSorted((left, right) => right.start - left.start)) {
|
|
107670
|
-
const replaced = `${binding.lintText ?? binding.text}${"\n".repeat(newlines(binding.original))}`;
|
|
107671
|
-
kept = kept.slice(0, binding.start) + replaced + kept.slice(binding.end);
|
|
107672
|
-
}
|
|
107673
|
-
const importedTypes = ast.program.body.filter((statement2) => statement2.type === "ImportDeclaration").flatMap(
|
|
107674
|
-
(statement2) => app.imports.some((item) => item.statement === statement2) ? appTypeAliases(statement2, app) : foreignTypeAliases(statement2)
|
|
107675
|
-
);
|
|
107676
|
-
const code2 = [
|
|
107677
|
-
kept,
|
|
107678
|
-
functionBinding === null ? FACTORY_PREFIX : "",
|
|
107679
|
-
functionNode.type === "Identifier" ? "" : sliceOf(source, functionNode),
|
|
107680
|
-
functionBinding === null ? FACTORY_SUFFIX : "",
|
|
107681
|
-
trailing,
|
|
107682
|
-
functionBinding === null ? "" : `
|
|
107683
|
-
return ${functionBinding};`,
|
|
107684
|
-
...importedTypes.map((declaration) => `
|
|
107685
|
-
${declaration}`),
|
|
107686
|
-
lazyDeclaration(app.lazy)
|
|
107687
|
-
].join("");
|
|
107688
|
-
return {
|
|
107689
|
-
code: code2,
|
|
107690
|
-
prefixLine: functionNode.loc.start.line,
|
|
107691
|
-
prefixColumn: functionNode.loc.start.column + 1,
|
|
107692
|
-
prefixLength: functionBinding === null ? FACTORY_PREFIX.length : 0,
|
|
107693
|
-
suffixLine: functionNode.loc.end.line,
|
|
107694
|
-
suffixColumn: functionNode.loc.end.column + 1,
|
|
107695
|
-
suffixLength: functionBinding === null ? FACTORY_SUFFIX.length : 0,
|
|
107696
|
-
appModules: Object.fromEntries([...app.modules].map(([path, module]) => [path, module.source])),
|
|
107697
|
-
pagesNamespaces: pagesNamespaceImports(ast)
|
|
107698
|
-
};
|
|
107699
|
-
}
|
|
107700
|
-
function pagesNamespaceImports(ast) {
|
|
107701
|
-
return ast.program.body.filter((statement2) => statement2.type === "ImportDeclaration" && statement2.source.value === PAGES_SDK_MODULE).flatMap((statement2) => statement2.specifiers).filter((specifier) => specifier.type === "ImportNamespaceSpecifier" && specifier.local.name !== "Sdk").map((specifier) => specifier.local.name);
|
|
107702
|
-
}
|
|
107703
|
-
function lazyDeclaration(lazy) {
|
|
107704
|
-
if (lazy.length === 0) {
|
|
107705
|
-
return "";
|
|
107706
|
-
}
|
|
107707
|
-
const signatures = [...new Map(lazy.map((item) => [item.specifier, item.path]))].map(([specifier, path]) => {
|
|
107708
|
-
const module = path === null ? "any" : `typeof import(${JSON.stringify(`@app/${path}`)})`;
|
|
107709
|
-
return `(path: ${JSON.stringify(specifier)}): Promise<${module}>;`;
|
|
107710
|
-
}).join(" ");
|
|
107711
|
-
return `
|
|
107712
|
-
const __lazy = undefined as unknown as { ${signatures} };`;
|
|
107713
|
-
}
|
|
107714
|
-
function newlines(text2) {
|
|
107715
|
-
return text2.split("\n").length - 1;
|
|
107716
|
-
}
|
|
107717
|
-
function appTypeAliases(statement2, app) {
|
|
107718
|
-
const path = app.imports.find((item) => item.statement === statement2)?.path;
|
|
107719
|
-
if (path === void 0) {
|
|
107720
|
-
return [];
|
|
107721
|
-
}
|
|
107722
|
-
return statement2.specifiers.filter(
|
|
107723
|
-
(specifier) => specifier.type === "ImportSpecifier" && (statement2.importKind === "type" || specifier.importKind === "type")
|
|
107724
|
-
).map(
|
|
107725
|
-
(specifier) => `type ${specifier.local.name} = import(${JSON.stringify(`@app/${path}`)}).${specifier.imported.name ?? specifier.imported.value};`
|
|
107726
|
-
);
|
|
107727
|
-
}
|
|
107728
|
-
var NO_APP_IMPORTS = { imports: [], lazy: [], modules: /* @__PURE__ */ new Map(), bindings: [], prelude: "", draftPrelude: "" };
|
|
107729
|
-
function isTypeOnlySpecifier(statement2, specifier) {
|
|
107730
|
-
return statement2.importKind === "type" || specifier.importKind === "type";
|
|
107731
|
-
}
|
|
107732
|
-
function importedName(specifier) {
|
|
107733
|
-
return specifier.imported.type === "StringLiteral" ? specifier.imported.value : specifier.imported.name;
|
|
107734
|
-
}
|
|
107735
|
-
function foreignBindingText(statement2, { lint, resolve: resolve7 }) {
|
|
107736
|
-
const specifier = statement2.source.value;
|
|
107737
|
-
const kind = importKind(specifier);
|
|
107738
|
-
const statements2 = [];
|
|
107739
|
-
for (const item of statement2.specifiers) {
|
|
107740
|
-
if (isTypeOnlySpecifier(statement2, item)) {
|
|
107741
|
-
continue;
|
|
107742
|
-
}
|
|
107743
|
-
const local = item.local.name;
|
|
107744
|
-
if (kind === "host" && specifier === PAGES_SDK_MODULE) {
|
|
107745
|
-
const name = item.type === "ImportSpecifier" ? importedName(item) : null;
|
|
107746
|
-
if (name === "Sdk") {
|
|
107747
|
-
if (local !== "Sdk") {
|
|
107748
|
-
statements2.push(`const ${local} = Sdk;`);
|
|
107749
|
-
}
|
|
107750
|
-
} else if (name !== null && Object.hasOwn(PAGE_SDK_EXPORTS, name)) {
|
|
107751
|
-
statements2.push(`const ${local} = ${pagesSdkMember(name, { lint })};`);
|
|
107752
|
-
} else if (item.type === "ImportNamespaceSpecifier") {
|
|
107753
|
-
statements2.push(`const ${local} = ${pagesSdkObjectText(null, { lint })};`);
|
|
107754
|
-
} else if (name !== null && Object.hasOwn(PAGE_SDK_TYPES, name)) {
|
|
107755
|
-
} else {
|
|
107756
|
-
statements2.push(`const ${local}: any = undefined;`);
|
|
107757
|
-
}
|
|
107758
|
-
continue;
|
|
107759
|
-
}
|
|
107760
|
-
if (kind === "host") {
|
|
107761
|
-
const host = specifier === "react" ? "React" : null;
|
|
107762
|
-
const name = item.type === "ImportSpecifier" ? importedName(item) : null;
|
|
107763
|
-
if (host === "React" && item.type !== "ImportSpecifier" && local === "React") {
|
|
107764
|
-
continue;
|
|
107765
|
-
}
|
|
107766
|
-
if (host !== null && name !== null) {
|
|
107767
|
-
statements2.push(`const ${local} = ${host}[${JSON.stringify(name)}];`);
|
|
107768
|
-
} else if (host !== null) {
|
|
107769
|
-
statements2.push(`const ${local} = ${host};`);
|
|
107770
|
-
} else if (!isAuthoringModule(specifier)) {
|
|
107771
|
-
statements2.push(`const ${local}: any = undefined;`);
|
|
107772
|
-
}
|
|
107773
|
-
continue;
|
|
107774
|
-
}
|
|
107775
|
-
if (lint) {
|
|
107776
|
-
statements2.push(
|
|
107777
|
-
kind === "style_module" ? `const ${local}: Record<string, string> = {};` : `const ${local}: any = undefined;`
|
|
107778
|
-
);
|
|
107779
|
-
continue;
|
|
107780
|
-
}
|
|
107781
|
-
const value = kind === "package" ? packageExpression(specifier) : kind === "style_module" ? styleModuleExpression(resolve7(specifier)) : null;
|
|
107782
|
-
if (value === null) {
|
|
107783
|
-
statements2.push(`const ${local} = undefined;`);
|
|
107784
|
-
} else if (item.type === "ImportSpecifier") {
|
|
107785
|
-
statements2.push(`const ${local} = ${value}[${JSON.stringify(importedName(item))}];`);
|
|
107786
|
-
} else if (item.type === "ImportDefaultSpecifier" && kind === "package") {
|
|
107787
|
-
statements2.push(`const ${local} = ${value}.default;`);
|
|
107788
|
-
} else {
|
|
107789
|
-
statements2.push(`const ${local} = ${value};`);
|
|
107790
|
-
}
|
|
107791
|
-
}
|
|
107792
|
-
return statements2.join(" ");
|
|
107793
|
-
}
|
|
107794
|
-
function foreignTypeAliases(statement2) {
|
|
107795
|
-
const specifier = statement2.source.value;
|
|
107796
|
-
return statement2.specifiers.filter((item) => statement2.source.value !== "react" || isTypeOnlySpecifier(statement2, item)).filter(
|
|
107797
|
-
(item) => specifier !== PAGES_SDK_MODULE || item.type === "ImportSpecifier" && Object.hasOwn(PAGE_SDK_TYPES, importedName(item))
|
|
107798
|
-
).filter((item) => !(item.type !== "ImportSpecifier" && item.local.name === "React")).map((item) => {
|
|
107799
|
-
const local = item.local.name;
|
|
107800
|
-
if (specifier === PAGES_SDK_MODULE) {
|
|
107801
|
-
const type = PAGE_SDK_TYPES[importedName(item)];
|
|
107802
|
-
return `type ${local}${type.parameters} = Sdk.${importedName(item)}${type.arguments};`;
|
|
107803
|
-
}
|
|
107804
|
-
if (specifier === "react" && item.type === "ImportSpecifier") {
|
|
107805
|
-
return `type ${local} = React.${importedName(item)};`;
|
|
107806
|
-
}
|
|
107807
|
-
if (isAuthoringModule(specifier) && item.type === "ImportSpecifier" && Object.hasOwn(AUTHORING_TYPE_PARAMETERS, importedName(item))) {
|
|
107808
|
-
return `type ${local}${AUTHORING_TYPE_PARAMETERS[importedName(item)]} = any;`;
|
|
107809
|
-
}
|
|
107810
|
-
return `type ${local} = ${SDK_TYPE_DECLARATIONS[local] ?? "any"};`;
|
|
107811
|
-
});
|
|
107812
|
-
}
|
|
107813
|
-
function foreignBindings(source, ast, imports, resolve7) {
|
|
107814
|
-
return ast.program.body.filter((statement2) => statement2.type === "ImportDeclaration").filter((statement2) => !imports.some((item) => item.statement === statement2)).filter((statement2) => !isAuthoringModule(statement2.source.value)).map((statement2) => ({
|
|
107815
|
-
start: statement2.start,
|
|
107816
|
-
end: statement2.end,
|
|
107817
|
-
text: foreignBindingText(statement2, { lint: false, resolve: resolve7 }),
|
|
107818
|
-
lintText: foreignBindingText(statement2, { lint: true, resolve: resolve7 }),
|
|
107819
|
-
original: sliceOf(source, statement2)
|
|
107820
|
-
})).filter((binding) => binding.text !== "" || binding.lintText !== "");
|
|
107821
|
-
}
|
|
107822
|
-
function lazyImports(root, path, ast) {
|
|
107823
|
-
return moduleSpecifiers(ast).filter((item) => item.dynamic && item.specifier !== null && importKind(item.specifier) === "app").map((item) => ({
|
|
107824
|
-
specifier: item.specifier,
|
|
107825
|
-
path: resolveLocalSpecifier(root, path, item.specifier),
|
|
107826
|
-
start: item.call.start
|
|
107827
|
-
}));
|
|
107828
|
-
}
|
|
107829
|
-
function appImports(root, path, source, ast) {
|
|
107830
|
-
if (root === null) {
|
|
107831
|
-
return { ...NO_APP_IMPORTS, bindings: foreignBindings(source, ast, [], () => null) };
|
|
107832
|
-
}
|
|
107833
|
-
const imports = appImportsOf(root, path, ast, { ui: true });
|
|
107834
|
-
const foreign = foreignBindings(source, ast, imports, (specifier) => resolveLocalSpecifier(root, path, specifier));
|
|
107835
|
-
const lazy = lazyImports(root, path, ast);
|
|
107836
|
-
const loaded = [...imports, ...lazy.filter((item) => item.path !== null)];
|
|
107837
|
-
if (imports.length === 0 && lazy.length === 0) {
|
|
107838
|
-
return { ...NO_APP_IMPORTS, bindings: foreign, draftPrelude: draftPagesPrelude(root, loaded) ?? "" };
|
|
107839
|
-
}
|
|
107840
|
-
const modules = appModuleClosure(root, loaded, /* @__PURE__ */ new Set(), { ui: true });
|
|
107841
|
-
const bindings = [...appBindings(source, imports), ...foreign].toSorted((left, right) => left.start - right.start);
|
|
107842
|
-
const prelude = appPrelude(modules);
|
|
107843
|
-
return { imports, lazy, modules, bindings, prelude, draftPrelude: draftPagesPrelude(root, loaded) ?? prelude };
|
|
107844
|
-
}
|
|
107845
|
-
function draftPagesPrelude(root, loaded) {
|
|
107846
|
-
if (!existsSync7(join14(root, GENERATED_PAGES_PATH))) {
|
|
107847
|
-
return null;
|
|
107848
|
-
}
|
|
107849
|
-
const modules = appModuleClosure(root, [...loaded, { path: GENERATED_PAGES_PATH }], /* @__PURE__ */ new Set(), { ui: true });
|
|
107850
|
-
return `${appPrelude(modules)}
|
|
107851
|
-
const ${DRAFT_PAGES_NAME} = ${APP_IMPORT}(${JSON.stringify(GENERATED_PAGES_PATH)}).Pages;
|
|
107852
|
-
`;
|
|
107853
|
-
}
|
|
107854
|
-
function functionUnit(source, ast, functionNode, helpers, app) {
|
|
107855
|
-
const bindings = app.bindings.map((binding) => `${binding.text}
|
|
107856
|
-
`).join("");
|
|
107857
|
-
const prelude = helpers.map((statement2) => `${sliceOf(source, statement2)}
|
|
107858
|
-
`).join("");
|
|
107859
|
-
const functionBinding = boundName(functionNode);
|
|
107860
|
-
const functionSource = functionNode.type === "Identifier" ? "" : sliceOf(source, functionNode);
|
|
107861
|
-
const returned = functionBinding === null ? `${FACTORY_PREFIX}${functionSource}${FACTORY_SUFFIX}` : `${functionSource}
|
|
107862
|
-
return ${functionBinding};`;
|
|
107863
|
-
const code2 = `${app.prelude}${bindings}${prelude}${returned}`;
|
|
107864
|
-
return {
|
|
107865
|
-
source: code2,
|
|
107866
|
-
compiled_code: compile(code2, functionNode),
|
|
107867
|
-
// What a draft of this unit runs before its own code: the page builder
|
|
107868
|
-
// previews a page's factory body without its imports.
|
|
107869
|
-
app_prelude: app.draftPrelude === "" && bindings === "" ? null : `${app.draftPrelude}${bindings}`,
|
|
107870
|
-
lint: lintUnit(source, ast, functionNode, helpers, app, functionBinding)
|
|
107871
|
-
};
|
|
107872
|
-
}
|
|
107873
|
-
function boundName(functionNode) {
|
|
107874
|
-
if (functionNode.type === "FunctionDeclaration") {
|
|
107875
|
-
return functionNode.id?.name ?? null;
|
|
107876
|
-
}
|
|
107877
|
-
return functionNode.type === "Identifier" ? functionNode.name : null;
|
|
107878
|
-
}
|
|
107879
|
-
function defaultExportFunction(ast, declaration) {
|
|
107880
|
-
if (isFunctionNode(declaration)) {
|
|
107881
|
-
return declaration;
|
|
107882
|
-
}
|
|
107883
|
-
if (declaration?.type !== "Identifier") {
|
|
107884
|
-
return null;
|
|
107885
|
-
}
|
|
107886
|
-
for (const statement2 of ast.program.body) {
|
|
107887
|
-
const node = statement2.type === "ExportNamedDeclaration" ? statement2.declaration : statement2;
|
|
107888
|
-
if (node?.type === "FunctionDeclaration" && node.id?.name === declaration.name) {
|
|
107889
|
-
return node;
|
|
107890
|
-
}
|
|
107891
|
-
if (node?.type === "VariableDeclaration" && node.kind === "const") {
|
|
107892
|
-
const bound = node.declarations.find(
|
|
107893
|
-
(item) => item.id.type === "Identifier" && item.id.name === declaration.name
|
|
107894
|
-
);
|
|
107895
|
-
if (bound !== void 0) {
|
|
107896
|
-
return isFunctionNode(bound.init) ? bound.init : null;
|
|
107897
|
-
}
|
|
107898
|
-
}
|
|
107899
|
-
}
|
|
107900
|
-
return null;
|
|
107901
|
-
}
|
|
107902
|
-
function buildComponent(path, name, source, ast, root = null) {
|
|
107903
|
-
const { declaration, helpers } = defaultExportOf(ast, {
|
|
107904
|
-
helpers: "anywhere",
|
|
107905
|
-
allowAppImports: true,
|
|
107906
|
-
namedExports: "keep"
|
|
107907
|
-
});
|
|
107908
|
-
if (defaultExportFunction(ast, declaration) === null) {
|
|
107909
|
-
throw new SourceError("A component file must export default a function", declaration);
|
|
107910
|
-
}
|
|
107911
|
-
return {
|
|
107912
|
-
path,
|
|
107913
|
-
name,
|
|
107914
|
-
...functionUnit(source, ast, declaration, helpers, appImports(root, path, source, ast))
|
|
107915
|
-
};
|
|
107916
|
-
}
|
|
107917
|
-
function buildLayout2(path, name, source, ast, root = null) {
|
|
107918
|
-
const { declaration, helpers } = defaultExportOf(ast, {
|
|
107919
|
-
helpers: "anywhere",
|
|
107920
|
-
allowAppImports: true,
|
|
107921
|
-
moduleUid: true
|
|
107922
|
-
});
|
|
107923
|
-
if (!isFunctionNode(declaration)) {
|
|
107924
|
-
throw new SourceError("A layout file must export default a function", declaration);
|
|
107925
|
-
}
|
|
107926
|
-
return {
|
|
107927
|
-
path,
|
|
107928
|
-
name,
|
|
107929
|
-
...functionUnit(source, ast, declaration, helpers, appImports(root, path, source, ast))
|
|
107930
|
-
};
|
|
107931
|
-
}
|
|
107932
|
-
function normalizeRoute(route) {
|
|
107933
|
-
const trimmed = route.length > 1 ? route.replace(/\/+$/, "") : route;
|
|
107934
|
-
return trimmed.replaceAll(/\{[^}/]+\}/g, "{}").toLowerCase();
|
|
107935
|
-
}
|
|
107936
|
-
function optionalMetaString(meta, key, nodes) {
|
|
107937
|
-
const value = meta[key];
|
|
107938
|
-
if (value === void 0 || value === null) {
|
|
107939
|
-
return null;
|
|
107940
|
-
}
|
|
107941
|
-
if (typeof value !== "string" || value === "") {
|
|
107942
|
-
throw new SourceError(`"${key}" must be a non-empty string or null`, nodes[key]);
|
|
107943
|
-
}
|
|
107944
|
-
return value;
|
|
107945
|
-
}
|
|
107946
|
-
function flatMetaValue(meta, flat, grouped, nodes, warnings2) {
|
|
107947
|
-
const value = meta[flat];
|
|
107948
|
-
if (value === void 0 || value === null) {
|
|
107949
|
-
return null;
|
|
107950
|
-
}
|
|
107951
|
-
if (typeof value !== "string" && (typeof value !== "object" || Array.isArray(value))) {
|
|
107952
|
-
throw new SourceError(`"${flat}" must be a string or null`, nodes[flat]);
|
|
107953
|
-
}
|
|
107954
|
-
if (isTextOnlyTipTap(value) && grouped !== "image") {
|
|
107955
|
-
warnings2.push({ node: nodes[flat], message: `Write the ${grouped} as a string` });
|
|
107956
|
-
}
|
|
107957
|
-
const normalized = normalizeMetaValue(value);
|
|
107958
|
-
const disallowed = disallowedMetaResolver(normalized);
|
|
107959
|
-
if (disallowed !== null) {
|
|
107960
|
-
throw new SourceError(
|
|
107961
|
-
`"${flat}" holds ${disallowed}. A page ${grouped} is a string, or a seo function of the bound records: seo: { ${grouped}: ({ bindings }) => ... }`,
|
|
107962
|
-
nodes[flat]
|
|
107963
|
-
);
|
|
107964
|
-
}
|
|
107965
|
-
return normalized;
|
|
107966
|
-
}
|
|
107967
|
-
function optionalBoolean2(meta, key, nodes, fallback) {
|
|
107968
|
-
const value = meta[key];
|
|
107969
|
-
if (value === void 0 || value === null) {
|
|
107970
|
-
return fallback;
|
|
107971
|
-
}
|
|
107972
|
-
if (typeof value !== "boolean") {
|
|
107973
|
-
throw new SourceError(`"${key}" must be true or false`, nodes[key]);
|
|
107974
|
-
}
|
|
107975
|
-
return value;
|
|
107976
|
-
}
|
|
107977
|
-
function pageAuthorizer(meta, nodes) {
|
|
107978
|
-
const value = meta.authorizer;
|
|
107979
|
-
if (value === void 0 || value === null) {
|
|
107980
|
-
return null;
|
|
107981
|
-
}
|
|
107982
|
-
if (typeof value === "string") {
|
|
107983
|
-
if (!PAGE_AUTHORIZERS.has(value)) {
|
|
107984
|
-
throw new SourceError(
|
|
107985
|
-
'"authorizer" must be null, "authenticated", or { resource, permissions }',
|
|
107986
|
-
nodes.authorizer
|
|
107987
|
-
);
|
|
107988
|
-
}
|
|
107989
|
-
return { resource: null, permissions: [] };
|
|
107990
|
-
}
|
|
107991
|
-
if (typeof value !== "object" || Array.isArray(value)) {
|
|
107992
|
-
throw new SourceError(
|
|
107993
|
-
'"authorizer" must be null, "authenticated", or { resource, permissions }',
|
|
107994
|
-
nodes.authorizer
|
|
107995
|
-
);
|
|
107996
|
-
}
|
|
107997
|
-
for (const key of Object.keys(value)) {
|
|
107998
|
-
if (key !== "resource" && key !== "permissions") {
|
|
107999
|
-
throw new SourceError(`Unknown authorizer option "${key}"`, nodes.authorizer);
|
|
108000
|
-
}
|
|
108001
|
-
}
|
|
108002
|
-
const resource = value.resource ?? null;
|
|
108003
|
-
const permissions = value.permissions ?? [];
|
|
108004
|
-
if (resource !== null && (typeof resource !== "string" || resource === "")) {
|
|
108005
|
-
throw new SourceError('"authorizer.resource" must be Resources.<Name>.slug or a resource slug', nodes.authorizer);
|
|
108006
|
-
}
|
|
108007
|
-
if (!Array.isArray(permissions) || permissions.some((permission) => typeof permission !== "string" || permission === "")) {
|
|
108008
|
-
throw new SourceError(
|
|
108009
|
-
'"authorizer.permissions" must be a list of permission uids, such as Permissions.<Name>.uid or SystemPermissions.<Name>.uid',
|
|
108010
|
-
nodes.authorizer
|
|
108011
|
-
);
|
|
108012
|
-
}
|
|
108013
|
-
return { resource, permissions };
|
|
108014
|
-
}
|
|
108015
|
-
function pageBindings(meta, nodes, route, option) {
|
|
108016
|
-
const value = meta[option];
|
|
108017
|
-
if (value === void 0 || value === null) {
|
|
108018
|
-
return [];
|
|
108019
|
-
}
|
|
108020
|
-
if (typeof value !== "object" || Array.isArray(value)) {
|
|
108021
|
-
throw new SourceError(`"${option}" must be an object keyed by route parameter`, nodes[option]);
|
|
108022
|
-
}
|
|
108023
|
-
const names2 = routeParamNames(route);
|
|
108024
|
-
const bindings = [];
|
|
108025
|
-
for (const [key, binding] of Object.entries(value)) {
|
|
108026
|
-
if (!names2.includes(key)) {
|
|
108027
|
-
throw new SourceError(`"${option}.${key}" is not a parameter of "${route}"`, nodes[option]);
|
|
108028
|
-
}
|
|
108029
|
-
if (typeof binding !== "object" || binding === null || Array.isArray(binding)) {
|
|
108030
|
-
throw new SourceError(`"${option}.${key}" must be an object`, nodes[option]);
|
|
108031
|
-
}
|
|
108032
|
-
for (const name of Object.keys(binding)) {
|
|
108033
|
-
if (!PARAM_KEYS.has(name)) {
|
|
108034
|
-
throw new SourceError(`Unknown option "${option}.${key}.${name}"`, nodes[option]);
|
|
108035
|
-
}
|
|
108036
|
-
}
|
|
108037
|
-
const { resource = null, lookupField = null, relations = [], scope: scope2 = null } = binding;
|
|
108038
|
-
if (typeof resource !== "string" || resource === "") {
|
|
108039
|
-
throw new SourceError(
|
|
108040
|
-
`"${option}.${key}.resource" must be Resources.<Name>.slug or a resource slug`,
|
|
108041
|
-
nodes[option]
|
|
108042
|
-
);
|
|
108043
|
-
}
|
|
108044
|
-
if (lookupField !== null && (typeof lookupField !== "string" || lookupField === "")) {
|
|
108045
|
-
throw new SourceError(`"${option}.${key}.lookupField" must be a field key`, nodes[option]);
|
|
108046
|
-
}
|
|
108047
|
-
if (!Array.isArray(relations) || relations.some((relation) => typeof relation !== "string")) {
|
|
108048
|
-
throw new SourceError(`"${option}.${key}.relations" must be a list of field keys`, nodes[option]);
|
|
108049
|
-
}
|
|
108050
|
-
if (scope2 !== null && !RECORD_SCOPES.has(scope2)) {
|
|
108051
|
-
throw new SourceError(
|
|
108052
|
-
`"${option}.${key}.scope" must be "active", "activeOrArchived", or "archived"`,
|
|
108053
|
-
nodes[option]
|
|
108054
|
-
);
|
|
108055
|
-
}
|
|
108056
|
-
bindings.push({ key, resource, lookupField, relations, scope: scope2 });
|
|
108057
|
-
}
|
|
108058
|
-
return bindings;
|
|
108059
|
-
}
|
|
108060
|
-
function buildPage(path, source, ast, root = null, resources = null, permissions = null, assets = null, domains = null) {
|
|
108061
|
-
const { declaration, helpers } = defaultExportOf(ast, {
|
|
108062
|
-
helpers: "above",
|
|
108063
|
-
allowAppImports: true
|
|
108064
|
-
});
|
|
108065
|
-
const [metaNode, functionNode] = expectDefineCall(declaration, "definePage", 2);
|
|
108066
|
-
const seoNode = seoProperty(metaNode);
|
|
108067
|
-
const layoutNode = layoutProperty(metaNode);
|
|
108068
|
-
const { value: meta, nodes } = staticObject(withoutProperties(metaNode, [seoNode, layoutNode]), {
|
|
108069
|
-
resources,
|
|
108070
|
-
permissions,
|
|
108071
|
-
domains
|
|
108072
|
-
});
|
|
108073
|
-
const warnings2 = [];
|
|
108074
|
-
const layoutRef = pageLayoutOf(ast, layoutNode, path, root);
|
|
108075
|
-
for (const key of Object.keys(meta)) {
|
|
108076
|
-
if (!PAGE_KEYS.has(key)) {
|
|
108077
|
-
throw new SourceError(`Unknown page option "${key}"`, nodes[key]);
|
|
108078
|
-
}
|
|
108079
|
-
}
|
|
108080
|
-
if (typeof meta.route !== "string" || !meta.route.startsWith("/")) {
|
|
108081
|
-
throw new SourceError('"route" must be a string that starts with "/"', nodes.route ?? metaNode);
|
|
108082
|
-
}
|
|
108083
|
-
if (/\[[^\]]*\]/.test(meta.route)) {
|
|
108084
|
-
throw new SourceError("Route parameters use {name}, not [name]", nodes.route);
|
|
108085
|
-
}
|
|
108086
|
-
const renderProfile = meta.renderProfile ?? "standard";
|
|
108087
|
-
if (!PAGE_RENDER_PROFILES.has(renderProfile)) {
|
|
108088
|
-
throw new SourceError('"renderProfile" must be "standard" or "print"', nodes.renderProfile);
|
|
108089
|
-
}
|
|
108090
|
-
if (renderProfile === "print" && layoutRef !== null) {
|
|
108091
|
-
throw new SourceError('A print page has no layout. Remove "layout"', layoutNode.value);
|
|
108092
|
-
}
|
|
108093
|
-
if (!isFunctionNode(functionNode)) {
|
|
108094
|
-
throw new SourceError("The second argument of definePage must be a function", functionNode);
|
|
108095
|
-
}
|
|
108096
|
-
if (meta.params !== void 0 && meta.bindings !== void 0) {
|
|
108097
|
-
throw new SourceError('Use "bindings" only. "params" is its old name', nodes.params);
|
|
108098
|
-
}
|
|
108099
|
-
const bindingOption = meta.params === void 0 ? "bindings" : "params";
|
|
108100
|
-
if (bindingOption === "params") {
|
|
108101
|
-
warnings2.push({ node: nodes.params, message: '"params" is now "bindings". Rename the option' });
|
|
108102
|
-
}
|
|
108103
|
-
const stored = pageMeta(meta, nodes, seoNode, source, warnings2, assets);
|
|
108104
|
-
return {
|
|
108105
|
-
path,
|
|
108106
|
-
route: meta.route,
|
|
108107
|
-
name: optionalMetaString(meta, "name", nodes),
|
|
108108
|
-
title: stored.title,
|
|
108109
|
-
description: stored.description,
|
|
108110
|
-
og_image: stored.og_image,
|
|
108111
|
-
head_html: optionalMetaString(meta, "headHtml", nodes),
|
|
108112
|
-
layout: layoutRef?.path ?? null,
|
|
108113
|
-
render_profile: renderProfile,
|
|
108114
|
-
sitemap: optionalBoolean2(meta, "sitemap", nodes, renderProfile !== "print"),
|
|
108115
|
-
domain_key: pageDomainKey(meta, nodes, domains),
|
|
108116
|
-
paused: optionalBoolean2(meta, "paused", nodes, false),
|
|
108117
|
-
authorizer: pageAuthorizer(meta, nodes),
|
|
108118
|
-
params: pageBindings(meta, nodes, meta.route, bindingOption),
|
|
108119
|
-
...functionUnit(source, ast, functionNode, helpers, appImports(root, path, source, ast)),
|
|
108120
|
-
layoutNode: layoutNode?.value ?? null,
|
|
108121
|
-
seoReads: stored.reads,
|
|
108122
|
-
seoAsset: stored.asset,
|
|
108123
|
-
warnings: warnings2,
|
|
108124
|
-
resourceNodes: {
|
|
108125
|
-
meta: metaNode,
|
|
108126
|
-
authorizer: nodes.authorizer ?? null,
|
|
108127
|
-
params: nodes[bindingOption] ?? null,
|
|
108128
|
-
bindingOption
|
|
108129
|
-
}
|
|
108130
|
-
};
|
|
108131
|
-
}
|
|
108132
|
-
function pageDomainKey(meta, nodes, domains) {
|
|
108133
|
-
if (meta.domain === void 0 || meta.domain === null) {
|
|
108134
|
-
return null;
|
|
108135
|
-
}
|
|
108136
|
-
if (!isDomainsReference(nodes.domain.value, domains) || typeof meta.domain !== "string") {
|
|
108137
|
-
throw new SourceError(DOMAIN_REFERENCE_MESSAGE, nodes.domain);
|
|
108138
|
-
}
|
|
108139
|
-
return meta.domain;
|
|
108140
|
-
}
|
|
108141
|
-
function withoutProperties(objectNode, properties) {
|
|
108142
|
-
const removed = properties.filter((property) => property !== void 0);
|
|
108143
|
-
if (removed.length === 0) {
|
|
108144
|
-
return objectNode;
|
|
108145
|
-
}
|
|
108146
|
-
const node = optionsObject(objectNode);
|
|
108147
|
-
return { ...node, properties: node.properties.filter((item) => !removed.includes(item)) };
|
|
108148
|
-
}
|
|
108149
|
-
function optionsObject(metaNode) {
|
|
108150
|
-
return metaNode.type === "ObjectExpression" ? metaNode : metaNode.expression;
|
|
108151
|
-
}
|
|
108152
|
-
function layoutProperty(metaNode) {
|
|
108153
|
-
const node = optionsObject(metaNode);
|
|
108154
|
-
if (node?.type !== "ObjectExpression") {
|
|
108155
|
-
return void 0;
|
|
108156
|
-
}
|
|
108157
|
-
return node.properties.find(
|
|
108158
|
-
(property) => property.type === "ObjectProperty" && !property.computed && (property.key.name ?? property.key.value) === "layout"
|
|
108159
|
-
);
|
|
108160
|
-
}
|
|
108161
|
-
function pageLayoutOf(ast, property, path, root) {
|
|
108162
|
-
if (property === void 0 || property.value.type === "NullLiteral") {
|
|
108163
|
-
return null;
|
|
108164
|
-
}
|
|
108165
|
-
const value = property.value;
|
|
108166
|
-
if (value.type === "StringLiteral") {
|
|
108167
|
-
const named = root === null ? null : resolveLocalSpecifier(root, "", `layouts/${value.value}.tsx`);
|
|
108168
|
-
const suggestion = named === null ? "../layouts/app" : relativeSpecifier(path, named);
|
|
108169
|
-
throw new SourceError(
|
|
108170
|
-
`"layout" takes the imported layout, not a name. Add import AppLayout from '${suggestion}' and pass layout: AppLayout`,
|
|
108171
|
-
value
|
|
108172
|
-
);
|
|
108173
|
-
}
|
|
108174
|
-
if (value.type !== "Identifier") {
|
|
108175
|
-
throw new SourceError('"layout" must be an imported layout, such as layout: AppLayout', value);
|
|
108176
|
-
}
|
|
108177
|
-
const imported = importBinding(ast, value.name);
|
|
108178
|
-
if (imported === null) {
|
|
108179
|
-
throw new SourceError('"layout" must be an imported layout, such as layout: AppLayout', value);
|
|
108180
|
-
}
|
|
108181
|
-
const { statement: statement2, specifier } = imported;
|
|
108182
|
-
if (specifier.type !== "ImportDefaultSpecifier" || statement2.importKind === "type" || importKind(statement2.source.value) !== "app") {
|
|
108183
|
-
throw new SourceError('"layout" must be the default import of a layout file', value);
|
|
108184
|
-
}
|
|
108185
|
-
const resolved = root === null ? null : resolveLocalSpecifier(root, path, statement2.source.value);
|
|
108186
|
-
if (root !== null && resolved === null) {
|
|
108187
|
-
throw new SourceError(`Cannot find "${statement2.source.value}" from ${path}`, statement2.source);
|
|
108188
|
-
}
|
|
108189
|
-
return { node: value, local: value.name, specifier: statement2.source.value, path: resolved };
|
|
108190
|
-
}
|
|
108191
|
-
function importBinding(ast, name) {
|
|
108192
|
-
for (const statement2 of ast.program.body) {
|
|
108193
|
-
if (statement2.type !== "ImportDeclaration") {
|
|
108194
|
-
continue;
|
|
108195
|
-
}
|
|
108196
|
-
const specifier = statement2.specifiers.find((item) => item.local.name === name);
|
|
108197
|
-
if (specifier !== void 0) {
|
|
108198
|
-
return { statement: statement2, specifier };
|
|
108199
|
-
}
|
|
108200
|
-
}
|
|
108201
|
-
return null;
|
|
108202
|
-
}
|
|
108203
|
-
function pageMeta(meta, nodes, seoNode, source, warnings2, assets) {
|
|
108204
|
-
if (seoNode !== void 0) {
|
|
108205
|
-
for (const [flat, grouped] of FLAT_SEO_KEYS) {
|
|
108206
|
-
if (meta[flat] !== void 0) {
|
|
108207
|
-
flatMetaValue(meta, flat, grouped, nodes, []);
|
|
108208
|
-
throw new SourceError(`Move "${flat}" into seo: { ${grouped} }`, nodes[flat]);
|
|
108209
|
-
}
|
|
108210
|
-
}
|
|
108211
|
-
const seo = readSeo(seoNode.value, source, assets);
|
|
108212
|
-
return {
|
|
108213
|
-
title: seoResolver(seo.title),
|
|
108214
|
-
description: seoResolver(seo.description),
|
|
108215
|
-
og_image: seoResolver(seo.image),
|
|
108216
|
-
reads: seoFieldReads(seo),
|
|
108217
|
-
asset: seo.image?.kind === "asset" ? { key: seo.image.key, node: seo.image.node } : null
|
|
108218
|
-
};
|
|
108219
|
-
}
|
|
108220
|
-
const values = {};
|
|
108221
|
-
for (const [flat, grouped] of FLAT_SEO_KEYS) {
|
|
108222
|
-
if (isPlainObject2(meta[flat]) && !isTextOnlyTipTap(meta[flat])) {
|
|
108223
|
-
warnings2.push({
|
|
108224
|
-
node: nodes[flat],
|
|
108225
|
-
message: `"${flat}" is now seo.${grouped}. Write the resolver as a seo function: seo: { ${grouped}: ({ bindings }) => ... }`
|
|
108226
|
-
});
|
|
108227
|
-
} else if (meta[flat] !== void 0) {
|
|
108228
|
-
warnings2.push({ node: nodes[flat], message: `"${flat}" is now seo.${grouped}. Move it into seo: { ${grouped} }` });
|
|
108229
|
-
}
|
|
108230
|
-
values[grouped] = flatMetaValue(meta, flat, grouped, nodes, warnings2);
|
|
108231
|
-
}
|
|
108232
|
-
return {
|
|
108233
|
-
title: values.title,
|
|
108234
|
-
description: values.description,
|
|
108235
|
-
og_image: values.image,
|
|
108236
|
-
reads: [],
|
|
108237
|
-
asset: null
|
|
108238
|
-
};
|
|
108239
|
-
}
|
|
108240
|
-
|
|
108241
106865
|
// scripts/lib/runtime-build/route-occupancy.mjs
|
|
108242
106866
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
108243
106867
|
|
|
@@ -108250,6 +106874,25 @@ function hostKey(domainKey, domains, primaryDomain) {
|
|
|
108250
106874
|
return domains.some((domain) => domain.key === domainKey && domain.fallback === "primary") ? "" : domainKey;
|
|
108251
106875
|
}
|
|
108252
106876
|
|
|
106877
|
+
// scripts/lib/runtime-build/ui-sources.mjs
|
|
106878
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
106879
|
+
|
|
106880
|
+
// scripts/lib/runtime-build/page-seo.mjs
|
|
106881
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
106882
|
+
var FLAT_SEO_KEYS = [
|
|
106883
|
+
["title", "title"],
|
|
106884
|
+
["description", "description"],
|
|
106885
|
+
["ogImage", "image"]
|
|
106886
|
+
];
|
|
106887
|
+
var SEO_KEYS = FLAT_SEO_KEYS.map(([, key]) => key);
|
|
106888
|
+
var PAGE_META_RESOLVERS = new Set(page_meta_resolvers_default);
|
|
106889
|
+
|
|
106890
|
+
// scripts/lib/runtime-build/ui-sources.mjs
|
|
106891
|
+
function normalizeRoute(route) {
|
|
106892
|
+
const trimmed = route.length > 1 ? route.replace(/\/+$/, "") : route;
|
|
106893
|
+
return trimmed.replaceAll(/\{[^}/]+\}/g, "{}").toLowerCase();
|
|
106894
|
+
}
|
|
106895
|
+
|
|
108253
106896
|
// scripts/lib/runtime-build/route-occupancy.mjs
|
|
108254
106897
|
function reportRouteCollisions(pages, workflows, domains, primaryDomain, diagnostics) {
|
|
108255
106898
|
const sources = [
|
|
@@ -108311,18 +106954,11 @@ var NOTIFICATION_TYPE_PATTERN = /^notifications\/[^/]+\/type\.ts$/;
|
|
|
108311
106954
|
var NOTIFICATION_TEMPLATE_PATTERN = /^notifications\/[^/]+\/[^/]+\.template\.ts$/;
|
|
108312
106955
|
var EMAIL_LAYOUT_PATTERN = /^email-layouts\/[^/]+\/layout\.ts$/;
|
|
108313
106956
|
var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set(["vendor"]);
|
|
108314
|
-
var COMPONENT_NAME_PATTERN = /^[A-Z][A-Za-z0-9]*$/;
|
|
108315
106957
|
var RECORD_BINDING_NON_USERS = /* @__PURE__ */ new Set(["record_binding", "workflow_test", "migration_test", "test", "test_suite"]);
|
|
108316
106958
|
var MODULE_ENTITY_TYPES = { layouts: "layout", components: "component" };
|
|
108317
106959
|
var ENTRY_TYPES = /* @__PURE__ */ new Map([
|
|
108318
|
-
["layout", { output: "layouts"
|
|
108319
|
-
[
|
|
108320
|
-
"component",
|
|
108321
|
-
{
|
|
108322
|
-
output: "components",
|
|
108323
|
-
build: (path, source, ast, root) => path.endsWith(".tsx") && isComponentModule(path, ast) ? buildComponent(path, path, source, ast, root) : null
|
|
108324
|
-
}
|
|
108325
|
-
]
|
|
106960
|
+
["layout", { output: "layouts" }],
|
|
106961
|
+
["component", { output: "components" }]
|
|
108326
106962
|
]);
|
|
108327
106963
|
var MODULE_ENTITY_EXTENSIONS = /* @__PURE__ */ new Set([".tsx", ".ts", ".jsx", ".js"]);
|
|
108328
106964
|
function moduleEntityType(devPath) {
|
|
@@ -108340,43 +106976,6 @@ function topDirectory(path) {
|
|
|
108340
106976
|
function isDirectChild(path, directory) {
|
|
108341
106977
|
return path.startsWith(`${directory}/`) && !path.slice(directory.length + 1).includes("/");
|
|
108342
106978
|
}
|
|
108343
|
-
function stem(path) {
|
|
108344
|
-
return basename10(withoutDevInfix(path), extname(path));
|
|
108345
|
-
}
|
|
108346
|
-
function rowMenuReads(path, ast) {
|
|
108347
|
-
const found2 = [];
|
|
108348
|
-
const pending = [ast.program];
|
|
108349
|
-
while (pending.length > 0) {
|
|
108350
|
-
const node = pending.pop();
|
|
108351
|
-
if ((node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && !node.computed && node.object.type === "Identifier" && node.object.name === "Sdk" && ROW_MENU_MEMBERS.has(node.property.name)) {
|
|
108352
|
-
found2.push(diagnosticAt(path, node, NAVIGATION_MENU_REMOVED));
|
|
108353
|
-
}
|
|
108354
|
-
pending.push(...childNodes(node));
|
|
108355
|
-
}
|
|
108356
|
-
return found2.toSorted((left, right) => left.line - right.line || left.column - right.column);
|
|
108357
|
-
}
|
|
108358
|
-
var DEFINE_NAVIGATION_REMOVED = "defineNavigation was removed. Default-export defineMenu((ctx) => items) from @diagonal-hq/pages, then import the menu in a layout and pass it to useMenu";
|
|
108359
|
-
function checkMenuModule(ast) {
|
|
108360
|
-
for (const statement2 of ast.program.body) {
|
|
108361
|
-
if (statement2.type === "ImportDeclaration" && statement2.specifiers.some(
|
|
108362
|
-
(specifier) => specifier.type === "ImportSpecifier" && specifier.imported.name === "defineNavigation"
|
|
108363
|
-
)) {
|
|
108364
|
-
throw new SourceError(DEFINE_NAVIGATION_REMOVED, statement2);
|
|
108365
|
-
}
|
|
108366
|
-
}
|
|
108367
|
-
const declaration = ast.program.body.find(
|
|
108368
|
-
(statement2) => statement2.type === "ExportDefaultDeclaration"
|
|
108369
|
-
)?.declaration;
|
|
108370
|
-
if (calleeName(declaration) === "defineNavigation") {
|
|
108371
|
-
throw new SourceError(DEFINE_NAVIGATION_REMOVED, declaration);
|
|
108372
|
-
}
|
|
108373
|
-
if (calleeName(declaration) !== "defineMenu") {
|
|
108374
|
-
throw new SourceError(
|
|
108375
|
-
"A navigation/*.ts file must default-export defineMenu((ctx) => items) from @diagonal-hq/pages",
|
|
108376
|
-
declaration ?? ast.program
|
|
108377
|
-
);
|
|
108378
|
-
}
|
|
108379
|
-
}
|
|
108380
106979
|
function isUnitSupportFile(path) {
|
|
108381
106980
|
const extension = extname(path).toLowerCase();
|
|
108382
106981
|
return extension === ".ts" || extension === ".css";
|
|
@@ -108456,119 +107055,17 @@ function classify(devPath) {
|
|
|
108456
107055
|
}
|
|
108457
107056
|
function rereadWorkflowFiles(root, workflowFiles) {
|
|
108458
107057
|
return workflowFiles.map((file2) => {
|
|
108459
|
-
const source =
|
|
107058
|
+
const source = readFileSync12(join15(root, file2.path), "utf8");
|
|
108460
107059
|
return source === file2.source ? file2 : { path: file2.path, source, ast: parseSource(source, { jsx: false }) };
|
|
108461
107060
|
});
|
|
108462
107061
|
}
|
|
108463
|
-
function isComponentModule(path, ast) {
|
|
108464
|
-
const declaration = ast.program.body.find((statement2) => statement2.type === "ExportDefaultDeclaration")?.declaration;
|
|
108465
|
-
if (defaultExportFunction(ast, declaration) === null) {
|
|
108466
|
-
return false;
|
|
108467
|
-
}
|
|
108468
|
-
const name = declaration.type === "Identifier" ? declaration.name : declaration.id?.name ?? stem(path);
|
|
108469
|
-
return COMPONENT_NAME_PATTERN.test(name);
|
|
108470
|
-
}
|
|
108471
|
-
function reportSdkCustom(root, path, references, diagnostics) {
|
|
108472
|
-
for (const reference of references) {
|
|
108473
|
-
const component = resolveLocalSpecifier(root, "", `components/${reference.name}`);
|
|
108474
|
-
const specifier = component === null ? `../components/${reference.name}` : relativeSpecifier(path, component);
|
|
108475
|
-
diagnostics.push(
|
|
108476
|
-
diagnosticAt(
|
|
108477
|
-
path,
|
|
108478
|
-
reference.node,
|
|
108479
|
-
`Sdk.Custom is removed. Import the component: import ${reference.name} from '${specifier}'`
|
|
108480
|
-
)
|
|
108481
|
-
);
|
|
108482
|
-
}
|
|
108483
|
-
}
|
|
108484
|
-
function checkPageResources(pages, resources, builtInSlugs, names2, diagnostics) {
|
|
108485
|
-
const slugs = /* @__PURE__ */ new Set([...resources.map((resource) => resource.slug), ...builtInSlugs]);
|
|
108486
|
-
for (const page of pages) {
|
|
108487
|
-
const references = [
|
|
108488
|
-
["authorizer.resource", page.authorizer?.resource ?? null, page.resourceNodes.authorizer],
|
|
108489
|
-
...page.params.map((param) => [
|
|
108490
|
-
`${page.resourceNodes.bindingOption}.${param.key}.resource`,
|
|
108491
|
-
param.resource,
|
|
108492
|
-
page.resourceNodes.params
|
|
108493
|
-
])
|
|
108494
|
-
];
|
|
108495
|
-
for (const [option, reference, node] of references) {
|
|
108496
|
-
if (reference === null || slugs.has(reference)) {
|
|
108497
|
-
continue;
|
|
108498
|
-
}
|
|
108499
|
-
diagnostics.push(
|
|
108500
|
-
diagnosticAt(
|
|
108501
|
-
page.path,
|
|
108502
|
-
node,
|
|
108503
|
-
`${option}: ${referenceProblem(reference, resources, names2).message}`
|
|
108504
|
-
)
|
|
108505
|
-
);
|
|
108506
|
-
}
|
|
108507
|
-
}
|
|
108508
|
-
}
|
|
108509
|
-
function checkPageSeo(pages, resources, diagnostics) {
|
|
108510
|
-
const resourcesBySlug = new Map(resources.map((resource) => [resource.slug, resource]));
|
|
108511
|
-
for (const page of pages) {
|
|
108512
|
-
const bindings = new Map(page.params.map((binding) => [binding.key, binding]));
|
|
108513
|
-
for (const entry of page.seoReads) {
|
|
108514
|
-
const problem2 = seoReadProblem(entry, bindings, resourcesBySlug);
|
|
108515
|
-
if (problem2 !== null) {
|
|
108516
|
-
diagnostics.push(diagnosticAt(page.path, entry.read.node, `seo.${entry.key}: ${problem2}`));
|
|
108517
|
-
}
|
|
108518
|
-
}
|
|
108519
|
-
}
|
|
108520
|
-
}
|
|
108521
|
-
function checkPageSeoAssets(pages, assets, diagnostics) {
|
|
108522
|
-
if (assets === null) {
|
|
108523
|
-
return;
|
|
108524
|
-
}
|
|
108525
|
-
const mimeTypesByKey = new Map(
|
|
108526
|
-
Object.values(assets).map((entry) => [entry.key, entry.mimeType.value])
|
|
108527
|
-
);
|
|
108528
|
-
for (const page of pages) {
|
|
108529
|
-
const mimeType = page.seoAsset === null ? "" : mimeTypesByKey.get(page.seoAsset.key) ?? "";
|
|
108530
|
-
if (mimeType !== "" && !EMAIL_IMAGE_MIME_TYPES.includes(mimeType)) {
|
|
108531
|
-
diagnostics.push(
|
|
108532
|
-
diagnosticAt(
|
|
108533
|
-
page.path,
|
|
108534
|
-
page.seoAsset.node,
|
|
108535
|
-
`seo.image: the asset "${page.seoAsset.key}" is ${mimeType}. A social image must be a PNG, JPEG, GIF, or WebP asset`
|
|
108536
|
-
)
|
|
108537
|
-
);
|
|
108538
|
-
}
|
|
108539
|
-
}
|
|
108540
|
-
}
|
|
108541
|
-
function checkPublicPageBindings(pages, resources, diagnostics) {
|
|
108542
|
-
const resourcesBySlug = new Map(resources.map((resource) => [resource.slug, resource]));
|
|
108543
|
-
for (const page of pages) {
|
|
108544
|
-
if (page.authorizer !== null) {
|
|
108545
|
-
continue;
|
|
108546
|
-
}
|
|
108547
|
-
for (const binding of page.params) {
|
|
108548
|
-
const resource = resourcesBySlug.get(binding.resource);
|
|
108549
|
-
if (resource === void 0 || resource.policies.some(
|
|
108550
|
-
(policy) => policy.access === "public" && policy.scope.includes("show")
|
|
108551
|
-
)) {
|
|
108552
|
-
continue;
|
|
108553
|
-
}
|
|
108554
|
-
diagnostics.push(
|
|
108555
|
-
diagnosticAt(
|
|
108556
|
-
page.path,
|
|
108557
|
-
page.resourceNodes.params,
|
|
108558
|
-
`${page.resourceNodes.bindingOption}.${binding.key}: The page is public, but ${resource.name} has no public "show" policy, so a visitor cannot open the page. Add a public show policy to ${resource.name}, or set an authorizer on the page`,
|
|
108559
|
-
{ severity: "warning" }
|
|
108560
|
-
)
|
|
108561
|
-
);
|
|
108562
|
-
}
|
|
108563
|
-
}
|
|
108564
|
-
}
|
|
108565
107062
|
var CHECKED_FILE_KINDS = /* @__PURE__ */ new Set(["record_binding", "assets", "config", "redirects", "permission", "role", "workspace_field"]);
|
|
108566
107063
|
function stringFacts(root, files) {
|
|
108567
107064
|
const facts = /* @__PURE__ */ Object.create(null);
|
|
108568
107065
|
for (const path of files.filter((item) => ["config", "workspace_field"].includes(classify(item)))) {
|
|
108569
107066
|
let ast;
|
|
108570
107067
|
try {
|
|
108571
|
-
ast = parseSource(
|
|
107068
|
+
ast = parseSource(readFileSync12(join15(root, path), "utf8"), { jsx: false });
|
|
108572
107069
|
} catch (error) {
|
|
108573
107070
|
if (error instanceof SyntaxError) {
|
|
108574
107071
|
continue;
|
|
@@ -108604,7 +107101,7 @@ function definitionParseErrors(root, files) {
|
|
|
108604
107101
|
continue;
|
|
108605
107102
|
}
|
|
108606
107103
|
try {
|
|
108607
|
-
parseSource(
|
|
107104
|
+
parseSource(readFileSync12(join15(root, path), "utf8"), { jsx: module && (extname(path) === ".tsx" || extname(path) === ".jsx") });
|
|
108608
107105
|
} catch (error) {
|
|
108609
107106
|
if (!(error instanceof SyntaxError)) {
|
|
108610
107107
|
throw error;
|
|
@@ -108616,10 +107113,10 @@ function definitionParseErrors(root, files) {
|
|
|
108616
107113
|
}
|
|
108617
107114
|
function writeGeneratedModule(root, relativePath, source, hasEntries) {
|
|
108618
107115
|
const path = join15(root, relativePath);
|
|
108619
|
-
if (!hasEntries && !
|
|
107116
|
+
if (!hasEntries && !existsSync7(path)) {
|
|
108620
107117
|
return;
|
|
108621
107118
|
}
|
|
108622
|
-
if (
|
|
107119
|
+
if (existsSync7(path) && readFileSync12(path, "utf8") === source) {
|
|
108623
107120
|
return;
|
|
108624
107121
|
}
|
|
108625
107122
|
mkdirSync3(dirname7(path), { recursive: true });
|
|
@@ -108638,22 +107135,10 @@ function roleFilesOf(root, answer, diagnostics) {
|
|
|
108638
107135
|
diagnostics.push(...answer.diagnostics);
|
|
108639
107136
|
return answer.roles;
|
|
108640
107137
|
}
|
|
108641
|
-
function checkPagePermissions(pages, permissions, diagnostics) {
|
|
108642
|
-
const known = knownPermissionUids(permissions);
|
|
108643
|
-
for (const page of pages) {
|
|
108644
|
-
for (const permission of page.authorizer?.permissions ?? []) {
|
|
108645
|
-
if (!known.has(permission)) {
|
|
108646
|
-
diagnostics.push(
|
|
108647
|
-
diagnosticAt(page.path, page.resourceNodes.authorizer, `authorizer.permissions: ${permissionReferenceProblem(permission, permissions)}`)
|
|
108648
|
-
);
|
|
108649
|
-
}
|
|
108650
|
-
}
|
|
108651
|
-
}
|
|
108652
|
-
}
|
|
108653
107138
|
function readWorkflowReferences(root, files, diagnostics) {
|
|
108654
107139
|
const workflowFiles = files.filter((path) => classify(path) === "workflow").map((path) => {
|
|
108655
107140
|
try {
|
|
108656
|
-
return { path, ast: parseSource(
|
|
107141
|
+
return { path, ast: parseSource(readFileSync12(join15(root, path), "utf8"), { jsx: false }) };
|
|
108657
107142
|
} catch (error) {
|
|
108658
107143
|
if (error instanceof SyntaxError) {
|
|
108659
107144
|
return { path, ast: null };
|
|
@@ -108685,30 +107170,93 @@ function lintPageUnits(units, resources, pages, diagnostics, assetsComplete, dom
|
|
|
108685
107170
|
}
|
|
108686
107171
|
});
|
|
108687
107172
|
}
|
|
108688
|
-
function
|
|
108689
|
-
|
|
108690
|
-
const pages = [];
|
|
108691
|
-
for (const path of paths) {
|
|
108692
|
-
const source = readFileSync11(join15(root, path), "utf8");
|
|
107173
|
+
function unparsedPages(root, paths) {
|
|
107174
|
+
return paths.filter((path) => {
|
|
108693
107175
|
try {
|
|
108694
|
-
|
|
107176
|
+
parseSource(readFileSync12(join15(root, path), "utf8"), { jsx: true });
|
|
107177
|
+
return false;
|
|
108695
107178
|
} catch (error) {
|
|
108696
|
-
if (
|
|
108697
|
-
|
|
107179
|
+
if (error instanceof SyntaxError) {
|
|
107180
|
+
return true;
|
|
108698
107181
|
}
|
|
107182
|
+
throw error;
|
|
108699
107183
|
}
|
|
108700
|
-
}
|
|
108701
|
-
|
|
108702
|
-
|
|
108703
|
-
|
|
108704
|
-
writeGeneratedModule(root, GENERATED_PAGES_PATH,
|
|
107184
|
+
});
|
|
107185
|
+
}
|
|
107186
|
+
function pageEntriesOf(root, answer, diagnostics, at) {
|
|
107187
|
+
writeSources(root, answer.written);
|
|
107188
|
+
writeGeneratedModule(root, GENERATED_PAGES_PATH, answer.source, answer.hasEntries);
|
|
107189
|
+
diagnostics.splice(at, 0, ...answer.diagnostics);
|
|
108705
107190
|
return {
|
|
108706
|
-
entries,
|
|
108707
|
-
pathsByName,
|
|
108708
|
-
uidsByPath: new Map(
|
|
108709
|
-
uidDiagnostics:
|
|
107191
|
+
entries: answer.entries,
|
|
107192
|
+
pathsByName: new Map(answer.pathsByName),
|
|
107193
|
+
uidsByPath: new Map(answer.uidsByPath),
|
|
107194
|
+
uidDiagnostics: answer.uidDiagnostics
|
|
108710
107195
|
};
|
|
108711
107196
|
}
|
|
107197
|
+
function pageFileAnswer(answers, path) {
|
|
107198
|
+
const answer = answers[path];
|
|
107199
|
+
if (answer === void 0) {
|
|
107200
|
+
throw new Error(`The workspace check has no answer for ${path}.`);
|
|
107201
|
+
}
|
|
107202
|
+
if (!answer.parsed) {
|
|
107203
|
+
throw parserDisagreement(path);
|
|
107204
|
+
}
|
|
107205
|
+
return answer;
|
|
107206
|
+
}
|
|
107207
|
+
function unitAnswerOf(answer, path, type) {
|
|
107208
|
+
const unit = answer.units.find((item) => item.path === path && item.type === type);
|
|
107209
|
+
if (unit === void 0) {
|
|
107210
|
+
throw new Error(`The workspace check has no answer for ${path}.`);
|
|
107211
|
+
}
|
|
107212
|
+
if (!unit.parsed) {
|
|
107213
|
+
throw parserDisagreement(path);
|
|
107214
|
+
}
|
|
107215
|
+
return unit;
|
|
107216
|
+
}
|
|
107217
|
+
function codeModuleAnswerOf(root, answer, request2, path, source, recalled) {
|
|
107218
|
+
const code2 = answer.codeModules[path];
|
|
107219
|
+
if (code2 !== void 0 && code2.parsed && code2.sha256 === sha256(source)) {
|
|
107220
|
+
return { code: code2, modules: answer.modules, stale: (component) => componentChanged(root, component) };
|
|
107221
|
+
}
|
|
107222
|
+
if (code2 !== void 0 && !code2.parsed) {
|
|
107223
|
+
throw parserDisagreement(path);
|
|
107224
|
+
}
|
|
107225
|
+
return recalledModule(root, request2, path, recalled);
|
|
107226
|
+
}
|
|
107227
|
+
function recalledModule(root, request2, path, recalled) {
|
|
107228
|
+
if (!recalled.has(path)) {
|
|
107229
|
+
const pages = checkWorkspace({ root, pages: { ...request2, pages: [], entries: [], menus: [], components: [path] } }).pages;
|
|
107230
|
+
const code2 = pages.codeModules[path];
|
|
107231
|
+
if (code2 === void 0 || !code2.parsed) {
|
|
107232
|
+
throw parserDisagreement(path);
|
|
107233
|
+
}
|
|
107234
|
+
recalled.set(path, { code: code2, modules: pages.modules, stale: () => false });
|
|
107235
|
+
}
|
|
107236
|
+
return recalled.get(path);
|
|
107237
|
+
}
|
|
107238
|
+
function componentChanged(root, component) {
|
|
107239
|
+
return Object.entries(component.outcome.reads).some(
|
|
107240
|
+
([path, hash]) => !existsSync7(join15(root, path)) || sha256(readFileSync12(join15(root, path), "utf8")) !== hash
|
|
107241
|
+
);
|
|
107242
|
+
}
|
|
107243
|
+
function sdkCustomOf(root, answer, request2, path, source, recalled) {
|
|
107244
|
+
const page = answer.pages[path];
|
|
107245
|
+
if (page !== void 0) {
|
|
107246
|
+
if (!page.parsed) {
|
|
107247
|
+
throw parserDisagreement(path);
|
|
107248
|
+
}
|
|
107249
|
+
return page.migrated !== null && source !== page.migrated ? page.sdkCustomOriginal : page.sdkCustom;
|
|
107250
|
+
}
|
|
107251
|
+
return codeModuleAnswerOf(root, answer, request2, path, source, recalled).code.sdkCustom;
|
|
107252
|
+
}
|
|
107253
|
+
function componentAnswerOf(root, answer, request2, path, source, recalled) {
|
|
107254
|
+
let module = codeModuleAnswerOf(root, answer, request2, path, source, recalled);
|
|
107255
|
+
if (module.code.component !== null && module.stale(module.code.component)) {
|
|
107256
|
+
module = recalledModule(root, request2, path, recalled);
|
|
107257
|
+
}
|
|
107258
|
+
return module.code.component === null ? null : { answer: module.code.component, modules: module.modules };
|
|
107259
|
+
}
|
|
108712
107260
|
var NOTIFICATION_KINDS = new Set(Object.keys(NOTIFICATION_DEFINITIONS));
|
|
108713
107261
|
function buildNotifications(root, files, { writeSource, names: names2, resources, builtInResources, recordBindingEntries, resourcesComplete, pages, workflows, assets, assetCatalog, diagnostics }) {
|
|
108714
107262
|
const paths = files.filter((path) => NOTIFICATION_KINDS.has(classify(path)));
|
|
@@ -108717,7 +107265,7 @@ function buildNotifications(root, files, { writeSource, names: names2, resources
|
|
|
108717
107265
|
const uidDefinitions = [];
|
|
108718
107266
|
for (const path of paths) {
|
|
108719
107267
|
const kind = classify(path);
|
|
108720
|
-
const source =
|
|
107268
|
+
const source = readFileSync12(join15(root, path), "utf8");
|
|
108721
107269
|
try {
|
|
108722
107270
|
const ast = parseSource(source, { jsx: false });
|
|
108723
107271
|
for (const { type, node } of uidDefinitionNodes(kind, path, ast)) {
|
|
@@ -108771,7 +107319,7 @@ function readLiquidFiles(root, files) {
|
|
|
108771
107319
|
return new Map(
|
|
108772
107320
|
files.filter(
|
|
108773
107321
|
(path) => NOTIFICATION_DIRECTORIES.includes(topDirectory(path)) && path.endsWith(".liquid")
|
|
108774
|
-
).map((path) => [path,
|
|
107322
|
+
).map((path) => [path, readFileSync12(join15(root, path), "utf8")])
|
|
108775
107323
|
);
|
|
108776
107324
|
}
|
|
108777
107325
|
function objectProperty2(object, key) {
|
|
@@ -108924,7 +107472,8 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
108924
107472
|
let names2 = null;
|
|
108925
107473
|
let recordBindings = null;
|
|
108926
107474
|
const definitionDiagnosticsAt = diagnostics.length;
|
|
108927
|
-
const
|
|
107475
|
+
const pagePaths = files.filter((path) => classify(path) === "page");
|
|
107476
|
+
let generatedPages = null;
|
|
108928
107477
|
const packageFiles = readPackageFiles(root, diagnostics);
|
|
108929
107478
|
const packageWorkspace = isPackageWorkspace(packageFiles.manifest);
|
|
108930
107479
|
if (!packageWorkspace) {
|
|
@@ -108943,6 +107492,8 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
108943
107492
|
const failedPages = /* @__PURE__ */ new Set();
|
|
108944
107493
|
let moduleCheck = null;
|
|
108945
107494
|
let workspaceAnswer = null;
|
|
107495
|
+
let pagesAnswer = null;
|
|
107496
|
+
const pageChecks = /* @__PURE__ */ new Map();
|
|
108946
107497
|
let pageAssets = null;
|
|
108947
107498
|
const buildFile = (path) => {
|
|
108948
107499
|
const kind = classify(path);
|
|
@@ -108980,11 +107531,12 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
108980
107531
|
output.redirects = workspaceAnswer.definitions.redirects.redirects;
|
|
108981
107532
|
return;
|
|
108982
107533
|
}
|
|
108983
|
-
const source =
|
|
107534
|
+
const source = readFileSync12(join15(root, path), "utf8");
|
|
108984
107535
|
try {
|
|
108985
107536
|
const ast = parseSource(source, { jsx: extname(path) === ".tsx" });
|
|
107537
|
+
const answer = kind === "page" ? pageFileAnswer(pagesAnswer.pages, path) : null;
|
|
108986
107538
|
if (kind === "page") {
|
|
108987
|
-
diagnostics.push(...rowMenuReads
|
|
107539
|
+
diagnostics.push(...answer.rowMenuReads);
|
|
108988
107540
|
}
|
|
108989
107541
|
if (kind === "page" && unitBuildBlocked(moduleCheck, path)) {
|
|
108990
107542
|
failedPages.add(path);
|
|
@@ -108993,28 +107545,20 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
108993
107545
|
}
|
|
108994
107546
|
switch (kind) {
|
|
108995
107547
|
case "page": {
|
|
108996
|
-
const fixed =
|
|
107548
|
+
const fixed = answer.migrated ?? source;
|
|
108997
107549
|
const pageAst = fixed === source ? ast : parseSource(fixed, { jsx: true });
|
|
108998
107550
|
if (fixed !== source) {
|
|
108999
107551
|
migratedPages.set(path, fixed);
|
|
109000
107552
|
}
|
|
109001
|
-
const
|
|
109002
|
-
|
|
109003
|
-
|
|
109004
|
-
|
|
109005
|
-
|
|
109006
|
-
|
|
109007
|
-
|
|
109008
|
-
|
|
109009
|
-
|
|
109010
|
-
);
|
|
109011
|
-
output.pages.push(page);
|
|
109012
|
-
diagnostics.push(
|
|
109013
|
-
...page.warnings.map(
|
|
109014
|
-
(warning) => diagnosticAt(path, warning.node, warning.message, { severity: "warning" })
|
|
109015
|
-
)
|
|
109016
|
-
);
|
|
109017
|
-
diagnostics.push(...slugStringWarnings(path, page.resourceNodes.meta, names2));
|
|
107553
|
+
const built = unitOf(root, path, answer.outcome, pagesAnswer.modules);
|
|
107554
|
+
if ("diagnostic" in built) {
|
|
107555
|
+
diagnostics.push(built.diagnostic);
|
|
107556
|
+
failedPages.add(path);
|
|
107557
|
+
break;
|
|
107558
|
+
}
|
|
107559
|
+
output.pages.push({ ...answer.outcome.page, ...built.unit });
|
|
107560
|
+
pageChecks.set(path, answer.outcome.checks);
|
|
107561
|
+
diagnostics.push(...answer.outcome.warnings, ...answer.outcome.slugWarnings);
|
|
109018
107562
|
uiEntries.push({ path, source: fixed, ast: pageAst });
|
|
109019
107563
|
break;
|
|
109020
107564
|
}
|
|
@@ -109043,8 +107587,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109043
107587
|
testFiles.push({ path, source, ast });
|
|
109044
107588
|
break;
|
|
109045
107589
|
case "navigation":
|
|
109046
|
-
|
|
109047
|
-
diagnostics.push(...menuPermissionSlugWarnings(path, ast, permissionsBuild.entries));
|
|
107590
|
+
diagnostics.push(...pageFileAnswer(pagesAnswer.menus, path).diagnostics);
|
|
109048
107591
|
break;
|
|
109049
107592
|
}
|
|
109050
107593
|
} catch (error) {
|
|
@@ -109054,14 +107597,20 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109054
107597
|
}
|
|
109055
107598
|
}
|
|
109056
107599
|
};
|
|
109057
|
-
const buildUnit = (path,
|
|
109058
|
-
const source =
|
|
107600
|
+
const buildUnit = (path, answerOf, add) => {
|
|
107601
|
+
const source = readFileSync12(join15(root, path), "utf8");
|
|
109059
107602
|
try {
|
|
109060
107603
|
const ast = parseSource(source, { jsx: path.endsWith("x") });
|
|
109061
107604
|
const entry = { path, source, ast };
|
|
109062
|
-
|
|
109063
|
-
|
|
109064
|
-
|
|
107605
|
+
const { answer, modules } = answerOf(source);
|
|
107606
|
+
diagnostics.push(...answer.rowMenuReads);
|
|
107607
|
+
if (!unitBuildBlocked(moduleCheck, path) && answer.outcome.notComponent === void 0) {
|
|
107608
|
+
const built = unitOf(root, path, answer.outcome, modules);
|
|
107609
|
+
if ("diagnostic" in built) {
|
|
107610
|
+
diagnostics.push(built.diagnostic);
|
|
107611
|
+
return null;
|
|
107612
|
+
}
|
|
107613
|
+
add({ path, name: path, ...built.unit });
|
|
109065
107614
|
}
|
|
109066
107615
|
return entry;
|
|
109067
107616
|
} catch (error) {
|
|
@@ -109087,6 +107636,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109087
107636
|
workspaceAnswer = checkWorkspace({
|
|
109088
107637
|
root,
|
|
109089
107638
|
assetKeysFromDefinitions: true,
|
|
107639
|
+
pageUids: { paths: pagePaths, unparsed: unparsedPages(root, pagePaths), write: writeSource },
|
|
109090
107640
|
definitions: {
|
|
109091
107641
|
files,
|
|
109092
107642
|
priorAssetErrors: diagnostics.some((diagnostic2) => diagnostic2.path === "assets.ts" && diagnostic2.severity === "error"),
|
|
@@ -109096,8 +107646,6 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109096
107646
|
),
|
|
109097
107647
|
write: writeSource,
|
|
109098
107648
|
workflowPackageDeclared,
|
|
109099
|
-
pageEntries: generatedPages.entries,
|
|
109100
|
-
pagePathsByName: [...generatedPages.pathsByName],
|
|
109101
107649
|
fieldCatalog: FIELD_CATALOG,
|
|
109102
107650
|
capabilityCatalog: CAPABILITY_CATALOG,
|
|
109103
107651
|
binaryExtensions: [...BINARY_EXTENSIONS],
|
|
@@ -109111,13 +107659,14 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109111
107659
|
},
|
|
109112
107660
|
...moduleRequest === null ? {} : { modules: moduleRequest }
|
|
109113
107661
|
});
|
|
107662
|
+
generatedPages = pageEntriesOf(root, workspaceAnswer.pageUids, diagnostics, definitionDiagnosticsAt);
|
|
109114
107663
|
const definitionsAnswer = workspaceAnswer.definitions;
|
|
109115
107664
|
diagnostics.splice(definitionDiagnosticsAt, 0, ...definitionsAnswer.moduleUids.diagnostics);
|
|
109116
107665
|
writeSources(root, definitionsAnswer.moduleUids.written);
|
|
109117
107666
|
const recordBindingsAnswer = definitionsAnswer.recordBindings;
|
|
109118
107667
|
domainKeys = definitionsAnswer.domains?.keys ?? null;
|
|
109119
107668
|
declaredDomains = domainKeys === null ? null : domainEntries(domainKeys);
|
|
109120
|
-
if (declaredDomains !== null || !
|
|
107669
|
+
if (declaredDomains !== null || !existsSync7(join15(root, GENERATED_DOMAINS_PATH))) {
|
|
109121
107670
|
writeGeneratedModule(
|
|
109122
107671
|
root,
|
|
109123
107672
|
GENERATED_DOMAINS_PATH,
|
|
@@ -109159,7 +107708,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109159
107708
|
}
|
|
109160
107709
|
const assets = assetEntries(output.assets, assetCatalog);
|
|
109161
107710
|
pageAssets = assetsComplete ? assets : null;
|
|
109162
|
-
if (assetsComplete || !
|
|
107711
|
+
if (assetsComplete || !existsSync7(join15(root, GENERATED_ASSETS_PATH))) {
|
|
109163
107712
|
writeGeneratedModule(
|
|
109164
107713
|
root,
|
|
109165
107714
|
GENERATED_ASSETS_PATH,
|
|
@@ -109208,7 +107757,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109208
107757
|
generatedWorkspaceFieldsSource(generatedWorkspaceFields, workspaceFields, { workflowPackageDeclared }),
|
|
109209
107758
|
workspaceFieldKeysByName.size > 0
|
|
109210
107759
|
);
|
|
109211
|
-
const skillFiles = otherFiles.filter((path) => classify(path) === "skill").map((path) => ({ path, content:
|
|
107760
|
+
const skillFiles = otherFiles.filter((path) => classify(path) === "skill").map((path) => ({ path, content: readFileSync12(join15(root, path), "utf8") }));
|
|
109212
107761
|
const skillCheck = checkSkillFiles(skillFiles, { root, write: writeSource });
|
|
109213
107762
|
output.skills.push(...skillCheck.skills);
|
|
109214
107763
|
diagnostics.push(...skillCheck.diagnostics);
|
|
@@ -109224,7 +107773,25 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109224
107773
|
skillPathsByName.size > 0
|
|
109225
107774
|
);
|
|
109226
107775
|
const roles = roleFilesOf(root, definitionsAnswer.roles, diagnostics);
|
|
109227
|
-
|
|
107776
|
+
const rerunModules = moduleRequest !== null && moduleCheckStale(root, workspaceAnswer.modules);
|
|
107777
|
+
const pageRequest = pagesRequest({
|
|
107778
|
+
pages: pagePaths,
|
|
107779
|
+
entries: entryPaths.filter((path) => ENTRY_TYPES.has(moduleEntityType(path))).map((path) => [path, moduleEntityType(path)]),
|
|
107780
|
+
menus: files.filter((path) => classify(path) === "navigation"),
|
|
107781
|
+
migrate: fixSource && writeSource,
|
|
107782
|
+
names: names2,
|
|
107783
|
+
permissionEntries: permissionsBuild.entries,
|
|
107784
|
+
permissions: permissionsBuild.permissions,
|
|
107785
|
+
permissionsComplete: permissionsBuild.complete,
|
|
107786
|
+
assets: pageAssets,
|
|
107787
|
+
domainKeys,
|
|
107788
|
+
resources: resourcesComplete ? output.resources : null,
|
|
107789
|
+
builtInResourceSlugs: [...BUILT_IN_RESOURCE_SLUGS],
|
|
107790
|
+
generatedModules: Object.keys(moduleRequest?.generatedModules ?? {})
|
|
107791
|
+
});
|
|
107792
|
+
const secondAnswer = checkWorkspace({ root, pages: pageRequest, ...rerunModules ? { modules: moduleRequest } : {} });
|
|
107793
|
+
pagesAnswer = secondAnswer.pages;
|
|
107794
|
+
moduleCheck = moduleCheckOf(root, moduleRequest, rerunModules ? secondAnswer.modules : workspaceAnswer.modules);
|
|
109228
107795
|
for (const path of otherFiles) {
|
|
109229
107796
|
buildFile(path);
|
|
109230
107797
|
}
|
|
@@ -109237,12 +107804,11 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109237
107804
|
if (type === void 0) {
|
|
109238
107805
|
throw new Error(`The entry [${path}] is not a module that builds as an entry`);
|
|
109239
107806
|
}
|
|
109240
|
-
const entry = buildUnit(
|
|
109241
|
-
|
|
109242
|
-
|
|
109243
|
-
|
|
109244
|
-
|
|
109245
|
-
});
|
|
107807
|
+
const entry = buildUnit(
|
|
107808
|
+
path,
|
|
107809
|
+
() => ({ answer: unitAnswerOf(pagesAnswer, path, unitTypes.get(path)), modules: pagesAnswer.modules }),
|
|
107810
|
+
(unit) => output[type.output].push(unit)
|
|
107811
|
+
);
|
|
109246
107812
|
if (entry !== null && !uiEntries.some((item) => item.path === path)) {
|
|
109247
107813
|
uiEntries.push(entry);
|
|
109248
107814
|
}
|
|
@@ -109275,15 +107841,11 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109275
107841
|
diagnostics.push(...definitionsAnswer.config.staffDiagnostics);
|
|
109276
107842
|
output.config = config;
|
|
109277
107843
|
}
|
|
109278
|
-
|
|
109279
|
-
|
|
109280
|
-
|
|
109281
|
-
|
|
109282
|
-
checkPageResources(output.pages, output.resources, BUILT_IN_RESOURCE_SLUGS, names2, diagnostics);
|
|
109283
|
-
checkPageSeo(output.pages, output.resources, diagnostics);
|
|
109284
|
-
checkPublicPageBindings(output.pages, output.resources, diagnostics);
|
|
107844
|
+
for (const check2 of ["permissions", "resources", "seo", "publicBindings", "seoAssets"]) {
|
|
107845
|
+
for (const page of output.pages) {
|
|
107846
|
+
diagnostics.push(...pageChecks.get(page.path)[check2]);
|
|
107847
|
+
}
|
|
109285
107848
|
}
|
|
109286
|
-
checkPageSeoAssets(output.pages, pageAssets, diagnostics);
|
|
109287
107849
|
const notificationsComplete = !notificationCheck.diagnostics.some(
|
|
109288
107850
|
(diagnostic2) => diagnostic2.severity === "error"
|
|
109289
107851
|
);
|
|
@@ -109309,13 +107871,14 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109309
107871
|
);
|
|
109310
107872
|
const entriesByPath = new Map(uiEntries.map((entry) => [entry.path, entry]));
|
|
109311
107873
|
const sdkCustomPaths = /* @__PURE__ */ new Set();
|
|
107874
|
+
const recalledModules = /* @__PURE__ */ new Map();
|
|
109312
107875
|
for (const [path, module] of Object.entries(moduleGraph.modules)) {
|
|
109313
107876
|
if (module.kind !== "module" || !/\.[jt]sx?$/.test(path)) {
|
|
109314
107877
|
continue;
|
|
109315
107878
|
}
|
|
109316
107879
|
let entry = graphModules.get(path) ?? null;
|
|
109317
107880
|
if (entry === null) {
|
|
109318
|
-
const source =
|
|
107881
|
+
const source = readFileSync12(join15(root, path), "utf8");
|
|
109319
107882
|
try {
|
|
109320
107883
|
entry = { path, source, ast: parseSource(source, { jsx: path.endsWith("x") }) };
|
|
109321
107884
|
} catch (error) {
|
|
@@ -109325,17 +107888,19 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109325
107888
|
throw error;
|
|
109326
107889
|
}
|
|
109327
107890
|
}
|
|
109328
|
-
const references =
|
|
107891
|
+
const references = sdkCustomOf(root, pagesAnswer, pageRequest, path, entry.source, recalledModules);
|
|
109329
107892
|
if (references.length > 0) {
|
|
109330
107893
|
sdkCustomPaths.add(path);
|
|
109331
|
-
|
|
107894
|
+
diagnostics.push(...references);
|
|
109332
107895
|
}
|
|
109333
|
-
if (entriesByPath.has(path) || !path.endsWith(".tsx") || topDirectory(path) === "pages"
|
|
107896
|
+
if (entriesByPath.has(path) || !path.endsWith(".tsx") || topDirectory(path) === "pages") {
|
|
109334
107897
|
continue;
|
|
109335
107898
|
}
|
|
109336
|
-
|
|
109337
|
-
|
|
109338
|
-
|
|
107899
|
+
const component = componentAnswerOf(root, pagesAnswer, pageRequest, path, entry.source, recalledModules);
|
|
107900
|
+
if (component === null) {
|
|
107901
|
+
continue;
|
|
107902
|
+
}
|
|
107903
|
+
buildUnit(path, () => component, (unit) => output.components.push(unit));
|
|
109339
107904
|
}
|
|
109340
107905
|
const workflowBuild = buildWorkflows({
|
|
109341
107906
|
workflows: rereadWorkflowFiles(root, workflowFiles),
|
|
@@ -109427,9 +107992,7 @@ function buildMaterializedWorkspace(root, plan, { assetCatalog = null, writeSour
|
|
|
109427
107992
|
);
|
|
109428
107993
|
const layouts = output.layouts.map(({ lint: _lint, ...layout }) => layout);
|
|
109429
107994
|
const entryComponents = [...output.components, ...output.layouts].filter((unit) => entryPaths.includes(unit.path) && moduleEntityType(unit.path) === "component").map(({ path, compiled_code }) => ({ path, compiled_code }));
|
|
109430
|
-
const pages = output.pages.map(
|
|
109431
|
-
({ layoutNode: _layoutNode, resourceNodes: _resourceNodes, seoReads: _seoReads, seoAsset: _seoAsset, warnings: _warnings, lint: _lint, ...page }) => page
|
|
109432
|
-
);
|
|
107995
|
+
const pages = output.pages.map(({ lint: _lint, ...page }) => page);
|
|
109433
107996
|
const packageRelease = packageWorkspace ? buildPackage(root, {
|
|
109434
107997
|
manifest: packageFiles.manifest,
|
|
109435
107998
|
files: files.filter((path) => !plan.files.has(path)),
|