@diagonal-hq/cli 0.8.1 → 0.9.0
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/README.md +36 -11
- package/dist/cli.mjs +938 -583
- package/dist/index.d.ts +6 -5
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -23059,8 +23059,8 @@ ${lanes.join("\n")}
|
|
|
23059
23059
|
return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
23060
23060
|
}
|
|
23061
23061
|
function forEachReturnStatement(body, visitor) {
|
|
23062
|
-
return
|
|
23063
|
-
function
|
|
23062
|
+
return traverse6(body);
|
|
23063
|
+
function traverse6(node) {
|
|
23064
23064
|
switch (node.kind) {
|
|
23065
23065
|
case 254:
|
|
23066
23066
|
return visitor(node);
|
|
@@ -23079,13 +23079,13 @@ ${lanes.join("\n")}
|
|
|
23079
23079
|
case 257:
|
|
23080
23080
|
case 259:
|
|
23081
23081
|
case 300:
|
|
23082
|
-
return forEachChild(node,
|
|
23082
|
+
return forEachChild(node, traverse6);
|
|
23083
23083
|
}
|
|
23084
23084
|
}
|
|
23085
23085
|
}
|
|
23086
23086
|
function forEachYieldExpression(body, visitor) {
|
|
23087
|
-
return
|
|
23088
|
-
function
|
|
23087
|
+
return traverse6(body);
|
|
23088
|
+
function traverse6(node) {
|
|
23089
23089
|
switch (node.kind) {
|
|
23090
23090
|
case 230:
|
|
23091
23091
|
const value = visitor(node);
|
|
@@ -23096,7 +23096,7 @@ ${lanes.join("\n")}
|
|
|
23096
23096
|
if (!operand) {
|
|
23097
23097
|
return;
|
|
23098
23098
|
}
|
|
23099
|
-
return
|
|
23099
|
+
return traverse6(operand);
|
|
23100
23100
|
case 267:
|
|
23101
23101
|
case 265:
|
|
23102
23102
|
case 268:
|
|
@@ -23105,10 +23105,10 @@ ${lanes.join("\n")}
|
|
|
23105
23105
|
default:
|
|
23106
23106
|
if (isFunctionLike(node)) {
|
|
23107
23107
|
if (node.name && node.name.kind === 168) {
|
|
23108
|
-
return
|
|
23108
|
+
return traverse6(node.name.expression);
|
|
23109
23109
|
}
|
|
23110
23110
|
} else if (!isPartOfTypeNode(node)) {
|
|
23111
|
-
return forEachChild(node,
|
|
23111
|
+
return forEachChild(node, traverse6);
|
|
23112
23112
|
}
|
|
23113
23113
|
}
|
|
23114
23114
|
}
|
|
@@ -25723,9 +25723,9 @@ ${lanes.join("\n")}
|
|
|
25723
25723
|
} else {
|
|
25724
25724
|
forEach(declarations, (member) => {
|
|
25725
25725
|
if (isAccessor2(member) && isStatic2(member) === isStatic2(accessor)) {
|
|
25726
|
-
const
|
|
25726
|
+
const memberName2 = getPropertyNameForPropertyNameNode(member.name);
|
|
25727
25727
|
const accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
|
25728
|
-
if (
|
|
25728
|
+
if (memberName2 === accessorName) {
|
|
25729
25729
|
if (!firstAccessor) {
|
|
25730
25730
|
firstAccessor = member;
|
|
25731
25731
|
} else if (!secondAccessor) {
|
|
@@ -35869,7 +35869,7 @@ ${lanes.join("\n")}
|
|
|
35869
35869
|
/* AdviseOnEmitNode */
|
|
35870
35870
|
);
|
|
35871
35871
|
}
|
|
35872
|
-
function createDecorateHelper(decoratorExpressions, target,
|
|
35872
|
+
function createDecorateHelper(decoratorExpressions, target, memberName2, descriptor) {
|
|
35873
35873
|
context.requestEmitHelper(decorateHelper);
|
|
35874
35874
|
const argumentsArray = [];
|
|
35875
35875
|
argumentsArray.push(factory2.createArrayLiteralExpression(
|
|
@@ -35878,8 +35878,8 @@ ${lanes.join("\n")}
|
|
|
35878
35878
|
true
|
|
35879
35879
|
));
|
|
35880
35880
|
argumentsArray.push(target);
|
|
35881
|
-
if (
|
|
35882
|
-
argumentsArray.push(
|
|
35881
|
+
if (memberName2) {
|
|
35882
|
+
argumentsArray.push(memberName2);
|
|
35883
35883
|
if (descriptor) {
|
|
35884
35884
|
argumentsArray.push(descriptor);
|
|
35885
35885
|
}
|
|
@@ -37646,13 +37646,13 @@ ${lanes.join("\n")}
|
|
|
37646
37646
|
void 0
|
|
37647
37647
|
);
|
|
37648
37648
|
}
|
|
37649
|
-
function createMemberAccessForPropertyName(factory2, target,
|
|
37650
|
-
if (isComputedPropertyName(
|
|
37651
|
-
return setTextRange(factory2.createElementAccessExpression(target,
|
|
37649
|
+
function createMemberAccessForPropertyName(factory2, target, memberName2, location) {
|
|
37650
|
+
if (isComputedPropertyName(memberName2)) {
|
|
37651
|
+
return setTextRange(factory2.createElementAccessExpression(target, memberName2.expression), location);
|
|
37652
37652
|
} else {
|
|
37653
37653
|
const expression2 = setTextRange(
|
|
37654
|
-
isMemberName2(
|
|
37655
|
-
|
|
37654
|
+
isMemberName2(memberName2) ? factory2.createPropertyAccessExpression(target, memberName2) : factory2.createElementAccessExpression(target, memberName2),
|
|
37655
|
+
memberName2
|
|
37656
37656
|
);
|
|
37657
37657
|
addEmitFlags(
|
|
37658
37658
|
expression2,
|
|
@@ -37783,13 +37783,13 @@ ${lanes.join("\n")}
|
|
|
37783
37783
|
return setParent(setTextRange(factory2.cloneNode(node), node), node.parent);
|
|
37784
37784
|
}
|
|
37785
37785
|
}
|
|
37786
|
-
function createExpressionForPropertyName(factory2,
|
|
37787
|
-
if (isIdentifier5(
|
|
37788
|
-
return factory2.createStringLiteralFromNode(
|
|
37789
|
-
} else if (isComputedPropertyName(
|
|
37790
|
-
return setParent(setTextRange(factory2.cloneNode(
|
|
37786
|
+
function createExpressionForPropertyName(factory2, memberName2) {
|
|
37787
|
+
if (isIdentifier5(memberName2)) {
|
|
37788
|
+
return factory2.createStringLiteralFromNode(memberName2);
|
|
37789
|
+
} else if (isComputedPropertyName(memberName2)) {
|
|
37790
|
+
return setParent(setTextRange(factory2.cloneNode(memberName2.expression), memberName2.expression), memberName2.expression.parent);
|
|
37791
37791
|
} else {
|
|
37792
|
-
return setParent(setTextRange(factory2.cloneNode(
|
|
37792
|
+
return setParent(setTextRange(factory2.cloneNode(memberName2), memberName2), memberName2.parent);
|
|
37793
37793
|
}
|
|
37794
37794
|
}
|
|
37795
37795
|
function createExpressionForAccessorDeclaration(factory2, properties, property, receiver, multiLine) {
|
|
@@ -62933,14 +62933,14 @@ ${lanes.join("\n")}
|
|
|
62933
62933
|
}
|
|
62934
62934
|
}
|
|
62935
62935
|
}
|
|
62936
|
-
function tryGetMemberInModuleExports(
|
|
62936
|
+
function tryGetMemberInModuleExports(memberName2, moduleSymbol) {
|
|
62937
62937
|
const symbolTable = getExportsOfModule(moduleSymbol);
|
|
62938
62938
|
if (symbolTable) {
|
|
62939
|
-
return symbolTable.get(
|
|
62939
|
+
return symbolTable.get(memberName2);
|
|
62940
62940
|
}
|
|
62941
62941
|
}
|
|
62942
|
-
function tryGetMemberInModuleExportsAndProperties(
|
|
62943
|
-
const symbol = tryGetMemberInModuleExports(
|
|
62942
|
+
function tryGetMemberInModuleExportsAndProperties(memberName2, moduleSymbol) {
|
|
62943
|
+
const symbol = tryGetMemberInModuleExports(memberName2, moduleSymbol);
|
|
62944
62944
|
if (symbol) {
|
|
62945
62945
|
return symbol;
|
|
62946
62946
|
}
|
|
@@ -62949,7 +62949,7 @@ ${lanes.join("\n")}
|
|
|
62949
62949
|
return void 0;
|
|
62950
62950
|
}
|
|
62951
62951
|
const type = getTypeOfSymbol(exportEquals);
|
|
62952
|
-
return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type,
|
|
62952
|
+
return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName2) : void 0;
|
|
62953
62953
|
}
|
|
62954
62954
|
function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) {
|
|
62955
62955
|
return !(resolvedExternalModuleType.flags & 12713980 || getObjectFlags(resolvedExternalModuleType) & 1 || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path
|
|
@@ -64591,16 +64591,16 @@ ${lanes.join("\n")}
|
|
|
64591
64591
|
if (getDeclaredTypeOfSymbol(parentSymbol) === type) {
|
|
64592
64592
|
return parentName;
|
|
64593
64593
|
}
|
|
64594
|
-
const
|
|
64594
|
+
const memberName2 = symbolName(type.symbol);
|
|
64595
64595
|
if (isIdentifierText(
|
|
64596
|
-
|
|
64596
|
+
memberName2,
|
|
64597
64597
|
99
|
|
64598
64598
|
/* ESNext */
|
|
64599
64599
|
)) {
|
|
64600
64600
|
return appendReferenceToType(
|
|
64601
64601
|
parentName,
|
|
64602
64602
|
factory.createTypeReferenceNode(
|
|
64603
|
-
|
|
64603
|
+
memberName2,
|
|
64604
64604
|
/*typeArguments*/
|
|
64605
64605
|
void 0
|
|
64606
64606
|
)
|
|
@@ -64608,9 +64608,9 @@ ${lanes.join("\n")}
|
|
|
64608
64608
|
}
|
|
64609
64609
|
if (isImportTypeNode(parentName)) {
|
|
64610
64610
|
parentName.isTypeOf = true;
|
|
64611
|
-
return factory.createIndexedAccessTypeNode(parentName, factory.createLiteralTypeNode(factory.createStringLiteral(
|
|
64611
|
+
return factory.createIndexedAccessTypeNode(parentName, factory.createLiteralTypeNode(factory.createStringLiteral(memberName2)));
|
|
64612
64612
|
} else if (isTypeReferenceNode(parentName)) {
|
|
64613
|
-
return factory.createIndexedAccessTypeNode(factory.createTypeQueryNode(parentName.typeName), factory.createLiteralTypeNode(factory.createStringLiteral(
|
|
64613
|
+
return factory.createIndexedAccessTypeNode(factory.createTypeQueryNode(parentName.typeName), factory.createLiteralTypeNode(factory.createStringLiteral(memberName2)));
|
|
64614
64614
|
} else {
|
|
64615
64615
|
return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
|
|
64616
64616
|
}
|
|
@@ -67948,9 +67948,9 @@ ${lanes.join("\n")}
|
|
|
67948
67948
|
const last22 = memberProps[memberProps.length - 1];
|
|
67949
67949
|
const initializedValue = last22.declarations && last22.declarations[0] && isEnumMember2(last22.declarations[0]) ? getConstantValue2(last22.declarations[0]) : void 0;
|
|
67950
67950
|
const initializer2 = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
|
|
67951
|
-
const
|
|
67951
|
+
const memberName22 = unescapeLeadingUnderscores(last22.escapedName);
|
|
67952
67952
|
const member2 = factory.createEnumMember(
|
|
67953
|
-
|
|
67953
|
+
memberName22,
|
|
67954
67954
|
initializer2
|
|
67955
67955
|
);
|
|
67956
67956
|
members.push(member2);
|
|
@@ -67967,10 +67967,10 @@ ${lanes.join("\n")}
|
|
|
67967
67967
|
initializer = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
|
|
67968
67968
|
initializerLength = (initializer == null ? void 0 : initializer.text.length) ?? 0;
|
|
67969
67969
|
}
|
|
67970
|
-
const
|
|
67971
|
-
context.approximateLength += 4 +
|
|
67970
|
+
const memberName2 = unescapeLeadingUnderscores(p.escapedName);
|
|
67971
|
+
context.approximateLength += 4 + memberName2.length + initializerLength;
|
|
67972
67972
|
const member = factory.createEnumMember(
|
|
67973
|
-
|
|
67973
|
+
memberName2,
|
|
67974
67974
|
initializer
|
|
67975
67975
|
);
|
|
67976
67976
|
members.push(member);
|
|
@@ -71457,24 +71457,24 @@ ${lanes.join("\n")}
|
|
|
71457
71457
|
const declName = isBinaryExpression2(decl) ? decl.left : decl.name;
|
|
71458
71458
|
const type = isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
|
|
71459
71459
|
if (isTypeUsableAsPropertyName(type)) {
|
|
71460
|
-
const
|
|
71460
|
+
const memberName2 = getPropertyNameFromType(type);
|
|
71461
71461
|
const symbolFlags = decl.symbol.flags;
|
|
71462
|
-
let lateSymbol = lateSymbols.get(
|
|
71463
|
-
if (!lateSymbol) lateSymbols.set(
|
|
71462
|
+
let lateSymbol = lateSymbols.get(memberName2);
|
|
71463
|
+
if (!lateSymbol) lateSymbols.set(memberName2, lateSymbol = createSymbol(
|
|
71464
71464
|
0,
|
|
71465
|
-
|
|
71465
|
+
memberName2,
|
|
71466
71466
|
4096
|
|
71467
71467
|
/* Late */
|
|
71468
71468
|
));
|
|
71469
|
-
const earlySymbol = earlySymbols && earlySymbols.get(
|
|
71469
|
+
const earlySymbol = earlySymbols && earlySymbols.get(memberName2);
|
|
71470
71470
|
if (!(parent2.flags & 32) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
71471
71471
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
71472
|
-
const name = !(type.flags & 16384) && unescapeLeadingUnderscores(
|
|
71472
|
+
const name = !(type.flags & 16384) && unescapeLeadingUnderscores(memberName2) || declarationNameToString(declName);
|
|
71473
71473
|
forEach(declarations, (declaration) => error2(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
71474
71474
|
error2(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
71475
71475
|
lateSymbol = createSymbol(
|
|
71476
71476
|
0,
|
|
71477
|
-
|
|
71477
|
+
memberName2,
|
|
71478
71478
|
4096
|
|
71479
71479
|
/* Late */
|
|
71480
71480
|
);
|
|
@@ -73315,14 +73315,14 @@ ${lanes.join("\n")}
|
|
|
73315
73315
|
if (type.arrayFallbackSignatures) {
|
|
73316
73316
|
return type.arrayFallbackSignatures;
|
|
73317
73317
|
}
|
|
73318
|
-
let
|
|
73318
|
+
let memberName2;
|
|
73319
73319
|
if (everyType(type, (t) => {
|
|
73320
73320
|
var _a;
|
|
73321
|
-
return !!((_a = t.symbol) == null ? void 0 : _a.parent) && isArrayOrTupleSymbol(t.symbol.parent) && (!
|
|
73321
|
+
return !!((_a = t.symbol) == null ? void 0 : _a.parent) && isArrayOrTupleSymbol(t.symbol.parent) && (!memberName2 ? (memberName2 = t.symbol.escapedName, true) : memberName2 === t.symbol.escapedName);
|
|
73322
73322
|
})) {
|
|
73323
73323
|
const arrayArg = mapType(type, (t) => getMappedType((isReadonlyArraySymbol(t.symbol.parent) ? globalReadonlyArrayType : globalArrayType).typeParameters[0], t.mapper));
|
|
73324
73324
|
const arrayType = createArrayType(arrayArg, someType(type, (t) => isReadonlyArraySymbol(t.symbol.parent)));
|
|
73325
|
-
return type.arrayFallbackSignatures = getSignaturesOfType(getTypeOfPropertyOfType(arrayType,
|
|
73325
|
+
return type.arrayFallbackSignatures = getSignaturesOfType(getTypeOfPropertyOfType(arrayType, memberName2), kind);
|
|
73326
73326
|
}
|
|
73327
73327
|
type.arrayFallbackSignatures = result;
|
|
73328
73328
|
}
|
|
@@ -73633,11 +73633,11 @@ ${lanes.join("\n")}
|
|
|
73633
73633
|
if (links.flags & 512) {
|
|
73634
73634
|
links.containsArgumentsReference = true;
|
|
73635
73635
|
} else {
|
|
73636
|
-
links.containsArgumentsReference =
|
|
73636
|
+
links.containsArgumentsReference = traverse6(declaration.body);
|
|
73637
73637
|
}
|
|
73638
73638
|
}
|
|
73639
73639
|
return links.containsArgumentsReference;
|
|
73640
|
-
function
|
|
73640
|
+
function traverse6(node) {
|
|
73641
73641
|
if (!node) return false;
|
|
73642
73642
|
switch (node.kind) {
|
|
73643
73643
|
case 80:
|
|
@@ -73646,14 +73646,14 @@ ${lanes.join("\n")}
|
|
|
73646
73646
|
case 175:
|
|
73647
73647
|
case 178:
|
|
73648
73648
|
case 179:
|
|
73649
|
-
return node.name.kind === 168 &&
|
|
73649
|
+
return node.name.kind === 168 && traverse6(node.name);
|
|
73650
73650
|
case 212:
|
|
73651
73651
|
case 213:
|
|
73652
|
-
return
|
|
73652
|
+
return traverse6(node.expression);
|
|
73653
73653
|
case 304:
|
|
73654
|
-
return
|
|
73654
|
+
return traverse6(node.initializer);
|
|
73655
73655
|
default:
|
|
73656
|
-
return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && !!forEachChild(node,
|
|
73656
|
+
return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && !!forEachChild(node, traverse6);
|
|
73657
73657
|
}
|
|
73658
73658
|
}
|
|
73659
73659
|
}
|
|
@@ -96888,20 +96888,20 @@ ${lanes.join("\n")}
|
|
|
96888
96888
|
const isPrivate2 = isPrivateIdentifier(name);
|
|
96889
96889
|
const privateStaticFlags = isPrivate2 && isStaticMember ? 16 : 0;
|
|
96890
96890
|
const names2 = isPrivate2 ? privateIdentifiers : isStaticMember ? staticNames : instanceNames;
|
|
96891
|
-
const
|
|
96892
|
-
if (
|
|
96891
|
+
const memberName2 = name && getEffectivePropertyNameForPropertyNameNode(name);
|
|
96892
|
+
if (memberName2) {
|
|
96893
96893
|
switch (member.kind) {
|
|
96894
96894
|
case 178:
|
|
96895
|
-
addName(names2, name,
|
|
96895
|
+
addName(names2, name, memberName2, 1 | privateStaticFlags);
|
|
96896
96896
|
break;
|
|
96897
96897
|
case 179:
|
|
96898
|
-
addName(names2, name,
|
|
96898
|
+
addName(names2, name, memberName2, 2 | privateStaticFlags);
|
|
96899
96899
|
break;
|
|
96900
96900
|
case 173:
|
|
96901
|
-
addName(names2, name,
|
|
96901
|
+
addName(names2, name, memberName2, 3 | privateStaticFlags);
|
|
96902
96902
|
break;
|
|
96903
96903
|
case 175:
|
|
96904
|
-
addName(names2, name,
|
|
96904
|
+
addName(names2, name, memberName2, 8 | privateStaticFlags);
|
|
96905
96905
|
break;
|
|
96906
96906
|
}
|
|
96907
96907
|
}
|
|
@@ -96935,8 +96935,8 @@ ${lanes.join("\n")}
|
|
|
96935
96935
|
const memberNameNode = member.name;
|
|
96936
96936
|
const isStaticMember = isStatic2(member);
|
|
96937
96937
|
if (isStaticMember && memberNameNode) {
|
|
96938
|
-
const
|
|
96939
|
-
switch (
|
|
96938
|
+
const memberName2 = getEffectivePropertyNameForPropertyNameNode(memberNameNode);
|
|
96939
|
+
switch (memberName2) {
|
|
96940
96940
|
case "name":
|
|
96941
96941
|
case "length":
|
|
96942
96942
|
case "caller":
|
|
@@ -96948,7 +96948,7 @@ ${lanes.join("\n")}
|
|
|
96948
96948
|
case "prototype":
|
|
96949
96949
|
const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
|
|
96950
96950
|
const className = getNameOfSymbolAsWritten(getSymbolOfDeclaration(node));
|
|
96951
|
-
error2(memberNameNode, message,
|
|
96951
|
+
error2(memberNameNode, message, memberName2, className);
|
|
96952
96952
|
break;
|
|
96953
96953
|
}
|
|
96954
96954
|
}
|
|
@@ -96958,24 +96958,24 @@ ${lanes.join("\n")}
|
|
|
96958
96958
|
const names2 = /* @__PURE__ */ new Map();
|
|
96959
96959
|
for (const member of node.members) {
|
|
96960
96960
|
if (member.kind === 172) {
|
|
96961
|
-
let
|
|
96961
|
+
let memberName2;
|
|
96962
96962
|
const name = member.name;
|
|
96963
96963
|
switch (name.kind) {
|
|
96964
96964
|
case 11:
|
|
96965
96965
|
case 9:
|
|
96966
|
-
|
|
96966
|
+
memberName2 = name.text;
|
|
96967
96967
|
break;
|
|
96968
96968
|
case 80:
|
|
96969
|
-
|
|
96969
|
+
memberName2 = idText(name);
|
|
96970
96970
|
break;
|
|
96971
96971
|
default:
|
|
96972
96972
|
continue;
|
|
96973
96973
|
}
|
|
96974
|
-
if (names2.get(
|
|
96975
|
-
error2(getNameOfDeclaration(member.symbol.valueDeclaration), Diagnostics.Duplicate_identifier_0,
|
|
96976
|
-
error2(member.name, Diagnostics.Duplicate_identifier_0,
|
|
96974
|
+
if (names2.get(memberName2)) {
|
|
96975
|
+
error2(getNameOfDeclaration(member.symbol.valueDeclaration), Diagnostics.Duplicate_identifier_0, memberName2);
|
|
96976
|
+
error2(member.name, Diagnostics.Duplicate_identifier_0, memberName2);
|
|
96977
96977
|
} else {
|
|
96978
|
-
names2.set(
|
|
96978
|
+
names2.set(memberName2, true);
|
|
96979
96979
|
}
|
|
96980
96980
|
}
|
|
96981
96981
|
}
|
|
@@ -115759,7 +115759,7 @@ ${lanes.join("\n")}
|
|
|
115759
115759
|
return void 0;
|
|
115760
115760
|
}
|
|
115761
115761
|
const prefix2 = getClassMemberPrefix(node, member);
|
|
115762
|
-
const
|
|
115762
|
+
const memberName2 = getExpressionForPropertyName(
|
|
115763
115763
|
member,
|
|
115764
115764
|
/*generateNameForComputedPropertyName*/
|
|
115765
115765
|
!hasSyntacticModifier(
|
|
@@ -115772,7 +115772,7 @@ ${lanes.join("\n")}
|
|
|
115772
115772
|
const helper = emitHelpers().createDecorateHelper(
|
|
115773
115773
|
decoratorExpressions,
|
|
115774
115774
|
prefix2,
|
|
115775
|
-
|
|
115775
|
+
memberName2,
|
|
115776
115776
|
descriptor
|
|
115777
115777
|
);
|
|
115778
115778
|
setEmitFlags(
|
|
@@ -123613,14 +123613,14 @@ ${lanes.join("\n")}
|
|
|
123613
123613
|
const name = isComputedPropertyName(propertyName) ? propertyName.expression : isIdentifier5(propertyName) ? factory2.createStringLiteral(unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName;
|
|
123614
123614
|
e = factory2.createObjectDefinePropertyCall(receiver, name, factory2.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
|
|
123615
123615
|
} else {
|
|
123616
|
-
const
|
|
123616
|
+
const memberName2 = createMemberAccessForPropertyName(
|
|
123617
123617
|
factory2,
|
|
123618
123618
|
receiver,
|
|
123619
123619
|
propertyName,
|
|
123620
123620
|
/*location*/
|
|
123621
123621
|
member.name
|
|
123622
123622
|
);
|
|
123623
|
-
e = factory2.createAssignment(
|
|
123623
|
+
e = factory2.createAssignment(memberName2, memberFunction);
|
|
123624
123624
|
}
|
|
123625
123625
|
setEmitFlags(
|
|
123626
123626
|
memberFunction,
|
|
@@ -156340,8 +156340,8 @@ ${lanes.join("\n")}
|
|
|
156340
156340
|
}
|
|
156341
156341
|
function quote(sourceFile, preferences, text) {
|
|
156342
156342
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
156343
|
-
const
|
|
156344
|
-
return quotePreference === 0 ? `'${stripQuotes(
|
|
156343
|
+
const quoted2 = JSON.stringify(text);
|
|
156344
|
+
return quotePreference === 0 ? `'${stripQuotes(quoted2).replace(/'/g, () => "\\'").replace(/\\"/g, '"')}'` : quoted2;
|
|
156345
156345
|
}
|
|
156346
156346
|
function isEqualityOperatorKind(kind) {
|
|
156347
156347
|
switch (kind) {
|
|
@@ -160993,10 +160993,10 @@ interface Symbol {
|
|
|
160993
160993
|
case 9: {
|
|
160994
160994
|
const defineCall = node;
|
|
160995
160995
|
const className = special === 7 ? defineCall.arguments[0] : defineCall.arguments[0].expression;
|
|
160996
|
-
const
|
|
160996
|
+
const memberName2 = defineCall.arguments[1];
|
|
160997
160997
|
const [depth, classNameIdentifier] = startNestedNodes(node, className);
|
|
160998
160998
|
startNode(node, classNameIdentifier);
|
|
160999
|
-
startNode(node, setTextRange(factory.createIdentifier(
|
|
160999
|
+
startNode(node, setTextRange(factory.createIdentifier(memberName2.text), memberName2));
|
|
161000
161000
|
addChildrenRecursively(node.arguments[2]);
|
|
161001
161001
|
endNode();
|
|
161002
161002
|
endNode();
|
|
@@ -176591,14 +176591,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
176591
176591
|
return factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(obj, propertyName), createUndefined()));
|
|
176592
176592
|
}
|
|
176593
176593
|
function createActionsForAddMissingMemberInTypeScriptFile(context, { parentDeclaration, declSourceFile, modifierFlags, token }) {
|
|
176594
|
-
const
|
|
176594
|
+
const memberName2 = token.text;
|
|
176595
176595
|
const isStatic22 = modifierFlags & 256;
|
|
176596
176596
|
const typeNode = getTypeNode2(context.program.getTypeChecker(), parentDeclaration, token);
|
|
176597
|
-
const addPropertyDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addPropertyDeclaration(t, declSourceFile, parentDeclaration,
|
|
176597
|
+
const addPropertyDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName2, typeNode, modifierFlags2));
|
|
176598
176598
|
const actions2 = [createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(
|
|
176599
176599
|
modifierFlags & 256
|
|
176600
176600
|
/* Static */
|
|
176601
|
-
), [isStatic22 ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0,
|
|
176601
|
+
), [isStatic22 ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0, memberName2], fixMissingMember, Diagnostics.Add_all_missing_members)];
|
|
176602
176602
|
if (isStatic22 || isPrivateIdentifier(token)) {
|
|
176603
176603
|
return actions2;
|
|
176604
176604
|
}
|
|
@@ -176606,7 +176606,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
176606
176606
|
actions2.unshift(createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(
|
|
176607
176607
|
2
|
|
176608
176608
|
/* Private */
|
|
176609
|
-
), [Diagnostics.Declare_private_property_0,
|
|
176609
|
+
), [Diagnostics.Declare_private_property_0, memberName2]));
|
|
176610
176610
|
}
|
|
176611
176611
|
actions2.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode));
|
|
176612
176612
|
return actions2;
|
|
@@ -251060,13 +251060,13 @@ var FlowErrorTemplates = {
|
|
|
251060
251060
|
DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
|
|
251061
251061
|
DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
|
|
251062
251062
|
EnumBooleanMemberNotInitialized: ({
|
|
251063
|
-
memberName,
|
|
251063
|
+
memberName: memberName2,
|
|
251064
251064
|
enumName
|
|
251065
|
-
}) => `Boolean enum members need to be initialized. Use either \`${
|
|
251065
|
+
}) => `Boolean enum members need to be initialized. Use either \`${memberName2} = true,\` or \`${memberName2} = false,\` in enum \`${enumName}\`.`,
|
|
251066
251066
|
EnumDuplicateMemberName: ({
|
|
251067
|
-
memberName,
|
|
251067
|
+
memberName: memberName2,
|
|
251068
251068
|
enumName
|
|
251069
|
-
}) => `Enum member names need to be unique, but the name \`${
|
|
251069
|
+
}) => `Enum member names need to be unique, but the name \`${memberName2}\` has already been used before in enum \`${enumName}\`.`,
|
|
251070
251070
|
EnumInconsistentMemberValues: ({
|
|
251071
251071
|
enumName
|
|
251072
251072
|
}) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,
|
|
@@ -251079,26 +251079,26 @@ var FlowErrorTemplates = {
|
|
|
251079
251079
|
}) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
|
|
251080
251080
|
EnumInvalidMemberInitializerPrimaryType: ({
|
|
251081
251081
|
enumName,
|
|
251082
|
-
memberName,
|
|
251082
|
+
memberName: memberName2,
|
|
251083
251083
|
explicitType
|
|
251084
|
-
}) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${
|
|
251084
|
+
}) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName2}\` needs to be a ${explicitType} literal.`,
|
|
251085
251085
|
EnumInvalidMemberInitializerSymbolType: ({
|
|
251086
251086
|
enumName,
|
|
251087
|
-
memberName
|
|
251088
|
-
}) => `Symbol enum members cannot be initialized. Use \`${
|
|
251087
|
+
memberName: memberName2
|
|
251088
|
+
}) => `Symbol enum members cannot be initialized. Use \`${memberName2},\` in enum \`${enumName}\`.`,
|
|
251089
251089
|
EnumInvalidMemberInitializerUnknownType: ({
|
|
251090
251090
|
enumName,
|
|
251091
|
-
memberName
|
|
251092
|
-
}) => `The enum member initializer for \`${
|
|
251091
|
+
memberName: memberName2
|
|
251092
|
+
}) => `The enum member initializer for \`${memberName2}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`,
|
|
251093
251093
|
EnumInvalidMemberName: ({
|
|
251094
251094
|
enumName,
|
|
251095
|
-
memberName,
|
|
251095
|
+
memberName: memberName2,
|
|
251096
251096
|
suggestion
|
|
251097
|
-
}) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${
|
|
251097
|
+
}) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName2}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`,
|
|
251098
251098
|
EnumNumberMemberNotInitialized: ({
|
|
251099
251099
|
enumName,
|
|
251100
|
-
memberName
|
|
251101
|
-
}) => `Number enum members need to be initialized, e.g. \`${
|
|
251100
|
+
memberName: memberName2
|
|
251101
|
+
}) => `Number enum members need to be initialized, e.g. \`${memberName2} = 1\` in enum \`${enumName}\`.`,
|
|
251102
251102
|
EnumStringMemberInconsistentlyInitialized: ({
|
|
251103
251103
|
enumName
|
|
251104
251104
|
}) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`,
|
|
@@ -253186,28 +253186,28 @@ var flow = (superClass) => class FlowParserMixin extends superClass {
|
|
|
253186
253186
|
id,
|
|
253187
253187
|
init
|
|
253188
253188
|
} = this.flowEnumMemberRaw();
|
|
253189
|
-
const
|
|
253190
|
-
if (
|
|
253189
|
+
const memberName2 = id.name;
|
|
253190
|
+
if (memberName2 === "") {
|
|
253191
253191
|
continue;
|
|
253192
253192
|
}
|
|
253193
|
-
if (/^[a-z]/.test(
|
|
253193
|
+
if (/^[a-z]/.test(memberName2)) {
|
|
253194
253194
|
this.raise(FlowErrors.EnumInvalidMemberName, id, {
|
|
253195
|
-
memberName,
|
|
253196
|
-
suggestion:
|
|
253195
|
+
memberName: memberName2,
|
|
253196
|
+
suggestion: memberName2[0].toUpperCase() + memberName2.slice(1),
|
|
253197
253197
|
enumName
|
|
253198
253198
|
});
|
|
253199
253199
|
}
|
|
253200
|
-
if (seenNames.has(
|
|
253200
|
+
if (seenNames.has(memberName2)) {
|
|
253201
253201
|
this.raise(FlowErrors.EnumDuplicateMemberName, id, {
|
|
253202
|
-
memberName,
|
|
253202
|
+
memberName: memberName2,
|
|
253203
253203
|
enumName
|
|
253204
253204
|
});
|
|
253205
253205
|
}
|
|
253206
|
-
seenNames.add(
|
|
253206
|
+
seenNames.add(memberName2);
|
|
253207
253207
|
const context = {
|
|
253208
253208
|
enumName,
|
|
253209
253209
|
explicitType,
|
|
253210
|
-
memberName
|
|
253210
|
+
memberName: memberName2
|
|
253211
253211
|
};
|
|
253212
253212
|
memberNode.id = id;
|
|
253213
253213
|
switch (init.type) {
|
|
@@ -264210,17 +264210,44 @@ function fieldBuilderCall(node, options2) {
|
|
|
264210
264210
|
}
|
|
264211
264211
|
function resourceReference(node, options2) {
|
|
264212
264212
|
const binding = options2.resources ?? null;
|
|
264213
|
-
|
|
264213
|
+
const reference = binding === null ? null : resourceMember(node, binding.local);
|
|
264214
|
+
if (reference === null) {
|
|
264214
264215
|
throw new SourceError("MemberExpression is not allowed in static data. Use literal values only", node);
|
|
264215
264216
|
}
|
|
264216
|
-
const
|
|
264217
|
-
|
|
264217
|
+
const { nameNode, propertyNode: propertyNode2 } = reference;
|
|
264218
|
+
const name = `${binding.local}.${nameNode.name}`;
|
|
264219
|
+
if (!binding.slugsByName.has(nameNode.name)) {
|
|
264218
264220
|
throw new SourceError(
|
|
264219
|
-
`Unknown resource "${
|
|
264220
|
-
|
|
264221
|
+
`Unknown resource "${name}". Each name in ${binding.local} is a file in resources/`,
|
|
264222
|
+
nameNode
|
|
264221
264223
|
);
|
|
264222
264224
|
}
|
|
264223
|
-
|
|
264225
|
+
if (propertyNode2 === null) {
|
|
264226
|
+
throw new SourceError(
|
|
264227
|
+
`${name} is the metadata of the resource. Use ${name}.slug to name the resource`,
|
|
264228
|
+
node
|
|
264229
|
+
);
|
|
264230
|
+
}
|
|
264231
|
+
if (propertyNode2.name !== "slug") {
|
|
264232
|
+
throw new SourceError(
|
|
264233
|
+
`Static data cannot read ${name}.${propertyNode2.name}. Use ${name}.slug to name the resource`,
|
|
264234
|
+
propertyNode2
|
|
264235
|
+
);
|
|
264236
|
+
}
|
|
264237
|
+
return binding.slugsByName.get(nameNode.name);
|
|
264238
|
+
}
|
|
264239
|
+
function resourceMember(node, local) {
|
|
264240
|
+
if (node.computed || node.property.type !== "Identifier") {
|
|
264241
|
+
return null;
|
|
264242
|
+
}
|
|
264243
|
+
if (node.object.type === "Identifier") {
|
|
264244
|
+
return node.object.name === local ? { nameNode: node.property, propertyNode: null } : null;
|
|
264245
|
+
}
|
|
264246
|
+
const inner = node.object;
|
|
264247
|
+
if (inner.type !== "MemberExpression" || inner.computed || inner.object.type !== "Identifier" || inner.object.name !== local || inner.property.type !== "Identifier") {
|
|
264248
|
+
return null;
|
|
264249
|
+
}
|
|
264250
|
+
return { nameNode: inner.property, propertyNode: node.property };
|
|
264224
264251
|
}
|
|
264225
264252
|
function staticValue(node, options2 = {}) {
|
|
264226
264253
|
switch (node.type) {
|
|
@@ -267675,308 +267702,9 @@ function sha256(value) {
|
|
|
267675
267702
|
return createHash("sha256").update(value).digest("hex");
|
|
267676
267703
|
}
|
|
267677
267704
|
|
|
267678
|
-
// scripts/lib/runtime-build/
|
|
267679
|
-
var STYLE_KINDS = /* @__PURE__ */ new Set(["style", "style_module"]);
|
|
267680
|
-
function resolveFileSpecifier(root, from, specifier) {
|
|
267681
|
-
const request2 = specifier.startsWith(APP_PREFIX) ? specifier.slice(APP_PREFIX.length) : posix2.join(posix2.dirname(from), specifier);
|
|
267682
|
-
const path = posix2.normalize(request2);
|
|
267683
|
-
if (path.startsWith("../") || path === ".." || path.startsWith("/")) {
|
|
267684
|
-
return null;
|
|
267685
|
-
}
|
|
267686
|
-
const file2 = checkoutFile(root, path);
|
|
267687
|
-
return file2 !== null && isExactFile(file2) ? path : null;
|
|
267688
|
-
}
|
|
267689
|
-
function declaredPackages(manifest) {
|
|
267690
|
-
return /* @__PURE__ */ new Set([...Object.keys(manifest?.dependencies ?? {}), ...Object.keys(manifest?.peerDependencies ?? {})]);
|
|
267691
|
-
}
|
|
267692
|
-
function ownExports(ast) {
|
|
267693
|
-
const names2 = /* @__PURE__ */ new Set();
|
|
267694
|
-
const starTargets = [];
|
|
267695
|
-
for (const statement2 of ast.program.body) {
|
|
267696
|
-
if (statement2.type === "ExportDefaultDeclaration") {
|
|
267697
|
-
names2.add("default");
|
|
267698
|
-
} else if (statement2.type === "ExportAllDeclaration") {
|
|
267699
|
-
if (statement2.exportKind === "type") {
|
|
267700
|
-
continue;
|
|
267701
|
-
}
|
|
267702
|
-
if (statement2.exported) {
|
|
267703
|
-
names2.add(statement2.exported.name ?? statement2.exported.value);
|
|
267704
|
-
} else {
|
|
267705
|
-
starTargets.push(statement2.source.value);
|
|
267706
|
-
}
|
|
267707
|
-
} else if (statement2.type === "ExportNamedDeclaration" && statement2.exportKind !== "type") {
|
|
267708
|
-
const declaration = statement2.declaration;
|
|
267709
|
-
if (declaration?.type === "VariableDeclaration") {
|
|
267710
|
-
for (const declarator of declaration.declarations) {
|
|
267711
|
-
for (const name of bindingNames(declarator.id)) {
|
|
267712
|
-
names2.add(name);
|
|
267713
|
-
}
|
|
267714
|
-
}
|
|
267715
|
-
} else if (declaration?.id && declaration.type !== "TSTypeAliasDeclaration" && declaration.type !== "TSInterfaceDeclaration" && !declaration.declare) {
|
|
267716
|
-
names2.add(declaration.id.name);
|
|
267717
|
-
}
|
|
267718
|
-
for (const specifier of statement2.specifiers ?? []) {
|
|
267719
|
-
if (specifier.exportKind !== "type") {
|
|
267720
|
-
names2.add(specifier.exported.name ?? specifier.exported.value);
|
|
267721
|
-
}
|
|
267722
|
-
}
|
|
267723
|
-
}
|
|
267724
|
-
}
|
|
267725
|
-
return { names: names2, starTargets };
|
|
267726
|
-
}
|
|
267727
|
-
function bindingNames(pattern) {
|
|
267728
|
-
switch (pattern?.type) {
|
|
267729
|
-
case "Identifier":
|
|
267730
|
-
return [pattern.name];
|
|
267731
|
-
case "ObjectPattern":
|
|
267732
|
-
return pattern.properties.flatMap(
|
|
267733
|
-
(property) => bindingNames(property.type === "RestElement" ? property.argument : property.value)
|
|
267734
|
-
);
|
|
267735
|
-
case "ArrayPattern":
|
|
267736
|
-
return pattern.elements.flatMap((element) => bindingNames(element));
|
|
267737
|
-
case "AssignmentPattern":
|
|
267738
|
-
return bindingNames(pattern.left);
|
|
267739
|
-
case "RestElement":
|
|
267740
|
-
return bindingNames(pattern.argument);
|
|
267741
|
-
default:
|
|
267742
|
-
return [];
|
|
267743
|
-
}
|
|
267744
|
-
}
|
|
267745
|
-
function requestedNames(statement2) {
|
|
267746
|
-
if (statement2 === null || statement2.importKind === "type" || statement2.exportKind === "type") {
|
|
267747
|
-
return [];
|
|
267748
|
-
}
|
|
267749
|
-
if (statement2.type === "ExportAllDeclaration") {
|
|
267750
|
-
return ["*"];
|
|
267751
|
-
}
|
|
267752
|
-
if (statement2.type === "ExportNamedDeclaration") {
|
|
267753
|
-
return (statement2.specifiers ?? []).filter((specifier) => specifier.exportKind !== "type").map((specifier) => specifier.local.name ?? specifier.local.value);
|
|
267754
|
-
}
|
|
267755
|
-
if (statement2.type !== "ImportDeclaration") {
|
|
267756
|
-
return [];
|
|
267757
|
-
}
|
|
267758
|
-
return statement2.specifiers.flatMap((specifier) => {
|
|
267759
|
-
if (specifier.type === "ImportDefaultSpecifier") {
|
|
267760
|
-
return ["default"];
|
|
267761
|
-
}
|
|
267762
|
-
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
267763
|
-
return ["*"];
|
|
267764
|
-
}
|
|
267765
|
-
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type") {
|
|
267766
|
-
return [specifier.imported.name ?? specifier.imported.value];
|
|
267767
|
-
}
|
|
267768
|
-
return [];
|
|
267769
|
-
});
|
|
267770
|
-
}
|
|
267771
|
-
function buildModuleGraph(root, entries, manifest, diagnostics, assetKeys = /* @__PURE__ */ new Set()) {
|
|
267772
|
-
const packages = declaredPackages(manifest);
|
|
267773
|
-
const scannedStyles = /* @__PURE__ */ new Set();
|
|
267774
|
-
const modules = {};
|
|
267775
|
-
const parsed = new Map(entries.map((entry) => [entry.path, entry]));
|
|
267776
|
-
const pending = entries.map((entry) => entry.path);
|
|
267777
|
-
const usedPackages = /* @__PURE__ */ new Set();
|
|
267778
|
-
while (pending.length > 0) {
|
|
267779
|
-
const path = pending.shift();
|
|
267780
|
-
if (Object.hasOwn(modules, path)) {
|
|
267781
|
-
continue;
|
|
267782
|
-
}
|
|
267783
|
-
const kind = importKind(`./${posix2.basename(path)}`);
|
|
267784
|
-
if (STYLE_KINDS.has(kind)) {
|
|
267785
|
-
checkStylesheet(root, path, assetKeys, diagnostics, scannedStyles);
|
|
267786
|
-
modules[path] = { kind, source_sha256: sha256(readFileSync(join3(root, path))), imports: [] };
|
|
267787
|
-
continue;
|
|
267788
|
-
}
|
|
267789
|
-
let entry = parsed.get(path);
|
|
267790
|
-
if (entry === void 0) {
|
|
267791
|
-
const source = readFileSync(join3(root, path), "utf8");
|
|
267792
|
-
try {
|
|
267793
|
-
entry = { path, source, ast: parseSource(source, { jsx: path.endsWith("x") }) };
|
|
267794
|
-
} catch (error) {
|
|
267795
|
-
diagnostics.push(diagnosticAt(path, null, `The module does not parse: ${error.message}`));
|
|
267796
|
-
modules[path] = { kind: "module", source_sha256: sha256(source), imports: [], exports: null };
|
|
267797
|
-
continue;
|
|
267798
|
-
}
|
|
267799
|
-
parsed.set(path, entry);
|
|
267800
|
-
}
|
|
267801
|
-
const comments = entry.ast.comments ?? [];
|
|
267802
|
-
let commentIndex = 0;
|
|
267803
|
-
for (const match of entry.source.matchAll(/url\(\s*['"]?asset:/gi)) {
|
|
267804
|
-
while (commentIndex < comments.length && comments[commentIndex].end <= match.index) {
|
|
267805
|
-
commentIndex++;
|
|
267806
|
-
}
|
|
267807
|
-
if (commentIndex < comments.length && comments[commentIndex].start <= match.index) {
|
|
267808
|
-
continue;
|
|
267809
|
-
}
|
|
267810
|
-
const prefix2 = entry.source.slice(0, match.index);
|
|
267811
|
-
diagnostics.push(
|
|
267812
|
-
diagnostic(
|
|
267813
|
-
path,
|
|
267814
|
-
prefix2.split("\n").length,
|
|
267815
|
-
match.index - prefix2.lastIndexOf("\n"),
|
|
267816
|
-
"asset: URLs work only in CSS files. Move this background into a CSS file"
|
|
267817
|
-
)
|
|
267818
|
-
);
|
|
267819
|
-
}
|
|
267820
|
-
const imports = [];
|
|
267821
|
-
for (const found2 of moduleSpecifiers2(entry.ast)) {
|
|
267822
|
-
if (found2.specifier === null) {
|
|
267823
|
-
diagnostics.push(diagnosticAt(path, found2.node, "A dynamic import must name its module with a string literal"));
|
|
267824
|
-
continue;
|
|
267825
|
-
}
|
|
267826
|
-
if (found2.typeOnly) {
|
|
267827
|
-
continue;
|
|
267828
|
-
}
|
|
267829
|
-
const importType = importKind(found2.specifier);
|
|
267830
|
-
const refused = unsupportedImportMessage(found2.specifier, importType);
|
|
267831
|
-
if (refused !== null) {
|
|
267832
|
-
diagnostics.push(diagnosticAt(path, found2.node, refused));
|
|
267833
|
-
continue;
|
|
267834
|
-
}
|
|
267835
|
-
if (importType === "host") {
|
|
267836
|
-
imports.push({ specifier: found2.specifier, kind: "host", target: found2.specifier, dynamic: found2.dynamic });
|
|
267837
|
-
continue;
|
|
267838
|
-
}
|
|
267839
|
-
if (importType === "package") {
|
|
267840
|
-
if (!packages.has(packageName(found2.specifier))) {
|
|
267841
|
-
diagnostics.push(
|
|
267842
|
-
diagnosticAt(
|
|
267843
|
-
path,
|
|
267844
|
-
found2.node,
|
|
267845
|
-
`"${packageName(found2.specifier)}" is not a dependency. Add it to "dependencies" in package.json`
|
|
267846
|
-
)
|
|
267847
|
-
);
|
|
267848
|
-
continue;
|
|
267849
|
-
}
|
|
267850
|
-
usedPackages.add(found2.specifier);
|
|
267851
|
-
imports.push({
|
|
267852
|
-
specifier: found2.specifier,
|
|
267853
|
-
kind: "package",
|
|
267854
|
-
target: found2.specifier,
|
|
267855
|
-
dynamic: found2.dynamic,
|
|
267856
|
-
package_names: found2.dynamic ? ["*"] : requestedNames(found2.statement)
|
|
267857
|
-
});
|
|
267858
|
-
continue;
|
|
267859
|
-
}
|
|
267860
|
-
const target = importType === "app" ? resolveLocalSpecifier(root, path, found2.specifier) : resolveFileSpecifier(root, path, found2.specifier);
|
|
267861
|
-
if (target === null) {
|
|
267862
|
-
diagnostics.push(diagnosticAt(path, found2.node, `Cannot find "${found2.specifier}" from ${path}`));
|
|
267863
|
-
continue;
|
|
267864
|
-
}
|
|
267865
|
-
imports.push({
|
|
267866
|
-
specifier: found2.specifier,
|
|
267867
|
-
kind: importType,
|
|
267868
|
-
target,
|
|
267869
|
-
dynamic: found2.dynamic,
|
|
267870
|
-
names: requestedNames(found2.statement),
|
|
267871
|
-
node: found2.node
|
|
267872
|
-
});
|
|
267873
|
-
pending.push(target);
|
|
267874
|
-
}
|
|
267875
|
-
modules[path] = { kind: "module", source_sha256: sha256(entry.source), imports, exports: ownExports(entry.ast) };
|
|
267876
|
-
}
|
|
267877
|
-
checkLinkage(modules, diagnostics);
|
|
267878
|
-
for (const module of Object.values(modules)) {
|
|
267879
|
-
for (const item of module.imports) {
|
|
267880
|
-
delete item.node;
|
|
267881
|
-
}
|
|
267882
|
-
delete module.exports;
|
|
267883
|
-
}
|
|
267884
|
-
return { modules, packages: [...usedPackages].toSorted() };
|
|
267885
|
-
}
|
|
267886
|
-
function checkLinkage(modules, diagnostics) {
|
|
267887
|
-
const resolved = /* @__PURE__ */ new Map();
|
|
267888
|
-
const exportsOf = (path, visiting = /* @__PURE__ */ new Set()) => {
|
|
267889
|
-
if (resolved.has(path)) {
|
|
267890
|
-
return resolved.get(path);
|
|
267891
|
-
}
|
|
267892
|
-
const module = modules[path];
|
|
267893
|
-
if (module?.exports === null || module?.exports === void 0 || visiting.has(path)) {
|
|
267894
|
-
return null;
|
|
267895
|
-
}
|
|
267896
|
-
visiting.add(path);
|
|
267897
|
-
const names2 = new Set(module.exports.names);
|
|
267898
|
-
for (const specifier of module.exports.starTargets) {
|
|
267899
|
-
const item = module.imports.find((candidate) => candidate.specifier === specifier);
|
|
267900
|
-
const target = item?.kind === "app" ? exportsOf(item.target, visiting) : null;
|
|
267901
|
-
if (target === null) {
|
|
267902
|
-
resolved.set(path, null);
|
|
267903
|
-
return null;
|
|
267904
|
-
}
|
|
267905
|
-
for (const name of target) {
|
|
267906
|
-
if (name !== "default") {
|
|
267907
|
-
names2.add(name);
|
|
267908
|
-
}
|
|
267909
|
-
}
|
|
267910
|
-
}
|
|
267911
|
-
resolved.set(path, names2);
|
|
267912
|
-
return names2;
|
|
267913
|
-
};
|
|
267914
|
-
for (const [path, module] of Object.entries(modules)) {
|
|
267915
|
-
for (const item of module.imports) {
|
|
267916
|
-
if (item.kind !== "app" || item.names.length === 0) {
|
|
267917
|
-
continue;
|
|
267918
|
-
}
|
|
267919
|
-
const available = exportsOf(item.target);
|
|
267920
|
-
if (available === null) {
|
|
267921
|
-
continue;
|
|
267922
|
-
}
|
|
267923
|
-
for (const name of item.names) {
|
|
267924
|
-
if (name !== "*" && !available.has(name)) {
|
|
267925
|
-
diagnostics.push(
|
|
267926
|
-
diagnosticAt(
|
|
267927
|
-
path,
|
|
267928
|
-
item.node,
|
|
267929
|
-
name === "default" ? `${item.target} has no default export` : `"${name}" is not exported by ${item.target}`
|
|
267930
|
-
)
|
|
267931
|
-
);
|
|
267932
|
-
}
|
|
267933
|
-
}
|
|
267934
|
-
}
|
|
267935
|
-
}
|
|
267936
|
-
}
|
|
267937
|
-
function checkStylesheet(root, path, assetKeys, diagnostics, scanned) {
|
|
267938
|
-
if (scanned.has(path)) {
|
|
267939
|
-
return;
|
|
267940
|
-
}
|
|
267941
|
-
scanned.add(path);
|
|
267942
|
-
const { urls, imports } = cssReferences(readFileSync(join3(root, path), "utf8"));
|
|
267943
|
-
for (const url of urls) {
|
|
267944
|
-
const key = assetUrlKey(url.value);
|
|
267945
|
-
if (key !== null && assetKeys !== null && !assetKeys.has(key)) {
|
|
267946
|
-
diagnostics.push(diagnostic(path, url.line, url.column, `Unknown asset "${key}". Add it to assets.ts`));
|
|
267947
|
-
} else if (!isExternalCssUrl(url.value)) {
|
|
267948
|
-
diagnostics.push(diagnostic(path, url.line, url.column, binaryCssUrlMessage(url.value)));
|
|
267949
|
-
}
|
|
267950
|
-
}
|
|
267951
|
-
for (const target of imports) {
|
|
267952
|
-
if (assetUrlKey(target.value) !== null) {
|
|
267953
|
-
diagnostics.push(
|
|
267954
|
-
diagnostic(path, target.line, target.column, "asset: URLs are only for url() in CSS files")
|
|
267955
|
-
);
|
|
267956
|
-
continue;
|
|
267957
|
-
}
|
|
267958
|
-
if (isExternalCssUrl(target.value)) {
|
|
267959
|
-
continue;
|
|
267960
|
-
}
|
|
267961
|
-
const binary = binaryCssImportMessage(target.value);
|
|
267962
|
-
if (binary !== null) {
|
|
267963
|
-
diagnostics.push(diagnostic(path, target.line, target.column, binary));
|
|
267964
|
-
continue;
|
|
267965
|
-
}
|
|
267966
|
-
const resolved = resolveCssReference(root, path, target.value);
|
|
267967
|
-
if (resolved === null) {
|
|
267968
|
-
diagnostics.push(diagnostic(path, target.line, target.column, `Cannot find "${target.value}" from ${path}`));
|
|
267969
|
-
continue;
|
|
267970
|
-
}
|
|
267971
|
-
checkStylesheet(root, resolved, assetKeys, diagnostics, scanned);
|
|
267972
|
-
}
|
|
267973
|
-
}
|
|
267974
|
-
|
|
267975
|
-
// scripts/lib/runtime-build/page-lint.mjs
|
|
267976
|
-
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
267977
|
-
|
|
267978
|
-
// scripts/lib/lint-jsx-pipeline.mjs
|
|
267705
|
+
// scripts/lib/runtime-build/resource-references.mjs
|
|
267979
267706
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
267707
|
+
import { basename as basename2, extname } from "node:path";
|
|
267980
267708
|
|
|
267981
267709
|
// node_modules/@babel/traverse/lib/index.js
|
|
267982
267710
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
@@ -292222,7 +291950,702 @@ traverse3.hasType = function(tree, type, denylistTypes) {
|
|
|
292222
291950
|
};
|
|
292223
291951
|
traverse3.cache = cache;
|
|
292224
291952
|
|
|
291953
|
+
// scripts/lib/runtime-build/resource-references.mjs
|
|
291954
|
+
var traverse4 = traverse3.default ?? traverse3;
|
|
291955
|
+
var GENERATED_RESOURCES_PATH = "generated/resources.ts";
|
|
291956
|
+
var GENERATED_RESOURCES_MODULE = "@app/generated/resources";
|
|
291957
|
+
var RESOURCES_EXPORT = "Resources";
|
|
291958
|
+
var SLUG_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
291959
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
291960
|
+
function resourceConstName(slug) {
|
|
291961
|
+
return slug.split(/[-_]+/).filter((word) => word !== "").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
291962
|
+
}
|
|
291963
|
+
function resourceNames(paths, diagnostics) {
|
|
291964
|
+
const slugsByName = /* @__PURE__ */ new Map();
|
|
291965
|
+
const namesBySlug = /* @__PURE__ */ new Map();
|
|
291966
|
+
for (const path of paths) {
|
|
291967
|
+
const slug = basename2(path, extname(path));
|
|
291968
|
+
if (!SLUG_PATTERN.test(slug)) {
|
|
291969
|
+
diagnostics.push(
|
|
291970
|
+
diagnosticAt(
|
|
291971
|
+
path,
|
|
291972
|
+
null,
|
|
291973
|
+
`The file name "${slug}" is the resource slug, so it must start with a lowercase letter and contain only a-z, 0-9, _ and -`
|
|
291974
|
+
)
|
|
291975
|
+
);
|
|
291976
|
+
continue;
|
|
291977
|
+
}
|
|
291978
|
+
const name = resourceConstName(slug);
|
|
291979
|
+
const other = slugsByName.get(name);
|
|
291980
|
+
if (other !== void 0) {
|
|
291981
|
+
diagnostics.push(
|
|
291982
|
+
diagnosticAt(
|
|
291983
|
+
path,
|
|
291984
|
+
null,
|
|
291985
|
+
`The slugs "${other}" and "${slug}" both have the name Resources.${name}. Rename one of the files`
|
|
291986
|
+
)
|
|
291987
|
+
);
|
|
291988
|
+
continue;
|
|
291989
|
+
}
|
|
291990
|
+
slugsByName.set(name, slug);
|
|
291991
|
+
namesBySlug.set(slug, name);
|
|
291992
|
+
}
|
|
291993
|
+
return { slugsByName, namesBySlug };
|
|
291994
|
+
}
|
|
291995
|
+
function resourceMetadata(resource) {
|
|
291996
|
+
if (resource.platform) {
|
|
291997
|
+
return { slug: resource.slug, platform: true };
|
|
291998
|
+
}
|
|
291999
|
+
const fields = /* @__PURE__ */ Object.create(null);
|
|
292000
|
+
for (const field2 of resource.fields) {
|
|
292001
|
+
const metadata = {
|
|
292002
|
+
key: field2.key,
|
|
292003
|
+
type: field2.type,
|
|
292004
|
+
label: field2.label,
|
|
292005
|
+
description: field2.description,
|
|
292006
|
+
required: field2.required
|
|
292007
|
+
};
|
|
292008
|
+
if (field2.type === "select") {
|
|
292009
|
+
metadata.options = field2.settings.options.map(
|
|
292010
|
+
({ label, value, color }) => color === void 0 || color === null ? { label, value } : { label, value, color }
|
|
292011
|
+
);
|
|
292012
|
+
}
|
|
292013
|
+
if (field2.type === "relation") {
|
|
292014
|
+
metadata.resource = field2.settings.resource;
|
|
292015
|
+
}
|
|
292016
|
+
fields[field2.key] = metadata;
|
|
292017
|
+
}
|
|
292018
|
+
return {
|
|
292019
|
+
slug: resource.slug,
|
|
292020
|
+
name: resource.name,
|
|
292021
|
+
singularName: resource.singular_name,
|
|
292022
|
+
displayField: resource.display_field,
|
|
292023
|
+
fields
|
|
292024
|
+
};
|
|
292025
|
+
}
|
|
292026
|
+
function resourceEntries({ slugsByName }, resources) {
|
|
292027
|
+
const resourcesBySlug = new Map(resources.map((resource) => [resource.slug, resource]));
|
|
292028
|
+
const entries = /* @__PURE__ */ Object.create(null);
|
|
292029
|
+
for (const name of [...slugsByName.keys()].toSorted(byteOrder)) {
|
|
292030
|
+
const slug = slugsByName.get(name);
|
|
292031
|
+
const resource = resourcesBySlug.get(slug);
|
|
292032
|
+
entries[name] = resource === void 0 ? { slug } : resourceMetadata(resource);
|
|
292033
|
+
}
|
|
292034
|
+
return entries;
|
|
292035
|
+
}
|
|
292036
|
+
function generatedResourcesSource(names2, resources) {
|
|
292037
|
+
return `// AUTO-GENERATED by \`diagonal check\`. Do not edit.
|
|
292038
|
+
export const ${RESOURCES_EXPORT} = ${printLiteral(resourceEntries(names2, resources), 0)} as const;
|
|
292039
|
+
`;
|
|
292040
|
+
}
|
|
292041
|
+
function inlineResources(source, ast, isGeneratedModule, entries, { typescript: typescript2 = false } = {}) {
|
|
292042
|
+
const imports = ast.program.body.filter(
|
|
292043
|
+
(statement2) => statement2.type === "ImportDeclaration" && statement2.importKind !== "type" && isGeneratedModule(statement2.source.value)
|
|
292044
|
+
);
|
|
292045
|
+
const specifiers = new Set(
|
|
292046
|
+
imports.flatMap((statement2) => statement2.specifiers.filter((specifier) => specifier.importKind !== "type"))
|
|
292047
|
+
);
|
|
292048
|
+
const locals = new Set([...specifiers].map((specifier) => specifier.local.name));
|
|
292049
|
+
if (locals.size === 0) {
|
|
292050
|
+
return { source, edits: [], problems: [], otherUses: [] };
|
|
292051
|
+
}
|
|
292052
|
+
const parents = /* @__PURE__ */ new Map();
|
|
292053
|
+
const pending = [ast.program];
|
|
292054
|
+
while (pending.length > 0) {
|
|
292055
|
+
const node = pending.pop();
|
|
292056
|
+
for (const child of childNodes(node)) {
|
|
292057
|
+
parents.set(child, node);
|
|
292058
|
+
pending.push(child);
|
|
292059
|
+
}
|
|
292060
|
+
}
|
|
292061
|
+
const identifiers = [];
|
|
292062
|
+
traverse4(ast, {
|
|
292063
|
+
Identifier(path) {
|
|
292064
|
+
if (locals.has(path.node.name) && specifiers.has(path.scope.getBinding(path.node.name)?.path.node)) {
|
|
292065
|
+
identifiers.push(path.node);
|
|
292066
|
+
}
|
|
292067
|
+
}
|
|
292068
|
+
});
|
|
292069
|
+
const replacements = [];
|
|
292070
|
+
const problems = [];
|
|
292071
|
+
const otherUses = [];
|
|
292072
|
+
for (const identifier4 of identifiers) {
|
|
292073
|
+
const parent = parents.get(identifier4);
|
|
292074
|
+
const typeName = isTypeQueryName(identifier4, parent);
|
|
292075
|
+
if (!typeName && !isValueReference(identifier4, parent, parents.get(parent))) {
|
|
292076
|
+
continue;
|
|
292077
|
+
}
|
|
292078
|
+
let node = identifier4;
|
|
292079
|
+
let value = entries;
|
|
292080
|
+
let path = identifier4.name;
|
|
292081
|
+
let problem = null;
|
|
292082
|
+
for (let next = parents.get(node); memberName(next, node) !== null; next = parents.get(node)) {
|
|
292083
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
292084
|
+
break;
|
|
292085
|
+
}
|
|
292086
|
+
const key = memberName(next, node).name;
|
|
292087
|
+
if (!Object.hasOwn(value, key)) {
|
|
292088
|
+
problem = {
|
|
292089
|
+
node: memberName(next, node),
|
|
292090
|
+
message: node === identifier4 ? `Unknown resource "${path}.${key}". Each name in ${path} is a file in resources/` : `${path} has no "${key}"`
|
|
292091
|
+
};
|
|
292092
|
+
break;
|
|
292093
|
+
}
|
|
292094
|
+
value = value[key];
|
|
292095
|
+
path = `${path}.${key}`;
|
|
292096
|
+
node = next;
|
|
292097
|
+
}
|
|
292098
|
+
if (problem !== null) {
|
|
292099
|
+
problems.push(problem);
|
|
292100
|
+
} else if (typeName) {
|
|
292101
|
+
const query = typeQueryReplacement(node, value, parents);
|
|
292102
|
+
if (query !== null) {
|
|
292103
|
+
replacements.push({
|
|
292104
|
+
start: query.node.start,
|
|
292105
|
+
end: query.node.end,
|
|
292106
|
+
text: keepingLayout(source.slice(query.node.start, query.node.end), query.text)
|
|
292107
|
+
});
|
|
292108
|
+
}
|
|
292109
|
+
} else if (node === identifier4 || isWriteTarget(node, parents.get(node))) {
|
|
292110
|
+
otherUses.push(node);
|
|
292111
|
+
} else {
|
|
292112
|
+
replacements.push({
|
|
292113
|
+
start: node.start,
|
|
292114
|
+
end: node.end,
|
|
292115
|
+
text: keepingLayout(
|
|
292116
|
+
source.slice(node.start, node.end),
|
|
292117
|
+
typescript2 && value !== null ? `(${JSON.stringify(value)} as const)` : `(${JSON.stringify(value)})`
|
|
292118
|
+
)
|
|
292119
|
+
});
|
|
292120
|
+
}
|
|
292121
|
+
}
|
|
292122
|
+
if (problems.length === 0 && otherUses.length === 0) {
|
|
292123
|
+
for (const statement2 of imports) {
|
|
292124
|
+
replacements.push({
|
|
292125
|
+
start: statement2.start,
|
|
292126
|
+
end: statement2.end,
|
|
292127
|
+
text: keepingLayout(source.slice(statement2.start, statement2.end), "")
|
|
292128
|
+
});
|
|
292129
|
+
}
|
|
292130
|
+
}
|
|
292131
|
+
const edits = replacements.toSorted((left, right) => left.start - right.start);
|
|
292132
|
+
let result = source;
|
|
292133
|
+
for (const { start, end, text } of edits.toReversed()) {
|
|
292134
|
+
result = `${result.slice(0, start)}${text}${result.slice(end)}`;
|
|
292135
|
+
}
|
|
292136
|
+
return { source: result, edits, problems, otherUses };
|
|
292137
|
+
}
|
|
292138
|
+
function keepingLayout(original, text) {
|
|
292139
|
+
const lines = original.split("\n");
|
|
292140
|
+
if (lines.length > 1) {
|
|
292141
|
+
return `${text}${"\n".repeat(lines.length - 1)}${" ".repeat(lines.at(-1).length)}`;
|
|
292142
|
+
}
|
|
292143
|
+
return text.padEnd(original.length, " ");
|
|
292144
|
+
}
|
|
292145
|
+
function writtenPosition(inlined, original, line, column) {
|
|
292146
|
+
const offset = offsetOf(inlined.source, line, column);
|
|
292147
|
+
let shift = 0;
|
|
292148
|
+
for (const edit of inlined.edits) {
|
|
292149
|
+
const start = edit.start + shift;
|
|
292150
|
+
if (offset < start) {
|
|
292151
|
+
break;
|
|
292152
|
+
}
|
|
292153
|
+
if (offset < start + edit.text.length) {
|
|
292154
|
+
return positionOf(original, edit.start);
|
|
292155
|
+
}
|
|
292156
|
+
shift += edit.text.length - (edit.end - edit.start);
|
|
292157
|
+
}
|
|
292158
|
+
return positionOf(original, offset - shift);
|
|
292159
|
+
}
|
|
292160
|
+
function offsetOf(text, line, column) {
|
|
292161
|
+
let offset = 0;
|
|
292162
|
+
for (let current = 1; current < line; current++) {
|
|
292163
|
+
const next = text.indexOf("\n", offset);
|
|
292164
|
+
if (next === -1) {
|
|
292165
|
+
return text.length;
|
|
292166
|
+
}
|
|
292167
|
+
offset = next + 1;
|
|
292168
|
+
}
|
|
292169
|
+
return offset + column - 1;
|
|
292170
|
+
}
|
|
292171
|
+
function positionOf(text, offset) {
|
|
292172
|
+
const before = text.slice(0, offset);
|
|
292173
|
+
const lineStart = before.lastIndexOf("\n") + 1;
|
|
292174
|
+
return { line: before.split("\n").length, column: offset - lineStart + 1 };
|
|
292175
|
+
}
|
|
292176
|
+
function memberName(node, object) {
|
|
292177
|
+
if ((node?.type === "MemberExpression" || node?.type === "OptionalMemberExpression") && node.object === object && !node.computed && node.property.type === "Identifier") {
|
|
292178
|
+
return node.property;
|
|
292179
|
+
}
|
|
292180
|
+
return node?.type === "TSQualifiedName" && node.left === object ? node.right : null;
|
|
292181
|
+
}
|
|
292182
|
+
function isTypeQueryName(identifier4, parent) {
|
|
292183
|
+
return parent?.type === "TSTypeQuery" && parent.exprName === identifier4 || parent?.type === "TSQualifiedName" && parent.left === identifier4;
|
|
292184
|
+
}
|
|
292185
|
+
function typeQueryReplacement(name, value, parents) {
|
|
292186
|
+
let node = name;
|
|
292187
|
+
let access = "";
|
|
292188
|
+
for (let next = parents.get(node); next?.type === "TSQualifiedName" && next.left === node; next = parents.get(node)) {
|
|
292189
|
+
access = `${access}[${JSON.stringify(next.right.name)}]`;
|
|
292190
|
+
node = next;
|
|
292191
|
+
}
|
|
292192
|
+
const query = parents.get(node);
|
|
292193
|
+
if (query?.type !== "TSTypeQuery" || query.exprName !== node || (query.typeArguments ?? query.typeParameters ?? null) !== null) {
|
|
292194
|
+
return null;
|
|
292195
|
+
}
|
|
292196
|
+
return { node: query, text: `(${constType(value)})${access}` };
|
|
292197
|
+
}
|
|
292198
|
+
function constType(value) {
|
|
292199
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") {
|
|
292200
|
+
return String(value);
|
|
292201
|
+
}
|
|
292202
|
+
if (typeof value === "string") {
|
|
292203
|
+
return JSON.stringify(value);
|
|
292204
|
+
}
|
|
292205
|
+
if (Array.isArray(value)) {
|
|
292206
|
+
return `readonly [${value.map((item) => constType(item)).join(", ")}]`;
|
|
292207
|
+
}
|
|
292208
|
+
const members = Object.keys(value).map(
|
|
292209
|
+
(key) => `readonly ${IDENTIFIER_KEY.test(key) ? key : JSON.stringify(key)}: ${constType(value[key])}`
|
|
292210
|
+
);
|
|
292211
|
+
return members.length === 0 ? "{}" : `{ ${members.join("; ")} }`;
|
|
292212
|
+
}
|
|
292213
|
+
function isValueReference(identifier4, parent, grandparent) {
|
|
292214
|
+
if (parent === void 0 || parent.type === "ImportSpecifier") {
|
|
292215
|
+
return false;
|
|
292216
|
+
}
|
|
292217
|
+
if (parent.type === "ExportSpecifier") {
|
|
292218
|
+
return parent.local === identifier4 && (grandparent?.source ?? null) === null;
|
|
292219
|
+
}
|
|
292220
|
+
if ((parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && parent.property === identifier4 && !parent.computed) {
|
|
292221
|
+
return false;
|
|
292222
|
+
}
|
|
292223
|
+
if ((parent.type === "ObjectProperty" || parent.type === "ObjectMethod") && parent.key === identifier4 && !parent.computed && !parent.shorthand) {
|
|
292224
|
+
return false;
|
|
292225
|
+
}
|
|
292226
|
+
return parent.type !== "TSQualifiedName" && parent.type !== "TSTypeQuery";
|
|
292227
|
+
}
|
|
292228
|
+
function isWriteTarget(node, parent) {
|
|
292229
|
+
return parent?.type === "AssignmentExpression" && parent.left === node || parent?.type === "UpdateExpression" || parent?.type === "UnaryExpression" && parent.operator === "delete";
|
|
292230
|
+
}
|
|
292231
|
+
function byteOrder(left, right) {
|
|
292232
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
292233
|
+
}
|
|
292234
|
+
var IDENTIFIER_KEY = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
292235
|
+
function printLiteral(value, depth) {
|
|
292236
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") {
|
|
292237
|
+
return String(value);
|
|
292238
|
+
}
|
|
292239
|
+
if (typeof value === "string") {
|
|
292240
|
+
return quoted(value);
|
|
292241
|
+
}
|
|
292242
|
+
const indent = " ".repeat(depth + 1);
|
|
292243
|
+
const close = " ".repeat(depth);
|
|
292244
|
+
if (Array.isArray(value)) {
|
|
292245
|
+
return value.length === 0 ? "[]" : `[
|
|
292246
|
+
${value.map((item) => `${indent}${printLiteral(item, depth + 1)}`).join(",\n")}
|
|
292247
|
+
${close}]`;
|
|
292248
|
+
}
|
|
292249
|
+
const keys2 = Object.keys(value);
|
|
292250
|
+
return keys2.length === 0 ? "{}" : `{
|
|
292251
|
+
${keys2.map((key) => `${indent}${IDENTIFIER_KEY.test(key) ? key : quoted(key)}: ${printLiteral(value[key], depth + 1)}`).join(",\n")}
|
|
292252
|
+
${close}}`;
|
|
292253
|
+
}
|
|
292254
|
+
function quoted(text) {
|
|
292255
|
+
const escaped = text.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
292256
|
+
const singles = (text.match(/'/g) ?? []).length;
|
|
292257
|
+
const doubles = (text.match(/"/g) ?? []).length;
|
|
292258
|
+
return singles > doubles ? `"${escaped.replace(/"/g, '\\"')}"` : `'${escaped.replace(/'/g, "\\'")}'`;
|
|
292259
|
+
}
|
|
292260
|
+
function resourcesBinding(ast, names2) {
|
|
292261
|
+
for (const statement2 of ast.program.body) {
|
|
292262
|
+
if (statement2.type !== "ImportDeclaration" || statement2.source.value !== GENERATED_RESOURCES_MODULE || statement2.importKind === "type") {
|
|
292263
|
+
continue;
|
|
292264
|
+
}
|
|
292265
|
+
for (const specifier of statement2.specifiers) {
|
|
292266
|
+
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && (specifier.imported.name ?? specifier.imported.value) === RESOURCES_EXPORT) {
|
|
292267
|
+
return { local: specifier.local.name, slugsByName: names2.slugsByName };
|
|
292268
|
+
}
|
|
292269
|
+
}
|
|
292270
|
+
}
|
|
292271
|
+
return null;
|
|
292272
|
+
}
|
|
292273
|
+
function referenceProblem(reference, resources, { namesBySlug }) {
|
|
292274
|
+
if (UUID_PATTERN.test(reference)) {
|
|
292275
|
+
return {
|
|
292276
|
+
kind: "id",
|
|
292277
|
+
message: `"${reference}" is a resource id. Refer to a resource by its slug, with Resources.<Name>.slug from ${GENERATED_RESOURCES_MODULE}`
|
|
292278
|
+
};
|
|
292279
|
+
}
|
|
292280
|
+
const named = resources.find(
|
|
292281
|
+
(resource) => resource.name === reference || resource.singular_name === reference
|
|
292282
|
+
);
|
|
292283
|
+
if (named !== void 0) {
|
|
292284
|
+
return {
|
|
292285
|
+
kind: "name",
|
|
292286
|
+
message: `"${reference}" is a name of the resource "${named.slug}". Use Resources.${namesBySlug.get(named.slug)}.slug`
|
|
292287
|
+
};
|
|
292288
|
+
}
|
|
292289
|
+
return {
|
|
292290
|
+
kind: "unknown",
|
|
292291
|
+
message: `Unknown resource "${reference}". Use Resources.<Name>.slug from ${GENERATED_RESOURCES_MODULE}`
|
|
292292
|
+
};
|
|
292293
|
+
}
|
|
292294
|
+
function slugStringWarnings(path, node, { namesBySlug }, options2 = {}) {
|
|
292295
|
+
const warnings2 = [];
|
|
292296
|
+
const pending = [node];
|
|
292297
|
+
while (pending.length > 0) {
|
|
292298
|
+
const current = pending.pop();
|
|
292299
|
+
if (current.type === "ObjectProperty" && !current.computed && (current.key.name ?? current.key.value) === "resource" && current.value.type === "StringLiteral" && namesBySlug.has(current.value.value)) {
|
|
292300
|
+
warnings2.push(
|
|
292301
|
+
diagnosticAt(
|
|
292302
|
+
path,
|
|
292303
|
+
current.value,
|
|
292304
|
+
`Use Resources.${namesBySlug.get(current.value.value)}.slug from ${GENERATED_RESOURCES_MODULE} in place of the string "${current.value.value}"`,
|
|
292305
|
+
{ ...options2, severity: "warning" }
|
|
292306
|
+
)
|
|
292307
|
+
);
|
|
292308
|
+
}
|
|
292309
|
+
pending.push(...childNodes(current));
|
|
292310
|
+
}
|
|
292311
|
+
return warnings2;
|
|
292312
|
+
}
|
|
292313
|
+
|
|
292314
|
+
// scripts/lib/runtime-build/module-graph.mjs
|
|
292315
|
+
var STYLE_KINDS = /* @__PURE__ */ new Set(["style", "style_module"]);
|
|
292316
|
+
function resolveFileSpecifier(root, from, specifier) {
|
|
292317
|
+
const request2 = specifier.startsWith(APP_PREFIX) ? specifier.slice(APP_PREFIX.length) : posix2.join(posix2.dirname(from), specifier);
|
|
292318
|
+
const path = posix2.normalize(request2);
|
|
292319
|
+
if (path.startsWith("../") || path === ".." || path.startsWith("/")) {
|
|
292320
|
+
return null;
|
|
292321
|
+
}
|
|
292322
|
+
const file2 = checkoutFile(root, path);
|
|
292323
|
+
return file2 !== null && isExactFile(file2) ? path : null;
|
|
292324
|
+
}
|
|
292325
|
+
function declaredPackages(manifest) {
|
|
292326
|
+
return /* @__PURE__ */ new Set([...Object.keys(manifest?.dependencies ?? {}), ...Object.keys(manifest?.peerDependencies ?? {})]);
|
|
292327
|
+
}
|
|
292328
|
+
function ownExports(ast) {
|
|
292329
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
292330
|
+
const starTargets = [];
|
|
292331
|
+
for (const statement2 of ast.program.body) {
|
|
292332
|
+
if (statement2.type === "ExportDefaultDeclaration") {
|
|
292333
|
+
names2.add("default");
|
|
292334
|
+
} else if (statement2.type === "ExportAllDeclaration") {
|
|
292335
|
+
if (statement2.exportKind === "type") {
|
|
292336
|
+
continue;
|
|
292337
|
+
}
|
|
292338
|
+
if (statement2.exported) {
|
|
292339
|
+
names2.add(statement2.exported.name ?? statement2.exported.value);
|
|
292340
|
+
} else {
|
|
292341
|
+
starTargets.push(statement2.source.value);
|
|
292342
|
+
}
|
|
292343
|
+
} else if (statement2.type === "ExportNamedDeclaration" && statement2.exportKind !== "type") {
|
|
292344
|
+
const declaration = statement2.declaration;
|
|
292345
|
+
if (declaration?.type === "VariableDeclaration") {
|
|
292346
|
+
for (const declarator of declaration.declarations) {
|
|
292347
|
+
for (const name of bindingNames(declarator.id)) {
|
|
292348
|
+
names2.add(name);
|
|
292349
|
+
}
|
|
292350
|
+
}
|
|
292351
|
+
} else if (declaration?.id && declaration.type !== "TSTypeAliasDeclaration" && declaration.type !== "TSInterfaceDeclaration" && !declaration.declare) {
|
|
292352
|
+
names2.add(declaration.id.name);
|
|
292353
|
+
}
|
|
292354
|
+
for (const specifier of statement2.specifiers ?? []) {
|
|
292355
|
+
if (specifier.exportKind !== "type") {
|
|
292356
|
+
names2.add(specifier.exported.name ?? specifier.exported.value);
|
|
292357
|
+
}
|
|
292358
|
+
}
|
|
292359
|
+
}
|
|
292360
|
+
}
|
|
292361
|
+
return { names: names2, starTargets };
|
|
292362
|
+
}
|
|
292363
|
+
function bindingNames(pattern) {
|
|
292364
|
+
switch (pattern?.type) {
|
|
292365
|
+
case "Identifier":
|
|
292366
|
+
return [pattern.name];
|
|
292367
|
+
case "ObjectPattern":
|
|
292368
|
+
return pattern.properties.flatMap(
|
|
292369
|
+
(property) => bindingNames(property.type === "RestElement" ? property.argument : property.value)
|
|
292370
|
+
);
|
|
292371
|
+
case "ArrayPattern":
|
|
292372
|
+
return pattern.elements.flatMap((element) => bindingNames(element));
|
|
292373
|
+
case "AssignmentPattern":
|
|
292374
|
+
return bindingNames(pattern.left);
|
|
292375
|
+
case "RestElement":
|
|
292376
|
+
return bindingNames(pattern.argument);
|
|
292377
|
+
default:
|
|
292378
|
+
return [];
|
|
292379
|
+
}
|
|
292380
|
+
}
|
|
292381
|
+
function requestedNames(statement2) {
|
|
292382
|
+
if (statement2 === null || statement2.importKind === "type" || statement2.exportKind === "type") {
|
|
292383
|
+
return [];
|
|
292384
|
+
}
|
|
292385
|
+
if (statement2.type === "ExportAllDeclaration") {
|
|
292386
|
+
return ["*"];
|
|
292387
|
+
}
|
|
292388
|
+
if (statement2.type === "ExportNamedDeclaration") {
|
|
292389
|
+
return (statement2.specifiers ?? []).filter((specifier) => specifier.exportKind !== "type").map((specifier) => specifier.local.name ?? specifier.local.value);
|
|
292390
|
+
}
|
|
292391
|
+
if (statement2.type !== "ImportDeclaration") {
|
|
292392
|
+
return [];
|
|
292393
|
+
}
|
|
292394
|
+
return statement2.specifiers.flatMap((specifier) => {
|
|
292395
|
+
if (specifier.type === "ImportDefaultSpecifier") {
|
|
292396
|
+
return ["default"];
|
|
292397
|
+
}
|
|
292398
|
+
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
292399
|
+
return ["*"];
|
|
292400
|
+
}
|
|
292401
|
+
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type") {
|
|
292402
|
+
return [specifier.imported.name ?? specifier.imported.value];
|
|
292403
|
+
}
|
|
292404
|
+
return [];
|
|
292405
|
+
});
|
|
292406
|
+
}
|
|
292407
|
+
function buildModuleGraph(root, entries, manifest, diagnostics, assetKeys = /* @__PURE__ */ new Set(), resourceEntries2 = {}) {
|
|
292408
|
+
const packages = declaredPackages(manifest);
|
|
292409
|
+
const scannedStyles = /* @__PURE__ */ new Set();
|
|
292410
|
+
const modules = {};
|
|
292411
|
+
const parsed = new Map(entries.map((entry) => [entry.path, entry]));
|
|
292412
|
+
const pending = entries.map((entry) => entry.path);
|
|
292413
|
+
const usedPackages = /* @__PURE__ */ new Set();
|
|
292414
|
+
while (pending.length > 0) {
|
|
292415
|
+
const path = pending.shift();
|
|
292416
|
+
if (Object.hasOwn(modules, path)) {
|
|
292417
|
+
continue;
|
|
292418
|
+
}
|
|
292419
|
+
const kind = importKind(`./${posix2.basename(path)}`);
|
|
292420
|
+
if (STYLE_KINDS.has(kind)) {
|
|
292421
|
+
checkStylesheet(root, path, assetKeys, diagnostics, scannedStyles);
|
|
292422
|
+
modules[path] = { kind, source_sha256: sha256(readFileSync(join3(root, path))), imports: [] };
|
|
292423
|
+
continue;
|
|
292424
|
+
}
|
|
292425
|
+
let entry = parsed.get(path);
|
|
292426
|
+
if (entry === void 0) {
|
|
292427
|
+
const source = readFileSync(join3(root, path), "utf8");
|
|
292428
|
+
try {
|
|
292429
|
+
entry = { path, source, ast: parseSource(source, { jsx: path.endsWith("x") }) };
|
|
292430
|
+
} catch (error) {
|
|
292431
|
+
diagnostics.push(diagnosticAt(path, null, `The module does not parse: ${error.message}`));
|
|
292432
|
+
modules[path] = { kind: "module", source_sha256: sha256(source), imports: [], exports: null };
|
|
292433
|
+
continue;
|
|
292434
|
+
}
|
|
292435
|
+
parsed.set(path, entry);
|
|
292436
|
+
}
|
|
292437
|
+
const comments = entry.ast.comments ?? [];
|
|
292438
|
+
let commentIndex = 0;
|
|
292439
|
+
for (const match of entry.source.matchAll(/url\(\s*['"]?asset:/gi)) {
|
|
292440
|
+
while (commentIndex < comments.length && comments[commentIndex].end <= match.index) {
|
|
292441
|
+
commentIndex++;
|
|
292442
|
+
}
|
|
292443
|
+
if (commentIndex < comments.length && comments[commentIndex].start <= match.index) {
|
|
292444
|
+
continue;
|
|
292445
|
+
}
|
|
292446
|
+
const prefix2 = entry.source.slice(0, match.index);
|
|
292447
|
+
diagnostics.push(
|
|
292448
|
+
diagnostic(
|
|
292449
|
+
path,
|
|
292450
|
+
prefix2.split("\n").length,
|
|
292451
|
+
match.index - prefix2.lastIndexOf("\n"),
|
|
292452
|
+
"asset: URLs work only in CSS files. Move this background into a CSS file"
|
|
292453
|
+
)
|
|
292454
|
+
);
|
|
292455
|
+
}
|
|
292456
|
+
const imports = [];
|
|
292457
|
+
for (const found2 of moduleSpecifiers2(entry.ast)) {
|
|
292458
|
+
if (found2.specifier === null) {
|
|
292459
|
+
diagnostics.push(diagnosticAt(path, found2.node, "A dynamic import must name its module with a string literal"));
|
|
292460
|
+
continue;
|
|
292461
|
+
}
|
|
292462
|
+
if (found2.typeOnly) {
|
|
292463
|
+
continue;
|
|
292464
|
+
}
|
|
292465
|
+
const importType = importKind(found2.specifier);
|
|
292466
|
+
const refused = unsupportedImportMessage(found2.specifier, importType);
|
|
292467
|
+
if (refused !== null) {
|
|
292468
|
+
diagnostics.push(diagnosticAt(path, found2.node, refused));
|
|
292469
|
+
continue;
|
|
292470
|
+
}
|
|
292471
|
+
if (importType === "host") {
|
|
292472
|
+
imports.push({ specifier: found2.specifier, kind: "host", target: found2.specifier, dynamic: found2.dynamic });
|
|
292473
|
+
continue;
|
|
292474
|
+
}
|
|
292475
|
+
if (importType === "package") {
|
|
292476
|
+
if (!packages.has(packageName(found2.specifier))) {
|
|
292477
|
+
diagnostics.push(
|
|
292478
|
+
diagnosticAt(
|
|
292479
|
+
path,
|
|
292480
|
+
found2.node,
|
|
292481
|
+
`"${packageName(found2.specifier)}" is not a dependency. Add it to "dependencies" in package.json`
|
|
292482
|
+
)
|
|
292483
|
+
);
|
|
292484
|
+
continue;
|
|
292485
|
+
}
|
|
292486
|
+
usedPackages.add(found2.specifier);
|
|
292487
|
+
imports.push({
|
|
292488
|
+
specifier: found2.specifier,
|
|
292489
|
+
kind: "package",
|
|
292490
|
+
target: found2.specifier,
|
|
292491
|
+
dynamic: found2.dynamic,
|
|
292492
|
+
package_names: found2.dynamic ? ["*"] : requestedNames(found2.statement)
|
|
292493
|
+
});
|
|
292494
|
+
continue;
|
|
292495
|
+
}
|
|
292496
|
+
const target = importType === "app" ? resolveLocalSpecifier(root, path, found2.specifier) : resolveFileSpecifier(root, path, found2.specifier);
|
|
292497
|
+
if (target === null) {
|
|
292498
|
+
diagnostics.push(diagnosticAt(path, found2.node, `Cannot find "${found2.specifier}" from ${path}`));
|
|
292499
|
+
continue;
|
|
292500
|
+
}
|
|
292501
|
+
if (target === GENERATED_RESOURCES_PATH) {
|
|
292502
|
+
imports.push({ specifier: found2.specifier, kind: "resources", target, dynamic: found2.dynamic });
|
|
292503
|
+
continue;
|
|
292504
|
+
}
|
|
292505
|
+
imports.push({
|
|
292506
|
+
specifier: found2.specifier,
|
|
292507
|
+
kind: importType,
|
|
292508
|
+
target,
|
|
292509
|
+
dynamic: found2.dynamic,
|
|
292510
|
+
names: requestedNames(found2.statement),
|
|
292511
|
+
node: found2.node
|
|
292512
|
+
});
|
|
292513
|
+
pending.push(target);
|
|
292514
|
+
}
|
|
292515
|
+
if (imports.some((item) => item.kind === "resources")) {
|
|
292516
|
+
checkResourceReferences(root, entry, resourceEntries2, diagnostics);
|
|
292517
|
+
}
|
|
292518
|
+
modules[path] = { kind: "module", source_sha256: sha256(entry.source), imports, exports: ownExports(entry.ast) };
|
|
292519
|
+
}
|
|
292520
|
+
checkLinkage(modules, diagnostics);
|
|
292521
|
+
for (const module of Object.values(modules)) {
|
|
292522
|
+
for (const item of module.imports) {
|
|
292523
|
+
delete item.node;
|
|
292524
|
+
}
|
|
292525
|
+
delete module.exports;
|
|
292526
|
+
}
|
|
292527
|
+
return { modules, packages: [...usedPackages].toSorted() };
|
|
292528
|
+
}
|
|
292529
|
+
function checkResourceReferences(root, entry, resourceEntries2, diagnostics) {
|
|
292530
|
+
const isGeneratedModule = (specifier) => resolveLocalSpecifier(root, entry.path, specifier) === GENERATED_RESOURCES_PATH;
|
|
292531
|
+
const { problems, otherUses } = inlineResources(entry.source, entry.ast, isGeneratedModule, resourceEntries2);
|
|
292532
|
+
for (const problem of problems) {
|
|
292533
|
+
diagnostics.push(diagnosticAt(entry.path, problem.node, problem.message));
|
|
292534
|
+
}
|
|
292535
|
+
for (const node of otherUses) {
|
|
292536
|
+
diagnostics.push(
|
|
292537
|
+
diagnosticAt(
|
|
292538
|
+
entry.path,
|
|
292539
|
+
node,
|
|
292540
|
+
"Read a value such as Resources.<Name>.slug or Resources.<Name>.fields. The build replaces each reference with its value, so a page cannot use Resources as a whole"
|
|
292541
|
+
)
|
|
292542
|
+
);
|
|
292543
|
+
}
|
|
292544
|
+
for (const found2 of moduleSpecifiers2(entry.ast)) {
|
|
292545
|
+
if (found2.specifier === null || found2.typeOnly || !isGeneratedModule(found2.specifier)) {
|
|
292546
|
+
continue;
|
|
292547
|
+
}
|
|
292548
|
+
if (found2.dynamic) {
|
|
292549
|
+
diagnostics.push(diagnosticAt(entry.path, found2.node, "Import Resources with a static import"));
|
|
292550
|
+
} else if (found2.statement?.type !== "ImportDeclaration") {
|
|
292551
|
+
diagnostics.push(diagnosticAt(entry.path, found2.node, "A page module cannot re-export Resources. Import it where you read it"));
|
|
292552
|
+
}
|
|
292553
|
+
}
|
|
292554
|
+
}
|
|
292555
|
+
function checkLinkage(modules, diagnostics) {
|
|
292556
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
292557
|
+
const exportsOf = (path, visiting = /* @__PURE__ */ new Set()) => {
|
|
292558
|
+
if (resolved.has(path)) {
|
|
292559
|
+
return resolved.get(path);
|
|
292560
|
+
}
|
|
292561
|
+
const module = modules[path];
|
|
292562
|
+
if (module?.exports === null || module?.exports === void 0 || visiting.has(path)) {
|
|
292563
|
+
return null;
|
|
292564
|
+
}
|
|
292565
|
+
visiting.add(path);
|
|
292566
|
+
const names2 = new Set(module.exports.names);
|
|
292567
|
+
for (const specifier of module.exports.starTargets) {
|
|
292568
|
+
const item = module.imports.find((candidate) => candidate.specifier === specifier);
|
|
292569
|
+
const target = item?.kind === "app" ? exportsOf(item.target, visiting) : null;
|
|
292570
|
+
if (target === null) {
|
|
292571
|
+
resolved.set(path, null);
|
|
292572
|
+
return null;
|
|
292573
|
+
}
|
|
292574
|
+
for (const name of target) {
|
|
292575
|
+
if (name !== "default") {
|
|
292576
|
+
names2.add(name);
|
|
292577
|
+
}
|
|
292578
|
+
}
|
|
292579
|
+
}
|
|
292580
|
+
resolved.set(path, names2);
|
|
292581
|
+
return names2;
|
|
292582
|
+
};
|
|
292583
|
+
for (const [path, module] of Object.entries(modules)) {
|
|
292584
|
+
for (const item of module.imports) {
|
|
292585
|
+
if (item.kind !== "app" || item.names.length === 0) {
|
|
292586
|
+
continue;
|
|
292587
|
+
}
|
|
292588
|
+
const available = exportsOf(item.target);
|
|
292589
|
+
if (available === null) {
|
|
292590
|
+
continue;
|
|
292591
|
+
}
|
|
292592
|
+
for (const name of item.names) {
|
|
292593
|
+
if (name !== "*" && !available.has(name)) {
|
|
292594
|
+
diagnostics.push(
|
|
292595
|
+
diagnosticAt(
|
|
292596
|
+
path,
|
|
292597
|
+
item.node,
|
|
292598
|
+
name === "default" ? `${item.target} has no default export` : `"${name}" is not exported by ${item.target}`
|
|
292599
|
+
)
|
|
292600
|
+
);
|
|
292601
|
+
}
|
|
292602
|
+
}
|
|
292603
|
+
}
|
|
292604
|
+
}
|
|
292605
|
+
}
|
|
292606
|
+
function checkStylesheet(root, path, assetKeys, diagnostics, scanned) {
|
|
292607
|
+
if (scanned.has(path)) {
|
|
292608
|
+
return;
|
|
292609
|
+
}
|
|
292610
|
+
scanned.add(path);
|
|
292611
|
+
const { urls, imports } = cssReferences(readFileSync(join3(root, path), "utf8"));
|
|
292612
|
+
for (const url of urls) {
|
|
292613
|
+
const key = assetUrlKey(url.value);
|
|
292614
|
+
if (key !== null && assetKeys !== null && !assetKeys.has(key)) {
|
|
292615
|
+
diagnostics.push(diagnostic(path, url.line, url.column, `Unknown asset "${key}". Add it to assets.ts`));
|
|
292616
|
+
} else if (!isExternalCssUrl(url.value)) {
|
|
292617
|
+
diagnostics.push(diagnostic(path, url.line, url.column, binaryCssUrlMessage(url.value)));
|
|
292618
|
+
}
|
|
292619
|
+
}
|
|
292620
|
+
for (const target of imports) {
|
|
292621
|
+
if (assetUrlKey(target.value) !== null) {
|
|
292622
|
+
diagnostics.push(
|
|
292623
|
+
diagnostic(path, target.line, target.column, "asset: URLs are only for url() in CSS files")
|
|
292624
|
+
);
|
|
292625
|
+
continue;
|
|
292626
|
+
}
|
|
292627
|
+
if (isExternalCssUrl(target.value)) {
|
|
292628
|
+
continue;
|
|
292629
|
+
}
|
|
292630
|
+
const binary = binaryCssImportMessage(target.value);
|
|
292631
|
+
if (binary !== null) {
|
|
292632
|
+
diagnostics.push(diagnostic(path, target.line, target.column, binary));
|
|
292633
|
+
continue;
|
|
292634
|
+
}
|
|
292635
|
+
const resolved = resolveCssReference(root, path, target.value);
|
|
292636
|
+
if (resolved === null) {
|
|
292637
|
+
diagnostics.push(diagnostic(path, target.line, target.column, `Cannot find "${target.value}" from ${path}`));
|
|
292638
|
+
continue;
|
|
292639
|
+
}
|
|
292640
|
+
checkStylesheet(root, resolved, assetKeys, diagnostics, scanned);
|
|
292641
|
+
}
|
|
292642
|
+
}
|
|
292643
|
+
|
|
292644
|
+
// scripts/lib/runtime-build/page-lint.mjs
|
|
292645
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
292646
|
+
|
|
292225
292647
|
// scripts/lib/lint-jsx-pipeline.mjs
|
|
292648
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
292226
292649
|
var import_globals = __toESM(require_globals2(), 1);
|
|
292227
292650
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
292228
292651
|
|
|
@@ -295106,7 +295529,7 @@ function unstableQueryInputs(callPath) {
|
|
|
295106
295529
|
}
|
|
295107
295530
|
|
|
295108
295531
|
// scripts/lib/lint-jsx-pipeline.mjs
|
|
295109
|
-
var
|
|
295532
|
+
var traverse5 = traverse3.default ?? traverse3;
|
|
295110
295533
|
var PERMITTED_GLOBALS = /* @__PURE__ */ new Set([
|
|
295111
295534
|
...Object.keys(import_globals.default.browser),
|
|
295112
295535
|
...Object.keys(import_globals.default.es2025)
|
|
@@ -295367,7 +295790,7 @@ function stageScopeAnalysis(source, extraGlobals) {
|
|
|
295367
295790
|
throw failure("Lint error", error);
|
|
295368
295791
|
}
|
|
295369
295792
|
const undefinedRefs = [];
|
|
295370
|
-
|
|
295793
|
+
traverse5(wrappedAst, {
|
|
295371
295794
|
Program(path) {
|
|
295372
295795
|
for (const [name, node] of Object.entries(path.scope.globals)) {
|
|
295373
295796
|
if (PERMITTED_GLOBALS.has(name) || extraGlobals.has(name)) {
|
|
@@ -295432,7 +295855,7 @@ function stageNullableSdkValues(source) {
|
|
|
295432
295855
|
);
|
|
295433
295856
|
}
|
|
295434
295857
|
};
|
|
295435
|
-
|
|
295858
|
+
traverse5(ast, {
|
|
295436
295859
|
CallExpression: recordUrlCall,
|
|
295437
295860
|
OptionalCallExpression: recordUrlCall,
|
|
295438
295861
|
VariableDeclarator: recordMoneyDestructuring,
|
|
@@ -295500,7 +295923,7 @@ function stageHardcodedApiPaths(source) {
|
|
|
295500
295923
|
column: node.loc?.start.column ?? 0
|
|
295501
295924
|
});
|
|
295502
295925
|
};
|
|
295503
|
-
|
|
295926
|
+
traverse5(ast, {
|
|
295504
295927
|
StringLiteral(path) {
|
|
295505
295928
|
if (isInTypeScriptTypeContext(path)) {
|
|
295506
295929
|
return;
|
|
@@ -295539,7 +295962,7 @@ function stageJsxLiteralEscapes(source) {
|
|
|
295539
295962
|
column: node.loc?.start.column ?? 0
|
|
295540
295963
|
});
|
|
295541
295964
|
};
|
|
295542
|
-
|
|
295965
|
+
traverse5(ast, {
|
|
295543
295966
|
JSXText(path) {
|
|
295544
295967
|
record(path.node.value, path.node, "JSX text");
|
|
295545
295968
|
},
|
|
@@ -295586,7 +296009,7 @@ function stageUnstableQueryInputs(source) {
|
|
|
295586
296009
|
});
|
|
295587
296010
|
}
|
|
295588
296011
|
};
|
|
295589
|
-
|
|
296012
|
+
traverse5(ast, { CallExpression: inspect2, OptionalCallExpression: inspect2 });
|
|
295590
296013
|
if (violations.length > 0) {
|
|
295591
296014
|
const messages = violations.map((v) => `Line ${v.line}:${v.column} \u2014 ${v.message}`);
|
|
295592
296015
|
throw failure("Unstable query input", new Error(messages.join("\n")));
|
|
@@ -295741,114 +296164,6 @@ function lintUnit(unit, catalogs) {
|
|
|
295741
296164
|
return [];
|
|
295742
296165
|
}
|
|
295743
296166
|
|
|
295744
|
-
// scripts/lib/runtime-build/resource-references.mjs
|
|
295745
|
-
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
295746
|
-
import { basename as basename2, extname } from "node:path";
|
|
295747
|
-
var GENERATED_RESOURCES_PATH = "generated/resources.ts";
|
|
295748
|
-
var GENERATED_RESOURCES_MODULE = "@app/generated/resources";
|
|
295749
|
-
var RESOURCES_EXPORT = "Resources";
|
|
295750
|
-
var SLUG_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
295751
|
-
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
295752
|
-
function resourceConstName(slug) {
|
|
295753
|
-
return slug.split(/[-_]+/).filter((word) => word !== "").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
295754
|
-
}
|
|
295755
|
-
function resourceNames(paths, diagnostics) {
|
|
295756
|
-
const slugsByName = /* @__PURE__ */ new Map();
|
|
295757
|
-
const namesBySlug = /* @__PURE__ */ new Map();
|
|
295758
|
-
for (const path of paths) {
|
|
295759
|
-
const slug = basename2(path, extname(path));
|
|
295760
|
-
if (!SLUG_PATTERN.test(slug)) {
|
|
295761
|
-
diagnostics.push(
|
|
295762
|
-
diagnosticAt(
|
|
295763
|
-
path,
|
|
295764
|
-
null,
|
|
295765
|
-
`The file name "${slug}" is the resource slug, so it must start with a lowercase letter and contain only a-z, 0-9, _ and -`
|
|
295766
|
-
)
|
|
295767
|
-
);
|
|
295768
|
-
continue;
|
|
295769
|
-
}
|
|
295770
|
-
const name = resourceConstName(slug);
|
|
295771
|
-
const other = slugsByName.get(name);
|
|
295772
|
-
if (other !== void 0) {
|
|
295773
|
-
diagnostics.push(
|
|
295774
|
-
diagnosticAt(
|
|
295775
|
-
path,
|
|
295776
|
-
null,
|
|
295777
|
-
`The slugs "${other}" and "${slug}" both have the name Resources.${name}. Rename one of the files`
|
|
295778
|
-
)
|
|
295779
|
-
);
|
|
295780
|
-
continue;
|
|
295781
|
-
}
|
|
295782
|
-
slugsByName.set(name, slug);
|
|
295783
|
-
namesBySlug.set(slug, name);
|
|
295784
|
-
}
|
|
295785
|
-
return { slugsByName, namesBySlug };
|
|
295786
|
-
}
|
|
295787
|
-
function generatedResourcesSource({ slugsByName }) {
|
|
295788
|
-
const names2 = [...slugsByName.keys()].toSorted(
|
|
295789
|
-
(left, right) => left < right ? -1 : left > right ? 1 : 0
|
|
295790
|
-
);
|
|
295791
|
-
const body = names2.length === 0 ? "{}" : `{
|
|
295792
|
-
${names2.map((name) => ` ${name}: '${slugsByName.get(name)}'`).join(",\n")}
|
|
295793
|
-
}`;
|
|
295794
|
-
return `// AUTO-GENERATED by \`diagonal check\`. Do not edit.
|
|
295795
|
-
export const ${RESOURCES_EXPORT} = ${body} as const;
|
|
295796
|
-
`;
|
|
295797
|
-
}
|
|
295798
|
-
function resourcesBinding(ast, names2) {
|
|
295799
|
-
for (const statement2 of ast.program.body) {
|
|
295800
|
-
if (statement2.type !== "ImportDeclaration" || statement2.source.value !== GENERATED_RESOURCES_MODULE || statement2.importKind === "type") {
|
|
295801
|
-
continue;
|
|
295802
|
-
}
|
|
295803
|
-
for (const specifier of statement2.specifiers) {
|
|
295804
|
-
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && (specifier.imported.name ?? specifier.imported.value) === RESOURCES_EXPORT) {
|
|
295805
|
-
return { local: specifier.local.name, slugsByName: names2.slugsByName };
|
|
295806
|
-
}
|
|
295807
|
-
}
|
|
295808
|
-
}
|
|
295809
|
-
return null;
|
|
295810
|
-
}
|
|
295811
|
-
function referenceProblem(reference, resources, { namesBySlug }) {
|
|
295812
|
-
if (UUID_PATTERN.test(reference)) {
|
|
295813
|
-
return {
|
|
295814
|
-
kind: "id",
|
|
295815
|
-
message: `"${reference}" is a resource id. Refer to a resource by its slug, with Resources.<Name> from ${GENERATED_RESOURCES_MODULE}`
|
|
295816
|
-
};
|
|
295817
|
-
}
|
|
295818
|
-
const named = resources.find(
|
|
295819
|
-
(resource) => resource.name === reference || resource.singular_name === reference
|
|
295820
|
-
);
|
|
295821
|
-
if (named !== void 0) {
|
|
295822
|
-
return {
|
|
295823
|
-
kind: "name",
|
|
295824
|
-
message: `"${reference}" is a name of the resource "${named.slug}". Use Resources.${namesBySlug.get(named.slug)}`
|
|
295825
|
-
};
|
|
295826
|
-
}
|
|
295827
|
-
return {
|
|
295828
|
-
kind: "unknown",
|
|
295829
|
-
message: `Unknown resource "${reference}". Use Resources.<Name> from ${GENERATED_RESOURCES_MODULE}`
|
|
295830
|
-
};
|
|
295831
|
-
}
|
|
295832
|
-
function slugStringWarnings(path, node, { namesBySlug }, options2 = {}) {
|
|
295833
|
-
const warnings2 = [];
|
|
295834
|
-
const pending = [node];
|
|
295835
|
-
while (pending.length > 0) {
|
|
295836
|
-
const current = pending.pop();
|
|
295837
|
-
if (current.type === "ObjectProperty" && !current.computed && (current.key.name ?? current.key.value) === "resource" && current.value.type === "StringLiteral" && namesBySlug.has(current.value.value)) {
|
|
295838
|
-
warnings2.push(
|
|
295839
|
-
diagnosticAt(
|
|
295840
|
-
path,
|
|
295841
|
-
current.value,
|
|
295842
|
-
`Use Resources.${namesBySlug.get(current.value.value)} from ${GENERATED_RESOURCES_MODULE} in place of the string "${current.value.value}"`,
|
|
295843
|
-
{ ...options2, severity: "warning" }
|
|
295844
|
-
)
|
|
295845
|
-
);
|
|
295846
|
-
}
|
|
295847
|
-
pending.push(...childNodes(current));
|
|
295848
|
-
}
|
|
295849
|
-
return warnings2;
|
|
295850
|
-
}
|
|
295851
|
-
|
|
295852
296167
|
// scripts/lib/runtime-build/resources.mjs
|
|
295853
296168
|
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
295854
296169
|
|
|
@@ -297799,7 +298114,7 @@ function relationSettings(key, builder2, typeCatalog, settings) {
|
|
|
297799
298114
|
const { resource_id: resource, type: relationType, ...rest } = settings;
|
|
297800
298115
|
if (typeof resource !== "string" || resource === "") {
|
|
297801
298116
|
throw new SourceError(
|
|
297802
|
-
`field.relation "${key}" needs "resource": Resources.<Name
|
|
298117
|
+
`field.relation "${key}" needs "resource": Resources.<Name>.slug`,
|
|
297803
298118
|
optionNode(builder2, "resource")
|
|
297804
298119
|
);
|
|
297805
298120
|
}
|
|
@@ -298697,7 +299012,7 @@ function bindingFor(statement2, path) {
|
|
|
298697
299012
|
}
|
|
298698
299013
|
return statements2.join(" ");
|
|
298699
299014
|
}
|
|
298700
|
-
function appModuleClosure(root, imports, external = /* @__PURE__ */ new Set(), { ui = false } = {}) {
|
|
299015
|
+
function appModuleClosure(root, imports, external = /* @__PURE__ */ new Set(), { ui = false, transform: transform3 = null } = {}) {
|
|
298701
299016
|
const modules = /* @__PURE__ */ new Map();
|
|
298702
299017
|
const pending = imports.map((item) => item.path);
|
|
298703
299018
|
while (pending.length > 0) {
|
|
@@ -298705,7 +299020,8 @@ function appModuleClosure(root, imports, external = /* @__PURE__ */ new Set(), {
|
|
|
298705
299020
|
if (modules.has(path)) {
|
|
298706
299021
|
continue;
|
|
298707
299022
|
}
|
|
298708
|
-
const
|
|
299023
|
+
const read = readFileSync4(join6(root, path), "utf8");
|
|
299024
|
+
const source = transform3 === null ? read : transform3(path, read);
|
|
298709
299025
|
const ast = parseModule(path, source);
|
|
298710
299026
|
const requires = {};
|
|
298711
299027
|
const references = ui ? moduleSpecifiers2(ast).filter((item) => item.specifier !== null && !item.typeOnly).map((item) => ({ specifier: item.specifier, source: item.node })) : ast.program.body.filter(
|
|
@@ -299202,7 +299518,7 @@ function pageAuthorizer(meta, nodes) {
|
|
|
299202
299518
|
const resource = value.resource ?? null;
|
|
299203
299519
|
const permissions = value.permissions ?? [];
|
|
299204
299520
|
if (resource !== null && (typeof resource !== "string" || resource === "")) {
|
|
299205
|
-
throw new SourceError('"authorizer.resource" must be Resources.<Name
|
|
299521
|
+
throw new SourceError('"authorizer.resource" must be Resources.<Name>.slug or a resource slug', nodes.authorizer);
|
|
299206
299522
|
}
|
|
299207
299523
|
if (!Array.isArray(permissions) || permissions.some((permission) => typeof permission !== "string" || permission === "")) {
|
|
299208
299524
|
throw new SourceError(
|
|
@@ -299240,7 +299556,7 @@ function pageParams(meta, nodes, route) {
|
|
|
299240
299556
|
const { resource = null, lookupField = null, relations = [], scope: scope2 = null } = binding;
|
|
299241
299557
|
if (typeof resource !== "string" || resource === "") {
|
|
299242
299558
|
throw new SourceError(
|
|
299243
|
-
`"params.${key}.resource" must be Resources.<Name
|
|
299559
|
+
`"params.${key}.resource" must be Resources.<Name>.slug or a resource slug`,
|
|
299244
299560
|
nodes.params
|
|
299245
299561
|
);
|
|
299246
299562
|
}
|
|
@@ -299865,7 +300181,7 @@ function builder(method, call, checker, visiting) {
|
|
|
299865
300181
|
if (!type?.isStringLiteral()) {
|
|
299866
300182
|
throw new SchemaError(
|
|
299867
300183
|
call,
|
|
299868
|
-
"v.record() needs a resource, such as resources.Products from @diagonal/workflow/workspace or Resources.Products from @app/generated/resources in a file-based workspace."
|
|
300184
|
+
"v.record() needs a resource, such as resources.Products from @diagonal/workflow/workspace or Resources.Products.slug from @app/generated/resources in a file-based workspace."
|
|
299869
300185
|
);
|
|
299870
300186
|
}
|
|
299871
300187
|
return base("record", { resource: type.value });
|
|
@@ -299875,7 +300191,7 @@ function builder(method, call, checker, visiting) {
|
|
|
299875
300191
|
if (!type?.isStringLiteral()) {
|
|
299876
300192
|
throw new SchemaError(
|
|
299877
300193
|
call,
|
|
299878
|
-
"v.recordReference() needs a resource, such as resources.Products from @diagonal/workflow/workspace or Resources.Products from @app/generated/resources in a file-based workspace."
|
|
300194
|
+
"v.recordReference() needs a resource, such as resources.Products from @diagonal/workflow/workspace or Resources.Products.slug from @app/generated/resources in a file-based workspace."
|
|
299879
300195
|
);
|
|
299880
300196
|
}
|
|
299881
300197
|
return base("recordReference", {
|
|
@@ -300783,7 +301099,7 @@ function readWorkflowConfig(path, configNode, context) {
|
|
|
300783
301099
|
}
|
|
300784
301100
|
function resolveResource(reference, node, context, report) {
|
|
300785
301101
|
if (typeof reference !== "string" || reference === "") {
|
|
300786
|
-
report(node, '"resource" must be Resources.<Name
|
|
301102
|
+
report(node, '"resource" must be Resources.<Name>.slug');
|
|
300787
301103
|
return null;
|
|
300788
301104
|
}
|
|
300789
301105
|
const resource = context.findResource(reference);
|
|
@@ -301050,7 +301366,7 @@ function fieldTsType(fieldType) {
|
|
|
301050
301366
|
function propertyKey2(name) {
|
|
301051
301367
|
return IDENTIFIER.test(name) ? name : JSON.stringify(name);
|
|
301052
301368
|
}
|
|
301053
|
-
function
|
|
301369
|
+
function byteOrder2(left, right) {
|
|
301054
301370
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
301055
301371
|
}
|
|
301056
301372
|
function scriptWorkspaceDeclarations(resources, platformResources = []) {
|
|
@@ -301058,7 +301374,7 @@ function scriptWorkspaceDeclarations(resources, platformResources = []) {
|
|
|
301058
301374
|
...platformResources.map((resource) => [resource.slug, null]),
|
|
301059
301375
|
...resources.map((resource) => [resource.slug, resource])
|
|
301060
301376
|
]);
|
|
301061
|
-
const slugs = [...resourcesBySlug.keys()].toSorted(
|
|
301377
|
+
const slugs = [...resourcesBySlug.keys()].toSorted(byteOrder2);
|
|
301062
301378
|
const types2 = [];
|
|
301063
301379
|
let usesContent = false;
|
|
301064
301380
|
for (const slug of slugs) {
|
|
@@ -301078,7 +301394,7 @@ function scriptWorkspaceDeclarations(resources, platformResources = []) {
|
|
|
301078
301394
|
input.push(`${key}?: ${type} | null`);
|
|
301079
301395
|
record.push(`${key}: ${type} | null`);
|
|
301080
301396
|
}
|
|
301081
|
-
const capabilities = Object.keys(resource.capabilities ?? {}).toSorted(
|
|
301397
|
+
const capabilities = Object.keys(resource.capabilities ?? {}).toSorted(byteOrder2).map((capability) => `'${capability}'`);
|
|
301082
301398
|
types2.push(
|
|
301083
301399
|
` ${propertyKey2(slug)}: { id: '${slug}'; capabilities: ${capabilities.length === 0 ? "never" : capabilities.join(" | ")}; input: { ${input.join("; ")} }; record: { ${record.join("; ")} } & Record<string, unknown> };`
|
|
301084
301400
|
);
|
|
@@ -301099,9 +301415,9 @@ function scriptWorkspaceDeclarations(resources, platformResources = []) {
|
|
|
301099
301415
|
|
|
301100
301416
|
// scripts/lib/runtime-build/workflows.mjs
|
|
301101
301417
|
var WORKFLOW_EXTERNALS = /* @__PURE__ */ new Set(["@diagonal/workflow", "@diagonal/workflow/workspace"]);
|
|
301102
|
-
function compileScript(path,
|
|
301418
|
+
function compileScript(path, writtenSource, script, workspaceDeclarations, app) {
|
|
301103
301419
|
const result = compileWorkflowScript({
|
|
301104
|
-
source:
|
|
301420
|
+
source: script.source,
|
|
301105
301421
|
sdkFiles: SCRIPT_SDK_FILES,
|
|
301106
301422
|
workspaceDeclarations,
|
|
301107
301423
|
appModules: Object.fromEntries(
|
|
@@ -301111,12 +301427,13 @@ function compileScript(path, scriptSource, workspaceDeclarations, app) {
|
|
|
301111
301427
|
if (!result.ok) {
|
|
301112
301428
|
return {
|
|
301113
301429
|
compiled: null,
|
|
301114
|
-
diagnostics: result.diagnostics.map(
|
|
301115
|
-
|
|
301430
|
+
diagnostics: result.diagnostics.map((item) => {
|
|
301431
|
+
const position2 = writtenPosition(script, writtenSource, item.line, item.column);
|
|
301432
|
+
return diagnostic(path, position2.line, position2.column, `${item.message} [${item.code}]`, {
|
|
301116
301433
|
stage: WORKFLOW_STAGE,
|
|
301117
301434
|
severity: item.severity
|
|
301118
|
-
})
|
|
301119
|
-
)
|
|
301435
|
+
});
|
|
301436
|
+
})
|
|
301120
301437
|
};
|
|
301121
301438
|
}
|
|
301122
301439
|
return {
|
|
@@ -301127,18 +301444,38 @@ function compileScript(path, scriptSource, workspaceDeclarations, app) {
|
|
|
301127
301444
|
diagnostics: []
|
|
301128
301445
|
};
|
|
301129
301446
|
}
|
|
301130
|
-
function workflowAppImports(root, path, ast, diagnostics) {
|
|
301447
|
+
function workflowAppImports(root, path, ast, inline, diagnostics) {
|
|
301131
301448
|
if (root === null) {
|
|
301132
301449
|
return { imports: [], modules: /* @__PURE__ */ new Map() };
|
|
301133
301450
|
}
|
|
301134
301451
|
try {
|
|
301135
301452
|
const imports = appImportsOf(root, path, ast);
|
|
301136
|
-
return {
|
|
301453
|
+
return {
|
|
301454
|
+
imports,
|
|
301455
|
+
modules: appModuleClosure(root, imports, WORKFLOW_EXTERNALS, {
|
|
301456
|
+
transform: inline === null ? null : (modulePath, source) => inline(modulePath, source).source
|
|
301457
|
+
})
|
|
301458
|
+
};
|
|
301137
301459
|
} catch (error) {
|
|
301138
301460
|
diagnostics.push({ ...diagnosticFromError(path, error), stage: WORKFLOW_STAGE });
|
|
301139
301461
|
return { imports: [], modules: /* @__PURE__ */ new Map() };
|
|
301140
301462
|
}
|
|
301141
301463
|
}
|
|
301464
|
+
function resourceInliner(root, entries) {
|
|
301465
|
+
return (path, source) => {
|
|
301466
|
+
const isGeneratedModule = (specifier) => root === null ? false : resolveLocalSpecifier(root, path, specifier) === GENERATED_RESOURCES_PATH;
|
|
301467
|
+
let ast;
|
|
301468
|
+
try {
|
|
301469
|
+
ast = parseSource(source, { jsx: false });
|
|
301470
|
+
} catch (error) {
|
|
301471
|
+
if (error instanceof SyntaxError) {
|
|
301472
|
+
return { source, edits: [], problems: [], otherUses: [] };
|
|
301473
|
+
}
|
|
301474
|
+
throw error;
|
|
301475
|
+
}
|
|
301476
|
+
return inlineResources(source, ast, isGeneratedModule, entries, { typescript: /\.tsx?$/.test(path) });
|
|
301477
|
+
};
|
|
301478
|
+
}
|
|
301142
301479
|
function reportDuplicateTriggers(workflows, diagnostics) {
|
|
301143
301480
|
const seen = /* @__PURE__ */ new Map();
|
|
301144
301481
|
for (const workflow of workflows) {
|
|
@@ -301173,6 +301510,7 @@ function buildWorkflows({
|
|
|
301173
301510
|
platformResources = [],
|
|
301174
301511
|
resourcesComplete,
|
|
301175
301512
|
names: names2,
|
|
301513
|
+
resourceEntries: resourceEntries2 = {},
|
|
301176
301514
|
root = null
|
|
301177
301515
|
}) {
|
|
301178
301516
|
const diagnostics = [];
|
|
@@ -301191,14 +301529,27 @@ function buildWorkflows({
|
|
|
301191
301529
|
workflowPaths: new Set(workflows.map((workflow) => workflow.path)),
|
|
301192
301530
|
reportUnknownResources: resourcesComplete
|
|
301193
301531
|
};
|
|
301194
|
-
const
|
|
301532
|
+
const inline = resourceInliner(root, resourceEntries2);
|
|
301533
|
+
const testModules = /* @__PURE__ */ new Map();
|
|
301195
301534
|
const built = workflows.map(({ path, source, ast }) => {
|
|
301196
|
-
const app = workflowAppImports(root, path, ast, diagnostics);
|
|
301197
|
-
for (const [modulePath, module] of app.modules) {
|
|
301198
|
-
appModules.set(modulePath, module);
|
|
301199
|
-
}
|
|
301200
301535
|
const split = splitWorkflowModule(path, source, ast);
|
|
301201
301536
|
diagnostics.push(...split.diagnostics);
|
|
301537
|
+
const script = inline(path, split.scriptSource);
|
|
301538
|
+
for (const problem of script.problems) {
|
|
301539
|
+
diagnostics.push(diagnosticAt(path, problem.node, problem.message, { stage: WORKFLOW_STAGE }));
|
|
301540
|
+
}
|
|
301541
|
+
const app = workflowAppImports(
|
|
301542
|
+
root,
|
|
301543
|
+
path,
|
|
301544
|
+
script.source === split.scriptSource ? ast : parseSource(script.source, { jsx: false }),
|
|
301545
|
+
inline,
|
|
301546
|
+
diagnostics
|
|
301547
|
+
);
|
|
301548
|
+
if (tests.length > 0) {
|
|
301549
|
+
for (const [modulePath, module] of workflowAppImports(root, path, ast, null, []).modules) {
|
|
301550
|
+
testModules.set(modulePath, module);
|
|
301551
|
+
}
|
|
301552
|
+
}
|
|
301202
301553
|
const read = split.configNode === null ? { config: null, diagnostics: [] } : readWorkflowConfig(path, split.configNode, {
|
|
301203
301554
|
...context,
|
|
301204
301555
|
resourcesBinding: resourcesBinding(ast, names2)
|
|
@@ -301209,7 +301560,7 @@ function buildWorkflows({
|
|
|
301209
301560
|
...slugStringWarnings(path, split.configNode, names2, { stage: WORKFLOW_STAGE })
|
|
301210
301561
|
);
|
|
301211
301562
|
}
|
|
301212
|
-
const compiled = resourcesComplete ? compileScript(path, split.scriptSource, workspaceDeclarations, app) : { compiled: null, diagnostics: [] };
|
|
301563
|
+
const compiled = resourcesComplete ? compileScript(path, split.scriptSource, script, workspaceDeclarations, app) : { compiled: null, diagnostics: [] };
|
|
301213
301564
|
diagnostics.push(...compiled.diagnostics);
|
|
301214
301565
|
const config = read.config;
|
|
301215
301566
|
return {
|
|
@@ -301232,7 +301583,7 @@ function buildWorkflows({
|
|
|
301232
301583
|
built.filter((workflow) => workflow.type !== null),
|
|
301233
301584
|
diagnostics
|
|
301234
301585
|
);
|
|
301235
|
-
const testRun = runWorkflowTests({ tests, workflows, root, appModules });
|
|
301586
|
+
const testRun = runWorkflowTests({ tests, workflows, root, appModules: testModules });
|
|
301236
301587
|
diagnostics.push(...testRun.diagnostics);
|
|
301237
301588
|
return { workflows: built, workflowTests: testRun.workflowTests, diagnostics };
|
|
301238
301589
|
}
|
|
@@ -301450,26 +301801,17 @@ function checkPageResources(pages, resources, platformSlugs, names2, diagnostics
|
|
|
301450
301801
|
}
|
|
301451
301802
|
}
|
|
301452
301803
|
}
|
|
301453
|
-
function
|
|
301454
|
-
const expected = generatedResourcesSource(names2);
|
|
301804
|
+
function writeGeneratedResources(root, names2, resources) {
|
|
301455
301805
|
const path = join10(root, GENERATED_RESOURCES_PATH);
|
|
301456
|
-
|
|
301457
|
-
if (current === expected || current === null && names2.slugsByName.size === 0) {
|
|
301806
|
+
if (names2.slugsByName.size === 0 && !existsSync4(path)) {
|
|
301458
301807
|
return;
|
|
301459
301808
|
}
|
|
301460
|
-
|
|
301461
|
-
|
|
301462
|
-
writeFileSync3(path, expected);
|
|
301809
|
+
const source = generatedResourcesSource(names2, resources);
|
|
301810
|
+
if (existsSync4(path) && readFileSync7(path, "utf8") === source) {
|
|
301463
301811
|
return;
|
|
301464
301812
|
}
|
|
301465
|
-
|
|
301466
|
-
|
|
301467
|
-
GENERATED_RESOURCES_PATH,
|
|
301468
|
-
null,
|
|
301469
|
-
`${current === null ? "The file is missing" : "The file does not match the resources/ folder"}. Run \`diagonal check\` to write it, or write this content:
|
|
301470
|
-
${expected.trimEnd()}`
|
|
301471
|
-
)
|
|
301472
|
-
);
|
|
301813
|
+
mkdirSync2(dirname6(path), { recursive: true });
|
|
301814
|
+
writeFileSync3(path, source);
|
|
301473
301815
|
}
|
|
301474
301816
|
function lintUnits(units, resources, components, pages, diagnostics) {
|
|
301475
301817
|
const catalogs = {
|
|
@@ -301519,26 +301861,25 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301519
301861
|
files.filter((path) => classify(path) === "resource"),
|
|
301520
301862
|
diagnostics
|
|
301521
301863
|
);
|
|
301522
|
-
syncGeneratedResources(root, names2, writeSource, diagnostics);
|
|
301523
301864
|
const uiEntries = [];
|
|
301524
301865
|
const failedLayouts = /* @__PURE__ */ new Set();
|
|
301525
301866
|
const failedComponents = /* @__PURE__ */ new Set();
|
|
301526
301867
|
const failedPageKeys = [];
|
|
301527
|
-
|
|
301868
|
+
const buildFile = (path) => {
|
|
301528
301869
|
const kind = classify(path);
|
|
301529
301870
|
if (kind === "ignored") {
|
|
301530
|
-
|
|
301871
|
+
return;
|
|
301531
301872
|
}
|
|
301532
301873
|
if (kind === "unknown") {
|
|
301533
301874
|
diagnostics.push(
|
|
301534
301875
|
diagnosticAt(path, null, BINARY_EXTENSIONS.has(extname2(path).toLowerCase()) ? BINARY_FILE_MESSAGE : "The build does not know this file. Move or rename it")
|
|
301535
301876
|
);
|
|
301536
|
-
|
|
301877
|
+
return;
|
|
301537
301878
|
}
|
|
301538
301879
|
const source = readFileSync7(join10(root, path), "utf8");
|
|
301539
301880
|
if (kind === "skill") {
|
|
301540
301881
|
skillFiles.push({ path, content: source });
|
|
301541
|
-
|
|
301882
|
+
return;
|
|
301542
301883
|
}
|
|
301543
301884
|
try {
|
|
301544
301885
|
const ast = parseSource(source, { jsx: extname2(path) === ".tsx" });
|
|
@@ -301598,6 +301939,27 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301598
301939
|
failedComponents.add(stem(path));
|
|
301599
301940
|
}
|
|
301600
301941
|
}
|
|
301942
|
+
};
|
|
301943
|
+
const resourceFiles = files.filter((path) => topDirectory(path) === "resources");
|
|
301944
|
+
const otherFiles = files.filter((path) => topDirectory(path) !== "resources");
|
|
301945
|
+
for (const path of resourceFiles) {
|
|
301946
|
+
buildFile(path);
|
|
301947
|
+
}
|
|
301948
|
+
const resourcesComplete = !diagnostics.some(
|
|
301949
|
+
(diagnostic2) => diagnostic2.path.startsWith("resources/") && diagnostic2.severity === "error"
|
|
301950
|
+
);
|
|
301951
|
+
const platformSlugs = new Set(output.platform_resources.map((resource) => resource.slug));
|
|
301952
|
+
if (resourcesComplete) {
|
|
301953
|
+
checkRelations(output.resources, platformSlugs, names2, diagnostics);
|
|
301954
|
+
addInverseFields(output.resources, diagnostics);
|
|
301955
|
+
checkFieldPaths(output.resources, diagnostics);
|
|
301956
|
+
checkCapabilities(output.resources, platformSlugs, diagnostics);
|
|
301957
|
+
}
|
|
301958
|
+
output.resources = output.resources.map(withoutBuildNodes);
|
|
301959
|
+
writeGeneratedResources(root, names2, [...output.resources, ...output.platform_resources]);
|
|
301960
|
+
const entries = resourceEntries(names2, [...output.resources, ...output.platform_resources]);
|
|
301961
|
+
for (const path of otherFiles) {
|
|
301962
|
+
buildFile(path);
|
|
301601
301963
|
}
|
|
301602
301964
|
const uidCheck = checkDefinitionUids(root, uidDefinitions, { write: writeSource });
|
|
301603
301965
|
diagnostics.push(...uidCheck.diagnostics);
|
|
@@ -301621,18 +301983,9 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301621
301983
|
"component name",
|
|
301622
301984
|
diagnostics
|
|
301623
301985
|
);
|
|
301624
|
-
const resourcesComplete = !diagnostics.some(
|
|
301625
|
-
(diagnostic2) => diagnostic2.path.startsWith("resources/") && diagnostic2.severity === "error"
|
|
301626
|
-
);
|
|
301627
|
-
const platformSlugs = new Set(output.platform_resources.map((resource) => resource.slug));
|
|
301628
301986
|
if (resourcesComplete) {
|
|
301629
|
-
checkRelations(output.resources, platformSlugs, names2, diagnostics);
|
|
301630
|
-
addInverseFields(output.resources, diagnostics);
|
|
301631
|
-
checkFieldPaths(output.resources, diagnostics);
|
|
301632
|
-
checkCapabilities(output.resources, platformSlugs, diagnostics);
|
|
301633
301987
|
checkPageResources(output.pages, output.resources, platformSlugs, names2, diagnostics);
|
|
301634
301988
|
}
|
|
301635
|
-
output.resources = output.resources.map(withoutBuildNodes);
|
|
301636
301989
|
const packageFiles = readPackageFiles(root, diagnostics);
|
|
301637
301990
|
const assetsComplete = !diagnostics.some((diagnostic2) => diagnostic2.path === "assets.ts");
|
|
301638
301991
|
const assetKeys = assetsComplete ? new Set(output.assets.map((asset2) => asset2.key)) : null;
|
|
@@ -301641,7 +301994,8 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301641
301994
|
uiEntries,
|
|
301642
301995
|
packageFiles.manifest,
|
|
301643
301996
|
diagnostics,
|
|
301644
|
-
assetKeys
|
|
301997
|
+
assetKeys,
|
|
301998
|
+
entries
|
|
301645
301999
|
);
|
|
301646
302000
|
const workflowBuild = buildWorkflows({
|
|
301647
302001
|
workflows: workflowFiles,
|
|
@@ -301650,6 +302004,7 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
301650
302004
|
platformResources: output.platform_resources,
|
|
301651
302005
|
resourcesComplete,
|
|
301652
302006
|
names: names2,
|
|
302007
|
+
resourceEntries: entries,
|
|
301653
302008
|
root
|
|
301654
302009
|
});
|
|
301655
302010
|
diagnostics.push(...workflowBuild.diagnostics);
|