@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.
package/dist/index.cjs CHANGED
@@ -2564,6 +2564,7 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
2564
2564
  sourceFile,
2565
2565
  tagName,
2566
2566
  parsedTag,
2567
+ text,
2567
2568
  provenance,
2568
2569
  supportingDeclarations,
2569
2570
  options
@@ -2591,6 +2592,9 @@ function renderSyntheticArgumentExpression(valueKind, argumentText) {
2591
2592
  case "number":
2592
2593
  case "integer":
2593
2594
  case "signedInteger":
2595
+ if (trimmed === "Infinity" || trimmed === "-Infinity" || trimmed === "NaN") {
2596
+ return trimmed;
2597
+ }
2594
2598
  return Number.isFinite(Number(trimmed)) ? trimmed : JSON.stringify(trimmed);
2595
2599
  case "string":
2596
2600
  return JSON.stringify(argumentText);
@@ -2802,7 +2806,7 @@ function hasBuiltinConstraintBroadening(tagName, options) {
2802
2806
  const broadenedTypeId = getBroadenedCustomTypeId(options?.fieldType);
2803
2807
  return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
2804
2808
  }
2805
- function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, provenance, supportingDeclarations, options) {
2809
+ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, rawText, provenance, supportingDeclarations, options) {
2806
2810
  if (!(0, import_internals4.isBuiltinConstraintName)(tagName)) {
2807
2811
  return [];
2808
2812
  }
@@ -2823,8 +2827,10 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2823
2827
  const log = (0, import_internal4.getBuildLogger)();
2824
2828
  const broadeningLog = (0, import_internal4.getBroadeningLogger)();
2825
2829
  const syntheticLog = (0, import_internal4.getSyntheticLogger)();
2830
+ const typedParserLog = (0, import_internal4.getTypedParserLogger)();
2826
2831
  const logsEnabled = log !== import_core3.noopLogger || broadeningLog !== import_core3.noopLogger;
2827
2832
  const syntheticTraceEnabled = syntheticLog !== import_core3.noopLogger;
2833
+ const typedParserTraceEnabled = typedParserLog !== import_core3.noopLogger;
2828
2834
  const logStart = logsEnabled ? (0, import_internal4.nowMicros)() : 0;
2829
2835
  const subjectTypeKind = logsEnabled ? (0, import_internal4.describeTypeKind)(subjectType, checker) : "";
2830
2836
  function emit(outcome, result2) {
@@ -2932,16 +2938,57 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2932
2938
  ]);
2933
2939
  }
2934
2940
  }
2935
- const argumentExpression = renderSyntheticArgumentExpression(
2936
- definition.valueKind,
2937
- parsedTag?.argumentText ?? ""
2938
- );
2939
- if (definition.requiresArgument && argumentExpression === null) {
2940
- return emit("A-pass", []);
2941
- }
2941
+ const effectiveArgumentText = parsedTag !== null ? (0, import_internal3.parseTagSyntax)(tagName, rawText).argumentText : rawText;
2942
2942
  if (hasBroadening) {
2943
2943
  return emit("bypass", []);
2944
2944
  }
2945
+ const typedParseResult = (0, import_internal4.parseTagArgument)(tagName, effectiveArgumentText, "build");
2946
+ if (!typedParseResult.ok) {
2947
+ if (typedParserTraceEnabled) {
2948
+ typedParserLog.trace("typed-parser C-reject", {
2949
+ consumer: "build",
2950
+ tag: tagName,
2951
+ placement: nonNullPlacement,
2952
+ subjectTypeKind: subjectTypeKind !== "" ? subjectTypeKind : "-",
2953
+ roleOutcome: "C-reject",
2954
+ diagnosticCode: typedParseResult.diagnostic.code
2955
+ });
2956
+ }
2957
+ let mappedCode;
2958
+ switch (typedParseResult.diagnostic.code) {
2959
+ case "MISSING_TAG_ARGUMENT":
2960
+ mappedCode = "MISSING_TAG_ARGUMENT";
2961
+ break;
2962
+ case "INVALID_TAG_ARGUMENT":
2963
+ mappedCode = "INVALID_TAG_ARGUMENT";
2964
+ break;
2965
+ case "UNKNOWN_TAG":
2966
+ throw new Error(
2967
+ `Unexpected UNKNOWN_TAG from parseTagArgument("${tagName}") \u2014 tag was resolved via getTagDefinition.`
2968
+ );
2969
+ default: {
2970
+ const _exhaustive = typedParseResult.diagnostic.code;
2971
+ throw new Error(`Unknown diagnostic code: ${String(_exhaustive)}`);
2972
+ }
2973
+ }
2974
+ return emit("C-reject", [
2975
+ makeDiagnostic(mappedCode, typedParseResult.diagnostic.message, provenance)
2976
+ ]);
2977
+ }
2978
+ if (typedParserTraceEnabled) {
2979
+ typedParserLog.trace("typed-parser C-pass", {
2980
+ consumer: "build",
2981
+ tag: tagName,
2982
+ placement: nonNullPlacement,
2983
+ subjectTypeKind: subjectTypeKind !== "" ? subjectTypeKind : "-",
2984
+ roleOutcome: "C-pass",
2985
+ valueKind: typedParseResult.value.kind
2986
+ });
2987
+ }
2988
+ const argumentExpression = renderSyntheticArgumentExpression(
2989
+ definition.valueKind,
2990
+ effectiveArgumentText
2991
+ );
2945
2992
  const subjectTypeText = checker.typeToString(subjectType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
2946
2993
  const hostType = options?.hostType ?? subjectType;
2947
2994
  const hostTypeText = checker.typeToString(hostType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);