@formspec/build 0.1.0-alpha.57 → 0.1.0-alpha.58

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.
@@ -1142,6 +1142,7 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
1142
1142
  sourceFile,
1143
1143
  tagName,
1144
1144
  parsedTag,
1145
+ text,
1145
1146
  provenance,
1146
1147
  supportingDeclarations,
1147
1148
  options
@@ -1169,6 +1170,9 @@ function renderSyntheticArgumentExpression(valueKind, argumentText) {
1169
1170
  case "number":
1170
1171
  case "integer":
1171
1172
  case "signedInteger":
1173
+ if (trimmed === "Infinity" || trimmed === "-Infinity" || trimmed === "NaN") {
1174
+ return trimmed;
1175
+ }
1172
1176
  return Number.isFinite(Number(trimmed)) ? trimmed : JSON.stringify(trimmed);
1173
1177
  case "string":
1174
1178
  return JSON.stringify(argumentText);
@@ -1380,7 +1384,7 @@ function hasBuiltinConstraintBroadening(tagName, options) {
1380
1384
  const broadenedTypeId = getBroadenedCustomTypeId(options?.fieldType);
1381
1385
  return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
1382
1386
  }
1383
- function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, provenance, supportingDeclarations, options) {
1387
+ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, rawText, provenance, supportingDeclarations, options) {
1384
1388
  if (!(0, import_internals3.isBuiltinConstraintName)(tagName)) {
1385
1389
  return [];
1386
1390
  }
@@ -1401,8 +1405,10 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1401
1405
  const log = (0, import_internal3.getBuildLogger)();
1402
1406
  const broadeningLog = (0, import_internal3.getBroadeningLogger)();
1403
1407
  const syntheticLog = (0, import_internal3.getSyntheticLogger)();
1408
+ const typedParserLog = (0, import_internal3.getTypedParserLogger)();
1404
1409
  const logsEnabled = log !== import_core.noopLogger || broadeningLog !== import_core.noopLogger;
1405
1410
  const syntheticTraceEnabled = syntheticLog !== import_core.noopLogger;
1411
+ const typedParserTraceEnabled = typedParserLog !== import_core.noopLogger;
1406
1412
  const logStart = logsEnabled ? (0, import_internal3.nowMicros)() : 0;
1407
1413
  const subjectTypeKind = logsEnabled ? (0, import_internal3.describeTypeKind)(subjectType, checker) : "";
1408
1414
  function emit(outcome, result2) {
@@ -1510,16 +1516,57 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1510
1516
  ]);
1511
1517
  }
1512
1518
  }
1513
- const argumentExpression = renderSyntheticArgumentExpression(
1514
- definition.valueKind,
1515
- parsedTag?.argumentText ?? ""
1516
- );
1517
- if (definition.requiresArgument && argumentExpression === null) {
1518
- return emit("A-pass", []);
1519
- }
1519
+ const effectiveArgumentText = parsedTag !== null ? (0, import_internal2.parseTagSyntax)(tagName, rawText).argumentText : rawText;
1520
1520
  if (hasBroadening) {
1521
1521
  return emit("bypass", []);
1522
1522
  }
1523
+ const typedParseResult = (0, import_internal3.parseTagArgument)(tagName, effectiveArgumentText, "build");
1524
+ if (!typedParseResult.ok) {
1525
+ if (typedParserTraceEnabled) {
1526
+ typedParserLog.trace("typed-parser C-reject", {
1527
+ consumer: "build",
1528
+ tag: tagName,
1529
+ placement: nonNullPlacement,
1530
+ subjectTypeKind: subjectTypeKind !== "" ? subjectTypeKind : "-",
1531
+ roleOutcome: "C-reject",
1532
+ diagnosticCode: typedParseResult.diagnostic.code
1533
+ });
1534
+ }
1535
+ let mappedCode;
1536
+ switch (typedParseResult.diagnostic.code) {
1537
+ case "MISSING_TAG_ARGUMENT":
1538
+ mappedCode = "MISSING_TAG_ARGUMENT";
1539
+ break;
1540
+ case "INVALID_TAG_ARGUMENT":
1541
+ mappedCode = "INVALID_TAG_ARGUMENT";
1542
+ break;
1543
+ case "UNKNOWN_TAG":
1544
+ throw new Error(
1545
+ `Unexpected UNKNOWN_TAG from parseTagArgument("${tagName}") \u2014 tag was resolved via getTagDefinition.`
1546
+ );
1547
+ default: {
1548
+ const _exhaustive = typedParseResult.diagnostic.code;
1549
+ throw new Error(`Unknown diagnostic code: ${String(_exhaustive)}`);
1550
+ }
1551
+ }
1552
+ return emit("C-reject", [
1553
+ makeDiagnostic(mappedCode, typedParseResult.diagnostic.message, provenance)
1554
+ ]);
1555
+ }
1556
+ if (typedParserTraceEnabled) {
1557
+ typedParserLog.trace("typed-parser C-pass", {
1558
+ consumer: "build",
1559
+ tag: tagName,
1560
+ placement: nonNullPlacement,
1561
+ subjectTypeKind: subjectTypeKind !== "" ? subjectTypeKind : "-",
1562
+ roleOutcome: "C-pass",
1563
+ valueKind: typedParseResult.value.kind
1564
+ });
1565
+ }
1566
+ const argumentExpression = renderSyntheticArgumentExpression(
1567
+ definition.valueKind,
1568
+ effectiveArgumentText
1569
+ );
1523
1570
  const subjectTypeText = checker.typeToString(subjectType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
1524
1571
  const hostType = options?.hostType ?? subjectType;
1525
1572
  const hostTypeText = checker.typeToString(hostType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);